]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Add is_solaris to elf_x86_target_os
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 9 Feb 2018 16:44:42 +0000 (08:44 -0800)
committerRoland McGrath <mcgrathr@google.com>
Tue, 24 Apr 2018 19:03:13 +0000 (12:03 -0700)
Add is_solaris to elf_x86_target_os since Solaris is quite different.

* elf32-i386.c (elf_i386_get_synthetic_symtab): Also handle
is_solaris.
(i386_elf32_sol2_vec): Don't declare.
(elf_i386_link_setup_gnu_properties): Also handle is_solaris.
Don't set need_global_offset_table.
(elf_i386_solaris_arch_bed): New.
(elf_backend_arch_data): Set to elf_i386_solaris_arch_bed for
Solaris.
* elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Check
target_os != is_nacl instead of target_os == is_normal.
(x86_64_elf64_sol2_vec): Don't declare.
(elf_x86_64_link_setup_gnu_properties): Check target_os !=
is_nacl instead of target_os == is_normal.  Don't set
need_global_offset_table.
(elf_x86_64_solaris_arch_bed): New.
(elf_backend_arch_data): Set to elf_x86_64_solaris_arch_bed for
Solaris.
* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep
_GLOBAL_OFFSET_TABLE_ for Solaris.
(_bfd_x86_elf_link_setup_gnu_properties): Don't copy
need_global_offset_table.
* elfxx-x86.h (elf_x86_target_os): Add is_solaris.
(elf_x86_link_hash_table): Remove need_global_offset_table.
(elf_x86_init_table): Likewise.

(cherry picked from commit 3b4c384407ebbdd9ed4ad5057080b3be038b8748)

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.c
bfd/elfxx-x86.h

index 178bf83204de0351a03a1fa3761525c12c47fe17..ad41bbf8608fb4d12be1e780bc182dfc6e0c9c03 100644 (file)
@@ -1,3 +1,30 @@
+2018-02-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-i386.c (elf_i386_get_synthetic_symtab): Also handle
+       is_solaris.
+       (i386_elf32_sol2_vec): Don't declare.
+       (elf_i386_link_setup_gnu_properties): Also handle is_solaris.
+       Don't set need_global_offset_table.
+       (elf_i386_solaris_arch_bed): New.
+       (elf_backend_arch_data): Set to elf_i386_solaris_arch_bed for
+       Solaris.
+       * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Check
+       target_os != is_nacl instead of target_os == is_normal.
+       (x86_64_elf64_sol2_vec): Don't declare.
+       (elf_x86_64_link_setup_gnu_properties): Check target_os !=
+       is_nacl instead of target_os == is_normal.  Don't set
+       need_global_offset_table.
+       (elf_x86_64_solaris_arch_bed): New.
+       (elf_backend_arch_data): Set to elf_x86_64_solaris_arch_bed for
+       Solaris.
+       * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep
+       _GLOBAL_OFFSET_TABLE_ for Solaris.
+       (_bfd_x86_elf_link_setup_gnu_properties): Don't copy
+       need_global_offset_table.
+       * elfxx-x86.h (elf_x86_target_os): Add is_solaris.
+       (elf_x86_link_hash_table): Remove need_global_offset_table.
+       (elf_x86_init_table): Likewise.
+
 2018-02-08  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf32-i386.c (elf32_i386_copy_solaris_special_section_fields):
