fix: prefix compiled function name to avoid collision w other func

the new wrapper function will make a call to the main compiled function,
and we got some problem in the GOT/PLT due to function of the same name.
So now we prefiex with `concrete_` to avoid that.
This commit is contained in:
youben11
2023-03-09 09:01:40 +01:00
committed by Ayoub Benaissa
parent dc8b762708
commit 1e435de9d6
4 changed files with 12 additions and 1 deletions

View File

@@ -16,6 +16,9 @@
namespace concretelang {
/// prefix function name with `concrete_` to avoid collision with other function
std::string prefixFuncName(llvm::StringRef funcName);
// construct the function name of the wrapper function that unify function calls
// of compiled circuit
std::string makePackedFunctionName(llvm::StringRef name);

View File

@@ -27,7 +27,8 @@ using mlir::concretelang::StreamStringError;
outcome::checked<ServerLambda, StringError>
ServerLambda::loadFromModule(std::shared_ptr<DynamicModule> module,
std::string funcName) {
auto packedFuncName = ::concretelang::makePackedFunctionName(funcName);
auto packedFuncName = ::concretelang::makePackedFunctionName(
::concretelang::prefixFuncName(funcName));
ServerLambda lambda;
lambda.module =
module; // prevent module and library handler from being destroyed

View File

@@ -74,6 +74,9 @@ static void packFunctionArguments(llvm::Module *module) {
continue;
}
// prefix to avoid colliding with other functions
func.setName(::concretelang::prefixFuncName(func.getName()));
// Given a function `foo(<...>)`, define the interface function
// `mlir_foo(i8**)`.
auto *newType = llvm::FunctionType::get(

View File

@@ -7,6 +7,10 @@
namespace concretelang {
std::string prefixFuncName(llvm::StringRef funcName) {
return "concrete_" + funcName.str();
}
std::string makePackedFunctionName(llvm::StringRef name) {
return "_mlir_" + name.str();
}