This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

mips assembler question???


We have noticed that the mips  assembler  in mips16 mode is leaving  in
the object files all the temporally variables referenced by stabs in the
resulting .o file
This does not happen in non-mips16 mode.
Is this a bug or a feature?


As part of tracking this issue down we have found out the function in
gas/config/tc-mips.c




/* Handle a .stabn directive.  We need these in order to mark a label
   as being a mips16 text label correctly.  Sometimes the compiler
   will emit a label, followed by a .stabn, and then switch sections.
   If the label and .stabn are in mips16 mode, then the label is
   really a mips16 text label.  */

static void
s_mips_stab (type)
     int type;
{

***** If we comment out the next two lines  the local symbols are no
longer passed to the .o file *****
***** Commenting these two lines generated the proper output, is it safe
to take them out.   *******
  if (type == 'n' && mips_opts.mips16)
    mips16_mark_labels ();

  s_stab (type);
}

***************** C test case ***************************************
void test(void)
{
        int i, j;
        i = 0; j = i;
}


************* COMPILER FLAGS **********************************

compile with -g -mips16 -S



        .file   1 "test.c"
######### By turning  mips16 on we make it fail
#       .set    mips16
gcc2_compiled.:
__gnu_compiled_c:
.stabs "/folk/samuel/tmp/spr67816/lsi4101/",100,0,0,$Ltext0
.stabs "test.c",100,0,0,$Ltext0
        .text
$Ltext0:
.stabs "int:t1=r1;0020000000000;0017777777777;",128,0,0,0
.stabs "char:t2=r2;0;127;",128,0,0,0
.stabs "long int:t3=r1;0020000000000;0017777777777;",128,0,0,0
.stabs "unsigned int:t4=r1;0000000000000;0037777777777;",128,0,0,0
.stabs "long unsigned int:t5=r1;0000000000000;0037777777777;",128,0,0,0
.stabs "long long
int:t6=r1;01000000000000000000000;0777777777777777777777;",128,0,0,0
.stabs "long long unsigned
int:t7=r1;0000000000000;01777777777777777777777;",128,0,0,0
.stabs "short int:t8=r8;-32768;32767;",128,0,0,0
.stabs "short unsigned int:t9=r9;0;65535;",128,0,0,0
.stabs "signed char:t10=r10;-128;127;",128,0,0,0
.stabs "unsigned char:t11=r11;0;255;",128,0,0,0
.stabs "float:t12=r1;4;0;",128,0,0,0
.stabs "double:t13=r1;8;0;",128,0,0,0
.stabs "long double:t14=r1;8;0;",128,0,0,0
.stabs "complex int:t15=s8real:1,0,32;imag:1,32,32;;",128,0,0,0
.stabs "complex float:t16=r16;4;0;",128,0,0,0
.stabs "complex double:t17=r17;8;0;",128,0,0,0
.stabs "complex long double:t18=r18;8;0;",128,0,0,0
.stabs "void:t19=19",128,0,0,0
        .align  2
        .globl  test
$LM1:
        .stabn 68,0,2,$LM1
.stabs "test.c",132,0,0,$Ltext0
        .ent    test
test:
        .frame  $17,16,$31              # vars= 8, regs= 1/0, args= 0,
extra= 0
        .mask   0x00020000,-8
        .fmask  0x00000000,0
        addu    $sp,$sp,-16
        sw      $17,8($sp)
        move    $17,$sp
$LM2:
        .stabn 68,0,3,$LM2
$LBB2:
$LM3:
        .stabn 68,0,4,$LM3
        li      $2,0
        sw      $2,0($17)
        lw      $2,0($17)
        sw      $2,4($17)
$LM4:
        .stabn 68,0,5,$LM4
$LBE2:
$LM5:
        .stabn 68,0,5,$LM5
$L2:
        move    $sp,$17
        lw      $17,8($sp)
        addu    $sp,$sp,16
        j       $31
        .end    test
.stabs "test:F19",36,0,2,test
.stabs "i:1",128,0,3,-16
.stabs "j:1",128,0,3,-12
.stabn 192,0,0,$LBB2
.stabn 224,0,0,$LBE2
$Lscope0:
.stabs "",36,0,0,$Lscope0-test


*************************
WORKING OUTPUT VERSION ****************************


gas/as-new test.s -o test.o
binutils/objdump -d --syms test.o

test.o:     file format elf32-bigmips

