Yue Chen
2014-Sep-11 19:26 UTC
[LLVMdev] Reserve some empty memory space after each basic block
Hello! I am going to do a research project that inserts instructions (e.g., JMP) after each code basic block at runtime of a program (when the program is already loaded into memory). I believe first I should allocate (reserve) more memory space (could be filled with "NOP" instructions) after each basic block during compilation in order to put the extra instructions thereafter. Could anyone tell me how to implement it in LLVM for 32-bit x86 platform? E.g., which functions or data structures or materials of LLVM I should look at or refer to. I really appreciate your kind help. Best, Yue
John Criswell
2014-Sep-12 00:48 UTC
[LLVMdev] Reserve some empty memory space after each basic block
Dear Yue, The easiest thing to do is to write an LLVM pass that inserts some inline assembly code at the end of each basic block (right before the terminator instruction) that contains NOP instructions. To learn to do that, you should read the "Writing an LLVM Pass" document, the "LLVM Programmer's Manual," and be prepared to look at the doxygen documentation for creating inline assembly statements. Regards, John Criswell On 9/11/14, 3:26 PM, Yue Chen wrote:> Hello! > > I am going to do a research project that inserts instructions (e.g., > JMP) after each code basic block at runtime of a program (when the > program is already loaded into memory). > > I believe first I should allocate (reserve) more memory space (could > be filled with "NOP" instructions) after each basic block during > compilation in order to put the extra instructions thereafter. > > Could anyone tell me how to implement it in LLVM for 32-bit x86 > platform? E.g., which functions or data structures or materials of > LLVM I should look at or refer to. > > I really appreciate your kind help. > > Best, > Yue > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev