public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* objcopy error message
@ 2002-10-14 22:13 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2002-10-14 22:13 UTC (permalink / raw)
  To: binutils

objcopy currently doesn't report ambiguous matches very well.
Fixed like this:

	* objcopy.c (copy_file): Report ambiguous bfd_object matches, and
	other object errors in preference to bfd_core errors.

Index: binutils/objcopy.c
===================================================================
RCS file: /cvs/src/src/binutils/objcopy.c,v
retrieving revision 1.41
diff -u -p -r1.41 objcopy.c
--- binutils/objcopy.c	13 Aug 2002 13:39:02 -0000	1.41
+++ binutils/objcopy.c	15 Oct 2002 04:53:11 -0000
@@ -1418,7 +1418,8 @@ copy_file (input_filename, output_filena
      const char *output_target;
 {
   bfd *ibfd;
-  char **matching;
+  char **obj_matching;
+  char **core_matching;
 
   /* To allow us to do "strip *" without dying on the first
      non-object file, failures are nonfatal.  */
@@ -1441,11 +1442,10 @@ copy_file (input_filename, output_filena
 
       copy_archive (ibfd, obfd, output_target);
     }
-  else if (bfd_check_format_matches (ibfd, bfd_object, &matching)
-	   || bfd_check_format_matches (ibfd, bfd_core, &matching))
+  else if (bfd_check_format_matches (ibfd, bfd_object, &obj_matching))
     {
       bfd *obfd;
-
+    do_copy:
       /* bfd_get_target does not return the correct value until
          bfd_check_format succeeds.  */
       if (output_target == NULL)
@@ -1465,12 +1465,33 @@ copy_file (input_filename, output_filena
     }
   else
     {
+      bfd_error_type obj_error = bfd_get_error ();
+      bfd_error_type core_error;
+      
+      if (bfd_check_format_matches (ibfd, bfd_core, &core_matching))
+	{
+	  /* This probably can't happen..  */
+	  if (obj_error == bfd_error_file_ambiguously_recognized)
+	    free (obj_matching);
+	  goto do_copy;
+	}
+
+      core_error = bfd_get_error ();
+      /* Report the object error in preference to the core error.  */
+      if (obj_error != core_error)
+	bfd_set_error (obj_error);
+
       bfd_nonfatal (input_filename);
 
-      if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
+      if (obj_error == bfd_error_file_ambiguously_recognized)
+	{
+	  list_matching_formats (obj_matching);
+	  free (obj_matching);
+	}
+      if (core_error == bfd_error_file_ambiguously_recognized)
 	{
-	  list_matching_formats (matching);
-	  free (matching);
+	  list_matching_formats (core_matching);
+	  free (core_matching);
 	}
 
       status = 1;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-10-15  5:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-14 22:13 objcopy error message Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).