Commit Graph

11738 Commits

Author SHA1 Message Date
Stan Shebs
d548adb4ef Let time and gettimeofday use vdso by removing old clang workaround 2021-08-27 17:26:04 -07:00
Stan Shebs
2c9e5207e4 Do not use ppc-specific long double pack/unpack when compiling with clang 2021-08-27 17:26:04 -07:00
Stan Shebs
c3064d5f50 Remove old workaround in power7 logb functions, clang no longer crashes on the inline assembly 2021-08-27 17:26:04 -07:00
Josh Kunz
cb90884046 Additional fixes for llvm-as
Unlike GCC, llvm always uses an integrated assembler, which attempts to
recognized all `asm` statements written in the C code. glibc uses some
syntactically invalid asm statements to emit constants into assembly that
are later extracted with a sed or AWK script.

This change fixes two such invalid `asm` statements by wrapping the
output in a `.ascii` directive.. This does not break the sed/AWK (the same
special sequence is output) but it makes the statement syntactically valid.

See cf8e3f8757 for a previous fix for the same issue.
2021-08-27 17:26:04 -07:00
Stan Shebs
144448d566 Add workaround for infinite looping in ppc vsyscall for sched_getcpu. 2021-08-27 17:26:03 -07:00
Stan Shebs
6a12504329 Add an LD_DEBUG=tls option to help debug thread-local storage handling in ld.so 2021-08-27 17:26:03 -07:00
Stan Shebs
c4d57c29b5 Make multi-arch ifunc support work with clang 2021-08-27 17:26:02 -07:00
Ambrose Feinstein
af63681769 Redesign the fastload support for additional performance 2021-08-27 17:26:02 -07:00
Stan Shebs
8d141ab782 Fix sense of a test in the static-linking version of ppc get_clockfreq 2021-08-27 17:26:02 -07:00
Shu-Chun Weng
e1c6d2b0f4 Makes it compile for AArch64
De-nesting fix in 83c02e85 changed function signature but AArch64 was untested.
2021-08-27 17:26:01 -07:00
Shu-Chun Weng
83bede0cfc Makes AArch64 assembly acceptable to clang
According to ARMv8 architecture reference manual section C7.2.188, SIMD MOV (to
general) instruction format is

  MOV <Xd>, <Vn>.D[<index>]

gas appears to accept "<Vn>.2D[<index>]" as well, but clang's assembler does
not. C.f. https://community.arm.com/developer/ip-products/processors/f/cortex-a-forum/5214/aarch64-assembly-syntax-for-armclang
2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
038be62f96 Include STATIC_PIE_BOOTSTRAP with !NESTING in powerpc64/dl-machine.h 2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
738baca865 Enable relaxed relocations when building certain object files for x86_64. 2021-08-27 17:26:01 -07:00
Siva Chandra Reddy
0337af1396 Un-nest an include in dl-reloc-static-pie.c.
A corresponding adjustment in sysdeps/x86_64/dl-machine.h has also been
made.
2021-08-27 17:26:01 -07:00
Stan Shebs
43afb70033 Disable -mfloat128 for clang, lets power9 insns into power8 executables 2021-08-27 17:26:00 -07:00
Stan Shebs
895947a3ca Also work around clang bctrl issue in get_clockfreq.c 2021-08-27 17:26:00 -07:00
Raman Tenneti
9e8081d123 Changes to compile glibc-2.27 on PPC (Power8) with clang.
+ Use DOT_MACHINE macro instead of ".machine" instruction.
+ Use __isinf and __isinff instead of builtin versions.
+ In s_logb, s_logbf and s_logbl functions, used float versions to
  calculate "ret = x & 0x7f800000;" expression.
