glibc.git
13 hours agohurd: Fix fexecve master
Samuel Thibault [Thu, 28 May 2020 23:28:07 +0000 (23:28 +0000)]
hurd: Fix fexecve

* sysdeps/mach/hurd/fexecve.c (fexecve): Re-lookup fd with O_EXEC before
calling _hurd_exec_paths.

25 hours agoi386: Remove unused file sysdeps/unix/i386/sysdep.S
Florian Weimer [Thu, 28 May 2020 08:50:24 +0000 (10:50 +0200)]
i386: Remove unused file sysdeps/unix/i386/sysdep.S

Linux overrides this file via sysdeps/unix/sysv/linux/i386/sysdep.c.
Hurd does not have sysdeps/unix/i386 on its search path, so it uses
csu/sysdep.c instead.

26 hours agohurd: fix ptsname error when called on a non-tty
Samuel Thibault [Thu, 28 May 2020 10:22:36 +0000 (10:22 +0000)]
hurd: fix ptsname error when called on a non-tty

* sysdeps/mach/hurd/ptsname.c (__ptsname_internal): Replace
not-supported errors from __term_get_peername with ENOTTY.

26 hours agohurd: Fix fdopendir checking for directory type
Samuel Thibault [Thu, 28 May 2020 10:13:14 +0000 (10:13 +0000)]
hurd: Fix fdopendir checking for directory type

* sysdeps/mach/hurd/fdopendir.c (__fdopendir): Lookup "./" instead of
"/" that would designate the root of the filesystem.

26 hours agoi386: Remove NO_TLS_DIRECT_SEG_REFS handling
Florian Weimer [Thu, 28 May 2020 08:51:15 +0000 (10:51 +0200)]
i386: Remove NO_TLS_DIRECT_SEG_REFS handling

This was needed for 32-bit PV Xen, which has been superseded by this
point according to Xen developers.

27 hours agoHurd: Move <hurd/sigpreempt.h> internals into wrapper header
Florian Weimer [Thu, 28 May 2020 09:19:04 +0000 (11:19 +0200)]
Hurd: Move <hurd/sigpreempt.h> internals into wrapper header

_hurdsig_preemptors and _hurdsig_preempted_set are not ABI symbols,
so do not declare them.  HURD_PREEMPT_SIGNAL_P is an implementation
detail, so move it as well.

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
27 hours agoHurd: Use __sigmask in favor of deprecated sigmask
Florian Weimer [Thu, 28 May 2020 09:17:51 +0000 (11:17 +0200)]
Hurd: Use __sigmask in favor of deprecated sigmask

This fixes various build errors due to deprecation warnings.

Fixes commit 02802fafcf6e11ea3f998f685035ffe568dfddeb
("signal: Deprecate additional legacy signal handling functions").

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
27 hours agohurd: Fix pselect atomicity
Samuel Thibault [Wed, 27 May 2020 23:42:24 +0000 (23:42 +0000)]
hurd: Fix pselect atomicity

In case the signal arrives before the __mach_msg call, we need to catch
between the sigprocmask call and the __mach_msg call.  Let's just reuse
the support for sigsuspend to make the signal send a message that
our __mach_msg call will just receive.

* hurd/hurdselect.c (_hurd_select): Add sigport and ss variables. When
sigmask is not NULL, create a sigport port and register as
ss->suspended.  Add it to the portset.  When we receive a message on it,
set error to EINTR.  Clean up sigport and portset appropriately.

* hurd/hurdsig.c (wake_sigsuspend): Note that pselect also uses it.

28 hours agoelf: Remove extra hwcap mechanism from ldconfig
Florian Weimer [Thu, 28 May 2020 08:21:17 +0000 (10:21 +0200)]
elf: Remove extra hwcap mechanism from ldconfig

Historically, this mechanism was used to process "nosegneg"
subdirectories, and it is still used to include the "tls"
subdirectories.  With nosegneg support gone from ld.so, this is part
no longer useful.

The entire mechanism is not well-designed because it causes the
meaning of hwcap bits in ld.so.cache to depend on the kernel version
that was used to generate the cache, which makes it difficult to use
this mechanism for anything else in the future.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
28 hours agoelf: Do not read hwcaps from the vDSO in ld.so
Florian Weimer [Thu, 28 May 2020 08:20:56 +0000 (10:20 +0200)]
elf: Do not read hwcaps from the vDSO in ld.so

This was only ever used for the "nosegneg" flag.  This approach for
passing hardware capability information creates a subtle dependency
between the kernel and userspace, and ld.so.cache contents.  It seems
inappropriate for toady, where people expect to be able to run
system images which very different kernel versions.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
45 hours agolinux: Use internal DIR locks when accessing filepos on telldir
Adhemerval Zanella [Tue, 14 Apr 2020 20:41:56 +0000 (17:41 -0300)]
linux: Use internal DIR locks when accessing filepos on telldir

Since it might change during a readdir call.

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

3 days agoUpdate i386 libm-test-ulps
Samuel Thibault [Tue, 26 May 2020 11:21:57 +0000 (13:21 +0200)]
Update i386 libm-test-ulps

3 days agohtl: Add clock variants
Samuel Thibault [Tue, 26 May 2020 00:09:11 +0000 (00:09 +0000)]
htl: Add clock variants

* htl/pt-join.c (__pthread_join): Move implementation to...
(__pthread_join_common): ... new function. Add try, timed and clock support.
(__pthread_join): Reimplement on top of __pthread_join_common.
(__pthread_tryjoin_np, __pthread_timedjoin_np, __pthread_clockjoin_np):
Implement on top of __pthread_join_common.
(pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np): New
aliases.

* hurd/hurdlock.c (__lll_abstimed_wait, __lll_abstimed_xwait,
__lll_abstimed_lock): Check for supported clock.

* sysdeps/htl/pt-cond-timedwait.c (__pthread_cond_timedwait_internal):
Add clockid parameter and support it.
(__pthread_cond_timedwait): Pass -1 as clockid.
(__pthread_cond_clockwait): New function.
(pthread_cond_clockwait): New alias.
* sysdeps/htl/pt-cond-wait.c (__pthread_cond_timedwait_internal): Update
prototype.
(__pthread_cond_wait): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedrdlock.c
(__pthread_rwlock_timedrdlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockrdlock): New function.
(pthread_rwlock_clockrdlock): New alias.
* sysdeps/htl/pt-rwlock-rdlock.c (__pthread_rwlock_timedrdlock_internal): Update
prototype.
(__pthread_rwlock_rdlock): Pass -1 as clockid.

* sysdeps/htl/pt-rwlock-timedwrlock.c
(__pthread_rwlock_timedwrlock_internal): Add clockid parameter, and
support id.
(__pthread_rwlock_clockwrlock): New function.
(pthread_rwlock_clockwrlock): New alias.
* sysdeps/htl/pt-rwlock-wrlock.c (__pthread_rwlock_timedwrlock_internal): Update
prototype.
(__pthread_rwlock_wrlock): Pass -1 as clockid.

* sysdeps/mach/hurd/htl/pt-mutex-timedlock.c (__pthread_mutex_timedlock): Move implementation to
(__pthread_mutex_clocklock): New function with additional clockid
parameter and support it.
(pthread_mutex_clocklock): New alias.
(__pthread_mutex_timedlock): Reimplement on top of __pthread_mutex_clocklock.

* sysdeps/htl/pthread.h (pthread_tryjoin_np, pthread_timedjoin_np,
pthread_clockjoin_np, pthread_mutex_clocklock, pthread_cond_clockwait,
pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock): New prototypes.
* sysdeps/htl/pthreadP.h (__pthread_cond_clockwait): New prototype.

* htl/Versions (GLIBC_2.32): Add pthread_cond_clockwait,
pthread_mutex_clocklock, pthread_rwlock_clockrdlock, pthread_rwlock_clockwrlock,
pthread_tryjoin_np, pthread_timedjoin_np, pthread_clockjoin_np.
* sysdeps/mach/hurd/i386/libpthread.abilist (pthread_clockjoin_np,
pthread_cond_clockwait, pthread_mutex_clocklock, pthread_rwlock_clockrdlock,
pthread_rwlock_clockwrlock, pthread_timedjoin_np, pthread_tryjoin_np):
New functions.

* nptl/tst-abstime.c, nptl/tst-join10.c, nptl/tst-join11.c, nptl/tst-join12.c,
nptl/tst-join13.c, nptl/tst-join14.c, nptl/tst-join2.c, nptl/tst-join3.c,
nptl/tst-join8.c, nptl/tst-join9.c, nptl/tst-mutex-errorcheck.c,
nptl/tst-pthread-mutexattr.c, nptl/tst-mutex11.c, nptl/tst-mutex5.c,
nptl/tst-mutex7.c, nptl/tst-mutex7robus.c, nptl/tst-mutex9.c,
nptl/tst-rwlock12.c, nptl/tst-rwlock14.c: Move to sysdeps/pthread.
* sysdeps/pthread/tst-mutex8.c: Move back to nptl.
* nptl/Makefile (tests): Move tst-mutex5, tst-mutex7, tst-mutex7robust,
tst-mutex9, tst-mutex11, tst-rwlock12, tst-rwlock14, tst-join2, tst-join3,
tst-join8, tst-join9 tst-join10, tst-join11, tst-join12, tst-join13, tst-join14,
tst-abstime, tst-mutex-errorcheck, tst-pthread-mutexattr to ...
* sysdeps/pthread/Makefile (tests): ... here.

3 days agosignal: Deprecate additional legacy signal handling functions
Florian Weimer [Mon, 25 May 2020 16:32:28 +0000 (18:32 +0200)]
signal: Deprecate additional legacy signal handling functions

This needs a few test adjustments: In some cases, sigignore was
used for convenience (replaced with xsignal with SIG_IGN).  Tests
for the deprecated functions need to disable
-Wdeprecated-declarations, and for the sigmask deprecation,
-Wno-error.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 days agoelf: Turn _dl_printf, _dl_error_printf, _dl_fatal_printf into functions
Florian Weimer [Mon, 25 May 2020 16:17:27 +0000 (18:17 +0200)]
elf: Turn _dl_printf, _dl_error_printf, _dl_fatal_printf into functions

This change makes it easier to set a breakpoint on these calls.

This also addresses the issue that including <ldsodefs.h> without
<unistd.h> does not result usable _dl_*printf macros because of the
use of the STD*_FILENO macros there.

