]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
S/390: z13 use GNU attribute to indicate vector ABI
authorAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Mon, 27 Apr 2015 08:32:23 +0000 (10:32 +0200)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Mon, 27 Apr 2015 08:32:23 +0000 (10:32 +0200)
bfd/
* elf-s390-common.c (elf_s390_merge_obj_attributes): New function.
* elf32-s390.c (elf32_s390_merge_private_bfd_data): Call
elf_s390_merge_obj_attributes.
* elf64-s390.c (elf64_s390_merge_private_bfd_data): New function.

binutils/
* readelf.c (display_s390_gnu_attribute): New function.
(process_s390_specific): New function.
(process_arch_specific): Call process_s390_specific.

gas/
* doc/as.texinfo: Document Tag_GNU_S390_ABI_Vector.

include/elf/
* s390.h: Define Tag_GNU_S390_ABI_Vector.

bfd/ChangeLog
bfd/elf-s390-common.c
bfd/elf32-s390.c
bfd/elf64-s390.c
binutils/ChangeLog
binutils/readelf.c
gas/doc/as.texinfo
gas/testsuite/ChangeLog
include/elf/ChangeLog
include/elf/s390.h

index 367b5ec029f725d8fa91a60dd6aeba18ebdee343..2b4b32f8dde505ddff3807b8cac67a49f4adb64b 100644 (file)
@@ -1,3 +1,10 @@
+2015-04-27  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * elf-s390-common.c (elf_s390_merge_obj_attributes): New function.
+       * elf32-s390.c (elf32_s390_merge_private_bfd_data): Call
+       elf_s390_merge_obj_attributes.
+       * elf64-s390.c (elf64_s390_merge_private_bfd_data): New function.
+
 2015-04-24  Jiong Wang  <jiong.wang@arm.com>
 
        PR ld/18270
index 462da16e1249fe35cb7dede156dfc2ad505c732f..dc6f55b0938357910440fcdb3d0acb6b0797581b 100644 (file)
@@ -254,3 +254,61 @@ elf_s390_elf_sort_relocs_p (asection *sec)
 {
   return (sec->flags & SEC_CODE) == 0;
 }
+
+/* Merge object attributes from IBFD into OBFD.  Raise an error if
+   there are conflicting attributes.  */
+static bfd_boolean
+elf_s390_merge_obj_attributes (bfd *ibfd, bfd *obfd)
+{
+  obj_attribute *in_attr, *in_attrs;
+  obj_attribute *out_attr, *out_attrs;
+
+  if (!elf_known_obj_attributes_proc (obfd)[0].i)
+    {
+      /* This is the first object.  Copy the attributes.  */
+      _bfd_elf_copy_obj_attributes (ibfd, obfd);
+
+      /* Use the Tag_null value to indicate the attributes have been
+        initialized.  */
+      elf_known_obj_attributes_proc (obfd)[0].i = 1;
+
+      return TRUE;
+    }
+
+  in_attrs = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
+  out_attrs = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
+
+  /* Check for conflicting Tag_GNU_S390_ABI_Vector attributes and
+     merge non-conflicting ones.  */
+  in_attr = &in_attrs[Tag_GNU_S390_ABI_Vector];
+  out_attr = &out_attrs[Tag_GNU_S390_ABI_Vector];
+
+  if (in_attr->i > 2)
+    _bfd_error_handler
+      (_("Warning: %B uses unknown vector ABI %d"), ibfd,
+       in_attr->i);
+  else if (out_attr->i > 2)
+    _bfd_error_handler
+      (_("Warning: %B uses unknown vector ABI %d"), obfd,
+       out_attr->i);
+  else if (in_attr->i != out_attr->i)
+    {
+      out_attr->type = ATTR_TYPE_FLAG_INT_VAL;
+
+      if (in_attr->i && out_attr->i)
+       {
+         const char abi_str[3][9] = { "none", "software", "hardware" };
+
+         _bfd_error_handler
+           (_("Warning: %B uses vector %s ABI, %B uses %s ABI"),
+            ibfd, obfd, abi_str[in_attr->i], abi_str[out_attr->i]);
+       }
+      if (in_attr->i > out_attr->i)
+       out_attr->i = in_attr->i;
+    }
+
+  /* Merge Tag_compatibility attributes and any common GNU ones.  */
+  _bfd_elf_merge_object_attributes (ibfd, obfd);
+
+  return TRUE;
+}
index 0127eabe77896472c8656e77fdaf2547052d2fad..19ba0442518066b950aeb2673dc640f6027c01f1 100644 (file)
@@ -3980,9 +3980,18 @@ elf_s390_plt_sym_val (bfd_vma i, const asection *plt,
   return plt->vma + PLT_FIRST_ENTRY_SIZE + i * PLT_ENTRY_SIZE;
 }
 
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
 static bfd_boolean
 elf32_s390_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
 {
+  if (!is_s390_elf (ibfd) || !is_s390_elf (obfd))
+    return TRUE;
+
+  if (!elf_s390_merge_obj_attributes (ibfd, obfd))
+    return FALSE;
+
   elf_elfheader (obfd)->e_flags |= elf_elfheader (ibfd)->e_flags;
   return TRUE;
 }
