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] MIPS: Add a GNU attribute for -mips32 -mfp64 objects


Hello All,

the appended patch extends the exisiting GNU attribute which tags the
MIPS floating point ABI variant. The new tag is used for MIPS32 R2
CPUs which allow to run the FPU in a mode with 64-bit wide registers.
I failed to come up with a better name than "-mips32r2 -mfp64", which
are the command line options to select this mode.

While I wrote this patch I noticed that the tagging takes only place
when the respective gnu_attribute is found in the source code. This
leaves objects created from assembly untagged. I wonder if it is a good
idea to generally add a FP ABI attribute, derived from the assembler's
command line flags, unless this is overridden by a gnu_attribute
directive in the source. Is there a backward compatibility issue I fail
to see, or some other effect which makes this a bad idea?


Thiemo


2007-11-14  Thiemo Seufer  <ths@mips.com>

	[ld/testsuite/ChangeLog]
	* ld-mips-elf/attr-gnu-4-14.d, ld-mips-elf/attr-gnu-4-41.d:
	Adjust warning message for -mfp64 flag.
	* ld-mips-elf/attr-gnu-4-5.s, ld-mips-elf/attr-gnu-4-04.d,
	ld-mips-elf/attr-gnu-4-51.d, ld-mips-elf/attr-gnu-4-05.d,
	ld-mips-elf/attr-gnu-4-15.d, ld-mips-elf/attr-gnu-4-24.d,
	ld-mips-elf/attr-gnu-4-25.d, ld-mips-elf/attr-gnu-4-34.d,
	ld-mips-elf/attr-gnu-4-35.d, ld-mips-elf/attr-gnu-4-42.d,
	ld-mips-elf/attr-gnu-4-43.d, ld-mips-elf/attr-gnu-4-44.d,
	ld-mips-elf/attr-gnu-4-45.d, ld-mips-elf/attr-gnu-4-40.d,
	ld-mips-elf/attr-gnu-4-14.d: New testcases files.
	* ld-mips-elf/mips-elf.exp: Run new testcases.

	[binutils/ChangeLog]
	* readelf.c (display_mips_gnu_attribute): Recognize -mips32r2 -mfp64
	objects.

	[include/ChangeLog]
	* elf/mips.h (Tag_GNU_MIPS_ABI_FP): Mention -mips32r2 -mfp64 variant
	in comment.

	[bfd/ChangeLog]
	* elfxx-mips.c (mips_elf_merge_obj_attributes): Handle -mips32r2
	-mfp64 attribute.


Index: head/bfd/elfxx-mips.c
===================================================================
--- head.orig/bfd/elfxx-mips.c	2007-11-14 19:15:45.000000000 +0000
+++ head/bfd/elfxx-mips.c	2007-11-14 19:15:49.000000000 +0000
@@ -11055,11 +11055,11 @@
 	out_attr[Tag_GNU_MIPS_ABI_FP].i = in_attr[Tag_GNU_MIPS_ABI_FP].i;
       else if (in_attr[Tag_GNU_MIPS_ABI_FP].i == 0)
 	;
-      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i > 3)
+      else if (in_attr[Tag_GNU_MIPS_ABI_FP].i > 4)
 	_bfd_error_handler
 	  (_("Warning: %B uses unknown floating point ABI %d"), ibfd,
 	   in_attr[Tag_GNU_MIPS_ABI_FP].i);
-      else if (out_attr[Tag_GNU_MIPS_ABI_FP].i > 3)
+      else if (out_attr[Tag_GNU_MIPS_ABI_FP].i > 4)
 	_bfd_error_handler
 	  (_("Warning: %B uses unknown floating point ABI %d"), obfd,
 	   out_attr[Tag_GNU_MIPS_ABI_FP].i);
@@ -11081,6 +11081,12 @@
 		   obfd, ibfd);
 		break;
 
+	      case 4:
+		_bfd_error_handler
+		  (_("Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"),
+		   obfd, ibfd);
+		break;
+
 	      default:
 		abort ();
 	      }
