This is the mail archive of the
mailing list for the binutils project.
Re: Dynamically wrap non dynamic symbol
- From: R0b0t1 <r030t1 at gmail dot com>
- To: Christian Gagneraud <chgans at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 20 Sep 2017 20:54:40 -0500
- Subject: Re: Dynamically wrap non dynamic symbol
- Authentication-results: sourceware.org; auth=none
- References: <CABxGUTgHuVTjnWnMBPcodA5ninrGA+D23tMT+_4ZyS3aH2D7Zg@mail.gmail.com>
On Wed, Sep 20, 2017 at 7:28 PM, Christian Gagneraud <firstname.lastname@example.org> wrote:
> Hi there,
> I am trying to wrap function calls, at runtime, in a dynamic way and
> without having to modify the original binary.
That makes me think of dyncall: http://www.dyncall.org/.
> Basically i have a function "void *install_hook(const char
> *symbol_name, void *replacement)" that replace the function associated
> with the symbol "symbol_name" with the function pointer "replacement",
> and returns the original function pointer.
But this makes me think you want something else, i.e. you want to
intercept calls made to a library. Is this right?
> Using dl_iterate_phdr it is possible to install wrapper around dynamic
> symbols, but i would like to do the same for symbols that are local to
> the executable.
> Objects are compiled with "gcc -fPIC" and executable is generate with "ld -pie".
> I thought that "ld -pie" will make all the local symbols show up in
> the dynamic program section header, but it doesn't.
I think I understand the above but could personally use some
explanation of it if you have the time.
> Is this even possible to install wrapper around local symbols?
> If so would you have any information to share?
The most straightforward way I know of is to generate a fake library
that calls the real one. I'm not sure how to adapt this to private