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]

PR4453 archive matching


BFD's check_format_matches for archives is quite lax.  If an archive
doesn't have a map, many formats will match.  This normally isn't a
problem because the default target matches too, and if the default
matches along with others you don't get an ambigous match error.
The same goes for targets in the associated target vector.  PR 4453 is
about the case where you have an archive with an armap, containing
object files for some target other than these specially treated
targets.  The trouble is that the ecoff archive match code says "yes,
I see an archive but it doesn't have an armap", which is quite
reasonable since the armap present isn't an ecoff one, but without an
armap the files within the archive are not checked.  Again this is
reasonble because the archive might not contain object files.  Where
we go wrong is to count such a target match as good as the correct
target match.

	PR 4453
	* format.c (bfd_check_format_matches): Don't accept archives as
	fully matching unless they have a map.

Index: bfd/format.c
===================================================================
RCS file: /cvs/src/src/bfd/format.c,v
retrieving revision 1.26
diff -u -p -r1.26 format.c
--- bfd/format.c	14 Sep 2007 05:19:27 -0000	1.26
+++ bfd/format.c	19 Jan 2008 13:02:43 -0000
@@ -210,7 +210,7 @@ bfd_check_format_matches (bfd *abfd, bfd
 
       temp = BFD_SEND_FMT (abfd, _bfd_check_format, (abfd));
 
-      if (temp)
+      if (temp && (abfd->format != bfd_archive || bfd_has_map (abfd)))
 	{
 	  /* This format checks out as ok!  */
 	  right_targ = temp;
@@ -228,12 +228,13 @@ bfd_check_format_matches (bfd *abfd, bfd
 	    matching_vector[match_count] = temp;
 	  match_count++;
 	}
-      else if ((err = bfd_get_error ()) == bfd_error_wrong_object_format
+      else if (temp
+	       || (err = bfd_get_error ()) == bfd_error_wrong_object_format
 	       || err == bfd_error_file_ambiguously_recognized)
 	{
-	  /* An archive with objects of the wrong type, or an
-	     ambiguous match.  We want this target to match if we get
-	     no better matches.  */
+	  /* An archive with no armap or objects of the wrong type,
+	     or an ambiguous match.  We want this target to match
+	     if we get no better matches.  */
 	  if (ar_right_targ != bfd_default_vector[0])
 	    ar_right_targ = *target;
 	  if (matching_vector)

-- 
Alan Modra
Australia Development Lab, IBM


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