index f06b58acda95121028599dc4dc779401685c8c9f..c9db9546a93a8158d512093c12c13b67cf528a3b 100644 (file)
@@ -3766,6 +3766,21 @@ elf_s390_plt_sym_val (bfd_vma i, const asection *plt,
   return plt->vma + PLT_FIRST_ENTRY_SIZE + i * PLT_ENTRY_SIZE;
 }
 
+/* Merge backend specific data from an object file to the output
+   object file when linking.  */
+
+static bfd_boolean
+elf64_s390_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+  if (!is_s390_elf (ibfd) || !is_s390_elf (obfd))
+    return TRUE;
+
+  if (!elf_s390_merge_obj_attributes (ibfd, obfd))
+    return FALSE;
+
+  return TRUE;
+}
+
 /* Why was the hash table entry size definition changed from
    ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
    this is the only reason for the s390_elf64_size_info structure.  */
@@ -3824,7 +3839,8 @@ const struct elf_size_info s390_elf64_size_info =
 #define bfd_elf64_bfd_is_local_label_name     elf_s390_is_local_label_name
 #define bfd_elf64_bfd_link_hash_table_create  elf_s390_link_hash_table_create
 #define bfd_elf64_bfd_reloc_type_lookup              elf_s390_reloc_type_lookup
-#define bfd_elf64_bfd_reloc_name_lookup elf_s390_reloc_name_lookup
+#define bfd_elf64_bfd_reloc_name_lookup       elf_s390_reloc_name_lookup
+#define bfd_elf64_bfd_merge_private_bfd_data  elf64_s390_merge_private_bfd_data
 
 #define elf_backend_adjust_dynamic_symbol     elf_s390_adjust_dynamic_symbol
 #define elf_backend_check_relocs             elf_s390_check_relocs
index 44c56b5db31e22a0961df2b530e65484c40d64b9..18f43224787386d83fe050ccc16428bb1a37805a 100644 (file)
@@ -1,3 +1,9 @@
+2015-04-27  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * readelf.c (display_s390_gnu_attribute): New function.
+       (process_s390_specific): New function.
+       (process_arch_specific): Call process_s390_specific.
+
 2015-04-24  Nick Clifton  <nickc@redhat.com>
 
        PR 18313
index dfa5c0b52d696ff2112bf941735625f0bbce5fdc..724df241f5e7fbf3601709d614aa926a6178d239 100644 (file)
@@ -12845,6 +12845,41 @@ display_power_gnu_attribute (unsigned char * p,
   return display_tag_value (tag & 1, p, end);
 }
 
