]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
7 years agoImprove libm-test XFAILing for ibm128-libgcc.
Joseph Myers [Mon, 9 Jan 2017 22:40:59 +0000 (22:40 +0000)] 
Improve libm-test XFAILing for ibm128-libgcc.

This patch further improves XFAILing for ibm128-libgcc of tests in
auto-libm-test-*.

The bulk of the cases needing XFAILing are
xfail-rounding:ibm128-libgcc used for inputs where (possibly after
rounding the inputs to another floating-point type) the result
overflows (and the result in non-default rounding modes may be wildly
wrong with unpatched libgcc) or underflows near 0 (and the result in
non-default rounding modes may end up having the wrong sign).  This
patch makes gen-auto-libm-tests detect such cases and apply
xfail-rounding:ibm128-libgcc automatically to them, so most of the
manual XFAILs in auto-libm-test-in are no longer needed (some are
still needed if e.g. the result is very close to overflow, resulting
in an internal overflow in libgcc in some rounding modes).  A few
manual XFAILs are added for cases not covered by this
gen-auto-libm-tests change, and a few existing such XFAILs are left
in.

Tested for powerpc.

* math/gen-auto-libm-tests.c (output_for_one_input_case): Apply
xfail-rounding:ibm128-libgcc automatically to tests overflowing
and those that can underflow to zero.
* math/auto-libm-test-in: Remove most XFAILs for ibm128-libgcc and
add others.
* math/auto-libm-test-out: Regenerated.

7 years agoFix math/test-fenv for no-exceptions / no-rounding-modes configurations.
Joseph Myers [Mon, 9 Jan 2017 18:27:49 +0000 (18:27 +0000)] 
Fix math/test-fenv for no-exceptions / no-rounding-modes configurations.

This patch fixes math/test-fenv.c to check EXCEPTION_TESTS and
ROUNDING_TESTS to avoid failing in cases where some exceptions or
rounding modes are defined but not supported at runtime.

Tested for mips64 soft float and for x86_64.

* math/test-fenv.c (fe_tests): Skip most tests when exceptions not
supported.
(feholdexcept_tests): Skip tests requiring exceptions or rounding
modes support if not supported.

7 years agoUpdate MicroBlaze localplt.data.
Joseph Myers [Mon, 9 Jan 2017 16:09:53 +0000 (16:09 +0000)] 
Update MicroBlaze localplt.data.

This patch updates the MicroBlaze localplt.data based on the results
of a build with build-many-glibcs.py.  This is simply an empirical
update; quite possibly the port could be optimized to remove more
local PLT entry usage.

Tested (compilation tests) with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/microblaze/localplt.data (__pread64):
Add libc.so PLT entry.
(__tls_get_addr): Make ld.so PLT entry optional.

7 years agoMove fortified explicit_bzero back to string3
Adhemerval Zanella [Fri, 6 Jan 2017 13:05:27 +0000 (11:05 -0200)] 
Move fortified explicit_bzero back to string3

Commit 38765ab68f329fd moved the bzero, bcopy, and explicit_bzero
fortified macros to a common header (strings_fortified.h).  However
the side effect is a fortified explicit_bzero is defined when including
only strings.h.

This patch moves back the fortified explicit_bzero definition to
strings3.h header.

Checked on x86_64-linux-gnu.

* string/bits/strings_fortified.h (explicit_bzero): Move back to ..
* string/bits/string3.h: ... here.

7 years agoMake fallback fesetexceptflag always succeed (bug 21028).
Joseph Myers [Thu, 5 Jan 2017 23:15:47 +0000 (23:15 +0000)] 
Make fallback fesetexceptflag always succeed (bug 21028).

The fallback implementation of fesetexceptflag currently fails if any
exceptions are specified.  It should always succeed, because the
exception state is always that all exceptions (if any are defined in
<fenv.h> but not supported in this configuration) are always clear,
just as fallback fetestexcept always succeeds and fallback fesetenv
always succeeds unless asked to set FE_NOMASK_ENV.

This patch fixes it accordingly.  Together with the patch to
test-fexcept.c to allow feraiseexcept to fail in another place, this
stops that test from failing for MIPS soft-float.

Tested for mips64 soft-float.