@@ -11101,6 +11107,12 @@
 		   obfd, ibfd);
 		break;
 
+	      case 4:
+		_bfd_error_handler
+		  (_("Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"),
+		   obfd, ibfd);
+		break;
+
 	      default:
 		abort ();
 	      }
@@ -11111,6 +11123,7 @@
 	      {
 	      case 1:
 	      case 2:
+	      case 4:
 		_bfd_error_handler
 		  (_("Warning: %B uses hard float, %B uses soft float"),
 		   ibfd, obfd);
@@ -11121,6 +11134,32 @@
 	      }
 	    break;
 
+	  case 4:
+	    switch (in_attr[Tag_GNU_MIPS_ABI_FP].i)
+	      {
+	      case 1:
+		_bfd_error_handler
+		  (_("Warning: %B uses -msingle-float, %B uses -mips32r2 -mfp64"),
+		   ibfd, obfd);
+		break;
+
+	      case 2:
+		_bfd_error_handler
+		  (_("Warning: %B uses -mdouble-float, %B uses -mips32r2 -mfp64"),
+		   ibfd, obfd);
+		break;
+
+	      case 3:
+		_bfd_error_handler
+		  (_("Warning: %B uses hard float, %B uses soft float"),
+		   obfd, ibfd);
+		break;
+
+	      default:
+		abort ();
+	      }
+	    break;
+
 	  default:
 	    abort ();
 	  }
Index: head/include/elf/mips.h
===================================================================
--- head.orig/include/elf/mips.h	2007-11-14 19:01:30.000000000 +0000
+++ head/include/elf/mips.h	2007-11-14 19:15:49.000000000 +0000
@@ -1012,9 +1012,9 @@
   /* 0-3 are generic.  */
   Tag_GNU_MIPS_ABI_FP = 4, /* Value 1 for hard-float -mdouble-float, 2
 			      for hard-float -msingle-float, 3 for
-			      soft-float; 0 for not tagged or not
-			      using any ABIs affected by the
-			      differences.  */
+			      soft-float, 4 for -mips32r2 -mfp64; 0 for
+			      not tagged or not using any ABIs affected
+			      by the differences.  */
 };
 
 #endif /* _ELF_MIPS_H */
Index: head/binutils/readelf.c
===================================================================
--- head.orig/binutils/readelf.c	2007-11-14 19:01:30.000000000 +0000
+++ head/binutils/readelf.c	2007-11-14 19:15:49.000000000 +0000
@@ -8833,6 +8833,9 @@
 	case 3:
 	  printf ("Soft float\n");
 	  break;
+	case 4:
+	  printf ("64-bit float (-mips32r2 -mfp64)\n");
+	  break;
 	default:
 	  printf ("??? (%d)\n", val);
 	  break;
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-5.s
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-5.s	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1 @@
+.gnu_attribute 4,5
Index: head/ld/testsuite/ld-mips-elf/mips-elf.exp
===================================================================
--- head.orig/ld/testsuite/ld-mips-elf/mips-elf.exp	2007-11-14 19:01:30.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/mips-elf.exp	2007-11-14 19:15:49.000000000 +0000
@@ -285,17 +285,30 @@
 run_dump_test "attr-gnu-4-01"
 run_dump_test "attr-gnu-4-02"
 run_dump_test "attr-gnu-4-03"
+run_dump_test "attr-gnu-4-04"
+run_dump_test "attr-gnu-4-05"
 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-14"
+run_dump_test "attr-gnu-4-15"
 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-23"
+run_dump_test "attr-gnu-4-24"
+run_dump_test "attr-gnu-4-25"
 run_dump_test "attr-gnu-4-30"
 run_dump_test "attr-gnu-4-31"
 run_dump_test "attr-gnu-4-32"
 run_dump_test "attr-gnu-4-33"
+run_dump_test "attr-gnu-4-34"
+run_dump_test "attr-gnu-4-35"
+run_dump_test "attr-gnu-4-40"
 run_dump_test "attr-gnu-4-41"
