Skip to content
Snippets Groups Projects
Commit 01353d81 authored by Lang Hames's avatar Lang Hames
Browse files

[llvm-jitlink] Allow -entry option to find hidden symbols.

This is useful when debugging failures in object files compiled with
visibility=hidden.
parent 53fc971a
No related branches found
No related tags found
No related merge requests found
......@@ -1301,7 +1301,7 @@ static Error loadObjects(Session &S) {
{
// Create a "main" JITLinkDylib.
IdxToJLD[0] = S.MainJD;
S.JDSearchOrder.push_back(S.MainJD);
S.JDSearchOrder.push_back({S.MainJD, JITDylibLookupFlags::MatchAllSymbols});
LLVM_DEBUG(dbgs() << " 0: " << S.MainJD->getName() << "\n");
// Add any extra JITLinkDylibs from the command line.
......@@ -1314,15 +1314,18 @@ static Error loadObjects(Session &S) {
unsigned JDIdx =
JITLinkDylibs.getPosition(JLDItr - JITLinkDylibs.begin());
IdxToJLD[JDIdx] = &*JD;
S.JDSearchOrder.push_back(&*JD);
S.JDSearchOrder.push_back({&*JD, JITDylibLookupFlags::MatchAllSymbols});
LLVM_DEBUG(dbgs() << " " << JDIdx << ": " << JD->getName() << "\n");
}
// Set every dylib to link against every other, in command line order.
for (auto *JD : S.JDSearchOrder) {
// Set every dylib to link against every other, in command line order,
// using exported symbols only.
for (auto &KV : S.JDSearchOrder) {
auto *JD = KV.first;
auto LookupFlags = JITDylibLookupFlags::MatchExportedSymbolsOnly;
JITDylibSearchOrder LinkOrder;
for (auto *JD2 : S.JDSearchOrder) {
for (auto &KV2 : S.JDSearchOrder) {
auto *JD2 = KV2.first;
if (JD2 == JD)
continue;
LinkOrder.push_back(std::make_pair(JD2, LookupFlags));
......@@ -1395,8 +1398,8 @@ static Error loadObjects(Session &S) {
LLVM_DEBUG({
dbgs() << "Dylib search order is [ ";
for (auto *JD : S.JDSearchOrder)
dbgs() << JD->getName() << " ";
for (auto &KV : S.JDSearchOrder)
dbgs() << KV.first->getName() << " ";
dbgs() << "]\n";
});
......@@ -1553,7 +1556,7 @@ static void dumpSessionStats(Session &S) {
}
static Expected<JITEvaluatedSymbol> getMainEntryPoint(Session &S) {
return S.ES.lookup(S.JDSearchOrder, EntryPointName);
return S.ES.lookup(S.JDSearchOrder, S.ES.intern(EntryPointName));
}
static Expected<JITEvaluatedSymbol> getOrcRuntimeEntryPoint(Session &S) {
......@@ -1561,7 +1564,7 @@ static Expected<JITEvaluatedSymbol> getOrcRuntimeEntryPoint(Session &S) {
const auto &TT = S.ES.getExecutorProcessControl().getTargetTriple();
if (TT.getObjectFormat() == Triple::MachO)
RuntimeEntryPoint = '_' + RuntimeEntryPoint;
return S.ES.lookup(S.JDSearchOrder, RuntimeEntryPoint);
return S.ES.lookup(S.JDSearchOrder, S.ES.intern(RuntimeEntryPoint));
}
static Expected<int> runWithRuntime(Session &S, ExecutorAddr EntryPointAddr) {
......@@ -1630,11 +1633,20 @@ int main(int argc, char *argv[]) {
// Find the entry-point function unconditionally, since we want to force
// it to be materialized to collect stats.
EntryPoint = ExitOnErr(getMainEntryPoint(*S));
LLVM_DEBUG({
dbgs() << "Using entry point \"" << EntryPointName
<< "\": " << formatv("{0:x16}", EntryPoint.getAddress()) << "\n";
});
// If we're running with the ORC runtime then replace the entry-point
// with the __orc_rt_run_program symbol.
if (!OrcRuntime.empty())
if (!OrcRuntime.empty()) {
EntryPoint = ExitOnErr(getOrcRuntimeEntryPoint(*S));
LLVM_DEBUG({
dbgs() << "(called via __orc_rt_run_program_wrapper at "
<< formatv("{0:x16}", EntryPoint.getAddress()) << ")\n";
});
}
}
if (ShowAddrs)
......
......@@ -50,7 +50,7 @@ struct Session {
orc::ExecutionSession ES;
orc::JITDylib *MainJD = nullptr;
LLVMJITLinkObjectLinkingLayer ObjLayer;
std::vector<orc::JITDylib *> JDSearchOrder;
orc::JITDylibSearchOrder JDSearchOrder;
~Session();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment