On Fri, 28 Jul 2006 11:32:23 -0700, David Daney <firstname.lastname@example.org> wrote:
> >> This was always the tricky part for me. How do you know if the
> >> function is a leaf?
> > I think that if you cannot find a store instruction which saves RA to
> > the stack -- either because it's a real leaf and there is no such store,
> > or because the PC hasn't yet reached the store instruction -- then in
> > both cases it can be treated as a leaf.
> Presumably you are walking the code back from the PC until you find the
> prolog. How would you tell if you had gone past the beginning of a leaf
> function? If you find a j $31 you might assume that it was the end of
> the previous function.
I think you are misunderstanding here.
What the get_frame_info() doing is just searching "sw $ra, ofs($sp)"
and "addiu sp,sp,-imm" instructions from beginning of the function.
We can obtain the start address and size of the function by
kallsyms_lookup(). This is why those stuff depend on CONFIG_KALLSYMS.
> I may be missing something here, if you know of a failure-proof manner
> to detect leaf functions I would appreciate hearing what it is.
I have no good idea to do it without CONFIG_KALL_SYMS.
I suppose there is no silver bullet here...