diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-10-26 16:32:34 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-10-26 16:32:55 -0700 |
commit | 7b7e7f1da28585cfa49cbced50dbbd75a143cd20 (patch) | |
tree | 92bc4519ea2dc65f76bd4d2d8280c3857ef55d42 /bfd/elf64-x86-64.c | |
parent | 0fde2c536bc483baa4baa2990ebebfb3a7c00415 (diff) | |
download | gdb-7b7e7f1da28585cfa49cbced50dbbd75a143cd20.zip gdb-7b7e7f1da28585cfa49cbced50dbbd75a143cd20.tar.gz gdb-7b7e7f1da28585cfa49cbced50dbbd75a143cd20.tar.bz2 |
Check symbol defined by assignment in linker script
Symbol symbol defined by an assignment in a linker script has type
bfd_link_hash_new. elf_i386_convert_load and elf_x86_64_convert_load
should check bfd_link_hash_new to see if a symbol is defined by a linker
script.
bfd/
PR ld/19175
* elf32-i386.c (elf_i386_convert_load): Check bfd_link_hash_new
instead of calling bfd_link_get_defined_symbol.
* elf64-x86-64.c (elf_x86_64_convert_load): Likewise. Skip
relocation overflow for bfd_link_hash_new.
* linker.c (bfd_link_get_defined_symbol): Removed.
* bfd-in2.h: Regenerated.
ld/testsuite/
PR ld/19175
* ld-i386/i386.exp: Run pr19175.
* ld-x86-64/x86-64.exp: Likewise.
* ld-i386/pr19175.d: New file.
* ld-i386/pr19175.s: Likewise.
* ld-i386/pr19175.t: Likewise.
* ld-x86-64/pr19175.d: Likewise.
* ld-x86-64/pr19175.s: Likewise.
* ld-x86-64/pr19175.t: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r-- | bfd/elf64-x86-64.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 9778f2f..deaee91 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -3116,8 +3116,6 @@ elf_x86_64_convert_load (bfd *abfd, asection *sec, } else { - bfd_boolean defined; - indx = r_symndx - symtab_hdr->sh_info; h = elf_sym_hashes (abfd)[indx]; BFD_ASSERT (h != NULL); @@ -3126,17 +3124,26 @@ elf_x86_64_convert_load (bfd *abfd, asection *sec, || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; - defined = bfd_link_get_defined_symbol (link_info, &h->root, - &tsec, &toff); - /* 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 (defined + if ((h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak + || h->root.type == bfd_link_hash_new) && h->type != STT_GNU_IFUNC && h != htab->elf.hdynamic && SYMBOL_REFERENCES_LOCAL (link_info, h)) - symtype = h->type; + { + /* 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) + goto convert; + tsec = h->root.u.def.section; + toff = h->root.u.def.value; + symtype = h->type; + } else continue; } @@ -3213,6 +3220,7 @@ elf_x86_64_convert_load (bfd *abfd, asection *sec, continue; } +convert: if (opcode == 0xff) { /* We have "call/jmp *foo@GOTPCREL(%rip)". */ |