diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-10-26 06:10:23 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-10-26 08:11:55 -0700 |
commit | a6af384b19c63bab4a1803c09592c5b5bd8674c2 (patch) | |
tree | be13c54b14d178b3c327ea1e372b2337980e7d95 /bfd/elf64-x86-64.c | |
parent | 7cc53fba0a4e5c316a6e86fdae28f8cc9d0f9a68 (diff) | |
download | gdb-a6af384b19c63bab4a1803c09592c5b5bd8674c2.zip gdb-a6af384b19c63bab4a1803c09592c5b5bd8674c2.tar.gz gdb-a6af384b19c63bab4a1803c09592c5b5bd8674c2.tar.bz2 |
Properly convert address load of __start_XXX/__stop_XXX
Since __start_XXX and __stop_XXX symbols aren't defined when address
load is being converted, we need to check if there is an XXX output
section to get their section and value. This patch adds a new function,
bfd_link_get_defined_symbol, to search for the XXX output section to
check if __start_XXX and __stop_XXX symbols are defined.
bfd/
PR ld/19171
* elf32-i386.c (elf_i386_convert_load): Call
bfd_link_get_defined_symbol to check if a symbol is defined.
* elf64-x86-64.c (elf_x86_64_convert_load): Call
bfd_link_get_defined_symbol to get defined symbol section and
value.
* linker.c (bfd_link_get_defined_symbol): New function.
* bfd-in2.h: Regenerated.
ld/testsuite/
PR ld/19171
* ld-i386/lea1.s: Add tests for address load of __start_XXX
and __stop_XXX.
* ld-i386/mov1.s: Likewise.
* ld-x86-64/lea1.s: Likewise.
* ld-x86-64/mov1.s: Likewise.
* ld-i386/lea1a.d: Updated.
* ld-i386/lea1b.d: Likewise.
* ld-i386/lea1c.d: Likewise.
* ld-i386/mov1a.d: Likewise.
* ld-i386/mov1b.d: Likewise.
* ld-x86-64/lea1a.d: Likewise.
* ld-x86-64/lea1b.d: Likewise.
* ld-x86-64/lea1c.d: Likewise.
* ld-x86-64/lea1d.d: Likewise.
* ld-x86-64/lea1e.d: Likewise.
* ld-x86-64/lea1f.d: Likewise.
* ld-x86-64/mov1a.d: Likewise.
* ld-x86-64/mov1b.d: Likewise.
* ld-x86-64/mov1c.d: Likewise.
* ld-x86-64/mov1d.d: Likewise.
Diffstat (limited to 'bfd/elf64-x86-64.c')
-rw-r--r-- | bfd/elf64-x86-64.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index f864834..9778f2f 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -3116,6 +3116,8 @@ 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); @@ -3124,19 +3126,17 @@ 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 ((h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak) + if (defined && h->type != STT_GNU_IFUNC && h != htab->elf.hdynamic && SYMBOL_REFERENCES_LOCAL (link_info, h)) - { - tsec = h->root.u.def.section; - toff = h->root.u.def.value; - symtype = h->type; - } + symtype = h->type; else continue; } |