]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 years agoRFC: powerpc64le: Enable support for IEEE long double gabriel/powerpc-ieee128-printscan
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:28 +0000 (11:48 -0300)] 
RFC: powerpc64le: Enable support for IEEE long double

Not for glibc-2.31 - Do not commit!

No changes since v3.

Changes since v2:

  - Added definition of LDBL_IBM128_COMPAT_VERSION and
    LDBL_IBM128_VERSION (moved from a previous commit).

Changes since v1:

  - Use __LONG_DOUBLE_USES_FLOAT128 directly.

-- 8< --
On platforms where long double may have two different formats, i.e.: the
same format as double (64-bits) or something else (128-bits), building
with -mlong-double-128 is the default and function calls in the user
program match the name of the function in Glibc.  When building with
-mlong-double-64, Glibc installed headers redirect such calls to the
appropriate function.

This patch adds similar redirections to be used by user code builds in
IEEE long double mode (-mabi=ieeelongdouble).  It also skips some uses
of libc_hidden_proto in internal headers, because they also produce
redirections, causing a redirection conflict.

PS: Missing NEWS entry.

4 years agopowerpc64le: Require a compiler with -mno-gnu-attribute
Gabriel F. T. Gomes [Fri, 11 Oct 2019 18:20:05 +0000 (15:20 -0300)] 
powerpc64le: Require a compiler with -mno-gnu-attribute

Not for glibc-2.31 - Do not commit!

No changes since v3.

No changes since v2.

Changes since v1:

  - Added mentions to the build requirement in manual/install.texi,
    INSTALL (regenerated) and NEWS.

-- 8< --
On powerpc64le, a few files are built on IEEE long double mode
(-mabi=ieeelongdouble), whereas most are built on IBM long double mode
(-mabi=ibmlongdouble, the default for -mlong-double-128). Since binutils
2.31, linking object files with different long double modes causes
errors similar to:

  ld: libc_pic.a(s_isinfl.os) uses IBM long double,
      libc_pic.a(ieee128-qefgcvt.os) uses IEEE long double.
  collect2: error: ld returned 1 exit status
  make[2]: *** [../Makerules:649: libc_pic.os] Error 1

The warnings are fair and correct, but in order for glibc to have
support for both long double modes on powerpc64le, they have to be
ignored.  This can be accomplished with the use of -mno-gnu-attribute
option when building the few files that require IEEE long double mode.

However, -mno-gnu-attribute is not available in GCC 6, the minimum
version required to build glibc, so this patch adds a test for this
feature in powerpc64le builds, and fails early if it's not available.

Tested, on powerpc64le, that the build fails early with GCC 6 and that
it succeeds with GCC 7 or greater.

Reviewed-by: Joseph Myers <joseph@codesourcery.com>
4 years agoldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128
Gabriel F. T. Gomes [Tue, 10 Sep 2019 13:05:03 +0000 (08:05 -0500)] 
ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128

No changes since v3.

No changes since v2.

Changes since v1:

  - Do not try to remove -mabi=ieeelongdouble, since it hasn't been
    added.  The removal is a residue from our initial development.

-- 8< --
Some compiler versions, e.g. GCC 7, complain when -mlong-double-128 is
used together with -mabi=ibmlongdouble or -mabi=ieeelongdouble,
producing the following error message:

  cc1: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’

This patch removes -mlong-double-128 from the compilation lines that
explicitly request -mabi=*longdouble.

Tested for powerpc64le.

4 years agoAvoid compat symbols for totalorder in powerpc64le IEEE long double
Gabriel F. T. Gomes [Mon, 9 Sep 2019 17:59:46 +0000 (12:59 -0500)] 
Avoid compat symbols for totalorder in powerpc64le IEEE long double

No changes since v3.

No changes since v2.

Changes since v1:

  - Added comment on the redefinition of libm_alias_float128_other_r_ldbl.

-- 8< --
On powerpc64le, the libm_alias_float128_other_r_ldbl macro is
used to create an alias between totalorderf128 and __totalorderlieee128,
as well as between the totalordermagf128 and __totalordermaglieee128.

However, the totalorder* and totalordermag* functions changed their
parameter type since commit ID 42760d764649 and got compat symbols for
their old versions.  With this change, the aforementioned macro would
create two conflicting aliases for __totalorderlieee128 and
__totalordermaglieee128.

This patch avoids the creation of the alias between the IEEE long double
symbols (__totalorderl*ieee128) and the compat symbols, because the IEEE
long double functions have never been exported thus don't need such
compat symbol.

Tested for powerpc64le.

Reviewed-by: Joseph Myers <joseph@codesourcery.com>
4 years agoldbl-128ibm-compat: Compiler flags for stdio functions
Tulio Magno Quites Machado Filho [Mon, 30 Jul 2018 15:04:40 +0000 (12:04 -0300)] 
ldbl-128ibm-compat: Compiler flags for stdio functions

No changes since v3.

No changes since v2.

No changes since v1.

-- 8< --
Some of the files that provide stdio.h and wchar.h functions have a
filename prefixed with 'io', such as 'iovsprintf.c'.  On platforms that
imply ldbl-128ibm-compat, these files must be compiled with the flag
-mabi=ibmlongdouble.  This patch adds this flag to their compilation.

Notice that this is not required for the other files that provide
similar functions, because filenames that are not prefixed with 'io'
have ldbl-128ibm-compat counterparts in the Makefile, which already adds
-mabi=ibmlongdouble to them.

4 years agoDo not redirect calls to __GI_* symbols, when redirecting to *ieee128
Tulio Magno Quites Machado Filho [Sun, 20 Oct 2019 21:00:30 +0000 (16:00 -0500)] 
Do not redirect calls to __GI_* symbols, when redirecting to *ieee128

No changes since v3.

No changes since v2.

Changes since v1:

  - Reduced the number of changes to the minimum required to build *cvt
    files in -mabi=ieeelongdouble mode.
  - Added __LONG_DOUBLE_USES_FLOAT128 to all long-double.h files.

-- 8< --
On platforms where long double has IEEE binary128 format as a third
option (initially, only powerpc64le), many exported functions are
redirected to their __*ieee128 equivalents.  This redirection is
provided by installed headers such as stdio-ldbl.h, and is supposed to
work correctly with user code.

However, during the build of glibc, similar redirections are employed,
in internal headers, such as include/stdio.h, in order to avoid extra
PLT entries.  These redirections conflict with the redirections to
__*ieee128, and must be avoided during the build.  This patch protects
the second redirections with a test for __LONG_DOUBLE_USES_FLOAT128, a
new macro that is defined to 1 when functions that deal with long double
typed values reuses the _Float128 implementation (this is currently only
true for powerpc64le).

Tested for powerpc64le, x86_64, and with build-many-glibcs.py.

Co-authored-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
4 years agoldbl-128ibm-compat: Add *cvt functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:24 +0000 (11:48 -0300)] 
ldbl-128ibm-compat: Add *cvt functions

No changes since v3.

  - Reviewed-by Paul Murphy.  Waiting for the preceding patches.

Changes since v2:

  - Fix http URLs.

No changes since v1.

-- 8< --
This patch adds IEEE long double versions of q*cvt* functions for
powerpc64le.  Unlike all other long double to/from string conversion
functions, these do not rely on internal functions that can take
floating-point numbers with different formats and act on them
accordingly, instead, the related files are rebuilt with the
-mabi=ieeelongdouble compiler flag set.

