Like constants, globals on some platforms are GOT relative. This means they have to be allocated
near the GOT, which new doesn't do. So break out the allocate into a new function.
Also move GOT index handling into JITResolver. This lets it update the mapping when a Lazy
function is JITed. It doesn't managed the table, just the mapping. Note that this is
still non-ideal, as any function that takes a function address should also take a GOT
index, but that is a lot of changes. The relocation resolve process updates any GOT entry
it sees is out of date.
llvm-svn: 22537
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp
index 3907511..1e879a9 100644
--- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp
@@ -294,7 +294,8 @@
// actually initialize the global after current function has finished
// compilation.
uint64_t S = getTargetData().getTypeSize(GV->getType()->getElementType());
- Ptr = new char[(size_t)S];
+ unsigned char A = getTargetData().getTypeAlignment(GV->getType()->getElementType());
+ Ptr = MCE->allocateGlobal(S, A);
state.getPendingGlobals(locked).push_back(GV);
}
addGlobalMapping(GV, Ptr);