Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM insert opcode before instruction

I want to insert specific opcode before BasicBlock terminator, in my case before ReturnInst.

It is possible?

Example:

TerminatorInst* terminator = BasicBlock->getTerminator();
if (isa<ReturnInst>(terminator))  
{
//Insert opcode here.    
}
like image 301
Denis Avatar asked Dec 19 '25 20:12

Denis


1 Answers

Problem solved by using llvm::InlineAsm

llvm::InlineAsm *AsmCode = llvm::InlineAsm::get(Asm, nopInstruction, "", true, false, llvm::InlineAsm::AD_Intel);

where Asm - llvm::FunctionType, nopInstruction - llvm::StringRef(char*)

like image 91
Denis Avatar answered Dec 24 '25 09:12

Denis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!