This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Dynamically wrap non dynamic symbol

Hello Chris,

On Wed, Sep 20, 2017 at 7:28 PM, Christian Gagneraud <> 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:

> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]