+static unsigned char *
+display_s390_gnu_attribute (unsigned char * p,
+                           int tag,
+                           const unsigned char * const end)
+{
+  unsigned int len;
+  int val;
+
+  if (tag == Tag_GNU_S390_ABI_Vector)
+    {
+      val = read_uleb128 (p, &len, end);
+      p += len;
+      printf ("  Tag_GNU_S390_ABI_Vector: ");
+
+      switch (val)
+       {
+       case 0:
+         printf (_("any\n"));
+         break;
+       case 1:
+         printf (_("software\n"));
+         break;
+       case 2:
+         printf (_("hardware\n"));
+         break;
+       default:
+         printf ("??? (%d)\n", val);
+         break;
+       }
+      return p;
+   }
+
+  return display_tag_value (tag & 1, p, end);
+}
+
 static void
 display_sparc_hwcaps (int mask)
 {
@@ -13615,6 +13650,13 @@ process_power_specific (FILE * file)
                             display_power_gnu_attribute);
 }
 
+static int
+process_s390_specific (FILE * file)
+{
+  return process_attributes (file, NULL, SHT_GNU_ATTRIBUTES, NULL,
+                            display_s390_gnu_attribute);
+}
+
 static int
 process_sparc_specific (FILE * file)
 {
@@ -15609,6 +15651,10 @@ process_arch_specific (FILE * file)
     case EM_PPC:
       return process_power_specific (file);
       break;
+    case EM_S390:
+    case EM_S390_OLD:
+      return process_s390_specific (file);
+      break;
     case EM_SPARC:
     case EM_SPARC32PLUS:
     case EM_SPARCV9:
index 1c2fe081fac572ccbc6427eea9bc17caabafb026..ffdb97816d3921be1261b882d6eb738f74e8e8d2 100644 (file)
@@ -7126,6 +7126,22 @@ The vector ABI used by this object file.  The value will be:
 @end itemize
 @end table
 
+@subsection IBM z Systems Attributes
+
+@table @r
+@item Tag_GNU_S390_ABI_Vector (8)
+The vector ABI used by this object file.  The value will be:
+
+@itemize @bullet
+@item
+0 for files not affected by the vector ABI.
+@item
+1 for files using software vector ABI.
+@item
+2 for files using hardware vector ABI.
+@end itemize
+@end table
+
 @node Defining New Object Attributes
 @section Defining New Object Attributes
 
index 392c6e5e8237b99364ad94907a9d2c8b78a99b39..ca8f1594b905bdc9f11ee9d74602e1d8be0f33a3 100644 (file)
@@ -1,3 +1,7 @@
+2015-04-27  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * doc/as.texinfo: Document Tag_GNU_S390_ABI_Vector.
+
 2015-04-27  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
 
        * gas/s390/zarch-z13.d: Fix tests for VFCE, VLDE, VFSQ, WFK, and
index e4e094b231ade9a01765f877a2489504ba6f17d9..a30b2de82111b98aec51e3e0ddf64a80602f0f3a 100644 (file)
@@ -1,3 +1,7 @@
+2015-04-27  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>
+
+       * s390.h: Define Tag_GNU_S390_ABI_Vector.
+
 2015-04-24  Alan Modra  <amodra@gmail.com>
 
        * internal.h (ELF_SECTION_IN_SEGMENT_1): Ensure PT_LOAD and
index 0642d2e962748d98ce399582a22cc690a79c2323..57bbadd8a9410015520bc7d73b868971032ed15a 100644 (file)
@@ -129,6 +129,17 @@ START_RELOC_NUMBERS (elf_s390_reloc_type)
     RELOC_NUMBER (R_390_GNU_VTENTRY, 251)
 END_RELOC_NUMBERS (R_390_max)
 
-#endif /* _ELF_390_H */
-
+/* Object attribute tags.  */
+enum
+{
+  /* 0-3 are generic. */
+  /* 4 is reserved for the FP ABI. */
+
+  /* Vector ABI:
+     0 = not affected by the vector ABI, or not tagged.
+     1 = software vector ABI being used
+     2 = hardware vector ABI being used.  */
+  Tag_GNU_S390_ABI_Vector = 8,
+};
 
+#endif /* _ELF_390_H */