external/glibc.git
9 years agomanual: fix addmntent's MT-Safety race annotation
Ma Shimiao [Fri, 21 Nov 2014 04:45:02 +0000 (02:45 -0200)]
manual: fix addmntent's MT-Safety race annotation

for  ChangeLog

* manual/sysinfo.texi (addmntent): It is actually MT-Safe,
because the potential race is on the user-supplied stream.

9 years agoctermid: return string literal, document MT-Safety pitfall
Alexandre Oliva [Fri, 21 Nov 2014 04:06:22 +0000 (02:06 -0200)]
ctermid: return string literal, document MT-Safety pitfall

for  ChangeLog

* sysdeps/posix/ctermid.c (ctermid): Return a pointer to a
string literal if not passed a buffer.
* manual/job.texi (ctermid): Update reasoning, note deviation
from posix, suggest mtasurace when not passed a buffer, for
future non-preliminary safety notes.

9 years agomanual: cuserid is mtasurace if not passed a string
Alexandre Oliva [Fri, 21 Nov 2014 04:06:21 +0000 (02:06 -0200)]
manual: cuserid is mtasurace if not passed a string

for  ChangeLog

* manual/users.texi (cuserid): Fix MT-Safety note for the case
of not passing it a buffer.
Reported by Peng Haitao.

9 years agoRequire check-safety.sh to pass; wish for check that all fns are documented
Alexandre Oliva [Fri, 21 Nov 2014 04:06:19 +0000 (02:06 -0200)]
Require check-safety.sh to pass; wish for check that all fns are documented

for  ChangeLog

* manual/Makefile ($(objpfx)stamp-summary): Require
check-safety.sh to pass.
* manual/check-safety.sh: Wish for verification that every
@deftypefn and @deftypefun is followed by a @safety remark.

9 years agoNPTL: Use __libc_fatal in unwind.c.
Roland McGrath [Thu, 20 Nov 2014 21:58:03 +0000 (13:58 -0800)]
NPTL: Use __libc_fatal in unwind.c.

9 years agoNPTL: Conditionalize asynchronous cancellation support on [SIGCANCEL].
Roland McGrath [Thu, 20 Nov 2014 21:43:35 +0000 (13:43 -0800)]
NPTL: Conditionalize asynchronous cancellation support on [SIGCANCEL].

9 years agoNPTL: Refactor scheduler setup in pthread_create.
Roland McGrath [Thu, 20 Nov 2014 18:56:20 +0000 (10:56 -0800)]
NPTL: Refactor scheduler setup in pthread_create.

9 years agoUse C11 atomics in pthread_once.
Torvald Riegel [Mon, 20 Oct 2014 22:34:53 +0000 (00:34 +0200)]
Use C11 atomics in pthread_once.

9 years agoAdd tests for C11-like atomic operations.
Torvald Riegel [Mon, 20 Oct 2014 18:25:40 +0000 (20:25 +0200)]
Add tests for C11-like atomic operations.

9 years agoAdd atomic operations similar to those provided by C11.
Torvald Riegel [Sun, 14 Sep 2014 18:04:54 +0000 (20:04 +0200)]
Add atomic operations similar to those provided by C11.

9 years agoAdd arch-specific configuration for C11 atomics support.
Torvald Riegel [Fri, 17 Oct 2014 23:02:59 +0000 (01:02 +0200)]
Add arch-specific configuration for C11 atomics support.

This sets __HAVE_64B_ATOMICS if provided.  It also sets
USE_ATOMIC_COMPILER_BUILTINS to true if the existing atomic ops use the
__atomic* builtins (aarch64, mips partially) or if this has been
tested (x86_64); otherwise, this is set to false so that C11 atomics will
be based on the existing atomic operations.

9 years agoNPTL: Don't (re)validate sched_priority in pthread_create.
Roland McGrath [Thu, 20 Nov 2014 01:34:25 +0000 (17:34 -0800)]
NPTL: Don't (re)validate sched_priority in pthread_create.

9 years agoTest that pthread_create diagnoses invalid scheduling parameters.
Roland McGrath [Thu, 20 Nov 2014 01:28:31 +0000 (17:28 -0800)]
Test that pthread_create diagnoses invalid scheduling parameters.

9 years agoCVE-2014-7817: wordexp fails to honour WRDE_NOCMD.
Carlos O'Donell [Wed, 19 Nov 2014 16:44:12 +0000 (11:44 -0500)]
CVE-2014-7817: wordexp fails to honour WRDE_NOCMD.

The function wordexp() fails to properly handle the WRDE_NOCMD
flag when processing arithmetic inputs in the form of "$((... ``))"
where "..." can be anything valid. The backticks in the arithmetic
epxression are evaluated by in a shell even if WRDE_NOCMD forbade
command substitution. This allows an attacker to attempt to pass
dangerous commands via constructs of the above form, and bypass
the WRDE_NOCMD flag. This patch fixes this by checking for WRDE_NOCMD
in exec_comm(), the only place that can execute a shell. All other
checks for WRDE_NOCMD are superfluous and removed.

We expand the testsuite and add 3 new regression tests of roughly
the same form but with a couple of nested levels.

On top of the 3 new tests we add fork validation to the WRDE_NOCMD
testing. If any forks are detected during the execution of a wordexp()
call with WRDE_NOCMD, the test is marked as failed. This is slightly
heuristic since vfork might be used in the future, but it provides a
higher level of assurance that no shells were executed as part of
command substitution with WRDE_NOCMD in effect. In addition it doesn't
require libpthread or libdl, instead we use the public implementation
namespace function __register_atfork (already part of the public ABI
for libpthread).

Tested on x86_64 with no regressions.

9 years agoAuto-generate libc-modules.h
Siddhesh Poyarekar [Wed, 19 Nov 2014 06:46:00 +0000 (12:16 +0530)]
Auto-generate libc-modules.h

Remove libc-modules.h from the tree and auto-generate it from
soversions.i and the list of modules in the built-modules variable
defined in Makeconfig.  Macros generated have increasing numbered
values, with built-modules having lower values starting from 1,
following which a separator value LIBS_BEGIN is added and then finally
the library names from soversions.i are appended to the list.  This
allows us to conveniently differentiate between the versioned
libraries and other built modules, which is needed in errno.h and
netdb.h to decide whether to use an internal symbol or an external
one.

Verified that generated code remains unchanged on x86_64.

* Makeconfig (built-modules): List non-library modules to be
built.
(module-cppflags): Include libc-modules.h for
everything except shlib-versions.v.i.
(CPPFLAGS): Use it.
(before-compile): Add libc-modules.h.
($(common-objpfx)libc-modules.h,
$(common-objpfx)libc-modules.stmp): New targets.
(common-generated): Add libc-modules.h and libc-modules.stmp.
($(common-objpfx)Versions.v.i): Depend on libc-modules.h.
* include/libc-symbols.h: Don't include libc-modules.h.
* include/libc-modules.h: Remove file.
* scripts/gen-libc-modules.awk: New script to generate
libc-modules.h.
* sysdeps/unix/Makefile ($(common-objpfx)sysd-syscalls):
Depend on libc-modules.stmp.

9 years agoFix -Wundef warning in SHLIB_COMPAT
Siddhesh Poyarekar [Wed, 19 Nov 2014 06:45:01 +0000 (12:15 +0530)]
Fix -Wundef warning in SHLIB_COMPAT

Replace the IS_IN_##lib with IS_IN(lib).  Verified that the generated
code remains the same.

* include/shlib-compat.h (_SHLIB_COMPAT): Use IS_IN.

9 years agoAdd new macro IN_MODULE to identify module in which source is built
Siddhesh Poyarekar [Wed, 19 Nov 2014 06:43:54 +0000 (12:13 +0530)]
Add new macro IN_MODULE to identify module in which source is built

The current scheme to identify which module a translation unit is
built in depends on defining multiple macros IS_IN_* and also defining
NOT_IN_libc if we're building a non-libc module.  In addition, there
is an IN_LIB macro that does effectively the same thing, but for
different modules (notably the systemtap probes).  This macro scheme
unifies both ideas to use just one macro IN_MODULE and assign it a
value depending on the module it is being built into.  If the module
is not defined, it defaults to MODULE_libc.

Patches that follow will replace uses of IS_IN_* variables with the
IS_IN() macro.  libc-symbols.h has been converted already to give an
example of how such a transition will look.

Verified that there are no relevant binary changes.  One source change
that will crop up repeatedly is that of nscd_stat, since it uses the
build timestamp as a constant in its logic.

* Makeconfig (in-module): Get value of libof set for the
translation unit.
(CPPFLAGS): Use $(in-module).
* Makerules: Don't suffix routine names for nonlib.
* include/libc-modules.h: New file.
* include/libc-symbols.h: Include libc-modules.h
(IS_IN): New macro to replace IS_IN_* macros.
* elf/Makefile: Set libof-* for each routine.
* elf/rtld-Rules: Likewise.
* extra-modules.mk: Likewise.
* iconv/Makefile: Likewise.
* iconvdata/Makefile: Likewise.
* locale/Makefile: Likewise.
* malloc/Makefile: Likewise.
* nss/Makefile: Likewise.
* sysdeps/gnu/Makefile: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile: Likewise.
* sysdeps/unix/sysv/linux/Makefile: Likewise.
* sysdeps/s390/s390-64/Makefile: Likewise.
* nscd/Makefile: Set libof-* for each routine.  Set CFLAGS and
CPPFLAGS for nscd instead of nonlib.

9 years agoNPTL: Add stub createthread.c
Roland McGrath [Tue, 18 Nov 2014 19:03:35 +0000 (11:03 -0800)]
NPTL: Add stub createthread.c

9 years agoNPTL: Move Linux-specific createthread.c to sysdeps.
Roland McGrath [Tue, 18 Nov 2014 19:03:20 +0000 (11:03 -0800)]
NPTL: Move Linux-specific createthread.c to sysdeps.

9 years agoNPTL: Refactor createthread.c
Roland McGrath [Tue, 18 Nov 2014 19:03:00 +0000 (11:03 -0800)]
NPTL: Refactor createthread.c

9 years agoFix libm mpone, mptwo namespace (bug 17616).
Joseph Myers [Tue, 18 Nov 2014 15:40:56 +0000 (15:40 +0000)]
Fix libm mpone, mptwo namespace (bug 17616).

libm uses symbols mpone and mptwo for internal purposes.  This patch
moves them to the implementation namespace (__mpone and __mptwo).

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

