glibc/sysdeps/s390
Stefan Liebler 89b638f48a S390: Enable static PIE
This commit enables static PIE on 64bit.  On 31bit, static PIE is
not supported.

A new configure check in sysdeps/s390/s390-64/configure.ac also performs
a minimal test for requirements in ld:
Ensure you also have those patches for:
- binutils (ld)
  - "[PR ld/22263] s390: Avoid dynamic TLS relocs in PIE"
    https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=26b1426577b5dcb32d149c64cca3e603b81948a9
    (Tested by configure check above)
    Otherwise there will be a R_390_TLS_TPOFF relocation, which fails to
    be processed in _dl_relocate_static_pie() as static TLS map is not setup.
  - "s390: Add DT_JMPREL pointing to .rela.[i]plt with static-pie"
    https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=d942d8db12adf4c9e5c7d9ed6496a779ece7149e
    (We can't test it in configure as we are not able to link a static PIE
    executable if the system glibc lacks static PIE support)
    Otherwise there won't be DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ entries
    and the IFUNC symbols are not processed, which leads to crashes.

- kernel (the mentioned links to the commits belong to 5.19 merge window):
  - "s390/mmap: increase stack/mmap gap to 128MB"
    https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=f2f47d0ef72c30622e62471903ea19446ea79ee2
  - "s390/vdso: move vdso mapping to its own function"
    https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=57761da4dc5cd60bed2c81ba0edb7495c3c740b8
  - "s390/vdso: map vdso above stack"
    https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=9e37a2e8546f9e48ea76c839116fa5174d14e033
  - "s390/vdso: add vdso randomization"
    https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/commit/?h=features&id=41cd81abafdc4e58a93fcb677712a76885e3ca25
  (We can't test the kernel of the target system)
  Otherwise if /proc/sys/kernel/randomize_va_space is turned off (0),
  static PIE executables like ldconfig will crash.  While startup sbrk is
  used to enlarge the HEAP.  Unfortunately the underlying brk syscall fails
  as there is not enough space after the HEAP.  Then the address of the TLS
  image is invalid and the following memcpy in __libc_setup_tls() leads
  to a segfault.
  If /proc/sys/kernel/randomize_va_space is activated (default: 2), there
  is enough space after HEAP.

- glibc
  - "Linux: Define MMAP_CALL_INTERNAL"
    https://sourceware.org/git/?p=glibc.git;a=commit;h=c1b68685d438373efe64e5f076f4215723004dfb
  - "i386: Remove OPTIMIZE_FOR_GCC_5 from Linux libc-do-syscall.S"
    https://sourceware.org/git/?p=glibc.git;a=commit;h=6e5c7a1e262961adb52443ab91bd2c9b72316402
  - "i386: Honor I386_USE_SYSENTER for 6-argument Linux system calls"
    https://sourceware.org/git/?p=glibc.git;a=commit;h=60f0f2130d30cfd008ca39743027f1e200592dff
  - "ia64: Always define IA64_USE_NEW_STUB as a flag macro"
    https://sourceware.org/git/?p=glibc.git;a=commit;h=18bd9c3d3b1b6a9182698c85354578d1d58e9d64
  - "Linux: Implement a useful version of _startup_fatal"
    https://sourceware.org/git/?p=glibc.git;a=commit;h=a2a6bce7d7e52c1c34369a7da62c501cc350bc31
  - "Linux: Introduce __brk_call for invoking the brk system call"
    https://sourceware.org/git/?p=glibc.git;a=commit;h=b57ab258c1140bc45464b4b9908713e3e0ee35aa
  - "csu: Implement and use _dl_early_allocate during static startup"
    https://sourceware.org/git/?p=glibc.git;a=commit;h=f787e138aa0bf677bf74fa2a08595c446292f3d7
  The mentioned patch series by Florian Weimer avoids the mentioned failing
  sbrk syscall by falling back to mmap.

This commit also adjusts startup code in start.S to be ready for static PIE.
We have to add a wrapper function for main as we are not allowed to use
GOT relocations before __libc_start_main is called.
(Compare also to:
- commit 14d886edbd
  "aarch64: fix start code for static pie"
- commit 3d1d79283e
  "aarch64: fix static pie enabled libc when main is in a shared library"
)

(cherry picked from commit 728894dba4)
2022-05-19 17:15:57 +02:00
..
bits
fpu s390x: Update math: redirect roundeven function 2021-06-29 09:07:14 +02:00
multiarch S390: Also check vector support in memmove ifunc-selector [BZ #27511] 2021-03-26 10:51:31 +01:00
nptl nptl: Remove remaining code from libpthread 2021-05-21 22:35:01 +02:00
s390-32 elf: Add _dl_audit_pltexit 2022-04-08 14:18:12 -04:00
s390-64 S390: Enable static PIE 2022-05-19 17:15:57 +02:00
abort-instr.h
asm-syntax.h
atomic-machine.h
bzero.c
configure configure: Replaced obsolete AC_TRY_COMPILE 2021-06-04 10:16:00 -03:00
configure.ac configure: Replaced obsolete AC_TRY_COMPILE 2021-06-04 10:16:00 -03:00
dl-irel.h
dl-procinfo.c S390: Add new s390 platform z16. 2022-04-14 14:21:57 +02:00
dl-procinfo.h S390: Add new s390 platform z16. 2022-04-14 14:21:57 +02:00
dl-tls.h
elf-initfini.h
ffs.c
fix-fp-int-convert-overflow.h
gccframe.h
gconv-modules-s390.conf iconvdata: Move gconv-modules configuration to gconv-modules.conf 2021-06-09 09:47:16 +05:30
hp-timing.h
ifunc-memccpy.h
ifunc-memchr.h
ifunc-memcmp.h
ifunc-memcpy.h
ifunc-memmem.h
ifunc-memrchr.h
ifunc-memset.h
ifunc-rawmemchr.h
ifunc-stpcpy.h
ifunc-stpncpy.h
ifunc-strcat.h
ifunc-strchr.h
ifunc-strchrnul.h
ifunc-strcmp.h
ifunc-strcpy.h
ifunc-strcspn.h
ifunc-strlen.h
ifunc-strncat.h
ifunc-strncmp.h
ifunc-strncpy.h
ifunc-strnlen.h
ifunc-strpbrk.h
ifunc-strrchr.h
ifunc-strspn.h
ifunc-strstr.h
ifunc-wcpcpy.h
ifunc-wcpncpy.h
ifunc-wcscat.h
ifunc-wcschr.h
ifunc-wcschrnul.h
ifunc-wcscmp.h
ifunc-wcscpy.h
ifunc-wcscspn.h
ifunc-wcslen.h
ifunc-wcsncat.h
ifunc-wcsncmp.h
ifunc-wcsncpy.h
ifunc-wcsnlen.h
ifunc-wcspbrk.h
ifunc-wcsrchr.h
ifunc-wcsspn.h
ifunc-wmemchr.h
ifunc-wmemcmp.h
ifunc-wmemset.h
Implies
iso-8859-1_cp037_z900.c
jmpbuf-offsets.h
jmpbuf-unwind.h
ldsodefs.h
libc-tls.c
linkmap.h
longjmp.c
machine-gmon.h
Makefile iconvdata: Move gconv-modules configuration to gconv-modules.conf 2021-06-09 09:47:16 +05:30
memccpy-c.c
memccpy-vx.S
memccpy.c
memchr-vx.S
memchr-z900.S s390: Fix MEMCHR_Z900_G5 ifunc-variant if n>=0x80000000 [BZ #28024] 2021-07-01 16:46:59 +02:00
memchr.c
memcmp-z900.S
memcmp.c
memcopy.h
memcpy-z900.S
memcpy.c
memmem-arch13.S s390: Use long branches across object boundaries (jgh instead of jh) 2021-11-10 15:22:24 +01:00
memmem-c.c
memmem-vx.c
memmem.c
memmove-c.c
memmove.c S390: Also check vector support in memmove ifunc-selector [BZ #27511] 2021-03-26 10:51:31 +01:00
mempcpy.c
memrchr-c.c
memrchr-vx.S
memrchr.c
memset-z900.S
memset.c
memusage.h
preconfigure
rawmemchr-c.c
rawmemchr-vx.S
rawmemchr.c
sotruss-lib.c
stackinfo.h
stpcpy-c.c
stpcpy-vx.S
stpcpy.c
stpncpy-c.c
stpncpy-vx.S
stpncpy.c
strcat-c.c
strcat-vx.S
strcat.c
strchr-c.c
strchr-vx.S
strchr.c
strchrnul-c.c
strchrnul-vx.S
strchrnul.c
strcmp-vx.S
strcmp-z900.S
strcmp.c
strcpy-vx.S
strcpy-z900.S
strcpy.c
strcspn-c.c
strcspn-vx.S
strcspn.c
string_private.h
strlen-c.c
strlen-vx.S
strlen.c
strncat-c.c
strncat-vx.S
strncat.c
strncmp-c.c
strncmp-vx.S
strncmp.c
strncpy-vx.S
strncpy.c
strnlen-c.c
strnlen-vx.S
strnlen.c
strpbrk-c.c
strpbrk-vx.S
strpbrk.c
strrchr-c.c
strrchr-vx.S
strrchr.c
strspn-c.c
strspn-vx.S
strspn.c
strstr-arch13.S s390: Use long branches across object boundaries (jgh instead of jh) 2021-11-10 15:22:24 +01:00
strstr-c.c
strstr-vx.c
strstr.c
tst-dl-runtime-mod.S
tst-dl-runtime-profile-audit.c
tst-dl-runtime-profile-noaudit.c
tst-dl-runtime-resolve-audit.c
tst-dl-runtime-resolve-noaudit.c
tst-dl-runtime.c
unwind-arch.h
utf8-utf16-z9.c
utf8-utf32-z9.c
utf16-utf32-z9.c
Versions
wcpcpy-c.c
wcpcpy-vx.S
wcpcpy.c
wcpncpy-c.c
wcpncpy-vx.S
wcpncpy.c
wcscat-c.c
wcscat-vx.S
wcscat.c
wcschr-c.c
wcschr-vx.S
wcschr.c
wcschrnul-c.c
wcschrnul-vx.S
wcschrnul.c
wcscmp-c.c
wcscmp-vx.S
wcscmp.c
wcscpy-c.c
wcscpy-vx.S
wcscpy.c
wcscspn-c.c
wcscspn-vx.S
wcscspn.c
wcslen-c.c
wcslen-vx.S
wcslen.c
wcsncat-c.c
wcsncat-vx.S
wcsncat.c
wcsncmp-c.c
wcsncmp-vx.S
wcsncmp.c
wcsncpy-c.c
wcsncpy-vx.S
wcsncpy.c
wcsnlen-c.c
wcsnlen-vx.S
wcsnlen.c
wcspbrk-c.c
wcspbrk-vx.S
wcspbrk.c
wcsrchr-c.c
wcsrchr-vx.S
wcsrchr.c
wcsspn-c.c
wcsspn-vx.S
wcsspn.c
wmemchr-c.c
wmemchr-vx.S
wmemchr.c
wmemcmp-c.c
wmemcmp-vx.S
wmemcmp.c
wmemset-c.c
wmemset-vx.S
wmemset.c