diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2017-09-07 04:03:15 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2017-09-07 04:03:30 -0700 |
commit | 6999821f8b1e898f02d0c1196c4c83337c3b565e (patch) | |
tree | afd4c30d7e1fc646fe5c27996bb4ce58db0ec6b8 /bfd/elfxx-x86.h | |
parent | 639257e981e61472e5fc215eb60c5d545ac5e2ab (diff) | |
download | gdb-6999821f8b1e898f02d0c1196c4c83337c3b565e.zip gdb-6999821f8b1e898f02d0c1196c4c83337c3b565e.tar.gz gdb-6999821f8b1e898f02d0c1196c4c83337c3b565e.tar.bz2 |
x86: Remove _bfd_{i386,x86_64}_elf_convert_load
Instead of converting GOT relocations when sizing dynamic sections, we
convert GOT relocations during relocation check. Add a field, local_ref,
to elf_x86_link_hash_entry to indicate if symbol references are always
local with a new function to check if symbol references are always local,
which works in check_relocs.
* elf32-i386.c (elf_i386_convert_load_reloc): Add an argument,
r_type_p. Remove the converted argument. Replace
SYMBOL_REFERENCES_LOCAL with SYMBOL_REFERENCES_LOCAL_P. Return
the new relocation type via r_type_p.
(elf_i386_relocate_section): Likewise.
(elf_i386_finish_dynamic_symbol): Likewise.
(need_convert_load): Removed.
(check_relocs_failed): Updated.
(elf_i386_check_relocs): Call elf_i386_convert_load_reloc,
instead of setting need_convert_load.
(_bfd_i386_elf_convert_load): Removed.
* elf64-x86-64.c (need_convert_load): Removed.
(check_relocs_failed): Updated.
(elf_x86_64_convert_load_reloc): Add an argument, r_type_p.
Replace SYMBOL_REFERENCES_LOCAL with SYMBOL_REFERENCES_LOCAL_P.
Return the new relocation type via r_type_p.
(elf_x86_64_check_relocs): Call elf_x86_64_convert_load_reloc,
instead of setting need_convert_load.
(elf_x86_64_check_relocs): Don't check PIC if relocation has
been converted.
(_bfd_x86_64_elf_convert_load): Removed.
(elf_x86_64_relocate_section): Replace SYMBOL_REFERENCES_LOCAL
with SYMBOL_REFERENCES_LOCAL_P.
(elf_x86_64_finish_dynamic_symbol): Likewise.
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Don't
set convert_load.
(_bfd_x86_elf_size_dynamic_sections): Don't call convert_load.
(_bfd_x86_elf_link_symbol_references_local): New function.
* elfxx-x86.h (SYMBOL_REFERENCES_LOCAL_P): New.
(UNDEFINED_WEAK_RESOLVED_TO_ZERO): Replace elf.forced_local with
SYMBOL_REFERENCES_LOCAL_P.
(elf_x86_link_hash_entry): Add local_ref.
(elf_x86_link_hash_table): Remove convert_load.
(_bfd_i386_elf_convert_load): Removed.
(_bfd_x86_64_elf_convert_load): Likewise.
(_bfd_x86_elf_link_symbol_references_local): New.
Diffstat (limited to 'bfd/elfxx-x86.h')
-rw-r--r-- | bfd/elfxx-x86.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h index 9c0dcbbe..5d0a28a 100644 --- a/bfd/elfxx-x86.h +++ b/bfd/elfxx-x86.h @@ -45,6 +45,10 @@ && elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) == (id) \ ? ((struct elf_x86_link_hash_table *) ((p)->hash)) : NULL) +/* Will references to this symbol always be local in this object? */ +#define SYMBOL_REFERENCES_LOCAL_P(INFO, H) \ + _bfd_x86_elf_link_symbol_references_local ((INFO), (H)) + /* Is a undefined weak symbol which is resolved to 0. Reference to an undefined weak symbol is resolved to 0 when building executable if it isn't dynamic and @@ -54,7 +58,7 @@ */ #define UNDEFINED_WEAK_RESOLVED_TO_ZERO(INFO, ID, GOT_RELOC, EH) \ ((EH)->elf.root.type == bfd_link_hash_undefweak \ - && ((EH)->elf.forced_local \ + && (SYMBOL_REFERENCES_LOCAL_P ((INFO), &(EH)->elf) \ || (bfd_link_executable (INFO) \ && (elf_x86_hash_table ((INFO), (ID))->interp == NULL \ || !(GOT_RELOC) \ @@ -98,6 +102,12 @@ struct elf_x86_link_hash_entry /* TRUE if symbol is defined as a protected symbol. */ unsigned int def_protected : 1; + /* 0: Symbol references are unknown. + 1: Symbol references aren't local. + 2: Symbol references are local. + */ + unsigned int local_ref : 2; + /* Symbol is referenced by R_386_GOTOFF relocation. This is only used by i386. */ unsigned int gotoff_ref : 1; @@ -320,8 +330,6 @@ struct elf_x86_link_hash_table bfd_vma (*r_info) (bfd_vma, bfd_vma); bfd_vma (*r_sym) (bfd_vma); - bfd_boolean (*convert_load) (bfd *, asection *, - struct bfd_link_info *); bfd_boolean (*is_reloc_section) (const char *); enum elf_target_id target_id; unsigned int sizeof_reloc; @@ -405,12 +413,6 @@ struct elf_x86_plt && elf_tdata (bfd) != NULL \ && elf_object_id (bfd) == (htab)->target_id) -extern bfd_boolean _bfd_i386_elf_convert_load - (bfd *, asection *, struct bfd_link_info *); - -extern bfd_boolean _bfd_x86_64_elf_convert_load - (bfd *, asection *, struct bfd_link_info *); - extern bfd_boolean _bfd_x86_elf_mkobject (bfd *); @@ -468,6 +470,9 @@ extern bfd_boolean _bfd_x86_elf_hash_symbol extern bfd_boolean _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *, struct elf_link_hash_entry *); +extern bfd_boolean _bfd_x86_elf_link_symbol_references_local + (struct bfd_link_info *, struct elf_link_hash_entry *); + extern asection * _bfd_x86_elf_gc_mark_hook (asection *, struct bfd_link_info *, Elf_Internal_Rela *, struct elf_link_hash_entry *, Elf_Internal_Sym *); |