| <html lang="en"> |
| <head> |
| <title>Xtensa - Untitled</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Untitled"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Machine-Dependent.html#Machine-Dependent" title="Machine Dependent"> |
| <link rel="prev" href="WIN32.html#WIN32" title="WIN32"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| This file documents the GNU linker LD |
| (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10)) |
| version 2.33.1. |
| |
| Copyright (C) 1991-2019 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 |
| or any later version published by the Free Software Foundation; |
| with no Invariant Sections, with no Front-Cover Texts, and with no |
| Back-Cover Texts. A copy of the license is included in the |
| section entitled ``GNU Free Documentation License''.--> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Xtensa"></a> |
| <p> |
| Previous: <a rel="previous" accesskey="p" href="WIN32.html#WIN32">WIN32</a>, |
| Up: <a rel="up" accesskey="u" href="Machine-Dependent.html#Machine-Dependent">Machine Dependent</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">4.17 <code>ld</code> and Xtensa Processors</h3> |
| |
| <p><a name="index-Xtensa-processors-783"></a>The default <samp><span class="command">ld</span></samp> behavior for Xtensa processors is to interpret |
| <code>SECTIONS</code> 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: |
| |
| <pre class="smallexample"> SECTIONS |
| { |
| .text : { |
| *(.literal .text) |
| } |
| } |
| </pre> |
| <p class="noindent"><samp><span class="command">ld</span></samp> may interleave some of the <code>.literal</code> |
| and <code>.text</code> 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 <code>.literal</code> sections from an initial |
| group of files followed by the <code>.text</code> sections of that group of |
| files. Then, the <code>.literal</code> sections from the rest of the files |
| and the <code>.text</code> sections from the rest of the files would follow. |
| |
| <p><a name="index-g_t_0040option_007b_002d_002drelax_007d-on-Xtensa-784"></a><a name="index-relaxing-on-Xtensa-785"></a>Relaxation is enabled by default for the Xtensa version of <samp><span class="command">ld</span></samp> 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 <code>L32R</code> 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 <code>L32R</code> instructions. The second optimization is to remove |
| unnecessary overhead from assembler-generated “longcall” sequences of |
| <code>L32R</code>/<code>CALLX</code><var>n</var> when the target functions are within |
| range of direct <code>CALL</code><var>n</var> instructions. |
| |
| <p>For each of these cases where an indirect call sequence can be optimized |
| to a direct call, the linker will change the <code>CALLX</code><var>n</var> |
| instruction to a <code>CALL</code><var>n</var> instruction, remove the <code>L32R</code> |
| instruction, and remove the literal referenced by the <code>L32R</code> |
| instruction if it is not used for anything else. Removing the |
| <code>L32R</code> 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 <code>L32R</code> |
| instruction that was removed. If code size is more important than |
| performance, the <samp><span class="option">--size-opt</span></samp> 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. |
| |
| <p>The following Xtensa-specific command-line options can be used to |
| control the linker: |
| |
| <p><a name="index-Xtensa-options-786"></a> |
| <dl> |
| <dt><samp><span class="option">--size-opt</span></samp><dd>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. |
| </dl> |
| |
| </body></html> |
| |