bfd:
authorJoseph Myers <joseph@codesourcery.com>
Sat, 30 Jun 2007 00:03:40 +0000 (00:03 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Sat, 30 Jun 2007 00:03:40 +0000 (00:03 +0000)
* elf32-ppc.c (ppc_elf_merge_obj_attributes): New.
(ppc_elf_merge_private_bfd_data): Call it.

binutils:
* readelf.c (display_power_gnu_attribute, process_power_specific):
New.
(process_arch_specific): Call process_power_specific.

include/elf:
* ppc.h (Tag_GNU_Power_ABI_FP): Define.

ld/testsuite:
* ld-powerpc/attr-gnu-4-0.s, ld-powerpc/attr-gnu-4-00.d,
ld-powerpc/attr-gnu-4-01.d, ld-powerpc/attr-gnu-4-02.d,
ld-powerpc/attr-gnu-4-1.s, ld-powerpc/attr-gnu-4-10.d,
ld-powerpc/attr-gnu-4-11.d, ld-powerpc/attr-gnu-4-12.d,
ld-powerpc/attr-gnu-4-13.d, ld-powerpc/attr-gnu-4-2.s,
ld-powerpc/attr-gnu-4-20.d, ld-powerpc/attr-gnu-4-21.d,
ld-powerpc/attr-gnu-4-22.d, ld-powerpc/attr-gnu-4-3.s,
ld-powerpc/attr-gnu-4-31.d: New.
* ld-powerpc/powerpc.exp: Run these new tests.

23 files changed:
bfd/ChangeLog
bfd/elf32-ppc.c
binutils/ChangeLog
binutils/readelf.c
include/elf/ChangeLog
include/elf/ppc.h
ld/testsuite/ChangeLog
ld/testsuite/ld-powerpc/attr-gnu-4-0.s [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-00.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-01.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-02.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-1.s [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-10.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-11.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-12.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-13.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-2.s [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-20.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-21.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-22.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-3.s [new file with mode: 0644]
ld/testsuite/ld-powerpc/attr-gnu-4-31.d [new file with mode: 0644]
ld/testsuite/ld-powerpc/powerpc.exp

index 92de3e5f4031b6be38e5bccfb1b4a6b508e3bd42..bd2a82c23548fce2670b7b1e448baf7387414ca9 100644 (file)
@@ -1,3 +1,8 @@
+2007-06-29  Joseph Myers  <joseph@codesourcery.com>
+
+       * elf32-ppc.c (ppc_elf_merge_obj_attributes): New.
+       (ppc_elf_merge_private_bfd_data): Call it.
+
 2007-06-29  Joseph Myers  <joseph@codesourcery.com>
 
        * elfxx-mips.c (mips_elf_merge_obj_attributes): New.
index b84f0af2ad8171253195a4a506ad9e6a1eb87511..d67ad866a6f0d7d5df4cdf6743c454fdb0a4418c 100644 (file)
@@ -3594,6 +3594,62 @@ ppc_elf_check_relocs (bfd *abfd,
   return TRUE;
 }
 \f
+
+/* Merge object attributes from IBFD into OBFD.  Raise an error if
+   there are conflicting attributes.  */
+static bfd_boolean
+ppc_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd)
+{
+  obj_attribute *in_attr;
+  obj_attribute *out_attr;
+
+  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;
+    }
+
+  /* Check for conflicting Tag_GNU_Power_ABI_FP attributes and merge
+     non-conflicting ones.  */
+  in_attr = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
+  out_attr = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
+  if (in_attr[Tag_GNU_Power_ABI_FP].i != out_attr[Tag_GNU_Power_ABI_FP].i)
+    {
+      out_attr[Tag_GNU_Power_ABI_FP].type = 1;
+      if (out_attr[Tag_GNU_Power_ABI_FP].i == 0)
+       out_attr[Tag_GNU_Power_ABI_FP].i = in_attr[Tag_GNU_Power_ABI_FP].i;
+      else if (in_attr[Tag_GNU_Power_ABI_FP].i == 0)
+       ;
+      else if (out_attr[Tag_GNU_Power_ABI_FP].i == 1
+              && in_attr[Tag_GNU_Power_ABI_FP].i == 2)
+       _bfd_error_handler
+         (_("Warning: %B uses hard float, %B uses soft float"), obfd, ibfd);
+      else if (out_attr[Tag_GNU_Power_ABI_FP].i == 2
+              && in_attr[Tag_GNU_Power_ABI_FP].i == 1)
+       _bfd_error_handler
+         (_("Warning: %B uses hard float, %B uses soft float"), ibfd, obfd);
+      else if (in_attr[Tag_GNU_Power_ABI_FP].i > 2)
+       _bfd_error_handler
+         (_("Warning: %B uses unknown floating point ABI %d"), ibfd,
+          in_attr[Tag_GNU_Power_ABI_FP].i);
+      else
+       _bfd_error_handler
+         (_("Warning: %B uses unknown floating point ABI %d"), obfd,
+          out_attr[Tag_GNU_Power_ABI_FP].i);
+    }
+
+  /* Merge Tag_compatibility attributes and any common GNU ones.  */
+  _bfd_elf_merge_object_attributes (ibfd, obfd);
+
+  return TRUE;
+}
+
 /* Merge backend specific data from an object file to the output
    object file when linking.  */
 
@@ -3612,6 +3668,9 @@ ppc_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
   if (! _bfd_generic_verify_endian_match (ibfd, obfd))
     return FALSE;
 
+  if (!ppc_elf_merge_obj_attributes (ibfd, obfd))
+    return FALSE;
+
   new_flags = elf_elfheader (ibfd)->e_flags;
   old_flags = elf_elfheader (obfd)->e_flags;
   if (!elf_flags_init (obfd))
index 76e0b682e6215e9b4b0a884e55d3b9bbae2ebeda..4096ba29a9aeb113cb5cf99d83c392a24b7a6848 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-29  Joseph Myers  <joseph@codesourcery.com>
+
+       * readelf.c (display_power_gnu_attribute, process_power_specific):
+       New.
+       (process_arch_specific): Call process_power_specific.
+
 2007-06-29  Joseph Myers  <joseph@codesourcery.com>
 
        * readelf.c (display_mips_gnu_attribute): New.
index c20fcd6e525f23c31bd9b37068a2647db8b1f6a8..ab41e28828b17729c237615a4d306e8c17dd1bee 100644 (file)
@@ -8346,6 +8346,57 @@ display_gnu_attribute (unsigned char *p,
   return p;
 }
 
+static unsigned char *
+display_power_gnu_attribute (unsigned char *p, int tag)
+{
+  int type;
+  unsigned int len;
+  int val;
+
+  if (tag == Tag_GNU_Power_ABI_FP)
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("  Tag_GNU_Power_ABI_FP: ");
+      switch (val)
+       {
+       case 0:
+         printf ("Hard or soft float\n");
+         break;
+       case 1:
+         printf ("Hard float\n");
+         break;
+       case 2:
+         printf ("Soft float\n");
+         break;
+       default:
+         printf ("??? (%d)\n", val);
+         break;
+       }
+      return p;
+   }
+
+  if (tag & 1)
+    type = 1; /* String.  */
+  else
+    type = 2; /* uleb128.  */
+  printf ("  Tag_unknown_%d: ", tag);
+
+  if (type == 1)
+    {
+      printf ("\"%s\"\n", p);
+      p += strlen ((char *)p) + 1;
+    }
+  else
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("%d (0x%x)\n", val, val);
+    }
+
+  return p;
+}
+
 static unsigned char *
 display_mips_gnu_attribute (unsigned char *p, int tag)
 {
@@ -8539,6 +8590,13 @@ process_arm_specific (FILE *file)
                             display_arm_attribute, NULL);
 }
 
