diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2012-10-05 14:10:23 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2012-10-05 14:10:23 +0000 |
commit | 55587cffec6f0fc1b5577a0e23baf08ea9d91340 (patch) | |
tree | 7a764bac36b0b3438e0de4c17bf788db4e545543 /tools | |
parent | 1e10bd68f4f2e0514bc2979d760d41c827705e1e (diff) | |
download | external_llvm-55587cffec6f0fc1b5577a0e23baf08ea9d91340.zip external_llvm-55587cffec6f0fc1b5577a0e23baf08ea9d91340.tar.gz external_llvm-55587cffec6f0fc1b5577a0e23baf08ea9d91340.tar.bz2 |
lli: [MCJIT] Suppress "__main" for cygming in LLIMCJITMemoryManager::getPointerToNamedFunction(), like legacy JITMemoryManager's.
CRT's __main (aka premain) invokes global ctors on cygming. See also PR3897.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165312 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lli/lli.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index c5645ec..57a31f2 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -338,6 +338,10 @@ void LLIMCJITMemoryManager::invalidateInstructionCache() { AllocatedCodeMem[i].size()); } +static int jit_noop() { + return 0; +} + void *LLIMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure) { #if defined(__linux__) @@ -360,6 +364,14 @@ void *LLIMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name, if (Name == "mknod") return (void*)(intptr_t)&mknod; #endif // __linux__ + // We should not invoke parent's ctors/dtors from generated main()! + // On Mingw and Cygwin, the symbol __main is resolved to + // callee's(eg. tools/lli) one, to invoke wrong duplicated ctors + // (and register wrong callee's dtors with atexit(3)). + // We expect ExecutionEngine::runStaticConstructorsDestructors() + // is called before ExecutionEngine::runFunctionAsMain() is called. + if (Name == "__main") return (void*)(intptr_t)&jit_noop; + const char *NameStr = Name.c_str(); void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr); if (Ptr) return Ptr; |