Re: [DynInst_API:] Adding raw bytes before function


Date: Mon, 29 Aug 2016 16:02:41 +0000
From: Bill Williams <bill@xxxxxxxxxxx>
Subject: Re: [DynInst_API:] Adding raw bytes before function
Matthias--

Unless you have very specific location constraints, using BPatch_malloc instead of BPatch_createVariable to create and allocate space for a BPatch_variableExpr should handle all of the bookkeeping for you. If you do have constraints, there are internal mechanisms that will help (we try to allocate relocated code near the original, for instance) but those aren't currently exposed; I'd want to understand your use case better before trying to push a constrained-malloc interface out to the public BPatch classes.

Let me know if you've got further questions.

--bw

________________________________________
From: Dyninst-api <dyninst-api-bounces@xxxxxxxxxxx> on behalf of Matthias Fischer <fischmat@xxxxxxxxx>
Sent: Monday, August 29, 2016 9:30 AM
To: dyninst-api@xxxxxxxxxxx
Subject: [DynInst_API:] Adding raw bytes before function

Hi,

I'd like to write information to a binary (or process) for each function
in way that allows access from an indirect callsite with minimal overhead.

My current idea is to write raw bytes before the actual function code,
so the bytes are stored at [callsite_target - offset, callsite_target[.
Then I can access the information as a BPatch_variableExpr using
BPatch_dynamicTargetExpr to calculate the address. However, I cannot
simply write the bytes at this address without possibly overwriting
existing instructions - the code before the function would have to be
relocated.

So far, I have not found a way to write raw bytes at a specific address
with relocation of possible overwritten instructions. Is that even
possible with dyninstAPI or is there another way to achieve my initial goal?

Thanks,
Matthias


_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
[← Prev in Thread] Current Thread [Next in Thread→]