aboutsummaryrefslogtreecommitdiff
path: root/bfd/elfxx-x86.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-11-03 11:14:56 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-11-03 11:15:10 -0700
commit79b0c981b8f0c912208ec305d48e775bcb6d2624 (patch)
treefe791c604664a174b872fa4afcc51b8fe7bcb49d /bfd/elfxx-x86.c
parent67fa57cfa536cefb5ae7cc4635db66d03fdbd8bb (diff)
downloadgdb-79b0c981b8f0c912208ec305d48e775bcb6d2624.zip
gdb-79b0c981b8f0c912208ec305d48e775bcb6d2624.tar.gz
gdb-79b0c981b8f0c912208ec305d48e775bcb6d2624.tar.bz2
x86: Remove func_pointer_refcount
Since check_reloc is running after gc_sections, there is no need for reference count. If a function pointer relocation can be resolved at run-time, there is no need for PLT and it doesn't count as non-GOT/PLT relocation. func_pointer_refcount can be removed. * elf32-i386.c (elf_i386_check_relocs): Set plt.refcount to 1. Don't use func_pointer_refcount. Don't set plt.refcount nor non_got_ref for function pointer reference. * elf64-x86-64.c (elf_x86_64_check_relocs): Likewise. * elfxx-x86.c (elf_x86_allocate_dynrelocs): Don't use func_pointer_refcount. (_bfd_x86_elf_copy_indirect_symbol): Don't copy func_pointer_refcount. (_bfd_x86_elf_hide_symbol): Don't use func_pointer_refcount. * elfxx-x86.h (GENERATE_DYNAMIC_RELOCATION_P): Likewise. (elf_x86_link_hash_entry): Remove func_pointer_refcount.
Diffstat (limited to 'bfd/elfxx-x86.c')
-rw-r--r--bfd/elfxx-x86.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index f4466eb..df21d4e 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -108,11 +108,6 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
resolved_to_zero = UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh);
- /* Clear the reference count of function pointer relocations if
- symbol isn't a normal function. */
- if (h->type != STT_FUNC)
- eh->func_pointer_refcount = 0;
-
/* We can't use the GOT PLT if pointer equality is needed since
finish_dynamic_symbol won't clear symbol value and the dynamic
linker won't update the GOT slot. We will get into an infinite
@@ -162,15 +157,11 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
/* Don't create the PLT entry if there are only function pointer
relocations which can be resolved at run-time. */
else if (htab->elf.dynamic_sections_created
- && (h->plt.refcount > eh->func_pointer_refcount
+ && (h->plt.refcount > 0
|| eh->plt_got.refcount > 0))
{
bfd_boolean use_plt_got = eh->plt_got.refcount > 0;
- /* Clear the reference count of function pointer relocations
- if PLT is used. */
- eh->func_pointer_refcount = 0;
-
/* Make sure this symbol is output as a dynamic symbol.
Undefined weak syms won't yet be marked as dynamic. */
if (h->dynindx == -1
@@ -488,7 +479,6 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
pointer initialization. */
if ((!h->non_got_ref
- || eh->func_pointer_refcount > 0
|| (h->root.type == bfd_link_hash_undefweak
&& !resolved_to_zero))
&& ((h->def_dynamic
@@ -513,7 +503,6 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
}
eh->dyn_relocs = NULL;
- eh->func_pointer_refcount = 0;
keep: ;
}
@@ -1643,15 +1632,7 @@ _bfd_x86_elf_copy_indirect_symbol (struct bfd_link_info *info,
dir->pointer_equality_needed |= ind->pointer_equality_needed;
}
else
- {
- if (eind->func_pointer_refcount > 0)
- {
- edir->func_pointer_refcount += eind->func_pointer_refcount;
- eind->func_pointer_refcount = 0;
- }
-
- _bfd_elf_link_hash_copy_indirect (info, dir, ind);
- }
+ _bfd_elf_link_hash_copy_indirect (info, dir, ind);
}
/* Remove undefined weak symbol from the dynamic symbol table if it
@@ -1900,7 +1881,7 @@ _bfd_x86_elf_hide_symbol (struct bfd_link_info *info,
weak symbol dynamic so that PC relative branch to the undefined
weak symbol will land to address 0. */
struct elf_x86_link_hash_entry *eh = elf_x86_hash_entry (h);
- if (h->plt.refcount > eh->func_pointer_refcount
+ if (h->plt.refcount > 0
|| eh->plt_got.refcount > 0)
return;
}