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.
+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
--- /dev/null
+extern int foo __attribute ((weak));
+
+int
+_start (void)
+{
+ if (&foo)
+ return foo;
+}
--- /dev/null
+# NONE relocs are not needed in a PIE.
+#failif
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_.*_NONE.*
+#pass
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" "" \