x86: Resolve local undefined weak symbol to 0
[binutils-gdb.git] / bfd / elf64-x86-64.c
index 1a9bebe668f930b6518a9a418498d8ee14f5957c..957dcd98ce6f3dcf11694d858d26b8129c9c9a9e 100644 (file)
@@ -1050,14 +1050,16 @@ static const struct elf_x86_64_backend_data elf_x86_64_arch_bed =
    it isn't dynamic and
    1. Has non-GOT/non-PLT relocations in text section.  Or
    2. Has no GOT/PLT relocation.
+   Local undefined weak symbol is always resolved to 0.
  */
 #define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, GOT_RELOC, EH)   \
   ((EH)->elf.root.type == bfd_link_hash_undefweak              \
-   && bfd_link_executable (INFO)                               \
-   && (elf_x86_64_hash_table (INFO)->interp == NULL            \
-       || !(GOT_RELOC)                                         \
-       || (EH)->has_non_got_reloc                              \
-       || !(INFO)->dynamic_undefined_weak))
+   && ((EH)->elf.forced_local                                  \
+       || (bfd_link_executable (INFO)                          \
+          && (elf_x86_64_hash_table (INFO)->interp == NULL     \
+              || !(GOT_RELOC)                                  \
+              || (EH)->has_non_got_reloc                       \
+              || !(INFO)->dynamic_undefined_weak))))
 
 /* x86-64 ELF linker hash entry.  */