[RFC PATCH 07/11] MIPS/BFD: Move attribute check after ELF file header flag check

Maciej W. Rozycki macro@imgtec.com
Fri Nov 20 14:50:00 GMT 2015


We have a problem in that in making compatibility checks while merging 
private BFD data on the MIPS target we give priority to the attribute 
check, which may fail and cause the function to abort early on.  The 
problem with this is the ABI compatibility aspect recorded in the 
attributes is relatively minor compared to aspects recorded in the ELF 
file header.  However the premature exit causes any more important 
compatibility aspect violated to be masked and not reported to the user 
once a problem with attributes has been noticed.

So move the attribute check after the ELF file header flag check in 
`_bfd_mips_elf_merge_private_bfd_data', and do not return prematurely 
there.  Take advantage of the resulting grouping of ELF file header 
handling together and remove the premature success return point for the 
first input object being handled, letting the code later on figure out 
output ABI flags even for this object.

Update LD test cases according to messages from ELF file header checks 
now preceding ones from attribute checks.

	bfd/
	* elfxx-mips.c (_bfd_mips_elf_merge_private_bfd_data): Move 
	attribute check after ELF file header flag check.

	ld/testsuite/
	* ld-mips-elf/attr-gnu-4-14.d: Update the order of messages 
	expected according to MIPS BFD private data merge changes.
	* ld-mips-elf/attr-gnu-4-24.d: Likewise.
	* ld-mips-elf/attr-gnu-4-34.d: Likewise.
	* ld-mips-elf/attr-gnu-4-41.d: Likewise.
	* ld-mips-elf/attr-gnu-4-42.d: Likewise.
	* ld-mips-elf/attr-gnu-4-43.d: Likewise.
	* ld-mips-elf/attr-gnu-4-45.d: Likewise.
	* ld-mips-elf/attr-gnu-4-46.d: Likewise.
	* ld-mips-elf/attr-gnu-4-47.d: Likewise.
	* ld-mips-elf/attr-gnu-4-48.d: Likewise.
	* ld-mips-elf/attr-gnu-4-49.d: Likewise.
	* ld-mips-elf/attr-gnu-4-54.d: Likewise.
	* ld-mips-elf/attr-gnu-4-64.d: Likewise.
	* ld-mips-elf/attr-gnu-4-74.d: Likewise.
---
binutils-mips-bfd-merge-attrs.diff
Index: binutils/bfd/elfxx-mips.c
===================================================================
--- binutils.orig/bfd/elfxx-mips.c	2015-11-17 13:08:57.091576699 +0000
+++ binutils/bfd/elfxx-mips.c	2015-11-17 13:09:00.330993883 +0000
@@ -15220,6 +15220,7 @@ _bfd_mips_elf_merge_private_bfd_data (bf
   bfd_boolean null_input_bfd = TRUE;
   asection *sec;
   obj_attribute *out_attr;
+  bfd_boolean ok;
 
   /* Check if we have the same endianness.  */
   if (! _bfd_generic_verify_endian_match (ibfd, obfd))
@@ -15321,9 +15322,6 @@ _bfd_mips_elf_merge_private_bfd_data (bf
       in_tdata->abiflags_valid = TRUE;
     }
 
-  if (!mips_elf_merge_obj_attributes (ibfd, obfd))
-    return FALSE;
-
   if (!out_tdata->abiflags_valid)
     {
       /* Copy input abiflags if output abiflags are not already valid.  */
@@ -15351,8 +15349,12 @@ _bfd_mips_elf_merge_private_bfd_data (bf
 	  update_mips_abiflags_isa (obfd, &out_tdata->abiflags);
 	}
 
-      return TRUE;
+      ok = TRUE;
     }
+  else
+    ok = mips_elf_merge_obj_e_flags (ibfd, obfd);
+
+  ok = mips_elf_merge_obj_attributes (ibfd, obfd) && ok;
 
   /* Update the output abiflags fp_abi using the computed fp_abi.  */
   out_attr = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
@@ -15374,7 +15376,7 @@ _bfd_mips_elf_merge_private_bfd_data (bf
   out_tdata->abiflags.ases |= in_tdata->abiflags.ases;
   out_tdata->abiflags.flags1 |= in_tdata->abiflags.flags1;
 
-  if (!mips_elf_merge_obj_e_flags (ibfd, obfd))
+  if (!ok)
     {
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d	2015-11-17 12:35:44.038585828 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-14.d	2015-11-17 13:09:00.359345975 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-1.s
 #source: attr-gnu-4-4.s -W
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mdouble-float \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
-#error:   [^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error:   [^\n]*: Warning: .* uses -mdouble-float \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-24.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-24.d	2015-11-17 12:35:44.216940425 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-24.d	2015-11-17 13:09:00.383889176 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-2.s
 #source: attr-gnu-4-4.s -W
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -msingle-float \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
-#error:   [^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error:   [^\n]*: Warning: .* uses -msingle-float \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-34.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-34.d	2015-11-17 12:35:44.539551997 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-34.d	2015-11-17 13:09:00.425708314 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-3.s
 #source: attr-gnu-4-4.s -W
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -msoft-float \(set by .*\), .* uses -mhard-float\n
-#error:   [^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error:   [^\n]*: Warning: .* uses -msoft-float \(set by .*\), .* uses -mhard-float\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d	2015-11-17 12:35:44.864437806 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-41.d	2015-11-17 13:09:00.438906549 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W
 #source: attr-gnu-4-1.s
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mdouble-float\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mdouble-float\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-42.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-42.d	2015-11-17 12:35:45.265162630 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-42.d	2015-11-17 13:09:00.451211796 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W
 #source: attr-gnu-4-2.s
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -msingle-float\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -msingle-float\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-43.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-43.d	2015-11-17 12:35:45.626670653 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-43.d	2015-11-17 13:09:00.473747645 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W
 #source: attr-gnu-4-3.s
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mhard-float \(set by .*\), .* uses -msoft-float\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mhard-float \(set by .*\), .* uses -msoft-float\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-45.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-45.d	2015-11-17 12:35:46.010093902 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-45.d	2015-11-17 13:09:00.487136122 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W -mips32r2
 #source: attr-gnu-4-5.s
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mfpxx\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mfpxx\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-46.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-46.d	2015-11-17 12:35:46.508459330 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-46.d	2015-11-17 13:09:00.497334508 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W -mips32r2
 #source: attr-gnu-4-6.s
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mgp32 -mfp64\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mgp32 -mfp64\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-47.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-47.d	2015-11-17 12:35:46.976037651 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-47.d	2015-11-17 13:09:00.504413257 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W -mips32r2
 #source: attr-gnu-4-7.s
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mgp32 -mfp64 -mno-odd-spreg\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses -mgp32 -mfp64 -mno-odd-spreg\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-48.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-48.d	2015-11-17 12:35:47.329247662 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-48.d	2015-11-17 13:09:00.524764673 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W
 #source: attr-gnu-4-8.s -W
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses unknown floating point ABI 8\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses unknown floating point ABI 8\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-49.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-49.d	2015-11-17 12:35:47.816351915 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-49.d	2015-11-17 13:09:00.549408156 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-4.s -W
 #source: attr-gnu-4-9.s -W
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses unknown floating point ABI 9\n
-#error:   [^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp32 module with previous -mfp64 modules\n
+#error:   [^\n]*: Warning: .* uses -mips32r2 -mfp64 \(12 callee-saved\) \(set by .*\), .* uses unknown floating point ABI 9\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-54.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-54.d	2015-11-17 12:35:48.216546781 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-54.d	2015-11-17 13:09:00.567771545 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-5.s
 #source: attr-gnu-4-4.s -W -mips32r2
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mfpxx \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
-#error:   [^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error:   [^\n]*: Warning: .* uses -mfpxx \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-64.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-64.d	2015-11-17 12:35:48.515314680 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-64.d	2015-11-17 13:09:00.574942056 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-6.s
 #source: attr-gnu-4-4.s -W -mips32r2
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mgp32 -mfp64 \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
-#error:   [^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error:   [^\n]*: Warning: .* uses -mgp32 -mfp64 \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z
Index: binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-74.d
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/attr-gnu-4-74.d	2015-11-17 12:35:48.986177495 +0000
+++ binutils/ld/testsuite/ld-mips-elf/attr-gnu-4-74.d	2015-11-17 13:09:00.604349799 +0000
@@ -1,6 +1,6 @@
 #source: attr-gnu-4-7.s
 #source: attr-gnu-4-4.s -W -mips32r2
 #ld: -r
-#error: \A[^\n]*: Warning: .* uses -mgp32 -mfp64 -mno-odd-spreg \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
-#error:   [^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error: \A[^\n]*: [^\n]* linking -mfp64 module with previous -mfp32 modules\n
+#error:   [^\n]*: Warning: .* uses -mgp32 -mfp64 -mno-odd-spreg \(set by .*\), .* uses -mips32r2 -mfp64 \(12 callee-saved\)\n
 #error:   [^\n]*: failed to merge target specific data of file [^\n]*\.o\Z



More information about the Binutils mailing list