diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-10-14 10:23:48 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-10-14 10:24:04 -0700 |
commit | ddb7fd0f7b43e4c755c4b8c7752948e050363525 (patch) | |
tree | 183ada9421a7f19d252ed59f68cfcf47e2121a9d /bfd | |
parent | 62cd30f167be56e68cb0a37789d400b47bbdbc6c (diff) | |
download | gdb-ddb7fd0f7b43e4c755c4b8c7752948e050363525.zip gdb-ddb7fd0f7b43e4c755c4b8c7752948e050363525.tar.gz gdb-ddb7fd0f7b43e4c755c4b8c7752948e050363525.tar.bz2 |
aarch64: Check UNDEFWEAK_NO_DYNAMIC_RELOC
Don't generate dynamic relocation against weak undefined symbol if it
is resolved to zero. FIXME: UNDEFWEAK_NO_DYNAMIC_RELOC may need to be
checked in more places.
PR ld/22269
* elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Don't
generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is
true.
(elfNN_aarch64_allocate_dynrelocs): Discard dynamic relocations
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 9 | ||||
-rw-r--r-- | bfd/elfnn-aarch64.c | 10 |
2 files changed, 17 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 59bfdf0..70b153b 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,14 @@ 2017-10-14 H.J. Lu <hongjiu.lu@intel.com> + PR ld/22269 + * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Don't + generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is + true. + (elfNN_aarch64_allocate_dynrelocs): Discard dynamic relocations + if UNDEFWEAK_NO_DYNAMIC_RELOC is true. + +2017-10-14 H.J. Lu <hongjiu.lu@intel.com> + * elf32-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Moved to ... * elf-bfd.h (UNDEFWEAK_NO_DYNAMIC_RELOC): Here. * elf64-ppc.c (UNDEFWEAK_NO_DYNAMIC_RELOC): Removed. diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 5fd314d..3083f3b 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -4953,6 +4953,7 @@ elfNN_aarch64_final_link_relocate (reloc_howto_type *howto, bfd_boolean relative_reloc; asection *base_got; bfd_vma orig_value = value; + bfd_boolean resolved_to_zero; globals = elf_aarch64_hash_table (info); @@ -5178,6 +5179,9 @@ bad_ifunc_reloc: } } + resolved_to_zero = (h != NULL + && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)); + switch (bfd_r_type) { case BFD_RELOC_AARCH64_NONE: @@ -5196,7 +5200,8 @@ bad_ifunc_reloc: || globals->root.is_relocatable_executable) && (input_section->flags & SEC_ALLOC) && (h == NULL - || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT + && !resolved_to_zero) || h->root.type != bfd_link_hash_undefweak)) /* Or we are creating an executable, we may need to keep relocations for symbols satisfied by a dynamic library if we manage to avoid @@ -8287,7 +8292,8 @@ elfNN_aarch64_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) visibility. */ if (eh->dyn_relocs != NULL && h->root.type == bfd_link_hash_undefweak) { - if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) + if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) eh->dyn_relocs = NULL; /* Make sure undefined weak symbols are output as a dynamic |