ld: Xtensa

1 
1 4.18 'ld' and Xtensa Processors
1 ===============================
1 
1 The default 'ld' behavior for Xtensa processors is to interpret
1 'SECTIONS' commands so that lists of explicitly named sections in a
1 specification with a wildcard file will be interleaved when necessary to
1 keep literal pools within the range of PC-relative load offsets.  For
1 example, with the command:
1 
1      SECTIONS
1      {
1        .text : {
1          *(.literal .text)
1        }
1      }
1 
1 'ld' may interleave some of the '.literal' and '.text' sections from
1 different object files to ensure that the literal pools are within the
1 range of PC-relative load offsets.  A valid interleaving might place the
1 '.literal' sections from an initial group of files followed by the
1 '.text' sections of that group of files.  Then, the '.literal' sections
1 from the rest of the files and the '.text' sections from the rest of the
1 files would follow.
1 
1    Relaxation is enabled by default for the Xtensa version of 'ld' and
1 provides two important link-time optimizations.  The first optimization
1 is to combine identical literal values to reduce code size.  A redundant
1 literal will be removed and all the 'L32R' instructions that use it will
1 be changed to reference an identical literal, as long as the location of
1 the replacement literal is within the offset range of all the 'L32R'
1 instructions.  The second optimization is to remove unnecessary overhead
1 from assembler-generated "longcall" sequences of 'L32R'/'CALLXN' when
1 the target functions are within range of direct 'CALLN' instructions.
1 
1    For each of these cases where an indirect call sequence can be
1 optimized to a direct call, the linker will change the 'CALLXN'
1 instruction to a 'CALLN' instruction, remove the 'L32R' instruction, and
1 remove the literal referenced by the 'L32R' instruction if it is not
1 used for anything else.  Removing the 'L32R' instruction always reduces
1 code size but can potentially hurt performance by changing the alignment
1 of subsequent branch targets.  By default, the linker will always
1 preserve alignments, either by switching some instructions between
1 24-bit encodings and the equivalent density instructions or by inserting
1 a no-op in place of the 'L32R' instruction that was removed.  If code
1 size is more important than performance, the '--size-opt' option can be
1 used to prevent the linker from widening density instructions or
1 inserting no-ops, except in a few cases where no-ops are required for
1 correctness.
1 
1    The following Xtensa-specific command-line options can be used to
1 control the linker:
1 
1 '--size-opt'
1      When optimizing indirect calls to direct calls, optimize for code
1      size more than performance.  With this option, the linker will not
1      insert no-ops or widen density instructions to preserve branch
1      target alignment.  There may still be some cases where no-ops are
1      required to preserve the correctness of the code.
1