diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-10-14 11:02:20 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-10-14 11:02:37 -0700 |
commit | 5056ba1d4df19006b873bc8e752f85fcc712b65b (patch) | |
tree | 6334cca66804f26e73414a5f4a87782bb19aa90e /bfd/elf32-m68k.c | |
parent | 60c1b909dfcc984f3aecb70032e90a34d71b44bc (diff) | |
download | gdb-5056ba1d4df19006b873bc8e752f85fcc712b65b.zip gdb-5056ba1d4df19006b873bc8e752f85fcc712b65b.tar.gz gdb-5056ba1d4df19006b873bc8e752f85fcc712b65b.tar.bz2 |
m68k: 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
* elf32-m68k.c (elf_m68k_check_relocs): Don't allocate dynamic
relocations if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_m68k_adjust_dynamic_symbol): Don't make symbol dynamic if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(elf_m68k_relocate_section): Don't generate dynamic relocation
if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
Diffstat (limited to 'bfd/elf32-m68k.c')
-rw-r--r-- | bfd/elf32-m68k.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 21bff66..501190d 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -2773,7 +2773,9 @@ elf_m68k_check_relocs (bfd *abfd, /* If we are creating a shared library, we need to copy the reloc into the shared library. */ - if (bfd_link_pic (info)) + if (bfd_link_pic (info) + && (h == NULL + || !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))) { /* When creating a shared object, we must copy these reloc types into the output file. We create a reloc @@ -3095,7 +3097,8 @@ elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info, { if ((h->plt.refcount <= 0 || SYMBOL_CALLS_LOCAL (info, h) - || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + || ((ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)) && h->root.type == bfd_link_hash_undefweak)) /* We must always create the plt entry if it was referenced by a PLTxxO relocation. In this case we already recorded @@ -3622,6 +3625,7 @@ elf_m68k_relocate_section (bfd *output_bfd, bfd_vma relocation; bfd_boolean unresolved_reloc; bfd_reloc_status_type r; + bfd_boolean resolved_to_zero; r_type = ELF32_R_TYPE (rel->r_info); if (r_type < 0 || r_type >= (int) R_68K_max) @@ -3661,6 +3665,9 @@ elf_m68k_relocate_section (bfd *output_bfd, if (bfd_link_relocatable (info)) continue; + resolved_to_zero = (h != NULL + && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)); + switch (r_type) { case R_68K_GOT8: @@ -3785,7 +3792,8 @@ elf_m68k_relocate_section (bfd *output_bfd, h) || (bfd_link_pic (info) && SYMBOL_REFERENCES_LOCAL (info, h)) - || (ELF_ST_VISIBILITY (h->other) + || ((ELF_ST_VISIBILITY (h->other) + || resolved_to_zero) && h->root.type == bfd_link_hash_undefweak)) { /* This is actually a static link, or it is a @@ -3954,7 +3962,8 @@ elf_m68k_relocate_section (bfd *output_bfd, && r_symndx != STN_UNDEF && (input_section->flags & SEC_ALLOC) != 0 && (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) && ((r_type != R_68K_PC8 && r_type != R_68K_PC16 |