This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: profiling on sh


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

It seems to be the _mcount reference that is choking.  Note that our _mcount
function is defined only in our static libc so it will always be linked into
the app rather than referenced through the plt.

cheers,

Kris

Index: sh.h
===================================================================
RCS file: /product/tools/gcc/gcc/config/sh/sh.h,v
retrieving revision 1.2
diff -r1.2 sh.h
1120a1121,1139
> #ifndef SH_MCOUNT_NAME
> #define SH_MCOUNT_NAME "_mcount"
> #endif
>
> #ifdef SH_MCOUNT_NAME
> #define FUNCTION_PROFILER(STREAM,LABELNO)   \
> {        \
>  char temp[20];      \
>  rtx sym;      \
>         \
>  fprintf((STREAM), "\tmov.l\t");    \
>  assemble_name((STREAM), (SH_MCOUNT_NAME));  \
>  fprintf((STREAM), ",r0\n");    \
>  fprintf((STREAM), "\tjsr\t@r0\n");   \
>  ASM_GENERATE_INTERNAL_LABEL(temp, "LP", (LABELNO)); \
>  sym = gen_rtx(SYMBOL_REF, Pmode, temp);   \
>  ASM_OUTPUT_INT((STREAM), sym);    \
> }
> #else
1125d1143
<
1132a1151
> #endif

----- Original Message -----
From: "Alexandre Oliva" <aoliva@redhat.com>
To: "Kris Warkentin" <kewarken@qnx.com>
Cc: <gcc@gcc.gnu.org>
Sent: Thursday, March 14, 2002 11:46 PM
Subject: Re: profiling on sh


> On Mar 14, 2002, "Kris Warkentin" <kewarken@qnx.com> wrote:
>
> > I'm looking at the FUNCTION_PROFILER macro in gcc/config/sh/sh.h and
> > all it seems to be doing is 'trapa #33' and then printing a label.
>
> Presumably, this is for some embedded SH environment.  You failed to
> specify which OS you're using, so it's hard to hazard guesses as to
> how to solve whatever problem you're running into.
>
> --
> Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist                Professional serial bug killer
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]