(The private symbol for _dl_fatal_printf will go away again
once the exception handling implementation is unified between
libc and ld.so.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
7 days agox86: Update Intel Atom processor family optimization
H.J. Lu [Thu, 21 May 2020 20:36:54 +0000 (13:36 -0700)]
x86: Update Intel Atom processor family optimization

Enable Intel Silvermont optimization for Intel Goldmont Plus.  Detect more
Intel Airmont processors.  Optimize Intel Tremont like Intel Silvermont
with rep string instructions.

8 days agoelf.h: add aarch64 property definitions
Szabolcs Nagy [Wed, 1 Apr 2020 08:25:47 +0000 (09:25 +0100)]
elf.h: add aarch64 property definitions

These property values are specified by the AArch64 ELF ABI and
binutils can create binaries marked with them.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 days agoelf.h: Add PT_GNU_PROPERTY
Szabolcs Nagy [Thu, 26 Mar 2020 09:22:12 +0000 (09:22 +0000)]
elf.h: Add PT_GNU_PROPERTY

This program header type is already used in binaries on x86 and
aarch64 targets.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
8 days ago<libc-symbols.h>: Add libpthread hidden alias support
Florian Weimer [Fri, 15 May 2020 20:04:31 +0000 (22:04 +0200)]
<libc-symbols.h>: Add libpthread hidden alias support

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Use __pthread_attr_copy in pthread_setattr_default_np
Florian Weimer [Mon, 18 May 2020 16:11:48 +0000 (18:11 +0200)]
nptl: Use __pthread_attr_copy in pthread_setattr_default_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug 25999)
Florian Weimer [Fri, 15 May 2020 19:24:59 +0000 (21:24 +0200)]
nptl: Use __pthread_attr_copy in pthread_getattr_default_np (bug 25999)

pthread_getattr_default_np needs to make a deep copy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Add __pthread_attr_copy for copying pthread_attr_t objects
Florian Weimer [Tue, 19 May 2020 10:32:39 +0000 (12:32 +0200)]
nptl: Add __pthread_attr_copy for copying pthread_attr_t objects

Also add the private type union pthread_attr_transparent, to reduce
the amount of casting that is required.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Make __pthread_attr_init, __pthread_attr_destroy available internally
Florian Weimer [Fri, 15 May 2020 20:48:42 +0000 (22:48 +0200)]
nptl: Make __pthread_attr_init, __pthread_attr_destroy available internally

pthread_attr_destroy needs to be a weak alias to avoid future
linknamespace failures.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Move pthread_gettattr_np into libc
Florian Weimer [Fri, 15 May 2020 09:01:49 +0000 (11:01 +0200)]
nptl: Move pthread_gettattr_np into libc

This is part of the libpthread removal project:

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

Use __getline instead of __getdelim to avoid a localplt failure.
Likewise for __getrlimit/getrlimit.

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_getattr_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py --only-linux pthread_getattr_np

The private export of __pthread_getaffinity_np is no longer needed, but
the hidden alias still necessary so that the symbol can be exported with
versioned_symbol.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Move pthread_getaffinity_np into libc
Florian Weimer [Fri, 15 May 2020 09:09:05 +0000 (11:09 +0200)]
nptl: Move pthread_getaffinity_np into libc

This is part of the libpthread removal project:

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

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_getaffinity_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py pthread_getaffinity_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Move pthread_attr_setaffinity_np into libc
Florian Weimer [Fri, 15 May 2020 15:51:57 +0000 (17:51 +0200)]
nptl: Move pthread_attr_setaffinity_np into libc

This is part of the libpthread removal project:

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

The symbol did not previously exist in libc, so a new GLIBC_2.32
symbol is needed, to get correct dependency for binaries which
use the symbol but no longer link against libpthread.

The abilist updates were performed by:

git ls-files 'sysdeps/unix/sysv/linux/**/libc.abilist' \
  | while read x ; do
    echo "GLIBC_2.32 pthread_attr_setaffinity_np F" >> $x
done
python3 scripts/move-symbol-to-libc.py pthread_attr_setaffinity_np

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
8 days agonptl: Replace some stubs with the Linux implementation
Florian Weimer [Fri, 15 May 2020 09:26:37 +0000 (11:26 +0200)]
nptl: Replace some stubs with the Linux implementation

The stubs for pthread_getaffinity_np, pthread_getname_np,
pthread_setaffinity_np, pthread_setname_np are replaced, and corresponding
tests are moved.

