简体   繁体   中英

How to make fake proxy Import library

I remember finding *.a library that doesn't contain any object but instead a list libraries (as a plain text?), something like: -liconv -lm

So that when gcc encounter it, both library will be searched for linking.

Is there such trick? pretty sure it was working that time, but I don't know how to make it now.

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 '.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM