bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/28513] New: avr rjmp offset calculation is off by an instruction


From: karako.tibor at freemail dot hu
Subject: [Bug ld/28513] New: avr rjmp offset calculation is off by an instruction
Date: Thu, 28 Oct 2021 12:32:29 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=28513

            Bug ID: 28513
           Summary: avr rjmp offset calculation is off by an instruction
           Product: binutils
           Version: 2.26
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: karako.tibor at freemail dot hu
  Target Milestone: ---

When compiled in one step the the rjmp offsets are miscalculated. If I compile
then link the result is correct though.

main.c:
int main() {
    asm("out 0x14, r24");
        while (1) {
        asm("out 0x16, r24");
        asm("out 0x18, r24");
    }
}

avr-gcc -O main.c -o faulty.hex -mmcu=attiny2313 -Wl,--oformat,ihex
avr-objdump -j .sec1 -d -m avr faulty.hex
This gives:
  34:   84 bb           out     0x14, r24       ; 20
  36:   86 bb           out     0x16, r24       ; 22
  38:   88 bb           out     0x18, r24       ; 24
  3a:   fe cf           rjmp    .-4             ;  0x38   <-- should be 0x36


avr-gcc -O main.c -o correct.elf -mmcu=attiny2313
avr-ld -o correct.elf.hex --oformat ihex correct.elf
avr-objdump -j .sec1 -d -m avr correct.elf.hex
  34:   84 bb           out     0x14, r24       ; 20
  36:   86 bb           out     0x16, r24       ; 22
  38:   88 bb           out     0x18, r24       ; 24
  3a:   fd cf           rjmp    .-6             ;  0x36

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]