This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] configure: fix STT_GNU_IFUNC support detection with PIE toolchains [BZ #25506]


When GCC defaults to PIE, compiling the conftest.S that is used to
detect for assembler and linker STT_GNU_IFUNC support emits a
relocation. This causes a false positive in the detection.

Example on riscv64 with a toolchain defaulting to PIE:

| configure:4009: checking for assembler and linker STT_GNU_IFUNC support
|
| Relocation section '.rela.dyn' at offset 0x268 contains 1 entry:
|    Offset          Info           Type           Sym. Value    Sym. Name + Addend
| 000000002000  000000000003 R_RISCV_RELATIVE                     280
| configure:4040: result: yes

This is also reproducible on MIPS.

Fix that by compiling conftest.S with -no-pie. After that change:

| configure:4009: checking for assembler and linker STT_GNU_IFUNC support
|
| There are no relocations in this file.
| configure:4040: result: no

Thanks to Andreas Schwab for the help debugging the issue.

---
 configure    | 2 +-
 configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index b959d2d9885..b31b56567ab 100755
--- a/configure
+++ b/configure
@@ -4031,7 +4031,7 @@ __start:
 EOF
 libc_cv_ld_gnu_indirect_function=no
 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
-	    -nostartfiles -nostdlib $no_ssp \
+	    -nostartfiles -nostdlib $no_ssp -no-pie \
 	    -o conftest conftest.S 1>&5 2>&5; then
   # Do a link to see if the backend supports IFUNC relocs.
   $READELF -r conftest 1>&5
diff --git a/configure.ac b/configure.ac
index 49b900c1ed6..8e19341f595 100644
--- a/configure.ac
+++ b/configure.ac
@@ -645,7 +645,7 @@ __start:
 EOF
 libc_cv_ld_gnu_indirect_function=no
 if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
-	    -nostartfiles -nostdlib $no_ssp \
+	    -nostartfiles -nostdlib $no_ssp -no-pie \
 	    -o conftest conftest.S 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then
   # Do a link to see if the backend supports IFUNC relocs.
   $READELF -r conftest 1>&AS_MESSAGE_LOG_FD
-- 
2.24.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]