* bucomm.c (bfd_nonfatal): Flush stdout before output to stderr.

(bfd_nonfatal_message, report, list_matching_formats): Likewise.
	(list_supported_targets): Tidy.
	* objdump.c (free_only_list): Formatting.
	(slurp_dynamic_symtab): Non-zero exit status for "not a dynamic
	object".
	(update_source_path): Delete redundant check for NULL filename.
	(disassemble_bytes): Error if disassemble_fn returns a value
	that won't increment address.
	(disassemble_data): Don't capitalize error message.
	(read_section_stabs): Likewise.
	(main): Return non-zero exit status on bad options.
This commit is contained in:
Alan Modra 2010-10-05 05:48:10 +00:00
parent ea65fe05d0
commit a8c62f1c04
3 changed files with 44 additions and 15 deletions

View File

@ -1,3 +1,18 @@
2010-10-05 Alan Modra <amodra@gmail.com>
* bucomm.c (bfd_nonfatal): Flush stdout before output to stderr.
(bfd_nonfatal_message, report, list_matching_formats): Likewise.
(list_supported_targets): Tidy.
* objdump.c (free_only_list): Formatting.
(slurp_dynamic_symtab): Non-zero exit status for "not a dynamic
object".
(update_source_path): Delete redundant check for NULL filename.
(disassemble_bytes): Error if disassemble_fn returns a value
that won't increment address.
(disassemble_data): Don't capitalize error message.
(read_section_stabs): Likewise.
(main): Return non-zero exit status on bad options.
2010-10-03 H.J. Lu <hongjiu.lu@intel.com>
PR binutils/12088

View File

@ -1,6 +1,6 @@
/* bucomm.c -- Bin Utils COMmon code.
Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002,
2003, 2005, 2006, 2007, 2008, 2009
2003, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Binutils.
@ -52,8 +52,10 @@ char *program_name;
void
bfd_nonfatal (const char *string)
{
const char *errmsg = bfd_errmsg (bfd_get_error ());
const char *errmsg;
fflush (stdout);
errmsg = bfd_errmsg (bfd_get_error ());
if (string)
fprintf (stderr, "%s: %s: %s\n", program_name, string, errmsg);
else
@ -78,10 +80,13 @@ bfd_nonfatal_message (const char *filename,
const asection *section,
const char *format, ...)
{
const char *errmsg = bfd_errmsg (bfd_get_error ());
const char *section_name = NULL;
const char *errmsg;
const char *section_name;
va_list args;
fflush (stdout);
errmsg = bfd_errmsg (bfd_get_error ());
section_name = NULL;
va_start (args, format);
fprintf (stderr, "%s", program_name);
@ -116,6 +121,7 @@ bfd_fatal (const char *string)
void
report (const char * format, va_list args)
{
fflush (stdout);
fprintf (stderr, "%s: ", program_name);
vfprintf (stderr, format, args);
putc ('\n', stderr);
@ -165,6 +171,7 @@ set_default_bfd_target (void)
void
list_matching_formats (char **p)
{
fflush (stdout);
fprintf (stderr, _("%s: Matching formats:"), program_name);
while (*p)
fprintf (stderr, " %s", *p++);
@ -177,13 +184,14 @@ void
list_supported_targets (const char *name, FILE *f)
{
int t;
const char **targ_names = bfd_target_list ();
const char **targ_names;
if (name == NULL)
fprintf (f, _("Supported targets:"));
else
fprintf (f, _("%s: supported targets:"), name);
targ_names = bfd_target_list ();
for (t = 0; targ_names[t] != NULL; t++)
fprintf (f, " %s", targ_names[t]);
fprintf (f, "\n");

View File

@ -393,7 +393,8 @@ free_only_list (void)
{
if (! at_least_one_seen)
{
non_fatal (_("Section '%s' mentioned in a -j option, but not found in any input file"),
non_fatal (_("section '%s' mentioned in a -j option, "
"but not found in any input file"),
only->name);
exit_status = 1;
}
@ -555,6 +556,7 @@ slurp_dynamic_symtab (bfd *abfd)
if (!(bfd_get_file_flags (abfd) & DYNAMIC))
{
non_fatal (_("%s: not a dynamic object"), bfd_get_filename (abfd));
exit_status = 1;
dynsymcount = 0;
return NULL;
}
@ -1210,9 +1212,6 @@ update_source_path (const char *filename)
const char *fname;
int i;
if (filename == NULL)
return NULL;
p = try_print_file_open (filename, filename);
if (p != NULL)
return p;
@ -1626,10 +1625,16 @@ disassemble_bytes (struct disassemble_info * inf,
inf->stream = stdout;
if (insn_width == 0 && inf->bytes_per_line != 0)
octets_per_line = inf->bytes_per_line;
if (octets < 0)
if (octets < (int) opb)
{
if (sfile.pos)
printf ("%s\n", sfile.buffer);
if (octets >= 0)
{
non_fatal (_("disassemble_fn returned length %d"),
octets);
exit_status = 1;
}
break;
}
}
@ -2107,7 +2112,7 @@ disassemble_data (bfd *abfd)
const bfd_arch_info_type *inf = bfd_scan_arch (machine);
if (inf == NULL)
fatal (_("Can't use supplied machine %s"), machine);
fatal (_("can't use supplied machine %s"), machine);
abfd->arch_info = inf;
}
@ -2126,7 +2131,7 @@ disassemble_data (bfd *abfd)
aux.disassemble_fn = disassembler (abfd);
if (!aux.disassemble_fn)
{
non_fatal (_("Can't disassemble for architecture %s\n"),
non_fatal (_("can't disassemble for architecture %s\n"),
bfd_printable_arch_mach (bfd_get_arch (abfd), 0));
exit_status = 1;
return;
@ -2396,11 +2401,11 @@ read_section_stabs (bfd *abfd, const char *sect_name, bfd_size_type *size_ptr)
if (! bfd_get_section_contents (abfd, stabsect, contents, 0, size))
{
non_fatal (_("Reading %s section of %s failed: %s"),
non_fatal (_("reading %s section of %s failed: %s"),
sect_name, bfd_get_filename (abfd),
bfd_errmsg (bfd_get_error ()));
free (contents);
exit_status = 1;
free (contents);
return NULL;
}
@ -3350,7 +3355,7 @@ main (int argc, char **argv)
endian = BFD_ENDIAN_LITTLE;
else
{
non_fatal (_("unrecognized -E option"));
nonfatal (_("unrecognized -E option"));
usage (stderr, 1);
}
break;
@ -3362,6 +3367,7 @@ main (int argc, char **argv)
else
{
non_fatal (_("unrecognized --endian type `%s'"), optarg);
exit_status = 1;
usage (stderr, 1);
}
break;