mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-09-10 05:52:21 +08:00
Remove x86 gc_sweep_hook
Since x86 backends never see the removed sections, there is no need for gc_sweep_hook. * elf32-i386.c (elf_i386_gc_sweep_hook): Removed. (elf_backend_gc_sweep_hook): Likewise. * elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise. (elf_backend_gc_sweep_hook): Likewise.
This commit is contained in:
@ -1,3 +1,10 @@
|
||||
2016-04-20 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* elf32-i386.c (elf_i386_gc_sweep_hook): Removed.
|
||||
(elf_backend_gc_sweep_hook): Likewise.
|
||||
* elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
|
||||
(elf_backend_gc_sweep_hook): Likewise.
|
||||
|
||||
2016-04-20 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
* elflink.c (_bfd_elf_link_check_relocs): Don't check relocations
|
||||
|
158
bfd/elf32-i386.c
158
bfd/elf32-i386.c
@ -2038,163 +2038,6 @@ elf_i386_gc_mark_hook (asection *sec,
|
||||
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
|
||||
}
|
||||
|
||||
/* Update the got entry reference counts for the section being removed. */
|
||||
|
||||
static bfd_boolean
|
||||
elf_i386_gc_sweep_hook (bfd *abfd,
|
||||
struct bfd_link_info *info,
|
||||
asection *sec,
|
||||
const Elf_Internal_Rela *relocs)
|
||||
{
|
||||
struct elf_i386_link_hash_table *htab;
|
||||
Elf_Internal_Shdr *symtab_hdr;
|
||||
struct elf_link_hash_entry **sym_hashes;
|
||||
bfd_signed_vma *local_got_refcounts;
|
||||
const Elf_Internal_Rela *rel, *relend;
|
||||
|
||||
if (bfd_link_relocatable (info))
|
||||
return TRUE;
|
||||
|
||||
htab = elf_i386_hash_table (info);
|
||||
if (htab == NULL)
|
||||
return FALSE;
|
||||
|
||||
elf_section_data (sec)->local_dynrel = NULL;
|
||||
|
||||
symtab_hdr = &elf_symtab_hdr (abfd);
|
||||
sym_hashes = elf_sym_hashes (abfd);
|
||||
local_got_refcounts = elf_local_got_refcounts (abfd);
|
||||
|
||||
relend = relocs + sec->reloc_count;
|
||||
for (rel = relocs; rel < relend; rel++)
|
||||
{
|
||||
unsigned long r_symndx;
|
||||
unsigned int r_type;
|
||||
struct elf_link_hash_entry *h = NULL;
|
||||
|
||||
r_symndx = ELF32_R_SYM (rel->r_info);
|
||||
if (r_symndx >= symtab_hdr->sh_info)
|
||||
{
|
||||
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
||||
while (h->root.type == bfd_link_hash_indirect
|
||||
|| h->root.type == bfd_link_hash_warning)
|
||||
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A local symbol. */
|
||||
Elf_Internal_Sym *isym;
|
||||
|
||||
isym = bfd_sym_from_r_symndx (&htab->sym_cache,
|
||||
abfd, r_symndx);
|
||||
|
||||
/* Check relocation against local STT_GNU_IFUNC symbol. */
|
||||
if (isym != NULL
|
||||
&& ELF32_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
|
||||
{
|
||||
h = elf_i386_get_local_sym_hash (htab, abfd, rel, FALSE);
|
||||
if (h == NULL)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
if (h)
|
||||
{
|
||||
struct elf_i386_link_hash_entry *eh;
|
||||
struct elf_dyn_relocs **pp;
|
||||
struct elf_dyn_relocs *p;
|
||||
|
||||
eh = (struct elf_i386_link_hash_entry *) h;
|
||||
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
|
||||
if (p->sec == sec)
|
||||
{
|
||||
/* Everything must go for SEC. */
|
||||
*pp = p->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
r_type = ELF32_R_TYPE (rel->r_info);
|
||||
if (! elf_i386_tls_transition (info, abfd, sec, NULL,
|
||||
symtab_hdr, sym_hashes,
|
||||
&r_type, GOT_UNKNOWN,
|
||||
rel, relend, h, r_symndx))
|
||||
return FALSE;
|
||||
|
||||
switch (r_type)
|
||||
{
|
||||
case R_386_TLS_LDM:
|
||||
if (htab->tls_ldm_got.refcount > 0)
|
||||
htab->tls_ldm_got.refcount -= 1;
|
||||
break;
|
||||
|
||||
case R_386_TLS_GD:
|
||||
case R_386_TLS_GOTDESC:
|
||||
case R_386_TLS_DESC_CALL:
|
||||
case R_386_TLS_IE_32:
|
||||
case R_386_TLS_IE:
|
||||
case R_386_TLS_GOTIE:
|
||||
case R_386_GOT32:
|
||||
case R_386_GOT32X:
|
||||
if (h != NULL)
|
||||
{
|
||||
if (h->got.refcount > 0)
|
||||
h->got.refcount -= 1;
|
||||
if (h->type == STT_GNU_IFUNC)
|
||||
{
|
||||
if (h->plt.refcount > 0)
|
||||
h->plt.refcount -= 1;
|
||||
}
|
||||
}
|
||||
else if (local_got_refcounts != NULL)
|
||||
{
|
||||
if (local_got_refcounts[r_symndx] > 0)
|
||||
local_got_refcounts[r_symndx] -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_386_32:
|
||||
case R_386_PC32:
|
||||
case R_386_SIZE32:
|
||||
if (bfd_link_pic (info)
|
||||
&& (h == NULL || h->type != STT_GNU_IFUNC))
|
||||
break;
|
||||
/* Fall through */
|
||||
|
||||
case R_386_PLT32:
|
||||
if (h != NULL)
|
||||
{
|
||||
if (h->plt.refcount > 0)
|
||||
h->plt.refcount -= 1;
|
||||
if (r_type == R_386_32
|
||||
&& (sec->flags & SEC_READONLY) == 0)
|
||||
{
|
||||
struct elf_i386_link_hash_entry *eh
|
||||
= (struct elf_i386_link_hash_entry *) h;
|
||||
if (eh->func_pointer_refcount > 0)
|
||||
eh->func_pointer_refcount -= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case R_386_GOTOFF:
|
||||
if (h != NULL && h->type == STT_GNU_IFUNC)
|
||||
{
|
||||
if (h->got.refcount > 0)
|
||||
h->got.refcount -= 1;
|
||||
if (h->plt.refcount > 0)
|
||||
h->plt.refcount -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Remove undefined weak symbol from the dynamic symbol table if it
|
||||
is resolved to 0. */
|
||||
|
||||
@ -5981,7 +5824,6 @@ elf_i386_add_symbol_hook (bfd * abfd,
|
||||
#define elf_backend_finish_dynamic_sections elf_i386_finish_dynamic_sections
|
||||
#define elf_backend_finish_dynamic_symbol elf_i386_finish_dynamic_symbol
|
||||
#define elf_backend_gc_mark_hook elf_i386_gc_mark_hook
|
||||
#define elf_backend_gc_sweep_hook elf_i386_gc_sweep_hook
|
||||
#define elf_backend_grok_prstatus elf_i386_grok_prstatus
|
||||
#define elf_backend_grok_psinfo elf_i386_grok_psinfo
|
||||
#define elf_backend_reloc_type_class elf_i386_reloc_type_class
|
||||
|
@ -2274,174 +2274,6 @@ elf_x86_64_gc_mark_hook (asection *sec,
|
||||
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
|
||||
}
|
||||
|
||||
/* Update the got entry reference counts for the section being removed. */
|
||||
|
||||
static bfd_boolean
|
||||
elf_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info,
|
||||
asection *sec,
|
||||
const Elf_Internal_Rela *relocs)
|
||||
{
|
||||
struct elf_x86_64_link_hash_table *htab;
|
||||
Elf_Internal_Shdr *symtab_hdr;
|
||||
struct elf_link_hash_entry **sym_hashes;
|
||||
bfd_signed_vma *local_got_refcounts;
|
||||
const Elf_Internal_Rela *rel, *relend;
|
||||
|
||||
if (bfd_link_relocatable (info))
|
||||
return TRUE;
|
||||
|
||||
htab = elf_x86_64_hash_table (info);
|
||||
if (htab == NULL)
|
||||
return FALSE;
|
||||
|
||||
elf_section_data (sec)->local_dynrel = NULL;
|
||||
|
||||
symtab_hdr = &elf_symtab_hdr (abfd);
|
||||
sym_hashes = elf_sym_hashes (abfd);
|
||||
local_got_refcounts = elf_local_got_refcounts (abfd);
|
||||
|
||||
htab = elf_x86_64_hash_table (info);
|
||||
relend = relocs + sec->reloc_count;
|
||||
for (rel = relocs; rel < relend; rel++)
|
||||
{
|
||||
unsigned long r_symndx;
|
||||
unsigned int r_type;
|
||||
struct elf_link_hash_entry *h = NULL;
|
||||
bfd_boolean pointer_reloc;
|
||||
|
||||
r_symndx = htab->r_sym (rel->r_info);
|
||||
if (r_symndx >= symtab_hdr->sh_info)
|
||||
{
|
||||
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
||||
while (h->root.type == bfd_link_hash_indirect
|
||||
|| h->root.type == bfd_link_hash_warning)
|
||||
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* A local symbol. */
|
||||
Elf_Internal_Sym *isym;
|
||||
|
||||
isym = bfd_sym_from_r_symndx (&htab->sym_cache,
|
||||
abfd, r_symndx);
|
||||
|
||||
/* Check relocation against local STT_GNU_IFUNC symbol. */
|
||||
if (isym != NULL
|
||||
&& ELF_ST_TYPE (isym->st_info) == STT_GNU_IFUNC)
|
||||
{
|
||||
h = elf_x86_64_get_local_sym_hash (htab, abfd, rel, FALSE);
|
||||
if (h == NULL)
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
if (h)
|
||||
{
|
||||
struct elf_x86_64_link_hash_entry *eh;
|
||||
struct elf_dyn_relocs **pp;
|
||||
struct elf_dyn_relocs *p;
|
||||
|
||||
eh = (struct elf_x86_64_link_hash_entry *) h;
|
||||
|
||||
for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
|
||||
if (p->sec == sec)
|
||||
{
|
||||
/* Everything must go for SEC. */
|
||||
*pp = p->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
r_type = ELF32_R_TYPE (rel->r_info);
|
||||
if (! elf_x86_64_tls_transition (info, abfd, sec, NULL,
|
||||
symtab_hdr, sym_hashes,
|
||||
&r_type, GOT_UNKNOWN,
|
||||
rel, relend, h, r_symndx))
|
||||
return FALSE;
|
||||
|
||||
pointer_reloc = FALSE;
|
||||
switch (r_type)
|
||||
{
|
||||
case R_X86_64_TLSLD:
|
||||
if (htab->tls_ld_got.refcount > 0)
|
||||
htab->tls_ld_got.refcount -= 1;
|
||||
break;
|
||||
|
||||
case R_X86_64_TLSGD:
|
||||
case R_X86_64_GOTPC32_TLSDESC:
|
||||
case R_X86_64_TLSDESC_CALL:
|
||||
case R_X86_64_GOTTPOFF:
|
||||
case R_X86_64_GOT32:
|
||||
case R_X86_64_GOTPCREL:
|
||||
case R_X86_64_GOTPCRELX:
|
||||
case R_X86_64_REX_GOTPCRELX:
|
||||
case R_X86_64_GOT64:
|
||||
case R_X86_64_GOTPCREL64:
|
||||
case R_X86_64_GOTPLT64:
|
||||
if (h != NULL)
|
||||
{
|
||||
if (h->got.refcount > 0)
|
||||
h->got.refcount -= 1;
|
||||
if (h->type == STT_GNU_IFUNC)
|
||||
{
|
||||
if (h->plt.refcount > 0)
|
||||
h->plt.refcount -= 1;
|
||||
}
|
||||
}
|
||||
else if (local_got_refcounts != NULL)
|
||||
{
|
||||
if (local_got_refcounts[r_symndx] > 0)
|
||||
local_got_refcounts[r_symndx] -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case R_X86_64_32:
|
||||
case R_X86_64_32S:
|
||||
pointer_reloc = !ABI_64_P (abfd);
|
||||
goto pointer;
|
||||
|
||||
case R_X86_64_64:
|
||||
pointer_reloc = TRUE;
|
||||
case R_X86_64_8:
|
||||
case R_X86_64_16:
|
||||
case R_X86_64_PC8:
|
||||
case R_X86_64_PC16:
|
||||
case R_X86_64_PC32:
|
||||
case R_X86_64_PC32_BND:
|
||||
case R_X86_64_PC64:
|
||||
case R_X86_64_SIZE32:
|
||||
case R_X86_64_SIZE64:
|
||||
pointer:
|
||||
if (bfd_link_pic (info)
|
||||
&& (h == NULL || h->type != STT_GNU_IFUNC))
|
||||
break;
|
||||
/* Fall thru */
|
||||
|
||||
case R_X86_64_PLT32:
|
||||
case R_X86_64_PLT32_BND:
|
||||
case R_X86_64_PLTOFF64:
|
||||
if (h != NULL)
|
||||
{
|
||||
if (h->plt.refcount > 0)
|
||||
h->plt.refcount -= 1;
|
||||
if (pointer_reloc && (sec->flags & SEC_READONLY) == 0)
|
||||
{
|
||||
struct elf_x86_64_link_hash_entry *eh
|
||||
= (struct elf_x86_64_link_hash_entry *) h;
|
||||
if (eh->func_pointer_refcount > 0)
|
||||
eh->func_pointer_refcount -= 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Remove undefined weak symbol from the dynamic symbol table if it
|
||||
is resolved to 0. */
|
||||
|
||||
@ -6613,7 +6445,6 @@ static const struct bfd_elf_special_section
|
||||
#define elf_backend_finish_dynamic_sections elf_x86_64_finish_dynamic_sections
|
||||
#define elf_backend_finish_dynamic_symbol elf_x86_64_finish_dynamic_symbol
|
||||
#define elf_backend_gc_mark_hook elf_x86_64_gc_mark_hook
|
||||
#define elf_backend_gc_sweep_hook elf_x86_64_gc_sweep_hook
|
||||
#define elf_backend_grok_prstatus elf_x86_64_grok_prstatus
|
||||
#define elf_backend_grok_psinfo elf_x86_64_grok_psinfo
|
||||
#ifdef CORE_HEADER
|
||||
|
Reference in New Issue
Block a user