OpenCores
Issue List
GCC 4.2.2 can't handle large case statements with -fPIC #86
Closed jeremybennett opened this issue over 9 years ago— assigned to: jeremybennettBug
jeremybennett commented over 9 years ago
<p> 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 </p> <ul><pre> 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 () /

</pre></ul> <p> Compile this with: </p> <ul><pre> or32-elf-gcc -fPIC -c bug-demo.c </pre></ul> <p> The resulting output is: <ul><pre> 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} </pre></ul> <p> 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. </p> <p> Jeremy </p> p> -- <br /> Tel: +44 (1590) 610184<br /> Cell: +44 (7970) 676050<br /> SkypeID: jeremybennett<br /> Email: <a href="mailto:jeremy.bennett@embecosm.com">jeremy.bennett@embecosm.com</a><br /> Web: <a href="http://www.embecosm.com">www.embecosm.com</a> </p>
jeremybennett commented about 8 years ago
<p> Transferred to OpenRISC bugzilla (<a href="http://bugzilla.opencores.org/show_bug.cgi?id=13">Bug 13</a>). </p> <p> Marking closed in this bugtracker. </p>
jeremybennett was assigned about 8 years ago
jeremybennett closed this about 8 years ago