Reputation: 41
I got the following error during compilation
(.sram.text+0x1283): dangerous relocation: windowed longcall crosses 1GB boundary; return may fail: (UND+0xdeadcafe)
in one of the functions.
The architecture is Xtensa and the toolchain used is a GNU toolchain built for Xtensa. This error is inside the function elf_xtensa_do_reloc() in the file elf32-xtensa.c in binutils source code.
Please let me know the cause of this error and any possible solution.
Upvotes: 3
Views: 2142
Reputation: 307
After struggling with the same error when developing for ESP32 on PlatformIO, the solution I found was to change the optimatazion flags from -Os
to -O3
.
[env:esp32dev]
build_unflags = -Os
build_flags = -O3
Upvotes: 0
Reputation: 1963
This is a known caveat of the default Xtensa windowed-register ABI. Quoting the Xtensa ISA reference manual:
The window increment stored with the return address register in
a4
occupies the two most significant bits of the register, and therefore those bits must be filled in by the subroutine return. TheRETW
andRETW.N
instructions fill in these bits from the two most significant bits of their own address. This prevents register-window calls from being used to call a routine in a different 1GB region of the address space.
You have two options to fix this:
Upvotes: 2