Bug 29067 - gas: -gsomething-not-already-a-long-option does not get a diagnostic
Summary: gas: -gsomething-not-already-a-long-option does not get a diagnostic
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.39
: P2 normal
Target Milestone: 2.39
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-15 21:27 UTC by Fangrui Song
Modified: 2022-04-19 17:46 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2022-04-15 21:27:13 UTC
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=4a5700b62f767ed08c97122bad182244700bb4e3 added a diagnostic:

% ~/Dev/binutils-gdb/out/debug/gas/as-new -gdwarf-6 a.s
Assembler messages:
Fatal error: unknown DWARF option -gdwarf-6

I think it makes sense to extend it for other unrecognized strings not starting with "dwarf"

% ~/Dev/binutils-gdb/out/debug/gas/as-new -gsomething-not-already-a-long-option a.s
# no diagnostic
Comment 1 H.J. Lu 2022-04-16 17:32:28 UTC
This works:

diff --git a/gas/as.c b/gas/as.c
index f320bac89b5..0262a6fec98 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -836,6 +836,8 @@ This program has absolutely no warranty.\n"));
        versions/sections/options.  */
     if (startswith (old_argv[optind - 1], "-gdwarf"))
       as_fatal (_("unknown DWARF option %s\n"), old_argv[optind - 1]);
+    else if (old_argv[optind - 1][1] == 'g' && optarg != NULL)
+      as_fatal (_("unknown option `%s'"), old_argv[optind - 1]);
 
     if (md_debug_format_selector)
       debug_type = md_debug_format_selector (& use_gnu_debug_info_extensions);
Comment 2 H.J. Lu 2022-04-19 17:46:46 UTC
Fixed by

commit 6ea673e2d643b7b2283aa73d35b02dfc9aa7115f
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Apr 16 10:46:05 2022 -0700

    as: Reject unknown -gXXX option
    
            * as.c (parse_args): Reject unknown -gXXX option.
            * testsuite/gas/all/empty.s: New file.
            * testsuite/gas/all/pr29067.d: Likewise.
            * testsuite/gas/all/pr29067.err: Likewise.
            * testsuite/gas/all/gas.exp: Run pr29067.