This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed, PATCH] 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.
---
 bfd/ChangeLog      | 17 +++++++++++++++++
 bfd/elf32-i386.c   |  7 ++-----
 bfd/elf64-x86-64.c |  9 +++------
 bfd/elfxx-x86.c    |  3 +++
 bfd/elfxx-x86.h    |  4 ++++
 5 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 764d3e7766..efee0544f6 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 3d8a4ae897..573a8edcc9 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 300e99ae4f..dcebd68c5a 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 fe5d211af2..6b7c119393 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 0c80ca45be..a95b5c60a2 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 *);
 
-- 
2.13.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]