]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
s390: Adjust configure check for static-pie support.
authorStefan Liebler <stli@linux.ibm.com>
Mon, 11 May 2026 13:22:11 +0000 (15:22 +0200)
committerStefan Liebler <stli@linux.ibm.com>
Wed, 20 May 2026 08:18:14 +0000 (10:18 +0200)
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.

sysdeps/s390/configure
sysdeps/s390/configure.ac

index e21a5ba3a7c84aa4897d9743814bd3c60dd348c3..8731f182bb02ffde2f3dcf5c042b73e6fe7848f6 100644 (file)
@@ -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=\$\
index 3c384f96704109c89759979a0fa31f788632df08..acbd8ebe1105ae14997c27cbfe4614d0ec2d3d43 100644 (file)
@@ -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