diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2015-12-01 14:45:51 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2015-12-01 14:45:51 -0800 |
commit | ead3d5427a2df5e33316d4ad045510c1d2078c2a (patch) | |
tree | afaddd5cd1679a6122659a741de7f8b217785e74 /bfd | |
parent | 974eac9d7694ca14dcdf6d1a74777a265fffdb95 (diff) | |
download | gdb-ead3d5427a2df5e33316d4ad045510c1d2078c2a.zip gdb-ead3d5427a2df5e33316d4ad045510c1d2078c2a.tar.gz gdb-ead3d5427a2df5e33316d4ad045510c1d2078c2a.tar.bz2 |
Properly check symbol defined by assignment in linker script
Symbol defined by a linker assignment may have type bfd_link_hash_new
or bfd_link_hash_undefined. And h->def_regular is always set.
elf_i386_convert_load and elf_x86_64_convert_load should check
h->def_regular as well as bfd_link_hash_undefined and bfd_link_hash_new
to see if a symbol is defined by a linker script.
bfd/
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.
ld/testsuite/
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 9 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 10 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 19 |
3 files changed, 25 insertions, 13 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index ca4f130..544ed88 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +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 diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 1df7244..ae3187d 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2976,11 +2976,11 @@ convert_branch: 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: diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 8e00362..63957bb 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -3127,18 +3127,21 @@ elf_x86_64_convert_load (bfd *abfd, asection *sec, /* 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; |