Add RESOLVED_LOCALLY_P
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 5 Oct 2017 21:36:58 +0000 (14:36 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 6 Oct 2017 07:24:23 +0000 (00:24 -0700)
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.h

index 4a3c690..25d349c 100644 (file)
@@ -2512,26 +2512,13 @@ r_386_got32:
          relative_reloc = FALSE;
          if (h != NULL)
            {
-             bfd_boolean dyn;
-
              off = h->got.offset;
-             dyn = htab->elf.dynamic_sections_created;
-             if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
-                                                    bfd_link_pic (info),
-                                                    h)
-                 || (bfd_link_pic (info)
-                     && SYMBOL_REFERENCES_LOCAL_P (info, h))
-                 || (ELF_ST_VISIBILITY (h->other)
-                     && h->root.type == bfd_link_hash_undefweak))
+             if (RESOLVED_LOCALLY_P (info, h, htab))
                {
-                 /* This is actually a static link, or it is a
-                    -Bsymbolic link and the symbol is defined
-                    locally, or the symbol was forced to be local
-                    because of a version file.  We must initialize
-                    this entry in the global offset table.  Since the
-                    offset must always be a multiple of 4, we use the
-                    least significant bit to record whether we have
-                    initialized it already.
+                 /* We must initialize this entry in the global offset
+                    table.  Since the offset must always be a multiple
+                    of 4, we use the least significant bit to record
+                    whether we have initialized it already.
 
                     When doing a dynamic link, we create a .rel.got
                     relocation entry to initialize the value.  This
index df91ab8..5a9e3fd 100644 (file)
@@ -2762,8 +2762,6 @@ do_ifunc_pointer:
          relative_reloc = FALSE;
          if (h != NULL)
            {
-             bfd_boolean dyn;
-
              off = h->got.offset;
              if (h->needs_plt
                  && h->plt.offset != (bfd_vma)-1
@@ -2779,21 +2777,12 @@ do_ifunc_pointer:
                  base_got = htab->elf.sgotplt;
                }
 
-             dyn = htab->elf.dynamic_sections_created;
-
-             if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, bfd_link_pic (info), h)
-                 || (bfd_link_pic (info)
-                     && SYMBOL_REFERENCES_LOCAL_P (info, h))
-                 || (ELF_ST_VISIBILITY (h->other)
-                     && h->root.type == bfd_link_hash_undefweak))
+             if (RESOLVED_LOCALLY_P (info, h, htab))
                {
-                 /* This is actually a static link, or it is a -Bsymbolic
-                    link and the symbol is defined locally, or the symbol
-                    was forced to be local because of a version file.  We
-                    must initialize this entry in the global offset table.
-                    Since the offset must always be a multiple of 8, we
-                    use the least significant bit to record whether we
-                    have initialized it already.
+                 /* We must initialize this entry in the global offset
+                    table.  Since the offset must always be a multiple
+                    of 8, we use the least significant bit to record
+                    whether we have initialized it already.
 
                     When doing a dynamic link, we create a .rela.got
                     relocation entry to initialize the value.  This is
index 88202b4..317c86e 100644 (file)
                        && ((H)->root.type == bfd_link_hash_defweak \
                            || !(H)->def_regular)))
 
+/* TRUE if this is actually a static link, or it is a -Bsymbolic link
+   and the symbol is defined locally, or the symbol was forced to be
+   local because of a version file.  */
+#define RESOLVED_LOCALLY_P(INFO, H, HTAB) \
+  (!WILL_CALL_FINISH_DYNAMIC_SYMBOL ((HTAB)->elf.dynamic_sections_created, \
+                                    bfd_link_pic (INFO), (H)) \
+   || (bfd_link_pic (INFO) \
+       && SYMBOL_REFERENCES_LOCAL_P ((INFO), (H))) \
+       || (ELF_ST_VISIBILITY ((H)->other) \
+          && (H)->root.type == bfd_link_hash_undefweak))
+
 /* TRUE if TLS IE->LE transition is OK.  */
 #define TLS_TRANSITION_IE_TO_LE_P(INFO, H, TLS_TYPE) \
   (bfd_link_executable (INFO) \