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.
This commit is contained in:
parent
b3b7c42388
commit
98b273dc13
5 changed files with 29 additions and 17 deletions
|
@ -11,6 +11,19 @@
|
|||
* 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);".
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue