[binutils-gdb] Add a compile-time test for PR ld/22269
H.J.Lu
hjl@sourceware.org
Fri Oct 20 16:50:00 GMT 2017
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f3012016f008030b48597b578a5fb1e550907374
commit f3012016f008030b48597b578a5fb1e550907374
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Fri Oct 20 09:47:08 2017 -0700
Add a compile-time test for PR ld/22269
This compile-time test requires a target C compiler to run. It fails
on many targets where ELF backend linkers fail to check undefined weak
symbol in static PIE via UNDEFWEAK_NO_DYNAMIC_RELOC.
PR ld/22269
* testsuite/ld-elf/pr22269-1.rd: New file.
* testsuite/ld-elf/pr22269-1.c: Likewise.
* testsuite/ld-elf/shared.exp: Run pr22269-1.
Diff:
---
ld/ChangeLog | 7 +++++++
ld/testsuite/ld-elf/pr22269-1.c | 8 ++++++++
ld/testsuite/ld-elf/pr22269-1.rd | 5 +++++
ld/testsuite/ld-elf/shared.exp | 13 +++++++++++++
4 files changed, 33 insertions(+)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 586420a..7cd9e7c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,10 @@
+2017-10-20 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/22269
+ * testsuite/ld-elf/pr22269-1.rd: New file.
+ * testsuite/ld-elf/pr22269-1.c: Likewise.
+ * testsuite/ld-elf/shared.exp: Run pr22269-1.
+
2017-10-19 Palmer Dabbelt <palmer@dabbelt.com>
* emultempl/riscvelf.em (riscv_elf_before_allocation): Add a
diff --git a/ld/testsuite/ld-elf/pr22269-1.c b/ld/testsuite/ld-elf/pr22269-1.c
new file mode 100644
index 0000000..8197687
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr22269-1.c
@@ -0,0 +1,8 @@
+extern int foo __attribute ((weak));
+
+int
+_start (void)
+{
+ if (&foo)
+ return foo;
+}
diff --git a/ld/testsuite/ld-elf/pr22269-1.rd b/ld/testsuite/ld-elf/pr22269-1.rd
new file mode 100644
index 0000000..9df3c38
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr22269-1.rd
@@ -0,0 +1,5 @@
+# NONE relocs are not needed in a PIE.
+#failif
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_NONE.*
+#pass
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index 6e091c9..640d324 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -465,6 +465,19 @@ set build_tests {
run_cc_link_tests $build_tests
+run_ld_link_tests [list \
+ [list \
+ "Build pr22269-1" \
+ "-pie -e _start --no-dynamic-linker -z text" \
+ "" \
+ "" \
+ { pr22269-1.c } \
+ {{readelf -rW pr22269-1.rd}} \
+ "pr22269-1" \
+ "-fPIE -O2" \
+ ] \
+]
+
set run_tests [list \
[list "Run normal with libfoo.so" \
"-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
More information about the Binutils-cvs
mailing list