After the removal of the NaCl port, nptl is Linux-specific, and the stubs
are no longer needed.  This effectively reverts commit
c76d1ff5149bd03210f2bb8cd64446c51618d016 ("NPTL: Add stubs for Linux-only
extension functions.").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
8 days agoLinux: Add missing handling of tai field to __ntp_gettime64
Florian Weimer [Wed, 20 May 2020 15:15:45 +0000 (17:15 +0200)]
Linux: Add missing handling of tai field to __ntp_gettime64

This fixes a build error:

../sysdeps/unix/sysv/linux/ntp_gettime.c: In function ‘__ntp_gettime’:
../sysdeps/unix/sysv/linux/ntp_gettime.c:56:10: error: ‘ntv64.tai’ is used uninitialized in this function [-Werror=uninitialized]
   56 |   *ntv = valid_ntptimeval64_to_ntptimeval (ntv64);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

8 days agoMention GCC 10 attribute access.
Martin Sebor [Wed, 20 May 2020 15:40:34 +0000 (09:40 -0600)]
Mention GCC 10 attribute access.

Reviewed-by: Paul Eggert <eggert@cs.ucla.edu>
8 days agoy2038: Replace __clock_gettime with __clock_gettime64
Lukasz Majewski [Mon, 16 Mar 2020 07:31:41 +0000 (08:31 +0100)]
y2038: Replace __clock_gettime with __clock_gettime64

The __clock_gettime internal function is not supporting 64 bit time on
architectures with __WORDSIZE == 32 and __TIMESIZE != 64 (like e.g. ARM 32
bit).

The __clock_gettime64 function shall be used instead in the glibc itself as
it supports 64 bit time on those systems.
This patch does not bring any changes to systems with __WORDSIZE == 64 as
for them the __clock_gettime64 is aliased to __clock_gettime (in
./include/time.h).

8 days agomanual: Add missing section and node for clockid_t wait functions
Florian Weimer [Mon, 18 May 2020 16:43:16 +0000 (18:43 +0200)]
manual: Add missing section and node for clockid_t wait functions

Without this, these functions appear under the node Default Thread
Attributes, which is confusing.

Eventually, the documentation should be merged with the (yet to be
documented) standardized functions.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
9 days agoy2038: linux: Provide __ntp_gettimex64 implementation
Lukasz Majewski [Wed, 22 Apr 2020 08:49:39 +0000 (10:49 +0200)]
y2038: linux: Provide __ntp_gettimex64 implementation

This patch provides new __ntp_gettimex64 explicit 64 bit function for getting
time parameters via NTP interface.

The call to __adjtimex in __ntp_gettime64 function has been replaced with
direct call to __clock_adjtime64 syscall, to simplify the code.

Moreover, a 32 bit version - __ntp_gettimex has been refactored to internally
use __ntp_gettimex64.

The __ntp_gettimex is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
ntptimeval and 64 bit struct __ntptimeval64.

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __ntp_gettimex64 and __ntp_gettimex.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoy2038: linux: Provide __ntp_gettime64 implementation
Lukasz Majewski [Wed, 22 Apr 2020 08:54:01 +0000 (10:54 +0200)]
y2038: linux: Provide __ntp_gettime64 implementation

This patch provides new __ntp_gettime64 explicit 64 bit function for getting
time parameters via NTP interface.

Internally, the __clock_adjtime64 syscall is used instead of __adjtimex. This
patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - __ntp_gettime has been refactored to internally
use __ntp_gettime64.

The __ntp_gettime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
ntptimeval and 64 bit struct __ntptimeval64.

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __ntp_gettime64 and __ntp_gettime.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoy2038: Provide conversion helpers for struct __ntptimeval64
Lukasz Majewski [Wed, 22 Apr 2020 22:20:51 +0000 (00:20 +0200)]
y2038: Provide conversion helpers for struct __ntptimeval64

Those functions allow easy conversion between Y2038 safe, glibc internal
struct __ntptimeval64 and struct ntptimeval.

The reserved fields (i.e. __glibc_reserved{1234}) during conversion are
zeroed as well, to provide behavior similar to one in ntp_gettimex function
(where those are cleared before the struct ntptimeval is returned).

Those functions are put in Linux specific sys/timex.h file, as putting
them into glibc's local include/time.h would cause build break on HURD as
it doesn't support struct timex related syscalls.

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoy2038: Introduce struct __ntptimeval64 - new internal glibc type
Lukasz Majewski [Tue, 21 Apr 2020 23:01:21 +0000 (01:01 +0200)]
y2038: Introduce struct __ntptimeval64 - new internal glibc type

This type is a glibc's "internal" type to get time parameters data from
Linux kernel (NTP daemon interface). It stores time in struct __timeval64
rather than struct timeval, which makes it Y2038-proof.

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoy2038: linux: Provide __adjtime64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 18:56:24 +0000 (20:56 +0200)]
y2038: linux: Provide __adjtime64 implementation

This patch provides new __adjtime64 explicit 64 bit function for adjusting
Linux kernel clock.

Internally, the __clock_adjtime64 syscall is used instead of __adjtimex. This
patch is necessary for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - __adjtime has been refactored to internally use
__adjtime64.

The __adjtime is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
timeval and 64 bit struct __timeval64.

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both __adjtime64 and __adjtime.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoy2038: linux: Provide ___adjtimex64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 17:29:31 +0000 (19:29 +0200)]
y2038: linux: Provide ___adjtimex64 implementation

This patch provides new ___adjtimex64 explicit 64 bit function for adjusting
Linux kernel clock.

Internally, the __clock_adjtime64 syscall is used. This patch is necessary
for having architectures with __WORDSIZE == 32 Y2038 safe.

Moreover, a 32 bit version - ___adjtimex has been refactored to internally
use ___adjtimex64.

The ___adjtimex is now supposed to be used on systems still supporting 32
bit time (__TIMESIZE != 64) - hence the necessary conversions between struct
timex and 64 bit struct __timex64.

Last but not least, in ___adjtimex64 function the __clock_adjtime syscall has
been replaced with __clock_adjtime64 to support 64 bit time on architectures
with __WORDSIZE == 32 and __TIMESIZE != 64.

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

Above tests were performed with Y2038 redirection applied as well as without to
test the proper usage of both ___adjtimex64 and ___adjtimex.

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
9 days agoy2038: linux: Provide __clock_adjtime64 implementation
Lukasz Majewski [Tue, 21 Apr 2020 17:14:18 +0000 (19:14 +0200)]
y2038: linux: Provide __clock_adjtime64 implementation

This patch replaces auto generated wrapper (as described in
sysdeps/unix/sysv/linux/syscalls.list) for clock_adjtime with one which adds
extra support for reading 64 bit time values on machines with __TIMESIZE != 64.

To achieve this goal new __clock_adjtime64 explicit 64 bit function for
adjusting Linux clock has been added.
Moreover, a 32 bit version - __clock_adjtime has been refactored to internally
use __clock_adjtime64.

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

The new __clock_adjtime64 syscall available from Linux 5.1+ has been used, when
applicable.
Up till v5.4 in the Linux kernel there was a bug preventing this call from
obtaining correct struct's timex time.tv_sec time after time_t overflow
(i.e. not being Y2038 safe).

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 clock_adjtime64) 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 clock_adjtime64
  syscall.

- Linux v4.19 (no clock_adjtime64 support) with default minimal kernel version
  for contemporary glibc (3.2.0)
  This kernel doesn't support clock_adjtime64 syscall, so the fallback to
  clock_adjtime 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>
