X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Flexsup.c;h=87341f93dcc41a5529f4258cf8d2ea0eff327c58;hb=39a67dc4f7d032c78f031e2d101b9552f1a6b57f;hp=1dcbf4cfa72790a2bcbc1a5d8499ba4c3e382a2f;hpb=6c3bc0f82c625d425b09c01f96b64946abe4118e;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/lexsup.c b/ld/lexsup.c index 1dcbf4cfa7..87341f93dc 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -1,5 +1,5 @@ /* Parse options for the GNU linker. - Copyright (C) 1991-2015 Free Software Foundation, Inc. + Copyright (C) 1991-2016 Free Software Foundation, Inc. This file is part of the GNU Binutils. @@ -65,9 +65,9 @@ static void help (void); enum control_enum { /* Use one dash before long option name. */ - ONE_DASH, + ONE_DASH = 1, /* Use two dashes before long option name. */ - TWO_DASHES, + TWO_DASHES = 2, /* Only accept two dashes before the long option name. This is an overloading of the use of this enum, since originally it was only intended to tell the --help display function how to display @@ -679,7 +679,28 @@ parse_args (unsigned argc, char **argv) switch (optc) { case '?': - einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]); + { + /* If the last word on the command line is an option that + requires an argument, getopt will refuse to recognise it. + Try to catch such options here and issue a more helpful + error message than just "unrecognized option". */ + int opt; + + for (opt = ARRAY_SIZE (ld_options); opt--;) + if (ld_options[opt].opt.has_arg == required_argument + /* FIXME: There are a few short options that do not + have long equivalents, but which require arguments. + We should handle them too. */ + && ld_options[opt].opt.name != NULL + && strcmp (argv[last_optind] + ld_options[opt].control, ld_options[opt].opt.name) == 0) + { + einfo (_("%P: %s: missing argument\n"), argv[last_optind]); + break; + } + + if (opt == -1) + einfo (_("%P: unrecognized option '%s'\n"), argv[last_optind]); + } /* Fall through. */ default: @@ -997,7 +1018,7 @@ parse_args (unsigned argc, char **argv) break; case OPTION_PLUGIN_OPT: if (plugin_opt_plugin_arg (optarg)) - einfo(_("%P%F: bad -plugin-opt option\n")); + einfo (_("%P%F: bad -plugin-opt option\n")); break; #endif /* ENABLE_PLUGINS */ case 'q':