114 lines
		
	
	
	
		
			6.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
		
		
			
		
	
	
			114 lines
		
	
	
	
		
			6.6 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| 
								 | 
							
								<html lang="en">
							 | 
						||
| 
								 | 
							
								<head>
							 | 
						||
| 
								 | 
							
								<title>Miscellaneous Commands - 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="Simple-Commands.html#Simple-Commands" title="Simple Commands">
							 | 
						||
| 
								 | 
							
								<link rel="prev" href="Format-Commands.html#Format-Commands" title="Format Commands">
							 | 
						||
| 
								 | 
							
								<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="Miscellaneous-Commands"></a>Previous: <a rel="previous" accesskey="p" href="Format-Commands.html#Format-Commands">Format Commands</a>,
							 | 
						||
| 
								 | 
							
								Up: <a rel="up" accesskey="u" href="Simple-Commands.html#Simple-Commands">Simple Commands</a>
							 | 
						||
| 
								 | 
							
								<hr><br>
							 | 
						||
| 
								 | 
							
								</div>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<h4 class="subsection">3.4.4 Other Linker Script Commands</h4>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								<p>There are a few other linker scripts commands.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <dl>
							 | 
						||
| 
								 | 
							
								<dt><code>ASSERT(</code><var>exp</var><code>, </code><var>message</var><code>)</code><dd><a name="index-ASSERT-341"></a><a name="index-assertion-in-linker-script-342"></a>Ensure that <var>exp</var> is non-zero.  If it is zero, then exit the linker
							 | 
						||
| 
								 | 
							
								with an error code, and print <var>message</var>.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><code>EXTERN(</code><var>symbol</var> <var>symbol</var><code> ...)</code><dd><a name="index-EXTERN-343"></a><a name="index-undefined-symbol-in-linker-script-344"></a>Force <var>symbol</var> to be entered in the output file as an undefined
							 | 
						||
| 
								 | 
							
								symbol.  Doing this may, for example, trigger linking of additional
							 | 
						||
| 
								 | 
							
								modules from standard libraries.  You may list several <var>symbol</var>s for
							 | 
						||
| 
								 | 
							
								each <code>EXTERN</code>, and you may use <code>EXTERN</code> multiple times.  This
							 | 
						||
| 
								 | 
							
								command has the same effect as the <span class="samp">-u</span> command-line option.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><code>FORCE_COMMON_ALLOCATION</code><dd><a name="index-FORCE_005fCOMMON_005fALLOCATION-345"></a><a name="index-common-allocation-in-linker-script-346"></a>This command has the same effect as the <span class="samp">-d</span> command-line option:
							 | 
						||
| 
								 | 
							
								to make <span class="command">ld</span> assign space to common symbols even if a relocatable
							 | 
						||
| 
								 | 
							
								output file is specified (<span class="samp">-r</span>).
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><code>INHIBIT_COMMON_ALLOCATION</code><dd><a name="index-INHIBIT_005fCOMMON_005fALLOCATION-347"></a><a name="index-common-allocation-in-linker-script-348"></a>This command has the same effect as the <span class="samp">--no-define-common</span>
							 | 
						||
| 
								 | 
							
								command-line option: to make <code>ld</code> omit the assignment of addresses
							 | 
						||
| 
								 | 
							
								to common symbols even for a non-relocatable output file.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><code>INSERT [ AFTER | BEFORE ] </code><var>output_section</var><dd><a name="index-INSERT-349"></a><a name="index-insert-user-script-into-default-script-350"></a>This command is typically used in a script specified by <span class="samp">-T</span> to
							 | 
						||
| 
								 | 
							
								augment the default <code>SECTIONS</code> with, for example, overlays.  It
							 | 
						||
| 
								 | 
							
								inserts all prior linker script statements after (or before)
							 | 
						||
| 
								 | 
							
								<var>output_section</var>, and also causes <span class="samp">-T</span> to not override the
							 | 
						||
| 
								 | 
							
								default linker script.  The exact insertion point is as for orphan
							 | 
						||
| 
								 | 
							
								sections.  See <a href="Location-Counter.html#Location-Counter">Location Counter</a>.  The insertion happens after the
							 | 
						||
| 
								 | 
							
								linker has mapped input sections to output sections.  Prior to the
							 | 
						||
| 
								 | 
							
								insertion, since <span class="samp">-T</span> scripts are parsed before the default
							 | 
						||
| 
								 | 
							
								linker script, statements in the <span class="samp">-T</span> script occur before the
							 | 
						||
| 
								 | 
							
								default linker script statements in the internal linker representation
							 | 
						||
| 
								 | 
							
								of the script.  In particular, input section assignments will be made
							 | 
						||
| 
								 | 
							
								to <span class="samp">-T</span> output sections before those in the default script.  Here
							 | 
						||
| 
								 | 
							
								is an example of how a <span class="samp">-T</span> script using <code>INSERT</code> might look:
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <pre class="smallexample">          SECTIONS
							 | 
						||
| 
								 | 
							
								          {
							 | 
						||
| 
								 | 
							
								            OVERLAY :
							 | 
						||
| 
								 | 
							
								            {
							 | 
						||
| 
								 | 
							
								              .ov1 { ov1*(.text) }
							 | 
						||
| 
								 | 
							
								              .ov2 { ov2*(.text) }
							 | 
						||
| 
								 | 
							
								            }
							 | 
						||
| 
								 | 
							
								          }
							 | 
						||
| 
								 | 
							
								          INSERT AFTER .text;
							 | 
						||
| 
								 | 
							
								     </pre>
							 | 
						||
| 
								 | 
							
								     <br><dt><code>NOCROSSREFS(</code><var>section</var> <var>section</var><code> ...)</code><dd><a name="index-NOCROSSREFS_0028_0040var_007bsections_007d_0029-351"></a><a name="index-cross-references-352"></a>This command may be used to tell <span class="command">ld</span> to issue an error about any
							 | 
						||
| 
								 | 
							
								references among certain output sections.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <p>In certain types of programs, particularly on embedded systems when
							 | 
						||
| 
								 | 
							
								using overlays, when one section is loaded into memory, another section
							 | 
						||
| 
								 | 
							
								will not be.  Any direct references between the two sections would be
							 | 
						||
| 
								 | 
							
								errors.  For example, it would be an error if code in one section called
							 | 
						||
| 
								 | 
							
								a function defined in the other section.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <p>The <code>NOCROSSREFS</code> command takes a list of output section names.  If
							 | 
						||
| 
								 | 
							
								<span class="command">ld</span> detects any cross references between the sections, it reports
							 | 
						||
| 
								 | 
							
								an error and returns a non-zero exit status.  Note that the
							 | 
						||
| 
								 | 
							
								<code>NOCROSSREFS</code> command uses output section names, not input section
							 | 
						||
| 
								 | 
							
								names.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								     <br><dt><code>OUTPUT_ARCH(</code><var>bfdarch</var><code>)</code><dd><a name="index-OUTPUT_005fARCH_0028_0040var_007bbfdarch_007d_0029-353"></a><a name="index-machine-architecture-354"></a><a name="index-architecture-355"></a>Specify a particular output machine architecture.  The argument is one
							 | 
						||
| 
								 | 
							
								of the names used by the BFD library (see <a href="BFD.html#BFD">BFD</a>).  You can see the
							 | 
						||
| 
								 | 
							
								architecture of an object file by using the <code>objdump</code> program with
							 | 
						||
| 
								 | 
							
								the <span class="samp">-f</span> option. 
							 | 
						||
| 
								 | 
							
								</dl>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								   </body></html>
							 | 
						||
| 
								 | 
							
								
							 |