1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- This file documents the GNU linker LD
4(GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))
5version 2.36.1.
6
7Copyright (C) 1991-2021 Free Software Foundation, Inc.
8
9Permission is granted to copy, distribute and/or modify this document
10under the terms of the GNU Free Documentation License, Version 1.3
11or any later version published by the Free Software Foundation;
12with no Invariant Sections, with no Front-Cover Texts, and with no
13Back-Cover Texts.  A copy of the license is included in the
14section entitled "GNU Free Documentation License". -->
15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
16<head>
17<title>LD: Xtensa</title>
18
19<meta name="description" content="LD: Xtensa">
20<meta name="keywords" content="LD: Xtensa">
21<meta name="resource-type" content="document">
22<meta name="distribution" content="global">
23<meta name="Generator" content="makeinfo">
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25<link href="index.html#Top" rel="start" title="Top">
26<link href="LD-Index.html#LD-Index" rel="index" title="LD Index">
27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28<link href="Machine-Dependent.html#Machine-Dependent" rel="up" title="Machine Dependent">
29<link href="BFD.html#BFD" rel="next" title="BFD">
30<link href="WIN32.html#WIN32" rel="previous" title="WIN32">
31<style type="text/css">
32<!--
33a.summary-letter {text-decoration: none}
34blockquote.smallquotation {font-size: smaller}
35div.display {margin-left: 3.2em}
36div.example {margin-left: 3.2em}
37div.indentedblock {margin-left: 3.2em}
38div.lisp {margin-left: 3.2em}
39div.smalldisplay {margin-left: 3.2em}
40div.smallexample {margin-left: 3.2em}
41div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
42div.smalllisp {margin-left: 3.2em}
43kbd {font-style:oblique}
44pre.display {font-family: inherit}
45pre.format {font-family: inherit}
46pre.menu-comment {font-family: serif}
47pre.menu-preformatted {font-family: serif}
48pre.smalldisplay {font-family: inherit; font-size: smaller}
49pre.smallexample {font-size: smaller}
50pre.smallformat {font-family: inherit; font-size: smaller}
51pre.smalllisp {font-size: smaller}
52span.nocodebreak {white-space:nowrap}
53span.nolinebreak {white-space:nowrap}
54span.roman {font-family:serif; font-weight:normal}
55span.sansserif {font-family:sans-serif; font-weight:normal}
56ul.no-bullet {list-style: none}
57-->
58</style>
59
60
61</head>
62
63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
64<a name="Xtensa"></a>
65<div class="header">
66<p>
67Previous: <a href="WIN32.html#WIN32" accesskey="p" rel="previous">WIN32</a>, Up: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="u" rel="up">Machine Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
68</div>
69<hr>
70<a name="ld-and-Xtensa-Processors"></a>
71<h3 class="section">5.17 <code>ld</code> and Xtensa Processors</h3>
72
73<a name="index-Xtensa-processors"></a>
74<p>The default <code>ld</code> behavior for Xtensa processors is to interpret
75<code>SECTIONS</code> commands so that lists of explicitly named sections in a
76specification with a wildcard file will be interleaved when necessary to
77keep literal pools within the range of PC-relative load offsets.  For
78example, with the command:
79</p>
80<div class="smallexample">
81<pre class="smallexample">SECTIONS
82{
83  .text : {
84    *(.literal .text)
85  }
86}
87</pre></div>
88
89<p><code>ld</code> may interleave some of the <code>.literal</code>
90and <code>.text</code> sections from different object files to ensure that the
91literal pools are within the range of PC-relative load offsets.  A valid
92interleaving might place the <code>.literal</code> sections from an initial
93group of files followed by the <code>.text</code> sections of that group of
94files.  Then, the <code>.literal</code> sections from the rest of the files
95and the <code>.text</code> sections from the rest of the files would follow.
96</p>
97<a name="index-_002d_002drelax-on-Xtensa"></a>
98<a name="index-relaxing-on-Xtensa"></a>
99<p>Relaxation is enabled by default for the Xtensa version of <code>ld</code> and
100provides two important link-time optimizations.  The first optimization
101is to combine identical literal values to reduce code size.  A redundant
102literal will be removed and all the <code>L32R</code> instructions that use it
103will be changed to reference an identical literal, as long as the
104location of the replacement literal is within the offset range of all
105the <code>L32R</code> instructions.  The second optimization is to remove
106unnecessary overhead from assembler-generated &ldquo;longcall&rdquo; sequences of
107<code>L32R</code>/<code>CALLX<var>n</var></code> when the target functions are within
108range of direct <code>CALL<var>n</var></code> instructions.
109</p>
110<p>For each of these cases where an indirect call sequence can be optimized
111to a direct call, the linker will change the <code>CALLX<var>n</var></code>
112instruction to a <code>CALL<var>n</var></code> instruction, remove the <code>L32R</code>
113instruction, and remove the literal referenced by the <code>L32R</code>
114instruction if it is not used for anything else.  Removing the
115<code>L32R</code> instruction always reduces code size but can potentially
116hurt performance by changing the alignment of subsequent branch targets.
117By default, the linker will always preserve alignments, either by
118switching some instructions between 24-bit encodings and the equivalent
119density instructions or by inserting a no-op in place of the <code>L32R</code>
120instruction that was removed.  If code size is more important than
121performance, the <samp>--size-opt</samp> option can be used to prevent the
122linker from widening density instructions or inserting no-ops, except in
123a few cases where no-ops are required for correctness.
124</p>
125<p>The following Xtensa-specific command-line options can be used to
126control the linker:
127</p>
128<a name="index-Xtensa-options"></a>
129<dl compact="compact">
130<dt><samp>--size-opt</samp></dt>
131<dd><p>When optimizing indirect calls to direct calls, optimize for code size
132more than performance.  With this option, the linker will not insert
133no-ops or widen density instructions to preserve branch target
134alignment.  There may still be some cases where no-ops are required to
135preserve the correctness of the code.
136</p>
137</dd>
138<dt><samp>--abi-windowed</samp></dt>
139<dt><samp>--abi-call0</samp></dt>
140<dd><p>Choose ABI for the output object and for the generated PLT code.
141PLT code inserted by the linker must match ABI of the output object
142because windowed and call0 ABI use incompatible function call
143conventions.
144Default ABI is chosen by the ABI tag in the <code>.xtensa.info</code> section
145of the first input object.
146A warning is issued if ABI tags of input objects do not match each other
147or the chosen output object ABI.
148</p></dd>
149</dl>
150
151
152<hr>
153<div class="header">
154<p>
155Previous: <a href="WIN32.html#WIN32" accesskey="p" rel="previous">WIN32</a>, Up: <a href="Machine-Dependent.html#Machine-Dependent" accesskey="u" rel="up">Machine Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
156</div>
157
158
159
160</body>
161</html>
162