[BZ #17616]
* sysdeps/ieee754/dbl-64/mpa.c (mpone): Rename to __mpone.
(mptwo): Rename to __mptwo.
(__inv): Use __mptwo instead of mptwo.
* sysdeps/ieee754/dbl-64/mpa.h (mpone): Rename to __mpone.
(mptwo): Rename to __mptwo.
* sysdeps/ieee754/dbl-64/mpatan.c (__mpatan): Use __mpone instead
of mpone and __mptwo instead of mptwo.
* sysdeps/ieee754/dbl-64/mpatan2.c (__mpatan2): Use __mpone
instead of mpone.
* sysdeps/ieee754/dbl-64/mpexp.c (__mpexp): Likewise.
* sysdeps/ieee754/dbl-64/mplog.c (__mplog): Likewise.
* sysdeps/ieee754/dbl-64/sincos32.c (__c32): Use __mpone instead
of mpone and __mptwo instead of mptwo.
(__mpranred): Use __mpone instead of mpone.
* conform/Makefile (test-xfail-ISO/math.h/linknamespace): Remove
variable.
(test-xfail-ISO99/complex.h/linknamespace): Likewise.
(test-xfail-ISO99/math.h/linknamespace): Likewise.
(test-xfail-ISO99/tgmath.h/linknamespace): Likewise.
(test-xfail-ISO11/complex.h/linknamespace): Likewise.
(test-xfail-ISO11/math.h/linknamespace): Likewise.
(test-xfail-ISO11/tgmath.h/linknamespace): Likewise.
(test-xfail-XPG3/math.h/linknamespace): Likewise.
(test-xfail-XPG4/math.h/linknamespace): Likewise.
(test-xfail-POSIX/math.h/linknamespace): Likewise.
(test-xfail-UNIX98/math.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/complex.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/math.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/tgmath.h/linknamespace): Likewise.
(test-xfail-POSIX2008/complex.h/linknamespace): Likewise.
(test-xfail-POSIX2008/math.h/linknamespace): Likewise.
(test-xfail-POSIX2008/tgmath.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/complex.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/math.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/tgmath.h/linknamespace): Likewise.

9 years agoFix crossreference to nonexistent node BSD Handler
Tom de Vries [Tue, 18 Nov 2014 10:14:13 +0000 (11:14 +0100)]
Fix crossreference to nonexistent node BSD Handler

2014-11-18  Tom de Vries  <tom@codesoucery.com>

* manual/signal.texi (Primitives Interrupted by Signals): In section,
replace BSD Handler xref with BSD Signal Handling.

9 years agoalpha: Fix soft-fp breakage
Richard Henderson [Mon, 17 Nov 2014 17:20:02 +0000 (09:20 -0800)]
alpha: Fix soft-fp breakage

Commit 5c0508a318af0a6c8be2a4cb2e3b76896218bf35 broke the Alpha
port, as the extra parenthesis got in the way of some token pasting
that we were doing in a redefined raw unpack macro.

Avoid this situation in the future by not attempting to redefine a
basic macro, but rather work from the outermost public interface.
The compiler does in fact see through the added indirection.

* sysdeps/alpha/soft-fp/local-soft-fp.h (_FP_UNPACK_RAW_2): Remove.
(_FP_PACK_RAW_2): Remove.
(AXP_DECL_RETURN_Q): Rename from FP_DECL_RETURN, use _FP_UNION_Q.
(AXP_RETURN_Q): Rename from FP_RETURN, use _FP_UNION_Q.
(AXP_UNPACK_RAW_Q, AXP_UNPACK_SEMIRAW_Q, AXP_UNPACK_Q): New.
(AXP_PACK_RAW_Q, AXP_PACK_SEMIRAW_Q, AXP_PACK_Q): New.
* sysdeps/alpha/soft-fp/ots_add.c (_OtsAddX): Update to match.
* sysdeps/alpha/soft-fp/ots_cmp.c (internal_equality): Likewise.
* sysdeps/alpha/soft-fp/ots_cmpe.c (internal_compare): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtqux.c (_OtsCvtQUX): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtqx.c (_OtsCvtQX): Likewise.
* sysdeps/alpha/soft-fp/ots_cvttx.c (_OtsConvertFloatTX): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtxq.c (_OtsCvtXQ): Likewise.
* sysdeps/alpha/soft-fp/ots_cvtxt.c (_OtsConvertFloatXT): Likewise.
* sysdeps/alpha/soft-fp/ots_div.c (_OtsDivX): Likewise.
* sysdeps/alpha/soft-fp/ots_mul.c (_OtsMulX): Likewise.
* sysdeps/alpha/soft-fp/ots_nintxq.c (_OtsNintXQ): Likewise.
* sysdeps/alpha/soft-fp/ots_sub.c (_OtsSubX): Likewise.

9 years agoRemove sigvec.
Roland McGrath [Fri, 14 Nov 2014 18:52:16 +0000 (10:52 -0800)]
Remove sigvec.

9 years agoRemove x86_64 __GNUC_PREREQ (4, 6) conditional.
Joseph Myers [Fri, 14 Nov 2014 18:53:07 +0000 (18:53 +0000)]
Remove x86_64 __GNUC_PREREQ (4, 6) conditional.

This patch removes a conditional on __GNUC_PREREQ (4, 6) in x86_64
code.

Tested for x86_64 that installed shared libraries are unchanged by
this patch.  Committed (I think this file reasonably comes under math
maintainership).

* sysdeps/x86_64/fpu/dla.h [__FMA4__ && __GNUC_PREREQ (4, 6)]
(DLA_FMS): Make definition conditional only on [__FMA4__].
[__FMA4__ && !__GNUC_PREREQ (4, 6)] (DLA_FMS): Remove conditional
definition.

9 years agoRemove ARM __GNUC_PREREQ(4,4) conditionals.
Joseph Myers [Fri, 14 Nov 2014 18:39:33 +0000 (18:39 +0000)]
Remove ARM __GNUC_PREREQ(4,4) conditionals.

This patch removes conditionals in ARM code on __GNUC_PREREQ(4,4),
which were already obsolete even before the move from 4.4 to 4.6 as
minimum GCC version for building glibc.

Tested for ARM that installed shared libraries are unchanged by this
patch.

* sysdeps/arm/sysdep.h [PROF && __GNUC_PREREQ(4,4)] (CALL_MCOUNT):
Make definition conditional only on [PROF].
[PROF && !__GNUC_PREREQ(4,4)] (CALL_MCOUNT): Remove conditional
definition.
[__GNUC_PREREQ(4,4)] (mcount): Make definition unconditional.
[!__GNUC_PREREQ(4,4)] (mcount): Remove conditional definition.

9 years agoOnly declare __sigpause in installed signal.h when necessary.
Joseph Myers [Fri, 14 Nov 2014 18:35:42 +0000 (18:35 +0000)]
Only declare __sigpause in installed signal.h when necessary.

This patch makes the installed signal.h declare __sigpause only when
necessary (when a macro definition of sigpause makes use of
__sigpause), rather than unconditionally.  This fixes false positives
in the linknamespace tests by making it visible to those tests that no
use of ISO C functionality will actually bring in the definition of
__sigpause and so bring in the other symbols defined in the same
object.  There is no bug filed in Bugzilla because this is fixing
false positives rather than any user-visible bug.

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

* signal/signal.h (__sigpause): Only declare if [__USE_XOPEN &&
!__GNUC__].
* include/signal.h (__sigpause): Move declaration above call to
libc_hidden_proto.
* conform/Makefile (test-xfail-ISO/signal.h/linknamespace): Remove
variable.
(test-xfail-ISO99/signal.h/linknamespace): Likewise.
(test-xfail-ISO11/signal.h/linknamespace): Likewise.

9 years agoFix sparc build.
David S. Miller [Fri, 14 Nov 2014 18:32:52 +0000 (10:32 -0800)]
Fix sparc build.

* sysdeps/sparc/sparc64/rtld-memcpy.c (NO_MEMPCPY_STPCPY_REDIRECT):
Define before including <string/memcpy.c> and <string/mempcpy.c>.

9 years agoRequire GCC 4.6 or later to build glibc.
Joseph Myers [Fri, 14 Nov 2014 18:00:34 +0000 (18:00 +0000)]
Require GCC 4.6 or later to build glibc.

As discussed in the thread starting at
<https://sourceware.org/ml/libc-alpha/2014-10/msg00792.html>, and
continuing into November, this patch increases the minimum GCC version
for building glibc to 4.6 (there seemed to be no clear consensus for
4.7).  In particular, this allows us to use #pragma GCC diagnostic for
fine-grained warning control with -Werror (subject to establishing a
suitable policy for that use).  The documentation has a statement, as
requested, about the most recent GCC version tested for building
glibc, and I've updated <https://sourceware.org/glibc/wiki/Release> to
refer to updating that statement.  A NEWS entry is added for this
change, although previous such changes didn't get them.

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

* configure.ac (libc_cv_compiler_ok): Require GCC 4.6 or later.
* configure: Regenerated.
* manual/install.texi (Tools for Compilation): Document a
requirement of GCC 4.6 or later and that GCC 4.9 is the newest
compiler verified to work.
* INSTALL: Regenerated.

9 years agoFix build of C mempcpy and stpcpy.
Joseph Myers [Fri, 14 Nov 2014 13:48:39 +0000 (13:48 +0000)]
Fix build of C mempcpy and stpcpy.

This patch fixes the build of C mempcpy and stpcpy by disabling the
redirection to __mempcpy and __stpcpy asm names if
NO_MEMPCPY_STPCPY_REDIRECT is defined, and defining that macro in the
relevant source files.

Tested for powerpc32 that the build is fixed.

* include/string.h [NO_MEMPCPY_STPCPY_REDIRECT] (mempcpy): Do not
redeclare with asm name.
[NO_MEMPCPY_STPCPY_REDIRECT] (stpcpy): Likewise.
* string/mempcpy.c (NO_MEMPCPY_STPCPY_REDIRECT): Define before
including <string.h>.
* string/stpcpy.c (NO_MEMPCPY_STPCPY_REDIRECT): Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c
[!NOT_IN_libc] (NO_MEMPCPY_STPCPY_REDIRECT): Likewise.
* sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
[!NOT_IN_libc] (NO_MEMPCPY_STPCPY_REDIRECT): Likewise.
* sysdeps/powerpc/powerpc64/multiarch/stpcpy.c
[SHARED && !NOT_IN_libc] (NO_MEMPCPY_STPCPY_REDIRECT): Likewise.

9 years agoUse prototype definition for __strtol.
Joseph Myers [Thu, 13 Nov 2014 21:37:53 +0000 (21:37 +0000)]
Use prototype definition for __strtol.

This patch fixes those warnings by using a prototype definition for
__strtol.

Tested for x86_64 that stripped installed shared libraries are
unchanged by this patch.

* stdlib/strtol.c (__strtol): Use prototype definition.

9 years agoFix strtoll / strtoull namespace for 32-bit (bug 17594).
Joseph Myers [Thu, 13 Nov 2014 19:50:55 +0000 (19:50 +0000)]
Fix strtoll / strtoull namespace for 32-bit (bug 17594).

For 32-bit platforms, strtoll and strtoull are strong symbols in libc,
but they are not in ISO C90, and are brought in by references to
__strtoll_internal / __strtoull_internal from scanf.  (For 64-bit
platforms, they are properly weak.)  This patch makes them weak for
32-bit (it has a side-effect of making other symbols weak that don't
need to be weak, such as strtol, but that's harmless).

Tested for x86 (testsuite, and that the disassembly of installed
shared libraries is unchanged by the patch).  This fixes all 120
unXFAILed FAILs of the new linknamespace tests seen for x86 (in fact,
there are now seven XPASSes of those tests for x86

XPASS: conform/POSIX2008/fcntl.h/linknamespace
XPASS: conform/UNIX98/libgen.h/linknamespace
XPASS: conform/XOPEN2K/fcntl.h/linknamespace
XPASS: conform/XOPEN2K/libgen.h/linknamespace
XPASS: conform/XOPEN2K8/fcntl.h/linknamespace
XPASS: conform/XOPEN2K8/libgen.h/linknamespace
XPASS: conform/XPG4/libgen.h/linknamespace

so suggesting that the failures seen for those on x86_64 are in some
way architecture-specific or 64-bit-specific).

[BZ #17594]
* stdlib/strtol.c (SYM__): New macro.
(SYM__1): Likewise.
(__strtol): Likewise.
(strtol): Rename to __strtol and define as weak alias of
__strtol.  Use libc_hidden_weak.

9 years agoS/390: dl-machine.h: Use numbered labels in inline assembly.
Stefan Liebler [Thu, 13 Nov 2014 09:45:28 +0000 (10:45 +0100)]
S/390: dl-machine.h: Use numbered labels in inline assembly.

9 years agoS/390: Add SystemTap probes to longjmp and setjmp.
Stefan Liebler [Thu, 13 Nov 2014 09:44:42 +0000 (10:44 +0100)]
S/390: Add SystemTap probes to longjmp and setjmp.

9 years agoS/390: Get rid of warning unused variable in dl-machine.h.
Stefan Liebler [Thu, 13 Nov 2014 09:44:11 +0000 (10:44 +0100)]
S/390: Get rid of warning unused variable in dl-machine.h.

9 years agoS/390: Get rid of warning: the comparision will always evaluate as false.
Stefan Liebler [Thu, 13 Nov 2014 09:42:31 +0000 (10:42 +0100)]
S/390: Get rid of warning: the comparision will always evaluate as false.

9 years agoNPTL: Move __libc_multiple_threads_ptr defn to nptl-init.c
Roland McGrath [Wed, 12 Nov 2014 22:50:09 +0000 (14:50 -0800)]
NPTL: Move __libc_multiple_threads_ptr defn to nptl-init.c

9 years agoAdd tests for namespace for static linking.
Joseph Myers [Wed, 12 Nov 2014 22:45:25 +0000 (22:45 +0000)]
Add tests for namespace for static linking.

One thing we currently try to ensure manually is that glibc is
namespace-clean for static linking; that is, if you only use features
from a particular standard (including the set of features exposed by
headers given feature test macros such as _DEFAULT_SOURCE that don't
correspond to any written standard), the library objects brought in by
the static linker will not define or use (strong) names that are
reserved to the user in that standard.

This patch implements automatic tests for this, using the same set of
standards as for the header conformance tests (it would, however, be
easy to add more standards for this testing, without them needing to
have the definitions of expected header contents for the header
tests).  The tests are based on the functions declared in each header,
as extracted using GCC's -aux-info option.  The following comment from
linknamespace.pl explains the caveats around this approach:

Here's an example of the output for ISO (C90) assert.h, from before my
recent fixes and whitelisting of cases that seem more complicated to
fix:

[initial] __assert_fail -> [libc.a(assert.o)] free -> [libc.a(malloc.o)] __get_nprocs -> [libc.a(getsysstats.o)] fgets_unlocked
[initial] __assert_fail -> [libc.a(assert.o)] __dcgettext -> [libc.a(dcgettext.o)] __dcigettext -> [libc.a(dcigettext.o)] __libc_setlocale_lock -> [libc.a(setlocale.o)] _nl_archive_subfreeres -> [libc.a(loadarchive.o)] __sysconf -> [libc.a(sysconf.o)] __tzname_max -> [libc.a(tzset.o)] __tzfile_compute -> [libc.a(tzfile.o)] fileno
[initial] __assert_fail -> [libc.a(assert.o)] __dcgettext -> [libc.a(dcgettext.o)] __dcigettext -> [libc.a(dcigettext.o)] __libc_setlocale_lock -> [libc.a(setlocale.o)] _nl_archive_subfreeres -> [libc.a(loadarchive.o)] __sysconf -> [libc.a(sysconf.o)] __tzname_max -> [libc.a(tzset.o)] __tzfile_compute -> [libc.a(tzfile.o)] fread_unlocked
[initial] __assert_fail -> [libc.a(assert.o)] __dcgettext -> [libc.a(dcgettext.o)] __dcigettext -> [libc.a(dcigettext.o)] __libc_setlocale_lock -> [libc.a(setlocale.o)] _nl_archive_subfreeres -> [libc.a(loadarchive.o)] __sysconf -> [libc.a(sysconf.o)] __tzname_max -> [libc.a(tzset.o)] __tzfile_compute -> [libc.a(tzfile.o)] ftello
[initial] __assert_fail -> [libc.a(assert.o)] free -> [libc.a(malloc.o)] malloc_info
[initial] __assert_fail -> [libc.a(assert.o)] __dcgettext -> [libc.a(dcgettext.o)] __dcigettext -> [libc.a(dcigettext.o)] __libc_setlocale_lock -> [libc.a(setlocale.o)] _nl_default_locale_path -> [libc.a(findlocale.o)] memmem
[initial] __assert_perror_fail -> [libc.a(assert-perr.o)] __strerror_r -> [libc.a(_strerror.o)] mempcpy
[initial] __assert_fail -> [libc.a(assert.o)] __dcgettext -> [libc.a(dcgettext.o)] __dcigettext -> [libc.a(dcigettext.o)] _nl_find_domain -> [libc.a(finddomain.o)] _nl_expand_alias -> [libc.a(localealias.o)] qsort -> [libc.a(msort.o)] qsort_r
[initial] __assert_fail -> [libc.a(assert.o)] _dl_pagesize -> [libc.a(dl-support.o)] __rawmemchr -> [libc.a(rawmemchr.o)] rawmemchr
[initial] __assert_fail -> [libc.a(assert.o)] __dcgettext -> [libc.a(dcgettext.o)] __dcigettext -> [libc.a(dcigettext.o)] __getcwd -> [libc.a(getcwd.o)] rewinddir
[initial] __assert_fail -> [libc.a(assert.o)] stderr
[initial] __assert_fail -> [libc.a(assert.o)] stderr -> [libc.a(stdio.o)] stdin
[initial] __assert_fail -> [libc.a(assert.o)] stderr -> [libc.a(stdio.o)] stdout
[initial] __assert_fail -> [libc.a(assert.o)] __dcgettext -> [libc.a(dcgettext.o)] __dcigettext -> [libc.a(dcigettext.o)] stpcpy
[initial] __assert_fail -> [libc.a(assert.o)] __fxprintf -> [libc.a(fxprintf.o)] _IO_vfprintf -> [libc.a(vfprintf.o)] __printf_fp -> [libc.a(printf_fp.o)] wmemset

Of the 161 XFAILs, seven are the inevitable varargs.h and ndbm.h
failures; I think the remaining 154 mostly represent genuine bugs in
glibc that should mostly be straightforward to fix (probably rather
fewer than 154 bugs - issues generally affect multiple headers, for
multiple standards).  (When fixing, of course you need to file a bug
in Bugzilla, and check for the possibility that the header
conditionals are what's incorrect - that the first listed symbol
shouldn't have been declared, or that the symbol finally brought in
should have been declared.)

* conform/GlibcConform.pm: New file.
* conform/conformtest.pl: Use GlibcConform module.
* conform/linknamespace.pl: New file.
* conform/list-header-symbols.pl: Likewise.
* conform/Makefile (linknamespace-symlists-base): New variable.
(linknamespace-symlists-tests): Likewise.
(linknamespace-header-base): Likewise.
(linknamespace-header-tests): Likewise.
(tests-special): Add new tests.
($(linknamespace-symlists-tests)): New rule.
(linknamespace-libs): New variable.
($(objpfx)symlist-stdlibs): New rule.
($(linknamespace-header-tests)): Likewise.
(test-xfail-XPG3/varargs.h/linknamespace): New variable.
(test-xfail-XPG4/varargs.h/linknamespace): Likewise.
(test-xfail-UNIX98/varargs.h/linknamespace): Likewise.
(test-xfail-XPG4/ndbm.h/linknamespace): Likewise.
(test-xfail-UNIX98/ndbm.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/ndbm.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/ndbm.h/linknamespace): Likewise.
(test-xfail-ISO/math.h/linknamespace): Likewise.
(test-xfail-ISO/signal.h/linknamespace): Likewise.
(test-xfail-ISO/stdio.h/linknamespace): Likewise.
(test-xfail-ISO/time.h/linknamespace): Likewise.
(test-xfail-ISO99/complex.h/linknamespace): Likewise.
(test-xfail-ISO99/ctype.h/linknamespace): Likewise.
(test-xfail-ISO99/math.h/linknamespace): Likewise.
(test-xfail-ISO99/signal.h/linknamespace): Likewise.
(test-xfail-ISO99/stdio.h/linknamespace): Likewise.
(test-xfail-ISO99/tgmath.h/linknamespace): Likewise.
(test-xfail-ISO11/complex.h/linknamespace): Likewise.
(test-xfail-ISO11/ctype.h/linknamespace): Likewise.
(test-xfail-ISO11/math.h/linknamespace): Likewise.
(test-xfail-ISO11/signal.h/linknamespace): Likewise.
(test-xfail-ISO11/stdio.h/linknamespace): Likewise.
(test-xfail-ISO11/tgmath.h/linknamespace): Likewise.
(test-xfail-XPG3/ctype.h/linknamespace): Likewise.
(test-xfail-XPG3/fnmatch.h/linknamespace): Likewise.
(test-xfail-XPG3/glob.h/linknamespace): Likewise.
(test-xfail-XPG3/math.h/linknamespace): Likewise.
(test-xfail-XPG3/regex.h/linknamespace): Likewise.
(test-xfail-XPG3/search.h/linknamespace): Likewise.
(test-xfail-XPG3/stdio.h/linknamespace): Likewise.
(test-xfail-XPG3/time.h/linknamespace): Likewise.
(test-xfail-XPG3/unistd.h/linknamespace): Likewise.
(test-xfail-XPG3/wordexp.h/linknamespace): Likewise.
(test-xfail-XPG4/ctype.h/linknamespace): Likewise.
(test-xfail-XPG4/fmtmsg.h/linknamespace): Likewise.
(test-xfail-XPG4/fnmatch.h/linknamespace): Likewise.
(test-xfail-XPG4/glob.h/linknamespace): Likewise.
(test-xfail-XPG4/grp.h/linknamespace): Likewise.
(test-xfail-XPG4/libgen.h/linknamespace): Likewise.
(test-xfail-XPG4/math.h/linknamespace): Likewise.
(test-xfail-XPG4/netdb.h/linknamespace): Likewise.
(test-xfail-XPG4/pwd.h/linknamespace): Likewise.
(test-xfail-XPG4/regex.h/linknamespace): Likewise.
(test-xfail-XPG4/search.h/linknamespace): Likewise.
(test-xfail-XPG4/stdio.h/linknamespace): Likewise.
(test-xfail-XPG4/stdlib.h/linknamespace): Likewise.
(test-xfail-XPG4/sys/mman.h/linknamespace): Likewise.
(test-xfail-XPG4/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-XPG4/syslog.h/linknamespace): Likewise.
(test-xfail-XPG4/time.h/linknamespace): Likewise.
(test-xfail-XPG4/unistd.h/linknamespace): Likewise.
(test-xfail-XPG4/wordexp.h/linknamespace): Likewise.
(test-xfail-POSIX/aio.h/linknamespace): Likewise.
(test-xfail-POSIX/fnmatch.h/linknamespace): Likewise.
(test-xfail-POSIX/glob.h/linknamespace): Likewise.
(test-xfail-POSIX/math.h/linknamespace): Likewise.
(test-xfail-POSIX/mqueue.h/linknamespace): Likewise.
(test-xfail-POSIX/pthread.h/linknamespace): Likewise.
(test-xfail-POSIX/regex.h/linknamespace): Likewise.
(test-xfail-POSIX/sched.h/linknamespace): Likewise.
(test-xfail-POSIX/semaphore.h/linknamespace): Likewise.
(test-xfail-POSIX/sys/mman.h/linknamespace): Likewise.
(test-xfail-POSIX/time.h/linknamespace): Likewise.
(test-xfail-POSIX/unistd.h/linknamespace): Likewise.
(test-xfail-POSIX/wordexp.h/linknamespace): Likewise.
(test-xfail-UNIX98/aio.h/linknamespace): Likewise.
(test-xfail-UNIX98/ctype.h/linknamespace): Likewise.
(test-xfail-UNIX98/fmtmsg.h/linknamespace): Likewise.
(test-xfail-UNIX98/fnmatch.h/linknamespace): Likewise.
(test-xfail-UNIX98/glob.h/linknamespace): Likewise.
(test-xfail-UNIX98/grp.h/linknamespace): Likewise.
(test-xfail-UNIX98/libgen.h/linknamespace): Likewise.
(test-xfail-UNIX98/math.h/linknamespace): Likewise.
(test-xfail-UNIX98/mqueue.h/linknamespace): Likewise.
(test-xfail-UNIX98/netdb.h/linknamespace): Likewise.
(test-xfail-UNIX98/pthread.h/linknamespace): Likewise.
(test-xfail-UNIX98/pwd.h/linknamespace): Likewise.
(test-xfail-UNIX98/regex.h/linknamespace): Likewise.
(test-xfail-UNIX98/sched.h/linknamespace): Likewise.
(test-xfail-UNIX98/search.h/linknamespace): Likewise.
(test-xfail-UNIX98/semaphore.h/linknamespace): Likewise.
(test-xfail-UNIX98/stdio.h/linknamespace): Likewise.
(test-xfail-UNIX98/stdlib.h/linknamespace): Likewise.
(test-xfail-UNIX98/sys/mman.h/linknamespace): Likewise.
(test-xfail-UNIX98/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-UNIX98/syslog.h/linknamespace): Likewise.
(test-xfail-UNIX98/time.h/linknamespace): Likewise.
(test-xfail-UNIX98/unistd.h/linknamespace): Likewise.
(test-xfail-UNIX98/wchar.h/linknamespace): Likewise.
(test-xfail-UNIX98/wordexp.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/aio.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/complex.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/fcntl.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/fmtmsg.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/fnmatch.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/glob.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/grp.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/libgen.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/math.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/mqueue.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/net/if.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/netdb.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/pthread.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/pwd.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/regex.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/search.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/semaphore.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/signal.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/spawn.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/stdlib.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/sys/mman.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/sys/wait.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/syslog.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/tgmath.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/time.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/ucontext.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/unistd.h/linknamespace): Likewise.
(test-xfail-XOPEN2K/wordexp.h/linknamespace): Likewise.
(test-xfail-POSIX2008/aio.h/linknamespace): Likewise.
(test-xfail-POSIX2008/complex.h/linknamespace): Likewise.
(test-xfail-POSIX2008/ctype.h/linknamespace): Likewise.
(test-xfail-POSIX2008/dirent.h/linknamespace): Likewise.
(test-xfail-POSIX2008/fcntl.h/linknamespace): Likewise.
(test-xfail-POSIX2008/grp.h/linknamespace): Likewise.
(test-xfail-POSIX2008/math.h/linknamespace): Likewise.
(test-xfail-POSIX2008/mqueue.h/linknamespace): Likewise.
(test-xfail-POSIX2008/net/if.h/linknamespace): Likewise.
(test-xfail-POSIX2008/netdb.h/linknamespace): Likewise.
(test-xfail-POSIX2008/pthread.h/linknamespace): Likewise.
(test-xfail-POSIX2008/regex.h/linknamespace): Likewise.
(test-xfail-POSIX2008/semaphore.h/linknamespace): Likewise.
(test-xfail-POSIX2008/spawn.h/linknamespace): Likewise.
(test-xfail-POSIX2008/sys/mman.h/linknamespace): Likewise.
(test-xfail-POSIX2008/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-POSIX2008/tgmath.h/linknamespace): Likewise.
(test-xfail-POSIX2008/time.h/linknamespace): Likewise.
(test-xfail-POSIX2008/unistd.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/aio.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/complex.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/dirent.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/fcntl.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/fmtmsg.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/grp.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/libgen.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/math.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/mqueue.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/net/if.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/netdb.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/pthread.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/pwd.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/regex.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/search.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/semaphore.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/spawn.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/sys/mman.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/sys/statvfs.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/syslog.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/tgmath.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/time.h/linknamespace): Likewise.
(test-xfail-XOPEN2K8/unistd.h/linknamespace): Likewise.

9 years agoFix localealias.c fgets_unlocked namespace (bug 17589).
Joseph Myers [Wed, 12 Nov 2014 22:42:22 +0000 (22:42 +0000)]
Fix localealias.c fgets_unlocked namespace (bug 17589).

intl/localealias.c is brought in by ISO C functions, but uses
fgets_unlocked, which is not an ISO C function.  This patch changes
this to use __fgets_unlocked.

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

[BZ #17589]
* intl/localealias.c [_LIBC] (FGETS): Use __fgets_unlocked instead
of fgets_unlocked.

9 years agoFix locale memmem namespace (bug 17585).
Joseph Myers [Wed, 12 Nov 2014 22:41:03 +0000 (22:41 +0000)]
Fix locale memmem namespace (bug 17585).

Locale code, brought in by ISO C functions, calls memmem, which is not
an ISO C function.  This isn't an ISO C conformance bug, because all
mem* names are reserved, but glibc practice is not to rely on that
reservation (thus, memmem is only declared in string.h if __USE_GNU
even though ISO C would allow it to be declared unconditionally, for
example).  This patch changes that code to use __memmem.

Note: there are uses of memmem elsewhere in glibc that I didn't
change, although it may turn out some of those also need to use
__memmem.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by this patch).

[BZ #17585]
* string/memmem.c [!_LIBC] (__memmem): Define to memmem.
(memmem): Rename to __memmem and define as weak alias of
__memmem.  Use libc_hidden_weak.
(__memmem): Use libc_hidden_def.
* include/string.h (__memmem): Declare.  Use libc_hidden_proto.
* locale/findlocale.c (valid_locale_name): Use __memmem instead of
memmem.

9 years agoFix __get_nprocs fgets_unlocked namespace (bug 17582).
Joseph Myers [Wed, 12 Nov 2014 22:39:36 +0000 (22:39 +0000)]
Fix __get_nprocs fgets_unlocked namespace (bug 17582).

__get_nprocs is called from malloc code, but calls fgets_unlocked,
which is not an ISO C or POSIX function.  This patch fixes it to call
a new __fgets_unlocked name instead.

Note: there are various other uses of fgets_unlocked in glibc's
libraries, and I haven't yet investigated which others might also be
problematic (called directly or indirectly from standard functions)
and so need to change to use __fgets_unlocked.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).

[BZ #17582]
* libio/iofgets.c [weak_alias && !_IO_MTSAFE_IO]
(__fgets_unlocked): Add alias of _IO_fgets.  Use libc_hidden_def.
* libio/iofgets_u.c (fgets_unlocked): Rename to __fgets_unlocked
and define as weak alias of __fgets_unlocked.  Use
libc_hidden_weak.
(__fgets_unlocked): Use libc_hidden_def.
* include/stdio.h (__fgets_unlocked): Declare.  Use
libc_hidden_proto.
* sysdeps/unix/sysv/linux/getsysstats.c (phys_pages_info): Use
__fgets_unlocked instead of fgets_unlocked.
* sysdeps/unix/sysv/linux/alpha/getsysstats.c
(GET_NPROCS_CONF_PARSER): Likewise.
* sysdeps/unix/sysv/linux/sparc/getsysstats.c
(GET_NPROCS_CONF_PARSER): Likewise.

9 years agoFix __printf_fp wmemset namespace (bug 17574).
Joseph Myers [Wed, 12 Nov 2014 22:38:11 +0000 (22:38 +0000)]
Fix __printf_fp wmemset namespace (bug 17574).

__printf_fp calls wmemset, but that is not an ISO C90 function.  This
patch fixes it to call a new __wmemset name instead (with wmemset
being a weak alias).

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).

[BZ #17574]
* wcsmbs/wmemset.c (wmemset): Rename to __wmemset and define as
weak alias of __wmemset.  Use libc_hidden_weak.
(__wmemset): Use libc_hidden_def.
* include/wchar.h (__wmemset): Declare.  Use libc_hidden_proto.
* stdio-common/printf_fp.c (___printf_fp): Call __wmemset instead
of wmemset.

9 years agoFix stpcpy / mempcpy namespace (bug 17573).
Joseph Myers [Wed, 12 Nov 2014 22:36:34 +0000 (22:36 +0000)]
Fix stpcpy / mempcpy namespace (bug 17573).

Various glibc functions call __stpcpy and __mempcpy for namespace
reasons instead of plain stpcpy and mempcpy.  But __stpcpy and
__mempcpy are macros that call __builtin_stpcpy and __builtin_mempcpy,
and unless GCC optimizes the calls, they end up calling the C
functions stpcpy and mempcpy.

For calls from within shared libc, libc_hidden_builtin_proto ensures
that calls to those C functions are in turn mapped to call __GI_stpcpy
and __GI_mempcpy.  However, for static libc, and for calls from shared
libraries other than libc, the ELF symbols stpcpy and mempcpy end up
getting called, breaking the ISO C namespace (in the case of stpcpy)
or glibc conventions about not relying on the "future library
directions" reservations (in the case of mempcpy).

This patch fixes this by adding declarations of these functions to
include/string.h, under an appropriate condition, with __asm__ used to
change the assembler name used for calls (the mempcpy case was
previously discussed, and the approach for the fix is as I suggested
in <https://sourceware.org/ml/libc-alpha/2013-02/msg00063.html>).

Tested for x86_64 with the testsuite; also checked that dcigettext.o
(an example previously noted of undesired calls to stpcpy and mempcpy)
now calls __stpcpy and __mempcpy instead, as do non-libc shared
libraries (__stpcpy and __mempcpy were already exported from shared
libc).  Disassembly of installed shared libraries isn't easy to
compare because of reordered PLT entries resulting from the change in
functions called (libnsl, libnss_compat, libnss_dns, libnss_files,
libnss_hesiod, libnss_nis, libnss_nisplus, libpthread, librt all have
such changes).

[BZ #17573]
* include/string.h [NOT_IN_libc || !SHARED] (mempcpy): Declare
with asm name __mempcpy.
[NOT_IN_libc || !SHARED] (stpcpy): Declare with asm name __stpcpy.

9 years agoFix x86_64 rawmemchr namespace (bug 17572).
Joseph Myers [Wed, 12 Nov 2014 22:35:12 +0000 (22:35 +0000)]
Fix x86_64 rawmemchr namespace (bug 17572).

rawmemchr is not an ISO C function, but __rawmemchr is called from ISO
C functions, so rawmemchr should be a weak alias.  On most
architecture it is, but x86_64 defines the function as rawmemchr with
__rawmemchr as a strong alias.  This patch makes x86_64 follow the
same arrangements as other architectures.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).

[BZ #17572]
* sysdeps/x86_64/rawmemchr.S (rawmemchr): Rename to __rawmemchr
and define as weak alias of __rawmemchr.
(__rawmemchr): Do not define as strong alias of rawmemchr.

9 years agoFix qsort_r namespace (bug 17571).
Joseph Myers [Wed, 12 Nov 2014 22:33:41 +0000 (22:33 +0000)]
Fix qsort_r namespace (bug 17571).

qsort_r is defined in the same file as qsort, but is not an ISO C
function, so should be a weak alias for __qsort_r.  The uses in
getaddrinfo should also call __qsort_r, since getaddrinfo is a POSIX
function and qsort_r isn't.  This patch implements this.  Because nscd
uses the getaddrinfo sources outside libc, as do the tst-rfc3484
tests, a #define of __qsort_r to qsort_r is added there alongside the
similar defines for other libc-internal symbols used in getaddrinfo.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).

[BZ #17571]
* stdlib/msort.c (qsort_r): Rename to __qsort_r and define as weak
alias of __qsort_r.
(qsort): Call __qsort_r instead of qsort_r.
* include/stdlib.h (qsort_r): Do not call libc_hidden_proto.
(__qsort_r): Declare.  Call libc_hidden_proto.
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Call __qsort_r
instead of qsort_r.
* nscd/gai.c (__qsort_r): Define to qsort_r.
* posix/tst-rfc3484.c (__qsort_r): Likewise.
* posix/tst-rfc3484-2.c (__qsort_r): Likewise.
* posix/tst-rfc3484-3.c (__qsort_r): Likewise.

9 years agoFix malloc_info namespace (bug 17570).
Joseph Myers [Wed, 12 Nov 2014 22:31:38 +0000 (22:31 +0000)]
Fix malloc_info namespace (bug 17570).

malloc_info is defined in the same file as malloc and free, but is not
an ISO C function, so should be a weak symbol.  This patch makes it
so.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch).

[BZ #17570]
* malloc/malloc.c (malloc_info): Rename to __malloc_info and
define as weak alias of __malloc_info.

9 years agoFix __getcwd rewinddir namespace (bug 17584).
Joseph Myers [Wed, 12 Nov 2014 16:24:16 +0000 (16:24 +0000)]
Fix __getcwd rewinddir namespace (bug 17584).

__getcwd is called from dcigettext.o (brought in by various ISO C
functionality), but calls rewinddir, which is not an ISO C function.
This patch makes __getcwd call __rewinddir instead and makes rewinddir
a weak alias for __rewinddir.

Since getcwd.c is shared with gnulib (albeit not merged in either
direction for a long time, and omitted from gnulib's
config/srclist.txt list of shared files) I put in a #ifndef _LIBC
define of __rewinddir to rewinddir, although a future merged version
of getcwd could end up looking significantly different.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by this patch).

[BZ #17584]
* dirent/rewinddir.c (rewinddir): Rename to __rewinddir and define
as weak alias of __rewinddir.  Don't use libc_hidden_def.
(__rewinddir): Use libc_hidden_def.
* sysdeps/mach/hurd/rewinddir.c: Rename to __rewinddir and define
as weak alias of __rewinddir.  Don't use libc_hidden_def.
(__rewinddir): Use libc_hidden_def.
* sysdeps/posix/rewinddir.c: Rename to __rewinddir and define as
weak alias of __rewinddir.  Don't use libc_hidden_def.
(__rewinddir): Use libc_hidden_def.
* include/dirent.h (rewinddir): Don't use libc_hidden_proto.
(__rewinddir): Use libc_hidden_proto.
* sysdeps/posix/getcwd.c [!_LIBC] (__rewinddir): Define to
rewinddir.
(__getcwd): Use __rewinddir instead of rewinddir.

9 years agoFix tzfile.c namespace (bug 17583).
Joseph Myers [Wed, 12 Nov 2014 16:22:51 +0000 (16:22 +0000)]
Fix tzfile.c namespace (bug 17583).

tzfile.c is brought in by various ISO C functions, but calls fileno,
fread_unlocked and ftello, which are not ISO C functions.  This patch
adds names __fileno, __fread_unlocked and __ftello for those
functions, making tzfile.c use those new names.

Note: there are various uses of fileno elsewhere in glibc that I
didn't change, although it may turn out that some of those also need
to use __fileno.

Tested for x86_64 with the glibc testsuite.  Changed line numbers in
tzfile.c cause changes in assertions, and for some reason this ends up
with different instruction choice and register allocation, affecting
the size of __tzfile_read and so making comparison of disassembly for
libc.so problematic.

[BZ #17583]
* libio/fileno.c (fileno): Rename to __fileno and define as weak
alias of __fileno.  Use libc_hidden_weak.
(__fileno): Use libc_hidden_def.
[weak_alias] (fileno_unlocked): Define as weak alias of __fileno.
* libio/ftello.c (ftello): Rename to __ftello and define as weak
alias of __ftello.
[__OFF_T_MATCHES_OFF64_T] (ftello64): Define as weak alias of
__ftello.
* libio/iofread.c [weak_alias && !_IO_MTSAFE_IO]
(__fread_unlocked): Define as strong alias of _IO_fread.  Use
libc_hidden_def.
(fread_unlocked): Don't use libc_hidden_ver.
* libio/iofread_u.c (fread_unlocked): Rename to __fread_unlocked
and define as weak alias of __fread_unlocked.  Don't use
libc_hidden_def.
(__fread_unlocked): Use libc_hidden_def.
* include/stdio.h (__fileno): Declare.  Use libc_hidden_proto.
(ftello): Don't use libc_hidden_proto.
(__ftello): Declare.  Use libc_hidden_proto.
(fread_unlocked): Don't use libc_hidden_proto.
(__fread_unlocked): Declare.  Use libc_hidden_proto.
* time/tzfile.c (__tzfile_read): Use __fileno, __fread_unlocked
and __ftello instead of fileno, fread_unlocked and ftello.

9 years agoUse GOT instead of GOT12 all over
Siddhesh Poyarekar [Wed, 12 Nov 2014 09:02:41 +0000 (14:32 +0530)]
Use GOT instead of GOT12 all over

GOT12 is a synonym for GOT, so just use GOT everywhere for
consistency.  Generated code is unchanged on s390.

9 years agoFix stack alignment when loader is invoked directly
Siddhesh Poyarekar [Wed, 12 Nov 2014 14:00:24 +0000 (19:30 +0530)]
Fix stack alignment when loader is invoked directly

The s390 ABI requires the stack pointer to be aligned at 8-bytes.
When a program is invoked as an argument to the dynamic linker,
_dl_start_user adjusts the stack to remove the dynamic linker
arguments so that the program sees only its name and arguments.  This
may result in the stack being misaligned since each argument shift is
only a word and not a double-word.

This is now fixed shifting argv and envp down instead of shifting argc
up and reclaiming the stack.  This requires _dl_argv to be adjusted
and hence, is no longer relro.

9 years agoFix tst-strcoll-overflow returning before timeout (BZ #17506)
Leonhard Holz [Wed, 12 Nov 2014 11:40:21 +0000 (17:10 +0530)]
Fix tst-strcoll-overflow returning before timeout (BZ #17506)

Modifies the test examination in test-skeleton.c so that a test can be
successful if it is interrupted or it returns uninterrupted with the
expected status. For this both EXPECTED_SIGNAL and EXPECTED_STATUS
have to be set, as is done in tst-strcoll-overflow.c.

9 years agoNew Bhilodi and Tulu locales (BZ #17475)
Tatiana Udalova [Wed, 12 Nov 2014 11:36:39 +0000 (17:06 +0530)]
New Bhilodi and Tulu locales (BZ #17475)

9 years ago[AArch64] Add ipc.h.
Alan Hayward [Tue, 11 Nov 2014 16:32:34 +0000 (16:32 +0000)]
[AArch64] Add ipc.h.

Adding ipc.h for AArch64 adjusted to behave correctly on big endian
targets.

9 years agoFix ChangeLog formatting of previous commit.
Marcus Shawcroft [Tue, 11 Nov 2014 15:51:55 +0000 (15:51 +0000)]
Fix ChangeLog formatting of previous commit.

9 years ago[AArch64] End frame record chain correctly.
Renlin Li [Tue, 11 Nov 2014 15:02:02 +0000 (15:02 +0000)]
[AArch64] End frame record chain correctly.

9 years agoUpdate minimal required bunutils version to 2.22
Andrew Senkevich [Mon, 10 Nov 2014 19:16:46 +0000 (11:16 -0800)]
Update minimal required bunutils version to 2.22

10 years agom68k: don't expect PLT reference to __tls_get_addr
Andreas Schwab [Fri, 7 Nov 2014 16:36:36 +0000 (17:36 +0100)]
m68k: don't expect PLT reference to __tls_get_addr

10 years agoRemove __libc_waitpid function name.
Joseph Myers [Fri, 7 Nov 2014 01:27:16 +0000 (01:27 +0000)]
Remove __libc_waitpid function name.

Continuing the removal of unused __libc_* function names, this patch
removes the __libc_waitpid name.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by the patch; __waitpid, which is exported from
shared libc, changes from weak to strong on some configurations, which
is of no significance).

* include/sys/wait.h (__libc_waitpid): Remove declaration.
* posix/waitpid.c (__libc_waitpid): Rename to __waitpid.
(__waitpid): Don't define as alias.  Use libc_hidden_def not
libc_hidden_weak.
(waitpid): Define as alias of __waitpid.
* sysdeps/unix/bsd/waitpid.c (__libc_waitpid): Rename to
__waitpid.
(__waitpid): Don't define as alias.  Use libc_hidden_def not
libc_hidden_weak.
(waitpid): Define as alias of __waitpid.
* sysdeps/unix/sysv/linux/i386/syscalls.list (waitpid): Remove
__libc_waitpid alias.
* sysdeps/unix/sysv/linux/m68k/syscalls.list (waitpid): Likewise.
* sysdeps/unix/sysv/linux/powerpc/syscalls.list (waitpid):
Likewise.
* sysdeps/unix/sysv/linux/sh/syscalls.list (waitpid): Likewise.
* sysdeps/unix/sysv/linux/sparc/syscalls.list (waitpid): Likewise.
* sysdeps/unix/sysv/linux/tile/waitpid.S (__libc_waitpid): Remove
alias.
* sysdeps/unix/sysv/linux/waitpid.c (__libc_waitpid): Rename to
__waitpid.
(__waitpid): Don't define as alias.  Use libc_hidden_def not
libc_hidden_weak.
(waitpid): Define as alias of __waitpid.

10 years agomanual/llio.texi: Comment on write atomicity.
Carlos O'Donell [Thu, 6 Nov 2014 20:58:52 +0000 (15:58 -0500)]
manual/llio.texi: Comment on write atomicity.

We add Linux-realted comments about the atomicity of
write with respect to file offsets. As of Linux 3.14
the file offset update is atomic. That means that
multiple threads calling the write syscall can not possibly
get the same file offset. Therefore the writes should
not overlap and data should not be lost as is required
by POSIX.

10 years agoRun check-localpltk/textrel/execstack over ld.so.
Carlos O'Donell [Thu, 6 Nov 2014 20:48:44 +0000 (15:48 -0500)]
Run check-localpltk/textrel/execstack over ld.so.

For maximum paranoia we run ld.so through the normal set
of tests for all of the shared libraries. This includes
running ld.so through check-localplt, check-textrel, and
check-execstack. While none of these should trigger any
failures given the way ld.so is built, it might possibly
fail if a developer does something wrong. This paranoia
was triggered by a discussion over the use of __strcpy
vs. strcpy [1] and if the symbol could leak and use the
libc.so version.

The check-localplt test fails right away because localplt.data
needs updating for all arches. By default we add 6 new symbols:
__tls_get_addr, __libc_memalign, malloc, calloc, realloc and
free. Other machines like i386, power, and s390 require some
different symbol sets e.g. ___tls_get_addr vs. __tls_get_addr
for i386.

Verified for i386
Verified for x86_64
Verified for ppc32
Verified for ppc64
Verified for ppc64le
Verified for arm
Verified for aarch64
Verified for s390
Verified for s390x
Guessed for alpha
Guessed for ia64
Guessed for m68k
Guessed for microblaze
Guessed for sparc32
Guessed for sparc64
Defaults for sh
Defaults for mips
Defaults for hppa
Defaults for tile

Machine manintainers notified to double check the data
used in localplt.data.

[1] https://sourceware.org/ml/libc-alpha/2014-10/msg00548.html

10 years agoRemove INTDEF / INTUSE / INTVARDEF (bug 14132).
Joseph Myers [Wed, 5 Nov 2014 23:35:36 +0000 (23:35 +0000)]
Remove INTDEF / INTUSE / INTVARDEF (bug 14132).

Completing the removal of the obsolete INTDEF / INTUSE mechanism, this
patch removes the final use - that for _dl_starting_up - replacing it
by rtld_hidden_def / rtld_hidden_proto.  Having removed the last use,
the mechanism itself is also removed.

Tested for x86_64 that installed stripped shared libraries are
unchanged by the patch.  (This is not much of a test since this
variable is only defined and used in the !HAVE_INLINED_SYSCALLS case.)

[BZ #14132]
* include/libc-symbols.h (INTUSE): Remove macro.
(INTDEF): Likewise.
(INTVARDEF): Likewise.
(_INTVARDEF): Likewise.
(INTDEF2): Likewise.
(INTVARDEF2): Likewise.
* elf/rtld.c [!HAVE_INLINED_SYSCALLS] (_dl_starting_up): Use
rtld_hidden_def instead of INTVARDEF.
* sysdeps/generic/ldsodefs.h [IS_IN_rtld]
(_dl_starting_up_internal): Remove declaration.
(_dl_starting_up): Use rtld_hidden_proto.
* elf/dl-init.c [!HAVE_INLINED_SYSCALLS] (_dl_starting_up): Remove
declaration.
[!HAVE_INLINED_SYSCALLS] (_dl_starting_up_internal): Likewise.
(_dl_init) [!HAVE_INLINED_SYSCALLS]: Don't use INTUSE with
_dl_starting_up.
* elf/dl-writev.h (_dl_writev): Likewise.
* sysdeps/powerpc/powerpc64/dl-machine.h [!HAVE_INLINED_SYSCALLS]
(DL_STARTING_UP_DEF): Use __GI__dl_starting_up instead of
_dl_starting_up_internal.

10 years agolibio: Refactor tst-fmemopen to use test-skeleton.c
Adhemerval Zanella [Wed, 11 Jun 2014 18:00:14 +0000 (15:00 -0300)]
libio: Refactor tst-fmemopen to use test-skeleton.c

This patch refactor tst-fmemopen.c to use test-skeleton.c.  No logic
changes are added.

10 years agobenchtests: Add malloc microbenchmark
Will Newton [Wed, 11 Sep 2013 14:47:12 +0000 (15:47 +0100)]
benchtests: Add malloc microbenchmark

Add a microbenchmark for measuring malloc and free performance with
varying numbers of threads. The benchmark allocates and frees buffers
of random sizes in a random order and measures the overall execution
time and RSS. Variants of the benchmark are run with 1, 8, 16 and
32 threads.

The random block sizes used follow an inverse square distribution
which is intended to mimic the behaviour of real applications which
tend to allocate many more small blocks than large ones.

ChangeLog:

2014-11-05  Will Newton  <will.newton@linaro.org>

* benchtests/Makefile: (bench-malloc): Add malloc thread
scalability benchmark.
* benchtests/bench-malloc-threads.c: New file.

10 years ago[AArch64] Add optimized strchrnul.
Richard Earnshaw [Wed, 5 Nov 2014 13:51:56 +0000 (13:51 +0000)]
[AArch64] Add optimized strchrnul.

Here is an optimized implementation of __strchrnul.  The
simplification that we don't have to track precisely why the loop
terminates (match or end-of-string) means we have to do less work in
both setup and the core inner loop.  That means this should never be
slower than strchr.

As with strchr, the use of LD1 means we do not need different versions
for big-/little-endian.

10 years agopowerpc: Simplify encoding of POWER8 instruction
Adhemerval Zanella [Wed, 5 Nov 2014 13:01:09 +0000 (08:01 -0500)]
powerpc: Simplify encoding of POWER8 instruction

10 years agoModify several tests to use test-skeleton.c
Arjun Shankar [Wed, 5 Nov 2014 09:54:08 +0000 (15:24 +0530)]
Modify several tests to use test-skeleton.c

This patch modifies several test cases to use test-skeleton.c.
It was generated by a bash script written for this purpose and
thus excludes several other tests which I deemed worth a visual
inspection before making the change.

I intend to follow up with individual patches to the tests
skipped by the script.

The script itself resides at http://git.io/WODAmg and should
reproduce this very patch when run against master.

ChangeLog:

2014-10-30  Arjun Shankar  <arjun.is@lostca.se>

* catgets/test-gencat.c: Use test-skeleton.c.
* catgets/tst-catgets.c: Likewise.
* csu/tst-empty.c: Likewise.
* elf/tst-audit2.c: Likewise.
* elf/tst-global1.c: Likewise.
* elf/tst-pathopt.c: Likewise.
* elf/tst-piemod1.c: Likewise.
* elf/tst-tls10.c: Likewise.
* elf/tst-tls11.c: Likewise.
* elf/tst-tls12.c: Likewise.
* gnulib/tst-gcc.c: Likewise.
* iconvdata/tst-e2big.c: Likewise.
* iconvdata/tst-loading.c: Likewise.
* iconv/tst-iconv1.c: Likewise.
* iconv/tst-iconv2.c: Likewise.
* inet/test-inet6_opt.c: Likewise.
* inet/tst-gethnm.c: Likewise.
* inet/tst-network.c: Likewise.
* inet/tst-ntoa.c: Likewise.
* intl/tst-codeset.c: Likewise.
* intl/tst-gettext2.c: Likewise.
* intl/tst-gettext3.c: Likewise.
* intl/tst-ngettext.c: Likewise.
* intl/tst-translit.c: Likewise.
* io/test-stat.c: Likewise.
* libio/test-fmemopen.c: Likewise.
* libio/tst-freopen.c: Likewise.
* libio/tst-sscanf.c: Likewise.
* libio/tst-ungetwc1.c: Likewise.
* libio/tst-ungetwc2.c: Likewise.
* libio/tst-widetext.c: Likewise.
* localedata/tst-ctype.c: Likewise.
* localedata/tst-digits.c: Likewise.
* localedata/tst-leaks.c: Likewise.
* localedata/tst-mbswcs1.c: Likewise.
* localedata/tst-mbswcs2.c: Likewise.
* localedata/tst-mbswcs3.c: Likewise.
* localedata/tst-mbswcs4.c: Likewise.
* localedata/tst-mbswcs5.c: Likewise.
* localedata/tst-setlocale.c: Likewise.
* localedata/tst-trans.c: Likewise.
* localedata/tst-wctype.c: Likewise.
* localedata/tst-xlocale1.c: Likewise.
* login/tst-grantpt.c: Likewise.
* malloc/tst-calloc.c: Likewise.
* malloc/tst-malloc.c: Likewise.
* malloc/tst-mallocstate.c: Likewise.
* malloc/tst-mcheck.c: Likewise.
* malloc/tst-mtrace.c: Likewise.
* malloc/tst-obstack.c: Likewise.
* math/atest-exp2.c: Likewise.
* math/atest-exp.c: Likewise.
* math/atest-sincos.c: Likewise.
* math/test-matherr.c: Likewise.
* math/test-misc.c: Likewise.
* math/test-powl.c: Likewise.
* math/tst-definitions.c: Likewise.
* misc/tst-dirname.c: Likewise.
* misc/tst-efgcvt.c: Likewise.
* misc/tst-fdset.c: Likewise.
* misc/tst-hsearch.c: Likewise.
* misc/tst-mntent2.c: Likewise.
* nptl/tst-sem7.c: Likewise.
* nptl/tst-sem8.c: Likewise.
* nptl/tst-sem9.c: Likewise.
* nss/test-netdb.c: Likewise.
* posix/tst-fnmatch.c: Likewise.
* posix/tst-getlogin.c: Likewise.
* posix/tst-gnuglob.c: Likewise.
* posix/tst-mmap.c: Likewise.
* pwd/tst-getpw.c: Likewise.
* resolv/tst-inet_ntop.c: Likewise.
* rt/tst-timer.c: Likewise.
* stdio-common/test-fseek.c: Likewise.
* stdio-common/test-popen.c: Likewise.
* stdio-common/test-vfprintf.c: Likewise.
* stdio-common/tst-cookie.c: Likewise.
* stdio-common/tst-fileno.c: Likewise.
* stdio-common/tst-gets.c: Likewise.
* stdio-common/tst-obprintf.c: Likewise.
* stdio-common/tst-perror.c: Likewise.
* stdio-common/tst-sprintf2.c: Likewise.
* stdio-common/tst-sprintf3.c: Likewise.
* stdio-common/tst-sprintf.c: Likewise.
* stdio-common/tst-swprintf.c: Likewise.
* stdio-common/tst-tmpnam.c: Likewise.
* stdio-common/tst-unbputc.c: Likewise.
* stdio-common/tst-wc-printf.c: Likewise.
* stdlib/tst-environ.c: Likewise.
* stdlib/tst-fmtmsg.c: Likewise.
* stdlib/tst-limits.c: Likewise.
* stdlib/tst-rand48-2.c: Likewise.
* stdlib/tst-rand48.c: Likewise.
* stdlib/tst-random2.c: Likewise.
* stdlib/tst-random.c: Likewise.
* stdlib/tst-strtol.c: Likewise.
* stdlib/tst-strtoll.c: Likewise.
* stdlib/tst-tls-atexit.c: Likewise.
* stdlib/tst-xpg-basename.c: Likewise.
* string/test-ffs.c: Likewise.
* string/tst-bswap.c: Likewise.
* string/tst-inlcall.c: Likewise.
* string/tst-strtok.c: Likewise.
* string/tst-strxfrm.c: Likewise.
* sysdeps/x86_64/tst-audit10.c: Likewise.
* sysdeps/x86_64/tst-audit3.c: Likewise.
* sysdeps/x86_64/tst-audit4.c: Likewise.
* sysdeps/x86_64/tst-audit5.c: Likewise.
* time/tst-ftime_l.c: Likewise.
* time/tst-getdate.c: Likewise.
* time/tst-mktime3.c: Likewise.
* time/tst-mktime.c: Likewise.
* time/tst-posixtz.c: Likewise.
* time/tst-strptime2.c: Likewise.
* time/tst-strptime3.c: Likewise.
* wcsmbs/tst-btowc.c: Likewise.
* wcsmbs/tst-mbrtowc.c: Likewise.
* wcsmbs/tst-mbsrtowcs.c: Likewise.
* wcsmbs/tst-wchar-h.c: Likewise.
* wcsmbs/tst-wcpncpy.c: Likewise.
* wcsmbs/tst-wcrtomb.c: Likewise.
* wcsmbs/tst-wcsnlen.c: Likewise.
* wcsmbs/tst-wcstof.c: Likewise.

10 years agoDon't use INTDEF/INTUSE with _dl_mcount (bug 14132).
Joseph Myers [Wed, 5 Nov 2014 01:02:47 +0000 (01:02 +0000)]
Don't use INTDEF/INTUSE with _dl_mcount (bug 14132).

Continuing the removal of the obsolete INTDEF / INTUSE mechanism, this
patch replaces its use for _dl_mcount with use of rtld_hidden_def /
rtld_hidden_proto.

Tested for x86_64 that installed stripped shared libraries are
unchanged by the patch.

[BZ #14132]
* elf/dl-profile.c (_dl_mcount): Use rtld_hidden_def instead of
INTDEF.
* sysdeps/generic/ldsodefs.h (_dl_mcount_internal): Remove
declaration.
(_dl_mcount): Use rtld_hidden_proto.
* elf/dl-runtime.c (_dl_profile_fixup): Don't use INTUSE with
_dl_mcount.
* elf/rtld.c (_rtld_global_ro): Likewise.

10 years agoDon't use INTDEF/INTUSE with _dl_init (bug 14132).
Joseph Myers [Tue, 4 Nov 2014 23:26:39 +0000 (23:26 +0000)]
Don't use INTDEF/INTUSE with _dl_init (bug 14132).

Continuing the removal of the obsolete INTDEF / INTUSE mechanism, this
patch eliminates its use for _dl_init.  Since _dl_init was already
declared with hidden visibility, creating a second hidden alias for it
was completely pointless, so this patch replaces all uses of
_dl_init_internal with plain _dl_init instead of using hidden_proto /
hidden_def (which are only needed when you want a hidden alias for a
non-hidden symbol; it's quite possible there are cases where they are
used but don't need to be because the symbol in question is not part
of the public ABI and is only used within a single library, so using
attributes_hidden instead would suffice).

Tested for x86_64 that installed stripped shared libraries are
unchanged by the patch.

[BZ #14132]
* elf/dl-init.c (_dl_init): Don't use INTDEF.
* sysdeps/aarch64/dl-machine.h (RTLD_START): Use _dl_init instead
of _dl_init_internal.
* sysdeps/alpha/dl-machine.h (RTLD_START): Likewise.
* sysdeps/arm/dl-machine.h (RTLD_START): Likewise.
* sysdeps/hppa/dl-machine.h (RTLD_START): Likewise.
* sysdeps/i386/dl-machine.h (RTLD_START): Likewise.
* sysdeps/ia64/dl-machine.h (RTLD_START): Likewise.
* sysdeps/m68k/dl-machine.h (RTLD_START): Likewise.
* sysdeps/microblaze/dl-machine.h (RTLD_START): Likewise.
* sysdeps/mips/dl-machine.h (RTLD_START): Likewise.
* sysdeps/powerpc/powerpc32/dl-start.S (_start): Likewise.
* sysdeps/s390/s390-32/dl-machine.h (RTLD_START): Likewise.
* sysdeps/s390/s390-64/dl-machine.h (RTLD_START): Likewise.
* sysdeps/sh/dl-machine.h (RTLD_START): Likewise.
* sysdeps/sparc/sparc32/dl-machine.h (RTLD_START): Likewise.
* sysdeps/sparc/sparc64/dl-machine.h (RTLD_START): Likewise.
* sysdeps/tile/dl-start.S (_start): Likewise.
* sysdeps/x86_64/dl-machine.h (RTLD_START): Likewise.
* sysdeps/x86_64/x32/dl-machine.h (RTLD_START): Likewise.

10 years agoDon't use INTDEF/INTUSE with _dl_argv (bug 14132).
Joseph Myers [Tue, 4 Nov 2014 17:39:39 +0000 (17:39 +0000)]
Don't use INTDEF/INTUSE with _dl_argv (bug 14132).

Continuing the removal of the obsolete INTDEF / INTUSE mechanism, this
patch replaces its use for _dl_argv with rtld_hidden_data_def and
rtld_hidden_proto.  Some places in .S files that previously used
_dl_argv_internal or INTUSE(_dl_argv) now use __GI__dl_argv directly
(there are plenty of existing examples of such direct use of __GI_*).

A single place in rtld.c previously used _dl_argv without INTUSE,
apparently accidentally, while the rtld_hidden_proto mechanism avoids
such accidential omissions.  As a consequence, this patch *does*
change the contents of stripped ld.so.  However, the installed
stripped shared libraries are identical to those you get if instead of
this patch you change that single _dl_argv use to use INTUSE, without
any other changes.

Tested for x86_64 (testsuite as well as comparison of installed
stripped shared libraries as described above).

[BZ #14132]
* sysdeps/generic/ldsodefs.h (_dl_argv): Use rtld_hidden_proto.
[IS_IN_rtld] (_dl_argv_internal): Do not declare.
(rtld_progname): Make macro definition unconditional.
* elf/rtld.c (_dl_argv): Use rtld_hidden_data_def instead of
INTDEF.
(dlmopen_doit): Do not use INTUSE with _dl_argv.
(dl_main): Likewise.
* elf/dl-sysdep.c (_dl_sysdep_start): Likewise.
* sysdeps/alpha/dl-machine.h (RTLD_START): Use __GI__dl_argv
instead of _dl_argv_internal.
* sysdeps/powerpc/powerpc32/dl-start.S (_dl_start_user): Use
__GI__dl_argv instead of INTUSE(_dl_argv).
* sysdeps/powerpc/powerpc64/dl-machine.h (RTLD_START): Use
__GI__dl_argv instead of _dl_argv_internal.

10 years agosoft-fp: Add _FP_TO_INT_ROUND.
Joseph Myers [Tue, 4 Nov 2014 16:34:49 +0000 (16:34 +0000)]
soft-fp: Add _FP_TO_INT_ROUND.

Continuing the series of patches adding soft-fp features from the
kernel version of soft-fp to glibc so that glibc's version is able to
replace the old fork of soft-fp in the kernel, this patch adds the
last major such feature: _FP_TO_INT_ROUND, converting a floating-point
number to an integer with rounding according to the current rounding
direction (as opposed to truncating towards zero, which _FP_TO_INT
does).

The general structure of the implementation follows that of
_FP_TO_INT, but of course is more complicated.  As with glibc's
_FP_TO_INT it works with raw input (the kernel versions of these
macros predate the conversion of _FP_TO_INT and many other macros to
raw or semi-raw input).  I have not tried to work out what bugs there
might be in the kernel version that this might fix; it's a
from-scratch implementation based on _FP_TO_INT.

Tested for powerpc (soft-float) that there is no change to the
installed shared libraries; also tested with the libm tests with lrint
/ lrintf / llrint / llrintf made to use _FP_TO_INT_ROUND, to provide
some test of the functionality.  As we don't have benchmarks for those
functions, I haven't actually included the soft-fp versions of them,
although I expect them to be faster than the existing code (given that
the existing code involves adding and subtracting numbers such as
0x1p52 to achieve the desired rounding, which is not particularly
efficient when the underlying floating point is software floating
point).

2014-11-04  Joseph Myers  <joseph@codesourcery.com>

* soft-fp/op-common.h (_FP_TO_INT_ROUND): New macro.
* soft-fp/double.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_D): New
macro.
[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_D): Likewise.
* soft-fp/extended.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_E):
New macro.
[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_E): Likewise.
* soft-fp/quad.h [_FP_W_TYPE_SIZE < 64] (FP_TO_INT_ROUND_Q): New
macro.
[_FP_W_TYPE_SIZE >= 64] (FP_TO_INT_ROUND_Q): Likewise.
* soft-fp/single.h (FP_TO_INT_ROUND_S): New macro.

10 years agoRemove unused include
Andreas Schwab [Wed, 17 Sep 2014 10:34:24 +0000 (12:34 +0200)]
Remove unused include

10 years agopowerpc: Fix encoding of POWER8 instruction
Adhemerval Zanella [Mon, 3 Nov 2014 12:26:33 +0000 (07:26 -0500)]
powerpc: Fix encoding of POWER8 instruction

This patch adds a binary encoding for 'mtvsrd' instruction to avoid
build failures when assembler does not support POWER8.

10 years agoDon't error out writing a multibyte character to an unbuffered stream (bug 17522)
Andreas Schwab [Thu, 30 Oct 2014 11:18:48 +0000 (12:18 +0100)]
Don't error out writing a multibyte character to an unbuffered stream (bug 17522)

10 years agoFix sparc struct fpu definition.
Jose E. Marchesi [Sat, 1 Nov 2014 20:45:02 +0000 (13:45 -0700)]
Fix sparc struct fpu definition.

* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h (struct fpu): fix
the size of the fpu_fr.fpu_dregs[] array.

10 years agoRemove __libc_nanosleep function name.
Joseph Myers [Sat, 1 Nov 2014 12:26:09 +0000 (12:26 +0000)]
Remove __libc_nanosleep function name.

Continuing the removal of unused __libc_* function names, this patch
removes the __libc_nanosleep name.

Tested for x86_64 (testsuite, and that the disassembly of installed
shared libraries is unchanged by the patch; __nanosleep changes from
weak to strong, which is of no significance).

* posix/nanosleep.c (__libc_nanosleep): Rename to __nanosleep.
(__nanosleep): Do not define as alias.
(nanosleep): Define as alias of __nanosleep.
* sysdeps/unix/sysv/linux/syscalls.list (nanosleep): Remove
__libc_nanosleep name.

10 years agoMake aclocal.m4 comment mention updating install.texi for autoconf version.
Joseph Myers [Fri, 31 Oct 2014 22:44:17 +0000 (22:44 +0000)]
Make aclocal.m4 comment mention updating install.texi for autoconf version.

* aclocal.m4 (GLIBC_AUTOCONF_VERSION): Mention need to update
install.texi in comment.

10 years agopowerpc: Change atomic_write_barrier to have release semantics.
Torvald Riegel [Fri, 17 Oct 2014 23:01:58 +0000 (01:01 +0200)]
powerpc: Change atomic_write_barrier to have release semantics.

10 years agoAdd a hook to enable load-time inspection of program headers
Matthew Fortune [Wed, 1 Oct 2014 16:08:51 +0000 (17:08 +0100)]
Add a hook to enable load-time inspection of program headers

This hook can be used to perform additional compatibility checks
between shared libraries by inspecting custom program header
information.

* elf/dl-machine-reject-phdr.h: New file.
* elf/dl-load.c: #include that.
(open_verify): Call elf_machine_reject_phdr_p and ignore the file
if that returned true.

10 years agoBZ#17496: Fix gnu/lib-names.h dependency.
Roland McGrath [Fri, 31 Oct 2014 22:07:36 +0000 (15:07 -0700)]
BZ#17496: Fix gnu/lib-names.h dependency.

10 years agoUpdate autoconf version requirement in install.texi.
Joseph Myers [Fri, 31 Oct 2014 21:49:35 +0000 (21:49 +0000)]
Update autoconf version requirement in install.texi.

I noticed that install.texi was out of date with regard to the actual
autoconf version requirement for regenerating configure scripts.  This
patch updates the documentation.

* manual/install.texi (Tools for Compilation): Update autoconf
version requirements.
* INSTALL: Regenerated.

10 years agoRemove __libc_pselect alias.
Joseph Myers [Fri, 31 Oct 2014 21:22:35 +0000 (21:22 +0000)]
Remove __libc_pselect alias.

Continuing the removal of unused __libc_* function names, this patch
removes the __libc_pselect alias.

Tested for x86_64 that installed stripped shared libraries are
unchanged by this patch.

* misc/pselect.c [!__pselect] (__libc_pselect): Remove alias.
* sysdeps/unix/sysv/linux/pselect.c [__NR_pselect6]
(__libc_pselect): Likewise.

10 years agoAdd bug 15215 to NEWS; move bug 17344 to correct version's list in NEWS.
Joseph Myers [Fri, 31 Oct 2014 21:21:15 +0000 (21:21 +0000)]
Add bug 15215 to NEWS; move bug 17344 to correct version's list in NEWS.

10 years agoMove powerpc64 pread/pwrite definitions to syscalls.list (bug 14138).
Joseph Myers [Fri, 31 Oct 2014 21:13:32 +0000 (21:13 +0000)]
Move powerpc64 pread/pwrite definitions to syscalls.list (bug 14138).

Concluding the move of syscall definitions to syscalls.list, where the
removal of support for old kernel versions has made this possible,
this patch removes C definitions of pread, pread64, pwrite and
pwrite64 for powerpc64.  As far as I can tell, the existing
syscalls.list definitions in
sysdeps/unix/sysv/linux/wordsize-64/syscalls.list should suffice to
produce results equivalent to what these C files do.

[BZ #14138]
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread.c: Remove file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pread64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/pwrite64.c: Likewise.

10 years agoFix SPARC atomic_write_barrier.
Torvald Riegel [Wed, 29 Oct 2014 18:14:14 +0000 (19:14 +0100)]
Fix SPARC atomic_write_barrier.

10 years agoClean up internal ctype.h header.
Roland McGrath [Thu, 30 Oct 2014 20:19:34 +0000 (13:19 -0700)]
Clean up internal ctype.h header.

10 years agoRemove __libc_readv and __libc_writev function names.
Joseph Myers [Thu, 30 Oct 2014 20:56:34 +0000 (20:56 +0000)]
Remove __libc_readv and __libc_writev function names.

Continuing the removal of __libc_* function names that are no longer
used anywhere, this patch removes the __libc_readv and __libc_writev
names.

Tested for x86_64 that stripped installed shared libraries are
unchanged by the patch.

* include/sys/uio.h (__libc_readv): Remove declaration.
(__libc_writev): Likewise.
* misc/readv.c (__libc_readv): Rename to __readv.
(__readv): Do not define as alias.
(readv): Define as alias of __readv.
* misc/writev.c (__libc_writev): Rename to __writev.
(__writev): Do not define as alias.
(writev): Define as alias of __writev.
* sysdeps/posix/readv.c (__libc_readv): Rename to __readv.
(__readv): Do not define as alias.
(readv): Define unconditionally as alias of __readv.
* sysdeps/posix/writev.c (__libc_writev): Rename to __writev.
(__writev): Do not define as alias.
(writev): Define unconditionally as alias of __writev.
* sysdeps/unix/syscalls.list (readv): Do not define __libc_readv
name.
(writev): Do not define __libc_writev name.

10 years agoClean up wchar_t conversion code in iconv program.
Roland McGrath [Thu, 30 Oct 2014 19:56:51 +0000 (12:56 -0700)]
Clean up wchar_t conversion code in iconv program.

10 years agoRemove __libc_creat function name.
Joseph Myers [Thu, 30 Oct 2014 19:44:31 +0000 (19:44 +0000)]
Remove __libc_creat function name.

glibc has lots of __libc_* function names that no longer serve any
purpose (are not used for any calls or exported at a public symbol
version).  This patch removes __libc_creat.  It has the effect of
creat becoming a strong symbol instead of a weak symbol in various
cases, but that's fine; in shared libraries it doesn't matter at all,
while for static linking the only other symbol sometimes defined in
the same object is creat64, and whenever creat64 is a reserved name so
is creat.

Other such cases of unnecessary __libc_* symbols are expected to be
dealt with in separate patches over time.

Tested for x86_64 (testsuite, and that the disassembly of installed
shared libraries is unchanged by the patch).

* include/fcntl.h (__libc_creat): Remove declaration.
* io/creat.c (__libc_creat): Rename to creat.
(creat): Do not define as alias.
* sysdeps/unix/sysv/linux/alpha/creat.c (creat64): Define as alias
of creat instead of __libc_creat.
* sysdeps/unix/sysv/linux/generic/creat.c (__libc_creat): Rename
to creat.
(creat): Do not define as alias.
[__WORDSIZE == 64] (creat64): Define as alias of creat instead of
__libc_creat.
* sysdeps/unix/sysv/linux/syscalls.list (creat): Do not define
__libc_creat name.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (creat):
Likewise.

10 years agomanual/llio.texi: Add Linux-specific comments for write().
Carlos O'Donell [Thu, 30 Oct 2014 00:39:07 +0000 (20:39 -0400)]
manual/llio.texi: Add Linux-specific comments for write().

Add Linux-specific comments about the atomicity of write() and
the POSIX requirements.

2014-10-29  Carlos O'Donell  <carlos@redhat.com>

* manual/llio.texi: Add comments discussing why write() may be
considered MT-unsafe on Linux.

10 years agoelf/dl-load.c: Use __strdup.
Carlos O'Donell [Tue, 28 Oct 2014 23:37:07 +0000 (19:37 -0400)]
elf/dl-load.c: Use __strdup.

During a refactoring pass several repeated blocks of code in dl-load.c
were turned into a call to a local function named local_strdup.  There
is no need for local_strdup, and the routines should instead call
__strdup.  This change does just that.  We call the internal symbol
__strdup because calling strdup is unsafe.  The user might be
using a standard that doesn't include strdup and may have defined this
symbol in their application. During a static link we might reference
the user defined symbol and crash if it doesn't implement a standards
conforming strdup. The resulting code is simpler to understand, and
makes it easier to debug.

No regressions on x86_64.

2014-10-28  Carlos O'Donell  <carlos@redhat.com>

* dl-load.c (local_strdup): Remove.
(expand_dynamic_string_token): Use __strdup.
(decompose_rpath): Likewise.
(_dl_map_object): Likewise.

10 years agoDon't use INTDEF/INTUSE in unwind-dw2-fde.c (bug 14132).
Joseph Myers [Tue, 28 Oct 2014 17:12:57 +0000 (17:12 +0000)]
Don't use INTDEF/INTUSE in unwind-dw2-fde.c (bug 14132).

Continuing the removal of the obsolete INTDEF / INTUSE mechanism, this
patch replaces its use in unwind-dw2-fde.c with hidden_def and
hidden_proto.

Tested for x86.  This patch does result in code generation differences
(for some reason GCC decides to partition __register_frame_info_bases
after the patch).

[BZ #14132]
* sysdeps/generic/unwind-dw2-fde.c
(__register_frame_info_bases_internal): Do not declare.
(__register_frame_info_table_bases_internal): Likewise.
(__deregister_frame_info_bases_internal): Likewise.
(__register_frame_info_bases): Declare and use hidden_proto before
definition.  Use hidden_def instead of INTDEF.
(__register_frame_info_table_bases): Likewise.
(__deregister_frame_info_bases): Likewise.
(__register_frame_info): Do not use INTUSE.
(__register_frame): Likewise.
(__register_frame_info_table): Likewise.
(__register_frame_table): Likewise.
(__deregister_frame_info): Likewise.
(__deregister_frame): Likewise.

10 years agoarm: Re-enable PI futex support for ARM kernels >= 3.14.3
Gratian Crisan [Mon, 27 Oct 2014 22:45:43 +0000 (22:45 +0000)]
arm: Re-enable PI futex support for ARM kernels >= 3.14.3

ARM linux kernels before 3.14.3 may or may not support
futex_atomic_cmpxchg_inatomic depending on the kernel configuration (e.g.
CONFIG_CPU_USE_DOMAINS && CONFIG_SMP configuration was not supported)

Starting with 3.14.3 the linux kernel unconditionally enables support for
ARM, and this re-enables the relevant __ASSUME_* macros.

Tested on ARM both with kernels >= 3.14.3 and older kernels.

* sysdeps/unix/sysv/linux/arm/kernel-features.h
[__LINUX_KERNEL_VERSION >= 0x030E03] (__ASSUME_FUTEX_LOCK_PI): Do
not undefine.
[__LINUX_KERNEL_VERSION >= 0x030E03] (__ASSUME_REQUEUE_PI):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x030E03] (__ASSUME_SET_ROBUST_LIST):
Likewise.

10 years agoMove setfsgid/setfsuid definitions to syscalls.list (bug 14138).
Joseph Myers [Mon, 27 Oct 2014 12:24:42 +0000 (12:24 +0000)]
Move setfsgid/setfsuid definitions to syscalls.list (bug 14138).

Continuing the move of syscall definitions to syscalls.list, where the
removal of support for old kernel versions has made this possible,
this patch moves various definitions of setfsgid and setfsuid.

Tested for x86.

[BZ #14138]
* sysdeps/unix/sysv/linux/arm/setfsgid.c: Remove file.
* sysdeps/unix/sysv/linux/arm/setfsuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setfsgid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setfsuid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setfsgid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setfsuid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setfsgid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setfsuid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setfsgid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setfsuid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setfsgid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setfsuid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/syscalls.list (setfsgid): Add
syscall.
(setfsuid): Likewise.
* sysdeps/unix/sysv/linux/i386/syscalls.list (setfsgid): Likewise.
(setfsuid): Likewise.
* sysdeps/unix/sysv/linux/m68k/syscalls.list (setfsgid): Likewise.
(setfsuid): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list (setfsgid):
Likewise.
(setfsuid): Likewise.
* sysdeps/unix/sysv/linux/sh/syscalls.list (setfsgid): Likewise.
(setfsuid): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list (setfsgid):
Likewise.
(setfsuid): Likewise.

10 years agoFix misdetected Slow_SSE4_2 cpu feature bit (bug 17501)
Andreas Schwab [Tue, 21 Oct 2014 09:09:19 +0000 (11:09 +0200)]
Fix misdetected Slow_SSE4_2 cpu feature bit (bug 17501)

10 years agoRework compiler version check in configure.
Roland McGrath [Fri, 24 Oct 2014 21:45:47 +0000 (14:45 -0700)]
Rework compiler version check in configure.

10 years agoPrototypify htonl and htons definitions.
Roland McGrath [Fri, 24 Oct 2014 19:37:36 +0000 (12:37 -0700)]
Prototypify htonl and htons definitions.

10 years agoThis patch improves strncat performance by using strlen. Strlen has a fast C implemen...
Wilco Dijkstra [Fri, 24 Oct 2014 16:12:12 +0000 (16:12 +0000)]
This patch improves strncat performance by using strlen. Strlen has a fast C implementation, so
this
will improve performance even on targets which don't have an optimized strlen. It is about twice
as
fast as the original strncat in bench-strncat.

10 years agoThis patch improves strcat performance by using strlen and strcpy. Strlen has a fast C
Wilco Dijkstra [Fri, 24 Oct 2014 16:08:42 +0000 (16:08 +0000)]
This patch improves strcat performance by using strlen and strcpy. Strlen has a fast C
implementation, so this improves performance even on targets which don't have an optimized
strlen and strcpy - it is 25% faster in bench-strcat. On targets which don't provide an
optimized strcat but which do have an optimized strlen and strcpy, performance gain is > 2x.

10 years agoCall libc_fetestexcept_aarch64 from math_private.h rather than duplicating functionality.
Wilco Dijkstra [Fri, 24 Oct 2014 13:23:12 +0000 (13:23 +0000)]
Call libc_fetestexcept_aarch64 from math_private.h rather than duplicating functionality.

10 years agoCall libc_feholdexcept_aarch64 from math_private.h rather than duplicating functionality.
Wilco Dijkstra [Fri, 24 Oct 2014 13:21:27 +0000 (13:21 +0000)]
Call libc_feholdexcept_aarch64 from math_private.h rather than duplicating functionality.