diff options
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r-- | binutils/objcopy.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 01eb6c0..954abb8 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -390,6 +390,7 @@ copy_file (input_filename, output_filename, input_target, output_target) char *output_target; { bfd *ibfd; + char **matching; /* To allow us to do "strip *" without dying on the first non-object file, failures are nonfatal. */ @@ -400,7 +401,16 @@ copy_file (input_filename, output_filename, input_target, output_target) nonfatal (input_filename); } - if (bfd_check_format (ibfd, bfd_object)) + if (bfd_check_format (ibfd, bfd_archive)) + { + bfd *obfd = bfd_openw (output_filename, output_target); + if (obfd == NULL) + { + nonfatal (output_filename); + } + copy_archive (ibfd, obfd, output_target); + } + else if (bfd_check_format_matches (ibfd, bfd_object, &matching)) { bfd *obfd = bfd_openw (output_filename, output_target); if (obfd == NULL) @@ -420,20 +430,15 @@ copy_file (input_filename, output_filename, input_target, output_target) nonfatal (input_filename); } } - else if (bfd_check_format (ibfd, bfd_archive)) + else { - bfd *obfd = bfd_openw (output_filename, output_target); - if (obfd == NULL) + bfd_nonfatal (input_filename); + if (bfd_error == file_ambiguously_recognized) { - nonfatal (output_filename); + list_matching_formats (matching); + free (matching); } - copy_archive (ibfd, obfd, output_target); - } - else - { - /* Get the right error message. */ - bfd_check_format (ibfd, bfd_object); - nonfatal (input_filename); + status = 1; } } |