1<html lang="en"> 2<head> 3<title>Xtensa - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Machine-Dependent.html#Machine-Dependent" title="Machine Dependent"> 9<link rel="prev" href="WIN32.html#WIN32" title="WIN32"> 10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 11<!-- 12This file documents the GNU linker LD 13(Sourcery CodeBench Lite 2011.09-69) 14version 2.21.53. 15 16Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 172001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 18 19Permission is granted to copy, distribute and/or modify this document 20under the terms of the GNU Free Documentation License, Version 1.3 21or any later version published by the Free Software Foundation; 22with no Invariant Sections, with no Front-Cover Texts, and with no 23Back-Cover Texts. A copy of the license is included in the 24section entitled ``GNU Free Documentation License''.--> 25<meta http-equiv="Content-Style-Type" content="text/css"> 26<style type="text/css"><!-- 27 pre.display { font-family:inherit } 28 pre.format { font-family:inherit } 29 pre.smalldisplay { font-family:inherit; font-size:smaller } 30 pre.smallformat { font-family:inherit; font-size:smaller } 31 pre.smallexample { font-size:smaller } 32 pre.smalllisp { font-size:smaller } 33 span.sc { font-variant:small-caps } 34 span.roman { font-family:serif; font-weight:normal; } 35 span.sansserif { font-family:sans-serif; font-weight:normal; } 36--></style> 37<link rel="stylesheet" type="text/css" href="../cs.css"> 38</head> 39<body> 40<div class="node"> 41<a name="Xtensa"></a> 42<p> 43Previous: <a rel="previous" accesskey="p" href="WIN32.html#WIN32">WIN32</a>, 44Up: <a rel="up" accesskey="u" href="Machine-Dependent.html#Machine-Dependent">Machine Dependent</a> 45<hr> 46</div> 47 48<h3 class="section">4.15 <code>ld</code> and Xtensa Processors</h3> 49 50<p><a name="index-Xtensa-processors-688"></a>The default <samp><span class="command">ld</span></samp> behavior for Xtensa processors is to interpret 51<code>SECTIONS</code> commands so that lists of explicitly named sections in a 52specification with a wildcard file will be interleaved when necessary to 53keep literal pools within the range of PC-relative load offsets. For 54example, with the command: 55 56<pre class="smallexample"> SECTIONS 57 { 58 .text : { 59 *(.literal .text) 60 } 61 } 62</pre> 63 <p class="noindent"><samp><span class="command">ld</span></samp> may interleave some of the <code>.literal</code> 64and <code>.text</code> sections from different object files to ensure that the 65literal pools are within the range of PC-relative load offsets. A valid 66interleaving might place the <code>.literal</code> sections from an initial 67group of files followed by the <code>.text</code> sections of that group of 68files. Then, the <code>.literal</code> sections from the rest of the files 69and the <code>.text</code> sections from the rest of the files would follow. 70 71 <p><a name="index-g_t_0040option_007b_002d_002drelax_007d-on-Xtensa-689"></a><a name="index-relaxing-on-Xtensa-690"></a>Relaxation is enabled by default for the Xtensa version of <samp><span class="command">ld</span></samp> and 72provides two important link-time optimizations. The first optimization 73is to combine identical literal values to reduce code size. A redundant 74literal will be removed and all the <code>L32R</code> instructions that use it 75will be changed to reference an identical literal, as long as the 76location of the replacement literal is within the offset range of all 77the <code>L32R</code> instructions. The second optimization is to remove 78unnecessary overhead from assembler-generated “longcall” sequences of 79<code>L32R</code>/<code>CALLX</code><var>n</var> when the target functions are within 80range of direct <code>CALL</code><var>n</var> instructions. 81 82 <p>For each of these cases where an indirect call sequence can be optimized 83to a direct call, the linker will change the <code>CALLX</code><var>n</var> 84instruction to a <code>CALL</code><var>n</var> instruction, remove the <code>L32R</code> 85instruction, and remove the literal referenced by the <code>L32R</code> 86instruction if it is not used for anything else. Removing the 87<code>L32R</code> instruction always reduces code size but can potentially 88hurt performance by changing the alignment of subsequent branch targets. 89By default, the linker will always preserve alignments, either by 90switching some instructions between 24-bit encodings and the equivalent 91density instructions or by inserting a no-op in place of the <code>L32R</code> 92instruction that was removed. If code size is more important than 93performance, the <samp><span class="option">--size-opt</span></samp> option can be used to prevent the 94linker from widening density instructions or inserting no-ops, except in 95a few cases where no-ops are required for correctness. 96 97 <p>The following Xtensa-specific command-line options can be used to 98control the linker: 99 100 <p><a name="index-Xtensa-options-691"></a> 101 <dl> 102<dt><samp><span class="option">--size-opt</span></samp><dd>When optimizing indirect calls to direct calls, optimize for code size 103more than performance. With this option, the linker will not insert 104no-ops or widen density instructions to preserve branch target 105alignment. There may still be some cases where no-ops are required to 106preserve the correctness of the code. 107</dl> 108 109 </body></html> 110 111