aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-03-06 10:42:22 +1030
committerAlan Modra <amodra@gmail.com>2023-03-06 10:42:22 +1030
commita734d906cc0e0d3f32705e67b72e7113c69890d6 (patch)
tree81241663b72aceea2f6abf06f17761239c99608c /binutils
parentec95986dc23f3f3c55beb945516a0008a526e772 (diff)
downloadgdb-a734d906cc0e0d3f32705e67b72e7113c69890d6.zip
gdb-a734d906cc0e0d3f32705e67b72e7113c69890d6.tar.gz
gdb-a734d906cc0e0d3f32705e67b72e7113c69890d6.tar.bz2
Correct objdump command line error handling
bfd_nonfatal is used when a bfd error is to be printed. That's not the case for command line errors. * objdump.c (nonfatal): Rename to my_bfd_nonfatal. (main): Use non_fatal and call usage on unrecognized arg errors. Don't set exit_status when calling usage.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/objdump.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/binutils/objdump.c b/binutils/objdump.c
index d00eed0..c895221 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -558,7 +558,7 @@ static struct option long_options[]=
};
static void
-nonfatal (const char *msg)
+my_bfd_nonfatal (const char *msg)
{
bfd_nonfatal (msg);
exit_status = 1;
@@ -5701,14 +5701,14 @@ display_object_bfd (bfd *abfd)
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
{
- nonfatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
list_matching_formats (matching);
return;
}
if (bfd_get_error () != bfd_error_file_not_recognized)
{
- nonfatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
return;
}
@@ -5718,7 +5718,7 @@ display_object_bfd (bfd *abfd)
return;
}
- nonfatal (bfd_get_filename (abfd));
+ my_bfd_nonfatal (bfd_get_filename (abfd));
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
list_matching_formats (matching);
@@ -5758,7 +5758,7 @@ display_any_bfd (bfd *file, int level)
if (arfile == NULL)
{
if (bfd_get_error () != bfd_error_no_more_archived_files)
- nonfatal (bfd_get_filename (file));
+ my_bfd_nonfatal (bfd_get_filename (file));
break;
}
@@ -5798,7 +5798,7 @@ display_file (char *filename, char *target, bool last_file)
file = bfd_openr (filename, target);
if (file == NULL)
{
- nonfatal (filename);
+ my_bfd_nonfatal (filename);
return;
}
@@ -5951,7 +5951,10 @@ main (int argc, char **argv)
else if (streq (optarg, "off"))
visualize_jumps = false;
else
- nonfatal (_("unrecognized argument to --visualize-option"));
+ {
+ non_fatal (_("unrecognized argument to --visualize-option"));
+ usage (stderr, 1);
+ }
}
break;
case OPTION_DISASSEMBLER_COLOR:
@@ -5968,7 +5971,10 @@ main (int argc, char **argv)
|| streq (optarg, "extended-colour"))
disassembler_color = extended;
else
- nonfatal (_("unrecognized argument to --disassembler-color"));
+ {
+ non_fatal (_("unrecognized argument to --disassembler-color"));
+ usage (stderr, 1);
+ }
break;
case 'E':
if (strcmp (optarg, "B") == 0)
@@ -5977,7 +5983,7 @@ main (int argc, char **argv)
endian = BFD_ENDIAN_LITTLE;
else
{
- nonfatal (_("unrecognized -E option"));
+ non_fatal (_("unrecognized -E option"));
usage (stderr, 1);
}
break;
@@ -5989,7 +5995,6 @@ main (int argc, char **argv)
else
{
non_fatal (_("unrecognized --endian type `%s'"), optarg);
- exit_status = 1;
usage (stderr, 1);
}
break;