[BZ #21028]
* math/fsetexcptflg.c (__fesetexceptflag): Always return 0.
* math/test-fexcept.c (test_set): Allow failure of feraiseexcept
if EXCEPTION_TESTS returns false.

7 years agoUse fortify macros for b{zero,copy} along decl from strings.h
Adhemerval Zanella [Thu, 5 Jan 2017 12:07:24 +0000 (10:07 -0200)] 
Use fortify macros for b{zero,copy} along decl from strings.h

As described in BZ#20558, bzero and bcopy declaration can only benefit
from fortified macros when decl came from string.h and when __USE_MISC
is defined (default behaviour).

This is due no standard includes those functions in string.h, so they
are only declared if __USE_MISC is defined (as pointed out in comment 4).
However fortification should be orthogona to other features test macros,
i.e, any function should be fortified if that function is declared.

To fix this behavior, the patch moved the bzero, bcopy, and
__explicit_bzero_chk to a common header (string/bits/strings_fortified.h)
and explicit fortified inclusion macros similar to string.h is added
on strings.h.  This allows to get fortified declarions by only including
strings.h.

Checked on x86_64-linux-gnu and along on a bootstrap installation to check
if the fortified are correctly triggered with example from bug report.

[BZ #20558]
* string/bits/string3.h [__USE_MISC] (bcopy): Move to
strings_fortified.h.
[__USE_MISC] (bzero): Likewise.
[__USE_MISC] (explicit_bzero): Likewise.
* string/strings.h: Include strings_fortified.h.
* string/Makefile (headers): Add strings_fortified.h.
* string/bits/strings_fortified.h: New file.
* include/bits/strings_fortified.h: Likewise.

7 years agoIncrease some test timeouts.
Joseph Myers [Thu, 5 Jan 2017 17:39:38 +0000 (17:39 +0000)] 
Increase some test timeouts.

This patch increases timeouts on some tests I've observed timing out.

elf/tst-tls13 and iconvdata/tst-loading both dynamically load many
objects and so are slow when testing over NFS.  They had timeouts set
from before the default changed from 2 to 20 seconds; this patch
removes those old settings, so effectively increasing the timeout to
20 seconds (from 3 and 10 seconds respectively).

malloc/tst-malloc-thread-fail.c and malloc/tst-mallocfork2.c are slow
on slow systems and so I set a fairly arbitrary 100 second timeout,
which seems to suffice on the system where I saw them timing out.

nss/tst-cancel-getpwuid_r.c and nss/tst-nss-getpwent.c are slow on
systems with a large passwd file; I set timeouts that empirically
worked for me.  (It seems tst-cancel-getpwuid_r.c is hitting the
100000 getpwuid_r call limit in my testing, with each call taking a
bit over 0.007 seconds, so 700 seconds for the test.)

* elf/tst-tls13.c (TIMEOUT): Remove.
* iconvdata/tst-loading.c (TIMEOUT): Likewise.
* malloc/tst-malloc-thread-fail.c (TIMEOUT): Increase to 100.
* malloc/tst-mallocfork2.c (TIMEOUT): Define to 100.
* nss/tst-cancel-getpwuid_r.c (TIMEOUT): Define to 900.
* nss/tst-nss-getpwent.c (TIMEOUT): Define to 300.

7 years agoFix MIPS n64 readahead (bug 21026).
Joseph Myers [Thu, 5 Jan 2017 17:35:53 +0000 (17:35 +0000)] 
Fix MIPS n64 readahead (bug 21026).

As noted in bug 20126, MIPS n64 uses an incorrect implementation of
readahead intended for 32-bit systems.  This patch adds a
syscalls.list entry to fix this.  An updated version of the
consolidation patch
<https://sourceware.org/ml/libc-alpha/2016-09/msg00527.html> could
remove this syscalls.list entry again.

Tested with compilation (only) for mips64; the nature of the syscall
doesn't allow for a glibc test to detect this issue.

[BZ #21026]
* sysdeps/unix/sysv/linux/mips/mips64/n64/syscalls.list
(readahead): New syscall entry.

7 years agoFix string/tester.c for GCC 7 -Wstringop-overflow=.
Joseph Myers [Wed, 4 Jan 2017 23:33:31 +0000 (23:33 +0000)] 
Fix string/tester.c for GCC 7 -Wstringop-overflow=.

GCC 7 has a -Wstringop-overflow= warning that includes warning for
strncat with a size specified that is larger than the size of the
buffer (which is dubious usage, but valid at runtime if in fact there
isn't an overflow with the particular buffer contents present).
string/tester.c tests such cases; this patch arranges for this warning
to be ignored around relevant strncat calls.

Tested compilation for aarch64 (GCC mainline) with
build-many-glibcs.py; did execution testing for x86_64 (GCC 5).

* string/tester.c (test_strncat): Disable -Wstringop-overflow=
around tests of strncat with large sizes.

7 years agoFix malloc/ tests for GCC 7 -Walloc-size-larger-than=.
Joseph Myers [Wed, 4 Jan 2017 23:32:14 +0000 (23:32 +0000)] 
Fix malloc/ tests for GCC 7 -Walloc-size-larger-than=.

GCC 7 has a -Walloc-size-larger-than= warning for allocations of half
the address space or more.  This causes errors building glibc tests
that deliberately test failure of very large allocations.  This patch
arranges for this warning to be ignored around the problematic
function calls.

Tested compilation for aarch64 (GCC mainline) with
build-many-glibcs.py; did execution testing for x86_64 (GCC 5).

* malloc/tst-malloc.c: Include <libc-internal.h>.
(do_test): Disable -Walloc-size-larger-than= around tests of
malloc with negative sizes.
* malloc/tst-mcheck.c: Include <libc-internal.h>.
(do_test): Disable -Walloc-size-larger-than= around tests of
malloc and realloc with negative sizes.
* malloc/tst-realloc.c: Include <libc-internal.h>.
(do_test): Disable -Walloc-size-larger-than= around tests of
realloc with negative sizes.

7 years agoUpdate libm-test XFAILs for ibm128 format.
Joseph Myers [Wed, 4 Jan 2017 23:29:42 +0000 (23:29 +0000)] 
Update libm-test XFAILs for ibm128 format.

This patch cleans up and updates the libm-test XFAILs for the ibm128
format.  More of them are changed to use a new ibm128-libgcc
conditional, to reflect that they are not in fact needed if you've
patched libgcc to fix the known issues (at substantial performance
cost).  Many additional XFAILs are added for tests that fail with
unpatched libgcc (most but not all of them xfail-rounding).

Note that further such fixes will be needed for test-ldouble actually
to pass with default libgcc (in particular, XFAILs for pow tests and
for various affected tests directly embedded in libm-test.inc).  With
patched libgcc, there may be a few XFAILs needed but the results are
already substantially clean apart from a few ulps differences.

Tested for powerpc.

* math/libm-test.inc (TEST_COND_ibm128_libgcc): New macro.
(init_max_error) [TEST_COND_ibm128]: Increase maximum error
allowed to 16 ulps.
* math/auto-libm-test-in: Change most XFAILs for ibm128 to use
ibm128-libgcc.  XFAIL more tests for ibm128-libgcc.
* math/auto-libm-test-out: Regenerated.

7 years agoMove wrappers to libm-compat-calls-auto
Gabriel F. T. Gomes [Wed, 14 Dec 2016 00:42:51 +0000 (22:42 -0200)] 
Move wrappers to libm-compat-calls-auto

This commit moves one step towards the deprecation of wrappers that
use _LIB_VERSION / matherr / __kernel_standard functionality, by
adding the suffix '_compat' to their filenames and adjusting Makefiles
and #includes accordingly.

New template wrappers that do not use such functionality will be added
by future patches and will be first used by the float128 wrappers.

7 years agoFix MicroBlaze bits/setjmp.h for C++.
Joseph Myers [Wed, 4 Jan 2017 18:12:14 +0000 (18:12 +0000)] 
Fix MicroBlaze bits/setjmp.h for C++.

For MicroBlaze, setjmp/check-installed-headers-cxx fails with:

../setjmp/setjmp.h:34:8: error: '__jmp_buf_tag' has a field '__jmp_buf_tag::__jmpbuf' whose type depends on the type '<unnamed struct>' which has no linkage [-Werror=subobject-linkage]

This patch fixes this in the same way as for some other architectures:
the struct used for the internal __jmp_buf type is given the tag
__jmp_buf_internal_tag.

Tested (compilation tests) with build-many-glibcs.py.

* sysdeps/microblaze/bits/setjmp.h (__jmp_buf): Give struct tag
__jmp_buf_internal_tag.

7 years agoMake MIPS soft-fp preserve NaN payloads for NAN2008.
Joseph Myers [Wed, 4 Jan 2017 17:15:39 +0000 (17:15 +0000)] 
Make MIPS soft-fp preserve NaN payloads for NAN2008.

This corresponds to a patch applied to libgcc.  In glibc it doesn't
actually affect much (only fma, I think).

The MIPS sfp-machine.h files have an _FP_CHOOSENAN implementation
which emulates hardware semantics of not preserving signaling NaN
payloads for an operation with two NaN arguments (although that
doesn't suffice to avoid sNaN payload preservation in any case with
just one NaN argument).

However, those are only hardware semantics in the legacy NaN case; in
the NAN2008 case, the architecture documentation says hardware
preserves payloads in such cases.  Furthermore, this implementation
assumes legacy NaN semantics, so in the NAN2008 case the
implementation actually has the effect of preserving sNaN payloads but
not preserving qNaN payloads, when both should be preserved.

This patch fixes the code just to copy from the first argument.

Tested for mips64 soft-float.

* sysdeps/mips/mips32/sfp-machine.h (_FP_CHOOSENAN): Always
preserve NaN payload if [__mips_nan2008].
* sysdeps/mips/mips64/sfp-machine.h (_FP_CHOOSENAN): Likewise.

7 years agoFix MicroBlaze __backtrace get_frame_size namespace (bug 21022).
Joseph Myers [Wed, 4 Jan 2017 01:06:04 +0000 (01:06 +0000)] 
Fix MicroBlaze __backtrace get_frame_size namespace (bug 21022).

Many linknamespace tests fail for MicroBlaze because __backtrace (as
brought in by libc_fatal.c) uses an inline function get_frame_size
which is not declared static.  This patch fixes it to be declared
static.

Tested (compilation tests) with build-many-glibcs.py.

[BZ #21022]
* sysdeps/microblaze/backtrace.c (get_frame_size): Make static.

7 years agoUpdate i386 libm-test-ulps.
Joseph Myers [Tue, 3 Jan 2017 21:05:46 +0000 (21:05 +0000)] 
Update i386 libm-test-ulps.

When testing changes to i386 libm functions (that are shadowed for
i686 builds by i686 versions) recently, I saw that the plain i386
libm-test-ulps (as opposed to the i686 multiarch version) needed
updating for tests that had been added since it was last updated.
This patch updates it accordingly.

* sysdeps/i386/fpu/libm-test-ulps: Update.

7 years agoRemove duplicate strcat implementations
Adhemerval Zanella [Tue, 3 Jan 2017 19:05:32 +0000 (17:05 -0200)] 
Remove duplicate strcat implementations

Since commit 6e46de42fe16 default strcat implementation is essentially
the same for specialized ia64 and powerpc ones.  This patch removes the
redundant implementation and adjust powerpc64 ifunc code to use the
default one.

Checked on powerpc32-linux-gnu (default and power4) and ia64-linux build
and on powerpc64le-linux-gnu.

* sysdeps/ia64/strcat.c: Remove file.
* sysdeps/powerpc/strcat.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/strcat-power7.c: Use default
C implementation.
* sysdeps/powerpc/powerpc64/multiarch/strcat-power8.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/strcat-ppc64.c: Likewise.

7 years agopowerpc: Fix write-after-destroy in lock elision [BZ #20822]
Tulio Magno Quites Machado Filho [Tue, 3 Jan 2017 19:16:02 +0000 (17:16 -0200)] 
powerpc: Fix write-after-destroy in lock elision [BZ #20822]

The update of *adapt_count after the release of the lock causes a race
condition when thread A unlocks, thread B continues and destroys the
mutex, and thread A writes to *adapt_count.

7 years agoFix math/test-fenvinline for no-exceptions configurations.
Joseph Myers [Tue, 3 Jan 2017 18:45:28 +0000 (18:45 +0000)] 
Fix math/test-fenvinline for no-exceptions configurations.

This patch fixes math/test-fenvinline.c to stop it failing in
no-exceptions configurations (where some exception macros are defined
but may not be supported at runtime).  The relevant parts of the test
are disabled in that case; some parts can still run (and the rounding
mode tests are written in a way such that they work even if the
rounding modes aren't supported).

Tested for mips64 soft-float, and for x86_64 to make sure the tests
still run when the exceptions are supported.

* math/test-fenvinline.c (do_test): Disable tests of raised
exceptions if !EXCEPTION_TESTS (FLOAT).

7 years agoFix x86 strncat optimized implementation for large sizes
Adhemerval Zanella [Tue, 3 Jan 2017 14:19:12 +0000 (12:19 -0200)] 
Fix x86 strncat optimized implementation for large sizes

Similar to BZ#19387, BZ#21014, and BZ#20971, both x86 sse2 strncat
optimized assembly implementations do not handle the size overflow
correctly.

The x86_64 one is in fact an issue with strcpy-sse2-unaligned, but
that is triggered also with strncat optimized implementation.

This patch uses a similar strategy used on 3daef2c8ee4df2, where
saturared math is used for overflow case.

Checked on x86_64-linux-gnu and i686-linux-gnu.  It fixes BZ #19390.

[BZ #19390]
* string/test-strncat.c (test_main): Add tests with SIZE_MAX as
maximum string size.
* sysdeps/i386/i686/multiarch/strcat-sse2.S (STRCAT): Avoid overflow
in pointer addition.
* sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S (STRCPY):
Likewise.

7 years agoFix elf/tst-ldconfig-X for cross testing.
Joseph Myers [Tue, 3 Jan 2017 15:11:17 +0000 (15:11 +0000)] 
Fix elf/tst-ldconfig-X for cross testing.

elf/Makefile passes arguments to tst-ldconfig-X.sh that are different
from what it expects, so resulting in the test failing in cross
testing.  This patch corrects the arguments passed (the script itself
has correct logic for cross testing, it's just the Makefile that's
wrong).

Tested for powerpc (cross testing) and for x86_64 (native testing).

* elf/Makefile ($(objpfx)tst-ldconfig-X.out): Correct arguments
passed to tst-ldconfig-X.sh.

7 years agoFix up tabs/spaces mismatches
Martin Galvan [Mon, 2 Jan 2017 14:35:14 +0000 (11:35 -0300)] 
Fix up tabs/spaces mismatches

Mixing them up breaks the gdb pretty printer tests.

ChangeLog:

2017-01-02  Martin Galvan  <martingalvan@sourceware.org>

* nptl/nptl-printers.py: Fix tabs/spaces mismatches.

7 years agoFix MIPS n32 lseek, lseek64 (bug 21019).
Joseph Myers [Mon, 2 Jan 2017 23:09:25 +0000 (23:09 +0000)] 
Fix MIPS n32 lseek, lseek64 (bug 21019).

The lseek consolidation broke lseek64 for MIPS n32, so resulting in
io/test-lfs failing with an incorrect return from ftello64.  This
configuration uses the lseek syscall with a 64-bit return value; as
the C syscall macros return long, they cannot be used in this case and
so an assembly implementation is needed; accordingly, this patch adds
lseek64 back to syscalls.list for this configuration.

lseek was also broken, truncating the result without checking for
overflow.  lseek however was already broken before the consolidation;
it aliased lseek64 so would return an out-of-range value, resulting in
architecturally undefined behavior in the caller if it tried to use a
non-sign-extended value with a 32-bit instruction.  This patch adds a
custom lseek implementation in C for n32, which calls __lseek64 to get
the 64-bit value then checks for overflow.

Because the prior lseek breakage did not show in test results, and the
lseek64 breakage showed only indirectly through tests of ftello64,
test coverage was clearly inadequate.  This patch extends
io/test-lfs.c to test the lseek64 return value (at a point where it
has already seeked over 2GB into a file), and then to test the lseek
return value (with the latter's expectations depending on whether
off_t is smaller than off64_t).

Tested for mips64 n32.  Also tested test-lfs for x86_64 and x86, where
as expected it passes.

[BZ #21019]
* sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list (lseek64):
New syscall entry.
* sysdeps/unix/sysv/linux/mips/mips64/n32/lseek.c: New file.
* io/test-lfs.c (do_test): Test offset returned from lseek64 and
lseek.

7 years agoAdd build-many-glibcs.py powerpc-linux-gnu-power4 build.
Joseph Myers [Mon, 2 Jan 2017 22:13:42 +0000 (22:13 +0000)] 
Add build-many-glibcs.py powerpc-linux-gnu-power4 build.

The 32-bit powerpc configurations in build-many-glibcs.py were failing
to cover the powerpc32 multiarch code at all, because that code is
only built for power4 and above configurations.  This patch adds a
32-bit power4 configuration so that at least some of that multiarch
code gets build-tested.  (This is preparation for reviewing the w_*
file renaming, which affects such powerpc32 multiarch files.)

* scripts/build-many-glibcs.py (Context.add_all_configs): Add
power4 glibc for powerpc-linux-gnu.

7 years agoFix test-sysvsem on some platforms
Adhemerval Zanella [Mon, 2 Jan 2017 18:19:48 +0000 (16:19 -0200)] 
Fix test-sysvsem on some platforms

The command IPC_STAT of semctl expects an union semun in its fourth
argument instead of struct semid_ds *.  This can cause failures on
powerpc32-linux-gnu.

Checked on x86_64-linux-gnu, i686-linux-gnu, and powerpc32-linux-gnu
(qemu system emulation).

7 years agoFix math/test-nearbyint-except for no-exceptions configurations.
Joseph Myers [Mon, 2 Jan 2017 20:47:17 +0000 (20:47 +0000)] 
Fix math/test-nearbyint-except for no-exceptions configurations.

The test math/test-nearbyint-except conditions some of its tests on an
EXCEPTION_TESTS call, not not all that need such a condition.  This
patch fixes it to use such a conditional for all its tests and to
return 77 (UNSUPPORTED) if none of the floating-point types tested
support exceptions.

Tested for mips64 soft float (where the test previously failed and is
now UNSUPPORTED); also tested for x86_64 to make sure the test still
PASSes in exceptions-supported cases.

* math/test-nearbyint-except.c: Include <stdbool.h>.
(any_supported): New variable.
(TEST_FUNC): Return early if !EXCEPTION_TESTS (FLOAT).  Otherwise
set any_supported.
(do_test): Return 77 if no floating-point type supported
exceptions.

7 years agoCorrect MIPS math-tests.h condition for sNaN payload preservation.
Joseph Myers [Mon, 2 Jan 2017 20:28:36 +0000 (20:28 +0000)] 
Correct MIPS math-tests.h condition for sNaN payload preservation.

Testing for MIPS soft float shows that the issue with NaN payload
preservation applies to soft float as well as hard float: the
sfp-machine.h emulates hardware non-preservation semantics, although
only for the case of two NaN arguments.

This patch duly changes the MIPS math-tests.h to expect such
non-preservation for soft float as well as hard float.  The issue in
the NAN2008 case for which I posted
<https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00034.html>, of sNaN
payloads being preserved but qNaN payloads not being preserved, is not
currently an issue for glibc tests because we don't have any tests
that check for qNaN payloads being preserved by arithmetic, so a
simple __mips_nan2008 conditional suffices without needing compiler
version checks in the __mips_nan2008 case.

Tested for mips64 soft float.

* sysdeps/mips/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD): Do not
condition on [__mips_hard_float].

7 years agoFix i686 memchr for large input sizes
Adhemerval Zanella [Mon, 2 Jan 2017 14:20:21 +0000 (12:20 -0200)] 
Fix i686 memchr for large input sizes

Similar to BZ#19387 and BZ#20971, both i686 memchr optimized assembly
implementations (memchr-sse2-bsf and memchr-sse2) do not handle the
size overflow correctly.

It is shown by the new tests added by commit 3daef2c8ee4df29, where
both implementation fails with size as SIZE_MAX.

This patch uses a similar strategy used on 3daef2c8ee4df2, where
saturared math is used for overflow case.

Checked on i686-linux-gnu.

[BZ #21014]
* sysdeps/i386/i686/multiarch/memchr-sse2-bsf.S (MEMCHR): Avoid overflow
in pointer addition.
* sysdeps/i386/i686/multiarch/memchr-sse2.S (MEMCHR): Likewise.

7 years agoFix pthread_cond_t on sparc for new condvar.
Torvald Riegel [Mon, 2 Jan 2017 14:39:14 +0000 (15:39 +0100)] 
Fix pthread_cond_t on sparc for new condvar.

* sysdeps/sparc/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt to
new condvar.

7 years agoMake build-many-glibcs.py use binutils 2.28 branch by default.
Joseph Myers [Mon, 2 Jan 2017 13:30:03 +0000 (13:30 +0000)] 
Make build-many-glibcs.py use binutils 2.28 branch by default.

Now that a release branch exists for binutils 2.28, this patch makes
build-many-glibcs.py use that by default in place of 2.27.

* scripts/build-many-glibcs.py (Context.checkout): Default
binutils version to 2.28 branch.

7 years agosupport: struct netent portability fix for support_format_netent
Florian Weimer [Sun, 1 Jan 2017 08:35:45 +0000 (09:35 +0100)] 
support: struct netent portability fix for support_format_netent

7 years agosupport: Use %td for pointer difference in xwrite
Florian Weimer [Sun, 1 Jan 2017 08:27:54 +0000 (09:27 +0100)] 
support: Use %td for pointer difference in xwrite

7 years agomalloc: Run tunables tests only if tunables are enabled
Florian Weimer [Sun, 1 Jan 2017 08:27:03 +0000 (09:27 +0100)] 
malloc: Run tunables tests only if tunables are enabled

Otherwise, the environment variable will not have any effect and
the test will fail.

7 years agoUpdate config.guess and config.sub to current versions.
Joseph Myers [Sun, 1 Jan 2017 00:29:55 +0000 (00:29 +0000)] 
Update config.guess and config.sub to current versions.

* scripts/config.guess: Update to version 2017-01-01.
* scripts/config.sub: Update to version 2017-01-01.

7 years agoUpdate copyright dates not handled by scripts/update-copyrights.
Joseph Myers [Sun, 1 Jan 2017 00:26:24 +0000 (00:26 +0000)] 
Update copyright dates not handled by scripts/update-copyrights.

I've updated copyright dates in glibc for 2017.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.

Please remember to include 2017 in the dates for any new files added
in future (which means updating any existing uncommitted patches you
have that add new files to use the new copyright dates in them).

* NEWS: Update copyright dates.
* catgets/gencat.c (print_version): Likewise.
* csu/version.c (banner): Likewise.
* debug/catchsegv.sh: Likewise.
* debug/pcprofiledump.c (print_version): Likewise.
* debug/xtrace.sh (do_version): Likewise.
* elf/ldconfig.c (print_version): Likewise.
* elf/ldd.bash.in: Likewise.
* elf/pldd.c (print_version): Likewise.
* elf/sotruss.sh: Likewise.
* elf/sprof.c (print_version): Likewise.
* iconv/iconv_prog.c (print_version): Likewise.
* iconv/iconvconfig.c (print_version): Likewise.
* locale/programs/locale.c (print_version): Likewise.
* locale/programs/localedef.c (print_version): Likewise.
* login/programs/pt_chown.c (print_version): Likewise.
* malloc/memusage.sh (do_version): Likewise.
* malloc/memusagestat.c (print_version): Likewise.
* malloc/mtrace.pl: Likewise.
* manual/libc.texinfo: Likewise.
* nptl/version.c (banner): Likewise.
* nscd/nscd.c (print_version): Likewise.
* nss/getent.c (print_version): Likewise.
* nss/makedb.c (print_version): Likewise.
* posix/getconf.c (main): Likewise.
* scripts/test-installation.pl: Likewise.
* sysdeps/unix/sysv/linux/lddlibc4.c (main): Likewise.

7 years agoUpdate copyright dates with scripts/update-copyrights.
Joseph Myers [Sun, 1 Jan 2017 00:14:16 +0000 (00:14 +0000)] 
Update copyright dates with scripts/update-copyrights.

7 years agoUpdate DNS RR type definitions [BZ #20593]
Florian Weimer [Sat, 31 Dec 2016 20:16:27 +0000 (21:16 +0100)] 
Update DNS RR type definitions [BZ #20593]

This commit includes a new script which allows generating parts of
the header files from IANA DNS parameters protocol registry.

7 years agoCVE-2015-5180: resolv: Fix crash with internal QTYPE [BZ #18784]
Florian Weimer [Sat, 31 Dec 2016 19:22:09 +0000 (20:22 +0100)] 
CVE-2015-5180: resolv: Fix crash with internal QTYPE [BZ #18784]

Also rename T_UNSPEC because an upcoming public header file
update will use that name.

7 years agotunables: Use correct unused attribute
Florian Weimer [Sat, 31 Dec 2016 19:27:36 +0000 (20:27 +0100)] 
tunables: Use correct unused attribute

7 years agoAdd NEWS item for tunables
Siddhesh Poyarekar [Sat, 31 Dec 2016 18:12:48 +0000 (23:42 +0530)] 
Add NEWS item for tunables

7 years agoUser manual documentation for tunables
Siddhesh Poyarekar [Sat, 31 Dec 2016 18:04:42 +0000 (23:34 +0530)] 
User manual documentation for tunables

Create a new node for tunables documentation and add notes for the
malloc tunables.

* manual/tunables.texi: New chapter.
* manual/Makefile (chapters): Add it.
* manual/probes.texi (@node): Point to the Tunables chapter.

7 years agoEnhance --enable-tunables to select tunables frontend at build time
Siddhesh Poyarekar [Sat, 31 Dec 2016 18:04:04 +0000 (23:34 +0530)] 
Enhance --enable-tunables to select tunables frontend at build time

At the GNU Tools Cauldron 2016, the state of the current tunables
patchset was considered OK with the addition of a way to select the
frontend to be used for the tunables.  That is, to avoid being locked
in to one type of frontend initially, it should be possible to build
tunables with a different frontend with something as simple as a
configure switch.

To that effect, this patch enhances the --enable-tunables option to
accept more values than just 'yes' or 'no'.  The current frontend (and
default when enable-tunables is 'yes') is called 'valstring', to
select the frontend where a single environment variable is set to a
colon-separated value string.  More such frontends can be added in
future.

* Makeconfig (have-tunables): Check for non-negative instead
of positive.
* configure.ac: Add 'valstring' as a valid value for
--enable-tunables.
* configure: Regenerate.
* elf/Makefile (have-tunables): Check for non-negative instead
of positive.
(CPPFLAGS-dl-tunables.c): Define TUNABLES_FRONTEND for
dl-tunables.c.
* elf/dl-tunables.c (GLIBC_TUNABLES): Define only when
TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
(tunables_strdup): Likewise.
(disable_tunables): Likewise.
(parse_tunables): Likewise.
(__tunables_init): Process GLIBC_TUNABLES envvar only when.
TUNABLES_FRONTEND == TUNABLES_FRONTEND_valstring.
* elf/dl-tunables.h (TUNABLES_FRONTEND_valstring): New macro.
(TUNABLES_FRONTEND_yes): New macro, define as
TUNABLES_FRONTEND_valstring by default.
* manual/install.texi: Document new acceptable values for
--enable-tunables.
* INSTALL: Regenerate.

7 years agoInitialize tunable list with the GLIBC_TUNABLES environment variable
Siddhesh Poyarekar [Sat, 31 Dec 2016 18:03:27 +0000 (23:33 +0530)] 
Initialize tunable list with the GLIBC_TUNABLES environment variable

Read tunables values from the users using the GLIBC_TUNABLES
environment variable.  The value of this variable is a colon-separated
list of name=value pairs.  So a typical string would look like this:

GLIBC_TUNABLES=glibc.malloc.mmap_threshold=2048:glibc.malloc.trim_threshold=1024

* config.make.in (have-loop-to-function): Define.
* elf/Makefile (CFLAGS-dl-tunables.c): Add
-fno-tree-loop-distribute-patterns.
* elf/dl-tunables.c: Include libc-internals.h.
(GLIBC_TUNABLES): New macro.
(tunables_strdup): New function.
(parse_tunables): New function.
(min_strlen): New function.
(__tunables_init): Use the new functions and macro.
(disable_tunable): Disable tunable from GLIBC_TUNABLES.
* malloc/tst-malloc-usable-tunables.c: New test case.
* malloc/tst-malloc-usable-static-tunables.c: New test case.
* malloc/Makefile (tests, tests-static): Add tests.

7 years agoAdd framework for tunables
Siddhesh Poyarekar [Sat, 31 Dec 2016 18:02:17 +0000 (23:32 +0530)] 
Add framework for tunables

The tunables framework allows us to uniformly manage and expose global
variables inside glibc as switches to users.  tunables/README has
instructions for glibc developers to add new tunables.

Tunables support can be enabled by passing the --enable-tunables
configure flag to the configure script.  This patch only adds a
framework and does not pose any limitations on how tunable values are
read from the user.  It also adds environment variables used in malloc
behaviour tweaking to the tunables framework as a PoC of the
compatibility interface.

* manual/install.texi: Add --enable-tunables option.
* INSTALL: Regenerate.
* README.tunables: New file.
* Makeconfig (CPPFLAGS): Define TOP_NAMESPACE.
(before-compile): Generate dl-tunable-list.h early.
* config.h.in: Add HAVE_TUNABLES.
* config.make.in: Add have-tunables.
* configure.ac: Add --enable-tunables option.
* configure: Regenerate.
* csu/init-first.c (__libc_init_first): Move
__libc_init_secure earlier...
* csu/init-first.c (LIBC_START_MAIN):... to here.
Include dl-tunables.h, libc-internal.h.
(LIBC_START_MAIN) [!SHARED]: Initialize tunables for static
binaries.
* elf/Makefile (dl-routines): Add dl-tunables.
* elf/Versions (ld): Add __tunable_set_val to GLIBC_PRIVATE
namespace.
* elf/dl-support (_dl_nondynamic_init): Unset MALLOC_CHECK_
only when !HAVE_TUNABLES.
* elf/rtld.c (process_envvars): Likewise.
* elf/dl-sysdep.c [HAVE_TUNABLES]: Include dl-tunables.h
(_dl_sysdep_start): Call __tunables_init.
* elf/dl-tunable-types.h: New file.
* elf/dl-tunables.c: New file.
* elf/dl-tunables.h: New file.
* elf/dl-tunables.list: New file.
* malloc/tst-malloc-usable-static.c: New test case.
* malloc/Makefile (tests-static): Add it.
* malloc/arena.c [HAVE_TUNABLES]: Include dl-tunables.h.
Define TUNABLE_NAMESPACE.
(DL_TUNABLE_CALLBACK (set_mallopt_check)): New function.
(DL_TUNABLE_CALLBACK_FNDECL): New macro.  Use it to define
callback functions.
(ptmalloc_init): Set tunable values.
* scripts/gen-tunables.awk: New file.
* sysdeps/mach/hurd/dl-sysdep.c: Include dl-tunables.h.
(_dl_sysdep_start): Call __tunables_init.

7 years agoresolv: Deprecate RES_BLAST
Florian Weimer [Sat, 31 Dec 2016 18:08:39 +0000 (19:08 +0100)] 
resolv: Deprecate RES_BLAST

7 years agoresolv: Deprecate the "inet6" option and RES_USE_INET6 [BZ #19582]
Florian Weimer [Tue, 4 Oct 2016 09:52:10 +0000 (11:52 +0200)] 
resolv: Deprecate the "inet6" option and RES_USE_INET6 [BZ #19582]

7 years agoresolv: Add beginnings of a libresolv test suite
Florian Weimer [Sat, 31 Dec 2016 13:06:16 +0000 (14:06 +0100)] 
resolv: Add beginnings of a libresolv test suite

7 years agosupport: Implement --verbose option for test programs
Florian Weimer [Sat, 31 Dec 2016 10:01:40 +0000 (11:01 +0100)] 
support: Implement --verbose option for test programs

Some tests can produce rather verbose tracing information,
and the --verbose option provides a standardized way to enable
such logging output.

7 years agosupport: Use support_record_failure consistently
Florian Weimer [Sat, 31 Dec 2016 11:20:49 +0000 (12:20 +0100)] 
support: Use support_record_failure consistently

This causes more test programs to link in the support_record_failure
function, which triggers an early call to mmap from an ELF
constructor, but this should not have side effects intefering
with the functionality actually under test (unlike, say, a call
to malloc).

7 years agosupport: Helper functions for entering namespaces
Florian Weimer [Sat, 31 Dec 2016 17:51:07 +0000 (18:51 +0100)] 
support: Helper functions for entering namespaces

7 years agogetentropy: Declare it in <unistd.h> for __USE_MISC [BZ #17252]
Florian Weimer [Sat, 31 Dec 2016 14:11:29 +0000 (15:11 +0100)] 
getentropy: Declare it in <unistd.h> for __USE_MISC [BZ #17252]

7 years agoNew condvar implementation that provides stronger ordering guarantees.
Torvald Riegel [Wed, 25 May 2016 21:43:36 +0000 (23:43 +0200)] 
New condvar implementation that provides stronger ordering guarantees.

This is a new implementation for condition variables, required
after http://austingroupbugs.net/view.php?id=609 to fix bug 13165.  In
essence, we need to be stricter in which waiters a signal or broadcast
is required to wake up; this couldn't be solved using the old algorithm.
ISO C++ made a similar clarification, so this also fixes a bug in
current libstdc++, for example.

We can't use the old algorithm anymore because futexes do not guarantee
to wake in FIFO order.  Thus, when we wake, we can't simply let any
waiter grab a signal, but we need to ensure that one of the waiters
happening before the signal is woken up.  This is something the previous
algorithm violated (see bug 13165).

There's another issue specific to condvars: ABA issues on the underlying
futexes.  Unlike mutexes that have just three states, or semaphores that
have no tokens or a limited number of them, the state of a condvar is
the *order* of the waiters.  A waiter on a semaphore can grab a token
whenever one is available; a condvar waiter must only consume a signal
if it is eligible to do so as determined by the relative order of the
waiter and the signal.
Therefore, this new algorithm maintains two groups of waiters: Those
eligible to consume signals (G1), and those that have to wait until
previous waiters have consumed signals (G2).  Once G1 is empty, G2
becomes the new G1.  64b counters are used to avoid ABA issues.

This condvar doesn't yet use a requeue optimization (ie, on a broadcast,
waking just one thread and requeueing all others on the futex of the
mutex supplied by the program).  I don't think doing the requeue is
necessarily the right approach (but I haven't done real measurements
yet):
* If a program expects to wake many threads at the same time and make
that scalable, a condvar isn't great anyway because of how it requires
waiters to operate mutually exclusive (due to the mutex usage).  Thus, a
thundering herd problem is a scalability problem with or without the
optimization.  Using something like a semaphore might be more
appropriate in such a case.
* The scalability problem is actually at the mutex side; the condvar
could help (and it tries to with the requeue optimization), but it
should be the mutex who decides how that is done, and whether it is done
at all.
* Forcing all but one waiter into the kernel-side wait queue of the
mutex prevents/avoids the use of lock elision on the mutex.  Thus, it
prevents the only cure against the underlying scalability problem
inherent to condvars.
* If condvars use short critical sections (ie, hold the mutex just to
check a binary flag or such), which they should do ideally, then forcing
all those waiter to proceed serially with kernel-based hand-off (ie,
futex ops in the mutex' contended state, via the futex wait queues) will
be less efficient than just letting a scalable mutex implementation take
care of it.  Our current mutex impl doesn't employ spinning at all, but
if critical sections are short, spinning can be much better.
* Doing the requeue stuff requires all waiters to always drive the mutex
into the contended state.  This leads to each waiter having to call
futex_wake after lock release, even if this wouldn't be necessary.

[BZ #13165]
* nptl/pthread_cond_broadcast.c (__pthread_cond_broadcast): Rewrite to
use new algorithm.
* nptl/pthread_cond_destroy.c (__pthread_cond_destroy): Likewise.
* nptl/pthread_cond_init.c (__pthread_cond_init): Likewise.
* nptl/pthread_cond_signal.c (__pthread_cond_signal): Likewise.
* nptl/pthread_cond_wait.c (__pthread_cond_wait): Likewise.
(__pthread_cond_timedwait): Move here from pthread_cond_timedwait.c.
(__condvar_confirm_wakeup, __condvar_cancel_waiting,
__condvar_cleanup_waiting, __condvar_dec_grefs,
__pthread_cond_wait_common): New.
(__condvar_cleanup): Remove.
* npt/pthread_condattr_getclock.c (pthread_condattr_getclock): Adapt.
* npt/pthread_condattr_setclock.c (pthread_condattr_setclock):
Likewise.
* npt/pthread_condattr_getpshared.c (pthread_condattr_getpshared):
Likewise.
* npt/pthread_condattr_init.c (pthread_condattr_init): Likewise.
* nptl/tst-cond1.c: Add comment.
* nptl/tst-cond20.c (do_test): Adapt.
* nptl/tst-cond22.c (do_test): Likewise.
* sysdeps/aarch64/nptl/bits/pthreadtypes.h (pthread_cond_t): Adapt
structure.
* sysdeps/arm/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/ia64/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/m68k/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/microblaze/nptl/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/mips/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/nios2/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/s390/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/sh/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/tile/nptl/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/pthreadtypes.h (pthread_cond_t):
Likewise.
* sysdeps/x86/bits/pthreadtypes.h (pthread_cond_t): Likewise.
* sysdeps/nptl/internaltypes.h (COND_NWAITERS_SHIFT): Remove.
(COND_CLOCK_BITS): Adapt.
* sysdeps/nptl/pthread.h (PTHREAD_COND_INITIALIZER): Adapt.
* nptl/pthreadP.h (__PTHREAD_COND_CLOCK_MONOTONIC_MASK,
__PTHREAD_COND_SHARED_MASK): New.
* nptl/nptl-printers.py (CLOCK_IDS): Remove.
(ConditionVariablePrinter, ConditionVariableAttributesPrinter): Adapt.
* nptl/nptl_lock_constants.pysym: Adapt.
* nptl/test-cond-printers.py: Adapt.
* sysdeps/unix/sysv/linux/hppa/internaltypes.h (cond_compat_clear,
cond_compat_check_and_clear): Adapt.
* sysdeps/unix/sysv/linux/hppa/pthread_cond_timedwait.c: Remove file ...
* sysdeps/unix/sysv/linux/hppa/pthread_cond_wait.c
(__pthread_cond_timedwait): ... and move here.
* nptl/DESIGN-condvar.txt: Remove file.
* nptl/lowlevelcond.sym: Likewise.
* nptl/pthread_cond_timedwait.c: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i586/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/i386/i686/pthread_cond_wait.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_broadcast.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_signal.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S: Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S: Likewise.

7 years agoRevert "Fix ChangeLog typo"
Andreas Schwab [Sat, 31 Dec 2016 07:53:22 +0000 (08:53 +0100)] 
Revert "Fix ChangeLog typo"

This reverts commit d2d43afa113eb143303a3d4c1e31194648077642.

7 years agoAdd fromfp functions.
Joseph Myers [Sat, 31 Dec 2016 00:40:59 +0000 (00:40 +0000)] 
Add fromfp functions.

TS 18661-1 defines fromfp functions (fromfp, fromfpx, ufromfp,
ufromfpx, and float and long double variants) to convert from
floating-point to an integer type with any signedness and any given
width up to that of intmax_t, in any of the five IEEE rounding modes
(the usual four for binary floating point, plus rounding to nearest
with ties rounding away from zero), with control of whether in-range
non-integer values should result in the "inexact" exception being
raised.  This patch implements these functions for glibc.

These implementations are (apart from raising exceptions) pure integer
implementations; it's entirely possible optimized versions could be
devised for some architectures.  A common math/fromfp.h header
provides various common helper code that can readily be shared between
the implementations for different types.  For each type, the bulk of
the implementation is also shared between the four functions, with
wrappers that define UNSIGNED and INEXACT macros appropriately before
including the main implementation.

As the functions return intmax_t and uintmax_t without math.h being
allowed to expose those typedef names, they are declared using
__intmax_t and __uintmax_t as obtained from <bits/types.h>.

The FP_INT_* rounding direction macros are defined as ascending
integers in the order the names are listed in the TS; I see no
significant value in allowing architectures to vary the values of
them.

The libm-test machinery is duly adapted to handle unsigned int
arguments, and intmax_t and uintmax_t results.  Because each test
input is generally tested for four functions, five rounding modes and
several different widths, the libm-test.inc additions are very large.
Thus, the diffs in the body of this message exclude the libm-test.inc
changes, with the full patch being attached gzipped.  The bulk of the
new tests were generated (expanded from a test input plus rounding
results and information about where it lies in the relevant interval
between integers, to libm-test tests for all relevant combinations of
function, rounding direction and width) by a script that's included in
the patch as math/gen-fromfp-tests.py (input data
math/gen-fromfp-tests-inputs); as an ad hoc script that's not really
expected to be rerun, it's not very polished, but it's at least
plausibly useful for adding any further tests for these functions in
future.  I may split the libm-test tests up by function in future (so
both libm-test.inc and auto-libm-test-out are split into separate
files, and the tests for each function are also built and run
separately), but not for 2.25.

For no obvious reason, adding tgmath tests for the new functions
resulted in -Wuninitialized errors from test-tgmath.c about the
variable i being used uninitialized.  Those errors were correct - the
variable is read by the frexp version in test-tgmath.c (where real
frexp would write through that pointer instead of reading it) - but I
don't know why this patch would result in the pre-existing issue being
newly detected.  The patch initializes the variable to avoid those
errors.

With these changes, glibc 2.25 should have all the library features
from TS 18661-1 other than the functions that round result to narrower
type (and constant rounding directions, but I'm considering those
mainly a compiler feature not a library one).

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(fromfp): New declaration.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
* math/tgmath.h (__TGMATH_TERNARY_FIRST_REAL_RET_ONLY): New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfp): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (fromfpx): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (ufromfpx): Likewise.
* math/math.h: Include <bits/types.h>.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (FP_INT_UPWARD): New enum
constant and macro.
(FP_INT_DOWNWARD): Likewise.
(FP_INT_TOWARDZERO): Likewise.
(FP_INT_TONEARESTFROMZERO): Likewise.
(FP_INT_TONEAREST): Likewise.
* math/Versions (fromfp): New libm symbol at version GLIBC_2.25.
(fromfpf): Likewise.
(fromfpl): Likewise.
(ufromfp): Likewise.
(ufromfpf): Likewise.
(ufromfpl): Likewise.
(fromfpx): Likewise.
(fromfpxf): Likewise.
(fromfpxl): Likewise.
(ufromfpx): Likewise.
(ufromfpxf): Likewise.
(ufromfpxl): Likewise.
* math/Makefile (libm-calls): Add s_fromfpF, s_ufromfpF,
s_fromfpxF and s_ufromfpxF.
* math/gen-fromfp-tests.py: New file.
* math/gen-fromfp-tests-inputs: Likewise.
* math/libm-test.inc: Include <stdint.h>
(check_intmax_t): New function.
(check_uintmax_t): Likewise.
(struct test_fiu_M_data): New type.
(struct test_fiu_U_data): Likewise.
(RUN_TEST_fiu_M): New macro.
(RUN_TEST_LOOP_fiu_M): Likewise.
(RUN_TEST_fiu_U): Likewise.
(RUN_TEST_LOOP_fiu_U): Likewise.
(fromfp_test_data): New array.
(fromfp_test): New function.
(fromfpx_test_data): New array.
(fromfpx_test): New function.
(ufromfp_test_data): New array.
(ufromfp_test): New function.
(ufromfpx_test_data): New array.
(ufromfpx_test): New function.
(main): Call fromfp_test, fromfpx_test, ufromfp_test and
ufromfpx_test.
* math/gen-libm-test.pl (parse_args): Handle u, M and U descriptor
characters.
* math/test-tgmath-ret.c: Include <stdint.h>.
(rm): New variable.
(width): Likewise.
(CHECK_RET_CONST_TYPE): Take extra arguments and pass them to
called function.
(CHECK_RET_CONST_FLOAT): Take extra arguments and pass them to
CHECK_RET_CONST_TYPE.
(CHECK_RET_CONST_DOUBLE): Likewise.
(CHECK_RET_CONST_LDOUBLE): Likewise.
(CHECK_RET_CONST): Take extra arguments and pass them to calls
macros.
(fromfp): New CHECK_RET_CONST call.
(ufromfp): Likewise.
(fromfpx): Likewise.
(ufromfpx): Likewise.
(do_test): Call check_return_fromfp, check_return_ufromfp,
check_return_fromfpx and check_return_ufromfpx.
* math/test-tgmath.c: Include <stdint.h>
(NCALLS): Increase to 138.
(F(compile_test)): Initialize i.  Call fromfp functions.
(F(fromfp)): New function.
(F(fromfpx)): Likewise.
(F(ufromfp)): Likewise.
(F(ufromfpx)): Likewise.
* manual/arith.texi (Rounding Functions): Document FP_INT_UPWARD,
FP_INT_DOWNWARD, FP_INT_TOWARDZERO, FP_INT_TONEARESTFROMZERO,
FP_INT_TONEAREST, fromfp, fromfpf, fromfpl, ufromfp, ufromfpf,
ufromfpl, fromfpx, fromfpxf, fromfpxl, ufromfpx, ufromfpxf and
ufromfpxl.
* manual/libm-err-tab.pl (@all_functions): Add fromfp, fromfpx,
ufromfp and ufromfpx.
* math/fromfp.h: New file.
* sysdeps/ieee754/dbl-64/s_fromfp.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fromfp_main.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fromfpx.c: Likewise.
* sysdeps/ieee754/dbl-64/s_ufromfp.c: Likewise.
* sysdeps/ieee754/dbl-64/s_ufromfpx.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpf.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpf_main.c: Likewise.
* sysdeps/ieee754/flt-32/s_fromfpxf.c: Likewise.
* sysdeps/ieee754/flt-32/s_ufromfpf.c: Likewise.
* sysdeps/ieee754/flt-32/s_ufromfpxf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpl_main.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_ufromfpl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_ufromfpxl.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add fromfp,
ufromfp, fromfpx and ufromfpx.
(CFLAGS-nldbl-fromfp.c): New variable.
(CFLAGS-nldbl-fromfpx.c): Likewise.
(CFLAGS-nldbl-ufromfp.c): Likewise.
(CFLAGS-nldbl-ufromfpx.c): Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include <stdint.h>.
* sysdeps/ieee754/ldbl-opt/nldbl-fromfp.c: New file.
* sysdeps/ieee754/ldbl-opt/nldbl-fromfpx.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-ufromfp.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-ufromfpx.c: Likewise.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoresolv: Turn historic name lookup functions into compat symbols
Florian Weimer [Fri, 30 Dec 2016 17:43:04 +0000 (18:43 +0100)] 
resolv: Turn historic name lookup functions into compat symbols

This change also removes the preprocessor-based function renaming.
It also applied to tests in resolv/, which ended up running against
the historic functions.

_endhtent was not part of the ABI because it is not listed in the
resolv/Versions file.

7 years agoDefine __intmax_t, __uintmax_t in bits/types.h.
Joseph Myers [Fri, 30 Dec 2016 13:41:40 +0000 (13:41 +0000)] 
Define __intmax_t, __uintmax_t in bits/types.h.

TS 18661-1 defines *fromfp* functions, which are declared in math.h
and whose return types are intmax_t and uintmax_t, without allowing
math.h to define those typedefs.  (This is similar to e.g. ISO C
declaring vprintf in stdio.h without allowing that header to define
va_list.)  Thus, math.h needs to access those typedefs under internal
names.

This patch accordingly arranges for bits/types.h (which defines only
internal names, not public *_t typedefs) to define __intmax_t and
__uintmax_t.  stdint.h is made to use bits/types.h and define intmax_t
and uintmax_t using __intmax_t and __uintmax_t, to avoid duplication
of information.  (It would be reasonable to define more of the types
in stdint.h - and in sys/types.h, where it duplicates such types -
using information already available in bits/types.h.)  The idea is
that the subsequent addition of fromfp functions would then make
math.h include bits/types.h and use __intmax_t and __uintmax_t as the
return types of those functions.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

* bits/types.h (__intmax_t): New typedef.
(__uintmax_t): Likewise.
* sysdeps/generic/stdint.h: Include <bits/types.h>.
(intmax_t): Define using __intmax_t.
(uintmax_t): Define using __uintmax_t.

7 years agoFix tst-support_record_failure-2 for run-built-tests = no.
Joseph Myers [Fri, 30 Dec 2016 13:01:44 +0000 (13:01 +0000)] 
Fix tst-support_record_failure-2 for run-built-tests = no.

The support/tst-support_record_failure-2.out test attempts to run
built code even if run-built-tests = no, so failing with
build-many-glibcs.py for all architectures whose code cannot be run on
the system running the script.  This patch disables the test in that
case.

Tested for x86_64 (native), and for aarch64 with build-many-glibcs.py.

* support/Makefile (tests-special): Make definition conditional on
[$(run-built-tests) = yes].
($(objpfx)tst-support_record_failure-2.out): Make rule conditional
on [$(run-built-tests) = yes].

7 years agoFix ChangeLog typo
Andreas Schwab [Fri, 30 Dec 2016 09:34:14 +0000 (10:34 +0100)] 
Fix ChangeLog typo

7 years agolocaledata: bs_BA: fix yesexpr/noexpr [BZ #20974]
Mike Frysinger [Thu, 15 Dec 2016 23:34:05 +0000 (18:34 -0500)] 
localedata: bs_BA: fix yesexpr/noexpr [BZ #20974]

Both regexes end with a "*." which means the previous match can be
omitted, and then the . allows them to match any input at all.

This means tools like coreutils' `rm -i` will always delete things
when prompted because the yesexpr regex matches all inputs (even
the negative ones).

7 years agoFix pretty printer tests for run-built-tests == no
Siddhesh Poyarekar [Fri, 30 Dec 2016 04:12:38 +0000 (09:42 +0530)] 
Fix pretty printer tests for run-built-tests == no

In my change to add configure tests for python I had a brainfart where
I tried to filter out unsupported tests from tests-printers-programs
instead of tests-printers to select tests to build.  I realize now
that all of that is completely unnecessary and it would be safe to
just build the tests as long as we don't try to run it.

This patch reverts that bit of the change.  Tested with
run-built-tests = no in config.make.

* Rules (tests): Add tests-printers-programs to tests to be
built.

7 years agoAdd SYSV shared memory test
Adhemerval Zanella [Mon, 31 Oct 2016 13:22:43 +0000 (11:22 -0200)] 
Add SYSV shared memory test

This patch adds a simple SYSV shared memory test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

* sysvipc/Makefile (tests): Add test-sysvshm.
* sysvipc/test-sysvshm.c: New file.

7 years agoUse shmget syscall for linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:24:53 +0000 (18:24 -0200)] 
Use shmget syscall for linux implementation

this patch add a direct call to shmget syscall if it is supported by
kernel features.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmget): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmget):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmget):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmget): Likewise.
* sysdeps/unix/sysv/linux/shmget.c (shmget): Use shmget syscall if it
is defined.

7 years agoUse shmdt syscall for linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:23:11 +0000 (18:23 -0200)] 
Use shmdt syscall for linux implementation

this patch add a direct call to shmdt syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmdt): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmdt):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmdt):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmdt): Likewise.
* sysdeps/unix/sysv/linux/shmdt.c (shmdt): Use shmdt syscall if it is
defined.

7 years agoConsolidate Linux shmctl implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:20:36 +0000 (18:20 -0200)] 
Consolidate Linux shmctl implementation

This patch consolidates the shmctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/shmctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
oldshmctl.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmctl): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmctl):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmctl): Likewise.
* sysdeps/unix/sysv/linux/alpha/shmctl.c: Remove file.
* sysdeps/unix/sysv/linux/arm/shmctl.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/shmctl.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/shmctl.c: Use default
implementation.
* sysdeps/unix/sysv/linux/shmctl.c (__new_shmctl): Use shmctl syscall
if it is defined.

7 years agoUse shmat syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 20:04:48 +0000 (18:04 -0200)] 
Use shmat syscall for Linux implementation

This patch add a direct call to shmat syscall if it is supported by
kernel features.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (shmat): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (shmat):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (shmat):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (shmat): Likewise.
* sysdeps/unix/sysv/linux/alpha/kernel-features.h (__NR_shmat):
Define to __NR_osf_shmat.
* sysdeps/unix/sysv/linux/shmat.c (shmat): Use shmat syscall if it is
defined.

7 years agoAdd SYSV semaphore test
Adhemerval Zanella [Mon, 31 Oct 2016 13:03:07 +0000 (11:03 -0200)] 
Add SYSV semaphore test

This patch adds a simple SYSV semaphore test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

* sysvipc/Makefile (tests): Add test-sysvsem.
* sysvipc/test-sysvsem.c: New file.

7 years agoConsolidate Linux semtimedop implementation
Adhemerval Zanella [Wed, 26 Oct 2016 19:51:37 +0000 (17:51 -0200)] 
Consolidate Linux semtimedop implementation

This patch consolidates the semtimedop Linux implementation in only
one default file, sysdeps/unix/sysv/linux/semtimedop.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (semtimedop): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semtimedop):
Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semtimedop):
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semtimedop):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semtimedop): Likewise.
* sysdeps/unix/sysv/linux/m68k/semtimedop.S: Remove file.
* sysdeps/unix/sysv/linux/s390/semtimedop.c: Reorganize headers and
add a comment about s390 syscall difference from default one.
* sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Use semtimedop
syscall if it is defined.

7 years agoUse semop syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 19:01:43 +0000 (17:01 -0200)] 
Use semop syscall for Linux implementation

