PowerPC prologue analysis

Aleksandar Ristovski aristovski@qnx.com
Mon Jul 28 20:13:00 GMT 2008


In the code, in rs6000-tdep.c around line 3334, there is a comment stating:

  /* if != -1, fdata.saved_gpr is the smallest number of saved_gpr.
     All gpr's from saved_gpr to gpr31 are saved.  */

I am, however, witnessing a function that appears to be saving r30, but not r31 (see the disassembly below). This, in turn, causes gdb to unwind r31 from a 'saved' area even though the area does not exist.

I am not very familiar with PowerPC ABI, but from what I gather reading the "function call" section, but can not see where is it stated that if r30 is saved, then r31 must be saved too? But again, I haven't studied the ABI very thoroughly and might be missing that line. 

Just for the reference, here is the disassembly of the function:

(gdb) disassemble foo
Dump of assembler code for function foo
0xfe346aa0 <foo+0>:    stwu    r1,-16(r1)
0xfe346aa4 <foo+4>:    mflr    r0
0xfe346aa8 <foo+8>:    bl      0xfe37ca18
0xfe346aac <foo+12>:   mr      r4,r3
0xfe346ab0 <foo+16>:   stw     r30,8(r1)
0xfe346ab4 <foo+20>:   mflr    r30
0xfe346ab8 <foo+24>:   li      r5,0
0xfe346abc <foo+28>:   li      r6,0
0xfe346ac0 <foo+32>:   stw     r0,20(r1)
0xfe346ac4 <foo+36>:   lwz     r3,-176(r30)
0xfe346ac8 <foo+40>:   bl      0xfe37d738
0xfe346acc <foo+44>:   lwz     r0,20(r1)
0xfe346ad0 <foo+48>:   lwz     r30,8(r1)
0xfe346ad4 <foo+52>:   addi    r1,r1,16
0xfe346ad8 <foo+56>:   mtlr    r0
0xfe346adc <foo+60>:   blr
End of assembler dump.


Aleksandar Ristovski
QNX Software Systems

More information about the Gdb mailing list