113 lines
		
	
	
	
		
			5.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
		
		
			
		
	
	
			113 lines
		
	
	
	
		
			5.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| 
								 | 
							
								<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.7">
							 | 
						||
| 
								 | 
							
								<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 Binutils)
							 | 
						||
| 
								 | 
							
								version 2.19.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000,
							 | 
						||
| 
								 | 
							
								2001, 2002, 2003, 2004, 2005, 2006, 2007 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.1
							 | 
						||
| 
								 | 
							
								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; } 
							 | 
						||
| 
								 | 
							
								--></style>
							 | 
						||
| 
								 | 
							
								</head>
							 | 
						||
| 
								 | 
							
								<body>
							 | 
						||
| 
								 | 
							
								<div class="node">
							 | 
						||
| 
								 | 
							
								<p>
							 | 
						||
| 
								 | 
							
								<a name="Xtensa"></a>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><br>
							 | 
						||
| 
								 | 
							
								</div>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<h3 class="section">4.14 <code>ld</code> and Xtensa Processors</h3>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<p><a name="index-Xtensa-processors-624"></a>The default <span class="command">ld</span> 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"><span class="command">ld</span> 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-_0040option_007b_002d_002drelax_007d-on-Xtensa-625"></a><a name="index-relaxing-on-Xtensa-626"></a>Relaxation is enabled by default for the Xtensa version of <span class="command">ld</span> 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 <span class="option">--size-opt</span> 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-627"></a>
							 | 
						||
| 
								 | 
							
								     
							 | 
						||
| 
								 | 
							
								<a name="index-_002d_002dno_002drelax-628"></a>
							 | 
						||
| 
								 | 
							
								<dl><dt><span class="option">--no-relax</span><dd>Since the Xtensa version of <code>ld</code> enables the <span class="option">--relax</span> option
							 | 
						||
| 
								 | 
							
								by default, the <span class="option">--no-relax</span> option is provided to disable
							 | 
						||
| 
								 | 
							
								relaxation.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><span class="option">--size-opt</span><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>
							 | 
						||
| 
								 | 
							
								
							 |