This patch add a direct call to semop syscall if it is supported by
kernel headers.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (semop): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semop):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semop):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semop): Likewise.
* sysdeps/unix/sysv/linux/semop.c (semop): Use semop syscall if it is
defined.

7 years agoUse semget syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 18:59:55 +0000 (16:59 -0200)] 
Use semget syscall for Linux implementation

This patch add a direct call to semget syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (semget): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (semget):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semget):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semget): Likewise.
* sysdeps/unix/sysv/linux/semget.c (semget): Use semget syscall
if it is defined.

7 years agoConsolidate Linux semctl implementation
Adhemerval Zanella [Wed, 26 Oct 2016 18:55:39 +0000 (16:55 -0200)] 
Consolidate Linux semctl implementation

This patch consolidates the semctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/semctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
oldsemctl.
* sysdeps/unix/sysv/linux/alpha/semctl.c: Remove file.
* sysdeps/unix/sysv/linux/arm/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/semctl.c: Use defaulf
implementation.
* sysdeps/unix/sysv/linux/semctl.c (__new_semctl): Use semctl
syscall if it is defined.
* sysdeps/unix/sysv/linux/generic/syscalls.list (semctl): Remove.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (semctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (semctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (semctl): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (semctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (semctl): Likewise.

7 years agoAdd SYSV message queue test
Adhemerval Zanella [Fri, 28 Oct 2016 20:35:03 +0000 (18:35 -0200)] 
Add SYSV message queue test

This patch adds a simple SYSV message queue test to check for correct
argument passing on kernel.  The idea is neither to be an extensive
testing nor to check for any specific Linux test.

* sysvipc/Makefile (tests): Add test-sysvmsg.
* sysvipc/test-sysvmsg.c: New file.
* test-skeleton.c (FAIL_UNSUPPORTED): New define.

7 years agoUse msgget syscall for Linux implementation
Adhemerval Zanella [Wed, 26 Oct 2016 13:00:24 +0000 (11:00 -0200)] 
Use msgget syscall for Linux implementation

This patch add a direct call to msgget syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgget): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgget):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgget):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgget): Likewise.
* sysdeps/unix/sysv/linux/msgget.c (msgget): Use msgget syscall if
define.

