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]

[Patch] Update ARM attribute support for Tag_DIV_use and Tag_MPextension_use


Hi,

Please can someone review, and then if appropriate approve, and commit
the attached patch?

The patch adds support for the ARM ABI attributes: Tag_DIV_use, and
Tag_MPextension_use.  It also adds some new attribute values for
existing attributes to the attribute dumping in readelf.

The interesting part of the patch is the support for
Tag_MPextension_use.  A previous version of the ABI gave this tag the ID
70, however, the latest version of the ABI has changed the ID to 42.  To
keep compatibility with old toolchains that use the old ID I treat both
tag IDs as being identical - but when merging attributes we only output
the new ID.

ChangeLog entry:
2010-02-17  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>
	* bfd/elf32-arm.c (elf32_arm_merge_eabi_attributes): Add support
	for merging Tag_DIV_use, Tag_MPextension_use, and
	Tag_MPextension_use_legacy tags.
	* bfd/readelf.c (arm_attr_tag_Advanced_SIMD_arch): Add
	description of newly permitted attribute values.
	(arm_attr_tag_Virtualization_use): Likewise.
	(arm_attr_tag_DIV_use): Add description of new attribute.
	(arm_attr_tag_MPextension_use): Likewise.
	* gas/config/tc-arm.c (arm_convert_symbolic_attribute): Add
	Tag_DIV_use.
	* gas/doc/c-arm.texi: Likewise
	* include/elf/arm.h (Tag_MPextension_use): Renumber.
	(Tag_DIV_use): Add.
	(Tag_MPextension_use_legacy): Likewise.
	* gas/testsuite/arm/attr-order.d: Fix test for new name for
	Tag_Virtualization_use attribute values
	* ld/testsuite/ld-arm/attr-merge-3.attr: Fix test for new
	Tag_MPextension_use value.
	* ld/testsuite/ld-arm/attr-merge-3b.s: Likewise
	* ld/testsuite/ld-arm/attr-merge-unknown-1.d: Fix test now that
	42 is a recognised attribute ID.
	* ld/testsuite/ld-arm/attr-merge-unknown-1.s: Likewise.
	* ld/testsuite/ld-arm/attr-merge-6.attr: New test.
	* ld/testsuite/ld-arm/attr-merge-6a.s: Likewise.
	* ld/testsuite/ld-arm/attr-merge-6b.s: Likewise.
	* ld/testsuite/ld-arm/attr-merge-7.attr: Likewise.
	* ld/testsuite/ld-arm/attr-merge-7a.s: Likewise.
	* ld/testsuite/ld-arm/attr-merge-7b.s: Likewise.
	* ld/testsuite/ld-arm/arm-elf.exp: Run the new tests.

Thanks,

Matt

-- 
Matthew Gretton-Dann
Principal Engineer - Tools, PD Software
ARM Limited
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.222
diff -u -p -r1.222 elf32-arm.c
--- bfd/elf32-arm.c	12 Feb 2010 20:52:51 -0000	1.222
+++ bfd/elf32-arm.c	17 Feb 2010 10:41:05 -0000
@@ -9812,11 +9812,33 @@ elf32_arm_merge_eabi_attributes (bfd *ib
       /* This is the first object.  Copy the attributes.  */
       _bfd_elf_copy_obj_attributes (ibfd, obfd);
 
+      out_attr = elf_known_obj_attributes_proc (obfd);
+
       /* Use the Tag_null value to indicate the attributes have been
 	 initialized.  */
-      elf_known_obj_attributes_proc (obfd)[0].i = 1;
+      out_attr[0].i = 1;
 
-      return TRUE;
+      /* We do not output objects with Tag_MPextension_use_legacy - we move
+	 the attribute's value to Tag_MPextension_use.  */
+      if (out_attr[Tag_MPextension_use_legacy].i != 0)
+	{
+	  if (out_attr[Tag_MPextension_use].i != 0
+	      && out_attr[Tag_MPextension_use_legacy].i
+	        != out_attr[Tag_MPextension_use].i)
+	    {
+	      _bfd_error_handler
+		(_("Error: %B has both the current and legacy "
+		   "Tag_MPextension_use attributes"), ibfd);
+	      result = FALSE;
+	    }
+
+	  out_attr[Tag_MPextension_use] =
+	    out_attr[Tag_MPextension_use_legacy];
+	  out_attr[Tag_MPextension_use_legacy].type = 0;
+	  out_attr[Tag_MPextension_use_legacy].i = 0;
+	}
+
+      return result;
     }
 
   in_attr = elf_known_obj_attributes_proc (ibfd);
