[LLVMdev] About instrumenting/rewriting X86 instructions
criswell at illinois.edu
Thu Dec 27 08:11:18 PST 2012
On 12/25/12 3:11 AM, guitarfeng wrote:
> Hi all,
> I plan to use LLVM to instrument/rewrite X86 instructions during the
> compilation of a program.
> For example, insert checking target instructions before jmp
> instructions, or rewrite a instruction to prevent code using a specific
Sorry that no one has responded to your inquiry. It's probably due to
the fact that it's the holiday season in the U.S. and elsewhere, so
hardly anyone's around.
Just out of curiousity, what are you trying to implement? It may be
better to implement your transform at the LLVM IR level than at the
> I think the work should be done at the CodeGen phase, but I'm not quite
> clear how can I start.
> Can anyone give me some suggestion?
I'm doing something similar (I'm extending a control-flow integrity
(CFI) implementation from LeHigh). The first thing I think you should
do is to learn how to write and run a MachineFunctionPass (an LLVM pass
that operates on the machine code IR). You can find directions on that
at http://llvm.org/docs/WritingAnLLVMPass.html and
Finally, you'll want to read the doxygen docs on MachineInstr,
MachineBasicBlock, and MachineFunction.
-- John T.
> Thanks very much,
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev