[llvm] r193472 - lli/RemoteMemoryManager.cpp: Resurrect __main stuff removed in r192504 to unbreak mingw32.
Kaylor, Andrew
andrew.kaylor at intel.com
Mon Oct 28 10:09:19 PDT 2013
This code is wrong. It returns the address of a local function when code is being generated for a remote target. Please revert this change.
What is the problem you're trying to address here?
-Andy
-----Original Message-----
From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of NAKAMURA Takumi
Sent: Saturday, October 26, 2013 6:53 AM
To: llvm-commits at cs.uiuc.edu
Subject: [llvm] r193472 - lli/RemoteMemoryManager.cpp: Resurrect __main stuff removed in r192504 to unbreak mingw32.
Author: chapuni
Date: Sat Oct 26 08:52:31 2013
New Revision: 193472
URL: http://llvm.org/viewvc/llvm-project?rev=193472&view=rev
Log:
lli/RemoteMemoryManager.cpp: Resurrect __main stuff removed in r192504 to unbreak mingw32.
Modified:
llvm/trunk/tools/lli/RemoteMemoryManager.cpp
llvm/trunk/tools/lli/RemoteMemoryManager.h
Modified: llvm/trunk/tools/lli/RemoteMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/RemoteMemoryManager.cpp?rev=193472&r1=193471&r2=193472&view=diff
==============================================================================
--- llvm/trunk/tools/lli/RemoteMemoryManager.cpp (original)
+++ llvm/trunk/tools/lli/RemoteMemoryManager.cpp Sat Oct 26 08:52:31
+++ 2013
@@ -204,3 +204,19 @@ uint8_t *RemoteMemoryManager::allocateGl 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;
+}
Modified: llvm/trunk/tools/lli/RemoteMemoryManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/RemoteMemoryManager.h?rev=193472&r1=193471&r2=193472&view=diff
==============================================================================
--- llvm/trunk/tools/lli/RemoteMemoryManager.h (original)
+++ llvm/trunk/tools/lli/RemoteMemoryManager.h Sat Oct 26 08:52:31 2013
@@ -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);
_______________________________________________
llvm-commits mailing list
llvm-commits at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list