This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: profiling on sh
kewarken@qnx.com wrote:
>
> Here's what I've been trying to do Alexandre. I'm modeling this after the
> way arm does it - most of the platforms seem to do something similar: call
> _mcount and then set a label afterwards - the code in mcount seems to figure
> out where it was called from and then gprof looks at the labels later to
> print the call graph and timing information. I hope you forgive my
> ignorance...I've only been looking at sh for a couple of days now. The
> problem with this is that it generates code that the assembler chokes on,
> giving 'pcrel too far' errors. I'm looking for the proper way to call
> _mcount() in this situation.
>
> My output is:
>
> mov.l _mcount,r0
> jsr @r0
> .long .LP0
The 'mov.l _mcount, r0' instruction doesn't do what you want: it
tries to load the longword at address _mcount. You want something like:
mov.l lab,r0
jsr @r0
nop
.align 4
.long .LP0
lab:
.long _mcount
You'll need extra work in _mcount to calculate the correct return
address, taking in the alignment and literals embedded in the code.
Also note that jsr has a delay slot - hence the nop after it.
The thumb ISA is closer to sh than arm, so maybe that could provide some
clues?
Steve.
--
Stephen Clarke, Principal Engineer, SuperH Inc.
Phone:1-408-922-4062, Fax:1-408-954-8507, mailto:Stephen.Clarke@st.com
Mail: SuperH Inc., 3801 Zanker Rd., San Jose, CA 95134, USA.