This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Gcc bug when using -mips16 -O1 options?




Hi,

I have problems when using gcc-2.95.3 compiling C codes to mips16 instructions.
Without optimization, gcc works fine. But the compiled .o file is strange when
optimization (-O1, -O2, -O3) is incorporated.
Gcc is configured as "mips-elf", running in Cygwin 1.1.8.

The test C code is as follows:

int _start(int mode)
{
  int i;
  i=5000;
  switch (mode)
    {
    case 0:
      i = mode + 24;
      break;
    case 1:
      i = mode - 6;
      break;
    case 2:
      i = mode * 47;
      break;
    case 3:
      i = mode /2;
      break;
    case 4:
      i = 4 % 3;
      break;
    case 5:
      i = mode & 0x134;
      break;
    }
  return 1;
}

Command line: mips-elf-gcc -c -mips16 -O1 convert.c
When I link convert.o with other files, linker reports

convert.o: In function `_start':
convert.c(.text+0x14): undefined reference to `$L4'
convert.c(.text+0x16): undefined reference to `$L5'
convert.c(.text+0x18): undefined reference to `$L6'
convert.c(.text+0x1a): undefined reference to `$L7'
convert.c(.text+0x1c): undefined reference to `$L8'
convert.c(.text+0x1e): undefined reference to `$L9'

The six undefined references relate to the six cases in the C code.
Then I found the generated assembly file
(mips-elf-gcc -S -mips16 -O1 convert.c) has no definitions of $L4 through $L9.
But those labels exist if I turn off optimization option.
I guess that's why linker reports error.

Now, is that a bug of Gcc or should I pay attention to something else?
Any help is appreciated, thank you.

The test case is archived in (See attached file: gcc_test.zip):
convert.c : C code
convert.i : preprocessor output
convert-mips16-O0.s : generated assembly file of -mips16 -O0
convert-mips16-O1.s : generated assembly file of -mips16 -O1

Ting-Cheng
Acer Labs., Inc.

Attachment: gcc_test.zip
Description: .ZIP File


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