MIPS, profiling, and not working

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux