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] Fix handling of Tag_ABI_HardFP_use for ARM


This patch sets Tag_ABI_HardFP_use to SP when a single precision FPU is selected.

It also fixes the merge of Tag_ABI_HardFP_use. Currently, Tag_ABI_HardFP_use is not treated as (SP & DP) when it's zero and Tag_VFP_arch != 0. This patch changes it to conform to the documentation.

No regressions on GAS and ld testsuite. Is it OK?

Regards,
--
Jie Zhang
CodeSourcery
(650) 331-3385 x735
	gas/
	* config/tc-arm.c (aeabi_set_public_attributes): Set
	Tag_ABI_HardFP_use to 1 if a single precision FPU is selected.

	gas/testsuite/
	* gas/arm/attr-mfpu-vfpxd.d: New test.

	bfd/
	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Merge
	Tag_ABI_HardFP_use correctly.

	ld/testsuite/
	* ld-arm/attr-merge-vfp-6.d: New test.
	* ld-arm/attr-merge-vfp-6r.d: New test.
	* ld-arm/attr-merge-vfpv3xd.s: New test.
	* ld-arm/arm-elf.exp: Add attr-merge-vfp-6 and attr-merge-vfp-6r.


Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.234
diff -u -p -r1.234 elf32-arm.c
--- bfd/elf32-arm.c	7 May 2010 18:24:45 -0000	1.234
+++ bfd/elf32-arm.c	10 May 2010 16:38:42 -0000
@@ -10106,6 +10106,11 @@ elf32_arm_merge_eabi_attributes (bfd *ib
 	  break;
 	case Tag_FP_arch:
 	    {
+	      /* Tag_ABI_HardFP_use is handled along with Tag_FP_arch since
+		 the meaning of Tag_ABI_HardFP_use depends on Tag_FP_arch
+		 when it's 0.  It might mean absence of FP hardware if
+		 Tag_FP_arch is zero, otherwise it is effectively SP + DP.  */
+
 	      static const struct
 	      {
 		  int ver;
@@ -10124,6 +10129,40 @@ elf32_arm_merge_eabi_attributes (bfd *ib
 	      int regs;
 	      int newval;
 
+	      /* If the output has no requirement about FP hardware,
+		 follow the requirement of the input.  */
+	      if (out_attr[i].i == 0)
+		{
+		  BFD_ASSERT (out_attr[Tag_ABI_HardFP_use].i == 0);
+		  out_attr[i].i = in_attr[i].i;
+		  out_attr[Tag_ABI_HardFP_use].i
+		    = in_attr[Tag_ABI_HardFP_use].i;
+		  break;
+		}
+	      /* If the input has no requirement about FP hardware, do
+		 nothing.  */
+	      else if (in_attr[i].i == 0)
+		{
+		  BFD_ASSERT (in_attr[Tag_ABI_HardFP_use].i == 0);
+		  break;
+		}
+
+	      /* Both the input and the output have nonzero Tag_FP_arch.
+		 So Tag_ABI_HardFP_use is (SP & DP) when it's zero.  */
+
+	      /* If both the input and the output have zero Tag_ABI_HardFP_use,
+		 do nothing.  */
+	      if (in_attr[Tag_ABI_HardFP_use].i == 0
+		  && out_attr[Tag_ABI_HardFP_use].i == 0)
+		;
+	      /* If the input and the output have different Tag_ABI_HardFP_use,
+		 the combination of them is 3 (SP & DP).  */
+	      else if (in_attr[Tag_ABI_HardFP_use].i
+		       != out_attr[Tag_ABI_HardFP_use].i)
+		out_attr[Tag_ABI_HardFP_use].i = 3;
+
+	      /* Now we can handle Tag_FP_arch.  */
+
 	      /* Values greater than 6 aren't defined, so just pick the
 	         biggest */
 	      if (in_attr[i].i > 6 && in_attr[i].i > out_attr[i].i)
@@ -10244,12 +10283,7 @@ elf32_arm_merge_eabi_attributes (bfd *ib
 	  /* Merged in target-independent code.  */
 	  break;
 	case Tag_ABI_HardFP_use:
-	  /* 1 (SP) and 2 (DP) conflict, so combine to 3 (SP & DP).  */
-	  if ((in_attr[i].i == 1 && out_attr[i].i == 2)
-	      || (in_attr[i].i == 2 && out_attr[i].i == 1))
-	    out_attr[i].i = 3;
-	  else if (in_attr[i].i > out_attr[i].i)
-	    out_attr[i].i = in_attr[i].i;
+	  /* This is handled along with Tag_FP_arch.  */
 	  break;
 	case Tag_ABI_FP_16bit_format:
 	  if (in_attr[i].i != 0 && out_attr[i].i != 0)
Index: gas/config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.442
diff -u -p -r1.442 tc-arm.c
--- gas/config/tc-arm.c	29 Apr 2010 14:44:14 -0000	1.442
+++ gas/config/tc-arm.c	10 May 2010 16:38:44 -0000
@@ -22856,6 +22856,11 @@ aeabi_set_public_attributes (void)
            || ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1xd))
     aeabi_set_attribute_int (Tag_VFP_arch, 1);
 
+  /* Tag_ABI_HardFP_use.  */
+  if (ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1xd)
+      && !ARM_CPU_HAS_FEATURE (flags, fpu_vfp_ext_v1))
+    aeabi_set_attribute_int (Tag_ABI_HardFP_use, 1);
+
   /* Tag_WMMX_arch.  */
   if (ARM_CPU_HAS_FEATURE (flags, arm_cext_iwmmxt2))
     aeabi_set_attribute_int (Tag_WMMX_arch, 2);
Index: gas/testsuite/gas/arm/attr-mfpu-vfpxd.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arm/attr-mfpu-vfpxd.d,v
retrieving revision 1.3
diff -u -p -r1.3 attr-mfpu-vfpxd.d
--- gas/testsuite/gas/arm/attr-mfpu-vfpxd.d	15 Apr 2010 10:56:39 -0000	1.3
+++ gas/testsuite/gas/arm/attr-mfpu-vfpxd.d	10 May 2010 16:38:44 -0000
@@ -10,3 +10,4 @@ File Attributes
   Tag_ARM_ISA_use: Yes
   Tag_THUMB_ISA_use: Thumb-1
   Tag_FP_arch: VFPv1
+  Tag_ABI_HardFP_use: SP only
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.76
diff -u -p -r1.76 arm-elf.exp
--- ld/testsuite/ld-arm/arm-elf.exp	7 May 2010 18:24:47 -0000	1.76
+++ ld/testsuite/ld-arm/arm-elf.exp	10 May 2010 16:38:45 -0000
@@ -518,4 +518,6 @@ run_dump_test "attr-merge-vfp-4"
 run_dump_test "attr-merge-vfp-4r"
 run_dump_test "attr-merge-vfp-5"
 run_dump_test "attr-merge-vfp-5r"
+run_dump_test "attr-merge-vfp-6"
+run_dump_test "attr-merge-vfp-6r"
 run_dump_test "attr-merge-incompatible"
Index: ld/testsuite/ld-arm/attr-merge-vfp-6.d
===================================================================
RCS file: ld/testsuite/ld-arm/attr-merge-vfp-6.d
diff -N ld/testsuite/ld-arm/attr-merge-vfp-6.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/attr-merge-vfp-6.d	10 May 2010 16:38:45 -0000
@@ -0,0 +1,14 @@
+#source: attr-merge-vfp-3.s
+#source: attr-merge-vfpv3xd.s
+#as:
+#ld: -r
+#readelf: -A
+# This test is only valid on ELF based ports.
+# not-target: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix*
+
+Attribute Section: aeabi
+File Attributes
+  Tag_ARM_ISA_use: Yes
+  Tag_THUMB_ISA_use: Thumb-1
+  Tag_FP_arch: VFPv3
+  Tag_ABI_HardFP_use: SP and DP
Index: ld/testsuite/ld-arm/attr-merge-vfp-6r.d
===================================================================
RCS file: ld/testsuite/ld-arm/attr-merge-vfp-6r.d
diff -N ld/testsuite/ld-arm/attr-merge-vfp-6r.d
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/attr-merge-vfp-6r.d	10 May 2010 16:38:45 -0000
@@ -0,0 +1,14 @@
+#source: attr-merge-vfpv3xd.s
+#source: attr-merge-vfp-3.s
+#as:
+#ld: -r
+#readelf: -A
+# This test is only valid on ELF based ports.
+# not-target: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix*
+
+Attribute Section: aeabi
+File Attributes
+  Tag_ARM_ISA_use: Yes
+  Tag_THUMB_ISA_use: Thumb-1
+  Tag_FP_arch: VFPv3
+  Tag_ABI_HardFP_use: SP and DP
Index: ld/testsuite/ld-arm/attr-merge-vfpv3xd.s
===================================================================
RCS file: ld/testsuite/ld-arm/attr-merge-vfpv3xd.s
diff -N ld/testsuite/ld-arm/attr-merge-vfpv3xd.s
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-arm/attr-merge-vfpv3xd.s	10 May 2010 16:38:45 -0000
@@ -0,0 +1,2 @@
+.fpu vfpv3xd
+

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