SYMBOL TABLE:
0000000000000000 l    d  .text  0000000000000000
0000000000000000 l    d  .data  0000000000000000
0000000000000000 l    d  .bss   0000000000000000
0000000000000000 l    d  .reginfo       0000000000000000
0000000000000000 l    d  .pdr   0000000000000000
0000000000000000 l    d  .stab  0000000000000000
0000000000000000 l    d  .stabstr       0000000000000000
0000000000000000 l    df *ABS*  0000000000000000 test.c
0000000000000000 l     F .text  0000000000000000 gcc2_compiled.
0000000000000000 l     F .text  0000000000000000 __gnu_compiled_c
0000000000000000 g     F .text  0000000000000000 test


Disassembly of section .text:

0000000000000000 <test>:
   0:   27bdfff0        addiu   $sp,$sp,-16
   4:   afb10008        sw      $s1,8($sp)
   8:   03a08821        move    $s1,$sp
   c:   24020000        li      $v0,0
  10:   ae220000        sw      $v0,0($s1)
  14:   8e220000        lw      $v0,0($s1)
  18:   00000000        nop
  1c:   ae220004        sw      $v0,4($s1)
  20:   0220e821        move    $sp,$s1
  24:   8fb10008        lw      $s1,8($sp)
  28:   03e00008        jr      $ra
  2c:   27bd0010        addiu   $sp,$sp,16



*************NOT WORKING  OUTPUT VERSION******************************


test.o:     file format elf32-bigmips

SYMBOL TABLE:
0000000000000000 l    d  .text  0000000000000000
0000000000000000 l    d  .data  0000000000000000
0000000000000000 l    d  .bss   0000000000000000
0000000000000000 l    d  .reginfo       0000000000000000
0000000000000000 l    d  .stab  0000000000000000
0000000000000000 l    d  .stabstr       0000000000000000
0000000000000000 l    df *ABS*  0000000000000000 test.c
0000000000000000 l       .text  0000000000000000 gcc2_compiled.
0000000000000000 l       .text  0000000000000000 __gnu_compiled_c
0000000000000000 g     F .text  0000000000000000 0xf0 test
0000000000000000 l       .text  0000000000000000 0xf0 $LM1
0000000000000006 l       .text  0000000000000000 0xf0 $LM2
0000000000000006 l       .text  0000000000000000 0xf0 $LM3
0000000000000006 l       .text  0000000000000000 0xf0 $LBB2
000000000000000e l       .text  0000000000000000 0xf0 $LM4
000000000000000e l       .text  0000000000000000 0xf0 $LM5
000000000000000e l       .text  0000000000000000 0xf0 $LBE2


Disassembly of section .text:

0000000000000000 <test>:
   0:   63fe            addiu   $sp,-16
   2:   d102            sw      $s1,8($sp)
   4:   673d            move    $s1,$sp

0000000000000006 <$LBB2>:
   6:   6a00            li      $v0,0
   8:   d940            sw      $v0,0($s1)
   a:   9940            lw      $v0,0($s1)
   c:   d941            sw      $v0,4($s1)

000000000000000e <$LBE2>:
   e:   65b9            move    $sp,$s1
  10:   9102            lw      $s1,8($sp)
  12:   6302            addiu   $sp,16
  14:   e820            jr      $ra
  16:   6500            nop
        ...




************************ With the change we inquired above we get.




        .text
       .set    mips16
tst:
        nop
$LBB1:
        nop
$LBE1:
        nop
$LBB2:
        .text   1
        nop
$LBE2:
        nop
.stabn 192,0,0,$LBB2
.stabn 192,0,0,$LBE2



mtest.o:     file format elf32-bigmips

SYMBOL TABLE:
0000000000000000 l    d  .text  0000000000000000
0000000000000000 l    d  .data  0000000000000000
0000000000000000 l    d  .bss   0000000000000000
0000000000000000 l    d  .reginfo       0000000000000000
0000000000000000 l    d  .pdr   0000000000000000
0000000000000000 l    d  .stab  0000000000000000
0000000000000000 l    d  .stabstr       0000000000000000
0000000000000000 l     F .text  0000000000000000 0xf0 tst
0000000000000008 l     F .text  0000000000000000 0xf0 $LBE2


Disassembly of section .text:

0000000000000000 <tst>:
   0:   6500            nop
   2:   6500            nop
   4:   6500            nop
   6:   6500            nop

0000000000000008 <$LBE2>:
   8:   6500            nop
   a:   0000            addiu   $s0,$sp,0
   c:   0000            addiu   $s0,$sp,0
        ...



Even though we have commented the two lines in  s_mips_stab () the
symbol before the stabn still is being preserve as intentioned.



--
Samuel Lopez
Wind River Systems
Phone: 510-749-2693
samuel@wrs.com
--------------------




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]