]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 years agoy2038: Export __clock_gettime64 to be usable in other libraries
Lukasz Majewski [Tue, 24 Mar 2020 07:52:15 +0000 (08:52 +0100)] 
y2038: Export __clock_gettime64 to be usable in other libraries

In the glibc project calls to clock_gettime shall be replaced with
__clock_gettime64, which is supporting 64 bit time.
To allow that the __clock_gettime64 needs to be exported as a GLIBC_PRIVATE
symbol.

4 years agomanual: Document the O_NOFOLLOW open flag
Florian Weimer [Tue, 5 May 2020 07:23:53 +0000 (09:23 +0200)] 
manual: Document the O_NOFOLLOW open flag

4 years agopowerpc64le/power9: guard power9 strcmp against rtld usage [BZ# 25905]
Paul E. Murphy [Fri, 1 May 2020 19:30:42 +0000 (14:30 -0500)] 
powerpc64le/power9: guard power9 strcmp against rtld usage [BZ# 25905]

strcmp is used while resolving PLT references.  Vector registers
should not be used during this.  The P9 strcmp makes heavy use of
vector registers, so it should be avoided in rtld.

This prevents quiet vector register corruption when glibc is configured
with --disable-multi-arch and --with-cpu=power9.  This can be seen with
test-float64x-compat_totalordermag during the first call into
totalordermagf64x@GLIBC_2.27.

Add a guard to fallback to the power8 implementation when building
power9 strcmp for libraries other than libc.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agofloat128: use builtin_signbitf128 always
Paul E. Murphy [Tue, 7 Apr 2020 21:20:35 +0000 (16:20 -0500)] 
float128: use builtin_signbitf128 always

The minimum GCC version has been raised to 6.2 for building
glibc.  Therefore, follow the advice inside the implementation
and remove the GCC < 6 codepath.

Likewise, remove the hidden_proto as all internal usages should
inline now.

4 years agoimprove out-of-bounds checking with GCC 10 attribute access [BZ #25219]
Martin Sebor [Mon, 4 May 2020 17:21:50 +0000 (11:21 -0600)] 
improve out-of-bounds checking with GCC 10 attribute access [BZ #25219]

Adds the access attribute newly introduced in GCC 10 to the subset of
function declarations that are already covered by _FORTIFY_SOURCE and
that don't have corresponding GCC built-in equivalents.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agonios2: delete sysdeps/unix/sysv/linux/nios2/kernel-features.h
Chung-Lin Tang [Mon, 4 May 2020 12:23:25 +0000 (20:23 +0800)] 
nios2: delete sysdeps/unix/sysv/linux/nios2/kernel-features.h

Commit 06436acf819d9e6ada7be3ca977d5c0a23d3f138 created a kernel-features.h
file with '#undef __ASSUME_SYSVIPC_DEFAULT_IPC_64', which is wrong for Nios II.
Deleting the header.

4 years agopowerpc: Rename argN to _argN in LOADARGS_N [BZ #25902]
H.J. Lu [Thu, 30 Apr 2020 22:49:47 +0000 (15:49 -0700)] 
powerpc: Rename argN to _argN in LOADARGS_N [BZ #25902]

LOADARGS_N in powerpc/sysdep.h uses argN as local variables.  It breaks
when argN is also a function argument.  Rename argN to _argN to avoid
conflict.

4 years agolocale/tst-localedef-path-norm: Don't create $(complocaledir)
Carlos O'Donell [Tue, 28 Apr 2020 19:46:00 +0000 (15:46 -0400)] 
locale/tst-localedef-path-norm: Don't create $(complocaledir)

We automatically create $(complocaledir) in the testroot.root
now and so we don't need to create it in the test.

Tested on x86_64.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agosupport: Set errno before testing it.
Carlos O'Donell [Wed, 29 Apr 2020 20:31:29 +0000 (16:31 -0400)] 
support: Set errno before testing it.

In test-conainer we should set errno to 0 before calling strtol,
and check after with TEST_COMPARE.

In tst-support_capture_subprocess we should set errno to 0 before
checking it after the call to strtol.

Tested on x86_64.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agolocaledef: Add tests-container test for --no-hard-links.
Carlos O'Donell [Tue, 25 Feb 2020 15:15:30 +0000 (10:15 -0500)] 
localedef: Add tests-container test for --no-hard-links.

The new tst-localedef-hardlinks verifies that when compiling
two locales (with default output directory) one with
--no-hard-links and one without the option, results in the
expected behaviour.  When --no-hard-links is used the link
counts on LC_CTYPE is 1, indicating that even thoug the two
locale are identical (though different named source files and
output direcotry) the localedef did not carry out the hard
link optimization.  Then when --no-hard-links is omitted the
localedef hard link optimization is correctly carried out and
for 2 compiled locales the link count for LC_CTYPE is 2.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agotest-container: Support $(complocaledir) and mkdirp.
Carlos O'Donell [Thu, 23 Jan 2020 14:45:00 +0000 (09:45 -0500)] 
test-container: Support $(complocaledir) and mkdirp.

Expand the support infrastructure:
- Create $(complocaledir) in the testroot.pristine to support localedef.
- Add the variable $complocaledir to script support.
- Add the script command 'mkdirp'.

All localedef tests which run with default paths need to have the
$(complocaledir) created in testroot.pristine. The localedef binary
will not by itself create the default path, but it will write into
the path. By adding this we can simplify the localedef tests.

The variable $complocaledir is the value of the configured
$(complocaledir) which is the location of the compiled locales that
will be searched by the runtime by default.

The command mkdirp will be available in script setup and will
be equivalent to running `mkdir -p`.

The variable and command can be used to write more complex tests.

Reviewed-by: DJ Delorie <dj@redhat.com>
4 years agoi386: Remove unused variable in sysdeps/x86/cacheinfo.c
Florian Weimer [Thu, 30 Apr 2020 19:12:23 +0000 (21:12 +0200)] 
i386: Remove unused variable in sysdeps/x86/cacheinfo.c

Commit a98dc92dd1e278df4c501deb07985018bc2b06de ("x86: Add cache
information support for Zhaoxin processors") introduced an unused
variable warning in the default i686-linux-gnu build:

In file included from ../sysdeps/i386/cacheinfo.c:3:
../sysdeps/x86/cacheinfo.c: In function 'init_cacheinfo':
../sysdeps/x86/cacheinfo.c:762:16: error: unused variable 'eax' [-Werror=unused-variable]
  762 |   unsigned int eax;
      |                ^~~

4 years agoAdd a C wrapper for prctl [BZ #25896]
H.J. Lu [Thu, 30 Apr 2020 17:42:43 +0000 (10:42 -0700)] 
Add a C wrapper for prctl [BZ #25896]

Add a C wrapper to pass arguments in

/* Control process execution.  */
extern int prctl (int __option, ...) __THROW;

to prctl syscall:

extern int prctl (int, unsigned long int, unsigned long int,
  unsigned long int, unsigned long int);

4 years agopowerpc64le: Enable support for IEEE long double
Gabriel F. T. Gomes [Thu, 11 Jul 2019 14:48:28 +0000 (11:48 -0300)] 
powerpc64le: Enable support for IEEE long double

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.

Likewise, the internals of glibc are now built against IEEE long double.
However, the only (minimally) notable usage of long double is difftime.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: blacklist broken GCC compilers (e.g GCC 7.5.0)
Paul E. Murphy [Tue, 17 Mar 2020 13:38:54 +0000 (08:38 -0500)] 
powerpc64le: blacklist broken GCC compilers (e.g GCC 7.5.0)

GCC 7.5.0 (PR94200) will refuse to compile if both -mabi=% and
-mlong-double-128 are passed on the command line.  Surprisingly,
it will work happily if the latter is not.  For the sake of
maintaining status quo, test for and blacklist such compilers.

Tested with a GCC 8.3.1 and GCC 7.5.0 compiler for ppc64le.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: bump binutils version requirement to >= 2.26
Paul E. Murphy [Thu, 5 Mar 2020 15:32:08 +0000 (09:32 -0600)] 
powerpc64le: bump binutils version requirement to >= 2.26

This is a small step up from 2.25 which brings in support for
rewriting the .gnu.attributes section of libc/libm.so.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: raise GCC requirement to 7.4 for long double transition
Paul E. Murphy [Fri, 7 Feb 2020 20:08:23 +0000 (14:08 -0600)] 
powerpc64le: raise GCC requirement to 7.4 for long double transition

Add compiler feature tests to ensure we can build ieee128 long double.
These test for -mabi=ieeelongdouble, -mno-gnu-attribute, and -Wno-psabi.

Likewise, verify some compiler bugs have been addressed.  These aren't
helpful for building glibc, but may cause test failures when testing
the new long double.  See notes below from Raji.

On powerpc64le, some older compiler versions give error for the function
signbit() for 128-bit floating point types.  This is fixed by PR83862
in gcc 8.0 and backported to gcc6 and gcc7.  This patch adds a test
to check compiler version to avoid compiler errors during make check.

Likewise, test for -mno-gnu-attribute support which was

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.

Co-Authored-By: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Co-Authored-By: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoRename __LONG_DOUBLE_USES_FLOAT128 to __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI
Paul E. Murphy [Fri, 14 Feb 2020 22:41:11 +0000 (16:41 -0600)] 
Rename __LONG_DOUBLE_USES_FLOAT128 to __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI

Improve the commentary to aid future developers who will stumble
upon this novel, yet not always perfect, mechanism to support
alternative formats for long double.

Likewise, rename __LONG_DOUBLE_USES_FLOAT128 to
__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI now that development work
has settled down.  The command used was

git grep -l __LONG_DOUBLE_USES_FLOAT128 ':!./ChangeLog*' | \
  xargs sed -i 's/__LONG_DOUBLE_USES_FLOAT128/__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI/g'

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoldbl-128ibm-compat: workaround GCC 9 C++ PR90731
Paul E. Murphy [Fri, 6 Mar 2020 15:41:03 +0000 (09:41 -0600)] 
ldbl-128ibm-compat: workaround GCC 9 C++ PR90731

GCC 9 has a bug (PR90731) whereby __typeof does not correctly copy
exception specifiers[1].  Surprisingly, this can be quieted by declaring
"#pragma system_header", or if the headers are installed in a system
directory.

Work around this by using the pragma for any gcc version between
9.0 and 9.2 to ensure tests continue to compile.

[1] Example error from g++ 9.2.1:

In file included from ../include/sys/cdefs.h:3,
                 from ../include/features.h:465,
                 from ../bits/libc-header-start.h:33,
                 from ../math/math.h:27,
                 from ../include/math.h:7,
                 from test-math-isinff.cc:21:
../libio/bits/stdio-ldbl.h:25:20: error: declaration of ‘int sprintf(char*, const char*, ...)’ has a different exception specifier
   25 | __LDBL_REDIR_DECL (sprintf)
      |                    ^~~~~~~
../misc/sys/cdefs.h:461:26: note: in definition of macro ‘__LDBL_REDIR_DECL’
  461 |   extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
      |                          ^~~~
In file included from ../include/stdio.h:5,
                 from test-math-isinff.cc:22:
../libio/stdio.h:334:12: note: from previous declaration ‘int sprintf(char*, const char*, ...) throw ()’
  334 | extern int sprintf (char *__restrict __s,
      |            ^~~~~~~

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agox86: Add the test case of __get_cpu_features support for Zhaoxin processors
mayshao-oc [Sun, 26 Apr 2020 05:49:44 +0000 (13:49 +0800)] 
x86: Add the test case of __get_cpu_features support for Zhaoxin processors

For the test case of the __get_cpu_features interface, add an item in
cpu_kinds and a switch case for Zhaoxin support.

4 years agox86: Add cache information support for Zhaoxin processors
mayshao-oc [Sun, 26 Apr 2020 05:48:27 +0000 (13:48 +0800)] 
x86: Add cache information support for Zhaoxin processors

To obtain Zhaoxin CPU cache information, add a new function
handle_zhaoxin().

Add a new function get_common_cache_info() that extracts the code
in init_cacheinfo() to get the value of the variable shared, threads.

Add Zhaoxin branch in init_cacheinfo() for initializing variables,
such as __x86_shared_cache_size.

4 years agox86: Add CPU Vendor ID detection support for Zhaoxin processors
mayshao [Fri, 24 Apr 2020 04:55:38 +0000 (12:55 +0800)] 
x86: Add CPU Vendor ID detection support for Zhaoxin processors

To recognize Zhaoxin CPU Vendor ID, add a new architecture type
arch_kind_zhaoxin for Vendor Zhaoxin detection.

4 years agoUpdate translations
Siddhesh Poyarekar [Thu, 30 Apr 2020 01:57:51 +0000 (07:27 +0530)] 
Update translations

Incorporate updates from translationproject.org.

4 years agoAdd C wrappers for process_vm_readv/process_vm_writev [BZ #25810]
H.J. Lu [Wed, 29 Apr 2020 20:20:27 +0000 (13:20 -0700)] 
Add C wrappers for process_vm_readv/process_vm_writev [BZ #25810]

Since the the U marker can only be applied to 2 unsigned long arguments
in syscalls.list files, add a C wrapper for process_vm_readv and
process_vm_writev syscals which have more than 2 unsigned long arguments.

4 years agogeneric/typesizes.h: Add support for 32-bit arches with 64-bit types
Alistair Francis [Fri, 14 Feb 2020 19:02:29 +0000 (11:02 -0800)] 
generic/typesizes.h: Add support for 32-bit arches with 64-bit types

Update the default typesizes.h to match the new kernel sizes for 32-bit
architectures with a 64-bit time_t and friends. This follows the sizes
used for RV32 which is a y2038 safe architecture added after Linux 5.1.

Reviewed-by: Vineet Gupta <vgupta@synopsys.com>
Tested-by: Vineet Gupta <vgupta@synopsys.com>
4 years agosemctl: Remove the sem-pad.h file
Alistair Francis [Tue, 25 Feb 2020 23:52:59 +0000 (15:52 -0800)] 
semctl: Remove the sem-pad.h file

Remove the sem-pad.h file and instead have architectures override the
struct semid_ds via the bits/types/struct_semid_ds.h file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agobits/sem.h: Split out struct semid_ds
Alistair Francis [Tue, 25 Feb 2020 22:52:27 +0000 (14:52 -0800)] 
bits/sem.h: Split out struct semid_ds

Split out the struct semid_ds into it's own file. This will allow us to
have architectures specify their own version.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoMark unsigned long arguments with U in more syscalls [BZ #25810]
H.J. Lu [Wed, 29 Apr 2020 15:08:40 +0000 (08:08 -0700)] 
Mark unsigned long arguments with U in more syscalls [BZ #25810]

Mark unsigned long arguments in mmap, read, recv, recvfrom, send, sendto,
write, ioperm, sendfile64, setxattr, lsetxattr, fsetxattr, getxattr,
lgetxattr, fgetxattr, listxattr, llistxattr and flistxattr with U in
syscalls.list files.

4 years agoelf: Add initial flag argument to __libc_early_init
Florian Weimer [Wed, 29 Apr 2020 13:44:03 +0000 (15:44 +0200)] 
elf: Add initial flag argument to __libc_early_init

The rseq initialization should happen only for the libc in the base
namespace (in the dynamic case) or the statically linked libc.  The
__libc_multiple_libcs flag does not quite cover this case at present,
so this commit introduces a flag argument to __libc_early_init,
indicating whether the libc being libc is the primary one (of the main
program).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd SYSCALL_ULONG_ARG_[12] to pass long to syscall [BZ #25810]
H.J. Lu [Wed, 29 Apr 2020 12:35:34 +0000 (05:35 -0700)] 
Add SYSCALL_ULONG_ARG_[12] to pass long to syscall [BZ #25810]

X32 has 32-bit long and pointer with 64-bit off_t.  Since x32 psABI
requires that pointers passed in registers must be zero-extended to
64bit, x32 can share many syscall interfaces with LP64.  When a LP64
syscall with long and unsigned long int arguments is used for x32, these
arguments must be properly extended to 64-bit.  Otherwise if the upper
32 bits of the register have undefined value, such a syscall will be
rejected by kernel.

For syscalls implemented in assembly codes, 'U' is added to syscall
signature key letters for unsigned long, which is zero-extended to
64-bit types.  SYSCALL_ULONG_ARG_1 and SYSCALL_ULONG_ARG_2 are passed
to syscall-template.S for the first and the second unsigned long int
arguments if PSEUDOS_HAVE_ULONG_INDICES is defined.  They are used by
x32 to zero-extend 32-bit arguments to 64 bits.

Tested on i386, x86-64 and x32 as well as with build-many-glibcs.py.

4 years agoMakeconfig: Use $(error ...) to output error message
Simon Marchi [Wed, 29 Apr 2020 09:24:41 +0000 (11:24 +0200)] 
Makeconfig: Use $(error ...) to output error message

Being not familiar with the glibc repository, I typed "make" inside some
subdirectory that has a Makefile, and was met with:

    $ make
    ../Makeconfig:42: *** missing separator.  Stop.

At Makeconfig:42, we have:

    objdir must be defined by the build-directory Makefile.

Change that to use $(error ...), which I guess was the original
intention.  The result is:

    $ make
    ../Makeconfig:42: *** objdir must be defined by the build-directory Makefile.  Stop.

4 years agomanual: Fix typos in the fexecve description
Florian Weimer [Wed, 29 Apr 2020 08:15:51 +0000 (10:15 +0200)] 
manual: Fix typos in the fexecve description

Reported by Michael Kerrisk.

4 years agomisc: Remove sstk from the autogenerated system call list
Florian Weimer [Tue, 28 Apr 2020 10:10:32 +0000 (12:10 +0200)] 
misc: Remove sstk from the autogenerated system call list

This change should not have an effect because the system call was
never defined.  Also add the misssing attribute_compat_text_section
attribute to the sstk function (a minor optimization).  Also update the
NEWS file to document the change.

Fixes commit 9cc93ba0973ad04ee26c515a1552afb85e73c6ba
("misc: Turn sstk into a compat symbol").

4 years agoRemove unused floating-point configuration from gmp-impl.h.
Joseph Myers [Tue, 28 Apr 2020 15:05:09 +0000 (15:05 +0000)] 
Remove unused floating-point configuration from gmp-impl.h.

This patch removes the IEEE_DOUBLE_BIG_ENDIAN and
IEEE_DOUBLE_MIXED_ENDIAN macros from gmp-impl.h and gmp-mparam.h, and
the ieee_double_extract union from gmp-impl.h.  The macros were used
only in defining the union, which was used nowhere in glibc.  As GMP's
gmp-impl.h is over 5000 lines, the file in glibc is so far from the
GMP version that it doesn't seem to make sense to keep things there
that are not relevant in glibc.  (I expect there is plenty more in the
header after this patch that is also not relevant in glibc and can be
cleaned up later.)

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

4 years agosupport: Implement <support/xthread.h> key create/delete
Mathieu Desnoyers [Mon, 27 Apr 2020 19:40:24 +0000 (21:40 +0200)] 
support: Implement <support/xthread.h> key create/delete

Expose xpthread_key_create and xpthread_key_delete wrappers
for tests.

4 years agonptl/tst-setuid1-static: Improve isolation from system objects
Florian Weimer [Mon, 27 Apr 2020 13:00:14 +0000 (15:00 +0200)] 
nptl/tst-setuid1-static: Improve isolation from system objects

Static dlopen needs an LD_LIBRARY_PATH setting to avoid loading system
libraries.

4 years agoIncrease the timeout of locale/tst-localedef-path-norm
Szabolcs Nagy [Mon, 27 Apr 2020 11:24:14 +0000 (12:24 +0100)] 
Increase the timeout of locale/tst-localedef-path-norm

On the current AArch64 buildbot the default 20s timeout is not
enough to run this test, it seems

 make test t=locale/tst-localedef-path-norm

takes about 25s, so i increased the timeout to 30s.

4 years agoUse 2020 as copyright year.
Carlos O'Donell [Mon, 27 Apr 2020 14:31:02 +0000 (10:31 -0400)] 
Use 2020 as copyright year.

Use the year 2020 for files added by commit:
92954ffa5a5662fbfde14febd7e5dcc358c85470

4 years agomisc: Turn sstk into a compat symbol
Florian Weimer [Mon, 27 Apr 2020 10:04:23 +0000 (12:04 +0200)] 
misc: Turn sstk into a compat symbol

It is not implemented anywhere.  There is an osf_sstk system call on
alpha, but it is not used to implement sstk, and the system call
is not implemented on Linux, either.

4 years agomanual: Document the fexecve function
Florian Weimer [Mon, 27 Apr 2020 09:38:28 +0000 (11:38 +0200)] 
manual: Document the fexecve function

4 years agonptl: Start new threads with all signals blocked [BZ #25098]
Florian Weimer [Mon, 27 Apr 2020 07:55:10 +0000 (09:55 +0200)] 
nptl: Start new threads with all signals blocked [BZ #25098]

New threads inherit the signal mask from the current thread.  This
means that signal handlers can run on the newly created thread
immediately after the kernel has created the userspace thread, even
before glibc has initialized the TCB.  Consequently, new threads can
observe uninitialized ctype data, among other things.

To address this, block all signals before starting the thread, and
pass the original signal mask to the start routine wrapper.  On the
new thread, first perform all thread initialization, and then unblock
signals.

The cost of doing this is two rt_sigprocmask system calls on the old
thread, and one rt_sigprocmask system call on the new thread.  (If
there was a way to clone a new thread with a signals disabled, this
could be brought down to one system call each.)  The thread descriptor
increases in size, too, and sigset_t is fairly large.  This increase
could be brought down by reusing space the in the descriptor which is
not needed before running user code, or by switching to an internal
sigset_t definition which only covers the signals supported by the
kernel definition.  (Part of the thread descriptor size increase is
already offset by reduced stack usage in the thread start wrapper
routine after this commit.)

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agolocaledef: Add verbose messages for failure paths.
Carlos O'Donell [Wed, 8 Jan 2020 18:24:42 +0000 (13:24 -0500)] 
localedef: Add verbose messages for failure paths.

During testing of localedef running in a minimal container
there were several error cases which were hard to diagnose
since they appeared as strerror (errno) values printed by the
higher level functions.  This change adds three new verbose
messages for potential failure paths.  The new messages give
the user the opportunity to use -v and display additional
information about why localedef might be failing.  I found
these messages useful myself while writing a localedef
container test for --no-hard-links.

Since the changes cleanup the code that handle codeset
normalization we add tst-localedef-path-norm which contains
many sub-tests to verify the correct expected normalization of
codeset strings both when installing to default paths (the
only time normalization is enabled) and installing to absolute
paths.  During the refactoring I created at least one
buffer-overflow which valgrind caught, but these tests did not
catch because the exec in the container had a very clean heap
with zero-initialized memory. However, between valgrind and
the tests the results are clean.

The new tst-localedef-path-norm passes without regression on
x86_64.

Change-Id: I28b9f680711ff00252a2cb15625b774cc58ecb9d

4 years agoRemove most gmp-mparam.h headers.
Joseph Myers [Fri, 24 Apr 2020 22:08:59 +0000 (22:08 +0000)] 
Remove most gmp-mparam.h headers.

Most gmp-mparam.h headers in glibc define various macros to the same
values they would be defined to by the generic version of that header,
plus macros IEEE_DOUBLE_BIG_ENDIAN or IEEE_DOUBLE_MIXED_ENDIAN related
to the representation of double.  The latter macros are in turn only
used in gmp-impl.h to define union ieee_double_extract, which is not
used in glibc.  Thus all of these headers, except for the generic one
and those that define _LONG_LONG_LIMB for ILP32 configurations with
64-bit registers, are redundant, and this patch removes them.

Tested with build-many-glibcs.py that installed stripped shared
libraries are unchanged by this patch.

4 years agoelf: Implement __libc_early_init
Florian Weimer [Fri, 24 Apr 2020 20:31:15 +0000 (22:31 +0200)] 
elf: Implement __libc_early_init

This function is defined in libc.so, and the dynamic loader calls
right after relocation has been finished, before any ELF constructors
or the preinit function is invoked.  It is also used in the static
build for initializing parts of the static libc.

To locate __libc_early_init, a direct symbol lookup function is used,
_dl_lookup_direct.  It does not search the entire symbol scope and
consults merely a single link map.  This function could also be used
to implement lookups in the vDSO (as an optimization).

A per-namespace variable (libc_map) is added for locating libc.so,
to avoid repeated traversals of the search scope.  It is similar to
GL(dl_initfirst).  An alternative would have been to thread a context
argument from _dl_open down to _dl_map_object_from_fd (where libc.so
is identified).  This could have avoided the global variable, but
the change would be larger as a result.  It would not have been
possible to use this to replace GL(dl_initfirst) because that global
variable is used to pass the function pointer past the stack switch
from dl_main to the main program.  Replacing that requires adding
a new argument to _dl_init, which in turn needs changes to the
architecture-specific libc.so startup code written in assembler.

__libc_early_init should not be used to replace _dl_var_init (as
it exists today on some architectures).  Instead, _dl_lookup_direct
should be used to look up a new variable symbol in libc.so, and
that should then be initialized from the dynamic loader, immediately
after the object has been loaded in _dl_map_object_from_fd (before
relocation is run).  This way, more IFUNC resolvers which depend on
these variables will work.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Introduce <elf_machine_sym_no_match.h>
Florian Weimer [Fri, 24 Apr 2020 20:13:03 +0000 (22:13 +0200)] 
elf: Introduce <elf_machine_sym_no_match.h>

MIPS needs to ignore certain existing symbols during symbol lookup.
The old scheme uses the ELF_MACHINE_SYM_NO_MATCH macro, with an
inline function, within its own header, with a sysdeps override for
MIPS.  This allows re-use of the function from another file (without
having to include <dl-machine.h> or providing the default definition
for ELF_MACHINE_SYM_NO_MATCH).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoAdd a syscall test for [BZ #25810]
H.J. Lu [Wed, 22 Apr 2020 16:48:10 +0000 (09:48 -0700)] 
Add a syscall test for [BZ #25810]

Add a test to pass 64-bit long arguments to syscall with undefined upper
32 bits on x32.

Tested on i386, x86-64 and x32 as well as with build-many-glibcs.py.

4 years agoelf: Support lld-style link map for librtld.map
Fangrui Song [Tue, 21 Apr 2020 16:28:42 +0000 (13:28 -0300)] 
elf: Support lld-style link map for librtld.map

GNU ld and gold's -Map include a line like:

  path/to/build/libc_pic.a(check_fds.os)

lld -Map does not have the archive member list, but we can still derive the
members from the following output

             VMA              LMA     Size Align Out     In      Symbol
...
           1a1c0            1a1c0       e2    16         path/to/build/libc_pic.a(check_fds.os):(.text)

4 years agosignal: Only handle on NSIG signals on signal functions (BZ #25657)
Adhemerval Zanella [Thu, 12 Mar 2020 12:50:19 +0000 (09:50 -0300)] 
signal: Only handle on NSIG signals on signal functions (BZ #25657)

The upper bits of the sigset_t s not fully initialized in the signal
mask calls that return information from kernel (sigprocmask,
sigpending, and pthread_sigmask), since the exported sigset_t size
(1024 bits) is larger than Linux support one (64 or 128 bits).
It might make sigisemptyset/sigorset/sigandset fail if the mask
is filled prior the call.

This patch changes the internal signal function to handle up to
supported Linux signal number (_NSIG), the remaining bits are
untouched.

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

4 years agolinux: Use pthread_sigmask on sigprocmask
Adhemerval Zanella [Wed, 11 Mar 2020 18:21:59 +0000 (15:21 -0300)] 
linux: Use pthread_sigmask on sigprocmask

With pthread_sigmask on libc.so, it allows implement sigprocmask
on top of pthread_sigmask.

Checked on x86_64-linux-gnu.

4 years agoia64: Remove sigprocmask/sigblock objects from libpthread
Adhemerval Zanella [Fri, 13 Mar 2020 19:10:08 +0000 (19:10 +0000)] 
ia64: Remove sigprocmask/sigblock objects from libpthread

It is required because __libc_unwind_longjmp (used on thread
cancellation) calls __sigprocmask.  Replace with a direct call.

They are required because __libc_unwind_longjmp (used for thread
cancellation) calls __sigprocmask.  Replace this with a direct call.

The sigblock function is not exported and is not used internally, so
it can be removed.

Checked on cross build for ia64-linux-gnu.

4 years agonptl: Move pthread_sigmask implementation to libc
Adhemerval Zanella [Wed, 11 Mar 2020 18:19:24 +0000 (15:19 -0300)] 
nptl: Move pthread_sigmask implementation to libc

This is part of the libpthread removal project:

  <https://sourceware.org/ml/libc-alpha/2019-10/msg00080.html>

A new symbol version is added on libc to force loading failure
instead of lazy binding one for newly binaries with old loaders.

Checked with a build against all affected ABIs.

4 years agoBug 25819: Update to Unicode 13.0.0
Mike FABIAN [Tue, 14 Apr 2020 16:43:13 +0000 (18:43 +0200)] 
Bug 25819: Update to Unicode 13.0.0

Unicode 13.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 13.0.0, using
the generator scripts contributed by Mike FABIAN (Red Hat).

Total added characters in newly generated CHARMAP: 5930
Total added characters in newly generated WIDTH: 5536

4 years agoARC: Update syscall-names.list for ARC specific syscalls
Vineet Gupta [Thu, 9 Apr 2020 02:56:12 +0000 (19:56 -0700)] 
ARC: Update syscall-names.list for ARC specific syscalls

4 years agoRevert "x86_64: Add SSE sfp-exceptions"
Adhemerval Zanella [Mon, 20 Apr 2020 11:14:48 +0000 (08:14 -0300)] 
Revert "x86_64: Add SSE sfp-exceptions"

The __sfp_handle_exceptions is not fully correct regarding raising
exceptions, since there is no direct way to raise only FP_EX_OVERFLOW
nor FP_EX_UNDERFLOW for SSE mode.  Both libgcc and feraiseexcept rely
on x87 mode to accomplish it.

This reverts commit 460ee50de054396cc9791ff4cfdc2f5029fb923d.

Checked on x86_64.

4 years agoprovide y2038 safe socket constants for default/asm-generic ABI
Vineet Gupta [Sun, 29 Mar 2020 04:10:20 +0000 (21:10 -0700)] 
provide y2038 safe socket constants for default/asm-generic ABI

These will be used by upcoming RV32 and ARC ports and any future ports.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
4 years agox86_64: Add SSE sfp-exceptions
Adhemerval Zanella [Thu, 26 Mar 2020 14:00:56 +0000 (11:00 -0300)] 
x86_64: Add SSE sfp-exceptions

The exported x86_64 fenv.h functions operate on both i387 and SSE (since
they should work on both float, double, and long double) while the
internal libc_fe* set either SSE (float, double, and float128) or
i387 (long double).

The libgcc __sfp_handle_exceptions (used on float128 implementation),
however, will set either SEE or i387 exception depending of the
exception to raise.  This broke the internal assumption of float128
where only SSE operations will be used.

This patch reimplements the libgcc __sfp_handle_exceptions to use only
SSE operations and sets libgcc to use it instead of its own
implementation.

And I think we should fix libgcc in a similar manner, since checking on
config/i386/64/sfp-machine.h it already only supports SSE rounding mode
and x86_64 ABI also expectes float128 to use SSE registers [1]
(although it is not clear on how future implementation might implement
it).

Checked on x86_64-linux-gnu.

[1] https://github.com/hjl-tools/x86-psABI/wiki/X86-psABI

4 years agoRemove __NO_MATH_INLINES
Adhemerval Zanella [Fri, 20 Mar 2020 13:05:20 +0000 (10:05 -0300)] 
Remove __NO_MATH_INLINES

With fenvinline.h removal the flag is not used anymore.

Checked on x86_64-linux-gnu.

4 years agoi686: Add INTERNAL_SYSCALL_NCS 6 argument support
Adhemerval Zanella [Mon, 6 Apr 2020 17:20:32 +0000 (14:20 -0300)] 
i686: Add INTERNAL_SYSCALL_NCS 6 argument support

It is required for i686 BZ#12683 support when building with -Os
or -fno-omit-frame-pointer on some gcc versions.  It is not used
on current code.

Check on i686-linux-gnu.

4 years agoReset converter state after second wchar_t output (Bug 25734)
Carlos O'Donell [Fri, 27 Mar 2020 21:03:36 +0000 (17:03 -0400)] 
Reset converter state after second wchar_t output (Bug 25734)

An input BIG5-HKSCS character may be converted into at most 2 wchar_t
characters. After outputting the second whcar_t character (which was
saved in the converter state) we must reset the state. If we fail
to reset the state we will be stuck continually copying that
character to the output even if we have further input to consider.

We add a new test case that covers the 4 BIG5-HKSCS characters
that may become 2 wchar_t characters.

Reviewed-by: Tom Honermann <tom@honermann.net>
4 years agoFix typo in posix/tst-fnmatch.input (Bug 25790)
Carlos O'Donell [Mon, 6 Apr 2020 14:34:05 +0000 (10:34 -0400)] 
Fix typo in posix/tst-fnmatch.input (Bug 25790)

Reported-by: Michael Builov <mbuilov@gmail.com>
4 years agoLinux: Remove <sys/sysctl.h> and the sysctl function
Florian Weimer [Wed, 15 Apr 2020 15:17:32 +0000 (17:17 +0200)] 
Linux: Remove <sys/sysctl.h> and the sysctl function

Linux 5.5 remove the system call in commit
61a47c1ad3a4dc6882f01ebdc88138ac62d0df03 ("Linux: Remove
<sys/sysctl.h>").  Therefore, the compat function is just a stub that
sets ENOSYS.

Due to SHLIB_COMPAT, new ports will not add the sysctl function anymore
automatically.

x32 already lacks the sysctl function, so an empty sysctl.c file is
used to suppress it.  Otherwise, a new compat symbol would be added.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoposix: Add wait4 test case
Alistair Francis [Wed, 8 Apr 2020 16:05:20 +0000 (09:05 -0700)] 
posix: Add wait4 test case

Add a wait4 test case based on the waitid test case.

4 years agolinux: wait4: Fix incorrect return value comparison
Alistair Francis [Mon, 6 Apr 2020 17:56:26 +0000 (10:56 -0700)] 
linux: wait4: Fix incorrect return value comparison

Patch 600f00b "linux: Use long time_t for wait4/getrusage" introduced
two bugs:
 - The usage32 struct was set if the wait4 syscall had an error.
 - For 32-bit systems the usage struct was set even if it was specified
   as NULL.

This patch fixes the two issues.

4 years agohurd: add mach_print function
Samuel Thibault [Tue, 14 Apr 2020 11:19:18 +0000 (13:19 +0200)] 
hurd: add mach_print function

* mach/Versions (GLIBC_2.32): Add mach_print.
* sysdeps/mach/hurd/i386/libc.abilist (GLIBC_2.32): Add mach_print.

4 years agox32: Properly pass long to syscall [BZ #25810]
H.J. Lu [Mon, 13 Apr 2020 17:31:26 +0000 (10:31 -0700)] 
x32: Properly pass long to syscall [BZ #25810]

X32 has 32-bit long and pointer with 64-bit off_t.  Since x32 psABI
requires that pointers passed in registers must be zero-extended to
64bit, x32 can share many syscall interfaces with LP64.  When a LP64
syscall with long and unsigned long arguments is used for x32, these
arguments must be properly extended to 64-bit.  Otherwise if the upper
32 bits of the register have undefined value, such a syscall will be
rejected by kernel.

Enforce zero-extension for pointers and array system call arguments.
For integer types, extend to int64_t (the full register) using a
regular cast, resulting in zero or sign extension based on the
signedness of the original type.

For

       void *mmap(void *addr, size_t length, int prot, int flags,
                  int fd, off_t offset);

we now generate

   0: 41 f7 c1 ff 0f 00 00  test   $0xfff,%r9d
   7: 75 1f                 jne    28 <__mmap64+0x28>
   9: 48 63 d2              movslq %edx,%rdx
   c: 89 f6                 mov    %esi,%esi
   e: 4d 63 c0              movslq %r8d,%r8
  11: 4c 63 d1              movslq %ecx,%r10
  14: b8 09 00 00 40        mov    $0x40000009,%eax
  19: 0f 05                 syscall

That is

1. addr is unchanged.
2. length is zero-extend to 64 bits.
3. prot is sign-extend to 64 bits.
4. flags is sign-extend to 64 bits.
5. fd is sign-extend to 64 bits.
6. offset is unchanged.

For int arguments, since kernel uses only the lower 32 bits and ignores
the upper 32 bits in 64-bit registers, these work correctly.

Tested on x86-64 and x32.  There are no code changes on x86-64.

4 years agoAdd GRND_INSECURE from Linux 5.6 to sys/random.h
Joseph Myers [Thu, 9 Apr 2020 21:21:16 +0000 (21:21 +0000)] 
Add GRND_INSECURE from Linux 5.6 to sys/random.h

This patch adds the GRND_INSECURE constant from Linux 5.6 to glibc's
sys/random.h.  This is also added to the documentation.  The constant
acts as a no-op for the Hurd implementation (as that doesn't check
whether the flags are known), which is semantically fine, while older
Linux kernels reject unknown flags with an EINVAL error.

Tested for x86_64.

4 years agoUpdate kernel version to 5.6 in tst-mman-consts.py.
Joseph Myers [Thu, 9 Apr 2020 21:19:19 +0000 (21:19 +0000)] 
Update kernel version to 5.6 in tst-mman-consts.py.

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

Tested with build-many-glibcs.py.

4 years agoUpdate mips libm-test-ulps
Adhemerval Zanella [Wed, 8 Apr 2020 16:53:08 +0000 (13:53 -0300)] 
Update mips libm-test-ulps

4 years agoUpdate alpha libm-test-ulps
Adhemerval Zanella [Wed, 8 Apr 2020 12:40:27 +0000 (09:40 -0300)] 
Update alpha libm-test-ulps

4 years agoUpdate ia64 libm-test-ulps
Adhemerval Zanella [Wed, 8 Apr 2020 12:36:05 +0000 (09:36 -0300)] 
Update ia64 libm-test-ulps

4 years agoUpdate sparc libm-test-ulps
Adhemerval Zanella [Wed, 8 Apr 2020 11:53:35 +0000 (14:53 +0300)] 
Update sparc libm-test-ulps

4 years agoUpdate arm libm-test-ulps
Adhemerval Zanella [Wed, 8 Apr 2020 11:50:27 +0000 (11:50 +0000)] 
Update arm libm-test-ulps

4 years agoUpdate aarch64 libm-test-ulps
Adhemerval Zanella [Wed, 8 Apr 2020 11:50:15 +0000 (11:50 +0000)] 
Update aarch64 libm-test-ulps

4 years agoUpdates to the shn_MM locale [BZ #25532]
kokoye2007 [Tue, 11 Feb 2020 12:32:59 +0000 (13:32 +0100)] 
Updates to the shn_MM locale [BZ #25532]

4 years agopowerpc: Update ULPs and xfail more ibm128 outputs
Tulio Magno Quites Machado Filho [Tue, 7 Apr 2020 14:41:29 +0000 (11:41 -0300)] 
powerpc: Update ULPs and xfail more ibm128 outputs

There are 2 new input values that require to be marked as
xfail-rounding:ibm128-libgcc as they're known to fail because of libgcc
issues with different rounding modes.
Otherwise, the other tests just need an increase in ULP.

4 years agoi386: Remove build support for GCC older than GCC 6
H.J. Lu [Tue, 7 Apr 2020 13:44:37 +0000 (06:44 -0700)] 
i386: Remove build support for GCC older than GCC 6

Since GCC 6.2 or later is required to build glibc, remove build support
for GCC older than GCC 6.

Testd with GCC 6.4 and GCC 9.3.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agooc_FR locale: Fix spelling of April (bug 25639)
Rafał Lużyński [Mon, 6 Apr 2020 21:45:52 +0000 (23:45 +0200)] 
oc_FR locale: Fix spelling of April (bug 25639)

Confirmed by CLDR and a native speaker: "abril" is more often used even
if "abrial" is also correct.  Both nominative (alt_mon) and genitive (mon)
cases are updated.

4 years agoUpdate hppa libm-test-ulps
John David Anglin [Mon, 6 Apr 2020 22:19:03 +0000 (22:19 +0000)] 
Update hppa libm-test-ulps

4 years agoy2038: linux: Provide __mq_timedreceive_time64 implementation
Lukasz Majewski [Mon, 10 Feb 2020 16:36:33 +0000 (17:36 +0100)] 
y2038: linux: Provide __mq_timedreceive_time64 implementation

This patch provides new __mq_timedreceive_time64 explicit 64 bit function for
receiving messages with absolute timeout.
Moreover, a 32 bit version - __mq_timedreceive has been refactored to
internally use __mq_timedreceive_time64.

The __mq_timedreceive 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.

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

As this wrapper function is also used internally in the glibc, to e.g. provide
mq_receive implementation, an explicit check for abs_timeout being NULL has been
added due to conversions between struct timespec and struct __timespec64.
Before this change the Linux kernel handled this NULL pointer.

Build tests:
- ./src/scripts/build-many-glibcs.py glibcs

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

Linux kernel, headers and minimal kernel version for glibc build test matrix:
- Linux v5.1 (with mq_timedreceive_time64) and glibc built 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
  mq_timedreceive_time64 syscall.

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

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: linux: Provide __mq_timedsend_time64 implementation
Lukasz Majewski [Mon, 10 Feb 2020 09:55:24 +0000 (10:55 +0100)] 
y2038: linux: Provide __mq_timedsend_time64 implementation

This patch provides new __mq_timedsend_time64 explicit 64 bit function for
sending messages with absolute timeout.
Moreover, a 32 bit version - __mq_timedsend has been refactored to internally
use __mq_timedsend_time64.

The __mq_timedsend 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.

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

As this wrapper function is also used internally in the glibc, to e.g. provide
mq_send implementation, an explicit check for abs_timeout being NULL has been
added due to conversions between struct timespec and struct __timespec64.
Before this change the Linux kernel handled this NULL pointer.

Build tests:
- ./src/scripts/build-many-glibcs.py glibcs

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

Linux kernel, headers and minimal kernel version for glibc build test matrix:
- Linux v5.1 (with mq_timedsend_time64) and glibc built with v5.1 as a
  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
  mq_timedsend_time64 syscall.

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

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoy2038: include: Move struct __timespec64 definition to a separate file
Lukasz Majewski [Wed, 12 Feb 2020 09:42:49 +0000 (10:42 +0100)] 
y2038: include: Move struct __timespec64 definition to a separate file

The struct __timespec64's definition has been moved from ./include/time.h to
./include/struct___timespec64.h.

This change would prevent from polluting other glibc namespaces (when
headers are modified to support 64 bit time on architectures with
__WORDSIZE==32).

Now it is possible to just include definition of this particular structure
when needed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agomalloc: ensure set_max_fast never stores zero [BZ #25733]
DJ Delorie [Sat, 4 Apr 2020 05:44:56 +0000 (01:44 -0400)] 
malloc: ensure set_max_fast never stores zero [BZ #25733]

The code for set_max_fast() stores an "impossibly small value"
instead of zero, when the parameter is zero.  However, for
small values of the parameter (ex: 1 or 2) the computation
results in a zero being stored anyway.

This patch checks for the parameter being small enough for the
computation to result in zero instead, so that a zero is never
stored.

key values which result in zero being stored:

x86-64:  1..7  (or other 64-bit)
i686:    1..11
armhfp:  1..3  (or other 32-bit)

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agopowerpc64le: enforce non-specific long double in .gnu.attributes section
Paul E. Murphy [Fri, 6 Mar 2020 15:40:27 +0000 (09:40 -0600)] 
powerpc64le: enforce non-specific long double in .gnu.attributes section

We turn off this feature to avoid polluting our shared libary with
a specific value.  However, static libgcc is not under our control,
and has enabled this for ibm128 routines.  This pollutes the
resulting shared libraries with it.

Attach a post-linking hook to replace this section with one crafted
as hard-float + indeterminate ldbl.  This allows IEEE ldbl users to
avoid having to disable the gnu attributes feature which should
protect them from linking ibm ldbl libraries using the gnu attributes
feature.

Currently, this only replaces libc and libm which support both ldbl
formats and rely on application code to explicitly determine which
is to be used.

Strictly speaking, the section could be deleted with minimal lost value.
However correctly set attributes could prove useful for some future change,
and similarly missing attributes.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: workaround ieee long double / _Float128 stdc++ bug
Paul E. Murphy [Fri, 7 Feb 2020 20:08:20 +0000 (14:08 -0600)] 
powerpc64le: workaround ieee long double / _Float128 stdc++ bug

-mabi=ieeelongdouble triggers the stdc++ libraries _Float128
support, which then breaks if algorithm is included.  For now,
explicitly disable _Float128 for such tests.

I have opened up GCC BZ 94080 to track this.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le: Enforce -mabi=ibmlongdouble when -mfloat128 used
Paul E. Murphy [Fri, 7 Feb 2020 20:08:12 +0000 (14:08 -0600)] 
powerpc64le: Enforce -mabi=ibmlongdouble when -mfloat128 used

I have observed a bug on 7.4.0 whereby __mulkc3 calls are
swapped with __multc3 depending on ABI selection.  For the
sake of being overly cautious, build all _Float128 files
with ibm128 to workaround these compilers.  This has been
noted in GCC BZ 84914, and will not be fixed for GCC 7.

Likewise, non-math files built with _Float128 are assumed
to have ibm long double.  Explicilty preserve this
assumption.

Finally, add some bootstrapping code to avoid applying
these options until IEEE long double is enabled as they
require GCC 7 and above.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agopowerpc64le/multiarch: don't generate strong aliases for fmaf128-ppc64
Paul E. Murphy [Tue, 31 Mar 2020 21:19:00 +0000 (16:19 -0500)] 
powerpc64le/multiarch: don't generate strong aliases for fmaf128-ppc64

This prevents generating a second alias for __fmaieee128 when
compiling with ldouble == ieee128 redirects.

4 years agoldbl-128ibm: simplify iscanonical.h
Paul E. Murphy [Mon, 16 Mar 2020 15:49:04 +0000 (10:49 -0500)] 
ldbl-128ibm: simplify iscanonical.h

The test for enabling _Float128 or IEEE 128 long double can be
greatly simplified knowing that there is no ibm128, thus we require
no special cases, and everything is canonical.

This reverts the changes to ldbl-128ibm iscanonical.h from commit
8dbfea3a2094798a52cebddde01d255483f49665 and extends the check
for __NO_LONG_DOUBLE_MATH to include a check for float128 redirects
to long double.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
4 years agoi386: Disable check_consistency for GCC 5 and above [BZ #25788]
H.J. Lu [Mon, 6 Apr 2020 13:02:11 +0000 (06:02 -0700)] 
i386: Disable check_consistency for GCC 5 and above [BZ #25788]

check_consistency should be disabled for GCC 5 and above since there is
no fixed PIC register in GCC 5 and above.  Check __GNUC_PREREQ (5,0)
instead OPTIMIZE_FOR_GCC_5 since OPTIMIZE_FOR_GCC_5 is false with
-fno-omit-frame-pointer.

4 years agoAdd IPPROTO_ETHERNET and IPPROTO_MPTCP from Linux 5.6 to netinet/in.h.
Joseph Myers [Fri, 3 Apr 2020 18:08:28 +0000 (18:08 +0000)] 
Add IPPROTO_ETHERNET and IPPROTO_MPTCP from Linux 5.6 to netinet/in.h.

This patch adds the IPPROTO_ETHERNET and IPPROTO_MPTCP constants from
Linux 5.6 to glibc's netinet/in.h.

Tested for x86_64.

4 years agoUpdate syscall lists for Linux 5.6.
Joseph Myers [Fri, 3 Apr 2020 18:07:55 +0000 (18:07 +0000)] 
Update syscall lists for Linux 5.6.

Linux 5.6 has new openat2 and pidfd_getfd syscalls.  This patch adds
them to syscall-names.list and regenerates the arch-syscall.h files.

Tested with build-many-glibcs.py.

4 years agoelf: Implement DT_AUDIT, DT_DEPAUDIT support [BZ #24943]
Florian Weimer [Mon, 17 Feb 2020 15:49:40 +0000 (16:49 +0100)] 
elf: Implement DT_AUDIT, DT_DEPAUDIT support [BZ #24943]

binutils ld has supported --audit, --depaudit for a long time,
only support in glibc has been missing.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoelf: Simplify handling of lists of audit strings
Florian Weimer [Fri, 3 Apr 2020 11:17:48 +0000 (13:17 +0200)] 
elf: Simplify handling of lists of audit strings

All list elements are colon-separated strings, and there is a hard
upper limit for the number of audit modules, so it is possible to
pre-allocate a fixed-size array of strings to which the LD_AUDIT
environment variable and --audit arguments are added.

Also eliminate the global variables for the audit list because
the list is only needed briefly during startup.

There is a slight behavior change: All duplicate LD_AUDIT environment
variables are now processed, not just the last one as before.  However,
such environment vectors are invalid anyway.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agosupport: Change xgetline to return 0 on EOF
Florian Weimer [Thu, 2 Apr 2020 15:09:36 +0000 (17:09 +0200)] 
support: Change xgetline to return 0 on EOF

The advantage is that the buffer will always contain the number
of characters as returned from the function, which allows one to use
a sequence like

  /* No more audit module output.  */
  line_length = xgetline (&buffer, &buffer_length, fp);
  TEST_COMPARE_BLOB ("", 0, buffer, line_length);

to check for an expected EOF, while also reporting any unexpected
extra data encountered.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agonptl: Remove x86_64 cancellation assembly implementations [BZ #25765]
Adhemerval Zanella [Tue, 31 Mar 2020 17:59:28 +0000 (14:59 -0300)] 
nptl: Remove x86_64 cancellation assembly implementations [BZ #25765]

All cancellable syscalls are done by C implementations, so there is no
no need to use a specialized implementation to optimize register usage.

It fixes BZ #25765.

Checked on x86_64-linux-gnu.

4 years agoaarch64: update bits/hwcap.h
Szabolcs Nagy [Tue, 17 Mar 2020 15:53:34 +0000 (15:53 +0000)] 
aarch64: update bits/hwcap.h

Up to date with Linux 5.6. dl-procinfo.c is not updated because
HWCAP2 bits are not handled specially in glibc.

4 years agoAdd tests for Safe-Linking
Eyal Itkin [Thu, 2 Apr 2020 11:26:35 +0000 (07:26 -0400)] 
Add tests for Safe-Linking

Adding the test "tst-safe-linking" for testing that Safe-Linking works
as expected. The test checks these 3 main flows:
 * tcache protection
 * fastbin protection
 * malloc_consolidate() correctness

As there is a random chance of 1/16 that of the alignment will remain
correct, the test checks each flow up to 10 times, using different random
values for the pointer corruption. As a result, the chance for a false
failure of a given tested flow is 2**(-40), thus highly unlikely.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agoS390: Regenerate ULPs.
Stefan Liebler [Fri, 3 Apr 2020 07:38:02 +0000 (09:38 +0200)] 
S390: Regenerate ULPs.

Updates needed after recent commit
a9d42c09a327540a99f2eac25a98fd2ad6d0b540
math: Add inputs that yield larger errors for float type (x86_64)

4 years agosysv/alpha: Use generic __timeval32 and helpers
Alistair Francis [Tue, 11 Feb 2020 21:16:14 +0000 (13:16 -0800)] 
sysv/alpha: Use generic __timeval32 and helpers

Now there is a generic __timeval32 and helpers we can use them for Alpha
instead of the Alpha specific ones.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agolinux: Use long time_t for wait4/getrusage
Alistair Francis [Mon, 23 Dec 2019 21:26:50 +0000 (13:26 -0800)] 
linux: Use long time_t for wait4/getrusage

The Linux kernel expects rusage to use a 32-bit time_t, even on archs
with a 64-bit time_t (like RV32). To address this let's convert
rusage to/from 32-bit and 64-bit to ensure the kernel always gets
a 32-bit time_t.

While we are converting these functions let's also convert them to be
the y2038 safe versions. This means there is a *64 function that is
called by a backwards compatible wrapper.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoresource: Add a __rusage64 struct
Alistair Francis [Sun, 19 Jan 2020 22:57:37 +0000 (14:57 -0800)] 
resource: Add a __rusage64 struct

Add a __rusage64 struct which always uses a 64-bit time_t.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>