2021-08-27 17:23:15 -07:00
Raman Tenneti
bb9e16c6ea Undid the dl_enable_fastload environment variable changes. 2021-08-27 17:23:15 -07:00
Paul Pluzhnikov
590786950c Add "fastload" support. 2021-08-27 17:23:15 -07:00
Stan Shebs
3372bfe221 Work around lack of mfppr in clang 2021-08-27 17:23:14 -07:00
Stan Shebs
960ba7975c Work around mtfsb0 syntax limitation with clang 2021-08-27 17:23:14 -07:00
Stan Shebs
e04e10b431 Avoid passing gcc-specific options to clang 2021-08-27 17:23:14 -07:00
Stan Shebs
452fe68a53 Make asm-based constraints be gcc-only 2021-08-27 17:23:14 -07:00
Stan Shebs
4b86f820b8 Make xxland syntax gcc-only 2021-08-27 17:23:14 -07:00
Stan Shebs
5e4f72b895 Add a first approximation of float definitions for ppc clang 2021-08-27 17:23:14 -07:00
Stan Shebs
e21102f77e Make powerpc .machine directives be gcc-only 2021-08-27 17:23:14 -07:00
Stan Shebs
bb112e11de Make mutex hints gcc-only, improve a type in __arch_compare_and_exchange_bool_32_acq 2021-08-27 17:23:14 -07:00
Stan Shebs
7724302310 Make power6 directives be gcc-only 2021-08-27 17:23:13 -07:00
Stan Shebs
1e88b203b3 Add power9 flag to go with -mfloat128 2021-08-27 17:23:13 -07:00
Stan Shebs
6fd7bec86f Disable more attempts to pass -mlong-double-128 to clang 2021-08-27 17:23:13 -07:00
Stan Shebs
d21dfbccdc Disable attempts to pass -mlong-double-128 to clang 2021-08-27 17:23:13 -07:00
Stan Shebs
b2d69ea7ac Add workaround for infinite looping in ppc vsyscalls 2021-08-27 17:23:13 -07:00
Stan Shebs
6ea6782b69 Work around clang crash by skipping apparently-unneeded asm 2021-08-27 17:23:13 -07:00
Stan Shebs
b35774068a Work around clang problem with ifuncs and vdso 2021-08-27 17:23:12 -07:00
Stan Shebs
96509a9dce Work around a ppc clang inlining bug 2021-08-27 17:23:12 -07:00
Stan Shebs
0f93e3333f Change de-nesting fix to use added argument instead of globals 2021-08-27 17:23:12 -07:00
Stan Shebs
21991760c7 Fix regressions in async-safe TLS, add run-time control for debugging, add more comments 2021-08-27 17:23:12 -07:00
Stan Shebs
c0ab16f8cc Fix TLS problems not handled by cherrypick 2021-08-27 17:23:12 -07:00
Brooks Moses
3e9a530aae Revert upstream removal of async-safe TLS patches. 2021-08-27 17:23:11 -07:00
Andreas Schwab
c4fde9669a Don't write beyond destination in __mempcpy_avx512_no_vzeroupper (bug 23196)
When compiled as mempcpy, the return value is the end of the destination
buffer, thus it cannot be used to refer to the start of it.

