https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98943

--- Comment #5 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
Created attachment 50119
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50119&action=edit
proposed direction

Here's a test patch.  As Jakub points out, we pass -d$ANYTHING to the compiler,
it is the following 123,456 that is considered a file to pass to the linker. 
It's fun trying to find a -OPTION that the driver doesn't pass to the linker
and doesn't already reject.  '-n' is one.

a) Reject any filename that is -STUFF (allow plain '-')
b) Reject any absolute path that is not accessible
c) When ignoring linker files, error if they are inaccessible.  If there are
funky ways of spelling a member of an archive, why are you trying to pass them
when not linking (i.e.  you're doing something specialized, do it in the right
place)

devvm1702:116>./xg++ -B./ -diag 123,44 -x c -c /dev/null
cc1: warning: unrecognized gcc debugging option: i
cc1: warning: unrecognized gcc debugging option: g
xg++: error: 123,44: unreadable linker input file file unused because linking
is not done: No such file or directory

devvm1702:120>./xg++ -B./ -nart bob.c 
xg++: error: unrecognized command-line option '-nart'

though I notice:

devvm1702:121>./xg++ -B./ -nope bob.c 
xg++: error: unrecognized command-line option '-nope'; did you mean '-no-pie'?

perhaps that check should apply to all - options, and not just near misses?

Reply via email to