summaryrefslogtreecommitdiff
path: root/bfd/elf32-sh.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf32-sh.c')
-rw-r--r--bfd/elf32-sh.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 35a4ddac86..4ff31bfb69 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -2054,7 +2054,7 @@ sh_elf_relax_section (abfd, sec, link_info, again)
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- internal_relocs = (_bfd_elf32_link_read_relocs
+ internal_relocs = (_bfd_elf_link_read_relocs
(abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
link_info->keep_memory));
if (internal_relocs == NULL)
@@ -2736,7 +2736,7 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
/* We always cache the relocs. Perhaps, if info->keep_memory is
FALSE, we should free them, if we are permitted to, when we
leave sh_coff_relax_section. */
- internal_relocs = (_bfd_elf32_link_read_relocs
+ internal_relocs = (_bfd_elf_link_read_relocs
(abfd, o, (PTR) NULL, (Elf_Internal_Rela *) NULL,
TRUE));
if (internal_relocs == NULL)
@@ -3940,6 +3940,10 @@ sh_elf_adjust_dynamic_symbol (info, h)
|| h->weakdef->root.type == bfd_link_hash_defweak);
h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value;
+ if (info->nocopyreloc)
+ h->elf_link_hash_flags
+ = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+ | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
return TRUE;
}
@@ -4083,7 +4087,9 @@ allocate_dynrelocs (h, inf)
}
if (htab->root.dynamic_sections_created
- && h->plt.refcount > 0)
+ && h->plt.refcount > 0
+ && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ || h->root.type != bfd_link_hash_undefweak))
{
/* Make sure this symbol is output as a dynamic symbol.
Undefined weak syms won't yet be marked as dynamic. */
@@ -4169,8 +4175,10 @@ allocate_dynrelocs (h, inf)
htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
else if (tls_type == GOT_TLS_GD)
htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela);
- else if (info->shared ||
- WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))
+ else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ || h->root.type != bfd_link_hash_undefweak)
+ && (info->shared
+ || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
}
else
@@ -4229,6 +4237,12 @@ allocate_dynrelocs (h, inf)
pp = &p->next;
}
}
+
+ /* Also discard relocs on undefined weak syms with non-default
+ visibility. */
+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+ && h->root.type == bfd_link_hash_undefweak)
+ eh->dyn_relocs = NULL;
}
else
{
@@ -4885,6 +4899,9 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
case R_SH_DIR32:
case R_SH_REL32:
if (info->shared
+ && (h == NULL
+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+ || h->root.type != bfd_link_hash_undefweak)
&& r_symndx != 0
&& (input_section->flags & SEC_ALLOC) != 0
&& (r_type != R_SH_REL32
@@ -5053,7 +5070,9 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
|| (info->shared
&& (info->symbolic || h->dynindx == -1
|| (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
- && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+ && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+ || (ELF_ST_VISIBILITY (h->other)
+ && h->root.type == bfd_link_hash_undefweak))
{
/* This is actually a static link, or it is a
-Bsymbolic link and the symbol is defined
@@ -5735,7 +5754,7 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
Elf_Internal_Sym *isym, *isymend;
bfd_size_type amt;
- internal_relocs = (_bfd_elf32_link_read_relocs
+ internal_relocs = (_bfd_elf_link_read_relocs
(input_bfd, input_section, (PTR) NULL,
(Elf_Internal_Rela *) NULL, FALSE));
if (internal_relocs == NULL)
@@ -6128,7 +6147,17 @@ sh_elf_copy_indirect_symbol (bed, dir, ind)
eind->tls_type = GOT_UNKNOWN;
}
- _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
+ if (ind->root.type != bfd_link_hash_indirect
+ && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
+ /* If called to transfer flags for a weakdef during processing
+ of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
+ We clear it ourselves for ELIMINATE_COPY_RELOCS. */
+ dir->elf_link_hash_flags |=
+ (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
+ | ELF_LINK_HASH_REF_REGULAR
+ | ELF_LINK_HASH_REF_REGULAR_NONWEAK));
+ else
+ _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
}
static int