x86: Use zero_undefweak in elf_x86_link_hash_entry
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 6 Oct 2017 22:25:07 +0000 (15:25 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 6 Oct 2017 22:29:32 +0000 (15:29 -0700)
Replace has_got_reloc and has_non_got_reloc in elf_x86_link_hash_entry
with zero_undefweak:

Bit 0: Symbol has no GOT nor PLT relocations.
Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.

zero_undefweak is initialized to 1 and undefined weak symbol should be
resolved to 0 if zero_undefweak > 0.

* elf32-i386.c (elf_i386_check_relocs): Replace has_got_reloc
and has_non_got_reloc with zero_undefweak.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_newfunc): Initialize
zero_undefweak to 1.
(_bfd_x86_elf_copy_indirect_symbol): Replace has_got_reloc and
has_non_got_reloc with zero_undefweak.
* elfxx-x86.h (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Replace
has_got_reloc and has_non_got_reloc with zero_undefweak.
(elf_x86_link_hash_entry): Likewise.

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

index dd257794f9e6c8dbb60043ddb23d1ad2ddf17f55..de01ad39d70c5d4b878a4c29af9768e7f1bdec3f 100644 (file)
        * elfxx-target.h (elf_backend_grok_freebsd_prstatus): Define.
        (elfNN_bed): Initialize `elf_backend_grok_freebsd_prstatus'.
 
+2017-10-06  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-i386.c (elf_i386_check_relocs): Replace has_got_reloc
+       and has_non_got_reloc with zero_undefweak.
+       * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
+       * elfxx-x86.c (_bfd_x86_elf_link_hash_newfunc): Initialize
+       zero_undefweak to 1.
+       (_bfd_x86_elf_copy_indirect_symbol): Replace has_got_reloc and
+       has_non_got_reloc with zero_undefweak.
+       * elfxx-x86.h (UNDEFINED_WEAK_RESOLVED_TO_ZERO): Replace
+       has_got_reloc and has_non_got_reloc with zero_undefweak.
+       (elf_x86_link_hash_entry): Likewise.
+
 2017-10-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elfxx-x86.h (COPY_INPUT_RELOC_P): Add "do/while(0);".
index 5fbcd6040e5c683b341dc21445afb8106c9de0ef..f752de6063b33a8b073aa8f48fb95a668a36a5f7 100644 (file)
@@ -1619,7 +1619,7 @@ elf_i386_check_relocs (bfd *abfd,
          if (h == NULL)
            continue;
 
-         eh->has_got_reloc = 1;
+         eh->zero_undefweak &= 0x2;
          h->needs_plt = 1;
          h->plt.refcount += 1;
          break;
@@ -1746,7 +1746,7 @@ elf_i386_check_relocs (bfd *abfd,
          if (r_type != R_386_TLS_IE)
            {
              if (eh != NULL)
-               eh->has_got_reloc = 1;
+               eh->zero_undefweak &= 0x2;
              break;
            }
          /* Fall through */
@@ -1754,7 +1754,7 @@ elf_i386_check_relocs (bfd *abfd,
        case R_386_TLS_LE_32:
        case R_386_TLS_LE:
          if (eh != NULL)
-           eh->has_got_reloc = 1;
+           eh->zero_undefweak &= 0x2;
          if (bfd_link_executable (info))
            break;
          info->flags |= DF_STATIC_TLS;
@@ -1763,7 +1763,7 @@ elf_i386_check_relocs (bfd *abfd,
        case R_386_32:
        case R_386_PC32:
          if (eh != NULL && (sec->flags & SEC_CODE) != 0)
-           eh->has_non_got_reloc = 1;
+           eh->zero_undefweak |= 0x2;
 do_relocation:
          /* We are called after all symbols have been resolved.  Only
             relocation against STT_GNU_IFUNC symbol must go through
index c4cf7ae5e4a3ef36ac4b60204a4bbeb31ca46bce..0b0aa6cb4de419ce7f5c711d3591a12e145a5dc1 100644 (file)
@@ -1958,7 +1958,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
            return elf_x86_64_need_pic (info, abfd, sec, h, symtab_hdr, isym,
                                        &x86_64_elf_howto_table[r_type]);
          if (eh != NULL)
-           eh->has_got_reloc = 1;
+           eh->zero_undefweak &= 0x2;
          break;
 
        case R_X86_64_GOTTPOFF:
@@ -2066,7 +2066,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_X86_64_GOTPC64:
        create_got:
          if (eh != NULL)
-           eh->has_got_reloc = 1;
+           eh->zero_undefweak &= 0x2;
          break;
 
        case R_X86_64_PLT32:
@@ -2083,7 +2083,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
          if (h == NULL)
            continue;
 
-         eh->has_got_reloc = 1;
+         eh->zero_undefweak &= 0x2;
          h->needs_plt = 1;
          h->plt.refcount += 1;
          break;
@@ -2134,7 +2134,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
        case R_X86_64_64:
 pointer:
          if (eh != NULL && (sec->flags & SEC_CODE) != 0)
-           eh->has_non_got_reloc = 1;
+           eh->zero_undefweak |= 0x2;
          /* We are called after all symbols have been resolved.  Only
             relocation against STT_GNU_IFUNC symbol must go through
             PLT.  */
index dcc393b375046a232cdb6a210291ae5ec7a38dce..9d5cfbf7e79abb2597a59164997a9e643e57a9c7 100644 (file)
@@ -676,6 +676,7 @@ _bfd_x86_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
       eh->plt_second.offset = (bfd_vma) -1;
       eh->plt_got.offset = (bfd_vma) -1;
       eh->tlsdesc_got = (bfd_vma) -1;
+      eh->zero_undefweak = 1;
     }
 
   return entry;
@@ -1407,8 +1408,7 @@ _bfd_x86_elf_copy_indirect_symbol (struct bfd_link_info *info,
      generate a R_386_COPY reloc.  */
   edir->gotoff_ref |= eind->gotoff_ref;
 
-  edir->has_got_reloc |= eind->has_got_reloc;
-  edir->has_non_got_reloc |= eind->has_non_got_reloc;
+  edir->zero_undefweak |= eind->zero_undefweak;
 
   if (ELIMINATE_COPY_RELOCS
       && ind->root.type != bfd_link_hash_indirect
index 5dc21b06bfd098a891a99142541d7721a7a1cb56..8e78b7ef602dbc3de608b8f5c61e204be76fc867 100644 (file)
@@ -60,8 +60,7 @@
   ((EH)->elf.root.type == bfd_link_hash_undefweak               \
    && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf)           \
        || (bfd_link_executable (INFO)                           \
-          && (!(EH)->has_got_reloc                              \
-              || (EH)->has_non_got_reloc))))
+          && (EH)->zero_undefweak > 0)))
 
 /* Should copy relocation be generated for a symbol.  Don't generate
    copy relocation against a protected symbol defined in a shared
@@ -236,11 +235,11 @@ struct elf_x86_link_hash_entry
 
   unsigned char tls_type;
 
-  /* TRUE if symbol has GOT or PLT relocations.  */
-  unsigned int has_got_reloc : 1;
-
-  /* TRUE if symbol has non-GOT/non-PLT relocations in text sections.  */
-  unsigned int has_non_got_reloc : 1;
+  /* Bit 0: Symbol has no GOT nor PLT relocations.
+     Bit 1: Symbol has non-GOT/non-PLT relocations in text sections.
+     zero_undefweak is initialized to 1 and undefined weak symbol
+     should be resolved to 0 if zero_undefweak > 0.  */
+  unsigned int zero_undefweak : 2;
 
   /* Don't call finish_dynamic_symbol on this symbol.  */
   unsigned int no_finish_dynamic_symbol : 1;
This page took 0.039353 seconds and 4 git commands to generate.