@@ -10151,6 +10173,52 @@ elf32_arm_merge_eabi_attributes (bfd *ib
 	    out_attr[i].i = in_attr[i].i;
 	  break;
 
+	case Tag_DIV_use:
+	  /* This tag is set to zero if we can use UDIV and SDIV in Thumb
+	     mode on a v7-M or v7-R CPU; to one if we can not use UDIV or
+	     SDIV at all; and to two if we can use UDIV or SDIV on a v7-A
+	     CPU.  We will merge as follows: If the input attribute's value
+	     is one then the output attribute's value remains unchanged.  If
+	     the input attribute's value is zero or two then if the output
+	     attribute's value is one the output value is set to the input
+	     value, otherwise the output value must be the same as the
+	     inputs.  */ 
+	  if (in_attr[i].i != 1 && out_attr[i].i != 1) 
+	    { 
+	      if (in_attr[i].i != out_attr[i].i)
+		{
+		  _bfd_error_handler
+		    (_("DIV usage mismatch between %B and %B"),
+		     ibfd, obfd); 
+		  result = FALSE;
+		}
+	    } 
+
+	  if (in_attr[i].i != 1)
+	    out_attr[i].i = in_attr[i].i; 
+	  
+	  break;
+
+	case Tag_MPextension_use_legacy:
+	  /* We don't output objects with Tag_MPextension_use_legacy - we
+	     move the value to Tag_MPextension_use.  */
+	  if (in_attr[i].i != 0 && in_attr[Tag_MPextension_use].i != 0)
+	    {
+	      if (in_attr[Tag_MPextension_use].i != in_attr[i].i)
+		{
+		  _bfd_error_handler
+		    (_("%B has has both the current and legacy "
+		       "Tag_MPextension_use attributes"), 
+		     ibfd);
+		  result = FALSE;
+		}
+	    }
+
+	  if (in_attr[i].i > out_attr[Tag_MPextension_use].i)
+	    out_attr[Tag_MPextension_use] = in_attr[i];
+
+	  break;
+
 	case Tag_nodefaults:
 	  /* This tag is set if it exists, but the value is unused (and is
 	     typically zero).  We don't actually need to do anything here -
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.484
diff -u -p -r1.484 readelf.c
--- binutils/readelf.c	9 Feb 2010 12:14:43 -0000	1.484
+++ binutils/readelf.c	17 Feb 2010 10:41:06 -0000
@@ -9071,7 +9071,8 @@ static const char * arm_attr_tag_THUMB_I
 static const char * arm_attr_tag_VFP_arch[] =
   {"No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16", "VFPv4", "VFPv4-D16"};
 static const char * arm_attr_tag_WMMX_arch[] = {"No", "WMMXv1", "WMMXv2"};
-static const char * arm_attr_tag_Advanced_SIMD_arch[] = {"No", "NEONv1"};
+static const char * arm_attr_tag_Advanced_SIMD_arch[] = 
+  {"No", "NEONv1", "NEONv1 with Fused-MAC"};
 static const char * arm_attr_tag_PCS_config[] =
   {"None", "Bare platform", "Linux application", "Linux DSO", "PalmOS 2004",
    "PalmOS (reserved)", "SymbianOS 2004", "SymbianOS (reserved)"};
@@ -9114,10 +9115,17 @@ static const char * arm_attr_tag_VFP_HP_
   {"Not Allowed", "Allowed"};
 static const char * arm_attr_tag_ABI_FP_16bit_format[] =
   {"None", "IEEE 754", "Alternative Format"};
+static const char * arm_attr_tag_MPextension_use[] = 
+  {"Not Allowed", "Allowed"};
+static const char * arm_attr_tag_DIV_use[] =
+  {"Allowed in Thumb-ISA, v7-R or v7-M", "Not allowed", 
+    "Allowed in v7-A with integer division extension"};
 static const char * arm_attr_tag_T2EE_use[] = {"Not Allowed", "Allowed"};
 static const char * arm_attr_tag_Virtualization_use[] =
+  {"Not Allowed", "TrustZone", "Virtualization Extensions", 
+    "TrustZone and Virtualization Extensions"};
+static const char * arm_attr_tag_MPextension_use_legacy[] = 
   {"Not Allowed", "Allowed"};
-static const char * arm_attr_tag_MPextension_use[] = {"Not Allowed", "Allowed"};
 
 #define LOOKUP(id, name) \
   {id, #name, 0x80 | ARRAY_SIZE(arm_attr_tag_##name), arm_attr_tag_##name}
@@ -9155,12 +9163,14 @@ static arm_attr_public_tag arm_attr_publ
   LOOKUP(34, CPU_unaligned_access),
   LOOKUP(36, VFP_HP_extension),
   LOOKUP(38, ABI_FP_16bit_format),
+  LOOKUP(42, MPextension_use),
+  LOOKUP(44, DIV_use),
   {64, "nodefaults", 0, NULL},
   {65, "also_compatible_with", 0, NULL},
   LOOKUP(66, T2EE_use),
   {67, "conformance", 1, NULL},
   LOOKUP(68, Virtualization_use),
-  LOOKUP(70, MPextension_use)
+  LOOKUP(70, MPextension_use_legacy)
 };
 #undef LOOKUP
 
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.430
diff -u -p -r1.430 tc-arm.c
--- gas/config/tc-arm.c	12 Feb 2010 20:15:13 -0000	1.430
+++ gas/config/tc-arm.c	17 Feb 2010 10:41:08 -0000
@@ -23043,12 +23043,14 @@ arm_convert_symbolic_attribute (const ch
       T (Tag_CPU_unaligned_access),
       T (Tag_VFP_HP_extension),
       T (Tag_ABI_FP_16bit_format),
+      T (Tag_MPextension_use),
+      T (Tag_DIV_use),
       T (Tag_nodefaults),
       T (Tag_also_compatible_with),
       T (Tag_conformance),
       T (Tag_T2EE_use),
       T (Tag_Virtualization_use),
-      T (Tag_MPextension_use)
+      /* We deliberately do not include Tag_MPextension_use_legacy.  */
 #undef T
     };
   unsigned int i;
