When building an executable, undefined symbols are error and undefined
weak symbols are resolved to zero. We only need to check PIC for
building a shared library.
bfd/
PR ld/21782
* elf64-x86-64.c (elf_x86_64_relocate_section): Limit PIC check
to shared library.
ld/
PR ld/21782
* testsuite/ld-x86-64/pie3-nacl.d: New file.
* testsuite/ld-x86-64/pie3.d: Likewise.
* testsuite/ld-x86-64/pie3.s: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pie3 and pie3-nacl.
(cherry picked from commit
c5bb8910e80c6cd80c63541f86471c18375c8198)
+2017-07-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21782
+ * elf64-x86-64.c (elf_x86_64_relocate_section): Limit PIC check
+ to shared library.
+
2017-07-16 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc64_elf_relocate_section): Don't optimize
&& ((bfd_link_executable (info)
&& h->root.type == bfd_link_hash_undefweak
&& !resolved_to_zero)
- || (bfd_link_pic (info)
- && !(bfd_link_pie (info)
- && h->root.type == bfd_link_hash_undefined))))
+ || bfd_link_dll (info)))
{
bfd_boolean fail = FALSE;
bfd_boolean branch
+2017-07-17 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/21782
+ * testsuite/ld-x86-64/pie3-nacl.d: New file.
+ * testsuite/ld-x86-64/pie3.d: Likewise.
+ * testsuite/ld-x86-64/pie3.s: Likewise.
+ * testsuite/ld-x86-64/x86-64.exp: Run pie3 and pie3-nacl.
+
2016-07-14 Maciej W. Rozycki <macro@imgtec.com>
* testsuite/ld-unique/pr21529.ld: New test linker script.
--- /dev/null
+#source: pie3.s
+#as: --64
+#ld: -pie -melf_x86_64
+#objdump: -dw
+#target: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <_start>:
+ +0: 48 8d 05 f9 ff ff ff lea -0x7\(%rip\),%rax # 0 <_start>
+#pass
--- /dev/null
+#as: --64
+#ld: -pie -melf_x86_64
+#objdump: -dw
+#notarget: x86_64-*-nacl*
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+191 <_start>:
+ +191: 48 8d 05 68 fe ff ff lea -0x198\(%rip\),%rax # 0 <_start-0x191>
+#pass
--- /dev/null
+ .text
+ .global _start
+ .weak foo
+_start:
+ leaq foo(%rip), %rax
run_dump_test "gotplt1"
run_dump_test "pie1"
run_dump_test "pie2"
+run_dump_test "pie3"
+run_dump_test "pie3-nacl"
run_dump_test "pic1"
run_dump_test "largecomm-1a"
run_dump_test "largecomm-1b"