+run_dump_test "attr-gnu-4-42"
+run_dump_test "attr-gnu-4-43"
+run_dump_test "attr-gnu-4-44"
+run_dump_test "attr-gnu-4-45"
+run_dump_test "attr-gnu-4-51"
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-04.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-04.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-0.s
+#source: attr-gnu-4-4.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#readelf: -A
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: 64-bit float \(-mips32r2 -mfp64\)
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-51.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-51.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-5.s
+#source: attr-gnu-4-1.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#warning: Warning: .* uses unknown floating point ABI 5
+#target: mips*-*-*
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-05.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-05.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-0.s
+#source: attr-gnu-4-5.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#readelf: -A
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: \?\?\? \(5\)
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-15.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-15.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,11 @@
+#source: attr-gnu-4-1.s
+#source: attr-gnu-4-5.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#readelf: -A
+#warning: Warning: .* uses unknown floating point ABI 5
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: Hard float \(-mdouble-float\)
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-24.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-24.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-2.s
+#source: attr-gnu-4-4.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#warning: Warning: .* uses -mips32r2 -mfp64
+#target: mips*-*-*
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-25.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-25.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,11 @@
+#source: attr-gnu-4-2.s
+#source: attr-gnu-4-5.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#readelf: -A
+#warning: Warning: .* uses unknown floating point ABI 5
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: Hard float \(-msingle-float\)
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-34.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-34.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-3.s
+#source: attr-gnu-4-4.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#warning: Warning: .* uses hard float, .* uses soft float
+#target: mips*-*-*
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-35.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-35.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,11 @@
+#source: attr-gnu-4-3.s
+#source: attr-gnu-4-5.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#readelf: -A
+#warning: Warning: .* uses unknown floating point ABI 5
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: Soft float
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-42.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-42.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-4.s
+#source: attr-gnu-4-2.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#warning: Warning: .* uses -mips32r2 -mfp64
+#target: mips*-*-*
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-43.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-43.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,6 @@
+#source: attr-gnu-4-4.s
+#source: attr-gnu-4-3.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#warning: Warning: .* uses hard float, .* uses soft float
+#target: mips*-*-*
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-44.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-44.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-4.s
+#source: attr-gnu-4-4.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#readelf: -A
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: 64-bit float \(-mips32r2 -mfp64\)
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-45.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-45.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-4.s
+#source: attr-gnu-4-5.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#warning: Warning: .* uses unknown floating point ABI 5
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: 64-bit float \(-mips32r2 -mfp64\)
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-40.d
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-40.d	2007-11-14 19:15:49.000000000 +0000
@@ -0,0 +1,10 @@
+#source: attr-gnu-4-4.s
+#source: attr-gnu-4-0.s
+#as: -EB -32
+#ld: -r -melf32btsmip
+#readelf: -A
+#target: mips*-*-*
+
+Attribute Section: gnu
+File Attributes
+  Tag_GNU_MIPS_ABI_FP: 64-bit float \(-mips32r2 -mfp64\)
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d
===================================================================
--- head.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d	2007-11-14 19:01:30.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d	2007-11-14 19:15:49.000000000 +0000
@@ -2,5 +2,5 @@
 #source: attr-gnu-4-4.s
 #as: -EB -32
 #ld: -r -melf32btsmip
-#warning: Warning: .* uses unknown floating point ABI 4
+#warning: Warning: .* uses -msingle-float, .* uses -mips32r2 -mfp64
 #target: mips*-*-*
Index: head/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d
===================================================================
--- head.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d	2007-11-14 19:01:30.000000000 +0000
+++ head/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d	2007-11-14 19:15:49.000000000 +0000
@@ -2,5 +2,5 @@
 #source: attr-gnu-4-1.s
 #as: -EB -32
 #ld: -r -melf32btsmip
-#warning: Warning: .* uses unknown floating point ABI 4
+#warning: Warning: .* uses -msingle-float, .* uses -mips32r2 -mfp64
 #target: mips*-*-*


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