platform/upstream/glibc.git
3 years ago<nss_action.h>: New abstraction for combining NSS modules and NSS actions
Florian Weimer [Thu, 20 Feb 2020 08:32:27 +0000 (09:32 +0100)]
<nss_action.h>: New abstraction for combining NSS modules and NSS actions

nss_action manages a set of lists of actions; these are the portions
of the lines in nsswitch.conf to the right of the colons, like
"dns [!UNAVAIL=return] files".  Each permutation of actions and
conditionals is cached for reuse, which limits memory growth, and
refers to the static list of modules managed by nss_modules.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonss: Introduce <nss_module.h>
Florian Weimer [Wed, 19 Feb 2020 19:55:48 +0000 (20:55 +0100)]
nss: Introduce <nss_module.h>

This provides the struct nss_module type, which combines the old
struct service_library type with the known_function tree, by
statically allocating space for all function pointers.

struct nss_module is fairly large (536 bytes), but it will be
shared across NSS databases.  The old known_function handling
had non-some per-function overhead (at least 32 bytes per looked-up
function, but more for long function anmes), so overall, this is not
too bad.  Resolving all functions at load time simplifies locking,
and the repeated lookups should be fast because the caches are hot
at this point.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoAdd scripts/move-symbol-to-libc.py
Florian Weimer [Fri, 4 Dec 2020 18:32:56 +0000 (19:32 +0100)]
Add scripts/move-symbol-to-libc.py

This helper script can be used to move symbols to libc.abilist across
all architectures, while preserving their symbol version.

3 years agopowerpc64le: Add glibc-hwcaps support
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
powerpc64le: Add glibc-hwcaps support

The "power10" and "power9" subdirectories are selected in a way
that matches the -mcpu=power10 and -mcpu=power9 options of GCC.

3 years agox86: Adjust tst-cpu-features-supports.c for GCC 11
H.J. Lu [Thu, 3 Dec 2020 23:02:44 +0000 (15:02 -0800)]
x86: Adjust tst-cpu-features-supports.c for GCC 11

Check HAS_CPU_FEATURE instead of CPU_FEATURE_USABLE for FSGSBASE, IBT,
LM, SHSTK and XSAVES since FSGSBASE requires kernel support, IBT/SHSTK/LM
require OS support and XSAVES is supervisor-mode only.

3 years agox86: Set RDRAND usable if CPU supports RDRAND
H.J. Lu [Thu, 3 Dec 2020 23:02:44 +0000 (15:02 -0800)]
x86: Set RDRAND usable if CPU supports RDRAND

Set RDRAND usable if CPU supports RDRAND.

3 years agoelf: Add missing <stddef.h> header to elf/dl-hwcaps.h
Matheus Castanho [Fri, 4 Dec 2020 12:48:56 +0000 (09:48 -0300)]
elf: Add missing <stddef.h> header to elf/dl-hwcaps.h

The lack of this header makes size_t unavailable on builds configured
with --disable-tunables, causing compilation errors.

3 years agolowlevellock-futex: Remove not used macros
Lukasz Majewski [Tue, 1 Dec 2020 11:26:55 +0000 (12:26 +0100)]
lowlevellock-futex: Remove not used macros

Following macros: lll_futex_timed_lock_pi, lll_futex_clock_wait_bitset,
lll_futex_wait_requeue_pi, lll_futex_timed_wait_requeue_pi are not
used anymore so are eligible for removal.

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agofutex: Remove not used futex_reltimed_wait{_cancelable}
Lukasz Majewski [Tue, 1 Dec 2020 10:25:11 +0000 (11:25 +0100)]
futex: Remove not used futex_reltimed_wait{_cancelable}

After gai_suspend and aio_suspend conversion to support 64 bit time and
hence rewriting the code to use only absolute variants of futex wait
functions (i.e. __futex_abstimed_wait64 and __futex_abstimed_wait_cancelable64)
futex_reltimed_wait{_cancelable} are not needed anymore and can be removed.

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoy2038: Convert gai_suspend to support 64 bit time
Lukasz Majewski [Mon, 30 Nov 2020 13:33:12 +0000 (14:33 +0100)]
y2038: Convert gai_suspend to support 64 bit time

This change uses (in gai_misc.h):
- __futex_abstimed_wait64 (instead of futex_reltimed_wait)
- __futex_abstimed_wait_cancellable64
     (instead of futex_reltimed_wait_cancellable)
        from ./sysdeps/nptl/futex-helpers.h

The gai_suspend() accepts relative timeout, which then is converted to
absolute one.

The i686-gnu port (HURD) do not define DONT_NEED_GAI_MISC_COND and as it
doesn't (yet) support 64 bit time it uses not converted
pthread_cond_timedwait().

The __gai_suspend() is supposed to be run on ports with __TIMESIZE !=64 and
__WORDSIZE==32. It internally utilizes __gai_suspend_time64() and hence the
conversion from 32 bit struct timespec to 64 bit one is required.

For ports supporting 64 bit time the __gai_suspend_time64() will be used
either via alias (to __gai_suspend when __TIMESIZE==64) or redirection
(when -D_TIME_BITS=64 is passed).

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

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agosymbols: Add defines for libanl's libanl_hidden_{def|proto}
Lukasz Majewski [Mon, 30 Nov 2020 16:57:56 +0000 (17:57 +0100)]
symbols: Add defines for libanl's libanl_hidden_{def|proto}

The __gai_suspend_time64, which supports 64 bit time on ports with
__WORDSIZE == 32 && __TIMESIZE != 64, shall be exported from libanl
(the same library from which original gai_suspend is exported).

Up till now there were no defines for this library. This commit adds
them.

3 years agox86_64: Add glibc-hwcaps support
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
x86_64: Add glibc-hwcaps support

The subdirectories match those in the x86-64 psABI:

