如何制作假代理导入库

How to make fake proxy Import library

我记得找到 *.a 库,它不包含任何对象,而是一个列表库(作为纯文本?),例如:-liconv -lm

这样当 gcc 遇到它时,将搜索两个库进行链接。

有这种技巧吗?很确定那时候它能用,但我现在不知道怎么做。

你的链接器是来自 binutils 的吗? binutils ld 支持 .a 文件为 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.

链接描述文件不必很复杂,它可以像这样简单(对于glibc的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 ) )

或者你可以 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’.