diff options
author | Alan Modra <amodra@gmail.com> | 2002-10-15 05:10:48 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2002-10-15 05:10:48 +0000 |
commit | 49c1257607d865a171f98f85bac9d72bcea51bbd (patch) | |
tree | 8862cca513e649d79dab805f3a25fca793629008 | |
parent | ff4cb3e841a1fa5b1aa9328a10e19f64f9012245 (diff) | |
download | gdb-49c1257607d865a171f98f85bac9d72bcea51bbd.zip gdb-49c1257607d865a171f98f85bac9d72bcea51bbd.tar.gz gdb-49c1257607d865a171f98f85bac9d72bcea51bbd.tar.bz2 |
* objcopy.c (copy_file): Report ambiguous bfd_object matches, and
other object errors in preference to bfd_core errors.
-rw-r--r-- | binutils/ChangeLog | 5 | ||||
-rw-r--r-- | binutils/objcopy.c | 35 |
2 files changed, 33 insertions, 7 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 8a0da76..ef0f03f 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,8 @@ +2002-10-15 Alan Modra <amodra@bigpond.net.au> + + * objcopy.c (copy_file): Report ambiguous bfd_object matches, and + other object errors in preference to bfd_core errors. + 2002-10-14 Alan Modra <amodra@bigpond.net.au> * Makefile.am: Run "make dep-am". diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 1accad4..978e9c1 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1418,7 +1418,8 @@ copy_file (input_filename, output_filename, input_target, output_target) 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_filename, input_target, output_target) 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_filename, input_target, output_target) } 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; |