diff options
author | Misha Brukman <brukman+llvm@gmail.com> | 2003-07-28 19:09:06 +0000 |
---|---|---|
committer | Misha Brukman <brukman+llvm@gmail.com> | 2003-07-28 19:09:06 +0000 |
commit | d69c1e6dc28bed3c156f78fee5253748e3d509e2 (patch) | |
tree | 89622d528271f684d2f9e7995c47011104eb79d9 /lib/ExecutionEngine | |
parent | d94a50f99d5201052e7f88d1f5ef0880d827ab40 (diff) | |
download | llvm-d69c1e6dc28bed3c156f78fee5253748e3d509e2.tar.gz llvm-d69c1e6dc28bed3c156f78fee5253748e3d509e2.tar.bz2 llvm-d69c1e6dc28bed3c156f78fee5253748e3d509e2.tar.xz |
Add ability for external C code to get pointers to functions given their name.
This us used by bugpoint -- when code is compiled to a shared object to be
JITted, it must use the JIT's lazy resolution method to find function addresses,
because some functions will not be available at .so load time, as they are in
the bytecode file.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 506da118c5..e6dc706d55 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -11,14 +11,13 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Target/TargetData.h" -#include "llvm/Function.h" +#include "llvm/Module.h" #include "Support/Statistic.h" #include <stdio.h> -static VM *TheVM = 0; - namespace { Statistic<> NumBytes("jello", "Number of bytes of machine code compiled"); + VM *TheVM = 0; class Emitter : public MachineCodeEmitter { // CurBlock - The start of the current block of memory. CurByte - The @@ -186,3 +185,16 @@ uint64_t Emitter::forceCompilationOf(Function *F) { return (intptr_t)TheVM->getPointerToFunction(F); } +// getPointerToNamedFunction - This function is used as a global wrapper to +// VM::getPointerToNamedFunction for the purpose of resolving symbols when +// bugpoint is debugging the JIT. In that scenario, we are loading an .so and +// need to resolve function(s) that are being mis-codegenerated, so we need to +// resolve their addresses at runtime, and this is the way to do it. +extern "C" { + void *getPointerToNamedFunction(const char *Name) { + Module &M = TheVM->getModule(); + if (Function *F = M.getNamedFunction(Name)) + return TheVM->getPointerToFunction(F); + return TheVM->getPointerToNamedFunction(Name); + } +} |