summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2013-10-26 13:52:31 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2013-10-26 13:52:31 +0000
commit2d60c0945102e6887fcdc752a7b714546afae354 (patch)
treea0d01c1e6ff130d014750100c75e99fc7477fd98 /tools
parent0435c5dbec925f6c33a5920b63b2bcb0873efe75 (diff)
downloadexternal_llvm-2d60c0945102e6887fcdc752a7b714546afae354.zip
external_llvm-2d60c0945102e6887fcdc752a7b714546afae354.tar.gz
external_llvm-2d60c0945102e6887fcdc752a7b714546afae354.tar.bz2
lli/RemoteMemoryManager.cpp: Resurrect __main stuff removed in r192504 to unbreak mingw32.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/lli/RemoteMemoryManager.cpp16
-rw-r--r--tools/lli/RemoteMemoryManager.h2
2 files changed, 17 insertions, 1 deletions
diff --git a/tools/lli/RemoteMemoryManager.cpp b/tools/lli/RemoteMemoryManager.cpp
index 04fc40e..f730f09 100644
--- a/tools/lli/RemoteMemoryManager.cpp
+++ b/tools/lli/RemoteMemoryManager.cpp
@@ -204,3 +204,19 @@ uint8_t *RemoteMemoryManager::allocateGlobal(uintptr_t Size, unsigned Alignment)
void RemoteMemoryManager::deallocateFunctionBody(void *Body) {
llvm_unreachable("Unexpected!");
}
+
+static int jit_noop() {
+ return 0;
+}
+
+uint64_t RemoteMemoryManager::getSymbolAddress(const std::string &Name) {
+ // 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 (uintptr_t)&jit_noop;
+
+ return 0;
+}
diff --git a/tools/lli/RemoteMemoryManager.h b/tools/lli/RemoteMemoryManager.h
index 5d0456f..3368b30 100644
--- a/tools/lli/RemoteMemoryManager.h
+++ b/tools/lli/RemoteMemoryManager.h
@@ -78,7 +78,7 @@ public:
// interface does support this, but clients must provide their own
// mechanism for finding remote symbol addresses. MCJIT will resolve
// symbols from Modules it contains.
- uint64_t getSymbolAddress(const std::string &Name) { return 0; }
+ uint64_t getSymbolAddress(const std::string &Name);
void notifyObjectLoaded(ExecutionEngine *EE, const ObjectImage *Obj);