summaryrefslogtreecommitdiff
path: root/bfd/elfxx-x86.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-09-02 07:37:05 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-09-02 15:12:04 -0700
commit5e2ac45d561dffec63af4c83a545b46db032c70c (patch)
treee9a264c81105fc2f48427635a068e8f4c92aa448 /bfd/elfxx-x86.h
parent2926eb2c326c625f54db61796fbe034b31f0958f (diff)
x86: Add _bfd_x86_elf_size_dynamic_sections
elf_i386_size_dynamic_sections and elf_x86_64_size_dynamic_sections are very similar, except for the followings: 1. elf_i386_size_dynamic_sections checks GOT_TLS_IE and GOT_TLS_IE_BOTH. elf_x86_64_size_dynamic_sections checks only GOT_TLS_IE. Since GOT_TLS_IE_BOTH is never true for x86-64, it is OK to check GOT_TLS_IE for both i386 and x86-64. 2, x86-64 sets tlsdesc_plt, but i386 doesn't. We set tlsdesc_plt only if target_id == X86_64_ELF_DATA. 3. x86-64 has if (s != htab->elf.srelplt) s->reloc_count = 0; and i386 has s->reloc_count = 0; i386 did have if (s != htab->srelplt) s->reloc_count = 0; in the original commit: commit 67a4f2b710581acc83afecff55424af285ecbc28 Author: Alexandre Oliva <aoliva@redhat.com> Date: Wed Jan 18 21:07:51 2006 +0000 But it was removed by commit 5ae0bfb60a576344d7f701605346282c1144499e Author: Richard Sandiford <rdsandiford@googlemail.com> Date: Tue Feb 28 07:16:12 2006 +0000 bfd/ * elf32-i386.c (elf_i386_link_hash_table): Add next_tls_desc_index. (elf_i386_link_hash_table_create): Initialize it. (elf_i386_compute_jump_table_size): Use it instead of srelplt->reloc_count. (allocate_dynrelocs): Likewise. (elf_i386_size_dynamic_sections): Likewise. (elf_i386_relocate_section): Likewise. A later commit: commit e1f987424b7b3f5ac63a2a6ae044a202a44b8ff8 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Oct 21 15:13:37 2011 +0000 Put IRELATIVE relocations after JUMP_SLOT. bfd/ 2011-10-21 H.J. Lu <hongjiu.lu@intel.com> PR ld/13302 * elf32-i386.c (elf_i386_link_hash_table): Add next_jump_slot_index and next_irelative_index. (elf_i386_link_hash_table_create): Initialize next_jump_slot_index and next_irelative_index. (elf_i386_allocate_dynrelocs): Increment reloc_count instead of next_tls_desc_index. (elf_i386_size_dynamic_sections): Set next_tls_desc_index and next_irelative_index from reloc_count. (elf_i386_finish_dynamic_symbol): Put R_386_IRELATIVE after R_386_JUMP_SLOT. changed it back to use reloc_count again. So it is correct to use if (s != htab->elf.srelplt) s->reloc_count = 0; for both i386 and x86-64 now. 4. i386 and x86-64 use different DT_XXXs. They are handled by adding them to elf_x86_link_hash_table. With these changes, we can share _bfd_x86_elf_size_dynamic_sections in elf32-i386.c and elf64-x86-64.c. * elf32-i386.c (elf_i386_convert_load): Renamed to ... (_bfd_i386_elf_convert_load): This. Remove static. (elf_i386_size_dynamic_sections): Removed. (elf_backend_size_dynamic_sections): Likewise. * elf64-x86-64.c (elf_x86_64_convert_load): Renamed to ... (_bfd_x86_64_elf_convert_load): This. Remove static. (elf_x86_64_size_dynamic_sections): Removed. (elf_backend_size_dynamic_sections): Likewise. * elfxx-x86.c (_bfd_x86_elf_allocate_dynrelocs): Renamed to ... (elf_x86_allocate_dynrelocs): This. Make it static. (_bfd_x86_elf_allocate_local_dynrelocs): Renamed to ... (elf_x86_allocate_local_dynreloc): This. Make it static. (elf_i386_is_reloc_section): New function. (elf_x86_64_is_reloc_section): Likewise. (_bfd_x86_elf_link_hash_table_create): Initialize convert_load, is_reloc_section, dt_reloc, dt_reloc_sz and dt_reloc_ent. Rearrange got_entry_size initialization. (_bfd_x86_elf_size_dynamic_sections): New function. * elfxx-x86.h (elf_x86_link_hash_table): Add convert_load, is_reloc_section, dt_reloc, dt_reloc_sz and dt_reloc_ent. (_bfd_i386_elf_convert_load): New. (_bfd_x86_64_elf_convert_load): Likewise. (_bfd_x86_elf_size_dynamic_sections): Likewise. (elf_backend_size_dynamic_sections): Likewise. (_bfd_x86_elf_allocate_dynrelocs): Removed. (_bfd_x86_elf_allocate_local_dynrelocs): Likewise.
Diffstat (limited to 'bfd/elfxx-x86.h')
-rw-r--r--bfd/elfxx-x86.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 8b99835db3..61244f5dfe 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -319,8 +319,14 @@ 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;
+ unsigned int dt_reloc;
+ unsigned int dt_reloc_sz;
+ unsigned int dt_reloc_ent;
unsigned int got_entry_size;
unsigned int pointer_r_type;
int dynamic_interpreter_size;
@@ -398,6 +404,12 @@ 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 *);
@@ -407,12 +419,6 @@ extern void _bfd_x86_elf_set_tls_module_base
extern bfd_vma _bfd_x86_elf_dtpoff_base
(struct bfd_link_info *);
-extern bfd_boolean _bfd_x86_elf_allocate_dynrelocs
- (struct elf_link_hash_entry *, void *);
-
-extern bfd_boolean _bfd_x86_elf_allocate_local_dynrelocs
- (void **, void *);
-
extern bfd_boolean _bfd_x86_elf_readonly_dynrelocs
(struct elf_link_hash_entry *, void *);
@@ -438,6 +444,9 @@ extern int _bfd_x86_elf_compare_relocs
extern bfd_boolean _bfd_x86_elf_link_check_relocs
(bfd *, struct bfd_link_info *);
+extern bfd_boolean _bfd_x86_elf_size_dynamic_sections
+ (bfd *, struct bfd_link_info *);
+
extern bfd_boolean _bfd_x86_elf_always_size_sections
(bfd *, struct bfd_link_info *);
@@ -488,6 +497,8 @@ extern bfd * _bfd_x86_elf_link_setup_gnu_properties
#define bfd_elf32_bfd_link_check_relocs \
_bfd_x86_elf_link_check_relocs
+#define elf_backend_size_dynamic_sections \
+ _bfd_x86_elf_size_dynamic_sections
#define elf_backend_always_size_sections \
_bfd_x86_elf_always_size_sections
#define elf_backend_merge_symbol_attribute \