Daniel Liew
2014-Jan-23 00:19 UTC
[LLVMdev] Question about linking modules with weak symbols
Hi, I have the need to re-implement linking archives containg bitcode modules built by the current llvm-ar tool. In built support for this was removed in LLVM3.3 so I decided to take a look at how it was implemented for inspiration. Of particular interest is Linker::LinkInArchives() and GetAllUndefined Symbols in lib/Linker/LinkArchive.cpp [1]. Although this code has long been dead and some of the APIs that these functions used are gone the principles of the algorithm are still relevant which is what I'm interested in. There doesn't seem to be any mention of weak symbols in Linker::LinkArchives() and I don't understand why. For example if you had a Module that had a function foo() defined but it was defined as a weak symbol then when linking with an archive is done, I expect the algorithm would want to look for modules in that archive that also define foo but aren't weak (i.e. strong symbols) to link in to build the composite module. Is this case covered by the algorithm and I've missed something? [1] https://github.com/llvm-mirror/llvm/blob/release_32/lib/Linker/LinkArchives.cpp Thanks, Dan Liew.