Skip to content

Commit 67911a5

Browse files
committed
Fix for existing function references in DeclareLiftedFunction
1 parent 9876545 commit 67911a5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/Arch/Arch.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,14 @@ llvm::Function *Arch::DeclareLiftedFunction(std::string_view name_,
730730
auto func_type = llvm::dyn_cast<llvm::FunctionType>(
731731
RecontextualizeType(LiftedFunctionType(), context));
732732
llvm::StringRef name(name_.data(), name_.size());
733-
auto func = llvm::Function::Create(
733+
auto func = module->getFunction(name.str());
734+
735+
if (!func || func->getFunctionType() != func_type) {
736+
func = llvm::Function::Create(
734737
func_type, llvm::GlobalValue::ExternalLinkage, 0u, name, module);
738+
} else if (func->isDeclaration()) {
739+
func->setLinkage(llvm::GlobalValue::ExternalLinkage);
740+
}
735741

736742
auto memory = remill::NthArgument(func, kMemoryPointerArgNum);
737743
auto state = remill::NthArgument(func, kStatePointerArgNum);

0 commit comments

Comments
 (0)