summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-jitlink
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2019-11-25 21:57:27 -0800
committerLang Hames <lhames@gmail.com>2019-11-28 13:30:49 -0800
commit674df13b5fa7ffbd273455d547eff4507a2fcaff (patch)
tree29acc579845dd57f9340506d94f45985787ab694 /llvm/tools/llvm-jitlink
parentf4d32ae75bf515f443a2c99dce5c882f460c82bd (diff)
downloadbcm5719-llvm-674df13b5fa7ffbd273455d547eff4507a2fcaff.tar.gz
bcm5719-llvm-674df13b5fa7ffbd273455d547eff4507a2fcaff.zip
[ORC][JITLink] Add support for weak references, and improve handling of static
libraries. This patch substantially updates ORCv2's lookup API in order to support weak references, and to better support static archives. Key changes: -- Each symbol being looked for is now associated with a SymbolLookupFlags value. If the associated value is SymbolLookupFlags::RequiredSymbol then the symbol must be defined in one of the JITDylibs being searched (or be able to be generated in one of these JITDylibs via an attached definition generator) or the lookup will fail with an error. If the associated value is SymbolLookupFlags::WeaklyReferencedSymbol then the symbol is permitted to be undefined, in which case it will simply not appear in the resulting SymbolMap if the rest of the lookup succeeds. Since lookup now requires these flags for each symbol, the lookup method now takes an instance of a new SymbolLookupSet type rather than a SymbolNameSet. SymbolLookupSet is a vector-backed set of (name, flags) pairs. Clients are responsible for ensuring that the set property (i.e. unique elements) holds, though this is usually simple and SymbolLookupSet provides convenience methods to support this. -- Lookups now have an associated LookupKind value, which is either LookupKind::Static or LookupKind::DLSym. Definition generators can inspect the lookup kind when determining whether or not to generate new definitions. The StaticLibraryDefinitionGenerator is updated to only pull in new objects from the archive if the lookup kind is Static. This allows lookup to be re-used to emulate dlsym for JIT'd symbols without pulling in new objects from archives (which would not happen in a normal dlsym call). -- JITLink is updated to allow externals to be assigned weak linkage, and weak externals now use the SymbolLookupFlags::WeaklyReferencedSymbol value for lookups. Unresolved weak references will be assigned the default value of zero. Since this patch was modifying the lookup API anyway, it alo replaces all of the "MatchNonExported" boolean arguments with a "JITDylibLookupFlags" enum for readability. If a JITDylib's associated value is JITDylibLookupFlags::MatchExportedSymbolsOnly then the lookup will only match against exported (non-hidden) symbols in that JITDylib. If a JITDylib's associated value is JITDylibLookupFlags::MatchAllSymbols then the lookup will match against any symbol defined in the JITDylib.
Diffstat (limited to 'llvm/tools/llvm-jitlink')
-rw-r--r--llvm/tools/llvm-jitlink/llvm-jitlink.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 251e79cf56d..003a333d956 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -57,6 +57,10 @@ static cl::list<std::string>
cl::ZeroOrMore);
static cl::opt<std::string>
+ CheckName("check-name", cl::desc("Name of checks to match against"),
+ cl::init("jitlink-check"));
+
+static cl::opt<std::string>
EntryPointName("entry", cl::desc("Symbol to call as main entry point"),
cl::init(""));
@@ -604,11 +608,12 @@ Error loadObjects(Session &S) {
// Set every dylib to link against every other, in command line order.
for (auto *JD : S.JDSearchOrder) {
- JITDylibSearchList O;
+ auto LookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly;
+ JITDylibSearchOrder O;
for (auto *JD2 : S.JDSearchOrder) {
if (JD2 == JD)
continue;
- O.push_back(std::make_pair(JD2, false));
+ O.push_back(std::make_pair(JD2, LookupFlags));
}
JD->setSearchOrder(std::move(O));
}
@@ -741,10 +746,11 @@ Error runChecks(Session &S) {
S.TT.isLittleEndian() ? support::little : support::big,
Disassembler.get(), InstPrinter.get(), dbgs());
+ std::string CheckLineStart = "# " + CheckName + ":";
for (auto &CheckFile : CheckFiles) {
auto CheckerFileBuf =
ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(CheckFile)));
- if (!Checker.checkAllRulesInBuffer("# jitlink-check:", &*CheckerFileBuf))
+ if (!Checker.checkAllRulesInBuffer(CheckLineStart, &*CheckerFileBuf))
ExitOnErr(make_error<StringError>(
"Some checks in " + CheckFile + " failed", inconvertibleErrorCode()));
}
OpenPOWER on IntegriCloud