[DynInst_API:] Use DynInst to replace a branch with a NOP?


Date: Wed, 06 Jan 2016 13:38:07 +0000
From: Jonas Wagner <jonas.wagner@xxxxxxx>
Subject: [DynInst_API:] Use DynInst to replace a branch with a NOP?

Hello,

Iâd like to dynamically modify a binary and change branches to NOPs and back. I wondered whether DynInst (in particular PatchAPI) would be a suitable tool for this. What do you think?

Hereâs what Iâd like to do in more detail: I have a program that contains branches like the one below.

... some code ...
21d0:   cmpb   $0x0, branch_flag
      â jne    2221
... some more code ...

These branches are usually not taken because the branch_flag is set to zero. Nevertheless, there is some cost for loading the flag and the non-taken branch. I would like to get rid of this cost as much as possible, by replacing that sequence of instructions with NOPs.

In a later stage, Iâd also like to undo some of these replacements, or even change the conditional branch into an unconditional branch.

Would PatchAPI be suitable for these kind of tasks? Do you have any hints for how I could use it, or what would be a better alternative?

Thanks a lot!
Jonas

â
[← Prev in Thread] Current Thread [Next in Thread→]