This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Dynamically wrap non dynamic symbol
- From: Christian Gagneraud <chgans at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 21 Sep 2017 12:28:45 +1200
- Subject: Dynamically wrap non dynamic symbol
- Authentication-results: sourceware.org; auth=none
Hi there,
I am trying to wrap function calls, at runtime, in a dynamic way and
without having to modify the original binary.
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.
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.
Is this even possible to install wrapper around local symbols?
If so would you have any information to share?
Thanks,
Chris