Index: gas/doc/c-arm.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/c-arm.texi,v
retrieving revision 1.67
diff -u -p -r1.67 c-arm.texi
--- gas/doc/c-arm.texi	28 Dec 2009 18:27:42 -0000	1.67
+++ gas/doc/c-arm.texi	17 Feb 2010 10:41:08 -0000
@@ -587,9 +587,10 @@ The @var{tag} is either an attribute num
 @code{Tag_ABI_optimization_goals}, @code{Tag_ABI_FP_optimization_goals},
 @code{Tag_compatibility}, @code{Tag_CPU_unaligned_access},
 @code{Tag_VFP_HP_extension}, @code{Tag_ABI_FP_16bit_format},
+@code{Tag_MPextension_use}, @code{Tag_DIV_use},
 @code{Tag_nodefaults}, @code{Tag_also_compatible_with},
 @code{Tag_conformance}, @code{Tag_T2EE_use},
-@code{Tag_Virtualization_use}, @code{Tag_MPextension_use}
+@code{Tag_Virtualization_use}
 
 The @var{value} is either a @code{number}, @code{"string"}, or
 @code{number, "string"} depending on the tag.
Index: gas/testsuite/gas/arm/attr-order.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/attr-order.d,v
retrieving revision 1.4
diff -u -p -r1.4 attr-order.d
--- gas/testsuite/gas/arm/attr-order.d	27 Jan 2009 15:20:11 -0000	1.4
+++ gas/testsuite/gas/arm/attr-order.d	17 Feb 2010 10:41:08 -0000
@@ -16,4 +16,4 @@ File Attributes
   Tag_unknown_63: "val"
   Tag_also_compatible_with: v6-M
   Tag_T2EE_use: Allowed
