Re: [DynInst_API:] Binary Rewriting using wrapFunction


Date: Mon, 15 Dec 2014 23:55:17 +0100
From: Sergej Proskurin <prosig@xxxxxxx>
Subject: Re: [DynInst_API:] Binary Rewriting using wrapFunction
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thank you very much for the fast reply.

> On 12/15/2014 09:02 AM, Bill Williams wrote:

> There are at least two approaches here, depending on your precise
> goals:

The idea is to insert shared library wrapper functions into the
original executable. The wrappers shall intecept calls to shared
libraries (which can be dynamically or statically linked).
Simultaneously the wrappers should be able to call the original shared
library functions.

In theory, the ELF symbols need to be modified in such a way that all
calls to shared libraries are redirected to functions, instrumented
into the original binary. I was hoping to achieve this behavior with
help of the framework provided by Dyninst without having to rewrite
the ELF file manually.

> 1) Open the binary, including all of its shared libraries, and
> rewrite the shared libraries in which you want to wrap functions.

I would really like to prevent direct modifications of shared
libraries and redundand storage of their copies.

> 2) For calls to functions outside the main executable, wrap the
> call site with pre-call and post-call instrumentation.

If I understood you correctly, you suggest to patch every call to the
associated function and hence wrap the actual function calls instead
of intercepting them on a more abstract level. I belive this might
work, thanks :)

Do you think that the best approach would be to utilize the PatchAPI
and try to insert the Function calls on a basic block level? I have
been looking for a similar functionality on the BPatch level. Although
there is the possibility to define points, where to insert calls to
functions, but these are defined by either "eBPatch_procedureLocation"
 or "BPatch_opCode". Unfortunately both do not include the possibility
to chose when it comes to inserting code in front of function calls.

Best regards,
Sergej
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBAgAGBQJUj2bVAAoJEPmT7OuIYciQ3+gIAI/puozTFz9ra4UtKQ6IlwWW
aofH4rlou4VdhnW7Ov+Vk/ovXQgRmAmHHkpu4rg1Z7TOfM9VTDYV3RVvoyOCEJVU
q4asfWCWYDCbaGLs0U7AoqO7qf4K6Yl0/rRsBc0NouiXAN9cguEacU7I/qOFEL86
cq+cw3bsk4wnRzOuqzzhXi3oW+PHqLgBfkkntmkgPhOex+mT2HHFlcIm/SpXuwSc
kuHOMTjJnV1v6otc8B6Xe9yShC2uTNuFdeURMhB8aqinmSBAs6ubB7cfnGv5Q2rb
ev9PXRYUoVnz+TqXY+afI1LrWip8JEd2smN6/4RBAjGoGavb/pPIUALymXHnB7o=
=IH6X
-----END PGP SIGNATURE-----
[← Prev in Thread] Current Thread [Next in Thread→]