Unknown attribute handling bug fix

Joseph S. Myers joseph@codesourcery.com
Thu Nov 4 15:51:00 GMT 2010


This patch fixes a pre-existing bug in the generic merging of unknown
object attributes that I found in the course of implementing and
testing the C6X support for such merging: inappropriate use of pointer
comparison for string attributes.  OK to commit?  (Test coverage for
this fix is provided by ld-tic6x/attr-unknown-3.d, added by the
following C6X-specific patch I'll post shortly.)

2010-11-04  Joseph Myers  <joseph@codesourcery.com>

	* elf-attrs.c (_bfd_elf_merge_unknown_attribute_low,
	_bfd_elf_merge_unknown_attribute_list): Correct test for matching
	string attributes.

Index: bfd/elf-attrs.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-attrs.c,v
retrieving revision 1.13
diff -u -p -r1.13 elf-attrs.c
--- bfd/elf-attrs.c	4 Nov 2010 11:35:00 -0000	1.13
+++ bfd/elf-attrs.c	4 Nov 2010 15:41:46 -0000
@@ -613,7 +613,7 @@ _bfd_elf_merge_unknown_attribute_low (bf
 
   /* Only pass on attributes that match in both inputs.  */
   if (in_attr[tag].i != out_attr[tag].i
-      || in_attr[tag].s != out_attr[tag].s
+      || (in_attr[tag].s == NULL) != (out_attr[tag].s == NULL)
       || (in_attr[tag].s != NULL && out_attr[tag].s != NULL
 	  && strcmp (in_attr[tag].s, out_attr[tag].s) != 0))
     {
@@ -673,7 +673,7 @@ _bfd_elf_merge_unknown_attribute_list (b
 
 	  /*  Only pass on attributes that match in both inputs.  */
 	  if (in_list->attr.i != out_list->attr.i
-	      || in_list->attr.s != out_list->attr.s
+	      || (in_list->attr.s == NULL) != (out_list->attr.s == NULL)
 	      || (in_list->attr.s && out_list->attr.s
 		  && strcmp (in_list->attr.s, out_list->attr.s) != 0))
 	    {

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Binutils mailing list