x86: Add sizeof_reloc to elf_x86_link_hash_table
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 2 Sep 2017 12:55:25 +0000 (05:55 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 2 Sep 2017 12:55:25 +0000 (05:55 -0700)
Initialize htab->sizeof_reloc once, instead of computing it every time.

* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
sizeof_reloc.
(_bfd_x86_elf_adjust_dynamic_symbol): Use sizeof_reloc.
* elfxx-x86.h (elf_x86_link_hash_table): Add sizeof_reloc.

bfd/ChangeLog
bfd/elfxx-x86.c
bfd/elfxx-x86.h

index 554c1e7520171d36c988dd3f6ea8bd1ef9f6d917..764d3e7766d92d0fbd2feb330cf056109475b2e9 100644 (file)
@@ -1,3 +1,10 @@
+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.
+       * elfxx-x86.h (elf_x86_link_hash_table): Add sizeof_reloc.
+
 2017-09-02  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-i386.c (elf_i386_allocate_dynrelocs): Check VxWorks
index 50d945ef0ac844e347b6e6184fb487fc83c2c6b6..fe5d211af2d2fe68216adeb490d21b8c6a4577d3 100644 (file)
@@ -277,6 +277,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->pointer_r_type = R_X86_64_64;
       ret->dynamic_interpreter = ELF64_DYNAMIC_INTERPRETER;
       ret->dynamic_interpreter_size = sizeof ELF64_DYNAMIC_INTERPRETER;
@@ -289,6 +290,7 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
       ret->r_sym = elf32_r_sym;
       if (bed->target_id == X86_64_ELF_DATA)
        {
+         ret->sizeof_reloc = sizeof (Elf32_External_Rela);
          ret->pointer_r_type = R_X86_64_32;
          ret->dynamic_interpreter = ELFX32_DYNAMIC_INTERPRETER;
          ret->dynamic_interpreter_size
@@ -297,6 +299,7 @@ _bfd_x86_elf_link_hash_table_create (bfd *abfd)
        }
       else
        {
+         ret->sizeof_reloc = sizeof (Elf32_External_Rel);
          ret->pointer_r_type = R_386_32;
          ret->dynamic_interpreter = ELF32_DYNAMIC_INTERPRETER;
          ret->dynamic_interpreter_size
@@ -735,9 +738,7 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
     }
   if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
-      srel->size += ((bed->target_id == I386_ELF_DATA)
-                    ? sizeof (Elf32_External_Rel)
-                    : bed->s->sizeof_rela);
+      srel->size += htab->sizeof_reloc;
       h->needs_copy = 1;
     }
 
index 86af21f431c6840e80a25f292549dd4b64967bf1..0c80ca45bea0d1fa4c91f032c114ee0ae7d8e1bc 100644 (file)
@@ -313,6 +313,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 pointer_r_type;
   int dynamic_interpreter_size;
   const char *dynamic_interpreter;