This is the mail archive of the gcc-bugs@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]

[Bug target/27192] call through function pointer goes to wrong address



------- Comment #4 from eweddington at cso dot atmel dot com  2007-04-04 00:38 -------
Confirmed bug.

shifty3.i is a test case showing the problem. Compiled with avr-gcc 4.1.2,
with:
avr-gcc -Os shifty.c -o shifty.o

shifty3.dis is a disassembly of shifty.o (with avr-objdump -d shifty.o).

The problem is exhibited here:

0000005a <main>:
  5a:   89 e2           ldi     r24, 0x29       ; 41
  5c:   90 e0           ldi     r25, 0x00       ; 0
  5e:   90 93 61 00     sts     0x0061, r25
  62:   80 93 60 00     sts     0x0060, r24
  66:   82 e5           ldi     r24, 0x52       ; 82
  68:   92 e0           ldi     r25, 0x02       ; 2
  6a:   90 93 64 00     sts     0x0064, r25
  6e:   80 93 63 00     sts     0x0063, r24
  72:   e0 91 60 00     lds     r30, 0x0060
  76:   f0 91 61 00     lds     r31, 0x0061
  7a:   09 95           icall
  7c:   e0 91 63 00     lds     r30, 0x0063
  80:   f0 91 64 00     lds     r31, 0x0064
  84:   09 95           icall

The correct word address of the function foo is taken and stored (address 5a to
62), but then the *byte* address of the function foo is taken, and an offset
added, and stored (address 66 to 6e). The following indirect call (address 7c
to 84) is then incorrect. The PC has to be a *word* address.

Adding a fixed offset to a function pointer, and then doing an indirect call,
is valid in an AVR application as it is possible to copy or place functions at
fixed offsets like this.

Please mark this bug as NEW.
Known to fail: 4.1.1, 4.1.2


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27192


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