Bug 21284 - [4.0/4.1 Regression] AVR target: switch/case jump table is placed in .data instead of .progmem.gcc_sw_table
Summary: [4.0/4.1 Regression] AVR target: switch/case jump table is placed in .data in...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-29 13:14 UTC by Bernard Fouché
Modified: 2005-07-23 22:49 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernard Fouché 2005-04-29 13:14:55 UTC
The following example is a test case showing the problem.

The jump table is placed in .data on gcc-4.0.0 instead of flash memory.

Gcc-4.0.0 was configured that way:

./configure --prefix=/home/avrdev --target=avr --enable-languages=c,c++
--disable-nls

[bernard@linuxbf stk500]$ cat testbug.c
unsigned long TestBug(int p)
{
  unsigned long  x=200;
  unsigned long  y=1;

  switch(p){
  case 0:
    x=1;
    y++;
    break;
  case 1:
    x=2;
    y++;
    break;
  case 2:
    x=3;
    y=2;
    break;
  case 3:
    x=4;
    y=34;
    break;
  case 4:
    x=5;
    y=38;
    break;
  case 5:
    x=6;
    y=9;
    break;
  case 6:
    x=7;
    y=71;
    break;
  case 7:
    x=8;
    y=712;
    break;
  case 8:
    x=9;
    y=-1;
    break;
  case 9:
    x=10;
    y=10;
    break;
  case 10:
    x=11;
    y=12;
    break;
  case 11:
    x=12;
    y=123;
    break;
  case 12:
    x=13;
    y=124;
    break;
  case 13:
    x=14;
    y=122;
    break;
  case 14:
    x=15;
    y=121;
    break;
  case 15:
    x=1;
    y++;
    break;
  case 16:
    x=2;
    y++;
    break;
  case 17:
    x=3;
    y=2;
    break;
  case 18:
    x=4;
    y=34;
    break;
  case 19:
    x=5;
    y=38;
    break;
  case 20:
    x=6;
    y=9;
    break;
  case 21:
    x=7;
    y=71;
    break;
  case 22:
    x=8;
    y=712;
    break;
  case 23:
    x=9;
    y=-1;
    break;
  case 24:
    x=10;
    y=10;
    break;
  case 25:
    x=11;
    y=12;
    break;
  case 26:
    x=12;
    y=123;
    break;
  case 27:
    x=13;
    y=124;
    break;
  case 28:
    x=14;
    y=122;
    break;
  case 29:
    x=15;
    y=121;
    break;
  }

  return x*y;
}
[bernard@linuxbf stk500]$ avr-gcc --version
avr-gcc (GCC) 3.4.3
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[bernard@linuxbf stk500]$ avr-gcc -Os -Wall -c testbug.c
[bernard@linuxbf stk500]$ avr-objdump -s testbug.o

testbug.o:     file format elf32-avr

Contents of section .text:
 0000 cf93df93 c8ecd0e0 e0e0f0e0 21e030e0  ............!.0.
 0010 40e050e0 aa2797fd a095ba2f 8e319105  @.P..'...../.1..
 0020 08f083c0 80509040 8f939f93 0895c1e0  .....P.@........
 0030 d0e0e0e0 f0e009c0 c2e0d0e0 e0e0f0e0  ................
 0040 43c0c3e0 d0e0e0e0 f0e022e0 30e040e0  C.........".0.@.
 0050 50e06bc0 c4e0d0e0 e0e0f0e0 22e230e0  P.k.........".0.
 0060 40e050e0 62c0c5e0 d0e0e0e0 f0e026e2  @.P.b.........&.
 0070 30e040e0 50e059c0 c6e0d0e0 e0e0f0e0  0.@.P.Y.........
 0080 29e030e0 40e050e0 50c0c7e0 d0e0e0e0  ).0.@.P.P.......
 0090 f0e027e4 30e040e0 50e047c0 c8e0d0e0  ..'.0.@.P.G.....
 00a0 e0e0f0e0 28ec32e0 40e050e0 3ec0c9e0  ....(.2.@.P.>...
 00b0 d0e0e0e0 f0e02fef 3fef4fef 5fef35c0  ....../.?.O._.5.
 00c0 cae0d0e0 e0e0f0e0 2c2f3d2f 4e2f5f2f  ........,/=/N/_/
 00d0 2cc0cbe0 d0e0e0e0 f0e02ce0 30e040e0  ,.........,.0.@.
 00e0 50e023c0 cce0d0e0 e0e0f0e0 2be730e0  P.#.........+.0.
 00f0 40e050e0 1ac0cde0 d0e0e0e0 f0e02ce7  @.P...........,.
 0100 30e040e0 50e011c0 cee0d0e0 e0e0f0e0  0.@.P...........
 0110 2ae730e0 40e050e0 08c0cfe0 d0e0e0e0  *.0.@.P.........
 0120 f0e029e7 30e040e0 50e06c2f 7d2f8e2f  ..).0.@.P.l/}/./
 0130 9f2f00d0 b92fa82f 972f862f 682f792f  ./..././././h/y/
 0140 8a2f9b2f df91cf91 0895               ././......      
