[llvm-commits] [llvm] r66051 - in /llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT: JIT.cpp JITEmitter.cpp
Bill Wendling
isanbard at gmail.com
Wed Mar 4 11:16:17 PST 2009
Author: void
Date: Wed Mar 4 13:16:17 2009
New Revision: 66051
URL: http://llvm.org/viewvc/llvm-project?rev=66051&view=rev
Log:
--- Merging (from foreign repository) r66050 into '.':
U lib/ExecutionEngine/JIT/JITEmitter.cpp
U lib/ExecutionEngine/JIT/JIT.cpp
Fix a thinko in the JIT where the address of a GV was only recorded in the map
on failure to resolve it.
Do not abort on failure to resolve an external symbol when using dlsym stubs,
since the symbol may not be in the JIT's address space. Just use 0.
Allow dlsym stubs to differentiate between GlobalVars and Functions.
Modified:
llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JIT.cpp
llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JITEmitter.cpp
Modified: llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JIT.cpp?rev=66051&r1=66050&r2=66051&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JIT.cpp Wed Mar 4 13:16:17 2009
@@ -610,12 +610,12 @@
return (void*)&__dso_handle;
#endif
Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(GV->getName().c_str());
- if (Ptr == 0) {
+ if (Ptr == 0 && !areDlsymStubsEnabled()) {
cerr << "Could not resolve external global address: "
<< GV->getName() << "\n";
abort();
- addGlobalMapping(GV, Ptr);
}
+ addGlobalMapping(GV, Ptr);
} else {
// GlobalVariable's which are not "constant" will cause trouble in a server
// situation. It's returned in the same block of memory as code which may
Modified: llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=66051&r1=66050&r2=66051&view=diff
==============================================================================
--- llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/branches/Apple/Dib/lib/ExecutionEngine/JIT/JITEmitter.cpp Wed Mar 4 13:16:17 2009
@@ -1348,12 +1348,22 @@
for (unsigned i = 0; i != GVs.size(); ++i)
MCE->emitInt32(Offsets[i]);
- // Emit the pointers
- for (unsigned i = 0; i != GVs.size(); ++i)
+ // Emit the pointers. Verify that they are at least 2-byte aligned, and set
+ // the low bit to 0 == GV, 1 == Function, so that the client code doing the
+ // relocation can write the relocated pointer at the appropriate place in
+ // the stub.
+ for (unsigned i = 0; i != GVs.size(); ++i) {
+ intptr_t Ptr = (intptr_t)Ptrs[i];
+ assert((Ptr & 1) == 0 && "Stub pointers must be at least 2-byte aligned!");
+
+ if (isa<Function>(GVs[i]))
+ Ptr |= (intptr_t)1;
+
if (sizeof(void *) == 8)
- MCE->emitInt64((intptr_t)Ptrs[i]);
+ MCE->emitInt64(Ptr);
else
- MCE->emitInt32((intptr_t)Ptrs[i]);
+ MCE->emitInt32(Ptr);
+ }
// Emit the strings
for (unsigned i = 0; i != GVs.size(); ++i)
More information about the llvm-commits
mailing list