-  Tag_Virtualization_use: Allowed
+  Tag_Virtualization_use: TrustZone
Index: include/elf/arm.h
===================================================================
RCS file: /cvs/src/src/include/elf/arm.h,v
retrieving revision 1.37
diff -u -p -r1.37 arm.h
--- include/elf/arm.h	17 Nov 2009 16:31:51 -0000	1.37
+++ include/elf/arm.h	17 Feb 2010 10:41:12 -0000
@@ -288,13 +288,18 @@ enum
   Tag_undefined37,
   Tag_ABI_FP_16bit_format,
   Tag_undefined39,
+  Tag_undefined40,
+  Tag_undefined41,
+  Tag_MPextension_use,
+  Tag_undefined_43,
+  Tag_DIV_use,
   Tag_nodefaults = 64,
   Tag_also_compatible_with,
   Tag_T2EE_use,
   Tag_conformance,
   Tag_Virtualization_use,
   Tag_undefined69,
-  Tag_MPextension_use
+  Tag_MPextension_use_legacy
 };
 
 #endif
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.70
diff -u -p -r1.70 arm-elf.exp
--- ld/testsuite/ld-arm/arm-elf.exp	12 Feb 2010 20:52:52 -0000	1.70
+++ ld/testsuite/ld-arm/arm-elf.exp	17 Feb 2010 10:41:12 -0000
@@ -296,6 +296,15 @@ set armeabitests {
      {"EABI attribute merging 5" "-r" "" {attr-merge-5.s attr-merge-5.s}
       {{readelf -A attr-merge-5.attr}}
       "attr-merge-5"}
+     {"EABI attribute merging 6" "-r" "" {attr-merge-6a.s attr-merge-6b.s}
+      {{readelf -A attr-merge-6.attr}}
+      "attr-merge-6"}
+     {"EABI attribute merging 6 reversed" "-r" "" {attr-merge-6b.s attr-merge-6a.s}
+      {{readelf -A attr-merge-6.attr}}
+      "attr-merge-6r"}
+     {"EABI attribute merging 7" "-r" "" {attr-merge-7a.s attr-merge-7b.s}
+      {{readelf -A attr-merge-7.attr}}
+      "attr-merge-7"}
      {"EABI attribute arch merging 1" "-r" "" {arch-v6k.s arch-v6t2.s}
       {{readelf -A attr-merge-arch-1.attr}}
       "attr-merge-arch-1"}
Index: ld/testsuite/ld-arm/attr-merge-3.attr
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/attr-merge-3.attr,v
retrieving revision 1.2
diff -u -p -r1.2 attr-merge-3.attr
--- ld/testsuite/ld-arm/attr-merge-3.attr	26 Jan 2009 14:36:43 -0000	1.2
+++ ld/testsuite/ld-arm/attr-merge-3.attr	17 Feb 2010 10:41:12 -0000
@@ -26,6 +26,6 @@ File Attributes
   Tag_ABI_VFP_args: VFP registers
   Tag_CPU_unaligned_access: v6
   Tag_VFP_HP_extension: Allowed
-  Tag_T2EE_use: Allowed
-  Tag_Virtualization_use: Allowed
   Tag_MPextension_use: Allowed
+  Tag_T2EE_use: Allowed
+  Tag_Virtualization_use: TrustZone
Index: ld/testsuite/ld-arm/attr-merge-3b.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/attr-merge-3b.s,v
retrieving revision 1.1
diff -u -p -r1.1 attr-merge-3b.s
--- ld/testsuite/ld-arm/attr-merge-3b.s	19 Jan 2009 12:20:15 -0000	1.1
+++ ld/testsuite/ld-arm/attr-merge-3b.s	17 Feb 2010 10:41:12 -0000
@@ -33,6 +33,6 @@
 	.eabi_attribute Tag_nodefaults, 1
 	@ .eabi_attribute Tag_also_compatible_with,
 	.eabi_attribute Tag_T2EE_use, 1
-	.eabi_attribute Tag_conformance, "2.07"
+	.eabi_attribute Tag_conformance, "2.08"
 	.eabi_attribute Tag_Virtualization_use, 1
 	.eabi_attribute Tag_MPextension_use, 1
Index: ld/testsuite/ld-arm/attr-merge-unknown-1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/attr-merge-unknown-1.d,v
retrieving revision 1.1
diff -u -p -r1.1 attr-merge-unknown-1.d
--- ld/testsuite/ld-arm/attr-merge-unknown-1.d	19 Jan 2009 12:20:15 -0000	1.1
+++ ld/testsuite/ld-arm/attr-merge-unknown-1.d	17 Feb 2010 10:41:12 -0000
@@ -2,4 +2,4 @@
 #source: blank.s
 #as:
 #ld:
-#error: Unknown mandatory EABI object attribute 42
+#error: Unknown mandatory EABI object attribute 40
Index: ld/testsuite/ld-arm/attr-merge-unknown-1.s
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/attr-merge-unknown-1.s,v
retrieving revision 1.1
diff -u -p -r1.1 attr-merge-unknown-1.s
--- ld/testsuite/ld-arm/attr-merge-unknown-1.s	19 Jan 2009 12:20:15 -0000	1.1
+++ ld/testsuite/ld-arm/attr-merge-unknown-1.s	17 Feb 2010 10:41:12 -0000
@@ -1,3 +1,3 @@
 	@ This attrubute is supposed to be unknown.
 	@ If this number should become known, change it.
-	.eabi_attribute  42, 1
+	.eabi_attribute  40, 1
Index: ld/testsuite/ld-arm/attr-merge-6a.s
===================================================================
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-6a.s	2010-02-17 10:19:18.591451000 +0000
@@ -0,0 +1,4 @@
+	.cpu cortex-a9
+	.fpu softvfp
+	.eabi_attribute 70, 1
+	.file	"attr-merge-6a.s"
Index: ld/testsuite/ld-arm/attr-merge-6b.s
===================================================================
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-6b.s	2010-02-17 10:19:18.597457000 +0000
@@ -0,0 +1,3 @@
+	.cpu cortex-a9
+	.fpu softvfp
+	.file	"attr-merge-6b.s"
Index: ld/testsuite/ld-arm/attr-merge-7.attr
===================================================================
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-7.attr	2010-02-17 10:19:18.603460000 +0000
@@ -0,0 +1,9 @@
+Attribute Section: aeabi
+File Attributes
+  Tag_CPU_name: "CORTEX-A9"
+  Tag_CPU_arch: v7
+  Tag_CPU_arch_profile: Application
+  Tag_ARM_ISA_use: Yes
+  Tag_THUMB_ISA_use: Thumb-2
+  Tag_MPextension_use: Allowed
+
Index: ld/testsuite/ld-arm/attr-merge-7a.s
===================================================================
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-7a.s	2010-02-17 10:19:18.609467000 +0000
@@ -0,0 +1,4 @@
+	.cpu cortex-a9
+	.fpu softvfp
+	.eabi_attribute 70, 1
+	.file	"attr-merge-7a.s"
Index: ld/testsuite/ld-arm/attr-merge-7b.s
===================================================================
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-7b.s	2010-02-17 10:19:18.614481000 +0000
@@ -0,0 +1,4 @@
+	.cpu cortex-a9
+	.fpu softvfp
+	.eabi_attribute Tag_MPextension_use, 1
+	.file	"attr-merge-7b.s"

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