7 years agoUse msgsnd syscall for Linux implementation
Adhemerval Zanella [Tue, 25 Oct 2016 22:57:55 +0000 (20:57 -0200)] 
Use msgsnd syscall for Linux implementation

This patch add a direct call to msgsnd syscall if it is supported by
kernel features.

hecked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgsnd): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgsnd):
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgsnd):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgsnd): Likewise.
* sysdeps/unix/sysv/linux/msgsnd.c (__libc_msgsnd): Use msgsnd syscall
if defined.

7 years agoConsolidate Linux msgrcv implementation
Adhemerval Zanella [Tue, 25 Oct 2016 22:55:09 +0000 (20:55 -0200)] 
Consolidate Linux msgrcv implementation

This patch consolidates the msgrcv Linux implementation in only
one default file, sysdeps/unix/sysv/linux/msgrcv.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgctl): Remove.
* sysdeps/unix/sysv/linux/arm/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/microblaze/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgctl): Likewise,
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (msgctl):
Likewise.
* sysdeps/unix/sysv/linux/msgrcv.c (__libc_msgrcv): Use msgrcv syscall
if defined.
* sysdeps/unix/sysv/linux/sparc/sparc64/msgrcv.c: Remove file.

7 years agoConsolidate Linux msgctl implementation
Adhemerval Zanella [Tue, 25 Oct 2016 22:38:37 +0000 (20:38 -0200)] 
Consolidate Linux msgctl implementation

