Is your linker from binutils? binutils ld
supports .a
files as implicit linker scripts:
If you specify a linker input file which the linker can not recognize as an object file or an archive file, it will try to read the file as a linker script. If the file can not be parsed as a linker script, the linker will report an error.
A linker script does not have to be complicated, it can be as simple as this (for glibc's libc.so
):
/* GNU ld script. */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( …/libc.so.6 …/libc_nonshared.a AS_NEEDED ( …/ld-linux-x86-64.so.2 ) )
Or you can just use INPUT
to delegate things to ld
:
If you use ‘INPUT (-lfile)
’, ld will transform the name to libfile.a
, as with the command line argument ‘-l
’.