mips-linux-elf -membedded-pic doesn't emit case statements

Jeff Long JwL@GiS.NeT
Sun Nov 19 18:25:00 GMT 2000


version: 2.95.2, latest snapshot, everything since 2.7.?
target: mips-linux-elf cross compiler
host: various Linux, Solaris

problem: Case statements are not emitted, though the jump table is.
         Labels are assumed to be symbols, link fails.

hint: Probably in gcse pass, case code is there in .cse dump, but
      not .gcse dump.  That's as far as I could follow it.

Example:

main.c:
-------
int
f( int i ) {

  int r;

  switch( i ) {

  case 1: r = 13; break;
  case 2: r = 17; break;
  case 3: r = 19; break;
  case 4: r = 23; break;
  case 5: r = 29; break;
  default: r = 0; break;

  }

  return( r );
}


mips-linux-elf-gcc -O2 main.c -membedded-pic -nostdlib
/usr/local/mips/mips-linux-elf/bin/ld: warning: cannot find entry symbol
_start; defaulting to 0000000000400000
/tmp/ccGnSmsE.o: In function `f':
main.c(.text+0x34): undefined reference to `$L4'
main.c(.text+0x38): undefined reference to `$L5'
main.c(.text+0x3c): undefined reference to `$L6'
main.c(.text+0x40): undefined reference to `$L7'
main.c(.text+0x44): undefined reference to `$L8'
collect2: ld returned 1 exit status


Generated assembly code:
------------------------
        .file   1 "main.c"
gcc2_compiled.:
__gnu_compiled_c:
        .text
        .align  2
        .globl  f
        .text
        .ent    f
f:
        .frame  $sp,8,$31               # vars= 0, regs= 1/0, args= 0,
extra= 0
        .mask   0x80000000,-8
        .fmask  0x00000000,0
        subu    $sp,$sp,8
        addu    $4,$4,-1
        sltu    $2,$4,5
        .set    noreorder
        .set    nomacro
        beq     $2,$0,$L3
        sw      $31,0($sp)
        .set    macro
        .set    reorder

        .set    noreorder
        bal     $LS10
        sll     $4,2
$LS10:
        addu    $4,$4,$31
        .set    reorder
        lw      $4,$L10-$LS10($4)
        addu    $4,$4,$31
        j       $4
        .rdata
        .align  3
        .text
$L10:
        .word   $L4-$LS10
        .word   $L5-$LS10
        .word   $L6-$LS10
        .word   $L7-$LS10
        .word   $L8-$LS10
$L3:
        lw      $31,0($sp)
        move    $2,$0
        .set    noreorder
        .set    nomacro
        j       $31
        addu    $sp,$sp,8
        .set    macro
        .set    reorder

        .end    f


More information about the Gcc-bugs mailing list