10 days agoldconfig: Default to the new format for ld.so.cache
Josh Triplett [Tue, 19 May 2020 12:41:48 +0000 (14:41 +0200)]
ldconfig: Default to the new format for ld.so.cache

glibc has supported this format for close to 20 years.

10 days agonss_compat: internal_end*ent may clobber errno, hiding ERANGE [BZ #25976]
Florian Weimer [Tue, 19 May 2020 12:09:38 +0000 (14:09 +0200)]
nss_compat: internal_end*ent may clobber errno, hiding ERANGE [BZ #25976]

During cleanup, before returning from get*_r functions, the end*ent
calls must not change errno.  Otherwise, an ERANGE error from the
underlying implementation can be hidden, causing unexpected lookup
failures.  This commit introduces an internal_end*ent_noerror
function which saves and restore errno, and marks the original
internal_end*ent function as warn_unused_result, so that it is used
only in contexts were errors from it can be handled explicitly.

Reviewed-by: DJ Delorie <dj@redhat.com>
10 days agopowerpc: Optimized rawmemchr for POWER9
Anton Blanchard [Thu, 14 May 2020 11:49:16 +0000 (21:49 +1000)]
powerpc: Optimized rawmemchr for POWER9

This version uses vector instructions and is up to 60% faster on medium
matches and up to 90% faster on long matches, compared to the POWER7
version. A few examples:

                            __rawmemchr_power9  __rawmemchr_power7
Length   32, alignment  0:   2.27566             3.77765
Length   64, alignment  2:   2.46231             3.51064
Length 1024, alignment  0:  17.3059             32.6678

10 days agox86: Add --enable-cet=permissive
H.J. Lu [Mon, 27 Apr 2020 22:44:07 +0000 (15:44 -0700)]
x86: Add --enable-cet=permissive

When CET is enabled, it is an error to dlopen a non CET enabled shared
library in CET enabled application.  It may be desirable to make CET
permissive, that is disable CET when dlopening a non CET enabled shared
library.  With the new --enable-cet=permissive configure option, CET is
disabled when dlopening a non CET enabled shared library.

Add DEFAULT_DL_X86_CET_CONTROL to config.h.in:

 /* The default value of x86 CET control.  */
 #define DEFAULT_DL_X86_CET_CONTROL cet_elf_property

which enables CET features based on ELF property note.

--enable-cet=permissive it to

 /* The default value of x86 CET control.  */
 #define DEFAULT_DL_X86_CET_CONTROL cet_permissive

which enables CET features permissively.

Update tst-cet-legacy-5a, tst-cet-legacy-5b, tst-cet-legacy-6a and
tst-cet-legacy-6b to check --enable-cet and --enable-cet=permissive.

10 days agoRemove NO_CTORS_DTORS_SECTIONS macro
Florian Weimer [Mon, 18 May 2020 12:56:26 +0000 (14:56 +0200)]
Remove NO_CTORS_DTORS_SECTIONS macro

This was originally added to support binutils older than version
2.22:

  <https://sourceware.org/ml/libc-alpha/2010-12/msg00051.html>

Since 2.22 is older than the minimum required binutils version
for building glibc, we no longer need this.  (The changes do
not impact the statically linked startup code.)

10 days agoelf: Assert that objects are relocated before their constructors run
Florian Weimer [Mon, 18 May 2020 13:21:04 +0000 (15:21 +0200)]
elf: Assert that objects are relocated before their constructors run

If we try to run constructors before relocation, this is always
a dynamic linker bug.  An assert is easier to notice than a call
via an invalid function pointer (which may not even produce a valid
call stack).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
10 days agopowerpc: Optimized stpcpy for POWER9
Anton Blanchard via Libc-alpha [Wed, 13 May 2020 23:08:35 +0000 (09:08 +1000)]
powerpc: Optimized stpcpy for POWER9

Add stpcpy support to the POWER9 strcpy. This is up to 40% faster on
small strings and up to 90% faster on long relatively unaligned strings,
compared to the POWER8 version. A few examples:

                                        __stpcpy_power9  __stpcpy_power8
Length   20, alignments in bytes  4/ 4:  2.58246          4.8788
Length 1024, alignments in bytes  1/ 6: 24.8186          47.8528

10 days agopowerpc: Optimized strcpy for POWER9
Anton Blanchard via Libc-alpha [Wed, 13 May 2020 23:00:26 +0000 (09:00 +1000)]
powerpc: Optimized strcpy for POWER9

This version uses VSX store vector with length instructions and is
significantly faster on small strings and relatively unaligned large
strings, compared to the POWER8 version. A few examples:

                                        __strcpy_power9  __strcpy_power8
Length   16, alignments in bytes  0/ 0: 2.52454          4.62695
Length  412, alignments in bytes  4/ 0: 11.6             22.9185

10 days agox86: Move CET control to _dl_x86_feature_control [BZ #25887]
H.J. Lu [Tue, 28 Apr 2020 17:05:25 +0000 (10:05 -0700)]
x86: Move CET control to _dl_x86_feature_control [BZ #25887]

1. Include <dl-procruntime.c> to get architecture specific initializer in
rtld_global.
2. Change _dl_x86_feature_1[2] to _dl_x86_feature_1.
3. Add _dl_x86_feature_control after _dl_x86_feature_1, which is a
struct of 2 bitfields for IBT and SHSTK control

This fixes [BZ #25887].

12 days agosunrpc/tst-udp-*: Fix timeout value
Samuel Thibault [Sat, 16 May 2020 17:29:50 +0000 (19:29 +0200)]
sunrpc/tst-udp-*: Fix timeout value

Following on 00c3da43a ('sunrpc/tst-udp-timeout: Fix timeout value').

While e.g. 2.5 timeout can be represented exactly with doubles, time stamps
may not be represented that exactly, and thus with coarse-grain clocks (e.g.
10ms) we may end up with 2.499-ish values due to rounding errors.

* sunrpc/tst-udp-timeout.c (test_udp_server): Add more timeout slack.
* sunrpc/tst-udp-nonblocking.c (do_test): Likewise.

12 days agoLinux: Remove remnants of the getcpu cache
Florian Weimer [Fri, 15 May 2020 09:32:30 +0000 (11:32 +0200)]
Linux: Remove remnants of the getcpu cache

The getcpu cache was removed from the kernel in Linux 2.6.24.  glibc
support from the sched_getcpu implementation was removed in commit
dd26c44403582fdf10d663170f947dfe4b3207a0 ("Consolidate sched_getcpu").

13 days agoUpdate timezone code from tzcode 2020a
Paul Eggert [Fri, 15 May 2020 15:52:25 +0000 (08:52 -0700)]
Update timezone code from tzcode 2020a

This patch updates files coming from tzcode to tzcode 2020a.
This is mostly for better support for Internet RFC 8536, by adding
support to zic for the Expires line (new to tzcode 2020a), the -b
option (new to 2019b) and the -r option (new to 2019a).
One trivial change to other glibc was needed.
* time/tzfile.c (__tzfile_read): Adjust to tzcode private.h renaming.
* timezone/private.h, timezone/tzfile.h, timezone/version:
* timezone/zdump.c, timezone/zic.c: Update from tzcode 2020a.

2 weeks agoaarch64: fix strcpy and strnlen for big-endian [BZ #25824]
Lexi Shao [Fri, 15 May 2020 10:48:59 +0000 (18:48 +0800)]
aarch64: fix strcpy and strnlen for big-endian [BZ #25824]

This patch fixes the optimized implementation of strcpy and strnlen
on a big-endian arm64 machine.

The optimized method uses neon, which can process 128bit with one
instruction. On a big-endian machine, the bit order should be reversed
for the whole 128-bits double word. But with instuction
rev64 datav.16b, datav.16b
it reverses 64bits in the two halves rather than reversing 128bits.
There is no such instruction as rev128 to reverse the 128bits, but we
can fix this by loading the data registers accordingly.

Fixes 0237b61526e7("aarch64: Optimized implementation of strcpy") and
2911cb68ed3d("aarch64: Optimized implementation of strnlen").

Signed-off-by: Lexi Shao <shaolexi@huawei.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
2 weeks agolocale: Add transliteration for Geresh, Gershayim (U+05F3, U+05F4)
Florian Weimer [Fri, 15 May 2020 08:38:10 +0000 (10:38 +0200)]
locale: Add transliteration for Geresh, Gershayim (U+05F3, U+05F4)

ISO-8859-8-based locales will need this transliteration if the locale
files contain these Unicode characters.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agostring: Fix string/tst-memmove-overflow to compile with GCC 7
Florian Weimer [Thu, 14 May 2020 10:12:29 +0000 (12:12 +0200)]
string: Fix string/tst-memmove-overflow to compile with GCC 7

GCC 8 relaxed what kind of expressions can be used in initializers,
and the previous use of static const variables relied on that.  Switch
to wide (non-int) enum constants instead, which is another GCC
extension that is more widely implemented.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agoAdd arch-syscall.h dependency for generating sysd-syscalls file
guojinhui [Thu, 14 May 2020 16:09:46 +0000 (18:09 +0200)]
Add arch-syscall.h dependency for generating sysd-syscalls file

After using "make update-syscall-lists" to update arch-syscall.h for
new kernel versions, sysd-syscalls will not be not be regenerated.
This will cause a compile error because the new data is not being
picked up.

Fixes commit a1bd5f86739926469bbe0054b93305ff5905b070
("Linux: Use system call tables during build").

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agoarm: XFAIL string/tst-memmove-overflow due to bug 25620
Florian Weimer [Wed, 13 May 2020 14:45:29 +0000 (16:45 +0200)]
arm: XFAIL string/tst-memmove-overflow due to bug 25620

Also reduce the amount of output in case of a large-scale mismatch in
the copied data.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agoelf: Remove redundant add_to_global_resize_failure call from dl_open_args
Florian Weimer [Tue, 12 May 2020 17:06:18 +0000 (19:06 +0200)]
elf: Remove redundant add_to_global_resize_failure  call from dl_open_args

The second call does not do anything because the data structures have
already been resized by the call that comes before the demarcation
point.  Fixes commit a509eb117fac1d764b15eba64993f4bdb63d7f3c
("Avoid late dlopen failure due to scope, TLS slotinfo updates
[BZ #25112]").

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agostring: Add string/tst-memmove-overflow, a test case for bug 25620
Florian Weimer [Tue, 12 May 2020 17:02:08 +0000 (19:02 +0200)]
string: Add string/tst-memmove-overflow, a test case for bug 25620

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agosupport: Add support_blob_repeat_allocate_shared
Florian Weimer [Tue, 12 May 2020 17:01:49 +0000 (19:01 +0200)]
support: Add support_blob_repeat_allocate_shared

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2 weeks agonptl: wait for pending setxid request also in detached thread (bug 25942)
Andreas Schwab [Thu, 7 May 2020 13:50:09 +0000 (15:50 +0200)]
nptl: wait for pending setxid request also in detached thread (bug 25942)

There is a race between __nptl_setxid and exiting detached thread, which
causes a deadlock on stack_cache_lock.  The deadlock happens in this
state:

T1: setgroups -> __nptl_setxid (holding stack_cache_lock, waiting on cmdp->cntr == 0)
T2 (detached, exiting): start_thread -> __deallocate_stack (waiting on stack_cache_lock)
more threads waiting on stack_cache_lock in pthread_create

For non-detached threads, start_thread waits for its own setxid handler to
finish before exiting.  Do this for detached threads as well.

2 weeks agoaarch64: Accept PLT calls to __getauxval within libc.so
Florian Weimer [Tue, 12 May 2020 09:30:30 +0000 (11:30 +0200)]
aarch64: Accept PLT calls to __getauxval within libc.so

When using outline atomics (-moutline-atomics, the default for ARMv8-A
starting with GCC 10), libgcc contains an ELF constructor which calls
__getauxval.  This code is built outside of glibc, so none of its
internal PLT avoidance schemes can be applied to it.  This change
suppresses the elf/check-localplt failure.

2 weeks agoUse unsigned constants for ICMP6 filters [BZ #22489]
Sergey [Fri, 24 Apr 2020 21:18:41 +0000 (17:18 -0400)]
Use unsigned constants for ICMP6 filters [BZ #22489]

The core problem here is that the filter array elements are unsigned
but the computed constants are signed.  This both causes a
signededness conversion at the &= step and may cause undefined
behavior if the MSB is being modified.  This patch uses unsigned
constants to avoid both cases. - DJ

2 weeks agoLinux: Enhance glibcsyscalls.py to support listing system calls
Florian Weimer [Mon, 11 May 2020 20:23:34 +0000 (22:23 +0200)]
Linux: Enhance glibcsyscalls.py to support listing system calls

The script can now be called to query the definition status of
system call numbers across all architectures, like this:

$ python3 sysdeps/unix/sysv/linux/glibcsyscalls.py query-syscall sync_file_range sync_file_range2
sync_file_range:
  defined: aarch64 alpha csky hppa i386 ia64 m68k microblaze mips/mips32 mips/mips64/n32 mips/mips64/n64 nios2 riscv/rv64 s390/s390-32 s390/s390-64 sh sparc/sparc32 sparc/sparc64 x86_64/64 x86_64/x32
  undefined: arm powerpc/powerpc32 powerpc/powerpc64
sync_file_range2:
  defined: arm powerpc/powerpc32 powerpc/powerpc64
  undefined: aarch64 alpha csky hppa i386 ia64 m68k microblaze mips/mips32 mips/mips64/n32 mips/mips64/n64 nios2 riscv/rv64 s390/s390-32 s390/s390-64 sh sparc/sparc32 sparc/sparc64 x86_64/64 x86_64/x32

This command lists the headers containing the system call numbers:

$ python3 sysdeps/unix/sysv/linux/glibcsyscalls.py list-headers

The argument parser code is based on a suggestion from Adhemerval Zanella.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2 weeks agoSuppress GCC 10 true positive warnings [BZ #25967]
Martin Sebor [Mon, 11 May 2020 17:29:39 +0000 (11:29 -0600)]
Suppress GCC 10 true positive warnings [BZ #25967]

Suppress or avoid warnings in tests that exercise failure modes by making
calls with invalid arguments.

Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
2 weeks agoPOWER: Add context-synchronizing instructions to pkey_write [BZ #25954]
Florian Weimer [Mon, 11 May 2020 09:20:02 +0000 (11:20 +0200)]
POWER: Add context-synchronizing instructions to pkey_write [BZ #25954]

Sandipan Das reported that,

"The Power ISA mandates that all writes to the Authority
Mask Register (AMR) must always be preceded as well as
succeeded by a context-synchronizing instruction. This
applies to both the privileged and unprivileged variants
of the Move To AMR instruction.

This [requirement] is from Table 6 of Chapter 11 in page 1134 of Power
ISA 3.0B. The document can be found here:
<https://ibm.ent.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv>
"

See this kernel patch submission:

<https://lore.kernel.org/linuxppc-dev/5f65cf37be993760de8112a88da194e3ccbb2bf8.1588959697.git.sandipan@linux.ibm.com/>

2 weeks agohurd: Add missing sigstate members initialization
Samuel Thibault [Sun, 10 May 2020 23:30:29 +0000 (01:30 +0200)]
hurd: Add missing sigstate members initialization

* hurd/hurdsig.c (_hurd_thread_sigstate): Initialize
  critical_section_lock, active_resources, cancel, and cancel_hook fields.

2 weeks agox86-64: Use RDX_LP on __x86_shared_non_temporal_threshold [BZ #25966]
H.J. Lu [Sat, 9 May 2020 19:04:23 +0000 (12:04 -0700)]
x86-64: Use RDX_LP on __x86_shared_non_temporal_threshold [BZ #25966]

Since __x86_shared_non_temporal_threshold is defined as

long int __x86_shared_non_temporal_threshold;

and long int is 4 bytes for x32, use RDX_LP to compare against
__x86_shared_non_temporal_threshold in assembly code.

2 weeks agolinux: Remove assembly umount2 implementation
Adhemerval Zanella [Fri, 8 May 2020 12:30:18 +0000 (09:30 -0300)]
linux: Remove assembly umount2 implementation

Only alpha and ia64 do not support __NR_umount2 (defined as
__NR_umount), but recent kernel fixes (74cd2184833f for ia64, and
12b57c5c70f39 for alpha) add the required alias.

Checked with a build against all affected ABIs.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2 weeks agosignal: Use <sigsetops.h> for sigemptyset, sigfillset
Florian Weimer [Fri, 8 May 2020 15:29:10 +0000 (17:29 +0200)]
signal: Use <sigsetops.h> for sigemptyset, sigfillset

This avoids changing the entire sigset_t structure.  Updating the
actually used part is sufficient.

3 weeks agockb_IQ, or_IN locales: Add missing reorder-end keywords
Florian Weimer [Fri, 8 May 2020 08:51:32 +0000 (10:51 +0200)]
ckb_IQ, or_IN locales: Add missing reorder-end keywords

This suppresses a non-fatal error during locale building.

Reviewed-by: Rafał Lużyński <digitalfreak@lingonborough.com>
3 weeks agosemaphore: consolidate arch headers into a generic one
Vineet Gupta [Tue, 5 May 2020 19:53:41 +0000 (12:53 -0700)]
semaphore: consolidate arch headers into a generic one

This consolidates the copy-pasted arch specific semaphore header into
single version (based on s390) which suffices 32-bit and and 64-bit
arch/ABI based on the canonical WORDSIZE.

For now I've left out arches which use alternate defines to choose for
32 vs 64-bit builds (aarch64, mips) which in theory can also use the same
header.

Passes build-many for
  aarch64-linux-gnu arm-linux-gnueabi arm-linux-gnueabihf
  riscv64-linux-gnu-rv64imac-lp64 riscv64-linux-gnu-rv64imafdc-lp64
  x86_64-linux-gnu microblaze-linux-gnu nios2-linux-gnu

Suggested-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoUse GCC 10 branch in build-many-glibcs.py.
Joseph Myers [Wed, 6 May 2020 15:41:55 +0000 (15:41 +0000)]
Use GCC 10 branch in build-many-glibcs.py.

This updates the default GCC version used in build-many-glibcs.py when
no version is specified explicitly.  I'm replacing my bot using GCC 8
with one using GCC 10 (leaving the GCC 9 and GCC mainline bots running
as at present).

3 weeks agoDocument the internal _ and N_ macros
Florian Weimer [Wed, 6 May 2020 15:35:21 +0000 (17:35 +0200)]
Document the internal _ and N_ macros

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 weeks agoy2038: Provide conversion helpers for struct __timex64
Lukasz Majewski [Tue, 21 Apr 2020 17:12:17 +0000 (19:12 +0200)]
y2038: Provide conversion helpers for struct __timex64

Those functions allow easy conversion between Y2038 safe, glibc internal
struct __timex64 and struct timex.

Those functions are put in Linux specific sys/timex.h file, as putting
them into glibc's local include/time.h would cause build break on HURD as
it doesn't support struct timex related syscalls.

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoy2038: Introduce struct __timex64 - new internal glibc type
Lukasz Majewski [Tue, 21 Apr 2020 17:08:33 +0000 (19:08 +0200)]
y2038: Introduce struct __timex64 - new internal glibc type

The introduced glibc's 'internal' struct __timex64 is a copy of Linux kernel's
struct __kernel_timex (v5.6) introduced for properly handling data for
clock_adjtime64 syscall.
As the struct's __kernel_timex size is the same as for archs with
__WORDSIZE == 64, proper padding and data types conversion (i.e. long to long
long) had to be added for architectures with __WORDSIZE == 32 &&
__TIMESIZE != 64.

Moreover, it stores time in struct __timeval64 rather than struct
timeval, which makes it Y2038-proof.

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoy2038: include: Move struct __timeval64 definition to a separate file
Lukasz Majewski [Tue, 21 Apr 2020 17:01:56 +0000 (19:01 +0200)]
y2038: include: Move struct __timeval64 definition to a separate file

The struct __timeval64's definition has been moved from ./include/time.h to
./include/struct___timeval64.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: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoy2038: nscd: Modify nscd_helper to use __clock_gettime64
Lukasz Majewski [Mon, 16 Mar 2020 12:50:23 +0000 (13:50 +0100)]
y2038: nscd: Modify nscd_helper to use __clock_gettime64

The nscd/nscd_helper.c uses __clock_gettime to get current time and on this
basis calculate the relative timeout for poll.
By using __clock_gettime64 on systems with __WORDSIZE == 32 && __TIMESIZE != 64
the timeout is correctly calculated after time_t overflow.

3 weeks agoy2038: inet: Convert inet deadline to support 64 bit time
Lukasz Majewski [Mon, 16 Mar 2020 09:09:13 +0000 (10:09 +0100)]
y2038: inet: Convert inet deadline to support 64 bit time

This change brings 64 bit time support to inet deadline related code for
architectures with __WORDSIZE == 32 && __TIMESIZE != 64.

It is also safe to replace struct timespec with struct __timespec64 in
deadline related structures as:

- The __deadline_to_ms () returns the number of miliseconds to deadline to
  be used with __poll (and hence it is a relative value).
- To calculate the deadline from timeval (which will be converted latter)
  the uintmax_t type is used (unsinged long long int).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 weeks agoy2038: hurd: Provide __clock_gettime64 function
Lukasz Majewski [Thu, 16 Jan 2020 13:27:27 +0000 (14:27 +0100)]
y2038: hurd: Provide __clock_gettime64 function

For Linux glibc ports the __TIMESIZE == 64 ensures proper aliasing for
__clock_gettime64 (to __clock_gettime).
When __TIMESIZE != 64 (like ARM32, PPC) the glibc expects separate definition
of the __clock_gettime64.

The HURD port only provides __clock_gettime, so this patch adds
__clock_gettime64 as a tiny wrapper on it.
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
3 weeks 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.

3 weeks 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

3 weeks 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>
3 weeks 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.

3 weeks 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>
3 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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 weeks 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.