[glibc] s390: Adjust configure check for static-pie support.
Stefan Liebler via Glibc-cvs <[email protected]> Wed, 20 May 2026 08:20:24 +0000 (GMT)
| Newsgroups | gmane.comp.lib.glibc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=aadbf5a10acb8c3ebfebe2e245f46e7f44797aa3 commit aadbf5a10acb8c3ebfebe2e245f46e7f44797aa3 Author: Stefan Liebler <[email protected]> Date: Mon May 11 15:22:11 2026 +0200 s390: Adjust configure check for static-pie support. With the previous approach, the configure check fails for lld in version >=19. While binutils and lld 18 is placing the R_390_IRELATIVE relocation in .rela.plt and emits DT_JMPREL pointing to it, newer lld versions puts the R_390_IRELATIVE relocation in .rela.dyn and therefore there is also no DT_JMPREL entry and the configure check claims that lld does not support static-pie. The R_390_IRELATIVE relocation is also processed fine in .rela.dyn, thus the configure check is adjusted. Now the configure checks that it exists a R_390_IRELATIVE relocation at all. If the R_390_IRELATIVE relocation lands in .rela.plt, it ensures that there is DT_JMPREL pointing to it. Otherwise there should be a .rela.dyn section. Diff: --- sysdeps/s390/configure | 30 +++++++++++++++++++++++++----- sysdeps/s390/configure.ac | 13 +++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/sysdeps/s390/configure b/sysdeps/s390/configure index e21a5ba3a7..8731f182bb 100644 --- a/sysdeps/s390/configure +++ b/sysdeps/s390/configure @@ -310,8 +310,10 @@ EOF libc_cv_s390x_staticpie_req_runtime=no # Check if the static linker does not generate dynamic TLS relocs in PIE # (binutils PR ld/22263), if it accepts --no-dynamic-linker - # (by using -static-pie), and if it adds a DT_JMPREL pointing to .rela.iplt - # with static pie. + # (by using -static-pie). + # If the R_390_IRELATIVE relocation lands in .rela.plt, ensure that there is + # DT_JMPREL pointing to it (binutils). Otherwise there should be a .rela.dyn + # without DT_JMPREL (lld>=19). if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest1.c -o conftest1.o' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 (eval $ac_try) 2>&5 @@ -336,16 +338,34 @@ EOF ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; } \ - && { ac_try='LC_ALL=C $READELF -Wd conftest | grep JMPREL >&5' + && { ac_try='LC_ALL=C $READELF -Wr conftest | grep R_390_IRELATIVE >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 (eval $ac_try) 2>&5 ac_status=$? printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } + test $ac_status = 0; }; } \ + && ( { ac_try='LC_ALL=C $READELF -Wr conftest | grep \.rela\.plt >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } \ + && { ac_try='LC_ALL=C $READELF -Wd conftest | grep JMPREL >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } \ + || { ac_try='LC_ALL=C $READELF -Wr conftest | grep \.rela\.dyn >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } ) then libc_cv_s390x_staticpie_req_runtime=yes fi - rm -rf conftest.* ;; + rm -rf conftest* ;; esac fi eval ac_res=\$\ diff --git a/sysdeps/s390/configure.ac b/sysdeps/s390/configure.ac index 3c384f9670..acbd8ebe11 100644 --- a/sysdeps/s390/configure.ac +++ b/sysdeps/s390/configure.ac @@ -169,17 +169,22 @@ EOF libc_cv_s390x_staticpie_req_runtime=no # Check if the static linker does not generate dynamic TLS relocs in PIE # (binutils PR ld/22263), if it accepts --no-dynamic-linker - # (by using -static-pie), and if it adds a DT_JMPREL pointing to .rela.iplt - # with static pie. + # (by using -static-pie). + # If the R_390_IRELATIVE relocation lands in .rela.plt, ensure that there is + # DT_JMPREL pointing to it (binutils). Otherwise there should be a .rela.dyn + # without DT_JMPREL (lld>=19). if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest1.c -o conftest1.o]) \ && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -fPIE -c conftest2.c -o conftest2.o]) \ && AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -static-pie -nostartfiles -nostdlib -fPIE -o conftest conftest1.o conftest2.o]) \ && AC_TRY_COMMAND([! LC_ALL=C $READELF -Wr conftest | grep R_390_TLS_TPOFF] >&AS_MESSAGE_LOG_FD) \ - && AC_TRY_COMMAND([LC_ALL=C $READELF -Wd conftest | grep JMPREL >&AS_MESSAGE_LOG_FD]) + && AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest | grep R_390_IRELATIVE] >&AS_MESSAGE_LOG_FD) \ + && ( AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest | grep \.rela\.plt >&AS_MESSAGE_LOG_FD]) \ + && AC_TRY_COMMAND([LC_ALL=C $READELF -Wd conftest | grep JMPREL >&AS_MESSAGE_LOG_FD]) \ + || AC_TRY_COMMAND([LC_ALL=C $READELF -Wr conftest | grep \.rela\.dyn >&AS_MESSAGE_LOG_FD]) ) then libc_cv_s390x_staticpie_req_runtime=yes fi - rm -rf conftest.*]) + rm -rf conftest*]) if test $libc_cv_s390x_staticpie_req_runtime = yes; then # Some kernels might fail with /proc/sys/kernel/randomize_va_space set to 0