This patch consolidates the msgctl Linux implementation in only
one default file, sysdeps/unix/sysv/linux/msgctl.c.  If tries to use
the direct syscall if it is supported, otherwise will use the old ipc
multiplex mechanism.

The patch also simplify header inclusion and reorganize internal
compat symbol to be built only if old ipc is defined.

Checked on x86_64, i686, powerpc64le, aarch64, and armhf.

* sysdeps/unix/sysv/linux/alpha/Makefile (sysdeps_routines): Remove
oldmsgctl.
* sysdeps/unix/sysv/linux/alpha/msgctl.c: Remove file.
* sysdeps/unix/sysv/linux/arm/msgctl.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/msgctl.c: Likewise.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (oldmsgctl): Remove.
* sysdeps/unix/sysv/linux/generic/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/hppa/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/ia64/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgctl):
Likewise.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgctl): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/msgctl.c: Use default
implementation.
* sysdeps/unix/sysv/linux/msgctl.c (__new_msgctl): Use msgctl syscall
if defined.

7 years agoRefactor Linux ipc_priv header
Adhemerval Zanella [Mon, 7 Nov 2016 19:29:30 +0000 (17:29 -0200)] 
Refactor Linux ipc_priv header

Some architectures support the old-style IPC and require IPC_64 equal to
0x100 to be passed along SysV IPC syscalls, while new architectures should
default to new IPC version (without the flags being set).

