[llvm] 3559831 - [lli] Add a filter to avoid importing the process's main symbol.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 2 16:08:51 PST 2020
Author: Lang Hames
Date: 2020-01-02T16:05:23-08:00
New Revision: 355983103f008b094b5cdd26233eb0ed7113e7ec
URL: https://github.com/llvm/llvm-project/commit/355983103f008b094b5cdd26233eb0ed7113e7ec
DIFF: https://github.com/llvm/llvm-project/commit/355983103f008b094b5cdd26233eb0ed7113e7ec.diff
LOG: [lli] Add a filter to avoid importing the process's main symbol.
If JIT'd code fails to define a main function and we import the process's
definition then we will end up recursively calling lli's main until we overflow
the stack and crash. This filter fixes the issue by ensuring that the process's
main function is never imported. This results in lli producing a much friendlier
"symbol not found" error when JIT'd code fails to define main.
Added:
Modified:
llvm/tools/lli/lli.cpp
Removed:
################################################################################
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 9aaeef085929..87a8c9f6932f 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -792,11 +792,15 @@ int runOrcLazyJIT(const char *ProgName) {
});
return TSM;
});
+
+ orc::MangleAndInterner Mangle(J->getExecutionSession(), J->getDataLayout());
J->getMainJITDylib().addGenerator(
ExitOnErr(orc::DynamicLibrarySearchGenerator::GetForCurrentProcess(
- J->getDataLayout().getGlobalPrefix())));
+ J->getDataLayout().getGlobalPrefix(),
+ [MainName = Mangle("main")](const orc::SymbolStringPtr &Name) {
+ return Name != MainName;
+ })));
- orc::MangleAndInterner Mangle(J->getExecutionSession(), J->getDataLayout());
orc::LocalCXXRuntimeOverrides CXXRuntimeOverrides;
ExitOnErr(CXXRuntimeOverrides.enable(J->getMainJITDylib(), Mangle));
More information about the llvm-commits
mailing list