[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/20545] New: [avr] Incorrect offsets computed for PC relative jum
From: |
saaadhu at gcc dot gnu.org |
Subject: |
[Bug ld/20545] New: [avr] Incorrect offsets computed for PC relative jumps with linker relaxation and alignment directives |
Date: |
Thu, 01 Sep 2016 05:40:26 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=20545
Bug ID: 20545
Summary: [avr] Incorrect offsets computed for PC relative jumps
with linker relaxation and alignment directives
Product: binutils
Version: 2.27
Status: NEW
Severity: normal
Priority: P2
Component: ld
Assignee: unassigned at sourceware dot org
Reporter: saaadhu at gcc dot gnu.org
Target Milestone: ---
There are a couple of cases where linker relaxation causes incorrect
computation of addends for relocs, resulting in wrong code or reloc overflow
errors.
$ cat repro.s
call foo
nop
.p2align 1
nop
.L618:
ldi r24,lo8(6)
brsh .L618
foo: nop
$ avr-as -mavr5 repro.s -o test.o && avr-ld -mavr5 --relax test.o &&
avr-objdump -S a.out
a.out: file format elf32-avr
Disassembly of section .text:
00000000 <__ctors_end>:
0: 03 d0 rcall .+6 ; 0x8 <__ctors_end+0x8>
2: 00 00 nop
4: 00 00 nop
6: 86 e0 ldi r24, 0x06 ; 6
8: e8 f7 brcc .-6 ; 0x4 <__ctors_end+0x4>
0000000a <foo>:
...
Note that the brsh in the source code jumps to the ldi instruction, whereas the
disassembly of the linker output shows that it jumps to the instruction before
it (nop).
$ cat repro2.s
foo:
jmp foo
call foo
.L1:
brsh .L1
.p2align 1
nop
$ ~/avr/install/bin/avr-as -mavr5 repro2.s -o test.o &&
~/avr/install/bin/avr-ld -mavr5 --relax test.o && ~/avr/install/bin/avr-objdump
-S a.out
a.out: file format elf32-avr
Disassembly of section .text:
00000000 <__ctors_end>:
0: ff cf rjmp .-2 ; 0x0 <__ctors_end>
2: fe df rcall .-4 ; 0x0 <__ctors_end>
4: e8 f7 brcc .-6 ; 0x0 <__ctors_end>
...
Again, the brsh in source code jumps to .L1 (i.e. itself), whereas in the
disassembled output, it jumps to the first instruction (jmp relaxed to rjmp).
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/20545] New: [avr] Incorrect offsets computed for PC relative jumps with linker relaxation and alignment directives,
saaadhu at gcc dot gnu.org <=
- [Bug ld/20545] [avr] Incorrect offsets computed for PC relative jumps with linker relaxation and alignment directives, saaadhu at gcc dot gnu.org, 2016/09/01
- [Bug ld/20545] [avr] Incorrect offsets computed for PC relative jumps with linker relaxation and alignment directives, urjaman at gmail dot com, 2016/09/01
- [Bug ld/20545] [avr] Incorrect offsets computed for PC relative jumps with linker relaxation and alignment directives, cvs-commit at gcc dot gnu.org, 2016/09/06
- [Bug ld/20545] [avr] Incorrect offsets computed for PC relative jumps with linker relaxation and alignment directives, cvs-commit at gcc dot gnu.org, 2016/09/06
- [Bug ld/20545] [avr] Incorrect offsets computed for PC relative jumps with linker relaxation and alignment directives, saaadhu at gcc dot gnu.org, 2016/09/06