+static int
+process_power_specific (FILE *file)
+{
+  return process_attributes (file, NULL, SHT_GNU_ATTRIBUTES, NULL,
+                            display_power_gnu_attribute);
+}
+
 static int
 process_mips_specific (FILE *file)
 {
@@ -9317,6 +9375,9 @@ process_arch_specific (FILE *file)
     case EM_MIPS_RS3_LE:
       return process_mips_specific (file);
       break;
+    case EM_PPC:
+      return process_power_specific (file);
+      break;
     default:
       break;
     }
index d690ad4749924f7c09f07fabcd8316f01528a080..ba08331c4c02ff867cb583287d7139c9e8c7a6da 100644 (file)
@@ -1,3 +1,7 @@
+2007-06-29  Joseph Myers  <joseph@codesourcery.com>
+
+       * ppc.h (Tag_GNU_Power_ABI_FP): Define.
+
 2007-06-29  Joseph Myers  <joseph@codesourcery.com>
 
        * mips.h (Tag_GNU_MIPS_ABI_FP): Define.
index ca5035274d9a6abb15156ea42e2569fea9d0f651..fe48814d86f208a93df8d90c870a4e5eb0c31c65 100644 (file)
@@ -171,4 +171,15 @@ END_RELOC_NUMBERS (R_PPC_max)
                                                   builds when those objects \
                                                   are not to be furhter \
                                                   relocated.  */
