It should be possible to resolve undefined symbols in dynamic libraries
using symbols defined in a linker script.
Details
- Reviewers
ruiu • rafael grimar • espindola - Commits
- rG3345c9ac189b: [ELF] Create and export symbols provided by a linker script if they referenced…
rL326176: [ELF] Create and export symbols provided by a linker script if they referenced…
rLLD326176: [ELF] Create and export symbols provided by a linker script if they referenced…
Diff Detail
- Repository
- rLLD LLVM Linker
Event Timeline
ELF/InputFiles.h | ||
---|---|---|
347 | It seems like instead of adding global variable you can make helper that |
ELF/InputFiles.h | ||
---|---|---|
347 | We call shouldDefineSym not only in declareSymbols but also in addSymbol, which might be called several times. As a result, the set itself would be created several times. Moreover, SharedFiles requires a template argument, so all involved methods would become templates too. I thought about keeping PROVIDE symbols which are not created during declareSymbols call. SymbolTable::scanShlibUndefined would then ask LinkerScript to create referenced symbols. However, it looks like blurring of responsibility to me. |
ELF/InputFiles.h | ||
---|---|---|
347 | Probably getUndefinedSymbols can be moved to InputFile with corresponding member. I do not think building of such set is very expensive and so it should be ok to do that twice. It is also seems that after landing D43008 it should be possible to remove call from 'addSymbol`. if (!Cmd->Sym) return; instead of if (!shouldDefineSym(Cmd)) return; I did not try it though. But at least such approach avoids introducing one more global variable |
- Move Undefs and getUndefinedSymbols() into InputFile
- Change type of Undefs to DenseSet<StringRef> so that it can be used to search for the symbol without creating another filter container.
This LGTM, thanks (minor nit below).
Please wait for approval from other reviewers.
ELF/LinkerScript.cpp | ||
---|---|---|
134 | You should be able to use count I believe: for (InputFile *F : SharedFiles) if (F->getUndefinedSymbols().count(Cmd->Name)) return true; |
It seems like instead of adding global variable you can make helper that
would scan over SharedFiles and invoke SharedFile::getUndefinedSymbols
to build the same set and then pass it to shouldDefineSym ?