diff --git a/src/lifters/vmexit.cpp b/src/lifters/vmexit.cpp new file mode 100644 index 0000000..2b758b7 --- /dev/null +++ b/src/lifters/vmexit.cpp @@ -0,0 +1,8 @@ +#include + +namespace vm +{ + lifters_t::lifter_callback_t lifters_t::vmexit = + [ & ]( vm::vmp_rtn_t *rtn, const vm::instrs::code_block_t &vm_code_block, + const vm::instrs::virt_instr_t &vinstr, llvm::IRBuilder<> *ir_builder ) { ir_builder->CreateRetVoid(); }; +} \ No newline at end of file diff --git a/src/vmp_rtn.cpp b/src/vmp_rtn.cpp index 0277be6..1e1520e 100644 --- a/src/vmp_rtn.cpp +++ b/src/vmp_rtn.cpp @@ -15,8 +15,12 @@ namespace vm flags = ir_builder->CreateAlloca( ir_builder->getInt64Ty(), nullptr, "flags" ); create_virtual_stack(); - // TODO: copy arg1 (array) onto the local stack... - // ir_builder->CreateMemCpy(... + for ( auto idx = 0u; idx < 21; ++idx ) + { + auto val = ir_builder->CreateLoad( llvm_fptr->getArg( idx ) ); + val->setAlignment( llvm::Align( 1 ) ); + push( 8, val ); + } create_virtual_registers(); } @@ -31,11 +35,11 @@ namespace vm void vmp_rtn_t::create_routine( void ) { - // function has no arguments and returns void... maybe change this in the future as i learn - // more and more LLVM... - auto func_ty = - llvm::FunctionType::get( llvm::Type::getVoidTy( *llvm_ctx ), - { llvm::ArrayType::get( llvm::IntegerType::get( *llvm_ctx, 64 ), 21 ) }, false ); + std::vector< llvm::Type * > arg_types; + for ( auto idx = 0u; idx < 21; ++idx ) + arg_types.push_back( llvm::PointerType::get( llvm::IntegerType::get( *llvm_ctx, 64 ), 0ull ) ); + + auto func_ty = llvm::FunctionType::get( llvm::Type::getVoidTy( *llvm_ctx ), arg_types, false ); // convert the rtn_begin address to a hex string and prepend "rtn_" to it... std::stringstream rtn_name;