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]

[RFA] Make incompatible Tag_compatibility attributes cause ld to fail


All,

Please find attached a patch which causes ld to fail when you try to
link two objects with incompatible Tag_compatibility attributes on an
ARM EABI target.

ld already produced an error message in this case, but the link
continued producing, possibly incorrect, ouput files and exiting with
status 0.  This patch causes ld to not produce any output and to exit
with non-zero status.

I think the bfd/elf32-ppc.c and bfd/elfxx-mips.c source files have
identical bugs to the issue fixed in bfd/elf32-arm.c - but I don't know
enough about those targets to make the change.

Proposed ld/testsuite/ChangeLog: 

2010-03-02  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>

	* ld-arm/arm-merge-incompatible.d: New test.
	* ld-arm/arm-merge-incompatiblea.s: Likewise.
	* ld-arm/arm-merge-incompatibleb.s: Likewise.
	* ld-arm/arm-elf.exp: Run the new test.

2010-03-01  Matthew Gretton-Dann  <matthew.gretton-dann@arm.com>

	* elf32-arm.c (elf32_arm_merge_eabi_attributes): Add a check 
	of the return value from the call to 
	_bfd_elf_merge_object_attributes.

Thanks,

Matt

-- 
Matthew Gretton-Dann
Principal Engineer - Tools, PD Software
ARM Limited
Index: ld/testsuite/ld-arm/arm-elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-arm/arm-elf.exp,v
retrieving revision 1.72
diff -u -p -u -p -r1.72 arm-elf.exp
--- ld/testsuite/ld-arm/arm-elf.exp	24 Feb 2010 11:15:11 -0000	1.72
+++ ld/testsuite/ld-arm/arm-elf.exp	2 Mar 2010 09:29:03 -0000
@@ -505,3 +505,4 @@ 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-incompatible"
Index: ld/testsuite/ld-arm/attr-merge-incompatible.d
===================================================================
diff -u -p /dev/null ld/testsuite/ld-arm/attr-merge-incompatible.d
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-incompatible.d	2010-03-01 17:02:50.726720000 +0000
@@ -0,0 +1,5 @@
+#source: attr-merge-incompatibleb.s
+#source: attr-merge-incompatiblea.s
+#as:
+#ld:
+#error: Object has vendor-specific contents that must be processed by the '.+' toolchain
Index: ld/testsuite/ld-arm/attr-merge-incompatiblea.s
===================================================================
diff -u -p /dev/null ld/testsuite/ld-arm/attr-merge-incompatiblea.s
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-incompatiblea.s	2010-03-01 17:02:50.730717000 +0000
@@ -0,0 +1 @@
+	.eabi_attribute Tag_compatibility, 1, "Random Toolchain Vendor"
Index: ld/testsuite/ld-arm/attr-merge-incompatibleb.s
===================================================================
diff -u -p /dev/null ld/testsuite/ld-arm/attr-merge-incompatibleb.s
--- /dev/null	2010-02-15 11:55:38.271192152 +0000
+++ ld/testsuite/ld-arm/attr-merge-incompatibleb.s	2010-03-01 17:02:50.733722000 +0000
@@ -0,0 +1 @@
+	.eabi_attribute Tag_compatibility, 1, "gnu"
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.223
diff -u -p -u -p -r1.223 elf32-arm.c
--- bfd/elf32-arm.c	18 Feb 2010 10:56:26 -0000	1.223
+++ bfd/elf32-arm.c	2 Mar 2010 09:29:05 -0000
@@ -10284,7 +10284,8 @@ elf32_arm_merge_eabi_attributes (bfd *ib
     }
 
   /* Merge Tag_compatibility attributes and any common GNU ones.  */
-  _bfd_elf_merge_object_attributes (ibfd, obfd);
+  if (!_bfd_elf_merge_object_attributes (ibfd, obfd))
+    return FALSE;
 
   /* Check for any attributes not known on ARM.  */
   in_list = elf_other_obj_attributes_proc (ibfd);

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