From eae821453c15f5990eecdaae1f16642baa0c11fb Mon Sep 17 00:00:00 2001 From: David MacKenzie Date: Sat, 22 Jan 1994 05:11:40 +0000 Subject: [PATCH] * objdump.c (list_matching_formats): If the file format is ambiguous, print the matching names so the user can choose one. (display_bfd): Call it. (display_file): Call it. --- binutils/ChangeLog | 7 +++++++ binutils/objdump.c | 28 +++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 5509f5be0f6..9a323fedc68 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,10 @@ +Fri Jan 21 20:22:30 1994 David J. Mackenzie (djm@thepub.cygnus.com) + + * objdump.c (list_matching_formats): If the file format is ambiguous, + print the matching names so the user can choose one. + (display_bfd): Call it. + (display_file): Call it. + Fri Jan 21 19:17:25 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) * objdump.c (disassemble_data): Support bfd_arch_rs6000. diff --git a/binutils/objdump.c b/binutils/objdump.c index c6dddc8eaa5..5da041cdca2 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -184,7 +184,7 @@ DEFUN (slurp_symtab, (abfd), symcount = bfd_canonicalize_symtab (abfd, sy); if (symcount <= 0) { - fprintf (stderr, "%s: Bad symbol table in \"%s\".\n", + fprintf (stderr, "%s: %s: Invalid symbol table\n", program_name, bfd_get_filename (abfd)); exit (1); } @@ -516,7 +516,7 @@ disassemble_data (abfd) disassemble = print_insn_little_mips; break; #endif -#ifdef ARCH_rs6000: +#ifdef ARCH_rs6000 case bfd_arch_rs6000: disassemble = print_insn_rs6000; break; @@ -730,7 +730,7 @@ dump_stabs_1 (abfd, name1, name2) if (is_elf ? (0 == stabstr_hdr) : (0 == stabstrsect)) { - fprintf (stderr, "%s: %s has no %s section.\n", program_name, + fprintf (stderr, "%s: %s has no %s section\n", program_name, abfd->filename, name2); return; } @@ -747,7 +747,7 @@ dump_stabs_1 (abfd, name1, name2) if (bfd_seek (abfd, stab_hdr->sh_offset, SEEK_SET) < 0 || stab_size != bfd_read ((PTR) stabs, stab_size, 1, abfd)) { - fprintf (stderr, "%s: reading %s section of %s failed.\n", + fprintf (stderr, "%s: Reading %s section of %s failed\n", program_name, name1, abfd->filename); return; @@ -763,7 +763,7 @@ dump_stabs_1 (abfd, name1, name2) if (bfd_seek (abfd, stabstr_hdr->sh_offset, SEEK_SET) < 0 || stabstr_size != bfd_read ((PTR) strtab, stabstr_size, 1, abfd)) { - fprintf (stderr, "%s: reading %s section of %s failed.\n", + fprintf (stderr, "%s: Reading %s section of %s failed\n", program_name, name2, abfd->filename); return; @@ -832,15 +832,27 @@ dump_stabs_1 (abfd, name1, name2) printf ("\n\n"); } +static void +list_matching_formats() +{ + char **p = bfd_matching_formats (); + + fprintf(stderr, "%s: Matching formats:", program_name); + while (*p) + fprintf(stderr, " %s", *p++); + fprintf(stderr, "\n"); +} + static void display_bfd (abfd) bfd *abfd; { - if (!bfd_check_format (abfd, bfd_object)) { - fprintf (stderr, "%s:%s: %s\n", program_name, abfd->filename, + fprintf (stderr, "%s: %s: %s\n", program_name, abfd->filename, bfd_errmsg (bfd_error)); + if (bfd_error == file_ambiguously_recognized) + list_matching_formats(); return; } printf ("\n%s: file format %s\n", abfd->filename, abfd->xvec->name); @@ -904,6 +916,8 @@ display_file (filename, target) { fprintf (stderr, "%s: ", program_name); bfd_perror (filename); + if (bfd_error == file_ambiguously_recognized) + list_matching_formats(); return; } -- 2.30.2