ld
and the Altera Nios IICall and immediate jump instructions on Nios II processors are limited to
transferring control to addresses in the same 256MB memory segment,
which may result in ld
giving
‘relocation truncated to fit’ errors with very large programs.
The command-line option --relax enables the generation of
trampolines that can access the entire 32-bit address space for calls
outside the normal call
and jmpi
address range. These
trampolines are inserted at section boundaries, so may not themselves
be reachable if an input section and its associated call trampolines are
larger than 256MB.
The --relax option is enabled by default unless -r
is also specified. You can disable trampoline generation by using the
--no-relax linker option. You can also disable this optimization
locally by using the ‘set .noat’ directive in assembly-language
source files, as the linker-inserted trampolines use the at
register as a temporary.
Note that the linker --relax option is independent of assembler relaxation options, and that using the GNU assembler’s -relax-all option interferes with the linker’s more selective call instruction relaxation.