Issue |
146537
|
Summary |
[AVR] Linking produces wrong startup code for xmega3 devices
|
Labels |
new issue
|
Assignees |
|
Reporter |
tomtor
|
script:
```
L=/home/tom/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/lib/gcc/avr/7.3.0
LXM3=$L/avrxmega3
LTINY=$L/avr25
clang -L$LXM3 -Os -target avr-none -mmcu=attiny402 bad_copy_data.c -o bad.out
clang -L$LTINY -Os -target avr-none -mmcu=attiny84 bad_copy_data.c -o good.out
```
`good.out` for the `attiny84` is OK, but `bad.out` for the `attiny402` has the following code fragment:
```
00000040 <__do_copy_data>:
40: 1f e3 ldi r17, 0x3F ; 63
42: a0 e0 ldi r26, 0x00 ; 0
44: bf e3 ldi r27, 0x3F ; 63
46: e9 ec ldi r30, 0xC9 ; 201
48: f0 e0 ldi r31, 0x00 ; 0
4a: 02 c0 rjmp .+4 ; 0x50 <.Lname11>
4c: 05 90 lpm r0, Z+
4e: 0d 92 st X+, r0
50: a0 30 cpi r26, 0x00 ; 0
52: b1 07 cpc r27, r17
54: d9 f7 brne .-10 ; 0x4c <.Lname10+0x2>
```
This loop from the CRT tries to copy 0 bytes (because RO data is mapped in the RAM space at 0x8000)
and this test:
` 50: a0 30 cpi r26, 0x00 ; 0`
fails because `X` has been already incremented in the previous line, so it will copy 0x10000 bytes overwriting the complete IO region and all RAM.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs