I have a binary file that I\'ve disassembled using avr-objcopy. The interrupt vector table looks like:
00000000 : ; VECTOR TABLE 0: 13 c0 rjmp
I found the answer!
I was assembling but not linking. So the assembler was filling in all relative jumps/calls/branches with .+0.
To fix this I needed to create a custom linker script I called linker.x which contains the following:
SECTIONS { . = 0x0; .text : { *(.text) } }
This tells the linker to start the .text section at address 0.
Then I could link the code using:
$ avr-ld -mavr4 -Tlinker.x a.out -o output.o
After linking using the above command all of the .+0's were filled in with their correct values!
The reason for this, is because until the linking stage, as/gcc don't know what else is going to be included in the binary file. It is the linker that takes all the individual object files and combines them into one. So if the linker stage is never run, there is no way to fill in the relative jumps with absolute jumps.
AVR's assembler does the both assembling and linking. But the gnu assembler is more generic and so you need to link separately.
I'm assuming that rjmp PC+2
doesnt work in avr-as ? That's how I'd do it in AVR Studio...