diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-10-06 15:25:07 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-10-06 15:29:32 -0700 |
commit | 98b273dc13b1e45db8c66821efc9e514884f3c25 (patch) | |
tree | 92329e76f47f0ae15386ce2669f43617c2666a9b /bfd | |
parent | b3b7c423883ad8d8b81f166ad2d2d4b637086bc0 (diff) | |
download | gdb-98b273dc13b1e45db8c66821efc9e514884f3c25.zip gdb-98b273dc13b1e45db8c66821efc9e514884f3c25.tar.gz gdb-98b273dc13b1e45db8c66821efc9e514884f3c25.tar.bz2 |
x86: Use zero_undefweak in elf_x86_link_hash_entry
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.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 13 | ||||
-rw-r--r-- | bfd/elf32-i386.c | 8 | ||||
-rw-r--r-- | bfd/elf64-x86-64.c | 8 | ||||
-rw-r--r-- | bfd/elfxx-x86.c | 4 | ||||
-rw-r--r-- | bfd/elfxx-x86.h | 13 |
5 files changed, 29 insertions, 17 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index dd25779..de01ad3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -13,6 +13,19 @@ 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);". (VERIFY_COPY_RELOC): Likewise. diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 5fbcd60..f752de6 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -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 diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index c4cf7ae..0b0aa6c 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -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. */ diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c index dcc393b..9d5cfbf 100644 --- a/bfd/elfxx-x86.c +++ b/bfd/elfxx-x86.c @@ -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 diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h index 5dc21b0..8e78b7e 100644 --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -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; |