jtkohl@MIT.EDU (John T Kohl) (02/22/91)
I recently started using the mprof package to ferret out memory leaks in
a fairly large library/program package for which I'm project leader.
However, on the DS3100 it had some problems dealing with call chains
which went through static functions from a particular library which had
removed the symbols pointing to the static function names (by using
ld -x -r). So I hacked up the code to find the entry points which had
previously been named. Here's the comment I left in the code:
/* jtkohl@mit.edu: this [the missing function address] (apparently)
happens when the symbol name for the referenced function
has been stripped out, such as when it's a static function
and the .o file had ld -x -r run over it.
What we really ought to do is determine where the
procedure really starts.
we attempt to do so, by starting with the previous function's address,
looking for the SECOND addiu sp,sp,{neg_size}.
since the MIPS and GCC compilers only generate one such
instruction per C function, the second one should be
in the prologue of the desired function.
HOWEVER, if we have a static function which is a LEAF (no
locals, no function calls) we will actually miss the
function and find the next one. Luckily, such a function
can never appear on the call graph leading to a malloc, so
if we assign it an address just before the address of the
next function, then we should never mistakenly "find"
it when doing a binary search for a return address.
If we have two or more functions with no args before
the next known function, it gets hairier...
ADDIU sp,sp, {size} is:
0x27bd.... (16-bit offset size)
*/
--
John Kohl <jtkohl@ATHENA.MIT.EDU> or <jtkohl@MIT.EDU>
Digital Equipment Corporation/Project Athena
(The above opinions are MINE. Don't put my words in somebody else's mouth!)