Contents of section .progmem.gcc_sw_table:
 0000 00c000c0 00c000c0 00c000c0 00c000c0  ................
 0010 00c000c0 00c000c0 00c000c0 00c000c0  ................
 0020 00c000c0 00c000c0 00c000c0 00c000c0  ................
 0030 00c000c0 00c000c0 00c000c0           ............    
[bernard@linuxbf stk500]$ avr-gcc --version
avr-gcc (GCC) 4.0.0
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[bernard@linuxbf stk500]$ avr-gcc -Os -Wall -c testbug.c
[bernard@linuxbf stk500]$ avr-objdump -s testbug.o

testbug.o:     file format elf32-avr

Contents of section .text:
 0000 f92fe82f 4e9760f4 e050f040 09946fe0  ././N.`..P.@..o.
 0010 70e080e0 90e029e7 30e040e0 50e07ec0  p.....).0.@.P.~.
 0020 68ec70e0 80e090e0 21e030e0 40e050e0  h.p.....!.0.@.P.
 0030 75c061e0 70e080e0 90e004c0 62e070e0  u.a.p.......b.p.
 0040 80e090e0 22e030e0 40e050e0 67c063e0  ....".0.@.P.g.c.
 0050 70e080e0 90e0f6cf 64e070e0 80e090e0  p.......d.p.....
 0060 22e230e0 40e050e0 59c065e0 70e080e0  ".0.@.P.Y.e.p...
 0070 90e026e2 30e040e0 50e050c0 66e070e0  ..&.0.@.P.P.f.p.
 0080 80e090e0 29e030e0 40e050e0 47c067e0  ....).0.@.P.G.g.
 0090 70e080e0 90e027e4 30e040e0 50e03ec0  p.....'.0.@.P.>.
 00a0 68e070e0 80e090e0 28ec32e0 40e050e0  h.p.....(.2.@.P.
 00b0 35c069e0 70e080e0 90e02fef 3fef4fef  5.i.p...../.?.O.
 00c0 5fef2cc0 6ae070e0 80e090e0 2ae030e0  _.,.j.p.....*.0.
 00d0 40e050e0 23c06be0 70e080e0 90e02ce0  @.P.#.k.p.....,.
 00e0 30e040e0 50e01ac0 6ce070e0 80e090e0  0.@.P...l.p.....
 00f0 2be730e0 40e050e0 11c06de0 70e080e0  +.0.@.P...m.p...
 0100 90e02ce7 30e040e0 50e008c0 6ee070e0  ..,.0.@.P...n.p.
 0110 80e090e0 2ae730e0 40e050e0 00d00895  ....*.0.@.P.....
Contents of section .data:
 0000 00c000c0 00c000c0 00c000c0 00c000c0  ................
 0010 00c000c0 00c000c0 00c000c0 00c000c0  ................
 0020 00c000c0 00c000c0 00c000c0 00c000c0  ................
 0030 00c000c0 00c000c0 00c000c0           ............    
[bernard@linuxbf stk500]$
Comment 1 GCC Commits 2005-05-05 15:36:52 UTC
Subject: Bug 21284

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	denisc@gcc.gnu.org	2005-05-05 15:36:34

Modified files:
	gcc            : ChangeLog 
	gcc/config/avr : avr.c 

Log message:
	PR target/21284
	* config/avr/avr.c (avr_output_addr_vec_elt): Use special section
	for output.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.218&r2=2.7592.2.219
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/avr/avr.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.129.6.2&r2=1.129.6.3

Comment 2 GCC Commits 2005-05-05 15:42:33 UTC
Subject: Bug 21284

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	denisc@gcc.gnu.org	2005-05-05 15:42:05

Modified files:
	gcc            : ChangeLog 
	gcc/config/avr : avr.c 

Log message:
	PR target/21284
	* config/avr/avr.c (avr_output_addr_vec_elt): Use special section
	for output.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8612&r2=2.8613
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/avr/avr.c.diff?cvsroot=gcc&r1=1.134&r2=1.135

Comment 3 Andrew Pinski 2005-05-05 16:25:37 UTC
Fixed.