asection *input_section,
Elf_Internal_Shdr *input_rel_hdr,
Elf_Internal_Rela *internal_relocs,
- struct elf_link_hash_entry **rel_hash
- ATTRIBUTE_UNUSED)
+ struct elf_link_hash_entry **rel_hash)
{
Elf_Internal_Rela *irela;
Elf_Internal_Rela *irelaend;
* bed->s->int_rels_per_ext_rel);
while (irela < irelaend)
{
+ if (rel_hash && *rel_hash)
+ (*rel_hash)->has_reloc = 1;
(*swap_out) (output_bfd, irela, erel);
irela += bed->s->int_rels_per_ext_rel;
erel += input_rel_hdr->sh_entsize;
+ if (rel_hash)
+ rel_hash++;
}
/* Bump the counter, so that we know where to add the next set of
if (!is_elf_hash_table (info->hash))
continue;
- /* Ignore the archive if the symbol isn't defined in a
- shared object. */
- if (!((struct elf_link_hash_entry *) h)->def_dynamic)
+ struct elf_link_hash_entry *eh
+ = (struct elf_link_hash_entry *) h;
+ /* Ignore the archive if the symbol isn't referenced by a
+ regular object or isn't defined in a shared object. */
+ if (!eh->ref_regular || !eh->def_dynamic)
continue;
/* Ignore the dynamic definition if symbol is first
defined in this archive. */
&& (h->root.u.undef.abfd->flags & BFD_PLUGIN) != 0)
strip = true;
+ /* Remember if this symbol should be stripped. */
+ bool should_strip = strip;
+
+ /* Strip undefined weak symbols link if they don't have relocation. */
+ if (!strip)
+ strip = !h->has_reloc && h->root.type == bfd_link_hash_undefweak;
+
type = h->type;
/* If we're stripping it, and it's not a dynamic symbol, there's
eoinfo->failed = true;
return false;
}
+ /* If a symbol is in the dynamic symbol table and isn't a
+ should-strip symbol, also keep it in the symbol table. */
+ if (!should_strip)
+ strip = false;
}
/* If we are marking the symbol as undefined, and there are no