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
+ UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+ (elf_m68k_relocate_section): Don't generate dynamic relocation
+ if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
+
+2017-10-14 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR ld/22269
* elf32-hppa.c (ensure_undef_dynamic): Don't make undefined
symbol dynamic if UNDEFWEAK_NO_DYNAMIC_RELOC is true.
(allocate_dynrelocs): Discard dynamic relocations if
/* 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
{
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
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)
if (bfd_link_relocatable (info))
continue;
+ resolved_to_zero = (h != NULL
+ && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+
switch (r_type)
{
case R_68K_GOT8:
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
&& 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