Having -mabi=ieeelongdouble passed to the compiler causes the object
files to be marked with a .gnu_attribute that is incompatible with the
.gnu_attribute in files built with -mabi=ibmlongdouble (the default).
The difference causes error messages similar to the following:

  ld: libc_pic.a(s_isinfl.os) uses IBM long double,
      libc_pic.a(ieee128-qefgcvt_r.os) uses IEEE long double.
  collect2: error: ld returned 1 exit status
  make[2]: *** [../Makerules:649: libc_pic.os] Error 1

Although this warning is useful in other situations, the library
actually needs to have functions with different long double formats, so
.gnu_attribute generation is explicitly disabled for these files with
the use of -mno-gnu-attribute.

Tested for powerpc64le on the branch that actually enables the
sysdeps/ieee754/ldbl-128ibm-compat for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoRefactor *cvt functions implementation (2/2)
Gabriel F. T. Gomes [Tue, 26 Nov 2019 17:48:49 +0000 (14:48 -0300)] 
Refactor *cvt functions implementation (2/2)

Changes since v3:

  - Converted into a standalone patch not to be squashed with the
    preceding patch (1/2).
  - Updated commit message.
  - Tested that installed stripped binaries for powerpc64le and x86_64
    remain identical before and after this patch.

Changes since v2:

  - Moved the removal of unused macros to a previous patch

Changes since v1:

  - Adapted after patch v1 19/31 (remove hidden_* uses) was dropped.
  - Fixed unintended removal of cvt* symbols on alpha and s390x
    (now tested with build-many-glibcs.py).

-- 8< --
This patch refactors the *cvt functions implementation in a way that
makes it easier to re-use them for implementing the IEEE long double on
powerpc64le.  By removing the macros that generate the function names
(APPEND combined with FUNC_PREFIX), the new code makes it easier to
define new function names, such as __qecvtieee128.

Tested that installed stripped binaries for powerpc64le and x86_64
remain identical before and after this patch.  Also tested for
powerpc64le, x86_64, as well as with the following build-many-glibcs
targets: alpha-linux-gnu, mips-linux-gnu, powerpc-linux-gnu-soft,
s390x-linux-gnu, and sparc64-linux-gnu.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoRefactor *cvt functions implementation (1/2)
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:08 +0000 (11:48 -0300)] 
Refactor *cvt functions implementation (1/2)

Changes since v3:

  - Converted into a standalone patch not to be squashed with the
    subsequent patch (2/2).
  - Updated commit message.
  - Tested that installed stripped binaries for powerpc64le and x86_64
    remain identical before and after this patch.

Changes since v2:

  - Squashed patches 1-4 and trivial bits of patch 5.
  - Replaced http with https (like the rest of glibc).
  - Updated copyright years.
  - Removed refactoring noise reported by Paul Murphy.

No changes since v1.

-- 8< --
This patch refactors the *cvt functions implementation in a way that
makes it easier to re-use them for implementing the IEEE long double on
powerpc64le.  By splitting the implementation per se in one file
(efgcvt-template.c) and the alias definitions in others (e.g. efgcvt.c),
the new code makes it easier to define new function names, such as
__qecvtieee128.

Tested that installed stripped binaries for powerpc64le and x86_64
remain identical before and after this patch.  Also tested for
powerpc64le, x86_64, as well as with the following build-many-glibcs
targets: alpha-linux-gnu, mips-linux-gnu, powerpc-linux-gnu-soft,
s390x-linux-gnu, and sparc64-linux-gnu.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Add ISO C99 versions of scanf functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:43 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add ISO C99 versions of scanf functions

In the format string for *scanf functions, the '%as', '%aS', and '%a[]'
modifiers behave differently depending on ISO C99 compatibility.  When
_GNU_SOURCE is defined and -std=c89 is passed to the compiler, these
functions behave like ascanf, and the modifiers allocate memory for the
output.  Otherwise, the ISO C99 compliant version of these functions is
used, and the modifiers consume a floating-point argument.  This patch
adds the IEEE binary128 variant of ISO C99 compliant functions for the
third long double format on powerpc64le.

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
Gabriel F. T. Gomes [Wed, 27 Nov 2019 16:06:50 +0000 (10:06 -0600)] 
ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf

Since commit

commit 03992356e6fedc5a5e9d32df96c1a2c79ea28a8f
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Feb 10 11:58:35 2018 -0500

    Use C99-compliant scanf under _GNU_SOURCE with modern compilers.

the selection of the GNU versions of scanf functions requires both
_GNU_SOURCE and -std=c89.  This patch changes the tests in
ldbl-128ibm-compat so that they actually test the GNU versions (without
this change, the redirection to the ISO C99 version always happens, so
GNU versions of the new implementation (e.g. __scanfieee128) were left
untested).

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agohurd: Fix local PLT
Samuel Thibault [Fri, 13 Dec 2019 09:10:59 +0000 (10:10 +0100)] 
hurd: Fix local PLT

* include/sys/random.h (__getrandom): Add hidden prototype.
* stdlib/getrandom.c (getrandom): Rename to hidden definition __getrandom.
Add weak alias.
* sysdeps/mach/hurd/getrandom.c (getrandom): Likewise.
* sysdeps/unix/sysv/linux/getrandom.c (getrandom): Likewise.
* sysdeps/mach/hurd/getentropy.c (getentropy): Use __getrandom instead of
getrandom.

4 years agodlopen: Do not block signals
Florian Weimer [Fri, 13 Dec 2019 09:23:10 +0000 (10:23 +0100)] 
dlopen: Do not block signals

Blocking signals causes issues with certain anti-malware solutions
which rely on an unblocked SIGSYS signal for system calls they
intercept.

This reverts commit a2e8aa0d9ea648068d8be52dd7b15f1b6a008e23
("Block signals during the initial part of dlopen") and adds
comments related to async signal safety to active_nodelete and
its caller.

Note that this does not make lazy binding async-signal-safe with regards
to dlopen.  It merely avoids introducing new async-signal-safety hazards
as part of the NODELETE changes.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agodlopen: Rework handling of pending NODELETE status
Florian Weimer [Fri, 13 Dec 2019 09:18:46 +0000 (10:18 +0100)] 
dlopen: Rework handling of pending NODELETE status