This patch refactor current ipc_priv.h Linux headers in two directions:

- Remove cross platform references (for instance alpha including powerpc
  definition) and add required definition for each required port.  The
  idea is to avoid tie one architecture definition with another and make
  platform change independent.

- Move all common definitions (the ipc syscall commands) on a common
  header, ipc_ops.h.

* sysdeps/unix/sysv/linux/aarch64/ipc_priv.h: New file.
* sysdeps/unix/sysv/linux/alpha/ipc_priv.h: Avoid included other arch
definition and define its own.
* sysdeps/unix/sysv/linux/ipc_ops.h: New file.
* sysdeps/unix/sysv/linux/x86_64/ipc_priv.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h: Likewise.
* sysdeps/unix/sysv/linux/mips/ipc_priv.h: Remove file.
* sysdeps/unix/sysv/linux/mips/mips64/ipc_priv.h: New file.
* sysdeps/unix/sysv/linux/ipc_priv.h: Move ipc syscall operation
definitions to common header.
* sysdeps/unix/sysv/linux/powerpc/ipc_priv.h: Use common syscall
operation from ipc_ops.h.

7 years agoAdd __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux
Adhemerval Zanella [Wed, 2 Nov 2016 17:41:15 +0000 (15:41 -0200)] 
Add __ASSUME_DIRECT_SYSVIPC_SYSCALL for Linux

