summaryrefslogtreecommitdiff
path: root/bfd/elfxx-x86.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-08-30 09:10:08 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-08-30 09:10:24 -0700
commit765e526c75506a7d9644bc7c137ac1923fdb1369 (patch)
tree0b715336c005aa362660a4902e6171788efee461 /bfd/elfxx-x86.h
parent70e65ca8e5d1fc984d58f6137c290e807fe772a5 (diff)
x86: Add _bfd_x86_elf_link_hash_table_create
Share _bfd_x86_elf_link_hash_table_create in elf32-i386.c and elf64-x86-64.c by: 1. Replace elf_i386_lazy_plt_layout, elf_i386_non_lazy_plt_layout, elf_i386_plt_layout, elf_x86_64_lazy_plt_layout, elf_x86_64_non_lazy_plt_layout and elf_x86_64_plt_layout with elf_x86_lazy_plt_layout, elf_x86_non_lazy_plt_layout and elf_x86_plt_layout. 2. Move plt, lazy_plt, non_lazy_plt, srelplt2 and next_tls_desc_index from elf_i386_link_hash_table to elf_x86_link_hash_table. 3. Remove elf_i386_link_hash_table and elf_x86_64_link_hash_table. * elf32-i386.c (ELF_DYNAMIC_INTERPRETER): Removed. (elf_i386_lazy_plt_layout): Likewise. (elf_i386_non_lazy_plt_layout): Likewise. (elf_i386_plt_layout): Likewise. (elf_i386_link_hash_table): Likewise. (elf_i386_next_tls_desc_index): Likewise. (elf_i386_srelplt2): Likewise. (elf_i386_plt): Likewise. (elf_i386_lazy_plt): Likewise. (elf_i386_non_lazy_plt): Likewise. (elf_i386_link_hash_table_create): Likewise. (bfd_elf32_bfd_link_hash_table_create): Likewise. (elf_i386_lazy_plt): Updated. (elf_i386_non_lazy_plt): Likewise. (elf_i386_lazy_ibt_plt): Likewise. (elf_i386_non_lazy_ibt_plt): Likewise. (elf_i386_allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. (elf_i386_finish_dynamic_symbol): Likewise. (elf_i386_finish_dynamic_sections): Likewise. (elf_i386_get_synthetic_symtab): Likewise. (elf_i386_link_setup_gnu_properties): Likewise. (elf_i386_nacl_plt): Likewise. * elf64-x86-64.c (ABI_64_P): Removed. (ELF64_DYNAMIC_INTERPRETER): Likewise. (ELF32_DYNAMIC_INTERPRETER): Likewise. (elf_x86_64_lazy_plt_layout): Likewise. (elf_x86_64_non_lazy_plt_layout): Likewise. (elf_x86_64_plt_layout): Likewise. (elf_x86_64_link_hash_table): Likewise. (elf_x86_64_plt): Likewise. (elf_x86_64_lazy_plt): Likewise. (elf_x86_64_non_lazy_plt): Likewise. (elf_x86_64_link_hash_table_create): Likewise. (bfd_elf64_bfd_link_hash_table_create): Likewise. (bfd_elf32_bfd_link_hash_table_create): Likewise. (elf_x86_64_lazy_plt): Updated. (elf_x86_64_non_lazy_plt): Likewise. (elf_x86_64_lazy_bnd_plt): Likewise. (elf_x86_64_non_lazy_bnd_plt): Likewise. (elf_x86_64_lazy_ibt_plt): Likewise. (elf_x32_lazy_ibt_plt): Likewise. (elf_x86_64_non_lazy_ibt_plt): Likewise. (elf_x32_non_lazy_ibt_plt): Likewise. (elf_x86_64_allocate_dynrelocs): Likewise. (elf_x86_64_size_dynamic_sections): Likewise. (elf_x86_64_relocate_section): Likewise. (elf_x86_64_finish_dynamic_symbol): Likewise. (elf_x86_64_finish_dynamic_sections): Likewise. (elf_x86_64_get_synthetic_symtab): Likewise. (elf_x86_64_link_setup_gnu_properties): Likewise. (elf_x86_64_nacl_plt): Likewise. * elfxx-x86.c: Include "objalloc.h", "elf/i386.h" and "elf/x86-64.h". (ELF32_DYNAMIC_INTERPRETER): New. (ELF64_DYNAMIC_INTERPRETER): Likewise. (ELFX32_DYNAMIC_INTERPRETER): Likewise. (_bfd_x86_elf_link_hash_table_create): Likewise. (_bfd_x86_elf_link_hash_table_free): Renamed to ... (elf_x86_link_hash_table_free): This. Make it static. * elfxx-x86.h: Don't include "objalloc.h". (ABI_64_P): New. (elf_x86_lazy_plt_layout): Likewise. (elf_x86_non_lazy_plt_layout): Likewise. (elf_x86_plt_layout): Likewise. (_bfd_x86_elf_link_hash_table_create): Likewise. (bfd_elf64_bfd_link_hash_table_create): Likewise. (bfd_elf32_bfd_link_hash_table_create): Likewise. (elf_x86_link_hash_table): Add plt, lazy_plt, non_lazy_plt, srelplt2 and next_tls_desc_index. (_bfd_x86_elf_link_hash_table_free): Removed.
Diffstat (limited to 'bfd/elfxx-x86.h')
-rw-r--r--bfd/elfxx-x86.h126
1 files changed, 124 insertions, 2 deletions
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 480189bfd4..21e16a2f10 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -24,9 +24,11 @@
#include "libbfd.h"
#include "elf-bfd.h"
#include "bfd_stdint.h"
-#include "objalloc.h"
#include "hashtab.h"
+#define ABI_64_P(abfd) \
+ (get_elf_backend_data (abfd)->s->elfclass == ELFCLASS64)
+
/* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid
copying dynamic variables from a shared lib into an app's dynbss
section, and instead use a dynamic relocation to point into the
@@ -118,6 +120,105 @@ struct elf_x86_link_hash_entry
bfd_vma tlsdesc_got;
};
+struct elf_x86_lazy_plt_layout
+{
+ /* The first entry in an absolute lazy procedure linkage table looks
+ like this. */
+ const bfd_byte *plt0_entry;
+ unsigned int plt0_entry_size; /* Size of PLT0 entry. */
+
+ /* Later entries in an absolute lazy procedure linkage table look
+ like this. */
+ const bfd_byte *plt_entry;
+ unsigned int plt_entry_size; /* Size of each PLT entry. */
+
+ /* Offsets into plt0_entry that are to be replaced with GOT[1] and
+ GOT[2]. */
+ unsigned int plt0_got1_offset;
+ unsigned int plt0_got2_offset;
+
+ /* Offset of the end of the PC-relative instruction containing
+ plt0_got2_offset. This is for x86-64 only. */
+ unsigned int plt0_got2_insn_end;
+
+ /* Offsets into plt_entry that are to be replaced with... */
+ unsigned int plt_got_offset; /* ... address of this symbol in .got. */
+ unsigned int plt_reloc_offset; /* ... offset into relocation table. */
+ unsigned int plt_plt_offset; /* ... offset to start of .plt. */
+
+ /* Length of the PC-relative instruction containing plt_got_offset.
+ This is used for x86-64 only. */
+ unsigned int plt_got_insn_size;
+
+ /* Offset of the end of the PC-relative jump to plt0_entry. This is
+ used for x86-64 only. */
+ unsigned int plt_plt_insn_end;
+
+ /* Offset into plt_entry where the initial value of the GOT entry
+ points. */
+ unsigned int plt_lazy_offset;
+
+ /* The first entry in a PIC lazy procedure linkage table looks like
+ this. This is used for i386 only. */
+ const bfd_byte *pic_plt0_entry;
+
+ /* Subsequent entries in a PIC lazy procedure linkage table look
+ like this. This is used for i386 only. */
+ const bfd_byte *pic_plt_entry;
+
+ /* .eh_frame covering the lazy .plt section. */
+ const bfd_byte *eh_frame_plt;
+ unsigned int eh_frame_plt_size;
+};
+
+struct elf_x86_non_lazy_plt_layout
+{
+ /* Entries in an absolute non-lazy procedure linkage table look like
+ this. */
+ const bfd_byte *plt_entry;
+ /* Entries in a PIC non-lazy procedure linkage table look like this.
+ This is used for i386 only. */
+ const bfd_byte *pic_plt_entry;
+
+ unsigned int plt_entry_size; /* Size of each PLT entry. */
+
+ /* Offsets into plt_entry that are to be replaced with... */
+ unsigned int plt_got_offset; /* ... address of this symbol in .got. */
+
+ /* Length of the PC-relative instruction containing plt_got_offset.
+ This is used for x86-64 only. */
+ unsigned int plt_got_insn_size;
+
+ /* .eh_frame covering the non-lazy .plt section. */
+ const bfd_byte *eh_frame_plt;
+ unsigned int eh_frame_plt_size;
+};
+
+struct elf_x86_plt_layout
+{
+ /* The first entry in a lazy procedure linkage table looks like this.
+ This is only used for i386 where absolute PLT0 and PIC PLT0 are
+ different. */
+ const bfd_byte *plt0_entry;
+ /* Entries in a procedure linkage table look like this. */
+ const bfd_byte *plt_entry;
+ unsigned int plt_entry_size; /* Size of each PLT entry. */
+
+ /* 1 has PLT0. */
+ unsigned int has_plt0;
+
+ /* Offsets into plt_entry that are to be replaced with... */
+ unsigned int plt_got_offset; /* ... address of this symbol in .got. */
+
+ /* Length of the PC-relative instruction containing plt_got_offset.
+ This is only used for x86-64. */
+ unsigned int plt_got_insn_size;
+
+ /* .eh_frame covering the .plt section. */
+ const bfd_byte *eh_frame_plt;
+ unsigned int eh_frame_plt_size;
+};
+
/* The first 3 values in tls_type of x86 ELF linker hash entry. */
#define GOT_UNKNOWN 0
#define GOT_NORMAL 1
@@ -140,6 +241,15 @@ struct elf_x86_link_hash_table
asection *plt_got;
asection *plt_got_eh_frame;
+ /* Parameters describing PLT generation, lazy or non-lazy. */
+ struct elf_x86_plt_layout plt;
+
+ /* Parameters describing lazy PLT generation. */
+ const struct elf_x86_lazy_plt_layout *lazy_plt;
+
+ /* Parameters describing non-lazy PLT generation. */
+ const struct elf_x86_non_lazy_plt_layout *non_lazy_plt;
+
union
{
bfd_signed_vma refcount;
@@ -178,6 +288,14 @@ struct elf_x86_link_hash_table
to read-only sections. */
bfd_boolean readonly_dynrelocs_against_ifunc;
+ /* The (unloaded but important) .rel.plt.unloaded section on VxWorks.
+ This is used for i386 only. */
+ asection *srelplt2;
+
+ /* The index of the next unused R_386_TLS_DESC slot in .rel.plt. This
+ is used for i386 only. */
+ bfd_vma next_tls_desc_index;
+
bfd_vma (*r_info) (bfd_vma, bfd_vma);
bfd_vma (*r_sym) (bfd_vma);
unsigned int pointer_r_type;
@@ -228,7 +346,7 @@ extern int _bfd_x86_elf_local_htab_eq
extern struct bfd_hash_entry * _bfd_x86_elf_link_hash_newfunc
(struct bfd_hash_entry *, struct bfd_hash_table *, const char *);
-extern void _bfd_x86_elf_link_hash_table_free
+extern struct bfd_link_hash_table * _bfd_x86_elf_link_hash_table_create
(bfd *);
extern int _bfd_x86_elf_compare_relocs
@@ -260,6 +378,10 @@ extern enum elf_property_kind _bfd_x86_elf_parse_gnu_properties
extern bfd_boolean _bfd_x86_elf_merge_gnu_properties
(struct bfd_link_info *, bfd *, elf_property *, elf_property *);
+#define bfd_elf64_bfd_link_hash_table_create \
+ _bfd_x86_elf_link_hash_table_create
+#define bfd_elf32_bfd_link_hash_table_create \
+ _bfd_x86_elf_link_hash_table_create
#define bfd_elf64_bfd_link_check_relocs \
_bfd_x86_elf_link_check_relocs
#define bfd_elf32_bfd_link_check_relocs \