* objdump.c (exit_status): New static variable.

(nonfatal): New static function.
	(disassemble_data): Set exit_status on error.
	(read_section_stabs): Likewise.
	(display_bfd): Likewise.  Call nonfatal rather than bfd_nonfatal.
	(display_file): Call nonfatal rather than bfd_nonfatal.
	(display_target_list, display_info_table): Likewise.
	(main): Return exit_status rather than 0.
This commit is contained in:
Ian Lance Taylor
1999-08-09 05:23:29 +00:00
parent 1a1ae23e52
commit 75cd796a72
2 changed files with 45 additions and 13 deletions

View File

@ -1,3 +1,14 @@
1999-08-09 Ian Lance Taylor <ian@zembu.com>
* objdump.c (exit_status): New static variable.
(nonfatal): New static function.
(disassemble_data): Set exit_status on error.
(read_section_stabs): Likewise.
(display_bfd): Likewise. Call nonfatal rather than bfd_nonfatal.
(display_file): Call nonfatal rather than bfd_nonfatal.
(display_target_list, display_info_table): Likewise.
(main): Return exit_status rather than 0.
1999-08-08 Ian Lance Taylor <ian@zembu.com> 1999-08-08 Ian Lance Taylor <ian@zembu.com>
* objdump.c (dump_section_header): Update for renaming of * objdump.c (dump_section_header): Update for renaming of

View File

@ -44,6 +44,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern int fprintf PARAMS ((FILE *, const char *, ...)); extern int fprintf PARAMS ((FILE *, const char *, ...));
#endif #endif
/* Exit status. */
static int exit_status = 0;
static char *default_target = NULL; /* default at runtime */ static char *default_target = NULL; /* default at runtime */
static int show_version = 0; /* show the version number */ static int show_version = 0; /* show the version number */
@ -112,6 +115,9 @@ static long dynsymcount = 0;
static void static void
usage PARAMS ((FILE *, int)); usage PARAMS ((FILE *, int));
static void
nonfatal PARAMS ((const char *));
static void static void
display_file PARAMS ((char *filename, char *target)); display_file PARAMS ((char *filename, char *target));
@ -288,6 +294,14 @@ static struct option long_options[]=
}; };
static void static void
nonfatal (msg)
const char *msg;
{
bfd_nonfatal (msg);
exit_status = 1;
}
static void
dump_section_header (abfd, section, ignored) dump_section_header (abfd, section, ignored)
bfd *abfd ATTRIBUTE_UNUSED; bfd *abfd ATTRIBUTE_UNUSED;
asection *section; asection *section;
@ -1565,6 +1579,7 @@ disassemble_data (abfd)
fprintf (stderr, _("%s: Can't disassemble for architecture %s\n"), fprintf (stderr, _("%s: Can't disassemble for architecture %s\n"),
program_name, program_name,
bfd_printable_arch_mach (bfd_get_arch (abfd), 0)); bfd_printable_arch_mach (bfd_get_arch (abfd), 0));
exit_status = 1;
return; return;
} }
@ -1818,6 +1833,7 @@ read_section_stabs (abfd, stabsect_name, strsect_name)
{ {
fprintf (stderr, _("%s: %s has no %s section\n"), program_name, fprintf (stderr, _("%s: %s has no %s section\n"), program_name,
bfd_get_filename (abfd), strsect_name); bfd_get_filename (abfd), strsect_name);
exit_status = 1;
return false; return false;
} }
@ -1834,6 +1850,7 @@ read_section_stabs (abfd, stabsect_name, strsect_name)
bfd_errmsg (bfd_get_error ())); bfd_errmsg (bfd_get_error ()));
free (stabs); free (stabs);
free (strtab); free (strtab);
exit_status = 1;
return false; return false;
} }
@ -1845,6 +1862,7 @@ read_section_stabs (abfd, stabsect_name, strsect_name)
bfd_errmsg (bfd_get_error ())); bfd_errmsg (bfd_get_error ()));
free (stabs); free (stabs);
free (strtab); free (strtab);
exit_status = 1;
return false; return false;
} }
@ -2018,7 +2036,7 @@ display_bfd (abfd)
if (!bfd_check_format_matches (abfd, bfd_object, &matching)) if (!bfd_check_format_matches (abfd, bfd_object, &matching))
{ {
bfd_nonfatal (bfd_get_filename (abfd)); nonfatal (bfd_get_filename (abfd));
if (bfd_get_error () == bfd_error_file_ambiguously_recognized) if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
{ {
list_matching_formats (matching); list_matching_formats (matching);
@ -2082,8 +2100,12 @@ display_bfd (abfd)
if (dhandle != NULL) if (dhandle != NULL)
{ {
if (! print_debugging_info (stdout, dhandle)) if (! print_debugging_info (stdout, dhandle))
fprintf (stderr, _("%s: printing debugging information failed\n"), {
bfd_get_filename (abfd)); fprintf (stderr,
_("%s: printing debugging information failed\n"),
bfd_get_filename (abfd));
exit_status = 1;
}
} }
} }
if (syms) if (syms)
@ -2108,7 +2130,7 @@ display_file (filename, target)
file = bfd_openr (filename, target); file = bfd_openr (filename, target);
if (file == NULL) if (file == NULL)
{ {
bfd_nonfatal (filename); nonfatal (filename);
return; return;
} }
@ -2125,9 +2147,7 @@ display_file (filename, target)
if (arfile == NULL) if (arfile == NULL)
{ {
if (bfd_get_error () != bfd_error_no_more_archived_files) if (bfd_get_error () != bfd_error_no_more_archived_files)
{ nonfatal (bfd_get_filename (file));
bfd_nonfatal (bfd_get_filename (file));
}
break; break;
} }
@ -2545,14 +2565,14 @@ display_target_list ()
if (abfd == NULL) if (abfd == NULL)
{ {
bfd_nonfatal (dummy_name); nonfatal (dummy_name);
continue; continue;
} }
if (! bfd_set_format (abfd, bfd_object)) if (! bfd_set_format (abfd, bfd_object))
{ {
if (bfd_get_error () != bfd_error_invalid_operation) if (bfd_get_error () != bfd_error_invalid_operation)
bfd_nonfatal (p->name); nonfatal (p->name);
continue; continue;
} }
@ -2598,7 +2618,7 @@ display_info_table (first, last)
if (abfd == NULL) if (abfd == NULL)
{ {
bfd_nonfatal (p->name); nonfatal (p->name);
ok = false; ok = false;
} }
@ -2607,7 +2627,7 @@ display_info_table (first, last)
if (! bfd_set_format (abfd, bfd_object)) if (! bfd_set_format (abfd, bfd_object))
{ {
if (bfd_get_error () != bfd_error_invalid_operation) if (bfd_get_error () != bfd_error_invalid_operation)
bfd_nonfatal (p->name); nonfatal (p->name);
ok = false; ok = false;
} }
} }
@ -2803,7 +2823,8 @@ main (argc, argv)
endian = BFD_ENDIAN_LITTLE; endian = BFD_ENDIAN_LITTLE;
else else
{ {
fprintf (stderr, _("%s: unrecognized -E option\n"), program_name); fprintf (stderr, _("%s: unrecognized -E option\n"),
program_name);
usage (stderr, 1); usage (stderr, 1);
} }
break; break;
@ -2845,5 +2866,5 @@ main (argc, argv)
END_PROGRESS (program_name); END_PROGRESS (program_name);
return 0; return exit_status;
} }