When you use cc(1)
to link a program, it will invoke a default linker command. For instance, your version of the compiler may have been built to use /usr/bin/l
GCC uses internally spec files (to decide how the gcc
program behaves, in particular how it is linking and with what linker). You can configure or change that with -specs= so have your own spec file and use it. Or use the -T option (of gcc
which explicitly passes it to ld
) to give a linker script.
The default spec is obtained with gcc -dumpspecs
Also, by strace(1)-ing some gcc
command, you'll find out that it tries to access e.g. /usr/lib/gcc/x86_64-linux-gnu/specs
; so put your own spec file there.
Those spec files are textual, so you should be able to write your own.
But I am not sure it is a good idea.
BTW, /usr/bin/cc
is on Linux distribution a symlink (on Debian: /usr/bin/cc -> /etc/alternatives/cc -> /usr/bin/gcc
), either to some gcc
or to some clang
. AFAIK, cc
(and c99) is specified in POSIX (but of course, nothing is told about its relation to ld
)