+
+/* Object attribute tags.  */
+enum
+{
+  /* 0-3 are generic.  */
+  Tag_GNU_Power_ABI_FP = 4, /* Value 1 for hard-float, 2 for
+                              soft-float; 0 for not tagged or not
+                              using any ABIs affected by the
+                              differences.  */
+};
+
 #endif /* _ELF_PPC_H */
index 5271fcfa556551b294c3b07944f9533d3b83d4db..28099e90191c842f2eb988aae605199b78efd259 100644 (file)
@@ -1,3 +1,15 @@
+2007-06-29  Joseph Myers  <joseph@codesourcery.com>
+
+       * ld-powerpc/attr-gnu-4-0.s, ld-powerpc/attr-gnu-4-00.d,
+       ld-powerpc/attr-gnu-4-01.d, ld-powerpc/attr-gnu-4-02.d,
+       ld-powerpc/attr-gnu-4-1.s, ld-powerpc/attr-gnu-4-10.d,
+       ld-powerpc/attr-gnu-4-11.d, ld-powerpc/attr-gnu-4-12.d,
+       ld-powerpc/attr-gnu-4-13.d, ld-powerpc/attr-gnu-4-2.s,
+       ld-powerpc/attr-gnu-4-20.d, ld-powerpc/attr-gnu-4-21.d,
+       ld-powerpc/attr-gnu-4-22.d, ld-powerpc/attr-gnu-4-3.s,
+       ld-powerpc/attr-gnu-4-31.d: New.
+       * ld-powerpc/powerpc.exp: Run these new tests.
+
 2007-06-29  Joseph Myers  <joseph@codesourcery.com>
 
        * ld-mips-elf/attr-gnu-4-0.s, ld-mips-elf/attr-gnu-4-00.d,
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-0.s b/ld/testsuite/ld-powerpc/attr-gnu-4-0.s
new file mode 100644 (file)
index 0000000..a143746
--- /dev/null
@@ -0,0 +1 @@
+.gnu_attribute 4,0
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-00.d b/ld/testsuite/ld-powerpc/attr-gnu-4-00.d
new file mode 100644 (file)
index 0000000..a4751a1
--- /dev/null
@@ -0,0 +1,7 @@
+#source: attr-gnu-4-0.s
+#source: attr-gnu-4-0.s
+#as: -a32
+#ld: -r -melf32ppc
+#readelf: -A
+#target: powerpc*-*-*
+
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-01.d b/ld/testsuite/ld-powerpc/attr-gnu-4-01.d
new file mode 100644 (file)
index 0000000..212e0c4
--- /dev/null
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-0.s
+#source: attr-gnu-4-1.s
+#as: -a32
+#ld: -r -melf32ppc
+#readelf: -A
+#target: powerpc*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_Power_ABI_FP: Hard float
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-02.d b/ld/testsuite/ld-powerpc/attr-gnu-4-02.d
new file mode 100644 (file)
index 0000000..9bd42b5
--- /dev/null
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-0.s
+#source: attr-gnu-4-2.s
+#as: -a32
+#ld: -r -melf32ppc
+#readelf: -A
+#target: powerpc*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_Power_ABI_FP: Soft float
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-1.s b/ld/testsuite/ld-powerpc/attr-gnu-4-1.s
new file mode 100644 (file)
index 0000000..e985a56
--- /dev/null
@@ -0,0 +1 @@
+.gnu_attribute 4,1
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-10.d b/ld/testsuite/ld-powerpc/attr-gnu-4-10.d
new file mode 100644 (file)
index 0000000..93297c2
--- /dev/null
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-1.s
+#source: attr-gnu-4-0.s
+#as: -a32
+#ld: -r -melf32ppc
+#readelf: -A
+#target: powerpc*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_Power_ABI_FP: Hard float
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-11.d b/ld/testsuite/ld-powerpc/attr-gnu-4-11.d
new file mode 100644 (file)
index 0000000..fb2b76e
--- /dev/null
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-1.s
+#source: attr-gnu-4-1.s
+#as: -a32
+#ld: -r -melf32ppc
+#readelf: -A
+#target: powerpc*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_Power_ABI_FP: Hard float
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-12.d b/ld/testsuite/ld-powerpc/attr-gnu-4-12.d
new file mode 100644 (file)
index 0000000..b7ffba0
--- /dev/null
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-1.s
+#source: attr-gnu-4-2.s
+#as: -a32
+#ld: -r -melf32ppc
+#warning: Warning: .* uses hard float, .* uses soft float
+#target: powerpc*-*-*
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-13.d b/ld/testsuite/ld-powerpc/attr-gnu-4-13.d
new file mode 100644 (file)
index 0000000..be1290e
--- /dev/null
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-1.s
+#source: attr-gnu-4-3.s
+#as: -a32
+#ld: -r -melf32ppc
+#warning: Warning: .* uses unknown floating point ABI 3
+#target: powerpc*-*-*
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-2.s b/ld/testsuite/ld-powerpc/attr-gnu-4-2.s
new file mode 100644 (file)
index 0000000..54ebf4e
--- /dev/null
@@ -0,0 +1 @@
+.gnu_attribute 4,2
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-20.d b/ld/testsuite/ld-powerpc/attr-gnu-4-20.d
new file mode 100644 (file)
index 0000000..3d83893
--- /dev/null
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-2.s
+#source: attr-gnu-4-0.s
+#as: -a32
+#ld: -r -melf32ppc
+#readelf: -A
+#target: powerpc*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_Power_ABI_FP: Soft float
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-21.d b/ld/testsuite/ld-powerpc/attr-gnu-4-21.d
new file mode 100644 (file)
index 0000000..b38f248
--- /dev/null
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-2.s
+#source: attr-gnu-4-1.s
+#as: -a32
+#ld: -r -melf32ppc
+#warning: Warning: .* uses hard float, .* uses soft float
+#target: powerpc*-*-*
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-22.d b/ld/testsuite/ld-powerpc/attr-gnu-4-22.d
new file mode 100644 (file)
index 0000000..f6bd198
--- /dev/null
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-2.s
+#source: attr-gnu-4-2.s
+#as: -a32
+#ld: -r -melf32ppc
+#readelf: -A
+#target: powerpc*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_Power_ABI_FP: Soft float
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-3.s b/ld/testsuite/ld-powerpc/attr-gnu-4-3.s
new file mode 100644 (file)
index 0000000..32e5f5d
--- /dev/null
@@ -0,0 +1 @@
+.gnu_attribute 4,3
diff --git a/ld/testsuite/ld-powerpc/attr-gnu-4-31.d b/ld/testsuite/ld-powerpc/attr-gnu-4-31.d
new file mode 100644 (file)
index 0000000..9cf8f4f
--- /dev/null
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-3.s
+#source: attr-gnu-4-1.s
+#as: -a32
+#ld: -r -melf32ppc
+#warning: Warning: .* uses unknown floating point ABI 3
+#target: powerpc*-*-*
index 927c4b83452db5730daa206ed2d58f9a9c798569..ad224b09a943c9910f0292707554f91a447d41ba 100644 (file)
@@ -147,3 +147,15 @@ if [ supports_ppc64 ] then {
 }
 
 run_dump_test "plt1"
+
+run_dump_test "attr-gnu-4-00"
+run_dump_test "attr-gnu-4-01"
+run_dump_test "attr-gnu-4-02"
+run_dump_test "attr-gnu-4-10"
+run_dump_test "attr-gnu-4-11"
+run_dump_test "attr-gnu-4-12"
+run_dump_test "attr-gnu-4-13"
+run_dump_test "attr-gnu-4-20"
+run_dump_test "attr-gnu-4-21"
+run_dump_test "attr-gnu-4-22"
+run_dump_test "attr-gnu-4-31"