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-microblaze.c (microblaze_elf_relocate_section): Don't
generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is
true.
(allocate_dynrelocs): Discard dynamic relocations if
UNDEFWEAK_NO_DYNAMIC_RELOC is true.
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/22269
2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/22269
+ * elf32-microblaze.c (microblaze_elf_relocate_section): Don't
+ generate dynamic relocation if UNDEFWEAK_NO_DYNAMIC_RELOC is
+ true.
+ (allocate_dynrelocs): Discard dynamic relocations if
+ UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+
+2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ 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
* 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
else
{
bfd_vma relocation;
else
{
bfd_vma relocation;
+ bfd_boolean resolved_to_zero;
/* This is a final link. */
sym = NULL;
/* This is a final link. */
sym = NULL;
+ resolved_to_zero = (h != NULL
+ && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+
switch ((int) r_type)
{
case (int) R_MICROBLAZE_SRO32 :
switch ((int) r_type)
{
case (int) R_MICROBLAZE_SRO32 :
/* Need to generate relocs ? */
if ((bfd_link_pic (info) || indx != 0)
&& (h == NULL
/* Need to generate relocs ? */
if ((bfd_link_pic (info) || indx != 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))
need_relocs = TRUE;
|| h->root.type != bfd_link_hash_undefweak))
need_relocs = TRUE;
if ((bfd_link_pic (info)
&& (h == NULL
if ((bfd_link_pic (info)
&& (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)
&& (!howto->pc_relative
|| (h != NULL
|| h->root.type != bfd_link_hash_undefweak)
&& (!howto->pc_relative
|| (h != NULL
+ else if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
+ eh->dyn_relocs = NULL;