+2015-12-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/19319
+ * elf32-i386.c (elf_i386_convert_load): Check h->def_regular
+ instead of bfd_link_hash_new.
+ * elf64-x86-64.c (elf_x86_64_convert_load): Likewise. Skip
+ relocation overflow for bfd_link_hash_undefined and
+ bfd_link_hash_new if h->def_regular is set.
+
2015-12-01 Alan Modra <amodra@gmail.com>
* aoutx.h (adjust_sizes_and_vmas): Remove unused text_size and
if (h == htab->elf.hdynamic)
continue;
- /* bfd_link_hash_new is set by an assignment in a linker
- script in bfd_elf_record_link_assignment. */
- if ((h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_new)
+ /* def_regular is set by an assignment in a linker script in
+ bfd_elf_record_link_assignment. */
+ if ((h->def_regular
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
&& SYMBOL_REFERENCES_LOCAL (link_info, h))
{
convert_load:
/* STT_GNU_IFUNC must keep GOTPCREL relocations. We also
avoid optimizing GOTPCREL relocations againt _DYNAMIC
since ld.so may use its link-time address. */
- if ((h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak
- || h->root.type == bfd_link_hash_new)
+ if ((h->def_regular
+ || h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
&& h->type != STT_GNU_IFUNC
&& h != htab->elf.hdynamic
&& SYMBOL_REFERENCES_LOCAL (link_info, h))
{
- /* bfd_link_hash_new is set by an assignment in a linker
- script in bfd_elf_record_link_assignment. FIXME: If
- we ever get a linker error due relocation overflow, we
- will skip this optimization. */
- if (h->root.type == bfd_link_hash_new)
+ /* bfd_link_hash_new or bfd_link_hash_undefined is
+ set by an assignment in a linker script in
+ bfd_elf_record_link_assignment. FIXME: If we
+ ever get a linker error due relocation overflow,
+ we will skip this optimization. */
+ if (h->def_regular
+ && (h->root.type == bfd_link_hash_new
+ || h->root.type == bfd_link_hash_undefined))
goto convert;
tsec = h->root.u.def.section;
toff = h->root.u.def.value;
+2015-12-01 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/19319
+ * ld-i386/i386.exp: Run pr19319 test.
+ * ld-x86-64/x86-64.exp: Likewise.
+ * ld-i386/pr19319.dd: New file.
+ * ld-i386/pr19319a.S: Likewise.
+ * ld-i386/pr19319b.S: Likewise.
+ * ld-x86-64/pr19319.dd: Likewise.
+ * ld-x86-64/pr19319a.S: Likewise.
+ * ld-x86-64/pr19319b.S: Likewise.
+
2015-11-11 Alan Modra <amodra@gmail.com>
Peter Bergner <bergner@vnet.ibm.com>
{{objdump {-dw} got1.dd}} \
"got1" \
] \
+ [list \
+ "Build pr19319.so" \
+ "-shared" \
+ "" \
+ { pr19319a.S } \
+ "" \
+ "pr19319.so" \
+ ] \
+ [list \
+ "Build pr19319" \
+ "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
+ "" \
+ { pr19319b.S } \
+ {{objdump {-dw} pr19319.dd}} \
+ "pr19319" \
+ ] \
]
run_ld_link_exec_tests [] [list \
--- /dev/null
+#...
+[a-f0-9]+ <_start>:
+[ ]*[a-f0-9]+: 8d 81 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%ecx\),%eax
+#pass
--- /dev/null
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ movl __start_my_section@GOT(%ecx), %eax
+ ret
+ .size foo, .-foo
+ .section my_section,"aw",@progbits
+ .align 8
+ .long 4660
+ .long 22136
--- /dev/null
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ movl __start_my_section@GOT(%ecx), %eax
+ ret
+ .size _start, .-_start
+ .section my_section,"aw",@progbits
+ .align 8
+ .long 4660
+ .long 22136
--- /dev/null
+#...
+[a-f0-9]+ <_start>:
+[ ]*[a-f0-9]+: 48 8d 05 ([0-9a-f]{2} ){4} * lea 0x[a-f0-9]+\(%rip\),%rax # [a-f0-9]+ <__start_my_section>
+#pass
--- /dev/null
+ .text
+ .globl foo
+ .type foo, @function
+foo:
+ movq __start_my_section@GOTPCREL(%rip), %rax
+ ret
+ .size foo, .-foo
+ .section my_section,"aw",@progbits
+ .align 8
+ .long 4660
+ .long 22136
--- /dev/null
+ .text
+ .globl _start
+ .type _start, @function
+_start:
+ movq __start_my_section@GOTPCREL(%rip), %rax
+ ret
+ .size _start, .-_start
+ .section my_section,"aw",@progbits
+ .align 8
+ .long 4660
+ .long 22136
{{objdump {-dw} gotpcrel1.dd}} \
"gotpcrel1" \
] \
+ [list \
+ "Build pr19319.so" \
+ "-shared" \
+ "" \
+ { pr19319a.S } \
+ "" \
+ "pr19319.so" \
+ ] \
+ [list \
+ "Build pr19319" \
+ "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
+ "" \
+ { pr19319b.S } \
+ {{objdump {-dw} pr19319.dd}} \
+ "pr19319" \
+ ] \
]
run_ld_link_exec_tests [] [list \