[fpc-devel] strange behavior of mips stabs

Fuxin Zhang zhangfx at lemote.com
Sun Jun 10 13:55:21 CEST 2012

for a function like this:
   int i(int b)
        int i1,i2,i3;
        return i1 + i2;

in x86, compile with gcc -fno-pic -fomit-frame-pointer -gstabs -O0 -S
the output is:
        .stabs  "i:F(0,1)",36,0,0,i
        .stabs  "b:p(0,1)",160,0,0,-20
.globl i
        .type   i, @function
        .stabn  68,0,10,.LM5-.LFBB2
        movl    %edi, -20(%rsp)
        .stabn  68,0,12,.LM6-.LFBB2
        movl    -8(%rsp), %eax
        movl    -4(%rsp), %edx
        leal    (%rdx,%rax), %eax
        .stabn  68,0,13,.LM7-.LFBB2
        .size   i, .-i
        .stabs  "i1:(0,1)",128,0,0,-4
        .stabs  "i2:(0,1)",128,0,0,-8
        .stabs  "i3:(0,1)",128,0,0,-12
        .stabn  192,0,0,.LFBB2-.LFBB2
        .stabn  224,0,0,.Lscope2-.LFBB2

Everything works as expect:
   the offsets for both parameters and locals are negative, no matter in
stabs directive or in the assembly code. And the offset value in stabs
equals to the one in the code.

But for mips, mipsel-linux-gcc -fno-pic -fomit-frame-pointer -gstabs -O0
-S output is:
        .align  2
        .stabs  "i:F(0,1)",36,0,0,i
        .stabs  "b:p(0,1)",160,0,0,24
        .globl  i
        .ent    i
        .type   i, @function
        .stabn  68,0,10,$LM5
        .set    nomips16
        .frame  $sp,24,$31              # vars= 16, regs= 0/0, args= 0, gp= 8
        .mask   0x00000000,0
        .fmask  0x00000000,0
        .set    noreorder
        .set    nomacro

        addiu   $sp,$sp,-24
        .cprestore      0
        sw      $4,24($sp)
        .stabn  68,0,12,$LM6
        lw      $3,16($sp)
        lw      $2,12($sp)
        addu    $2,$3,$2
        .stabn  68,0,13,$LM7
        addiu   $sp,$sp,24
        j       $31

        .set    macro
        .set    reorder
        .end    i
        .stabs  "i1:(0,1)",128,0,0,-8
        .stabs  "i2:(0,1)",128,0,0,-12

The local variable offsets in stabs are negative, but in the code they are
positive. For my understanding of fpc logic, they should both generated
from loc.reference.offset or something similiar, they cannot be different.
If I am not making mistake, we have to special case some code to make
debugging work.

Am I wrong?


More information about the fpc-devel mailing list