https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103673
Bug ID: 103673
Summary: avr-gcc with -mrelax with .balign is buggy
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: therealdragony at gmx dot de
Target Milestone: ---
Compile the following assembler code with avr-gcc
.rept 300
call test
.endr
ldi ZL,lo8(matrix)
ldi ZH,hi8(matrix)
1:rjmp 1b
test:
ret
.balign 256
matrix:
.byte 1,2,3,4,5
Then look at .lss
250: 06 d0 rcall .+12 ; 0x25e <test>
252: 05 d0 rcall .+10 ; 0x25e <test>
254: 04 d0 rcall .+8 ; 0x25e <test>
256: 03 d0 rcall .+6 ; 0x25e <test>
258: e8 ea ldi r30, 0xA8 ; 168
25a: f2 e0 ldi r31, 0x02 ; 2
25c: ff cf rjmp .-2 ; 0x25c <const_1s_max+0x1dd>
0000025e <test>:
25e: 08 95 ret
...
00000300 <matrix>:
300: 01 02 muls r16, r17
302: 03 04 cpc r0, r3
304: 05 00 .word 0x0005 ; ????
As you can see, the ldi is loading 0x02AB, which is wrong, as the matrix is
(correctly) located at 0x0300.
Compiled via:
#avr-gcc --version
avr-gcc (GCC) 10.2.0
#avr-gcc main.S -o main.elf -Wall -Wextra -std=gnu99 -mmcu=atxmega384c3
-nostartfiles -mrelax -Wl,--no-stubs -Wa,--no-pad-sections
#avr-objdump -DSg main.elf > main.lss
PS: This is my first bug report at all. I'm sorry if it contains formal
mistakes.