|
From: Tom H. <to...@co...> - 2009-05-20 08:07:49
|
Konstantin Serebryany wrote:
> Memcheck, Helgrind and other valgrind tools use LD_PRELOAD to replace
> or wrap functions in the users code.
It does use LD_PRELOAD but not in the normal way where the preloaded
library contains functions with the same name as the ones being replaced.
Instead the preloaded library contains functions with special mangled
names which valgrind recognises and adds to it's internal redirection
table so that when it sees the relevant function it can redirect it.
> This makes it impossible to use the tools on statically linked binaries.
> Meanwhile, PIN is capable of replacing/wrapping functions in static
> binaries, so it is at least theoretically possible to do the same in
> Valgrind.
Indeed, and so long as the static binary has a symbol table it would
already work I think except that:
(a) a statically linked binary won't use ld.so so won't process
the LD_PRELOAD at all.
(b) the symbols in our preload libraries are deliberately designed
to only intercept symbols in the 'right' so's - so malloc will
only be intercepted in libc.so and so on.
I think globally intercepting something like malloc (which would be
needed for a statically linked binary) could only ever be done on an
optional basis really but I guess we could support.
I'm not sure how to get round the LD_PRELOAD issue though?
At the end of the day the question may be one of how much work it is
worth doing to support something that is fairly uncommon these days.
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|