summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-10-07 14:13:04 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-10-11 13:56:43 -0700
commit4b2e4dc3b8872e0e7687e0fcbf5cc69ec3ad6e44 (patch)
treefc72407ebab6c2f30323ea541c04b08bf0d4a866
parent935bccc521798e0a4eb3b7160d519f3a9cfc50c8 (diff)
downloadbinutils-gdb-4b2e4dc3b8872e0e7687e0fcbf5cc69ec3ad6e44.tar.gz
m68k: Check UNDEFINED_WEAK_RESOLVED_TO_ZERO
Don't generate dynamic relocation against weak undefined symbol if it is resolved to zero. FIXME: UNDEFINED_WEAK_RESOLVED_TO_ZERO may need to be checked in more places. PR ld/22269 * elf32-m68k.c (elf_m68k_check_relocs): Don't allocate dynamic relocations if UNDEFINED_WEAK_RESOLVED_TO_ZERO is true. (elf_m68k_adjust_dynamic_symbol): Don't make symbol dynamic if UNDEFINED_WEAK_RESOLVED_TO_ZERO is true. (elf_m68k_relocate_section): Don't generate dynamic relocation if UNDEFINED_WEAK_RESOLVED_TO_ZERO is true.
-rw-r--r--bfd/elf32-m68k.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 5ca599c13a8..8930c10c484 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -2705,7 +2705,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
+ || !UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h)))
{
/* When creating a shared object, we must copy these
reloc types into the output file. We create a reloc
@@ -2902,7 +2904,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
+ || UNDEFINED_WEAK_RESOLVED_TO_ZERO (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
@@ -3429,6 +3432,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)
@@ -3468,6 +3472,9 @@ elf_m68k_relocate_section (bfd *output_bfd,
if (bfd_link_relocatable (info))
continue;
+ resolved_to_zero = (h != NULL
+ && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, h));
+
switch (r_type)
{
case R_68K_GOT8:
@@ -3592,7 +3599,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
@@ -3761,7 +3769,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