(cherry picked from commit 9aaaab7c6e)
2021-08-27 16:22:13 -07:00
Stefan Liebler
b3356fb4a1 Fix blocking pthread_join. [BZ #23137]
On s390 (31bit) if glibc is build with -Os, pthread_join sometimes
blocks indefinitely. This is e.g. observable with
testcase intl/tst-gettext6.

pthread_join is calling lll_wait_tid(tid), which performs the futex-wait
syscall in a loop as long as tid != 0 (thread is alive).

On s390 (and build with -Os), tid is loaded from memory before
comparing against zero and then the tid is loaded a second time
in order to pass it to the futex-wait-syscall.
If the thread exits in between, then the futex-wait-syscall is
called with the value zero and it waits until a futex-wake occurs.
As the thread is already exited, there won't be a futex-wake.

In lll_wait_tid, the tid is stored to the local variable __tid,
which is then used as argument for the futex-wait-syscall.
But unfortunately the compiler is allowed to reload the value
from memory.

With this patch, the tid is loaded with atomic_load_acquire.
Then the compiler is not allowed to reload the value for __tid from memory.

ChangeLog:

	[BZ #23137]
	* sysdeps/nptl/lowlevellock.h (lll_wait_tid):
	Use atomic_load_acquire to load __tid.

(cherry picked from commit 1660901840)
2021-08-27 16:22:12 -07:00
Joseph Myers
1ab675ca63 Add PTRACE_SECCOMP_GET_METADATA from Linux 4.16 to sys/ptrace.h.
This patch adds the PTRACE_SECCOMP_GET_METADATA constant from Linux
4.16 to all relevant sys/ptrace.h files.  A type struct
__ptrace_seccomp_metadata, analogous to other such types, is also
added.

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

	* sysdeps/unix/sysv/linux/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): New enum value and macro.
	* sysdeps/unix/sysv/linux/bits/ptrace-shared.h
	(struct __ptrace_seccomp_metadata): New type.
	* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/ptrace.h
	(PTRACE_SECCOMP_GET_METADATA): Likewise.

(cherry picked from commit 9320ca88a1)
2021-08-27 16:22:11 -07:00
H.J. Lu
c01dc8b1ff Update RWF_SUPPORTED for Linux kernel 4.16 [BZ #22947]
Add RWF_APPEND to RWF_SUPPORTED to support Linux kernel 4.16.

	[BZ #22947]
	* bits/uio-ext.h (RWF_APPEND): New.
	* sysdeps/unix/sysv/linux/bits/uio-ext.h (RWF_APPEND): Likewise.
	* manual/llio.texi: Document RWF_APPEND.
	* misc/tst-preadvwritev2-common.c (RWF_APPEND): New.
	(RWF_SUPPORTED): Add RWF_APPEND.

(cherry picked from commit f2652643d7)
2021-08-27 16:22:10 -07:00
Jesse Hathaway
dadc309087 getlogin_r: return early when linux sentinel value is set
When there is no login uid Linux sets /proc/self/loginid to the sentinel
value of, (uid_t) -1. If this is set we can return early and avoid
needlessly looking up the sentinel value in any configured nss
databases.

Checked on aarch64-linux-gnu.

	* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid): Return
	early when linux sentinel value is set.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit cc8a1620eb)
2021-08-27 16:22:10 -07:00
Aurelien Jarno
b88e5137e6 RISC-V: fix struct kernel_sigaction to match the kernel version [BZ #23069]
The RISC-V kernel doesn't define SA_RESTORER, hence the kernel version
of struct sigaction doesn't have the sa_restorer field. The default
kernel_sigaction.h therefore can't be used.

This patch adds a RISC-V specific version of kernel_sigaction.h to fix
the issue. This fixes for example the libnih testsuite.

Note that this patch is not needed in master as the bug has been fixed
by commit b4a5d26d88 ("linux: Consolidate sigaction implementation").
2021-08-27 16:22:08 -07:00
Florian Weimer
80153017d1 Linux i386: tst-bz21269 triggers SIGBUS on some kernels
In addition to SIGSEGV and SIGILL, SIGBUS is also a possible signal
generated by the kernel.

(cherry picked from commit 4d76d3e59d)
2021-08-27 16:22:08 -07:00
Andrew Senkevich
ee056103a0 Fix i386 memmove issue (bug 22644).
[BZ #22644]
	* sysdeps/i386/i686/multiarch/memcpy-sse2-unaligned.S: Fixed
	branch conditions.
	* string/test-memmove.c (do_test2): New testcase.

(cherry picked from commit cd66c0e584)
2021-08-27 16:22:08 -07:00
Andrew Waterman
012483cf93 RISC-V: fmax/fmin: Handle signalling NaNs correctly.
RISC-V's fmax(sNAN,4) returns 4 but glibc expects it to return qNAN.

	* sysdeps/riscv/rvd/s_fmax.c (__fmax): Handle sNaNs correctly.
	* sysdeps/riscv/rvd/s_fmin.c (__fmin): Likewise.
	* sysdeps/riscv/rvf/s_fmaxf.c (__fmaxf): Likewise.
	* sysdeps/riscv/rvf/s_fminf.c (__fminf): Likewise.

(cherry picked from commit fdcc625376)
2021-08-27 16:22:07 -07:00
DJ Delorie
ab9c196492 RISC-V: Do not initialize $gp in TLS macros.
RISC-V TLS doesn't require GP to be initialized, and doing so breaks
TLS in a shared object.

(cherry picked from commit 8090720a87)
2021-08-27 16:22:07 -07:00
Adhemerval Zanella
83d6db8187 i386: Fix i386 sigaction sa_restorer initialization (BZ#21269)
This patch fixes the i386 sa_restorer field initialization for sigaction
syscall for kernel with vDSO.  As described in bug report, i386 Linux
(and compat on x86_64) interprets SA_RESTORER clear with nonzero
sa_restorer as a request for stack switching if the SS segment is 'funny'.
This means that anything that tries to mix glibc's signal handling with
segmentation (for instance through modify_ldt syscall) is randomly broken
depending on what values lands in sa_restorer.

The testcase added  is based on Linux test tools/testing/selftests/x86/ldt_gdt.c,
more specifically in do_multicpu_tests function.  The main changes are:

  - C11 atomics instead of plain access.

  - Remove x86_64 support which simplifies the syscall handling and fallbacks.

  - Replicate only the test required to trigger the issue.

Checked on i686-linux-gnu.

	[BZ #21269]
	* sysdeps/unix/sysv/linux/i386/Makefile (tests): Add tst-bz21269.
	* sysdeps/unix/sysv/linux/i386/sigaction.c (SET_SA_RESTORER): Clear
	sa_restorer for vDSO case.
	* sysdeps/unix/sysv/linux/i386/tst-bz21269.c: New file.

(cherry picked from commit 68448be208)
2017-11-17 16:04:29 -02:00