This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[bfd] Redirecting function calls in object files
- From: "Ames Andreas" <Andreas dot Ames at comergo dot com>
- To: <binutils at sourceware dot org>
- Date: Tue, 11 Apr 2006 15:22:47 +0200
- Subject: [bfd] Redirecting function calls in object files
Hi all,
please note, that I'm almost a complete newbie when it comes to libbfd
and linker techniques in general.
I'm writing a test facility for a bunch of C++ modules. To this end I
want to 'fix' function calls within an object file to point to some
stub functions, i.e. I want to test a given class (given as an object
file) by replacing calls to instances of other classes with calls to
stubs provided by my test facility. I'm currently only interested in
pei- and elf-targets. Requiring that the object contains symbols is
no problem, because I have the sources for the classes under test.
As I understand so far, please correct me, this shouldn't be a problem
for functions in sections, for which bfd_is_und_section is true,
because I can just define them in another compilation unit and the
linker will pick them up. I can't figure out how this could work for
functions defined in the same compilation unit as the class under
test (think templates, for example). So here are the questions:
1) If they aren't inlined, can libbfd help me to replace the call(s)
to the original function defined in the object file under test to a
stub function defined in another object file, provided by my test
facility? If so, how?
2) Can I use libbfd to determine if the interesting functions are
inlined within the object under test (e.g. to issue an error
message and require a recompilation with no inlining)? Is it
certain that all calls to the same function within a single
compilation unit are either inlined or not (this is more of a
compiler question, I guess)?
Any pointers to docs or sample code (if it doesn't mean I have to
understand the whole ld code at once :-) and general explanations are
appreciated.
TIA,
aa
--
Andreas Ames | Programmer | Comergo GmbH |
Voice: +49 69 7505 3213 | ames AT avaya . com