avr-gcc-list
[Top][All Lists]
Advanced

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

avr-ld rjmp 2-off anomaly


From: Karakó Tibor
Subject: avr-ld rjmp 2-off anomaly
Date: Wed, 27 Oct 2021 00:24:19 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2

Hi,

I ran into a weird situation regarding whether I compile and link the code in one go or in two phases.

main.c:

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

When I run:

avr-gcc -O main.c -o main_one.hex -mmcu=attiny2313 -Wl,--oformat,ihex

I get a different result compared to:

avr-gcc -O main.c -o main_two.elf -mmcu=attiny2313
avr-ld -o main_two.elf.hex --oformat ihex main_two.elf

$ avr-objdump -j .sec1 -d -m avr main_two.elf.hex

 38:   fe cf           rjmp    .-4             ;  0x36

It calculates the jump correctly.

But the former one seems to introduce a 2-off bug when calculating the rjmps' offset:

$ avr-objdump -j .sec1 -d -m avr main_one.hex

  38:   ff cf           rjmp    .-2             ;  0x38

The same goes for every rjmp.

Is this a legit bug, or I am missing something?


gcc-avr(1:5.4.0+Atmel3.6.2-1)

binutils-avr(2.26.20160125+Atmel3.6.2-2)


Br,

Tibor




reply via email to

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