https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/77566eb03bc6a326811cb7e9a6b9396884b67c7c

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add glibc-hwcaps subdirectory support to ld.so cache processing
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
elf: Add glibc-hwcaps subdirectory support to ld.so cache processing

This recognizes the DL_CACHE_HWCAP_EXTENSION flag in cache entries,
and picks the supported cache entry with the highest priority.

The elf/tst-glibc-hwcaps-prepend-cache test documents a non-desired
aspect of the current cache implementation: If the cache selects a DSO
that does not exist on disk, _dl_map_object falls back to open_path,
which may or may not find an alternative implementation.  This is an
existing limitation that also applies to the legacy hwcaps processing
for ld.so.cache.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Process glibc-hwcaps subdirectories in ldconfig
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
elf: Process glibc-hwcaps subdirectories in ldconfig

Libraries from these subdirectories are added to the cache
with a special hwcap bit DL_CACHE_HWCAP_EXTENSION, so that
they are ignored by older dynamic loaders.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Implement tail merging of strings in ldconfig
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
elf: Implement tail merging of strings in ldconfig

This simplifies the string table construction in elf/cache.c
because there is no more need to keep track of offsets explicitly;
the string table implementation does this internally.

This change slightly reduces the size of the cache on disk.  The
file format does not change as a result.  The strings are
null-terminated, without explicit length, so tail merging is
transparent to readers.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Implement a string table for ldconfig, with tail merging
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
elf: Implement a string table for ldconfig, with tail merging

This will be used in ldconfig to reduce the ld.so.cache size slightly.

Tail merging is an optimization where a pointer points into another
string if the first string is a suffix of the second string.

The hash function FNV-1a was chosen because it is simple and achieves
good dispersion even for short strings (so that the hash table bucket
count can be a power of two).  It is clearly superior to the hsearch
hash and the ELF hash in this regard.

The hash table uses chaining for collision resolution.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add extension mechanism to ld.so.cache
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
elf: Add extension mechanism to ld.so.cache

A previously unused new-format header field is used to record
the address of an extension directory.

This change adds a demo extension which records the version of
ldconfig which builds a file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add endianness markup to ld.so.cache (bug 27008)
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
elf: Add endianness markup to ld.so.cache (bug 27008)

Use a reserved byte in the new format cache header to indicate whether
the file is in little endian or big endian format.  Eventually, this
information could be used to provide a unified cache for qemu-user
and similiar scenarios.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Add glibc-hwcaps support for LD_LIBRARY_PATH
Florian Weimer [Fri, 4 Dec 2020 08:13:43 +0000 (09:13 +0100)]
elf: Add glibc-hwcaps support for LD_LIBRARY_PATH

This hacks non-power-set processing into _dl_important_hwcaps.
Once the legacy hwcaps handling goes away, the subdirectory
handling needs to be reworked, but it is premature to do this
while both approaches are still supported.

ld.so supports two new arguments, --glibc-hwcaps-prepend and
--glibc-hwcaps-mask.  Each accepts a colon-separated list of
glibc-hwcaps subdirectory names.  The prepend option adds additional
subdirectories that are searched first, in the specified order.  The
mask option restricts the automatically selected subdirectories to
those listed in the option argument.  For example, on systems where
/usr/lib64 is on the library search path,
--glibc-hwcaps-prepend=valgrind:debug causes the dynamic loader to
search the directories /usr/lib64/glibc-hwcaps/valgrind and
/usr/lib64/glibc-hwcaps/debug just before /usr/lib64 is searched.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Synchronize <elf.h> section header flags with binutils
Florian Weimer [Thu, 3 Dec 2020 13:10:21 +0000 (14:10 +0100)]
elf: Synchronize <elf.h> section header flags with binutils

binutils 2.36 will add SHF_GNU_RETAIN support.  SHF_GNU_BUILD_NOTE
was also missing from the glibc header.

3 years agox86: Fix THREAD_SELF definition to avoid ld.so crash (bug 27004)
Jakub Jelinek [Thu, 3 Dec 2020 12:33:44 +0000 (13:33 +0100)]
x86: Fix THREAD_SELF definition to avoid ld.so crash (bug 27004)

The previous definition of THREAD_SELF did not tell the compiler
that %fs (or %gs) usage is invalid for the !DL_LOOKUP_GSCOPE_LOCK
case in _dl_lookup_symbol_x.  As a result, ld.so could try to use the
TCB before it was initialized.

As the comment in tls.h explains, asm volatile is undesirable here.
Using the __seg_fs (or __seg_gs) namespace does not interfere with
optimization, and expresses that THREAD_SELF is potentially trapping.

3 years agohtl: Add hidden def for __pthread_create/detach
Samuel Thibault [Thu, 3 Dec 2020 11:21:47 +0000 (12:21 +0100)]
htl: Add hidden def for __pthread_create/detach

to avoid a PLT.

3 years agomanual: Clarify File Access Modes section and add O_PATH
Florian Weimer [Thu, 3 Dec 2020 09:59:50 +0000 (10:59 +0100)]
manual: Clarify File Access Modes section and add O_PATH

Kees Cook reported that the current text is misleading:

  <https://lore.kernel.org/lkml/202005150847.2B1ED8F81@keescook/>

3 years agohtl: Add missing symbols
Samuel Thibault [Thu, 3 Dec 2020 09:48:27 +0000 (10:48 +0100)]
htl: Add missing symbols

hurd/hurdsig.c needs to detect whether __pthread_detach and
__pthread_create are available, so they need to be exposed.

3 years agoRevert "linux: Move xmknod{at} to compat symbols"
Adhemerval Zanella [Thu, 22 Oct 2020 18:24:12 +0000 (15:24 -0300)]
Revert "linux: Move xmknod{at} to compat symbols"

