This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: avr-gcc doesn't know address space wraps?


Ralph Doncaster schrieb:
On Sun, Jan 3, 2016 at 1:22 PM, Georg-Johann Lay <avr@gjlay.de> wrote:
Ralph Doncaster schrieb:
avr-gcc 4.9.2 doesn't seem to know that the address space wraps, so
that an rjmp in the last 2KB of the address space can reach code in
the first 2KB.  The following code works fine with a jmp, but if I
change the jmp ResetVector to rjmp, I get:
(.bootloader+0x4): relocation truncated to fit: R_AVR_13_PCREL against
`no symbol'

I'm compiling with:
avr-gcc -mmcu=atmega328p -nostartfiles
-Wl,-section-start=.bootloader=0x7E00   picobootSTK500.S   -o
picobootSTK500

I don't quite get what your question has to do with the compiler proper.
As you are programming in assembly, the only thing that avr-gcc does is
calling the assembler and the linker for you.

I don't quite get your point.  Are you suggesting I should report this
on the binutils list instead of here?

Well, you are using RJMP with an address that's out of scope, hence the linker/locator complains. The compiler would not generate code like

    rjmp ResetVector

The compiler would just emit "JMP <address>", hence you can use the same code sequence which always works.

Or are you having trouble with the compiler driver? This is actually the only part of the compiler that's involved here...

If you prefer RJMP over JMP provided address is in the range of RJMP, you would usually link with --relax or call the driver with -mrelax.

If it's vital for your code to RJMP instead of JMP provided address is not in the range of RJMP but address+0x8000 happens to be, you can make explicit use of wrap around capability of RJMP by RJMP <address>+0x8000.

Third approach is to link with --pmem-wrap-around= so that no explicit offset and no explicit RJMP is needed in the code.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]