Re: [DynInst_API:] modify register contents in dyninst


Date: Wed, 10 Jan 2018 16:59:42 +0000
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] modify register contents in dyninst
Rohit--

There are two ways to do this with higher-level APIs so that you don't need to touch the save/restore code. If what you actually want is to assign to a local variable, a BPatch_variableExpr is the most portable and generic way to go about this. If you want to work with registers directly, there are BPatch_registerExpr snippets that correspond to original register values. Generally I advise working with variable-based snippets, as that allows us to handle the actual locations transparently.

If you want to look at the save/restore code for reference, though, that can be found in baseTramp.C and registerSpace.C for the most part.

--bw
________________________________________
From: Dyninst-api <dyninst-api-bounces@xxxxxxxxxxx> on behalf of Rohit Poduri <poduri.rohit@xxxxxxxxx>
Sent: Saturday, December 30, 2017 6:48 PM
To: dyninst-api@xxxxxxxxxxx
Subject: [DynInst_API:] modify register contents in dyninst

Hi everyone,
I am using dyninst to do some static instrumentation by patching instructions and inserting function call instrumentation snippets on x86_64 . The task I am currently trying to do requires manipulation of a register. The sequence of my task is as follows-

1) Search for the appropriate point in the binary
2) Make a function call which returns some value
3) Put this value into a particular register (like rax)

I am currently implementing it using some wrapper function which calls the fucntion in step 2 and then has an assembly statement to put that value into the register. However I am not getting the value as I am expecting, as the next instruction after my point can see the value I moved into rax. I suspect this may be due to the save/restore register process of dyninst.

Is there any way I can get my task done. I am searching for 2 methods-

1) A high level API in dyninst which can do this task
2) Alter the save restore code so that it dosen't modify the contents of the register I am altering in step 3

If method 2 is feasible, I would like to know which section of the source code saves and restores the registers.

Any help would be appreciated.

Thanks,
Rohit

[← Prev in Thread] Current Thread [Next in Thread→]
  • Re: [DynInst_API:] modify register contents in dyninst, Bill Williams <=