This reverts commit 81b83ff61f95f30ad53d6075247af0ea61a0b16e to move
__xmknod{at} back to default symbols.  ABIs with default symbol version
of 2.33 or newer (such as riscv32) continue to just provide the mknod*
symbols.

The idea is to not force static libraries built against old glibc
to update against new glibcs (since they reference the the
xmknod{at} symbols).

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

3 years agoRevert "linux: Move {f}xstat{at} to compat symbols"
Adhemerval Zanella [Wed, 2 Dec 2020 16:51:57 +0000 (13:51 -0300)]
Revert "linux: Move {f}xstat{at} to compat symbols"

This reverts commit 20b39d59467b0c1d858e89ded8b0cebe55e22f60 to move
{f}xstat{at} back to default symbols.  ABIs with default symbol version
of 2.33 or newer (such as riscv32) continue to just provide the stat
symbols.

The idea is to not force static libraries built against old glibc
to update against new glibcs (since they reference the old
{f}xstat{at} symbols).

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

3 years agoelf.h: Fix spelling of EM_TILE64 comment
Florian Weimer [Wed, 2 Dec 2020 12:52:54 +0000 (13:52 +0100)]
elf.h: Fix spelling of EM_TILE64 comment

Reported-By: Jakub Jelinek <jakub@redhat.com>
3 years agonptl: Fix __futex_clocklock64 return error check [BZ #26964]
Lucas A. M. Magalhaes [Tue, 1 Dec 2020 21:05:07 +0000 (18:05 -0300)]
nptl: Fix __futex_clocklock64 return error check [BZ #26964]

The earlier implementation of this, __lll_clocklock, calls lll_clockwait
that doesn't return the futex syscall error codes.  It always tries again
if that fails.

However in the current implementation, when the futex returns EAGAIN,
__futex_clocklock64 will also return EGAIN, even if the futex is taken.

This patch fixes the EAGAIN issue and also adds a check for EINTR.  As
futex syscall can return EINTR if the thread is interrupted by a signal.
In this case I'm assuming the function should continue trying to lock as
there is no mention to about it on POSIX.  Also add a test for both
scenarios.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agopowerpc64le: ifunc select *f128 routines in multiarch mode
Paul E. Murphy [Tue, 7 Apr 2020 21:20:55 +0000 (16:20 -0500)]
powerpc64le: ifunc select *f128 routines in multiarch mode

Programatically generate simple wrappers for interesting libm *f128
objects.  Selected functions are transcendental functions or
those with trivial compiler builtins.  This can result in a 2-3x
speedup (e.g logf128 and expf128).

A second set of implementation files are generated which include
the first implementation encountered along the search path.  This
usually works, except when a wrapper is overriden and makefile
search order slightly diverges from include order.  Likewise,
wrapper object files are created for each generated file.  These
hold the ifunc selection routines which export ABI.

Next, several shared headers are intercepted to control renaming of
asm function redirects are used first, and sometimes macro renames
if the former is impractical.

Notably, if the request machine supports hardware IEEE128 (i.e POWER9
and newer) this ifunc machinery is disabled.  Likewise existing
ifunc support for float128 is consolidated into this (e.g sqrtf128
and fmaf128).

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agoy2038: Convert aio_suspend to support 64 bit time
Lukasz Majewski [Mon, 23 Nov 2020 20:47:20 +0000 (17:47 -0300)]
y2038: Convert aio_suspend to support 64 bit time

The aio_suspend function has been converted to support 64 bit time.

This change uses (in aio_misc.h):
- __futex_abstimed_wait64 (instead of futex_reltimed_wait)
- __futex_abstimed_wait_cancellable64
(instead of futex_reltimed_wait_cancellable)
    from ./sysdeps/nptl/futex-helpers.h

The aio_suspend() accepts relative timeout, which then is converted to
absolute one.

The i686-gnu port (HURD) do not define DONT_NEED_AIO_MISC_COND and as it
doesn't (yet) support 64 bit time it uses not converted
pthread_cond_timedwait().

The __aio_suspend() is supposed to be run on ports with __TIMESIZE !=64 and
__WORDSIZE==32. It internally utilizes __aio_suspend_time64() and hence the
conversion from 32 bit struct timespec to 64 bit one is required.

For ports supporting 64 bit time the __aio_suspend_time64() will be used
either via alias (to __aio_suspend when __TIMESIZE==64) or redirection
(when -D_TIME_BITS=64 is passed).

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 years agoFix typo in NEWS file
Shuo Wang [Mon, 2 Nov 2020 07:53:13 +0000 (15:53 +0800)]
Fix typo in NEWS file

3 years agonptl: Add EOVERFLOW checks for futex calls
Adhemerval Zanella [Thu, 26 Nov 2020 13:54:04 +0000 (10:54 -0300)]
nptl: Add EOVERFLOW checks for futex calls

Some futex-internal calls require additional check for EOVERFLOW (as
indicated by [1] [2] [3]).  For both mutex and rwlock code, EOVERFLOW is
handle as ETIMEDOUT; since it indicate to the caller that the blocking
operation could not be issued.

For mutex it avoids a possible issue where PTHREAD_MUTEX_ROBUST_* might
assume EOVERFLOW indicate futex has succeed, and for PTHREAD_MUTEX_PP_*
it avoid a potential busy infinite loop.  For rwlock and semaphores, it
also avoids potential busy infinite loops.

Checked on x86_64-linux-gnu and i686-linux-gnu, although EOVERFLOW
won't be possible with current usage (since all timeouts on 32-bit
architectures with 32-bit time_t support will be in the range of
32-bit time_t).

[1] https://sourceware.org/pipermail/libc-alpha/2020-November/120079.html
[2] https://sourceware.org/pipermail/libc-alpha/2020-November/120080.html
[3] https://sourceware.org/pipermail/libc-alpha/2020-November/120127.html

3 years agonptl: Fix PTHREAD_PRIO_PROTECT timed lock
Adhemerval Zanella [Wed, 25 Nov 2020 20:15:51 +0000 (17:15 -0300)]
nptl: Fix PTHREAD_PRIO_PROTECT timed lock

The 878fe624d4 changed lll_futex_timed_wait, which expects a relative
timeout, with a __futex_abstimed_wait64, which expects an absolute
timeout.  However the code still passes a relative timeout.

Also, the PTHREAD_PRIO_PROTECT support for clocks different than
CLOCK_REALTIME was broken since the inclusion of
pthread_mutex_clocklock (9d20e22e46) since lll_futex_timed_wait
always use CLOCK_REALTIME.

This patch fixes by removing the relative time calculation.  It
also adds some xtests that tests both thread and inter-process
usage.

Checked on x86_64-linux-gnu.

3 years agosh: Add sh4 fpu Implies folder
Adhemerval Zanella [Wed, 25 Nov 2020 18:00:44 +0000 (15:00 -0300)]
sh: Add sh4 fpu Implies folder

The commit 605f38177db (sh: Split BE/LE abilist) did not take in
consideration the SH4 fpu support.

Checked with a build for sh4-linux-gnu and manually checked that
the implementations at sysdeps/sh/sh4/fpu/ are selected.

John Paul Adrian Glaubitz also confirmed it fixes the build issues
he encontered.

3 years agoio: nftw/ftw: Fix stack overflow with large nopenfd [BZ #26353]
Xiaoming Ni [Thu, 26 Nov 2020 16:35:10 +0000 (13:35 -0300)]
io: nftw/ftw: Fix stack overflow with large nopenfd [BZ #26353]

The nopenfd value is used as argument for the internal buffer on
ftw_statup, which is allocated with alloca and might trigger
a stack overflow for large values.  This patch replaces the memory
allocation to use malloc instead.

Checked on x86_64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Introduce enum opt_format in the ldconfig implementation
Florian Weimer [Thu, 26 Nov 2020 15:59:44 +0000 (16:59 +0100)]
elf: Introduce enum opt_format in the ldconfig implementation

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agosupport: Add support_copy_file
Florian Weimer [Thu, 26 Nov 2020 15:59:44 +0000 (16:59 +0100)]
support: Add support_copy_file

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoNEWS entry for commit b4f020c9b408fb3d1d3d4901c4a71839145f8791
Florian Weimer [Wed, 25 Nov 2020 14:51:51 +0000 (15:51 +0100)]
NEWS entry for commit b4f020c9b408fb3d1d3d4901c4a71839145f8791

3 years agotimezone: Change zdump installation to bin directory
Prasanth R [Wed, 25 Nov 2020 14:51:51 +0000 (15:51 +0100)]
timezone: Change zdump installation to bin directory

Commit 3bc4186c7a9, tzdata changed the zdump installation
to bin directory, which creates duplicates of zdump in the
Root filesystem.

3 years agonptl: Return EINVAL for invalid clock for pthread_clockjoin_np
Adhemerval Zanella [Mon, 23 Nov 2020 16:47:18 +0000 (13:47 -0300)]
nptl: Return EINVAL for invalid clock for pthread_clockjoin_np

The align the GNU extension with the others one that accept specify
which clock to wait for (such as pthread_mutex_clocklock).

Check on x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Return EINVAL for pthread_mutex_clocklock/PI with CLOCK_MONOTONIC [BZ #26801]
Adhemerval Zanella [Thu, 29 Oct 2020 18:34:31 +0000 (15:34 -0300)]
nptl: Return EINVAL for pthread_mutex_clocklock/PI with CLOCK_MONOTONIC [BZ #26801]

Linux futex FUTEX_LOCK_PI operation only supports CLOCK_REALTIME,
so pthread_mutex_clocklock operation with priority aware mutexes
may fail depending of the input timeout.

Also, it is not possible to convert a CLOCK_MONOTONIC to a
CLOCK_REALTIME due the possible wall clock time change which might
invalid the requested timeout.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Replace lll_futex_wake with futex-internal.h
Adhemerval Zanella [Mon, 23 Nov 2020 13:38:12 +0000 (10:38 -0300)]
nptl: Replace lll_futex_wake with futex-internal.h

The idea is to make NPTL implementation to use on the functions
provided by futex-internal.h.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Replace lll_futex_supported_clockid with futex-internal.h
Adhemerval Zanella [Mon, 23 Nov 2020 13:16:33 +0000 (10:16 -0300)]
nptl: Replace lll_futex_supported_clockid with futex-internal.h

The idea is to make NPTL implementation to use on the functions
provided by futex-internal.h.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Replace lll_futex_{timed_}wait by futex-internal.h
Adhemerval Zanella [Mon, 23 Nov 2020 13:13:42 +0000 (10:13 -0300)]
nptl: Replace lll_futex_{timed_}wait by futex-internal.h

The idea is to make NPTL implementation to use on the functions
provided by futex-internal.h.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Replace lll_timedwait with __futex_abstimed_wait64
Adhemerval Zanella [Sun, 22 Nov 2020 21:55:03 +0000 (18:55 -0300)]
nptl: Replace lll_timedwait with __futex_abstimed_wait64

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Replace __futex_clocklock_wait64 with __futex_abstimed_wait64
Adhemerval Zanella [Sat, 21 Nov 2020 20:39:44 +0000 (17:39 -0300)]
nptl: Replace __futex_clocklock_wait64 with __futex_abstimed_wait64

For non null timeouts, the __futex_clocklock_wait64 creates an a
relative timeout by subtracting the current time from the input
argument.  The same behavior can be obtained with FUTEX_WAIT_BITSET
without the need to calculate the relative timeout.  Besides consolidate
the code it also avoid the possible relative timeout issues [1].

The __futex_abstimed_wait64 needs also to return EINVAL syscall
errors.

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

[1] https://sourceware.org/pipermail/libc-alpha/2020-November/119881.html

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Remove _futex_clock_wait_bitset64
Adhemerval Zanella [Sat, 21 Nov 2020 14:40:46 +0000 (11:40 -0300)]
nptl: Remove _futex_clock_wait_bitset64

It can be replaced with a __futex_abstimed_wait64 call.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Consolidate __futex_abstimed_wait_{cancelable}64
Adhemerval Zanella [Sat, 21 Nov 2020 13:39:26 +0000 (10:39 -0300)]
nptl: Consolidate __futex_abstimed_wait_{cancelable}64

The only different is how to issue the syscall.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Extend __futex_abstimed_wait_cancelable64 comment
Adhemerval Zanella [Fri, 20 Nov 2020 13:58:51 +0000 (10:58 -0300)]
nptl: Extend __futex_abstimed_wait_cancelable64 comment

And add a small optimization to avoid setting the operation for the
32-bit time fallback operation.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Remove clockwait_tid
Adhemerval Zanella [Mon, 23 Nov 2020 18:28:57 +0000 (15:28 -0300)]
nptl: Remove clockwait_tid

It can be replaced with a __futex_abstimed_wait_cancelable64 call,
with the advantage that there is no need to further clock adjustments
to create a absolute timeout.  It allows to remove the now ununsed
futex_timed_wait_cancel64 internal function.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Remove futex_wait_cancelable
Adhemerval Zanella [Mon, 23 Nov 2020 18:26:42 +0000 (15:26 -0300)]
nptl: Remove futex_wait_cancelable

It is used solely on __pthread_cond_wait_common and the call can be
replaced by a __futex_abstimed_wait_cancelable64 one.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agonptl: Remove unused internal futex functions
Adhemerval Zanella [Fri, 20 Nov 2020 13:36:56 +0000 (10:36 -0300)]
nptl: Remove unused internal futex functions

The __futex_abstimed_wait usage was remove with 3102e28bd11 and the
__futex_abstimed_wait_cancelable by 323592fdc92 and b8d3e8fbaac.
The futex_lock_pi can be replaced by a futex_lock_pi64.

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

Reviewed-by: Lukasz Majewski <lukma@denx.de>
3 years agoMark mtrace tests UNSUPPORTED if bug-ga2.mtrace or tst-leaks2.mtrace are missing
Stefan Liebler [Wed, 25 Nov 2020 07:30:17 +0000 (08:30 +0100)]
Mark mtrace tests UNSUPPORTED if bug-ga2.mtrace or tst-leaks2.mtrace are missing

Starting with commit 29fddfc7dfd6444fa61a256e9a0d0127545e1f2e, the
tests posix/bug-ga2 and resolv/tst-leaks2 are test-container tests.

If test-container.c returns with EXIT_UNSUPPORTED, the tests with
mtrace() are not executed and the mtrace files do not exist.

Therefore the "mtrace-analysis-part" of those tests are marked
UNSUPPORTED if the mtrace files are missing.

Reported-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agoelf: Fix uninitialized variable for _dl_write
Shuo Wang [Tue, 24 Nov 2020 19:42:18 +0000 (16:42 -0300)]
elf: Fix uninitialized variable for _dl_write

Variable ret in elf/dl-write.c is uninitialized, which should get
return value from __writev.

3 years agopowerpc: Make PT_THREAD_POINTER available to assembly code
Matheus Castanho [Mon, 19 Oct 2020 14:06:56 +0000 (11:06 -0300)]
powerpc: Make PT_THREAD_POINTER available to assembly code

PT_THREAD_POINTER is currenty defined inside a #ifndef __ASSEMBLER__ block, but
its usage should not be limited to C code, as it can be useful when accessing
the TLS from assembly code as well.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agoUse libnss_files.so for tests posix/bug-ga2 and resolv/tst-leaks2 [BZ #26821]
Stefan Liebler [Mon, 23 Nov 2020 09:51:24 +0000 (10:51 +0100)]
Use libnss_files.so for tests posix/bug-ga2 and resolv/tst-leaks2 [BZ #26821]

The tests posix/bug-ga2-mem and resolv/mtrace-tst-leaks2 are failing on
fedora 33 as mtrace reports memory leaks.

The /etc/nsswitch.conf differs between
Fedora 32: hosts:      files dns myhostname
Fedora 33: hosts:      files resolve [!UNAVAIL=return] myhostname dns

Therefore /lib64/libnss_resolve.so.2 (from systemd) and the dependencies
libgcc_s.so.1 and libpthread.so.0 are loaded.

Usually all malloc'ed resources from getaddrinfo / gethostbyname are freed
and the libraries are dlclose'd in nss/nsswitch.c:libc_freeres_fn (free_mem).
Unfortunately, /lib64/libnss_resolve.so.2 is marked with DF_1_NODELETE.
As this library is not unmapped, you'll see "Memory not freed".

Therefore those tests are now only relying on libnss_files.so by making
them test-container tests and providing the required configuration files.

By moving the tests to tests-container, those are now running with
"make check".  Therefore the mtrace part of the tests are also moved
from "make xcheck" to "make check".

bug-ga2.c is now using test-driver.c in order to support WAIT_FOR_DEBUGGER
environment variable.

3 years agohurd report-wait: Fix stpcpy usage
Samuel Thibault [Mon, 23 Nov 2020 00:31:41 +0000 (00:31 +0000)]
hurd report-wait: Fix stpcpy usage

We shall not overflow the size of the description parameter. This makes
describe_number and describe_port behave like strpcpy (except for not filling
all the end of buffer with zeroes) and _S_msg_report_wait use series of
stpncpy-like call. If we were to overflow, we can now detect it and
return ENOMEM.

3 years agohurd S_msg_report_wait: Fix detecting fd ports
Samuel Thibault [Mon, 23 Nov 2020 00:25:26 +0000 (00:25 +0000)]
hurd S_msg_report_wait: Fix detecting fd ports

_hurd_init_dtable stays set to non-NULL, so we have to run through both
_hurd_init_dtable and _hurd_dtable.

3 years agohurd S_msg_report_wait: Fix reporting ports
Samuel Thibault [Mon, 23 Nov 2020 00:24:03 +0000 (00:24 +0000)]
hurd S_msg_report_wait: Fix reporting ports

This fixes the parameter order of MSG_EXAMINE, thus fixing the detection
of e.g. fd ports for nicer output in ps WAIT output.

3 years agohurd: Fix strcpy calls
Samuel Thibault [Sun, 22 Nov 2020 23:15:36 +0000 (23:15 +0000)]
hurd: Fix strcpy calls

strcpy cannot be used with overlapping buffer, we have to use memmove
instead. strcpy also cannot be safely used when the destination buffer
is smaller that the source, we need to use strncpy to truncate the
source if needed.

3 years agohurd: Fix _S_msg_get/set_env_variable prototype
Samuel Thibault [Sun, 22 Nov 2020 09:59:17 +0000 (09:59 +0000)]
hurd: Fix _S_msg_get/set_env_variable prototype

_S_msg_get_env_variable and _S_msg_set_env_variable are taking string_t,
not char *.

Fixes a warning with gcc 11.

3 years agohurd: Enable using ifunc
Samuel Thibault [Fri, 13 Nov 2020 21:33:08 +0000 (21:33 +0000)]
hurd: Enable using ifunc

Bugs have been fixed in binutils/gcc/glibc.

3 years agoAdd {,sysdep-}ld-library-path make variable
Samuel Thibault [Fri, 13 Nov 2020 19:37:41 +0000 (19:37 +0000)]
Add {,sysdep-}ld-library-path make variable

On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading
dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This
adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in
Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some
more paths, here mach/ and hurd/.

3 years agonptl: Move stack list variables into _rtld_global
Florian Weimer [Mon, 16 Nov 2020 18:33:30 +0000 (19:33 +0100)]
nptl: Move stack list variables into _rtld_global

Now __thread_gscope_wait (the function behind THREAD_GSCOPE_WAIT,
formerly __wait_lookup_done) can be implemented directly in ld.so,
eliminating the unprotected GL (dl_wait_lookup_done) function
pointer.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agohurd: let _dl_argv and __libc_stack_end be relro
Samuel Thibault [Sun, 15 Nov 2020 13:47:13 +0000 (13:47 +0000)]
hurd: let _dl_argv and __libc_stack_end be relro

libpthread does not switch stacks.

3 years agohurd: Remove some remnants of cthreads
Samuel Thibault [Sat, 14 Nov 2020 23:35:35 +0000 (23:35 +0000)]
hurd: Remove some remnants of cthreads

Libc has actually been using mach's lock-internal.h mutex for a long
time already.

3 years agonanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64
Lukasz Majewski [Thu, 12 Nov 2020 11:24:04 +0000 (12:24 +0100)]
nanosleep: Pass NULL when rem == NULL on ports with __TIMESIZE != 64

On ports with __TIMESIZE != 64 the remaining time argument always receives
pointer to struct __timespec64 instance. This is the different behavior
when compared to 64 bit versions of clock_nanosleep and nanosleep
functions, which receive NULL.

To avoid any potential issues, we also pass NULL when *rem pointer is
NULL.

Reported-by: Andreas Schwab <schwab@suse.de>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoy2038: Convert thrd_sleep to support 64 bit time
Lukasz Majewski [Wed, 11 Nov 2020 23:24:48 +0000 (00:24 +0100)]
y2038: Convert thrd_sleep to support 64 bit time

The thrd_sleep function has been converted to support 64 bit time.
It was also necessary to provide Linux specific copy of it to avoid
problems on i686-gnu (i.e. HURD) port, which is not providing
clock_nanosleep() supporting 64 bit time.

The thrd_sleep is a wrapper on POSIX threads to provide C11 standard
threads interface. It directly calls __clock_nanosleep64().

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoy2038: Convert mtx_timedlock to support 64 bit time
Lukasz Majewski [Wed, 11 Nov 2020 23:09:03 +0000 (00:09 +0100)]
y2038: Convert mtx_timedlock to support 64 bit time

The mtx_timedlock function has been converted to support 64 bit time.
It was also necessary to provide Linux specific copy of it to avoid
problems on i686-gnu (i.e. HURD) port, which is not providing
pthread_mutex_timedlock() supporting 64 bit time.

The mtx_timedlock is a wrapper on POSIX threads to provide C11 standard
threads interface. It directly calls __pthread_mutex_timedlock64().

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agoy2038: Convert cnd_timedwait to support 64 bit time
Lukasz Majewski [Thu, 29 Oct 2020 13:19:25 +0000 (14:19 +0100)]
y2038: Convert cnd_timedwait to support 64 bit time

The cnd_timedwait function has been converted to support 64 bit time.
It was also necessary to provide Linux specific copy of it to avoid
problems on i686-gnu (i.e. HURD) port, which is not providing
pthread_cond_timedwait() supporting 64 bit time.

Moreover, a linux specific copy of thrd_priv.h header file has been
added as well.

The cnd_timedwait is a wrapper on POSIX threads to provide C11 standard
threads interface. It directly calls __pthread_cond_timedwait64().

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

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
3 years agohurd: Drop CLOCK_MONOTONIC change which slipped in
Samuel Thibault [Fri, 13 Nov 2020 23:59:04 +0000 (00:59 +0100)]
hurd: Drop CLOCK_MONOTONIC change which slipped in

3 years agohurd: make ptsname fail with ENOTTY on non-master-pty
Samuel Thibault [Fri, 13 Nov 2020 23:51:49 +0000 (23:51 +0000)]
hurd: make ptsname fail with ENOTTY on non-master-pty

3 years agomach: Add missing assert.h include
Samuel Thibault [Fri, 13 Nov 2020 22:38:51 +0000 (22:38 +0000)]
mach: Add missing assert.h include

3 years agohurd: break relocation loop between libc.so and lib{mach,hurd}user.so
Samuel Thibault [Fri, 13 Nov 2020 15:56:51 +0000 (15:56 +0000)]
hurd: break relocation loop between libc.so and lib{mach,hurd}user.so

See
https://sourceware.org/pipermail/libc-alpha/2020-November/119575.html

lib{mach,hurd}user.so gets relocated before libc.so, but its references
to strpcpy and memcpy would need an ifunc decision, which e.g. on
x86 relies on cpu_features, but libc.so's _rtld_global_ro is not
relocated yet.

We can however just make lib{mach,hurd}user.so only call non-ifunc
functions, which can be relocated before libc.so is relocated.

3 years agoRemove obsolete defines for HPUX support from fcntl.h and update O_NONBLOCK.
John David Anglin [Fri, 13 Nov 2020 16:42:11 +0000 (16:42 +0000)]
Remove obsolete defines for HPUX support from fcntl.h and update O_NONBLOCK.

3 years agoRemove tls.h inclusion from internal errno.h
Adhemerval Zanella [Tue, 4 Feb 2020 13:29:04 +0000 (10:29 -0300)]
Remove tls.h inclusion from internal errno.h

The tls.h inclusion is not really required and limits possible
definition on more arch specific headers.

This is a cleanup to allow inline functions on sysdep.h, more
specifically on i386 and ia64 which requires to access some tls
definitions its own.

No semantic changes expected, checked with a build against all
affected ABIs.

3 years agonptl: Eliminate <smp.h> and __is_smp
Florian Weimer [Fri, 13 Nov 2020 14:19:41 +0000 (15:19 +0100)]
nptl: Eliminate <smp.h> and __is_smp

Most systems are SMP, so optimizing for the UP case is no longer
approriate.  A dynamic check based on the kernel identification
has been only implemented for i386 anyway.

To disable adaptive mutexes on sh, define DEFAULT_ADAPTIVE_COUNT
as zero for this architecture.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agopowerpc: Eliminate UP macro conditionals
Florian Weimer [Fri, 13 Nov 2020 14:19:41 +0000 (15:19 +0100)]
powerpc: Eliminate UP macro conditionals

The macro is never defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agox86: Remove UP macro. Define LOCK_PREFIX unconditionally.
Florian Weimer [Fri, 13 Nov 2020 14:19:41 +0000 (15:19 +0100)]
x86: Remove UP macro.  Define LOCK_PREFIX unconditionally.

The UP macro is never defined.  Also define LOCK_PREFIX
unconditionally, to the same string.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoalpha: Remove UP preprocessor conditionals
Florian Weimer [Fri, 13 Nov 2020 14:19:41 +0000 (15:19 +0100)]
alpha: Remove UP preprocessor conditionals

The macro is never defined.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agohurd: Make sure signals get started
Samuel Thibault [Fri, 13 Nov 2020 10:23:08 +0000 (10:23 +0000)]
hurd: Make sure signals get started

Now that _hurd_libc_proc_init is idempotent, we can always call it,
independently of the __libc_multiple_libcs test which may not match
whether signals should be started or not.

3 years agohurd: initialize libpthread before starting the signal thread
Samuel Thibault [Fri, 13 Nov 2020 01:10:42 +0000 (01:10 +0000)]
hurd: initialize libpthread before starting the signal thread

We cannot rely on csu calling __pthread_initialize_minimal before
posixland_init, in some cases _init gets called before that.

3 years agohurd: Make _hurd_libc_proc_init idempotent
Samuel Thibault [Fri, 13 Nov 2020 00:21:47 +0000 (00:21 +0000)]
hurd: Make _hurd_libc_proc_init idempotent

For the cases where _init is getting called several times during startup. Better
clean pointers anyway.

3 years agopowerpc: Add optimized stpncpy for POWER9
Raphael M Zinsly [Thu, 12 Nov 2020 16:12:24 +0000 (13:12 -0300)]
powerpc: Add optimized stpncpy for POWER9

Add stpncpy support into the POWER9 strncpy.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agopowerpc: Add optimized strncpy for POWER9
Raphael M Zinsly [Thu, 12 Nov 2020 16:12:24 +0000 (13:12 -0300)]
powerpc: Add optimized strncpy for POWER9

Similar to the strcpy P9 optimization, this version uses VSX to improve
performance.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
3 years agoDon't use nested function in test-ffs
Siddhesh Poyarekar [Thu, 12 Nov 2020 07:46:02 +0000 (13:16 +0530)]
Don't use nested function in test-ffs

There is no real need to use a nested function in that test, so break
it out so that it can build with clang too.

3 years agoUse __builtin___stpncpy_chk when available
Siddhesh Poyarekar [Thu, 12 Nov 2020 06:39:56 +0000 (12:09 +0530)]
Use __builtin___stpncpy_chk when available

The builtin has been available in gcc since 4.7.0 and in clang since
2.6.  This fixes stpncpy fortification with clang since it does a
better job of plugging in __stpncpy_chk in the right place than the
header hackery.

This has been tested by building and running all tests with gcc 10.2.1
and also with clang tip as of a few days ago (just the tests in debug/
since running all tests don't work with clang at the moment) to make
sure that both compilers pass the stpncpy tests.

3 years agotests: Remove NULL check for an array
Siddhesh Poyarekar [Wed, 11 Nov 2020 17:23:50 +0000 (22:53 +0530)]
tests: Remove NULL check for an array

The NULL check for an array on stack is pointless since it will always
be false, so drop it.

3 years agohurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbols
Samuel Thibault [Wed, 11 Nov 2020 22:47:13 +0000 (22:47 +0000)]
hurd: Move {,f,l}xstat{,at} and xmknod{at} to compat symbols

We do not actually need them, so we can move their implementations
into the standard {,f,l}stat{,at} variants and only keep compatibility
wrappers.

3 years agohurd: Notify the proc server later during initialization
Samuel Thibault [Wed, 11 Nov 2020 12:52:35 +0000 (12:52 +0000)]
hurd: Notify the proc server later during initialization

Notifying the proc server is an involved task, and unleashes various signal
handling etc. so we have to do this after e.g. ifunc relocations are
completed.

3 years agohtl: Initialize later
Samuel Thibault [Wed, 11 Nov 2020 10:35:10 +0000 (10:35 +0000)]
htl: Initialize later

Since htl does not actually need a stack switch, we can initialize it
like nptl is, avoiding all sorts of startup issues with ifunc.

More precisely, htl defines __pthread_initialize_minimal instead of the
elder _cthread_init_routine. We can then drop the stack switching dances.

3 years agohtl: Keep thread signals blocked during its initialization
Samuel Thibault [Wed, 11 Nov 2020 12:49:10 +0000 (12:49 +0000)]
htl: Keep thread signals blocked during its initialization

One may send signals immediately after creating a thread. We need to block them
until the thread is ready to run signal handlers.

3 years agohtl: Fix spurious symbols in namespaces
Samuel Thibault [Wed, 11 Nov 2020 14:39:51 +0000 (14:39 +0000)]
htl: Fix spurious symbols in namespaces

pthread_attr_{{get,set}stack{addr,size},setstack} were defining a strong alias
for no reason, turning them to weak.

3 years agoUse O_CLOEXEC in sysconf [BZ #26791]
Maximilian Krüger [Wed, 11 Nov 2020 10:21:30 +0000 (11:21 +0100)]
Use O_CLOEXEC in sysconf [BZ #26791]

If sysconf is used in multithreaded processes, various filedescriptors
may leak due to missing O_CLOEXEC.  This commit adds the flag.

3 years agostruct _Unwind_Exception alignment should not depend on compiler flags
Florian Weimer [Wed, 11 Nov 2020 10:59:11 +0000 (11:59 +0100)]
struct _Unwind_Exception alignment should not depend on compiler flags

__attribute__((__aligned__)) selects an alignment that depends on
the micro-architecture selected by GCC flags.  Enabling vector
extensions may increase the allignment.  This is a problem when
building glibc as a collection of ELF multilibs with different
GCC flags because ld.so and libc.so/libpthread.so/&c may end up
with a different layout of struct pthread because of the
changing offset of its struct _Unwind_Exception field.

Tested-By: Matheus Castanho <msc@linux.ibm.com>
3 years agohurd: keep only required PLTs in ld.so
Samuel Thibault [Tue, 10 Nov 2020 23:35:19 +0000 (23:35 +0000)]
hurd: keep only required PLTs in ld.so

We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so.
See Roland's comment in
https://sourceware.org/bugzilla/show_bug.cgi?id=15605
"in the Hurd it's crucial that calls like __mmap be the libc ones
instead of the rtld-local ones after the bootstrap phase, when the
dynamic linker is being used for dlopen and the like."

We used to just avoid all hidden use in the rtld ; this commit switches to
keeping only those that should use PLT calls, i.e. essentially those defined in
sysdeps/mach/hurd/dl-sysdep.c:

__assert_fail
__assert_perror_fail
__*stat64
_exit

This fixes a few startup issues, notably the call to __tunable_get_val that is
made before PLTs are set up.

3 years agohurd: Add missing startup calls
Samuel Thibault [Tue, 10 Nov 2020 23:50:04 +0000 (23:50 +0000)]
hurd: Add missing startup calls

DL_SYSDEP_INIT and DL_PLATFORM_INIT were not getting called, leading to
missing x86 platform tuning, now mandatory with 0f09154c6400
("x86: Initialize CPU info via IFUNC relocation [BZ 26203]")

3 years agoriscv: Get cache information through sysconf
Zong Li [Thu, 29 Oct 2020 17:33:38 +0000 (01:33 +0800)]
riscv: Get cache information through sysconf

Add support to query cache information on RISC-V through sysconf()
function. The cache information had been added in AUX vector of RISC-V
architecture in Linux kernel v.5.10-rc1.
Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
Acked-by: Palmer Dabbelt <palmerdabbelt@google.com>
3 years agoRISC-V: Add _dl_start_user.
Jim Wilson [Tue, 10 Nov 2020 00:53:23 +0000 (16:53 -0800)]
RISC-V: Add _dl_start_user.

This is required for the debugglibc.sh script to work.  Tested by
successfully using this patched script, and a riscv64-linux testsuite
run.

We could perhaps call RTLD_EPILOGUE for ENTRY_POINT before calling
RTLD_PROLOGUE for _dl_start_user, but I don't think it matters.

OK?

Jim

3 years agolinux: Allow adjtime with NULL argument [BZ #26833]
Adhemerval Zanella [Mon, 2 Nov 2020 19:18:29 +0000 (16:18 -0300)]
linux: Allow adjtime with NULL argument [BZ #26833]

The adjtime interface allows return the amount of time remaining
from any previous adjustment that has not yet been completed by
passing a NULL as first argument.  This was introduced with y2038
support 0308077e3a.

Checked on i686-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>