Commit a2e8aa0d9ea648068d8be52dd7b15f1b6a008e23 ("Block signals during
the initial part of dlopen") was deemed necessary because of
read-modify-write operations like the one in  add_dependency in
elf/dl-lookup.c.  In the old code, we check for any kind of NODELETE
status and bail out:

      /* Redo the NODELETE check, as when dl_load_lock wasn't held
 yet this could have changed.  */
      if (map->l_nodelete != link_map_nodelete_inactive)
goto out;

And then set pending status (during relocation):

  if (flags & DL_LOOKUP_FOR_RELOCATE)
    map->l_nodelete = link_map_nodelete_pending;
  else
    map->l_nodelete = link_map_nodelete_active;

If a signal arrives during relocation and the signal handler, through
lazy binding, adds a global scope dependency on the same map, it will
set map->l_nodelete to link_map_nodelete_active.  This will be
overwritten with link_map_nodelete_pending by the dlopen relocation
code.

To avoid such problems in relation to the l_nodelete member, this
commit introduces two flags for active NODELETE status (irrevocable)
and pending NODELETE status (revocable until activate_nodelete is
invoked).  As a result, NODELETE processing in dlopen does not
introduce further reasons why lazy binding from signal handlers
is unsafe during dlopen, and a subsequent commit can remove signal
blocking from dlopen.

This does not address pre-existing issues (unrelated to the NODELETE
changes) which make lazy binding in a signal handler during dlopen
unsafe, such as the use of malloc in both cases.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agodlopen: Fix issues related to NODELETE handling and relocations
Florian Weimer [Fri, 13 Dec 2019 09:18:24 +0000 (10:18 +0100)] 
dlopen: Fix issues related to NODELETE handling and relocations

The assumption behind the assert in activate_nodelete was wrong:

Inconsistency detected by ld.so: dl-open.c: 459: activate_nodelete:
Assertion `!imap->l_init_called || imap->l_type != lt_loaded' failed! (edit)

It can happen that an already-loaded object that is in the local
scope is promoted to NODELETE status, via binding to a unique
symbol.

Similarly, it is possible that such NODELETE promotion occurs to
an already-loaded object from the global scope.  This is why the
loop in activate_nodelete has to cover all objects in the namespace
of the new object.

In do_lookup_unique, it could happen that the NODELETE status of
an already-loaded object was overwritten with a pending NODELETE
status.  As a result, if dlopen fails, this could cause a loss of
the NODELETE status of the affected object, eventually resulting
in an incorrect unload.

Fixes commit f63b73814f74032c0e5d0a83300e3d864ef905e5 ("Remove all
loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]").

4 years agohurd: Fix __close_nocancel_nostatus availability
Samuel Thibault [Fri, 13 Dec 2019 02:32:21 +0000 (03:32 +0100)] 
hurd: Fix __close_nocancel_nostatus availability

Not only libc/rtld use __close_nocancel_nostatus.

* sysdeps/mach/hurd/Makefile [$(subdir) == io] (sysdep_routines): Add
close_nocancel_nostatus.
* sysdeps/mach/hurd/Versions (libc): Add __close_nocancel_nostatus to
GLIBC_PRIVATE.
* sysdeps/mach/hurd/not-cancel.h (__close_nocancel_nostatus): Declare
function instead of defining inline.
[IS_IN (libc) || IS_IN (rtld)] (__close_nocancel_nostatus): Make
function hidden.
* sysdeps/mach/hurd/close_nocancel_nostatus.c: New file.

4 years agohurd: add getrandom and getentropy implementations
Andrew Eggenberger [Wed, 30 Oct 2019 04:19:32 +0000 (23:19 -0500)] 
hurd: add getrandom and getentropy implementations

* sysdeps/mach/hurd/getentropy.c: New file.
* sysdeps/mach/hurd/getrandom.c: Likewise.

4 years agohurd: Implement __close_nocancel_nostatus
Samuel Thibault [Fri, 13 Dec 2019 02:23:14 +0000 (03:23 +0100)] 
hurd: Implement __close_nocancel_nostatus

* sysdeps/mach/hurd/not-cancel.h: New file.

4 years agomanual: clarify fopen with the x flag
Paul Eggert [Wed, 11 Dec 2019 17:34:06 +0000 (09:34 -0800)] 
manual: clarify fopen with the x flag

* manual/stdio.texi (Opening Streams): Say how glibc's
implementation of fopen with "x" follows ISO C11.

4 years agoS390: Use sysdeps/ieee754/dbl-64/wordsize-64 on s390x.
Stefan Liebler [Wed, 11 Dec 2019 14:09:34 +0000 (15:09 +0100)] 
S390: Use sysdeps/ieee754/dbl-64/wordsize-64 on s390x.

This patch enables the usage of implementations in
sysdeps/ieee754/dbl-64/wordsize-64 on 64bit s390x.

4 years agoS390: Implement roundtoint and converttoint and define TOINT_INTRINSICS.
Stefan Liebler [Wed, 11 Dec 2019 14:09:33 +0000 (15:09 +0100)] 
S390: Implement roundtoint and converttoint and define TOINT_INTRINSICS.

This patch implements roundtoint and convertoint for s390
by using the load-fp-integer and convert-to-fixed instructions.
Both functions are using "round to nearest with ties away from zero"
rounding mode and do not raise inexact exceptions.

4 years agoS390: Implement math-barriers math_opt_barrier and math_force_eval.
Stefan Liebler [Wed, 11 Dec 2019 14:09:32 +0000 (15:09 +0100)] 
S390: Implement math-barriers math_opt_barrier and math_force_eval.

This patch implements the s390 specific math barriers in order
to omit the store and load from stack if possible.

4 years agoS390: Use libc_fe* macros in fe* functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:32 +0000 (15:09 +0100)] 
S390: Use libc_fe* macros in fe* functions.

This patch updates the s390 specific functions fegetround,
fesetround, feholdexcept, fesetenv, feupdateenv, fegetexceptflag,
fetestexcept, fesetexceptflag, fetestexceptflag.
Now those functions are using the libc_fe* macros if possible.

Furthermore fegetexceptflag is now returning the exception from
dxc field shifted to the usual exception-flags.
Thus a special fetestexceptflag implementation is not needed anymore.

4 years agoS390: Implement libc_fe* macros.
Stefan Liebler [Wed, 11 Dec 2019 14:09:31 +0000 (15:09 +0100)] 
S390: Implement libc_fe* macros.

This patch provides the s390 specific implementation for
libc_feholdexcept, libc_fesetround, libc_feholdexcept_setround,
libc_fetestexcept, libc_fesetenv, libc_feupdateenv_test,
libc_feupdateenv, libc_feholdsetround_ctx, libc_feresetround_ctx,
libc_feholdsetround_noex_ctx and libc_feresetround_noex_ctx.

4 years agoS390: Use convert-to-fixed instruction for llround functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:31 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for llround functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement llround, llroundf, llroundl.
Otherwise the common-code implementation is used.

4 years agoS390: Use convert-to-fixed instruction for lround functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:30 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for lround functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement lround, lroundf, lroundl.
Otherwise the common-code implementation is used.

4 years agoS390: Use convert-to-fixed instruction for llrint functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:29 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for llrint functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement llrint, llrintf, llrintl.
Otherwise the common-code implementation is used.

4 years agoS390: Use convert-to-fixed instruction for lrint functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:29 +0000 (15:09 +0100)] 
S390: Use convert-to-fixed instruction for lrint functions.

If compiled with z196 zarch support, the convert-to-fixed instruction
is used to implement lrint, lrintf, lrintl.
Otherwise the common-code implementation is used.

4 years agoS390: Use load-fp-integer instruction for roundeven functions.
Stefan Liebler [Wed, 11 Dec 2019 14:09:28 +0000 (15:09 +0100)] 
S390: Use load-fp-integer instruction for roundeven functions.

If compiled with z196 zarch support, the load-fp-integer instruction
is used to implement roundeven, roundevenf, roundevenl.
Otherwise the common-code implementation is used.

4 years agoAdjust s_copysignl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:28 +0000 (15:09 +0100)] 
Adjust s_copysignl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_ceilf.c and s_ceill.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:27 +0000 (15:09 +0100)] 
Adjust s_ceilf.c and s_ceill.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_floorf.c and s_floorl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:26 +0000 (15:09 +0100)] 
Adjust s_floorf.c and s_floorl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_rintf.c and s_rintl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:26 +0000 (15:09 +0100)] 
Adjust s_rintf.c and s_rintl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAdjust s_nearbyintf.c and s_nearbyintl.c regarding code style.
Stefan Liebler [Wed, 11 Dec 2019 14:09:25 +0000 (15:09 +0100)] 
Adjust s_nearbyintf.c and s_nearbyintl.c regarding code style.

This patch just adjusts the generic implementation regarding code style.
No functional change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for copysign functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:24 +0000 (15:09 +0100)] 
Use GCC builtins for copysign functions if desired.

This patch is always using the corresponding GCC builtin for copysignf, copysign,
and is using the builtin for copysignl, copysignf128 if the USE_FUNCTION_BUILTIN
macros are defined to one in math-use-builtins.h.

Altough the long double version is enabled by default we still need
the macro and the alternative implementation as the _Float128 version
of the builtin is not available with all supported GCC versions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for round functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:24 +0000 (15:09 +0100)] 
Use GCC builtins for round functions if desired.

This patch is using the corresponding GCC builtin for roundf, round,
roundl and roundf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for trunc functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:22 +0000 (15:09 +0100)] 
Use GCC builtins for trunc functions if desired.

This patch is using the corresponding GCC builtin for truncf, trunc,
truncl and truncf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for ceil functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:21 +0000 (15:09 +0100)] 
Use GCC builtins for ceil functions if desired.

This patch is using the corresponding GCC builtin for ceilf, ceil,
ceill and ceilf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for floor functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:20 +0000 (15:09 +0100)] 
Use GCC builtins for floor functions if desired.

This patch is using the corresponding GCC builtin for floorf, floor,
floorl and floorf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for rint functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:20 +0000 (15:09 +0100)] 
Use GCC builtins for rint functions if desired.

This patch is using the corresponding GCC builtin for rintf, rint,
rintl and rintf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoUse GCC builtins for nearbyint functions if desired.
Stefan Liebler [Wed, 11 Dec 2019 14:09:18 +0000 (15:09 +0100)] 
Use GCC builtins for nearbyint functions if desired.

This patch is using the corresponding GCC builtin for nearbyintf, nearbyint,
nearbintl and nearbyintf128 if the USE_FUNCTION_BUILTIN macros are defined to one
in math-use-builtins.h.

This is the case for s390 if build with at least --march=z196 --mzarch.
Otherwise the generic implementation is used.  The code of the generic
implementation is not changed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_round.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:17 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_round.c.

This patch replaces s_round.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_trunc.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:17 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_trunc.c.

This patch replaces s_trunc.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 and sparc64 files.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_ceil.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:16 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_ceil.c.

This patch replaces s_ceil.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 and sparc64 files.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_floor.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:15 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_floor.c.

This patch replaces s_floor.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 and sparc64 files.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_rint.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:14 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_rint.c.

This patch replaces s_rint.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoAlways use wordsize-64 version of s_nearbyint.c.
Stefan Liebler [Wed, 11 Dec 2019 14:09:14 +0000 (15:09 +0100)] 
Always use wordsize-64 version of s_nearbyint.c.

This patch replaces s_nearbyint.c in sysdeps/dbl-64 with the one in
sysdeps/dbl-64/wordsize-64 and removes the latter one.
The code is not changed except changes in code style.

Also adjusted the include path in x86_64 file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoldconfig: Do not print a warning for a missing ld.so.conf file
Florian Weimer [Wed, 11 Dec 2019 08:19:39 +0000 (09:19 +0100)] 
ldconfig: Do not print a warning for a missing ld.so.conf file

The configuration file is not needed for working system, so printing a
warning is not helpful.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agohurd: Fix using altstack while in an RPC call to be aborted
Samuel Thibault [Tue, 10 Dec 2019 23:23:00 +0000 (00:23 +0100)] 
hurd: Fix using altstack while in an RPC call to be aborted

* sysdeps/mach/hurd/i386/trampoline.c (_hurd_setup_sighandler): Always check
for interrupted code being with esp pointing at mach_msg arguments, even
when using an altstack. If we need to abort the RPC we will need
this.

4 years agoFix failure when CFLAGS contains -DNDEBUG (Bug 25251)
Carlos O'Donell [Tue, 3 Dec 2019 20:42:24 +0000 (15:42 -0500)] 
Fix failure when CFLAGS contains -DNDEBUG (Bug 25251)

Building tests with -DNDEBUG in CFLAGS, gcc 9.2.1 issues the following error:
tst-assert-c++.cc: In function ‘int do_test()’:
tst-assert-c++.cc:66:12: error: unused variable ‘value’ [-Werror=unused-variable]
   66 |     no_int value;
      |            ^~~~~
tst-assert-c++.cc:71:18: error: unused variable ‘value’ [-Werror=unused-variable]
   71 |     bool_and_int value;
      |                  ^~~~~

The assert has been disabled by building glibc with CFLAGS, CXXFLAGS,
and CPPFLAGS with -DNDEBUG which removes the assert and leaves the
value unused.

We never want the assert disabled because that's the point of the
test, so we undefine NDEBUG before including assert.h to ensure that
we get assert correctly defined.

4 years agonptl: Add more missing placeholder abi symbol from nanosleep move
Adhemerval Zanella [Tue, 3 Dec 2019 20:32:49 +0000 (20:32 +0000)] 
nptl: Add more missing placeholder abi symbol from nanosleep move

This patch adds the missing __libpthread_version_placeholder for
GLIBC_2.2.6 version from the nanosleep implementation move from
libpthread to libc (79a547b162).

It also fixes the wrong compat symbol definitions added by changing
back the version used on vfork check and remove the
__libpthread_version_placeholder added on some ABI (4f4bb489e0dd).

The __libpthread_version_placeholder is also refactored to make it
simpler to add new compat_symbols by adding a new macro
compat_symbol_unique which uses the compiler extension __COUNTER__
to generate unique strong alias to be used with compat_symbol.

Checked with a updated-abi on the all affected abis of the nanosleep
move.

Change-Id: I347a4dbdc931bb42b359456932dd1e17aa4d4078

4 years agosysdeps/riscv/start.S: rename .Lload_gp to load_gp (bug 24376)
Andreas Schwab [Mon, 12 Aug 2019 09:29:29 +0000 (11:29 +0200)] 
sysdeps/riscv/start.S: rename .Lload_gp to load_gp (bug 24376)

Renaming the symbol keeps the label in the symbol table as a normal local
label, so that `objdump -d' can pick it up as an anchor.

4 years agoy2038: linux: Provide __timer_settime64 implementation
Lukasz Majewski [Fri, 8 Nov 2019 12:15:27 +0000 (13:15 +0100)] 
y2038: linux: Provide __timer_settime64 implementation

This patch provides new __timer_settime64 explicit 64 bit function for setting
flags, interval and value of specified timer.
Moreover, a 32 bit version - __timer_settime has been refactored to internally
use __timer_settime64.

The __timer_settime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversion to 64 bit struct
__timespec64 from struct timespec (and opposite when old_value pointer is
provided).

The new __timer_settime64 syscall available from Linux 5.1+ has been used, when
applicable.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make check PARALLELMFLAGS="-j8" && \\
make xcheck PARALLELMFLAGS="-j8"

- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

- Use of cross-test-ssh.sh for ARM (armv7):
  make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck

Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with timer_settime64) and glibc build with v5.1 as
  minimal kernel version (--enable-kernel="5.1.0")
  The __ASSUME_TIME64_SYSCALLS flag defined.

