Rename addSymbol to match what it does and remove redundant params.
This commit is contained in:
parent
a804b3d9eb
commit
8115be39be
@ -319,9 +319,12 @@ IncrementalExecutor::installLazyFunctionCreator(LazyFunctionCreatorFunc_t fp)
|
|||||||
m_lazyFuncCreator.push_back(fp);
|
m_lazyFuncCreator.push_back(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IncrementalExecutor::addSymbol(const char* Name, void* Addr,
|
void IncrementalExecutor::replaceSymbol(const char* Name, void* Addr) const {
|
||||||
bool Jit) const {
|
assert(Addr);
|
||||||
m_JIT->addDefinition(Name, llvm::pointerToJITTargetAddress(Addr), Jit);
|
// FIXME: Look at the registration of at_quick_exit and uncomment.
|
||||||
|
// assert(m_JIT->getSymbolAddress(Name, /*IncludeHostSymbols*/true) &&
|
||||||
|
// "The symbol must exist");
|
||||||
|
m_JIT->addOrReplaceDefinition(Name, llvm::pointerToJITTargetAddress(Addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void* IncrementalExecutor::getAddressOfGlobal(llvm::StringRef symbolName,
|
void* IncrementalExecutor::getAddressOfGlobal(llvm::StringRef symbolName,
|
||||||
|
@ -193,7 +193,7 @@ namespace cling {
|
|||||||
///\brief Runs a wrapper function.
|
///\brief Runs a wrapper function.
|
||||||
ExecutionResult executeWrapper(llvm::StringRef function,
|
ExecutionResult executeWrapper(llvm::StringRef function,
|
||||||
Value* returnValue = 0) const;
|
Value* returnValue = 0) const;
|
||||||
///\brief Adds a symbol (function) to the execution engine.
|
///\brief Replaces a symbol (function) to the execution engine.
|
||||||
///
|
///
|
||||||
/// Allows runtime declaration of a function passing its pointer for being
|
/// Allows runtime declaration of a function passing its pointer for being
|
||||||
/// used by JIT generated code.
|
/// used by JIT generated code.
|
||||||
@ -201,10 +201,7 @@ namespace cling {
|
|||||||
/// @param[in] Name - The name of the symbol as required by the
|
/// @param[in] Name - The name of the symbol as required by the
|
||||||
/// linker (mangled if needed)
|
/// linker (mangled if needed)
|
||||||
/// @param[in] Address - The function pointer to register
|
/// @param[in] Address - The function pointer to register
|
||||||
/// @param[in] JIT - Add to the JIT injected symbol table
|
void replaceSymbol(const char* Name, void* Address) const;
|
||||||
/// @returns true if the symbol is successfully registered, false otherwise.
|
|
||||||
///
|
|
||||||
void addSymbol(const char* Name, void* Address, bool JIT = false) const;
|
|
||||||
|
|
||||||
///\brief Tells the execution to run all registered atexit functions once.
|
///\brief Tells the execution to run all registered atexit functions once.
|
||||||
///
|
///
|
||||||
|
@ -131,10 +131,8 @@ llvm::Error IncrementalJIT::removeModule(const Transaction& T) {
|
|||||||
return llvm::Error::success();
|
return llvm::Error::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
JITTargetAddress IncrementalJIT::addDefinition(StringRef LinkerMangledName,
|
JITTargetAddress IncrementalJIT::addOrReplaceDefinition(StringRef LinkerMangledName,
|
||||||
JITTargetAddress KnownAddr,
|
JITTargetAddress KnownAddr) {
|
||||||
bool AcceptExisting) {
|
|
||||||
void* Symbol = getSymbolAddress(LinkerMangledName, /*ExcludeFromHost=*/false);
|
|
||||||
|
|
||||||
// Nothing to define, we are redefining the same function. FIXME: Diagnose.
|
// Nothing to define, we are redefining the same function. FIXME: Diagnose.
|
||||||
if (Symbol && (JITTargetAddress)Symbol == KnownAddr)
|
if (Symbol && (JITTargetAddress)Symbol == KnownAddr)
|
||||||
|
@ -66,11 +66,9 @@ public:
|
|||||||
/// should include symbols from the host process or not.
|
/// should include symbols from the host process or not.
|
||||||
void* getSymbolAddress(llvm::StringRef Name, bool ExcludeHostSymbols);
|
void* getSymbolAddress(llvm::StringRef Name, bool ExcludeHostSymbols);
|
||||||
|
|
||||||
/// Inject a symbol with a known address. Collisions will cause an error
|
/// Inject a symbol with a known address.
|
||||||
/// unless AcceptExisting = true.
|
llvm::JITTargetAddress addOrReplaceDefinition(llvm::StringRef LinkerMangledName,
|
||||||
llvm::JITTargetAddress addDefinition(llvm::StringRef LinkerMangledName,
|
llvm::JITTargetAddress KnownAddr);
|
||||||
llvm::JITTargetAddress KnownAddr,
|
|
||||||
bool AcceptExisting = false);
|
|
||||||
|
|
||||||
llvm::Error runCtors() const {
|
llvm::Error runCtors() const {
|
||||||
return Jit->initialize(Jit->getMainJITDylib());
|
return Jit->initialize(Jit->getMainJITDylib());
|
||||||
|
@ -327,7 +327,7 @@ namespace cling {
|
|||||||
if (!Addr) {
|
if (!Addr) {
|
||||||
cling::errs() << "Replaced symbol " << Sym << " cannot be found in JIT!\n";
|
cling::errs() << "Replaced symbol " << Sym << " cannot be found in JIT!\n";
|
||||||
} else {
|
} else {
|
||||||
m_Executor->addSymbol(Sym.str().c_str(), Addr, true);
|
m_Executor->replaceSymbol(Sym.str().c_str(), Addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -537,10 +537,10 @@ namespace cling {
|
|||||||
|
|
||||||
if (!SyntaxOnly) {
|
if (!SyntaxOnly) {
|
||||||
// Override the native symbols now, before anything can be emitted.
|
// Override the native symbols now, before anything can be emitted.
|
||||||
m_Executor->addSymbol("__cxa_atexit",
|
m_Executor->replaceSymbol("__cxa_atexit",
|
||||||
utils::FunctionToVoidPtr(&local_cxa_atexit), true);
|
utils::FunctionToVoidPtr(&local_cxa_atexit));
|
||||||
// __dso_handle is inserted for the link phase, as macro is useless then
|
// __dso_handle is inserted for the link phase, as macro is useless then
|
||||||
m_Executor->addSymbol("__dso_handle", this, true);
|
m_Executor->replaceSymbol("__dso_handle", this);
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// According to the PE Format spec, in "The .tls Section"
|
// According to the PE Format spec, in "The .tls Section"
|
||||||
@ -551,13 +551,13 @@ namespace cling {
|
|||||||
// array is at the offset of 0x2C from the beginning of TEB. This
|
// array is at the offset of 0x2C from the beginning of TEB. This
|
||||||
// behavior is Intel x86-specific.
|
// behavior is Intel x86-specific.
|
||||||
static const unsigned long _tls_array = 0x2C;
|
static const unsigned long _tls_array = 0x2C;
|
||||||
m_Executor->addSymbol("_tls_array", (void *)&_tls_array, true);
|
m_Executor->replaceSymbol("_tls_array", (void *)&_tls_array);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CLING_WIN_SEH_EXCEPTIONS
|
#ifdef CLING_WIN_SEH_EXCEPTIONS
|
||||||
// Windows C++ SEH handler
|
// Windows C++ SEH handler
|
||||||
m_Executor->addSymbol("_CxxThrowException",
|
m_Executor->replaceSymbol("_CxxThrowException",
|
||||||
utils::FunctionToVoidPtr(&platform::ClingRaiseSEHException), true);
|
utils::FunctionToVoidPtr(&platform::ClingRaiseSEHException));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user