Skip to content
Snippets Groups Projects
Commit 608b96b5 authored by Andrea Gussoni's avatar Andrea Gussoni
Browse files

Fix `ReturnPC` type

Solved a bug that always allocated an `i32` for representing the return
address PC in the `function_call` helper (third parameter).

Now we allocate an `i64` or an `i32` depending on the input architecture
of the translated binary.
parent bb665926
No related branches found
No related tags found
No related merge requests found
...@@ -29,12 +29,12 @@ bool FunctionCallIdentification::runOnFunction(llvm::Function &F) { ...@@ -29,12 +29,12 @@ bool FunctionCallIdentification::runOnFunction(llvm::Function &F) {
Module *M = F.getParent(); Module *M = F.getParent();
LLVMContext &C = M->getContext(); LLVMContext &C = M->getContext();
PointerType *Int8PtrTy = Type::getInt8PtrTy(C); PointerType *Int8PtrTy = Type::getInt8PtrTy(C);
auto *Int32Ty = IntegerType::get(C, 32); auto *PCTy = IntegerType::get(C, GCBI.pcRegSize() * 8);
auto *PCPtrTy = cast<PointerType>(GCBI.pcReg()->getType()); auto *PCPtrTy = cast<PointerType>(GCBI.pcReg()->getType());
std::initializer_list<Type *> FunctionArgsTy = { std::initializer_list<Type *> FunctionArgsTy = {
Int8PtrTy, Int8PtrTy,
Int8PtrTy, Int8PtrTy,
Int32Ty, PCTy,
PCPtrTy PCPtrTy
}; };
using FT = FunctionType; using FT = FunctionType;
...@@ -212,7 +212,7 @@ bool FunctionCallIdentification::runOnFunction(llvm::Function &F) { ...@@ -212,7 +212,7 @@ bool FunctionCallIdentification::runOnFunction(llvm::Function &F) {
const std::initializer_list<Value *> Args { const std::initializer_list<Value *> Args {
Callee, Callee,
BlockAddress::get(ReturnBB), BlockAddress::get(ReturnBB),
ConstantInt::get(Int32Ty, ReturnPC), ConstantInt::get(PCTy, ReturnPC),
LinkRegister LinkRegister
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment