All of lore.kernel.org
 help / color / mirror / Atom feed
* MIPS, profiling, and not working
@ 2001-08-14 22:09 Daniel Jacobowitz
  2001-08-14 23:53 ` Simon Gee
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2001-08-14 22:09 UTC (permalink / raw)
  To: linux-mips, gcc-bugs; +Cc: Simon Gee

I'm having some interesting problems with getting _mcount() to work on
mips*-*-linux.  Most of them are easily correctable within _mcount itself,
but one deals with how it's called.  The sequence looks like this:

        .set    noreorder
        .set    noat
        move    $1,$31          # save current return address
        jal     _mcount
        subu    $sp,$sp,8               # _mcount pops 2 words from  stack
        .set    reorder
        .set    at

Suppose we have a function with no frame pointer, though - one which would
otherwise be a leaf.  We have a small problem based on the fact that
GCC considers it to be a leaf despite calling _mcount.  If it uses $sp for
its frame register, then when the jal expands:

0x404550 <__libc_start_main+16>:        sw      $gp,16($sp)

...

0x404574 <__libc_start_main+52>:        move    $at,$ra
0x404578 <__libc_start_main+56>:        lw      $t9,-32584($gp)
0x40457c <__libc_start_main+60>:        nop
0x404580 <__libc_start_main+64>:        jalr    $t9
0x404584 <__libc_start_main+68>:        nop
0x404588 <__libc_start_main+72>:        lw      $gp,16($sp)
0x40458c <__libc_start_main+76>:        addiu   $sp,$sp,-8


Note that we saved $gp at 16($sp), then tried to restore it before we fixed
$sp up again.

Does anyone have a good idea?  The best I can think of is to emit the jalr
from GCC directly, so that we can restore the GP after restoring the stack
pointer properly.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-08-16 10:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-08-14 22:09 MIPS, profiling, and not working Daniel Jacobowitz
2001-08-14 23:53 ` Simon Gee
2001-08-14 23:44   ` Daniel Jacobowitz
2001-08-15  0:11     ` Jun Sun
2001-08-16 10:12     ` Maciej W. Rozycki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.