index 4988359b2a3928d5c1fd83422c800fa820ab48d9..ba567a4440ef52df018d7254cfbc8d05e7d50360 100644 (file)
@@ -4193,6 +4193,7 @@ elf_i386_get_synthetic_symtab (bfd *abfd,
   switch (get_elf_x86_backend_data (abfd)->target_os)
     {
     case is_normal:
+    case is_solaris:
       non_lazy_plt = &elf_i386_non_lazy_plt;
       lazy_ibt_plt = &elf_i386_lazy_ibt_plt;
       non_lazy_ibt_plt = &elf_i386_non_lazy_ibt_plt;
@@ -4348,11 +4349,11 @@ static bfd *
 elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
 {
   struct elf_x86_init_table init_table;
-  const struct elf_backend_data *bed;
 
   switch (get_elf_x86_backend_data (info->output_bfd)->target_os)
     {
     case is_normal:
+    case is_solaris:
       init_table.plt0_pad_byte = 0x0;
       init_table.lazy_plt = &elf_i386_lazy_plt;
       init_table.non_lazy_plt = &elf_i386_non_lazy_plt;
@@ -4378,11 +4379,6 @@ elf_i386_link_setup_gnu_properties (struct bfd_link_info *info)
   init_table.r_info = elf32_r_info;
   init_table.r_sym = elf32_r_sym;
 
-  bed = get_elf_backend_data (info->output_bfd);
-  init_table.need_global_offset_table
-    = (bed->elf_backend_copy_special_section_fields
-       == elf32_i386_copy_solaris_special_section_fields);
-
   return _bfd_x86_elf_link_setup_gnu_properties (info, &init_table);
 }
 
@@ -4475,6 +4471,14 @@ elf_i386_fbsd_post_process_headers (bfd *abfd, struct bfd_link_info *info)
 #undef TARGET_LITTLE_NAME
 #define        TARGET_LITTLE_NAME              "elf32-i386-sol2"
 
+static const struct elf_x86_backend_data elf_i386_solaris_arch_bed =
+  {
+    is_solaris                         /* os */
+  };
+
+#undef elf_backend_arch_data
+#define        elf_backend_arch_data           &elf_i386_solaris_arch_bed
+
 #undef elf_backend_post_process_headers
 
 /* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
@@ -4601,6 +4605,9 @@ elf32_iamcu_elf_object_p (bfd *abfd)
 #undef ELF_MACHINE_CODE
 #define        ELF_MACHINE_CODE                EM_IAMCU
 
+#undef elf_backend_arch_data
+#define        elf_backend_arch_data           &elf_i386_arch_bed
+
 #undef ELF_OSABI
 
 #undef  elf32_bed
index 18e1179a3a70b32517b44d955abaed6b5436ba0c..a3feddb923737292d38da9672de029170ef44e1f 100644 (file)
@@ -4528,7 +4528,7 @@ elf_x86_64_get_synthetic_symtab (bfd *abfd,
   if (relsize <= 0)
     return -1;
 
-  if (get_elf_x86_backend_data (abfd)->target_os == is_normal)
+  if (get_elf_x86_backend_data (abfd)->target_os != is_nacl)
     {
       lazy_plt = &elf_x86_64_lazy_plt;
       non_lazy_plt = &elf_x86_64_non_lazy_plt;
@@ -4867,7 +4867,6 @@ static bfd *
 elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
 {
   struct elf_x86_init_table init_table;
-  const struct elf_backend_data *bed;
 
   if ((int) R_X86_64_standard >= (int) R_X86_64_converted_reloc_bit
       || (int) R_X86_64_max <= (int) R_X86_64_converted_reloc_bit
@@ -4880,8 +4879,7 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
   /* This is unused for x86-64.  */
   init_table.plt0_pad_byte = 0x90;
 
-  if (get_elf_x86_backend_data (info->output_bfd)->target_os
-      == is_normal)
+  if (get_elf_x86_backend_data (info->output_bfd)->target_os != is_nacl)
     {
       if (info->bndplt)
        {
@@ -4924,11 +4922,6 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
       init_table.r_sym = elf32_r_sym;
     }
 
-  bed = get_elf_backend_data (info->output_bfd);
-  init_table.need_global_offset_table
-    = (bed->elf_backend_copy_special_section_fields
-       == elf64_x86_64_copy_solaris_special_section_fields);
-
   return _bfd_x86_elf_link_setup_gnu_properties (info, &init_table);
 }
 
@@ -5054,6 +5047,14 @@ elf_x86_64_special_sections[]=
 #undef  TARGET_LITTLE_NAME
 #define TARGET_LITTLE_NAME                 "elf64-x86-64-sol2"
 
+static const struct elf_x86_backend_data elf_x86_64_solaris_arch_bed =
+  {
+    is_solaris                             /* os */
+  };
+
+#undef elf_backend_arch_data
+#define        elf_backend_arch_data               &elf_x86_64_solaris_arch_bed
+
 /* Restore default: we cannot use ELFOSABI_SOLARIS, otherwise ELFOSABI_NONE
    objects won't be recognized.  */
 #undef ELF_OSABI
index b0eb1c8d0f67f03ea954107bbdbc66a39e0b1f96..fc08d1b977fc9a238bc57693caefd267bf5a656c 100644 (file)
@@ -1098,8 +1098,9 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
              || htab->elf.igotplt->size == 0))
        {
          htab->elf.sgotplt->size = 0;
-         if (htab->elf.hgot != NULL
-             && !htab->need_global_offset_table)
+         /* Solaris requires to keep _GLOBAL_OFFSET_TABLE_ even if it
+            isn't used.  */
+         if (htab->elf.hgot != NULL && htab->target_os != is_solaris)
            {
              /* Remove the unused _GLOBAL_OFFSET_TABLE_ from symbol
                 table. */
@@ -2464,7 +2465,6 @@ error_alignment:
     return pbfd;
 
   htab->plt0_pad_byte = init_table->plt0_pad_byte;
-  htab->need_global_offset_table = init_table->need_global_offset_table;
 
   use_ibt_plt = info->ibtplt || info->ibt;
   if (!use_ibt_plt && pbfd != NULL)
index 4606bf19b682214a4abc38d5467e445a9b32a4d6..a7bd49e05b6551fa3498de8677cffb3a4d9cbadf 100644 (file)
@@ -401,6 +401,7 @@ struct elf_x86_plt_layout
 enum elf_x86_target_os
 {
   is_normal,
+  is_solaris,
   is_vxworks,
   is_nacl
 };
@@ -481,9 +482,6 @@ struct elf_x86_link_hash_table
   /* TRUE if GOT is referenced.  */
   unsigned int got_referenced : 1;
 
-  /* TRUE if _GLOBAL_OFFSET_TABLE_ is needed.  */
-  unsigned int need_global_offset_table : 1;
-
   bfd_vma (*r_info) (bfd_vma, bfd_vma);
   bfd_vma (*r_sym) (bfd_vma);
   bfd_boolean (*is_reloc_section) (const char *);
@@ -528,9 +526,6 @@ struct elf_x86_init_table
 
   bfd_byte plt0_pad_byte;
 
-  /* TRUE if _GLOBAL_OFFSET_TABLE_ is needed.  */
-  unsigned int need_global_offset_table : 1;
-
   bfd_vma (*r_info) (bfd_vma, bfd_vma);
   bfd_vma (*r_sym) (bfd_vma);
 };