You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
8.4 KiB
HTML
146 lines
8.4 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.13">
|
|
<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="REGION_005fALIAS.html#REGION_005fALIAS" title="REGION_ALIAS">
|
|
<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.26.
|
|
|
|
Copyright (C) 1991-2015 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="Miscellaneous-Commands"></a>
|
|
<p>
|
|
Previous: <a rel="previous" accesskey="p" href="REGION_005fALIAS.html#REGION_005fALIAS">REGION_ALIAS</a>,
|
|
Up: <a rel="up" accesskey="u" href="Simple-Commands.html#Simple-Commands">Simple Commands</a>
|
|
<hr>
|
|
</div>
|
|
|
|
<h4 class="subsection">3.4.5 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-401"></a><a name="index-assertion-in-linker-script-402"></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>.
|
|
|
|
<p>Note that assertions are checked before the final stages of linking
|
|
take place. This means that expressions involving symbols PROVIDEd
|
|
inside section definitions will fail if the user has not set values
|
|
for those symbols. The only exception to this rule is PROVIDEd
|
|
symbols that just reference dot. Thus an assertion like this:
|
|
|
|
<pre class="smallexample"> .stack :
|
|
{
|
|
PROVIDE (__stack = .);
|
|
PROVIDE (__stack_size = 0x100);
|
|
ASSERT ((__stack > (_end + __stack_size)), "Error: No room left for the stack");
|
|
}
|
|
</pre>
|
|
<p>will fail if <code>__stack_size</code> is not defined elsewhere. Symbols
|
|
PROVIDEd outside of section definitions are evaluated earlier, so they
|
|
can be used inside ASSERTions. Thus:
|
|
|
|
<pre class="smallexample"> PROVIDE (__stack_size = 0x100);
|
|
.stack :
|
|
{
|
|
PROVIDE (__stack = .);
|
|
ASSERT ((__stack > (_end + __stack_size)), "Error: No room left for the stack");
|
|
}
|
|
</pre>
|
|
<p>will work.
|
|
|
|
<br><dt><code>EXTERN(</code><var>symbol</var> <var>symbol</var><code> ...)</code><dd><a name="index-EXTERN-403"></a><a name="index-undefined-symbol-in-linker-script-404"></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 ‘<samp><span class="samp">-u</span></samp>’ command-line option.
|
|
|
|
<br><dt><code>FORCE_COMMON_ALLOCATION</code><dd><a name="index-FORCE_005fCOMMON_005fALLOCATION-405"></a><a name="index-common-allocation-in-linker-script-406"></a>This command has the same effect as the ‘<samp><span class="samp">-d</span></samp>’ command-line option:
|
|
to make <samp><span class="command">ld</span></samp> assign space to common symbols even if a relocatable
|
|
output file is specified (‘<samp><span class="samp">-r</span></samp>’).
|
|
|
|
<br><dt><code>INHIBIT_COMMON_ALLOCATION</code><dd><a name="index-INHIBIT_005fCOMMON_005fALLOCATION-407"></a><a name="index-common-allocation-in-linker-script-408"></a>This command has the same effect as the ‘<samp><span class="samp">--no-define-common</span></samp>’
|
|
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-409"></a><a name="index-insert-user-script-into-default-script-410"></a>This command is typically used in a script specified by ‘<samp><span class="samp">-T</span></samp>’ 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 ‘<samp><span class="samp">-T</span></samp>’ 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 ‘<samp><span class="samp">-T</span></samp>’ scripts are parsed before the default
|
|
linker script, statements in the ‘<samp><span class="samp">-T</span></samp>’ 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 ‘<samp><span class="samp">-T</span></samp>’ output sections before those in the default script. Here
|
|
is an example of how a ‘<samp><span class="samp">-T</span></samp>’ 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-411"></a><a name="index-cross-references-412"></a>This command may be used to tell <samp><span class="command">ld</span></samp> 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
|
|
<samp><span class="command">ld</span></samp> 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-413"></a><a name="index-machine-architecture-414"></a><a name="index-architecture-415"></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 ‘<samp><span class="samp">-f</span></samp>’ option.
|
|
|
|
<br><dt><code>LD_FEATURE(</code><var>string</var><code>)</code><dd><a name="index-LD_005fFEATURE_0028_0040var_007bstring_007d_0029-416"></a>This command may be used to modify <samp><span class="command">ld</span></samp> behavior. If
|
|
<var>string</var> is <code>"SANE_EXPR"</code> then absolute symbols and numbers
|
|
in a script are simply treated as numbers everywhere.
|
|
See <a href="Expression-Section.html#Expression-Section">Expression Section</a>.
|
|
</dl>
|
|
|
|
</body></html>
|
|
|