Previous: , Up: Machine Dependent   [Contents][Index]


4.17 ld and Xtensa Processors

The default ld behavior for Xtensa processors is to interpret SECTIONS commands so that lists of explicitly named sections in a specification with a wildcard file will be interleaved when necessary to keep literal pools within the range of PC-relative load offsets. For example, with the command:

SECTIONS
{
  .text : {
    *(.literal .text)
  }
}

ld may interleave some of the .literal and .text sections from different object files to ensure that the literal pools are within the range of PC-relative load offsets. A valid interleaving might place the .literal sections from an initial group of files followed by the .text sections of that group of files. Then, the .literal sections from the rest of the files and the .text sections from the rest of the files would follow.

Relaxation is enabled by default for the Xtensa version of ld and provides two important link-time optimizations. The first optimization is to combine identical literal values to reduce code size. A redundant literal will be removed and all the L32R instructions that use it will be changed to reference an identical literal, as long as the location of the replacement literal is within the offset range of all the L32R instructions. The second optimization is to remove unnecessary overhead from assembler-generated “longcall” sequences of L32R/CALLXn when the target functions are within range of direct CALLn instructions.

For each of these cases where an indirect call sequence can be optimized to a direct call, the linker will change the CALLXn instruction to a CALLn instruction, remove the L32R instruction, and remove the literal referenced by the L32R instruction if it is not used for anything else. Removing the L32R instruction always reduces code size but can potentially hurt performance by changing the alignment of subsequent branch targets. By default, the linker will always preserve alignments, either by switching some instructions between 24-bit encodings and the equivalent density instructions or by inserting a no-op in place of the L32R instruction that was removed. If code size is more important than performance, the --size-opt option can be used to prevent the linker from widening density instructions or inserting no-ops, except in a few cases where no-ops are required for correctness.

The following Xtensa-specific command-line options can be used to control the linker:

--size-opt

When optimizing indirect calls to direct calls, optimize for code size more than performance. With this option, the linker will not insert no-ops or widen density instructions to preserve branch target alignment. There may still be some cases where no-ops are required to preserve the correctness of the code.

--abi-windowed
--abi-call0

Choose ABI for the output object and for the generated PLT code. PLT code inserted by the linker must match ABI of the output object because windowed and call0 ABI use incompatible function call conventions. Default ABI is chosen by the ABI tag in the .xtensa.info section of the first input object. A warning is issued if ABI tags of input objects do not match each other or the chosen output object ABI.


Previous: , Up: Machine Dependent   [Contents][Index]