OpenCores

The openrisc bugtracker has been moved to: bugzilla.opencores.org. This page is read-only

GCC 4.2.2 can't handle large case statements with -fPIC

Back to bugtracker overview.

Information:
Type :: BUG
Status :: CLOSED
Assigned to :: Jeremy, Bennett

Description:

OpenRISC GCC 4.2.2 has a problem with large case statements when targeting position independent code. Here is a code fragment that demos the problem

    int
    bug_demo(char  arg)
    {
      /* There is a bug in GCC for OR1K, which can't handle two many cases
         with position independent code (PIC). Get rid of 1 case and it
         all works OK. */
      switch (arg)
        {
        case 'c':
          return 0;
    
        case 'i':
          return 1;
    
        case 'd':
          return 2;
    
        case 'o':
          return 3;
    
        case 'x':
          return 4;
    
        }
    
      return -1;
    
    }	/* bug_demo () */
    

Compile this with:

    or32-elf-gcc -fPIC -c bug-demo.c
    

The resulting output is:

    or32-elf-gcc -fPIC -c bug-demo.c
    /tmp/ccqWzGPc.s: Assembler messages:
    /tmp/ccqWzGPc.s:45: Error: can't resolve `.text' {.text section} - `.L8' {.rodata section}
    /tmp/ccqWzGPc.s:46: Error: can't resolve `.text' {.text section} - `.L8' {.rodata section}
    ...
    /tmp/ccqWzGPc.s:65: Error: can't resolve `.text' {.text section} - `.L8' {.rodata section}
    /tmp/ccqWzGPc.s:66: Error: can't resolve `.text' {.text section} - `.L8' {.rodata section}
    

Analysis of the assembler code shows the compiler attempting to construct a jump-table by subtracting labels in the read only data section from labels in the text section.

Jeremy

p> --
Tel: +44 (1590) 610184
Cell: +44 (7970) 676050
SkypeID: jeremybennett
Email: jeremy.bennett@embecosm.com
Web: www.embecosm.com

Comments:

Bennett, Jeremy Jul 1, 2011

Transferred to OpenRISC bugzilla (Bug 13).

Marking closed in this bugtracker.

Post a comment:
Login to post comments!

Back to bugtracker overview.

© copyright 1999-2012 OpenCores.org, equivalent to ORSoC AB, all rights reserved. OpenCores®, registered trademark.