aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-09-02 07:16:33 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-09-02 07:18:55 -0700
commit9ff114ca5d2c2753f1ac110f8586d0040c27a7a3 (patch)
treef5d17bbdf1bc70f396096e2bdc826dac90ad0b4e
parent503294e755498eb6545ca72b338c5037facab7f7 (diff)
downloadgdb-9ff114ca5d2c2753f1ac110f8586d0040c27a7a3.zip
gdb-9ff114ca5d2c2753f1ac110f8586d0040c27a7a3.tar.gz
gdb-9ff114ca5d2c2753f1ac110f8586d0040c27a7a3.tar.bz2
x86: Add elf_x86_compute_jump_table_size
Share elf_x86_compute_jump_table_size in elf32-i386.c and elf64-x86-64.c. * elf32-i386.c (elf_i386_compute_jump_table_size): Removed. (elf_i386_allocate_dynrelocs): Replace elf_i386_compute_jump_table_size with elf_x86_compute_jump_table_size. (elf_i386_size_dynamic_sections): Likewise. * elf64-x86-64.c (elf_x86_64_compute_jump_table_size): Removed. (elf_x86_64_allocate_dynrelocs): Replace elf_x86_64_compute_jump_table_size with elf_x86_compute_jump_table_size. (elf_x86_64_size_dynamic_sections): Likewise. * elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize got_entry_size. * elfxx-x86.h (elf_x86_link_hash_table): Add got_entry_size. (elf_x86_compute_jump_table_size): New.
-rw-r--r--bfd/ChangeLog17
-rw-r--r--bfd/elf32-i386.c7
-rw-r--r--bfd/elf64-x86-64.c9
-rw-r--r--bfd/elfxx-x86.c3
-rw-r--r--bfd/elfxx-x86.h4
5 files changed, 29 insertions, 11 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 764d3e7..efee054 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,22 @@
2017-09-02 H.J. Lu <hongjiu.lu@intel.com>
+ * elf32-i386.c (elf_i386_compute_jump_table_size): Removed.
+ (elf_i386_allocate_dynrelocs): Replace
+ elf_i386_compute_jump_table_size with
+ elf_x86_compute_jump_table_size.
+ (elf_i386_size_dynamic_sections): Likewise.
+ * elf64-x86-64.c (elf_x86_64_compute_jump_table_size): Removed.
+ (elf_x86_64_allocate_dynrelocs): Replace
+ elf_x86_64_compute_jump_table_size with
+ elf_x86_compute_jump_table_size.
+ (elf_x86_64_size_dynamic_sections): Likewise.
+ * elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
+ got_entry_size.
+ * elfxx-x86.h (elf_x86_link_hash_table): Add got_entry_size.
+ (elf_x86_compute_jump_table_size): New.
+
+2017-09-02 H.J. Lu <hongjiu.lu@intel.com>
+
* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
sizeof_reloc.
(_bfd_x86_elf_adjust_dynamic_symbol): Use sizeof_reloc.
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 3d8a4ae..573a8ed 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -858,9 +858,6 @@ static const struct elf_i386_backend_data elf_i386_arch_bed =
&& elf_tdata (bfd) != NULL \
&& elf_object_id (bfd) == I386_ELF_DATA)
-#define elf_i386_compute_jump_table_size(htab) \
- ((htab)->elf.srelplt->reloc_count * 4)
-
/* Return TRUE if the TLS access code sequence support transition
from R_TYPE. */
@@ -2206,7 +2203,7 @@ elf_i386_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
if (GOT_TLS_GDESC_P (tls_type))
{
eh->tlsdesc_got = htab->elf.sgotplt->size
- - elf_i386_compute_jump_table_size (htab);
+ - elf_x86_compute_jump_table_size (htab);
htab->elf.sgotplt->size += 8;
h->got.offset = (bfd_vma) -2;
}
@@ -2637,7 +2634,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
if (GOT_TLS_GDESC_P (*local_tls_type))
{
*local_tlsdesc_gotent = htab->elf.sgotplt->size
- - elf_i386_compute_jump_table_size (htab);
+ - elf_x86_compute_jump_table_size (htab);
htab->elf.sgotplt->size += 8;
*local_got = (bfd_vma) -2;
}
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 300e99a..dcebd68 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -973,9 +973,6 @@ static const struct elf_x86_64_backend_data elf_x86_64_arch_bed =
&& elf_tdata (bfd) != NULL \
&& elf_object_id (bfd) == X86_64_ELF_DATA)
-#define elf_x86_64_compute_jump_table_size(htab) \
- ((htab)->elf.srelplt->reloc_count * GOT_ENTRY_SIZE)
-
static bfd_boolean
elf64_x86_64_elf_object_p (bfd *abfd)
{
@@ -2632,7 +2629,7 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
if (GOT_TLS_GDESC_P (tls_type))
{
eh->tlsdesc_got = htab->elf.sgotplt->size
- - elf_x86_64_compute_jump_table_size (htab);
+ - elf_x86_compute_jump_table_size (htab);
htab->elf.sgotplt->size += 2 * GOT_ENTRY_SIZE;
h->got.offset = (bfd_vma) -2;
}
@@ -3035,7 +3032,7 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd,
if (GOT_TLS_GDESC_P (*local_tls_type))
{
*local_tlsdesc_gotent = htab->elf.sgotplt->size
- - elf_x86_64_compute_jump_table_size (htab);
+ - elf_x86_compute_jump_table_size (htab);
htab->elf.sgotplt->size += 2 * GOT_ENTRY_SIZE;
*local_got = (bfd_vma) -2;
}
@@ -3099,7 +3096,7 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd,
if (htab->elf.srelplt)
{
htab->sgotplt_jump_table_size
- = elf_x86_64_compute_jump_table_size (htab);
+ = elf_x86_compute_jump_table_size (htab);
htab->next_irelative_index = htab->elf.srelplt->reloc_count - 1;
}
else if (htab->elf.irelplt)
diff --git a/bfd/elfxx-x86.c b/bfd/elfxx-x86.c
index fe5d211..6b7c119 100644
--- a/bfd/elfxx-x86.c
+++ b/bfd/elfxx-x86.c
@@ -278,6 +278,7 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
ret->r_info = elf64_r_info;
ret->r_sym = elf64_r_sym;
ret->sizeof_reloc = sizeof (Elf64_External_Rela);
+ ret->got_entry_size = 8;
ret->pointer_r_type = R_X86_64_64;
ret->dynamic_interpreter = ELF64_DYNAMIC_INTERPRETER;
ret->dynamic_interpreter_size = sizeof ELF64_DYNAMIC_INTERPRETER;
@@ -291,6 +292,7 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
if (bed->target_id == X86_64_ELF_DATA)
{
ret->sizeof_reloc = sizeof (Elf32_External_Rela);
+ ret->got_entry_size = 8;
ret->pointer_r_type = R_X86_64_32;
ret->dynamic_interpreter = ELFX32_DYNAMIC_INTERPRETER;
ret->dynamic_interpreter_size
@@ -300,6 +302,7 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
else
{
ret->sizeof_reloc = sizeof (Elf32_External_Rel);
+ ret->got_entry_size = 4;
ret->pointer_r_type = R_386_32;
ret->dynamic_interpreter = ELF32_DYNAMIC_INTERPRETER;
ret->dynamic_interpreter_size
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index 0c80ca4..a95b5c6 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -314,6 +314,7 @@ struct elf_x86_link_hash_table
bfd_vma (*r_info) (bfd_vma, bfd_vma);
bfd_vma (*r_sym) (bfd_vma);
unsigned int sizeof_reloc;
+ unsigned int got_entry_size;
unsigned int pointer_r_type;
int dynamic_interpreter_size;
const char *dynamic_interpreter;
@@ -382,6 +383,9 @@ struct elf_x86_plt
#define elf_x86_local_tlsdesc_gotent(abfd) \
(elf_x86_tdata (abfd)->local_tlsdesc_gotent)
+#define elf_x86_compute_jump_table_size(htab) \
+ ((htab)->elf.srelplt->reloc_count * (htab)->got_entry_size)
+
extern bfd_boolean _bfd_x86_elf_mkobject
(bfd *);