x86: Update UNDEFINED_WEAK_RESOLVED_TO_ZERO
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 9 Sep 2017 14:29:15 +0000 (07:29 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 9 Sep 2017 14:29:29 +0000 (07:29 -0700)
Since the only information which SYMBOL_REFERENCES_LOCAL_P doesn't check
is relocations, UNDEFINED_WEAK_RESOLVED_TO_ZERO only needs to check for
relocations with SYMBOL_REFERENCES_LOCAL_P.

* elf32-i386.c (elf_i386_relocate_section): Update usage of
UNDEFINED_WEAK_RESOLVED_TO_ZERO.
(elf_i386_finish_dynamic_symbol): Likewise.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
(elf_x86_64_finish_dynamic_symbol): Likewise.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise.
(_bfd_x86_elf_fixup_symbol): Likewise.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.c
bfd/elfxx-x86.h

index b3eae2e82e3f976b8e1f1edaaa5541e21bbaef12..06b9278ec9cbe5ae890d387de4da8e62fd8f350f 100644 (file)
@@ -1,3 +1,13 @@
+2017-09-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-i386.c (elf_i386_relocate_section): Update usage of
+       UNDEFINED_WEAK_RESOLVED_TO_ZERO.
+       (elf_i386_finish_dynamic_symbol): Likewise.
+       * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+       (elf_x86_64_finish_dynamic_symbol): Likewise.
+       * elfxx-x86.c (elf_x86_allocate_dynrelocs): Likewise.
+       (_bfd_x86_elf_fixup_symbol): Likewise.
+
 2017-09-09  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elfxx-x86.c (_bfd_x86_elf_link_symbol_references_local): Don't
index 01006620404561dda6dd13a1fdf4ecc608840a9d..4337ab0ea0b68d3e60c227cc225b971181730dff 100644 (file)
@@ -2466,10 +2466,7 @@ do_ifunc_pointer:
        }
 
       resolved_to_zero = (eh != NULL
-                         && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
-                                                             I386_ELF_DATA,
-                                                             eh->has_got_reloc,
-                                                             eh));
+                         && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
 
       switch (r_type)
        {
@@ -3623,9 +3620,7 @@ elf_i386_finish_dynamic_symbol (bfd *output_bfd,
   /* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
      resolved undefined weak symbols in executable so that their
      references have value 0 at run-time.  */
-  local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, I386_ELF_DATA,
-                                                    eh->has_got_reloc,
-                                                    eh);
+  local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
 
   if (h->plt.offset != (bfd_vma) -1)
     {
index 4faa78bf525074f74dac993a4328560fead7d425..4371a1625c1fdad7391be931c0504f240dc655bd 100644 (file)
@@ -2766,10 +2766,7 @@ do_ifunc_pointer:
        }
 
       resolved_to_zero = (eh != NULL
-                         && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
-                                                             X86_64_ELF_DATA,
-                                                             eh->has_got_reloc,
-                                                             eh));
+                         && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
 
       /* When generating a shared object, the relocations handled here are
         copied into the output file to be resolved at run time.  */
@@ -3985,10 +3982,7 @@ elf_x86_64_finish_dynamic_symbol (bfd *output_bfd,
   /* We keep PLT/GOT entries without dynamic PLT/GOT relocations for
      resolved undefined weak symbols in executable so that their
      references have value 0 at run-time.  */
-  local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
-                                                    X86_64_ELF_DATA,
-                                                    eh->has_got_reloc,
-                                                    eh);
+  local_undefweak = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
 
   if (h->plt.offset != (bfd_vma) -1)
     {
index 20b07f0806f003ec38ec181413b77ca1c744f1ae..c41dbeff762419d775566c7e14e2b80d3c416784 100644 (file)
@@ -107,10 +107,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h,
 
   plt_entry_size = htab->plt.plt_entry_size;
 
-  resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
-                                                     bed->target_id,
-                                                     eh->has_got_reloc,
-                                                     eh);
+  resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
 
   /* Clear the reference count of function pointer relocations if
      symbol isn't a normal function.  */
@@ -1446,19 +1443,12 @@ bfd_boolean
 _bfd_x86_elf_fixup_symbol (struct bfd_link_info *info,
                           struct elf_link_hash_entry *h)
 {
-  if (h->dynindx != -1)
+  if (h->dynindx != -1
+      && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, elf_x86_hash_entry (h)))
     {
-      const struct elf_backend_data *bed
-       = get_elf_backend_data (info->output_bfd);
-      if (UNDEFINED_WEAK_RESOLVED_TO_ZERO (info,
-                                          bed->target_id,
-                                          elf_x86_hash_entry (h)->has_got_reloc,
-                                          elf_x86_hash_entry (h)))
-       {
-         h->dynindx = -1;
-         _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
-                                 h->dynstr_index);
-       }
+      h->dynindx = -1;
+      _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
+                             h->dynstr_index);
     }
   return TRUE;
 }
index 57f786215182c1266ea8a6d7f97a1109812ded38..2aee3500375f0ea07a55afa0a83d558a49c7557e 100644 (file)
    2. Has no GOT/PLT relocation.
    Local undefined weak symbol is always resolved to 0.
  */
-#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, ID, GOT_RELOC, EH) \
+#define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, EH) \
   ((EH)->elf.root.type == bfd_link_hash_undefweak               \
    && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf)           \
        || (bfd_link_executable (INFO)                           \
-          && (elf_x86_hash_table ((INFO), (ID))->interp == NULL \
-              || !(GOT_RELOC)                                   \
-              || (EH)->has_non_got_reloc                        \
-              || !(INFO)->dynamic_undefined_weak))))
+          && (!(EH)->has_got_reloc                              \
+              || (EH)->has_non_got_reloc))))
 
 /* Should copy relocation be generated for a symbol.  Don't generate
    copy relocation against a protected symbol defined in a shared
This page took 0.033515 seconds and 4 git commands to generate.