- Linux v5.1 and default minimal kernel version
  The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports timer_settime64
  syscall.

- Linux v4.19 (no timer_settime64 support) with default minimal kernel version
  for contemporary glibc (3.2.0)
  This kernel doesn't support timer_settime64 syscall, so the fallback to
  timer_settime is tested.

Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).

No regressions were observed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __timer_gettime64 implementation
Lukasz Majewski [Tue, 5 Nov 2019 16:04:24 +0000 (17:04 +0100)] 
y2038: linux: Provide __timer_gettime64 implementation

This patch provides new __timer_gettime64 explicit 64 bit function for reading
status of specified timer. To be more precise - the remaining time and interval
set with timer_settime.
Moreover, a 32 bit version - __timer_gettime has been refactored to internally
use __timer_gettime64.

The __timer_gettime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversion from 64 bit struct
__timespec64 to struct timespec.

The new __timer_gettime64 syscall available from Linux 5.1+ has been used, when
applicable.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Build tests:
- The code has been tested on x86_64/x86 (native compilation):
make PARALLELMFLAGS="-j8" && make check PARALLELMFLAGS="-j8" && \\
make xcheck PARALLELMFLAGS="-j8"

- The glibc has been build tested (make PARALLELMFLAGS="-j8") for
x86 (i386), x86_64-x32, and armv7

