platform/upstream/glibc.git
3 years agostdio-common: Remove _IO_vfwscanf
Florian Weimer [Tue, 1 Jun 2021 14:00:48 +0000 (16:00 +0200)]
stdio-common: Remove _IO_vfwscanf

The symbol has never been exported, so no compatibility symbol is
needed.  Removing this file prevents ld from creation an exported
symbol in case GLIBC_2_0 expands to a symbol version which
does not have a local: *; directive in the symbol version map file.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoaarch64: align stack in clone [BZ #27939]
Szabolcs Nagy [Tue, 1 Jun 2021 08:23:40 +0000 (09:23 +0100)]
aarch64: align stack in clone [BZ #27939]

The AArch64 PCS requires 16 byte aligned stack.  Previously if the
caller passed an unaligned stack to clone then the child crashed.

Fixes bug 27939.

3 years agopowerpc: Optimized memcmp for power10
Lucas A. M. Magalhaes [Thu, 6 May 2021 20:01:52 +0000 (17:01 -0300)]
powerpc: Optimized memcmp for power10

This patch was based on the __memcmp_power8 and the recent
__strlen_power10.

Improvements from __memcmp_power8:

1. Don't need alignment code.

   On POWER10 lxvp and lxvl do not generate alignment interrupts, so
they are safe for use on caching-inhibited memory.  Notice that the
comparison on the main loop will wait for both VSR to be ready.
Therefore aligning one of the input address does not improve
performance.  In order to align both registers a vperm is necessary
which add too much overhead.

2. Uses new POWER10 instructions

   This code uses lxvp to decrease contention on load by loading 32 bytes
per instruction.
   The vextractbm is used to have a smaller tail code for calculating the
return value.

3. Performance improvement

   This version has around 35% better performance on average. I saw no
performance regressions for any length or alignment.

Thanks Matheus for helping me out with some details.

Co-authored-by: Matheus Castanho <msc@linux.ibm.com>
Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
3 years agox86-64: Align child stack to 16 bytes [BZ #27902]
H.J. Lu [Sun, 23 May 2021 17:25:10 +0000 (10:25 -0700)]
x86-64: Align child stack to 16 bytes [BZ #27902]

In the x86-64 clone wrapper, align child stack to 16 bytes per the
x86-64 psABI.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agosupport: Do not build xpthread_attr_setaffinity_np for hurd
Adhemerval Zanella [Fri, 28 May 2021 19:00:19 +0000 (16:00 -0300)]
support: Do not build xpthread_attr_setaffinity_np for hurd

It does not provide pthread_attr_setaffinity_np extension.

3 years agonptl: Add pthread_attr_setaffinity_np failure test
Adhemerval Zanella [Mon, 24 May 2021 16:47:10 +0000 (13:47 -0300)]
nptl: Add pthread_attr_setaffinity_np failure test

It checks whether an invalid affinity mask does return an error,
similar to what sysdeps/pthread/tst-bad-schedattr.c does for
pthread_attr_setschedparam.

Checked on x86_64-linux-gnu.

3 years agosupport: Add xpthread_attr_setaffinity_np wrapper
Adhemerval Zanella [Fri, 21 May 2021 18:09:43 +0000 (15:09 -0300)]
support: Add xpthread_attr_setaffinity_np wrapper

3 years agonptl: Move createthread to pthread_create
Adhemerval Zanella [Fri, 21 May 2021 13:12:37 +0000 (10:12 -0300)]
nptl: Move createthread to pthread_create

The 'create_thread' function is moved to pthread_create.c.  It removes
the START_THREAD_DEFN and START_THREAD_SELF macros and make the
lock usage more clear (no need to cross-reference multiple files).

No functional change.

3 years agonptl: Move Linux createthread to nptl
Adhemerval Zanella [Fri, 21 May 2021 13:09:31 +0000 (10:09 -0300)]
nptl: Move Linux createthread to nptl

git mv -f sysdeps/unix/sysv/linux/createthread.c nptl/createthread.c

No functional change.

3 years agonptl: Install SIGSETXID handler with SA_ONSTACK [BZ #27914]
Florian Weimer [Thu, 27 May 2021 13:37:35 +0000 (15:37 +0200)]
nptl: Install SIGSETXID handler with SA_ONSTACK [BZ #27914]

The signal is sent to all threads, some of which may have switched
to very small stacks.  If they have also installed an alternate
signal stack, SA_ONSTACK makes this work.  The Go runtime needs this:

  runtime: C.setuid/C.setgid smashes Go stack
  <https://github.com/golang/go/issues/9400>

Doing this for SIGCANCEL is less obviously beneficial and needs further
testing.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoaarch64: Added optimized memset for A64FX
Naohiro Tamura [Thu, 27 May 2021 07:44:12 +0000 (07:44 +0000)]
aarch64: Added optimized memset for A64FX

This patch optimizes the performance of memset for A64FX [1] which
implements ARMv8-A SVE and has L1 64KB cache per core and L2 8MB cache
per NUMA node.

The performance optimization makes use of Scalable Vector Register
with several techniques such as loop unrolling, memory access
alignment, cache zero fill and prefetch.

SVE assembler code for memset is implemented as Vector Length Agnostic
code so theoretically it can be run on any SOC which supports ARMv8-A
SVE standard.

We confirmed that all testcases have been passed by running 'make
check' and 'make xcheck' not only on A64FX but also on ThunderX2.

And also we confirmed that the SVE 512 bit vector register performance
is roughly 4 times better than Advanced SIMD 128 bit register and 8
times better than scalar 64 bit register by running 'make bench'.

[1] https://github.com/fujitsu/A64FX

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Reviewed-by: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
3 years agoaarch64: Added optimized memcpy and memmove for A64FX
Naohiro Tamura [Thu, 27 May 2021 07:42:35 +0000 (07:42 +0000)]
aarch64: Added optimized memcpy and memmove for A64FX

This patch optimizes the performance of memcpy/memmove for A64FX [1]
which implements ARMv8-A SVE and has L1 64KB cache per core and L2 8MB
cache per NUMA node.

The performance optimization makes use of Scalable Vector Register
with several techniques such as loop unrolling, memory access
alignment, cache zero fill, and software pipelining.

SVE assembler code for memcpy/memmove is implemented as Vector Length
Agnostic code so theoretically it can be run on any SOC which supports
ARMv8-A SVE standard.

We confirmed that all testcases have been passed by running 'make
check' and 'make xcheck' not only on A64FX but also on ThunderX2.

And also we confirmed that the SVE 512 bit vector register performance
is roughly 4 times better than Advanced SIMD 128 bit register and 8
times better than scalar 64 bit register by running 'make bench'.

[1] https://github.com/fujitsu/A64FX

Reviewed-by: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Reviewed-by: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
3 years agobenchtests: Fixed bench-memcpy-random: buf1: mprotect failed
Naohiro Tamura [Wed, 12 May 2021 09:29:54 +0000 (09:29 +0000)]
benchtests: Fixed bench-memcpy-random: buf1: mprotect failed

This patch fixed mprotect system call failure on AArch64.
This failure happened on not only A64FX but also ThunderX2.

Also this patch updated a JSON key from "max-size" to "length" so that
'plot_strings.py' can process 'bench-memcpy-random.out'

3 years agoaarch64: Added Vector Length Set test helper script
Naohiro Tamura [Thu, 20 May 2021 07:34:37 +0000 (07:34 +0000)]
aarch64: Added Vector Length Set test helper script

This patch is a test helper script to change Vector Length for child
process. This script can be used as test-wrapper for 'make check'.

Usage examples:

~/build$ make check subdirs=string \
test-wrapper='~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 16'

~/build$ ~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 16 \
make test t=string/test-memcpy

~/build$ ~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 32 \
./debugglibc.sh string/test-memmove

~/build$ ~/glibc/sysdeps/unix/sysv/linux/aarch64/vltest.py 64 \
./testrun.sh string/test-memset

3 years agoaarch64: define BTI_C and BTI_J macros as NOP unless HAVE_AARCH64_BTI
Naohiro Tamura [Wed, 12 May 2021 09:27:20 +0000 (09:27 +0000)]
aarch64: define BTI_C and BTI_J macros as NOP unless HAVE_AARCH64_BTI

This patch defines BTI_C and BTI_J macros conditionally for
performance.
If HAVE_AARCH64_BTI is true, BTI_C and BTI_J are defined as HINT
instruction for ARMv8.5 BTI (Branch Target Identification).
If HAVE_AARCH64_BTI is false, both BTI_C and BTI_J are defined as
NOP.

3 years agoconfig: Added HAVE_AARCH64_SVE_ASM for aarch64
Naohiro Tamura [Wed, 12 May 2021 09:26:40 +0000 (09:26 +0000)]
config: Added HAVE_AARCH64_SVE_ASM for aarch64

This patch checks if assembler supports '-march=armv8.2-a+sve' to
generate SVE code or not, and then define HAVE_AARCH64_SVE_ASM macro.

3 years agotst-mallinfo2.c: Use correct multiple for total variable
Yang Xu [Thu, 18 Feb 2021 02:56:33 +0000 (10:56 +0800)]
tst-mallinfo2.c: Use correct multiple for total variable

Since test uses 160 multiple for malloc size, we should also use 160 multiple
for total variable instead of 16, then comparison is meaningful. So fix it.

Also change the ">" to ">=" so that the test is technically valid.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoLinux: Remove remaining references to $(shared-thread-library)
Florian Weimer [Tue, 25 May 2021 09:30:23 +0000 (11:30 +0200)]
Linux: Remove remaining references to $(shared-thread-library)

Since the variable expands to nothing under Linux, it is no longer
necessary to clutter the makefiles with it.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Do not install libpthread.so and do not link tests with it
Florian Weimer [Tue, 25 May 2021 09:30:23 +0000 (11:30 +0200)]
nptl: Do not install libpthread.so and do not link tests with it

Keep installing libpthread.a, so that -lpthread works.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agotestrun.sh: Improve --help message
Lucas A. M. Magalhaes [Tue, 25 May 2021 04:44:19 +0000 (10:14 +0530)]
testrun.sh: Improve --help message

The testrun.sh --help message was missing the "container" option.
Besides just adding the missing option I decide to rewrite it in the
same layout as other tools.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agopowerpc: Fix handling of scv return error codes [BZ #27892]
Nicholas Piggin [Thu, 20 May 2021 14:00:36 +0000 (11:00 -0300)]
powerpc: Fix handling of scv return error codes [BZ #27892]

When using scv for templated ASM syscalls, current code interprets any
negative return value as error, but the only valid error codes are in
the range -4095..-1 according to the ABI.

This commit also fixes 'signal.gen.test' strace test, where the issue
was first identified.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
3 years agoProperly check stack alignment [BZ #27901]
H.J. Lu [Sun, 23 May 2021 16:15:52 +0000 (09:15 -0700)]
Properly check stack alignment [BZ #27901]

1. Replace

if ((((uintptr_t) &_d) & (__alignof (double) - 1)) != 0)

which may be optimized out by compiler, with

int
__attribute__ ((weak, noclone, noinline))
is_aligned (void *p, int align)
{
  return (((uintptr_t) p) & (align - 1)) != 0;
}

2. Add TEST_STACK_ALIGN_INIT to TEST_STACK_ALIGN.
3. Add a common TEST_STACK_ALIGN_INIT to check 16-byte stack alignment
for both i386 and x86-64.
4. Update powerpc to use TEST_STACK_ALIGN_INIT.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agox86: Improve memmove-vec-unaligned-erms.S
Noah Goldstein [Sun, 23 May 2021 23:43:24 +0000 (19:43 -0400)]
x86: Improve memmove-vec-unaligned-erms.S

This patch changes the condition for copy 4x VEC so that if length is
exactly equal to 4 * VEC_SIZE it will use the 4x VEC case instead of
8x VEC case.

Results For Skylake memcpy-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.137   , 6.873   , New , 75.22
128 , 7   , 0   , 12.933  , 7.732   , New , 59.79
128 , 0   , 7   , 11.852  , 6.76    , New , 57.04
128 , 7   , 7   , 12.587  , 6.808   , New , 54.09

Results For Icelake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 9.963   , 5.416   , New , 54.36
128 , 7   , 0   , 16.467  , 8.061   , New , 48.95
128 , 0   , 7   , 14.388  , 7.644   , New , 53.13
128 , 7   , 7   , 14.546  , 7.642   , New , 52.54

Results For Tigerlake memcpy-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 0   , 8.979   , 4.95    , New , 55.13
128 , 7   , 0   , 14.245  , 7.122   , New , 50.0
128 , 0   , 7   , 12.668  , 6.675   , New , 52.69
128 , 7   , 7   , 13.042  , 6.802   , New , 52.15

Results For Skylake memmove-avx2-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 6.181   , 5.691   , New , 92.07
128 , 32  , 0   , 6.165   , 5.752   , New , 93.3
128 , 0   , 7   , 13.923  , 9.37    , New , 67.3
128 , 7   , 0   , 12.049  , 10.182  , New , 84.5

Results For Icelake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.479   , 4.889   , New , 89.23
128 , 32  , 0   , 5.127   , 4.911   , New , 95.79
128 , 0   , 7   , 18.885  , 13.547  , New , 71.73
128 , 7   , 0   , 15.565  , 14.436  , New , 92.75

Results For Tigerlake memmove-evex-erms
size, al1 , al2 , Cur T   , New T   , Win , New / Cur
128 , 0   , 32  , 5.275   , 4.815   , New , 91.28
128 , 32  , 0   , 5.376   , 4.565   , New , 84.91
128 , 0   , 7   , 19.426  , 14.273  , New , 73.47
128 , 7   , 0   , 15.924  , 14.951  , New , 93.89

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agoBench: Add support for choose direction of memcpy in benchtests
Noah Goldstein [Sun, 23 May 2021 23:36:36 +0000 (19:36 -0400)]
Bench: Add support for choose direction of memcpy in benchtests

This patch adds support for testing memcpy with both dst > src and dst
< src. Since memcpy is implemented as memmove which has seperate
control flows for certain sizes depending on dst > src it seems like
1) information that should be provided in the benchtest output and a
variable that can be controlled for the benchmarks.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
3 years agoAdd cast_to_pointer to cast an integer to void * pointer
H.J. Lu [Fri, 21 May 2021 22:58:36 +0000 (15:58 -0700)]
Add cast_to_pointer to cast an integer to void * pointer

3 years agonptl: Remove remaining code from libpthread
Florian Weimer [Fri, 21 May 2021 20:35:01 +0000 (22:35 +0200)]
nptl: Remove remaining code from libpthread

Only the placeholder compatibility symbols are left now.

The __errno_location symbol was removed (moved) using
scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_create, thrd_create into libc
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Move pthread_create, thrd_create into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

The libpthread placeholder symbols need some changes because some
symbol versions have gone away completely.  But
__errno_location@@GLIBC_2.0 still exists, so the GLIBC_2.0 version
is still there.

The internal __pthread_create symbol now points to the correct
function, so the sysdeps/nptl/thrd_create.c override is no longer
necessary.

There was an issue how the hidden alias of pthread_getattr_default_np
was defined, so this commit cleans up that aspects and removes the
GLIBC_PRIVATE export altogether.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Use custom NODELETE DSO for tst-dlopenfail, tst-dlopenfail-2
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
elf: Use custom NODELETE DSO for tst-dlopenfail, tst-dlopenfail-2

Once libpthread is empty and no longer marked NODELETE, it no longer
can be used for testing.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move semi-public __pthread_get_minstack symbol into libc
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Move semi-public __pthread_get_minstack symbol into libc

No abilist updates here because it is a GLIBC_PRIVATE symbol.

It's also necessary to move nptl_version into pthread_create, so
that it still ends up in static binaries.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Eliminate the __static_tls_size, __static_tls_align_m1 variables
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Eliminate the __static_tls_size, __static_tls_align_m1 variables

Use the  __nptl_tls_static_size_for_stack inline function instead,
and the GLRO (dl_tls_static_align) value directly.

The computation of GLRO (dl_tls_static_align)  in
_dl_determine_tlsoffset ensures that the alignment is at least
TLS_TCB_ALIGN, which at least STACK_ALIGN (see allocate_stack).
Therefore, the additional rounding-up step is removed.

ALso move the initialization of the default stack size from
__pthread_initialize_minimal_internal to __pthread_early_init.
This introduces an extra system call during single-threaded startup,
but this simplifies the initialization sequence.  No locking is
needed around the writes to __default_pthread_attr because the
process is single-threaded at this point.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Perform signal initialization upon pthread_create
Florian Weimer [Fri, 21 May 2021 20:35:00 +0000 (22:35 +0200)]
nptl: Perform signal initialization upon pthread_create

Install signal handlers and unblock signals before pthread_create
creates the first thread.

create_thread in sysdeps/unix/sysv/linux/createthread.c can send
SIGCANCEL to the current thread, so the SIGCANCEL handler is currently
needed even if pthread_cancel is never called.  (The way timer_create
uses SIGCANCEL does not need a signal handler; both SIG_DFL and SIG_IGN
dispositions should work.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Remove unused __libc_pthread_init function
Florian Weimer [Fri, 21 May 2021 10:09:07 +0000 (12:09 +0200)]
nptl: Remove unused __libc_pthread_init function

Fixes commit 732139dabeda7ecce0d56200bc176251e759ccde
("Linux: Move __reclaim_stacks into the fork implementation in
libc").

3 years agox86: Improve memset-vec-unaligned-erms.S
Noah Goldstein [Thu, 20 May 2021 17:13:51 +0000 (13:13 -0400)]
x86: Improve memset-vec-unaligned-erms.S

No bug. This commit makes a few small improvements to
memset-vec-unaligned-erms.S. The changes are 1) only aligning to 64
instead of 128. Either alignment will perform equally well in a loop
and 128 just increases the odds of having to do an extra iteration
which can be significant overhead for small values. 2) Align some
targets and the loop. 3) Remove an ALU from the alignment process. 4)
Reorder the last 4x VEC so that they are stored after the loop. 5)
Move the condition for leq 8x VEC to before the alignment
process. test-memset and test-wmemset are both passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoHurd: Define ARCH_MIN_GUARD_SIZE in internal <pthread.h>
Florian Weimer [Thu, 20 May 2021 16:55:26 +0000 (18:55 +0200)]
Hurd: Define ARCH_MIN_GUARD_SIZE in internal <pthread.h>

This macro is always defined on Linux.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoelf: Initialize GLRO (dl_minsigstacksize) after static dlopen
Florian Weimer [Thu, 20 May 2021 16:55:26 +0000 (18:55 +0200)]
elf: Initialize GLRO (dl_minsigstacksize) after static dlopen

This is another field of _rtld_global_ro that benefits from
initialization in __rtld_static_init.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agonptl: Add missing __pthread_cond_wait alias in static builds
Florian Weimer [Wed, 19 May 2021 20:16:26 +0000 (22:16 +0200)]
nptl: Add missing __pthread_cond_wait alias in static builds

Fixes commit cf3fff1c195f859ba949a7ad86d4fca70bd99740 ("nptl: Move
cnd_wait into libc").

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
3 years agoRemove --enable-stackguard-randomization (BZ #27872)
Adhemerval Zanella [Wed, 19 May 2021 13:22:19 +0000 (10:22 -0300)]
Remove --enable-stackguard-randomization (BZ #27872)

Last ENABLE_STACKGUARD_RANDOMIZE usage was removed by 4a103975c4.

3 years agos390x: Check HWCAP bits against compiler flags
Florian Weimer [Wed, 19 May 2021 09:09:57 +0000 (11:09 +0200)]
s390x: Check HWCAP bits against compiler flags

When compiled with GCC 11.1 and -march=z14 -O3 build flags, running
ld.so (or any dynamically linked program) prints:

Fatal glibc error: CPU lacks VXE support (z14 or later required)

Co-Authored-By: Stefan Liebler <stli@linux.ibm.com>
Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
3 years agopowerpc64le: Check HWCAP bits against compiler build flags
Florian Weimer [Wed, 19 May 2021 09:09:57 +0000 (11:09 +0200)]
powerpc64le: Check HWCAP bits against compiler build flags

When built with GCC 11.1 and -mcpu=power9, ld.so prints this error
message when running on POWER8:

Fatal glibc error: CPU lacks ISA 3.00 support (POWER9 or later required)

3 years agoelf: Add hook for checking HWCAP bits after auxiliary vector parsing
Florian Weimer [Wed, 19 May 2021 09:09:57 +0000 (11:09 +0200)]
elf: Add hook for checking HWCAP bits after auxiliary vector parsing

Reviewed-by: Stefan Liebler <stli@linux.ibm.com>
3 years agox86: Optimize memcmp-evex-movbe.S
Noah Goldstein [Mon, 17 May 2021 17:57:24 +0000 (13:57 -0400)]
x86: Optimize memcmp-evex-movbe.S

No bug. This commit optimizes memcmp-evex.S. The optimizations include
adding a new vec compare path for small sizes, reorganizing the entry
control flow, removing some unnecissary ALU instructions from the main
loop, and most importantly replacing the heavy use of vpcmp + kand
logic with vpxor + vptern. test-memcmp and test-wmemcmp are both
passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86: Optimize memcmp-avx2-movbe.S
Noah Goldstein [Mon, 17 May 2021 17:56:52 +0000 (13:56 -0400)]
x86: Optimize memcmp-avx2-movbe.S

No bug. This commit optimizes memcmp-avx2.S. The optimizations include
adding a new vec compare path for small sizes, reorganizing the entry
control flow, and removing some unnecissary ALU instructions from the
main loop. test-memcmp and test-wmemcmp are both passing.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86: Expand bench-memcmp.c and test-memcmp.c
Noah Goldstein [Mon, 17 May 2021 17:56:17 +0000 (13:56 -0400)]
x86: Expand bench-memcmp.c and test-memcmp.c

No bug. This commit adds some additional performance test cases to
bench-memcmp.c and test-memcmp.c. The new benchtests include some
medium range sizes, as well as small sizes near page cross. The new
correctness tests correspond with the new benchtests though add some
additional cases for checking the page cross logic.

Signed-off-by: Noah Goldstein <goldstein.w.n@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agolinux: Fix clock_getres fallback
Adhemerval Zanella [Tue, 18 May 2021 19:59:56 +0000 (16:59 -0300)]
linux: Fix clock_getres fallback

The tst-timespec_getres (e5ac7bd679de5) triggers an issue on 32-bit
architecture on Linux older than 5.1, where the fallback syscall
is used.

Checked on powerpc-linux-gnu.

3 years agoDo not declare asctime_r and ctime_r for C2X
Joseph Myers [Tue, 18 May 2021 19:47:49 +0000 (19:47 +0000)]
Do not declare asctime_r and ctime_r for C2X

ISO C2X added the asctime_r, ctime_r, gmtime_r and localtime_r
functions from POSIX.  It's now removed asctime_r and ctime_r again,
reflecting that they are marked obsolescent in POSIX; update glibc's
time.h accordingly.

The same change that removed those two functions from C2X also marked
asctime and ctime as deprecated (reflecting how POSIX shows them as
obsolescent), i.e. using the [[deprecated]] attribute in the
prototypes shown in C2X.  It's less clear if we should explicitly
deprecate those functions like that in the glibc headers; this patch
does nothing regarding such a deprecation (there's no normative
requirement from C2X showing the functions as deprecated).

Tested for x86_64 and x86.

3 years agohtl: Add __libpthread_freeres
Samuel Thibault [Tue, 18 May 2021 17:39:44 +0000 (17:39 +0000)]
htl: Add __libpthread_freeres

3 years agohurd: Add execveat
Samuel Thibault [Mon, 17 May 2021 23:47:47 +0000 (23:47 +0000)]
hurd: Add execveat

3 years agoFix stringop-overflow warning in bug-regex19.c.
Stefan Liebler [Mon, 17 May 2021 14:19:36 +0000 (16:19 +0200)]
Fix stringop-overflow warning in bug-regex19.c.

Starting with commit
26492c0a14966c32c43cd6ca1d0dca5e62c6cfef
"Annotate additional APIs with GCC attribute access.",
gcc emits this warning on s390x:
In function 'do_one_test',
    inlined from 'do_mb_tests' at bug-regex19.c:385:11:
bug-regex19.c:271:9: error: 're_search' specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  271 |   res = re_search (&regbuf, test->string, strlen (test->string),
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  272 |      test->start, strlen (test->string) - test->start, NULL);
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/regex.h:2,
                 from bug-regex19.c:22:
bug-regex19.c: In function 'do_mb_tests':
../posix/regex.h:554:17: note: in a call to function 're_search' declared with attribute 'read_only (2, 3)'
  554 | extern regoff_t re_search (struct re_pattern_buffer *__buffer,
      |                 ^~~~~~~~~
...

The function do_one_test is inlined into do_mb_tests on s390x (at least with
gcc 10).  If do_one_test is marked with __attribute__ ((noinline)), there are
no warnings on s390x. If do_one_test is marked with
__attribute__ ((always_inline)), there are the same warnings on x86_64.

test->string points to a variable length array on stack of do_mb_tests
and the content is generated based on the passed test struct.

According to Martin Sebor, this is a false positive caused by the same bug as
the one in nss/makedb.c.  It's fixed in GCC 11 and will also be available in
the next GCC 10.4 release.

3 years agolocaledata: Use U+00AF MACRON in more EBCDIC charsets [BZ #27882]
Florian Weimer [Tue, 18 May 2021 05:21:33 +0000 (07:21 +0200)]
localedata: Use U+00AF MACRON in more EBCDIC charsets [BZ #27882]

This updates IBM256, IBM277, IBM278, IBM280, IBM284, IBM297, IBM424
in the same way that IBM273 was updated for bug 23290.

IBM256 and IBM424 still have holes after this change, so HAS_HOLES
is not updated.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoldconfig: Avoid boolean coercion of opt_chroot
Siddhesh Poyarekar [Tue, 18 May 2021 04:04:04 +0000 (09:34 +0530)]
ldconfig: Avoid boolean coercion of opt_chroot

Generated code is unchanged.

3 years agoldconfig: Fix memory leaks
Siddhesh Poyarekar [Tue, 18 May 2021 03:59:02 +0000 (09:29 +0530)]
ldconfig: Fix memory leaks

Coverity discovered that paths allocated by chroot_canon are not freed
in a couple of routines in ldconfig.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agocharmap_conversion: Free conversion table on exit
Siddhesh Poyarekar [Tue, 18 May 2021 03:53:48 +0000 (09:23 +0530)]
charmap_conversion: Free conversion table on exit

The conversion table is allocated using xcalloc but never freed.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf/cache.c: Fix resource leaks identified by static analyzers
Siddhesh Poyarekar [Tue, 18 May 2021 03:38:41 +0000 (09:08 +0530)]
elf/cache.c: Fix resource leaks identified by static analyzers

A coverity run identified a number of resource leaks in cache.c.
There are a couple of simple memory leaks where a local allocation is
not freed before function return.  Then there is a mmap leak and a
file descriptor leak where a map is not unmapped in the error case and
a file descriptor remains open respectively.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoshow_archive_content: Fix trivial memory leak
Siddhesh Poyarekar [Tue, 18 May 2021 03:37:06 +0000 (09:07 +0530)]
show_archive_content: Fix trivial memory leak

Fix trivial leak identified by coverity.  The program runs to exit and
the leak doesn't grow, but it's just cleaner to free the allocated
memory.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoAdd C2X timespec_getres
Joseph Myers [Mon, 17 May 2021 20:55:21 +0000 (20:55 +0000)]
Add C2X timespec_getres

ISO C2X adds a timespec_getres function alongside the C11
timespec_get, with functionality similar to that of POSIX clock_getres
(including allowing a NULL pointer to be passed to the function).
Implement this function for glibc, similarly to the implementation of
timespec_get.

This includes a basic test like that of timespec_get, but no
documentation in the manual, given that TIME_UTC and timespec_get
aren't documented in the manual at all.  The handling of 64-bit time
follows that in timespec_get; people maintaining patch series for
64-bit time will need to update them accordingly (to export
__timespec_getres64, redirect calls in time.h and run the test for
_TIME_BITS=64).

Tested for x86_64 and x86, and (previous version; only testcase
differs) with build-many-glibcs.py.

3 years agoMissing ENOMEM in realloc_check wrapper (bug 27870)
Andreas Schwab [Mon, 17 May 2021 12:00:19 +0000 (14:00 +0200)]
Missing ENOMEM in realloc_check wrapper (bug 27870)

When MALLOC_CHECK_ is non-zero, the realloc hook missed to set errno to
ENOMEM when called with too big size.  Run the test tst-malloc-too-large
also with MALLOC_CHECK_=3 to catch that.

3 years agobenchtests: Use JSON for bench-rawmemchr output
Matheus Castanho [Wed, 12 May 2021 14:27:16 +0000 (11:27 -0300)]
benchtests: Use JSON for bench-rawmemchr output

Convert the output of benchtests/bench-rawmemchr to JSON like other string
benchmarks.  This makes the output more parseable and allows usage of
compare_strings.py, for example.

Reviewed-by: Lucas A. M. Magalhaes <lamm@linux.ibm.com>
3 years agopowerpc: Add optimized rawmemchr for POWER10
Matheus Castanho [Tue, 11 May 2021 20:53:07 +0000 (17:53 -0300)]
powerpc: Add optimized rawmemchr for POWER10

Reuse code for optimized strlen to implement a faster version of rawmemchr.
This takes advantage of the same benefits provided by the strlen implementation,
but needs some extra steps. __strlen_power10 code should be unchanged after this
change.

rawmemchr returns a pointer to the char found, while strlen returns only the
length, so we have to take that into account when preparing the return value.

To quickly check 64B, the loop on __strlen_power10 merges the whole block into
16B by using unsigned minimum vector operations (vminub) and checks if there are
any \0 on the resulting vector. The same code is used by rawmemchr if the char c
is 0. However, this approach does not work when c != 0.  We first need to
subtract each byte by c, so that the value we are looking for is converted to a
0, then taking the minimum and checking for nulls works again.

The new code branches after it has compared ~256 bytes and chooses which of the
two strategies above will be used in the main loop, based on the char c. This
extra branch adds some overhead (~5%) for length ~256, but is quickly amortized
by the faster loop for larger sizes.

Compared to __rawmemchr_power9, this version is ~20% faster for length < 256.
Because of the optimized main loop, the improvement becomes ~35% for c != 0
and ~50% for c = 0 for strings longer than 256.

Reviewed-by: Lucas A. M. Magalhaes <lamm@linux.ibm.com>
Reviewed-by: Raphael M Zinsly <rzinsly@linux.ibm.com>
3 years agonptl: Move pthread_sigqueue into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move pthread_sigqueue into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

The GLIBC_2.11 version is now empty, so add a placeholder symbol.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_setschedprio into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move pthread_setschedprio into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

The GLIBC_2.3.4 version is now empty, so add a placeholder symbol.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_setname_np into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move pthread_setname_np into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Add __libpthread_version_placeholder@@GLIBC_2.12 for the targets
that need it.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_setaffinity_np into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move pthread_setaffinity_np into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_getname_np into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move pthread_getname_np into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_getcpuclockid into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move pthread_getcpuclockid into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

__libpthread_version_placeholder@@GLIBC_2.2 is needed by this change;
the Versions entry for GLIBC_2.2 in libpthread had leftover symbols
due to an error in a previous conflict resolution.  The condition
for the placeholder symbol is complicated because some architectures
have earlier symbols at the GLIBC_2.2 symbol versions, so the
placeholder is not required there (yet).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Replace pthread_getcpuclockid with Linux implementation
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Replace pthread_getcpuclockid with Linux implementation

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_getattr_default_np into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move pthread_getattr_default_np into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

A new placeholder symbol __libpthread_version_placeholder@GLIBC_2.18
is needed to keep the GLIBC_2.18 symbol version in libpthread.
The __pthread_getattr_default_np@@GLIBC_PRIVATE export is used
from pthread_create.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Move static TLS size and alignment into _rtld_global_ro
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
elf: Move static TLS size and alignment into _rtld_global_ro

This helps to clarify that the caching of these fields in libpthread
(in __static_tls_size, __static_tls_align_m1) is unnecessary.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Remove DL_STATIC_INIT
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
elf: Remove DL_STATIC_INIT

All users have been converted to the __rtld_static_init mechanism.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agopowerpc: Remove _dl_var_init
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
powerpc: Remove _dl_var_init

The generic __rtld_static_init code handles GLRO (dl_pagesize),
GLRO (dl_auxv), GLRO (dl_hwcap), GLRO (dl_hwcap2).
GLRO (dl_cache_line_size) is handled in an __rtld_static_init_arch
override.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agomips: Remove _dl_var_init
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
mips: Remove _dl_var_init

The generic __rtld_static_init code handles GLRO (dl_pagesize).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agom68k: Remove _dl_var_init
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
m68k: Remove _dl_var_init

The generic __rtld_static_init code handles GLRO (dl_pagesize).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoia64: Remove _dl_var_init
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
ia64: Remove _dl_var_init

The generic __rtld_static_init code handles GLRO (dl_pagesize)
and GLRO (dl_clktck).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoarc: Remove _dl_var_init
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
arc: Remove _dl_var_init

The generic __rtld_static_init code handles GLRO (dl_pagesize).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoaarch64: Remove _dl_var_init
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
aarch64: Remove _dl_var_init

The generic __rtld_static_init code handles GLRO (dl_pagesize).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Partially initialize ld.so after static dlopen (bug 20802)
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
elf: Partially initialize ld.so after static dlopen (bug 20802)

After static dlopen, a copy of ld.so is loaded into the inner
namespace, but that copy is not initialized at all.  Some
architectures run into serious problems as result, which is why the
_dl_var_init mechanism was invented.  With libpthread moving into
libc and parts into ld.so, more architectures impacted, so it makes
sense to switch to a generic mechanism which performs the partial
initialization.

As a result, getauxval now works after static dlopen (bug 20802).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __nptl_create_event, __nptl_death_event into libc
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move __nptl_create_event, __nptl_death_event into libc

In libthread_db, use the exported GLIBC_PRIVATE symbols directly
instead of relying on _thread_db_* variables in libpthread
(which used to be created by the DB_FUNCTION macros).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __nptl_initial_report_events into ld.so/startup code
Florian Weimer [Mon, 17 May 2021 07:59:14 +0000 (09:59 +0200)]
nptl: Move __nptl_initial_report_events into ld.so/startup code

The initialization of the report_events TCB field is now performed
in __tls_init_tp instead of __pthread_initialize_minimal_internal
(in libpthread).

The events interface is difficult to test because GDB stopped using it
in 2015.  The td_thr_get_info change to ignore lookup issues is enough
to support GDB with this change.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoEnable support for GCC 11 -Wmismatched-dealloc.
Martin Sebor [Sun, 16 May 2021 21:21:18 +0000 (15:21 -0600)]
Enable support for GCC 11 -Wmismatched-dealloc.

To help detect common kinds of memory (and other resource) management
bugs, GCC 11 adds support for the detection of mismatched calls to
allocation and deallocation functions.  At each call site to a known
deallocation function GCC checks the set of allocation functions
the former can be paired with and, if the two don't match, issues
a -Wmismatched-dealloc warning (something similar happens in C++
for mismatched calls to new and delete).  GCC also uses the same
mechanism to detect attempts to deallocate objects not allocated
by any allocation function (or pointers past the first byte into
allocated objects) by -Wfree-nonheap-object.

This support is enabled for built-in functions like malloc and free.
To extend it beyond those, GCC extends attribute malloc to designate
a deallocation function to which pointers returned from the allocation
function may be passed to deallocate the allocated objects.  Another,
optional argument designates the positional argument to which
the pointer must be passed.

This change is the first step in enabling this extended support for
Glibc.

3 years agonptl: Fix tst-pthread-gdb-attach for ptrace_scope equal 1
Adhemerval Zanella [Wed, 12 May 2021 17:24:46 +0000 (14:24 -0300)]
nptl: Fix tst-pthread-gdb-attach for ptrace_scope equal 1

This is similar to the fix for elf/tst-pldd (2f9046fb059e94fe25):
it checks ptrace_scope value (values higher than 2 are too restrictive
to allow the test to run) and it rearranges the spawned processes
to make the target process the gdb child.

Checked on x86_64-linux-gnu with ptrace_scope set to 1.

3 years agostdlib: Fix data race in __run_exit_handlers [BZ #27749]
Vitaly Buka [Mon, 26 Apr 2021 19:27:29 +0000 (12:27 -0700)]
stdlib: Fix data race in __run_exit_handlers [BZ #27749]

Keep __exit_funcs_lock almost all the time and unlock it only to execute
callbacks. This fixed two issues.

1. f->func.cxa was modified outside the lock with rare data race like:
thread 0: __run_exit_handlers unlock __exit_funcs_lock
thread 1: __internal_atexit locks __exit_funcs_lock
thread 0: f->flavor = ef_free;
thread 1: sees ef_free and use it as new
thread 1: new->func.cxa.fn = (void (*) (void *, int)) func;
thread 1: new->func.cxa.arg = arg;
thread 1: new->flavor = ef_cxa;
thread 0: cxafct = f->func.cxa.fn;  // it's wrong fn!
thread 0: cxafct (f->func.cxa.arg, status);  // it's wrong arg!
thread 0: goto restart;
thread 0: call the same exit_function again as it's ef_cxa

2. Don't unlock in main while loop after *listp = cur->next. If *listp
   is NULL and __exit_funcs_done is false another thread may fail in
   __new_exitfn on assert (l != NULL):
 thread 0: *listp = cur->next;  // It can be the last: *listp = NULL.
 thread 0: __libc_lock_unlock
 thread 1: __libc_lock_lock in __on_exit
 thread 1: __new_exitfn
 thread 1: if (__exit_funcs_done)  // false: thread 0 isn't there yet.
 thread 1: l = *listp
 thread 1: moves one and crashes on assert (l != NULL);

The test needs multiple iterations to consistently fail without the fix.

Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=27749

Checked on x86_64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoMake sysdeps/generic/libc.abilist empty
Joseph Myers [Thu, 13 May 2021 21:28:17 +0000 (21:28 +0000)]
Make sysdeps/generic/libc.abilist empty

The __libc_single_threaded symbol was accidentally added to this file
in commit 706ad1e7af37be1d25fc2359bda006d31fe0d11b.

3 years agosupport: Free gdb_script_name
Siddhesh Poyarekar [Wed, 12 May 2021 04:36:32 +0000 (10:06 +0530)]
support: Free gdb_script_name

Identified by static analysis.

3 years agosupport: Close fds in copy_func
Siddhesh Poyarekar [Wed, 12 May 2021 04:43:41 +0000 (10:13 +0530)]
support: Close fds in copy_func

copy_func may leave file descriptors open on error, so close them on
function exit.

3 years agoinet: Free result from getaddrinfo
Siddhesh Poyarekar [Wed, 12 May 2021 11:20:59 +0000 (16:50 +0530)]
inet: Free result from getaddrinfo

Coverity discovered paths where the result from getaddrinfo was not
freed.

3 years agolinux/check_native: Always close socket on return
Siddhesh Poyarekar [Wed, 12 May 2021 03:44:54 +0000 (09:14 +0530)]
linux/check_native: Always close socket on return

The error paths of __check_native would leave the socket FD open on
return, resulting in an FD leak.  Rework function exit paths so that
the fd is always closed on return.

3 years agoRemove all usage of @BASH@ or ${BASH} in installed files, and hardcode /bin/bash...
Romain GEISSLER [Wed, 12 May 2021 02:15:33 +0000 (07:45 +0530)]
Remove all usage of @BASH@ or ${BASH} in installed files, and hardcode /bin/bash instead

(FYI, this is a repost of
https://sourceware.org/pipermail/libc-alpha/2019-July/105035.html now
that FSF papers have been signed and confirmed on FSF side).

This trivial patch attemps to fix BZ 24106. Basically the bash locally
used when building glibc on the host shall not leak on the installed
glibc, as the system where it is installed might be different and use
another bash location.

So I have looked for all occurences of @BASH@ or $(BASH) in installed
files, and replaced it by /bin/bash. This was suggested by Florian
Weimer in the bug report.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonptl: Move pthread_getconcurrency, pthread_setconcurrency into libc
Florian Weimer [Tue, 11 May 2021 18:22:33 +0000 (20:22 +0200)]
nptl: Move pthread_getconcurrency, pthread_setconcurrency into libc

The symbols were moved using scripts/move-symbol-to-libc.py,
in one commit due to their dependency on the internal
__concurrency_level variable.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_cancel into libc
Florian Weimer [Tue, 11 May 2021 09:56:37 +0000 (11:56 +0200)]
nptl: Move pthread_cancel into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __pthread_register_cancel_defer, __pthread_unregister_cancel_restore to...
Florian Weimer [Tue, 11 May 2021 09:52:56 +0000 (11:52 +0200)]
nptl: Move __pthread_register_cancel_defer, __pthread_unregister_cancel_restore to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move __pthread_register_cancel, __pthread_unregister_cancel to libc
Florian Weimer [Tue, 11 May 2021 09:38:46 +0000 (11:38 +0200)]
nptl: Move __pthread_register_cancel, __pthread_unregister_cancel to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Also clean up some unwinder linking leftover in the same spot
in nptl/pthreadP.h.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_setstacksize into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_setstacksize into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

It is necessary to arrange for a
__libpthread_version_placeholder@GLIBC_2.6 on some of the powerpc
targets.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_setstackaddr into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_setstackaddr into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_setstack into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_setstack into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_setguardsize into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_setguardsize into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_getstacksize into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_getstacksize into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_getstackaddr into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_getstackaddr into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_getstack into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_getstack into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_getguardsize into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_getguardsize into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Move pthread_attr_getaffinity_np into libc
Florian Weimer [Tue, 11 May 2021 17:32:43 +0000 (19:32 +0200)]
nptl: Move pthread_attr_getaffinity_np into libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoelf: Fix DTV gap reuse logic [BZ #27135]
Szabolcs Nagy [Thu, 31 Dec 2020 13:59:38 +0000 (13:59 +0000)]
elf: Fix DTV gap reuse logic [BZ #27135]

For some reason only dlopen failure caused dtv gaps to be reused.

It is possible that the intent was to never reuse modids for a
different module, but after dlopen failure all gaps are reused
not just the ones caused by the unfinished dlopened.

So the code has to handle reused modids already which seems to
work, however the data races at thread creation and tls access
(see bug 19329 and bug 27111) may be more severe if slots are
reused so this is scheduled after those fixes. I think fixing
the races are not simpler if reuse is disallowed and reuse has
other benefits, so set GL(dl_tls_dtv_gaps) whenever entries are
removed from the middle of the slotinfo list. The value does
not have to be correct: incorrect true value causes the next
modid query to do a slotinfo walk, incorrect false will leave
gaps and new entries are added at the end.

Fixes bug 27135.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>