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
​
_______________________________________________
Dyninst-api mailing list
Dyninst-api@cs.wisc.edu
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api

Reply via email to