On current minimum supported kernels, the SysV IPC on Linux is provided
by either the ipc syscalls or correspondent wire syscalls.  Also, for
architectures that supports wire syscalls all syscalls are supported
in a set (msgct, msgrcv, msgsnd, msgget, semctl, semget, semop, semtimedop,
shmctl, shmat, shmget, shmdt).

The architectures that only supports ipc syscall are:

  - i386, m68k, microblaze, mips32, powerpc (powerpc32, powerpc64, and
    powerpc64le), s390 (32 and 64 bits), sh, sparc32, and sparc64.

And the architectures that only supports wired syscalls are:

  - aarch64, alpha, hppa, ia64, mips64, mips64n32, nios2, tile
    (tilepro, tilegx, and tilegx64), and x86_64

Also arm is the only one that supports both wire syscalls and the
ipc, although the ipc one is deprecated.

This patch adds a new define, __ASSUME_DIRECT_SYSVIPC_SYSCALL, that wired
syscalls are supported on the system and the general idea is to use
it where possible.

I also checked the syscall table for all architectures on Linux 4.9
and there is no change on described support for Linux 2.6.32/3.2.

* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): New define.
* sysdeps/unix/sysv/linux/i386/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Undef.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_DIRECT_SYSVIPC_SYSCALL): Likewise.

7 years agopowerpc: Fix powerpc32/power7 memchr for large input sizes
Tulio Magno Quites Machado Filho [Wed, 28 Dec 2016 13:38:56 +0000 (11:38 -0200)] 
powerpc: Fix powerpc32/power7 memchr for large input sizes

The same error fixed in commit b224637928e9fc04e3cef3e10d02ccf042d01584
happens in the 32-bit implementation of memchr for power7.

This patch adopts the same solution, with a minimal change: it
implements a saturated addition where overflows sets the maximum pointer
size to UINTPTR_MAX.

7 years agopowerpc64: strchr/strchrnul optimization for power8
Rajalakshmi Srinivasaraghavan [Tue, 27 Dec 2016 19:48:37 +0000 (17:48 -0200)] 
powerpc64: strchr/strchrnul optimization for power8

The P7 code is used for <=32B strings and for > 32B vectorized loops are used.
This shows as an average 25% improvement depending on the position of search
character.  The performance is same for shorter strings.
Tested on ppc64 and ppc64le.

7 years agoFix various typos in the ChangeLog
Florian Weimer [Wed, 28 Dec 2016 12:49:06 +0000 (13:49 +0100)] 
Fix various typos in the ChangeLog

7 years agoAdd file missing from ChangeLog in previous commit
Florian Weimer [Wed, 28 Dec 2016 12:43:49 +0000 (13:43 +0100)] 
Add file missing from ChangeLog in previous commit

7 years agosupport: Add support for delayed test failure reporting
Florian Weimer [Wed, 28 Dec 2016 12:37:18 +0000 (13:37 +0100)] 
support: Add support for delayed test failure reporting

The new functions support_record_failure records a test failure,
but does not terminate the process.  The macros TEST_VERIFY
and TEST_VERIFY_EXIT check that a condition is true.

7 years agoAdd comments to check-c++-types.sh.
Steve Ellcey [Tue, 27 Dec 2016 22:26:05 +0000 (14:26 -0800)] 
Add comments to check-c++-types.sh.

* scripts/check-c++-types.sh: Add comments.

7 years agoFix typos in the spelling of "implementation"
Dmitry V. Levin [Tue, 27 Dec 2016 20:13:35 +0000 (20:13 +0000)] 
Fix typos in the spelling of "implementation"

Apply the following spelling fix:
$ git grep -El 'implemetn?ation' |
  xargs sed -ri 's/implemetn?ation/implementation/g'

[BZ #19514]
* resolv/res_send.c: Fix typo in comment.
* sysdeps/i386/i386-mcount.S: Likewise.
* sysdeps/s390/s390-32/s390-mcount.S: Likewise.
* sysdeps/s390/s390-64/s390x-mcount.S: Likewise.
* sysdeps/sparc/sparc-mcount.S: Likewise.

7 years agopowerpc: Remove f{max,min}{f} assembly implementations
Adhemerval Zanella [Fri, 16 Dec 2016 19:13:14 +0000 (19:13 +0000)] 
powerpc: Remove f{max,min}{f} assembly implementations

This patch removes the powerpc assembly implementation of fmax/fmin.
Based on benchtests, the assembly ones shows:

$ ./testrun.sh benchtests/bench-fmax
  "fmax": {
   "": {
    "duration": 5.07586e+09,
    "iterations": 2.01676e+09,
    "max": 1350.39,
    "min": 2.073,
    "mean": 2.51684
   },
   "qNaN": {
    "duration": 5.09315e+09,
    "iterations": 8.4568e+08,
    "max": 2788,
    "min": 5.806,
    "mean": 6.02255
   },
   "sNaN": {
    "duration": 5.09073e+09,
    "iterations": 8.42316e+08,
    "max": 4215.84,
    "min": 5.737,
    "mean": 6.04373
   }

And

$ ./testrun.sh benchtests/bench-fmin
  "fmin": {
   "": {
    "duration": 5.07711e+09,
    "iterations": 2.02982e+09,
    "max": 497.094,
    "min": 2.073,
    "mean": 2.50126
   },
   "qNaN": {
    "duration": 5.09134e+09,
    "iterations": 8.46968e+08,
    "max": 2255.14,
    "min": 5.807,
    "mean": 6.01125
   },
   "sNaN": {
    "duration": 5.09122e+09,
    "iterations": 8.4746e+08,
    "max": 1969.38,
    "min": 5.729,
    "mean": 6.00763
   }
  }

The default implementation (math/s_f{max.min}_template.c) shows slight better
latency for all cases:

$ ./testrun.sh benchtests/bench-fmax
  "fmax": {
   "": {
    "duration": 5.07044e+09,
    "iterations": 2.38695e+09,
    "max": 2048.58,
    "min": 2.073,
    "mean": 2.12423
   },
   "qNaN": {
    "duration": 5.09004e+09,
    "iterations": 9.45428e+08,
    "max": 3306.93,
    "min": 5.138,
    "mean": 5.38385
   },
   "sNaN": {
    "duration": 5.08458e+09,
    "iterations": 1.15959e+09,
    "max": 972.008,
    "min": 3.321,
    "mean": 4.3848
   }
  }

And:

$ ./testrun.sh benchtests/bench-fmin
  "fmin": {
   "": {
    "duration": 5.06817e+09,
    "iterations": 2.3913e+09,
    "max": 1177.9,
    "min": 2.073,
    "mean": 2.11942
   },
   "qNaN": {
    "duration": 5.08857e+09,
    "iterations": 9.45656e+08,
    "max": 2658.83,
    "min": 5.09,
    "mean": 5.38099
   },
   "sNaN": {
    "duration": 5.08093e+09,
    "iterations": 1.16725e+09,
    "max": 1030.74,
    "min": 3.323,
    "mean": 4.3529
   }
  }

Both were run with GCC 5.4 (ubuntu 16 default installation) using default
compiler flags on POWER8E 3.4GHz (powerpc64le-linux-gnu).

7 years agoFix typo in manual for iseqsig
Gabriel F. T. Gomes [Tue, 29 Nov 2016 15:48:24 +0000 (13:48 -0200)] 
Fix typo in manual for iseqsig

7 years agoDeclare getentropy in <unistd.h> [BZ #17252]
Florian Weimer [Tue, 27 Dec 2016 16:13:21 +0000 (17:13 +0100)] 
Declare getentropy in <unistd.h> [BZ #17252]

7 years agoresolv: Remove processing of unimplemented "spoof" host.conf options
Florian Weimer [Tue, 27 Dec 2016 15:01:06 +0000 (16:01 +0100)] 
resolv: Remove processing of unimplemented "spoof" host.conf options

7 years agosunrpc: Always obtain AF_INET addresses from NSS [BZ #20964]
Florian Weimer [Tue, 27 Dec 2016 15:44:15 +0000 (16:44 +0100)] 
sunrpc: Always obtain AF_INET addresses from NSS [BZ #20964]

The new __libc_rpc_gethostbyname function calls gethostbyname2_r
with an AF_INET argument and is therefore not affected by the
RES_USE_INET6 flag.

Validated with the following test program, with and without
RES_OPTIONS=inet6, against a NFS server.  (Link with -lrpcsvc.)

#include <rpc/clnt.h>
#include <rpcsvc/mount.h>
#include <stdio.h>
#include <string.h>

static void
usage (char **argv)
{
  printf ("usage:\n"
          "  %1$s HOST getrpcport\n"
          "  %1$s HOST callrpc\n"
          "  %1$s HOST clnt_create\n",
          argv[0]);
}

static void
dump_exports (struct exportnode *exports)
{
  while (exports != NULL)
    {
      printf ("%s\n", exports->ex_dir);
      exports = exports->ex_next;
    }
}

int
main (int argc, char **argv)
{
  if (argc != 3)
    {
      usage (argv);
      return 1;
    }

  const char *host = argv[1];
  const char *command = argv[2];

  if (strcmp (command, "getrpcport") == 0)
    {
      int port = getrpcport (host, MOUNTPROG, MOUNTVERS, IPPROTO_UDP);
      printf ("getrpcport: %d\n", port);
    }
  else if (strcmp (command, "callrpc") == 0)
    {
      struct exportnode *exports = NULL;
      int ret = callrpc (host, MOUNTPROG, MOUNTVERS, MOUNTPROC_EXPORT,
                         (xdrproc_t) xdr_void, NULL,
                         (xdrproc_t) xdr_exports, (char *)&exports);
      if (ret != 0)
        {
          clnt_perrno (ret);
          puts ("");
          return 1;
        }
      dump_exports (exports);
    }
  else if (strcmp (command, "clnt_create") == 0)
    {
      CLIENT *client = clnt_create
        (host, MOUNTPROG, MOUNTVERS, "udp");
      if (client == NULL)
        {
          printf ("error: clnt_create failed\n");
          return 1;
        }
      struct exportnode *exports = NULL;
      int ret = CLNT_CALL (client, MOUNTPROC_EXPORT,
                           (xdrproc_t) xdr_void, NULL,
                           (xdrproc_t) xdr_exports, (char *)&exports,
                           ((struct timeval) {15, 0}));
      if (ret != 0)
        {
          clnt_perrno (ret);
          puts ("");
          return 1;
        }
      dump_exports (exports);
    }
  else
    {
      usage (argv);
      return 1;
    }

  return 0;
}

7 years agorpcinfo: Remove traces of unbuilt helper program
Florian Weimer [Tue, 27 Dec 2016 13:56:32 +0000 (14:56 +0100)] 
rpcinfo: Remove traces of unbuilt helper program

7 years agoFix x86_64 memchr for large input sizes
Adhemerval Zanella [Thu, 15 Dec 2016 20:17:09 +0000 (18:17 -0200)] 
Fix x86_64 memchr for large input sizes

Current optimized memchr for x86_64 does for input arguments pointers
module 64 in range of [49,63] if there is no searchr char in the rest
of 64-byte block a pointer addition which might overflow:

* sysdeps/x86_64/memchr.S

    77          .p2align 4
    78  L(unaligned_no_match):
    79          add     %rcx, %rdx

Add (uintptr_t)s % 16 to n in %rdx.

    80          sub     $16, %rdx
    81          jbe     L(return_null)

This patch fixes by adding a saturated math that sets a maximum pointer
value if it overflows (UINTPTR_MAX).

Checked on x86_64-linux-gnu and powerpc64-linux-gnu.

[BZ# 19387]
* sysdeps/x86_64/memchr.S (memchr): Avoid overflow in pointer
addition.
* string/test-memchr.c (do_test): Remove alignment limitation.
(test_main): Add test that trigger BZ# 19387.

7 years agoEnable -fstack-protector=* when requested by configure [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:10 +0000 (10:09 +0100)] 
Enable -fstack-protector=* when requested by configure [BZ #7065]

7 years agoDo not stack-protect sigreturn stubs [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:06 +0000 (10:09 +0100)] 
Do not stack-protect sigreturn stubs [BZ #7065]

These are called from the kernel with the stack at a carefully-
chosen location so that the stack frame can be restored: they must not
move the stack pointer lest garbage be restored into the registers.

We explicitly inhibit protection for SPARC and for signal/sigreturn.c:
other arches either define their sigreturn stubs in .S files, or (i386,
x86_64, mips) use macros expanding to top-level asm blocks and explicit
labels in the text section to mock up a "function" without telling the
compiler that one is there at all.

7 years agoDrop explicit stack-protection of pieces of the system [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:03 +0000 (10:09 +0100)] 
Drop explicit stack-protection of pieces of the system [BZ #7065]

7 years agoLink a non-libc-using test with -fno-stack-protector [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:09:00 +0000 (10:09 +0100)] 
Link a non-libc-using test with -fno-stack-protector [BZ #7065]

This test cannot reference __stack_chk_fail because it is not linked
with libc at all.

7 years agoPLT avoidance for __stack_chk_fail [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:57 +0000 (10:08 +0100)] 
PLT avoidance for __stack_chk_fail [BZ #7065]

Add a hidden __stack_chk_fail_local alias to libc.so,
and make sure that on targets which use __stack_chk_fail,
this does not introduce a local PLT reference into libc.so.

7 years agoWork even with compilers which enable -fstack-protector by default [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:54 +0000 (10:08 +0100)] 
Work even with compilers which enable -fstack-protector by default [BZ #7065]

With all the machinery we just added, we can easily arrange to work even
when the compiler passes in -fstack-protector automatically: all the
necessary bits of glibc are always compiled with -fno-stack-protector
now.

So tear out the check in configure, and add appropriate calls to
-fno-stack-protector in tests that need them (largely those that use
-nostdlib), since we don't yet have a __stack_chk_fail that those
tests can rely upon.  (GCC often provides one, but we cannot rely on
this, especially not when bootstrapping.)

When stack protection is disabled, explicitly pass -fno-stack-protector
to everything, to stop a compiler hacked to enable it from inserting
calls to __stack_chk_fail via the PLT in every object file.

7 years agoIgnore __stack_chk_fail* in the rtld mapfile computation [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:51 +0000 (10:08 +0100)] 
Ignore __stack_chk_fail* in the rtld mapfile computation [BZ #7065]

The previous commit prevented rtld itself from being built with
-fstack-protector, but this is not quite enough.  We identify which
objects belong in rtld via a test link and analysis of the resulting
mapfile.  That link is necessarily done against objects that are
stack-protected, so drags in __stack_chk_fail_local, __stack_chk_fail,
and all the libc and libio code they use.

To stop this happening, use --defsym in the test librtld.map-production
link to force the linker to predefine these two symbols (to 0, but it
could be to anything).  (In a real link, this would of course be
catastrophic, but these object files are never used for anything else.)

7 years agoCompile the dynamic linker without stack protection [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:48 +0000 (10:08 +0100)] 
Compile the dynamic linker without stack protection [BZ #7065]

Also compile corresponding routines in the static libc.a with the same
flag.

7 years agoDisable stack protector in early static initialization [BZ #7065]
Nick Alcock [Mon, 26 Dec 2016 09:08:45 +0000 (10:08 +0100)] 
Disable stack protector in early static initialization [BZ #7065]

The startup code in csu/, and the brk and sbrk functions are
needed very early in initialization of a statically-linked program,
before the stack guard is initialized; TLS initialization also uses
memcpy, which cannot overrun its own stack.  Mark all of these as
-fno-stack-protector.

We also finally introduce @libc_cv_ssp@ and @no_stack_protector@, both
substituted by the configury changes made earlier, to detect the case
when -fno-stack-protector is supported by the compiler, and
unconditionally pass it in when this is the case, whether or not
--enable-stack-protector is passed to configure.  (This means that
it'll even work when the compiler's been hacked to pass
-fstack-protector by default, unless the hackage is so broken that
it does so in a way that is impossible to override.)