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:
Lscope1:
        .stabs  "i:F(0,1)",36,0,0,i
        .stabs  "b:p(0,1)",160,0,0,-20
.globl i
        .type   i, @function
i:
        .stabn  68,0,10,.LM5-.LFBB2
.LM5:
.LFBB2:
.LFB1:
        .cfi_startproc
        movl    %edi, -20(%rsp)
        .stabn  68,0,12,.LM6-.LFBB2
.LM6:
        movl    -8(%rsp), %eax
        movl    -4(%rsp), %edx
        leal    (%rdx,%rax), %eax
        .stabn  68,0,13,.LM7-.LFBB2
.LM7:
        ret
        .cfi_endproc
.LFE1:
        .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:
scope1:
        .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
i:
        .stabn  68,0,10,$LM5
$LM5:
$LFBB2:
        .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
$LM6:
        lw      $3,16($sp)
        lw      $2,12($sp)
        nop
        addu    $2,$3,$2
        .stabn  68,0,13,$LM7
$LM7:
        addiu   $sp,$sp,24
        j       $31
        nop

        .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?

Regards



_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to