Run-time tests:
- Run specific tests on ARM/x86 32bit systems (qemu):
  https://github.com/lmajewski/meta-y2038 and run tests:
  https://github.com/lmajewski/y2038-tests/commits/master

- Use of cross-test-ssh.sh for ARM (armv7):
  make PARALLELMFLAGS="-j8" test-wrapper='./cross-test-ssh.sh root@192.168.7.2' xcheck

Linux kernel, headers and minimal kernel version for glibc build test
matrix:
- Linux v5.1 (with timer_gettime64) and glibc build with v5.1 as
  minimal kernel version (--enable-kernel="5.1.0")
  The __ASSUME_TIME64_SYSCALLS flag defined.

- Linux v5.1 and default minimal kernel version
  The __ASSUME_TIME64_SYSCALLS not defined, but kernel supports timer_gettime64
  syscall.

- Linux v4.19 (no timer_gettime64 support) with default minimal kernel version
  for contemporary glibc (3.2.0)
  This kernel doesn't support timer_gettime64 syscall, so the fallback to
  timer_gettime is tested.

Above tests were performed with Y2038 redirection applied as well as without
(so the __TIMESIZE != 64 execution path is checked as well).

No regressions were observed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agotimer: Decouple x86_64 specific timer_settime from generic Linux implementation
Lukasz Majewski [Fri, 8 Nov 2019 10:13:56 +0000 (11:13 +0100)] 
timer: Decouple x86_64 specific timer_settime from generic Linux implementation

The x86_64 specific timer_settime implementation (from
./linux/x86_64/timer_settime.c) reused the Linux generic one (from
./linux/timer_settime.c) to implement handling some compatible timers
(previously defined in librt, now in libc).

As the generic implementation now is going to also support new (available
from Linux 5.1+) timer_settime64 syscall, those two implementations have
been decoupled for easier conversion.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agotimer: Decouple x86_64 specific timer_gettime from generic Linux implementation
Lukasz Majewski [Tue, 5 Nov 2019 11:18:24 +0000 (12:18 +0100)] 
timer: Decouple x86_64 specific timer_gettime from generic Linux implementation

The x86_64 specific timer_gettime implementation (from
./linux/x86_64/timer_gettime.c) reused the Linux generic one (from
./linux/timer_gettime.c) to implement handling some compatible timers
(previously defined in librt, now in libc).

As the generic implementation now is going to also support new (available
from Linux 5.1+) timer_gettime64 syscall, those two implementations have
been decoupled for easier conversion.

The original INLINE_SYSCALL() macro has been replaced with
INLINE_SYSCALL_CALL() to avoid explicit passing the number of arguments.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agotime: Introduce glibc's internal struct __itimerspec64
Lukasz Majewski [Tue, 5 Nov 2019 11:44:26 +0000 (12:44 +0100)] 
time: Introduce glibc's internal struct __itimerspec64

This change provides the glibc's internal struct itimerspec representation,
which is explicitly supporting 64 bit time (by using struct __timespec64).

