/* STT_GNU_IFUNC must keep R_X86_64_GOTPCREL relocation. We also
avoid optimizing _DYNAMIC since ld.so may use its link-time
address. */
- if (h->type != STT_GNU_IFUNC
+ if ((h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && h->type != STT_GNU_IFUNC
&& h != htab->elf.hdynamic
&& SYMBOL_REFERENCES_LOCAL (link_info, h))
{