summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2009-03-04 19:10:38 +0000
committerNate Begeman <natebegeman@mac.com>2009-03-04 19:10:38 +0000
commit920438ef1dea4793817f0658fef037380a166490 (patch)
tree2e1ad7c490d4317f90ebe1d2f009d062b941dbd7 /llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
parent8473a12bfefa382fdba247f7fc603145db7173f9 (diff)
downloadbcm5719-llvm-920438ef1dea4793817f0658fef037380a166490.tar.gz
bcm5719-llvm-920438ef1dea4793817f0658fef037380a166490.zip
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. llvm-svn: 66050
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
index 5c6236dcaeb..22515f3a82c 100644
--- a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -1348,12 +1348,22 @@ void JIT::updateDlsymStubTable() {
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)
OpenPOWER on IntegriCloud