Such representation is necessary to provide correct time after Y2038
(time_t overflow) on devices with __TIMESIZE == 32.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoCorrect range checking in mallopt/mxfast/tcache [BZ #25194]
DJ Delorie [Tue, 3 Dec 2019 22:44:36 +0000 (17:44 -0500)] 
Correct range checking in mallopt/mxfast/tcache [BZ #25194]

do_set_tcache_max, do_set_mxfast:
Fix two instances of comparing "size_t < 0"
Both cases have upper limit, so the "negative value" case
is already handled via overflow semantics.

do_set_tcache_max, do_set_tcache_count:
Fix return value on error.  Note: currently not used.

mallopt:
pass return value of helper functions to user.  Behavior should
only be actually changed for mxfast, where we restore the old
(pre-tunables) behavior.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agomisc/test-errno-linux: Handle EINVAL from quotactl
Florian Weimer [Thu, 5 Dec 2019 16:29:42 +0000 (17:29 +0100)] 
misc/test-errno-linux: Handle EINVAL from quotactl

In commit 3dd4d40b420846dd35869ccc8f8627feef2cff32 ("xfs: Sanity check
flags of Q_XQUOTARM call"), Linux 5.4 added checking for the flags
argument, causing the test to fail due to too restrictive test
expectations.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years ago<string.h>: Define __CORRECT_ISO_CPP_STRING_H_PROTO for Clang [BZ #25232]
Kamlesh Kumar [Thu, 5 Dec 2019 15:49:00 +0000 (16:49 +0100)] 
<string.h>: Define __CORRECT_ISO_CPP_STRING_H_PROTO for Clang [BZ #25232]

Without the asm redirects, strchr et al. are not const-correct.

libc++ has a wrapper header that works with and without
__CORRECT_ISO_CPP_STRING_H_PROTO (using a Clang extension).  But when
Clang is used with libstdc++ or just C headers, the overloaded functions
with the correct types are not declared.

This change does not impact current GCC (with libstdc++ or libc++).

4 years agobuild-many-glibcs.py: Move sparcv8 to extra_glibcs
Adhemerval Zanella [Tue, 3 Dec 2019 12:18:49 +0000 (09:18 -0300)] 
build-many-glibcs.py: Move sparcv8 to extra_glibcs

It also fixes the sparcv9-linux-gnu-disable-multi-arch configuration.
The resulting sparc possible build permutations are:

  - sparc64-linux-gnu
  - sparcv9-linux-gnu
  - sparcv8-linux-gnu-leon3 (from extra_glibcs)
  - sparc64-linux-gnu-disable-multi-arch (from extra_glibcs)
  - sparcv9-linux-gnu-disable-multi-arch (from extra_glibcs)

4 years agosysdeps/clock_gettime: Use clock_gettime64 if avaliable
Alistair Francis [Mon, 15 Jul 2019 23:30:59 +0000 (16:30 -0700)] 
sysdeps/clock_gettime: Use clock_gettime64 if avaliable

With the clock_gettime64 call we prefer to use vDSO. There is no call
to clock_gettime64 on glibc with older headers and kernel 5.1+ if it
doesn't support vDSO.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agosysdeps: Add clock_gettime64 vDSO
Alistair Francis [Wed, 18 Sep 2019 15:37:58 +0000 (08:37 -0700)] 
sysdeps: Add clock_gettime64 vDSO

Add support for the clock_gettim64 vDSO calls. These are protected by
the HAVE_CLOCK_GETTIME64_VSYSCALL define.

HAVE_CLOCK_GETTIME64_VSYSCALL should be defined for 32-bit platforms
(WORDSIZE == 32) that only run on the 5.1 kernel or later. WORDSIZE ==
64 platforms can use #define __vdso_clock_gettime64 __vdso_clock_gettime
and use the __vdso_clock_gettime syscall as they don't have a
__vdso_clock_gettime64 call.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoDo not use ld.so to open statically linked programs in debugglibc.sh
Gabriel F. T. Gomes [Wed, 4 Dec 2019 01:40:38 +0000 (22:40 -0300)] 
Do not use ld.so to open statically linked programs in debugglibc.sh

Debugging programs that have been dynamically linked against an
uninstalled glibc requires unusual steps, such as letting gdb know where
the thread db library is located and explicitly calling the loader.
However, when the program under test is statically linked, these steps
are not required (as a matter of fact, using the dynamic loader to run a
statically linked program is wrong and will fail), and gdb should be
called the usual way.

This patch modifies debugglibc.sh so that it checks if the program under
test is statically linked, then runs the debugger appropriately.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAttach to test in container from debugglibc.sh
Gabriel F. T. Gomes [Wed, 4 Dec 2019 01:10:50 +0000 (22:10 -0300)] 
Attach to test in container from debugglibc.sh

Some test cases are meant to be ran inside the container infrastructure
and make check automatically runs them as such.  However, running a
single test case in a container without make check is useful.

This patch adds a new --tool option to testrun.sh that makes this easy,
as well as it adds a new option (-c or --in-container) to debugglibc.sh,
which causes the program under test to be ran in a container (with
WAIT_FOR_DEBUGGER=1), then automatically attaches GDB to it.

Automatically detecting if a test case is supposed to be ran inside a
container is harder (if not impossible), as Carlos pointed out [1],
however, this patch makes it easier to do it manually:

  Using testrun.sh with containerized test:

    $ ./testrun.sh --tool=container /absolute/path/to/program

  Using debugglibc.sh with containerized test:

    $ ./debugglibc.sh -c /absolute/path/to/program

Note: running these commands with relative paths causes error and
warning messages to be displayed, although the test case might succeed.

For example, with relative path:

  $ ./testrun.sh --tool=container elf/tst-ldconfig-bad-aux-cache
  error: subprocess failed: execv
  error:   unexpected error output from subprocess
  /sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory
  info: f    0    1064   /var/cache/ldconfig/aux-cache            20 aux-cache
  [...]

Whereas with absolute paths, the errors and warnings are gone:

  $ ./testrun.sh --tool=container $PWD/elf/tst-ldconfig-bad-aux-cache
  info: f    0    1064   /var/cache/ldconfig/aux-cache            20 aux-cache
  [...]

[1] https://sourceware.org/ml/libc-alpha/2019-11/msg00873.html

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoExpand $(as-needed) and $(no-as-needed) throughout the build system
Florian Weimer [Tue, 3 Dec 2019 09:58:52 +0000 (10:58 +0100)] 
Expand $(as-needed) and $(no-as-needed) throughout the build system

Since commit a3cc4f48e94f32c9532ee36982ac00eb1e5719b0 ("Remove
--as-needed configure test."), --as-needed support is no longer
optional.

The macros are not much shorter and do not provide documentary
value, either, so this commit removes them.

4 years agox86: Assume --enable-cet if GCC defaults to CET [BZ #25225]
Florian Weimer [Tue, 3 Dec 2019 17:48:18 +0000 (18:48 +0100)] 
x86: Assume --enable-cet if GCC defaults to CET [BZ #25225]

This links in CET support if GCC defaults to CET.  Otherwise, __CET__
is defined, yet CET functionality is not compiled and linked into the
dynamic loader, resulting in a linker failure due to undefined
references to _dl_cet_check and _dl_open_check.

4 years agoldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:00 +0000 (11:48 -0300)] 
ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold

Since the commit

commit 86a0f56158bd9cbaf2d640e2e6c66539f4cbbcc1
Author: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Date:   Thu Jun 28 13:57:50 2018 +0530

    ldbl-128ibm-compat: Introduce ieee128 symbols

IEEE long double versions of strfroml, strtold, and wcstold have been
prepared, but not exposed (which will only happen when the full support
for IEEE long double is complete).  This patch adds tests for these
functions in both IBM and IEEE long double mode.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Add tests for strfmon and strfmon_l
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:56 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add tests for strfmon and strfmon_l

This patch adds elementary tests to check that strfmon and strfmon_l
correctly evaluate long double values with IBM Extended Precision and
IEEE binary128 format.

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Add strfmon_l with IEEE long double format
Rajalakshmi Srinivasaraghavan [Thu, 28 Jun 2018 09:47:42 +0000 (15:17 +0530)] 
ldbl-128ibm-compat: Add strfmon_l with IEEE long double format

Similarly to what has been done for printf-like functions, more
specifically to the internal implementation in __vfprintf_internal, this
patch extends __vstrfmon_l_internal to deal with long double values with
binary128 format (as a third format option and reusing the float128
implementation).

Tested for powerpc64le, powerpc64, x86_64, and with build-many-glibcs.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Replace http with https in new files
Gabriel F. T. Gomes [Wed, 27 Nov 2019 21:14:14 +0000 (18:14 -0300)] 
ldbl-128ibm-compat: Replace http with https in new files

Several commits to the ldbl-128ibm-compat directory added new files
where the URL in the copyright notice pointed to an http, rather than to
an https, address.  This happened because I copied the notices before
commit ID 5a82c74822d3.  This trivial patch fixes this issue.

4 years agoelf: Do not run IFUNC resolvers for LD_DEBUG=unused [BZ #24214]
Florian Weimer [Fri, 29 Nov 2019 16:55:22 +0000 (17:55 +0100)] 
elf: Do not run IFUNC resolvers for LD_DEBUG=unused [BZ #24214]

This commit adds missing skip_ifunc checks to aarch64, arm, i386,
sparc, and x86_64.  A new test case ensures that IRELATIVE IFUNC
resolvers do not run in various diagnostic modes of the dynamic
loader.

Reviewed-By: Szabolcs Nagy <szabolcs.nagy@arm.com>
4 years agoelf/tst-dlopenfail: Disable --no-as-needed for tst-dlopenfailmod1.so
Florian Weimer [Mon, 2 Dec 2019 13:53:16 +0000 (14:53 +0100)] 
elf/tst-dlopenfail: Disable --no-as-needed for tst-dlopenfailmod1.so

Otherwise, the shared object dependency which triggers the load
failure is dropped, invalidating the test.

4 years agohurd: Fix ld.so __access override from libc
Samuel Thibault [Sun, 1 Dec 2019 20:52:39 +0000 (20:52 +0000)] 
hurd: Fix ld.so __access override from libc

ld.so symbols to be overriden by libc need to be extern to really get
overriden. __access happens to have never been exposed, putting it to
GLIBC_PRIVATE.

4 years agohurd: Fix ld.so __getcwd override from libc
Samuel Thibault [Sun, 1 Dec 2019 20:48:46 +0000 (20:48 +0000)] 
hurd: Fix ld.so __getcwd override from libc

ld.so symbols to be overriden by libc need to be extern to really get
overriden. __getcwd happens to have never been exposed, putting it to
GLIBC_PRIVATE.

4 years agohurd: Make __sigprocmask GLIBC_PRIVATE
Samuel Thibault [Sun, 1 Dec 2019 19:20:51 +0000 (19:20 +0000)] 
hurd: Make __sigprocmask GLIBC_PRIVATE

We do not need to expose it.

4 years agohurd: Fix renameat2 error
Samuel Thibault [Sun, 1 Dec 2019 16:46:38 +0000 (16:46 +0000)] 
hurd: Fix renameat2 error

renameat2 has to exclude RENAME_EXCHANGE | RENAME_NOREPLACE with EINVAL,
as tested by stdio-common/tst-renameat2.

4 years agohurd: make strerror(0) coherent with other ports
Samuel Thibault [Sun, 1 Dec 2019 16:36:41 +0000 (16:36 +0000)] 
hurd: make strerror(0) coherent with other ports

Some tests assume that it is "Success", and it is not necessarily
related to the kernel anyway.

4 years agohurd: Fix ld.so link
Samuel Thibault [Sun, 1 Dec 2019 14:58:25 +0000 (14:58 +0000)] 
hurd: Fix ld.so link

Since a2e8aa0d9ea6 ("Block signals during the initial part of dlopen") dl_open
uses sigprocmask, so we need a stub implementation.

4 years agoUpdate kernel version to 5.4 in tst-mman-consts.py.
Joseph Myers [Fri, 29 Nov 2019 14:18:26 +0000 (14:18 +0000)] 
Update kernel version to 5.4 in tst-mman-consts.py.

This patch updates the kernel version in the test tst-mman-consts.py
to 5.4.  (There are no new constants covered by this test in 5.4 that
need any other header changes.)

Tested with build-many-glibcs.py.

4 years agoUpdate SOMAXCONN value from Linux 5.4.
Joseph Myers [Fri, 29 Nov 2019 14:17:15 +0000 (14:17 +0000)] 
Update SOMAXCONN value from Linux 5.4.

Linux 5.4 changes the SOMAXCONN value from 128 to 4096 (this isn't in
a uapi header; various constants related to the kernel/userspace
interface, including this one, are in the non-uapi linux/socket.h
header).

This patch increases the value in glibc.  As I understand it, it is
safe to use a higher value even with older kernels (the kernel will
simply adjust the value passed to listen to be no more than the value
supported in the kernel), and SOMAXCONN is actually only a default for
a sysctl value in the kernel that can be changed at runtime.  So I
think updating the value in glibc is a reasonable and safe thing to
do.

Tested for x86_64.

4 years agoUpdate syscall-names.list for Linux 5.4.
Joseph Myers [Thu, 28 Nov 2019 20:32:09 +0000 (20:32 +0000)] 
Update syscall-names.list for Linux 5.4.

This patch updates syscall-names.list for Linux 5.4.  There are no new
syscalls, so this is just a matter of updating the version number
listed in the file.

Tested with build-many-glibcs.py.

4 years agoFix syntax error in build-many-glibcs.py.
Joseph Myers [Thu, 28 Nov 2019 17:22:22 +0000 (17:22 +0000)] 
Fix syntax error in build-many-glibcs.py.

The recent SPARC changes caused a syntax error:

    'ccopts': '-m32 -mlong-double-128 -mcpu=v9'}],
                                                ^
SyntaxError: invalid syntax

Fixed by this patch.

4 years agoDefine MADV_COLD and MADV_PAGEOUT from Linux 5.4.
Joseph Myers [Thu, 28 Nov 2019 14:54:22 +0000 (14:54 +0000)] 
Define MADV_COLD and MADV_PAGEOUT from Linux 5.4.

Linux 5.4 adds constants MADV_COLD and MADV_PAGEOUT (defined with the
same values on all architectures).  This patch adds them to
bits/mman-linux.h.

Tested for x86_64.

4 years agoMove _dl_open_check to its original place in dl_open_worker
Florian Weimer [Thu, 31 Oct 2019 17:48:43 +0000 (18:48 +0100)] 
Move _dl_open_check to its original place in dl_open_worker

This reverts the non-test change from commit d0093c5cefb7f7a4143f
("Call _dl_open_check after relocation [BZ #24259]"), given that
the underlying bug has been fixed properly in commit 61b74477fa7f63
("Remove all loaded objects if dlopen fails, ignoring NODELETE
[BZ #20839]").

Tested on x86-64-linux-gnu, with and without --enable-cet.

Change-Id: I995a6cfb89f25d2b0cf5e606428c2a93eb48fc33

4 years agoBlock signals during the initial part of dlopen
Florian Weimer [Thu, 31 Oct 2019 18:30:19 +0000 (19:30 +0100)] 
Block signals during the initial part of dlopen

Lazy binding in a signal handler that interrupts a dlopen sees
intermediate dynamic linker state.  This has likely been always
unsafe, but with the new pending NODELETE state, this is clearly
incorrect.  Other threads are excluded via the loader lock, but the
current thread is not.  Blocking signals until right before ELF
constructors run is the safe thing to do.

Change-Id: Iad079080ebe7442c13313ba11dc2797953faef35

4 years agoRemove all loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]
Florian Weimer [Wed, 13 Nov 2019 14:44:56 +0000 (15:44 +0100)] 
Remove all loaded objects if dlopen fails, ignoring NODELETE [BZ #20839]

This introduces a “pending NODELETE” state in the link map, which is
flipped to the persistent NODELETE state late in dlopen, via
activate_nodelete.    During initial relocation, symbol binding
records pending NODELETE state only.  dlclose ignores pending NODELETE
state.  Taken together, this results that a partially completed dlopen
is rolled back completely because new NODELETE mappings are unloaded.

Tested on x86_64-linux-gnu and i386-linux-gnu.

Change-Id: Ib2a3d86af6f92d75baca65431d74783ee0dbc292

4 years agoAvoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112]
Florian Weimer [Wed, 27 Nov 2019 15:37:17 +0000 (16:37 +0100)] 
Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112]

This change splits the scope and TLS slotinfo updates in dlopen into
two parts: one to resize the data structures, and one to actually apply
the update.  The call to add_to_global_resize in dl_open_worker is moved
before the demarcation point at which no further memory allocations are
allowed.

_dl_add_to_slotinfo is adjusted to make the list update optional.  There
is some optimization possibility here because we could grow the slotinfo
list of arrays in a single call, one the largest TLS modid is known.

This commit does not fix the fatal meory allocation failure in
_dl_update_slotinfo.  Ideally, this error during dlopen should be
recoverable.

The update order of scopes and TLS data structures is retained, although
it appears to be more correct to fully initialize TLS first, and then
expose symbols in the newly loaded objects via the scope update.

Tested on x86_64-linux-gnu.

Change-Id: I240c58387dabda3ca1bcab48b02115175fa83d6c

4 years agoAvoid late failure in dlopen in global scope update [BZ #25112]
Florian Weimer [Thu, 31 Oct 2019 17:25:39 +0000 (18:25 +0100)] 
Avoid late failure in dlopen in global scope update [BZ #25112]

The call to add_to_global in dl_open_worker happens after running ELF
constructors for new objects.  At this point, proper recovery from
malloc failure would be quite complicated: We would have to run the
ELF destructors and close all opened objects, something that we
currently do not do.

Instead, this change splits add_to_global into two phases,
add_to_global_resize (which can raise an exception, called before ELF
constructors run), and add_to_global_update (which cannot, called
after ELF constructors).  A complication arises due to recursive
dlopen: After the inner dlopen consumes some space, the pre-allocation
in the outer dlopen may no longer be sufficient.  A new member in the
namespace structure, _ns_global_scope_pending_adds keeps track of the
maximum number of objects that need to be added to the global scope.
This enables the inner add_to_global_resize call to take into account
the needs of an outer dlopen.

Most code in the dynamic linker assumes that the number of global
scope entries fits into an unsigned int (matching the r_nlist member
of struct r_scop_elem).  Therefore, change the type of
_ns_global_scope_alloc to unsigned int (from size_t), and add overflow
checks.

Change-Id: Ie08e2f318510d5a6a4bcb1c315f46791b5b77524

4 years agoLazy binding failures during dlopen/dlclose must be fatal [BZ #24304]
Florian Weimer [Wed, 27 Nov 2019 15:20:47 +0000 (16:20 +0100)] 
Lazy binding failures during dlopen/dlclose must be fatal [BZ #24304]

If a lazy binding failure happens during the execution of an ELF
constructor or destructor, the dynamic loader catches the error
and reports it using the dlerror mechanism.  This is undesirable
because there could be other constructors and destructors that
need processing (which are skipped), and the process is in an
inconsistent state at this point.  Therefore, we have to issue
a fatal dynamic loader error error and terminate the process.

Note that the _dl_catch_exception in _dl_open is just an inner catch,
to roll back some state locally.  If called from dlopen, there is
still an outer catch, which is why calling _dl_init via call_dl_init
and a no-exception is required and cannot be avoiding by moving the
_dl_init call directly into _dl_open.

_dl_fini does not need changes because it does not install an error
handler, so errors are already fatal there.

Change-Id: I6b1addfe2e30f50a1781595f046f44173db9491a

4 years agoresolv: Implement trust-ad option for /etc/resolv.conf [BZ #20358]
Florian Weimer [Wed, 30 Oct 2019 16:26:58 +0000 (17:26 +0100)] 
resolv: Implement trust-ad option for /etc/resolv.conf [BZ #20358]

This introduces a concept of trusted name servers, for which the
AD bit is passed through to applications.  For untrusted name
servers (the default), the AD bit in responses are cleared, to
provide a safe default.

This approach is very similar to the one suggested by Pavel Šimerda
in <https://bugzilla.redhat.com/show_bug.cgi?id=1164339#c15>.

The DNS test framework in support/ is enhanced with support for
setting the AD bit in responses.

Tested on x86_64-linux-gnu.

Change-Id: Ibfe0f7c73ea221c35979842c5c3b6ed486495ccc

4 years agodlsym: Do not determine caller link map if not needed
Florian Weimer [Fri, 8 Nov 2019 14:48:51 +0000 (15:48 +0100)] 
dlsym: Do not determine caller link map if not needed

Obtaining the link map is potentially very slow because it requires
iterating over all loaded objects in the current implementation.  If
the caller supplied an explicit handle (i.e., not one of the RTLD_*
constants), the dlsym implementation does not need the identity of the
caller (except in the special case of auditing), so this change
avoids computing it in that case.

Even in the minimal case (dlsym called from a main program linked with
-dl), this shows a small speedup, perhaps around five percent.  The
performance improvement can be arbitrarily large in principle (if
_dl_find_dso_for_object has to iterate over many link maps).

Change-Id: Ide5d9e2cc7ac25a0ffae8fb4c26def0c898efa29

4 years agolibio: Disable vtable validation for pre-2.1 interposed handles [BZ #25203]
Florian Weimer [Fri, 22 Nov 2019 21:10:42 +0000 (22:10 +0100)] 
libio: Disable vtable validation for pre-2.1 interposed handles [BZ #25203]

Commit c402355dfa7807b8e0adb27c009135a7e2b9f1b0 ("libio: Disable
vtable validation in case of interposition [BZ #23313]") only covered
the interposable glibc 2.1 handles, in libio/stdfiles.c.  The
parallel code in libio/oldstdfiles.c needs similar detection logic.

Fixes (again) commit db3476aff19b75c4fdefbe65fcd5f0a90588ba51
("libio: Implement vtable verification [BZ #20191]").

Change-Id: Ief6f9f17e91d1f7263421c56a7dc018f4f595c21

4 years agoldbl-128ibm-compat: Add syslog functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:51 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add syslog functions

Similarly to __vfprintf_internal and __vfscanf_internal, the internal
implementation of syslog functions (__vsyslog_internal) takes a
'mode_flags' parameter used to select the format of long double
parameters.  This patch adds variants of the syslog functions that set
'mode_flags' to PRINTF_LDBL_USES_FLOAT128, thus enabling the correct
printing of long double values on powerpc64le, when long double has IEEE
binary128 format (-mabi=ieeelongdouble).

Tested for powerpc64le.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Add obstack printing functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:47 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add obstack printing functions

Similarly to the functions from the *printf family, this patch adds
implementations for __obstack_*printf* functions that set the
'mode_flags' parameter to PRINTF_LDBL_USES_FLOAT128, before making calls
to __vfprintf_internal (indirectly through __obstack_vprintf_internal).

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Reuse tests for err.h and error.h functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:39 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Reuse tests for err.h and error.h functions

Commit IDs 9771e6cb5102 and 7597b0c7f711 added tests for the functions
from err.h and error.h that can take long double parameters.
Afterwards, commit ID f0eaf8627654 reused them on architectures that
changed the long double format from the same as double to something else
(i.e.: architectures that imply ldbl-opt).  This patch reuses it again
for IEEE long double on powerpc64le.

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Add error.h functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:35 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add error.h functions

Use the recently added, internal functions, __error_at_line_internal and
__error_internal, to provide error.h functions that can take long double
arguments with IEEE binary128 format on platforms where long double can
also take double format or some non-IEEE format (currently, this means
powerpc64le).

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Add err.h functions
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:30 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add err.h functions

Use the recently added, internal functions, __vwarnx_internal and
__vwarn_internal, to provide err.h functions that can take long double
arguments with IEEE binary128 format on platforms where long double can
also take double format or some non-IEEE format (currently, this means
powerpc64le).

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agoldbl-128ibm-compat: Add argp_error and argp_failure
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:47:25 +0000 (11:47 -0300)] 
ldbl-128ibm-compat: Add argp_error and argp_failure

Use the recently added, internal functions, __argp_error_internal and
__argp_failure_internal, to provide argp_error and argp_failure that can
take long double arguments with IEEE binary128 format on platforms where
long double can also take double format or some non-IEEE format
(currently, this means powerpc64le).

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
4 years agosparc: Use atomic compiler builtins on sparc
Adhemerval Zanella [Tue, 12 Nov 2019 19:11:10 +0000 (19:11 +0000)] 
sparc: Use atomic compiler builtins on sparc

This patch removes the arch-specific atomic instruction, relying on
compiler builtins.  The __sparc32_atomic_locks support is removed
and a configure check is added to check if compiler uses libatomic
to implement CAS.

It also removes the sparc specific sem_* and pthread_barrier_*
implementations.  It in turn allows buidling against a LEON3/LEON4
sparcv8 target, although it will still be incompatible with generic
sparcv9.

Checked on sparcv9-linux-gnu and sparc64-linux-gnu.  I also checked
with build against sparcv8-linux-gnu with -mcpu=leon3.

Tested-by: Andreas Larsson <andreas@gaisler.com>