]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: Handle bad -gdwarf options, just like bad --gdwarf options.
authorMark Wielaard <mark@klomp.org>
Wed, 26 Aug 2020 19:46:04 +0000 (21:46 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 14 Sep 2020 22:24:09 +0000 (00:24 +0200)
parse_args uses getopt_long_only so it can handle long options both
with double and single dash. But this means that some single dash
options like -gdwarf-1 don't generate an error (unlike --gdwarf-1).

This is especially confusing since there is also --gdwarf2, but no
--gdwarf4 (it is --gdwarf-4). When giving -gdwarf4 the option is
silently interpreted as -g (which set dwarf_version to 2). This causes
some confusion for people who don't expect this and suddenly get
DWARF2 instead of DWARF4 as they might expect.

So make it so that the -gdwarf<unknown> creates an error, just like
--gdwarf<unknown> would.

gas/ChangeLog
gas/as.c

index bc72700cb472bcc0bb82af669fd5a655e27a2e63..10286e66e13b2e180360da45011bec86da78c466 100644 (file)
@@ -1,3 +1,10 @@
+2020-09-14  Mark Wielaard  <mark@klomp.org>
+
+       Backport from mainline:
+       2020-08-26  Mark Wielaard  <mark@klomp.org>
+
+       * as.c (parse_args): Handle bad -gdwarf options.
+
 2020-08-26  David Faust  <david.faust@oracle.com>
 
        * config/tc-bpf.c: Add option -mxbpf to select xbpf isa.
index a04e615d35dfed90ec451929fe4d1947f9d67c34..0801903126e5c36e24a9fdeac0189a7cff42b910 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -824,6 +824,13 @@ This program has absolutely no warranty.\n"));
              && md_parse_option (optc, optarg))
            continue;
 
+         /* We end up here for any -gsomething-not-already-a-long-option.
+            give some useful feedback on not (yet) supported -gdwarfxxx
+            versions/sections/options.  */
+         if (strncmp (old_argv[optind - 1], "-gdwarf",
+                      strlen ("-gdwarf")) == 0)
+           as_fatal (_("unknown DWARF option %s\n"), old_argv[optind - 1]);
+
          if (md_debug_format_selector)
            debug_type = md_debug_format_selector (& use_gnu_debug_info_extensions);
          else if (IS_ELF)