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.

100 lines
4.6 KiB
HTML

<html lang="en">
<head>
<title>SECTIONS - 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="Scripts.html#Scripts" title="Scripts">
<link rel="prev" href="Assignments.html#Assignments" title="Assignments">
<link rel="next" href="MEMORY.html#MEMORY" title="MEMORY">
<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="SECTIONS"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="MEMORY.html#MEMORY">MEMORY</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Assignments.html#Assignments">Assignments</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Scripts.html#Scripts">Scripts</a>
<hr>
</div>
<h3 class="section">3.6 SECTIONS Command</h3>
<p><a name="index-SECTIONS-423"></a>The <code>SECTIONS</code> command tells the linker how to map input sections
into output sections, and how to place the output sections in memory.
<p>The format of the <code>SECTIONS</code> command is:
<pre class="smallexample"> SECTIONS
{
<var>sections-command</var>
<var>sections-command</var>
...
}
</pre>
<p>Each <var>sections-command</var> may of be one of the following:
<ul>
<li>an <code>ENTRY</code> command (see <a href="Entry-Point.html#Entry-Point">Entry command</a>)
<li>a symbol assignment (see <a href="Assignments.html#Assignments">Assignments</a>)
<li>an output section description
<li>an overlay description
</ul>
<p>The <code>ENTRY</code> command and symbol assignments are permitted inside the
<code>SECTIONS</code> command for convenience in using the location counter in
those commands. This can also make the linker script easier to
understand because you can use those commands at meaningful points in
the layout of the output file.
<p>Output section descriptions and overlay descriptions are described
below.
<p>If you do not use a <code>SECTIONS</code> command in your linker script, the
linker will place each input section into an identically named output
section in the order that the sections are first encountered in the
input files. If all input sections are present in the first file, for
example, the order of sections in the output file will match the order
in the first input file. The first section will be at address zero.
<ul class="menu">
<li><a accesskey="1" href="Output-Section-Description.html#Output-Section-Description">Output Section Description</a>: Output section description
<li><a accesskey="2" href="Output-Section-Name.html#Output-Section-Name">Output Section Name</a>: Output section name
<li><a accesskey="3" href="Output-Section-Address.html#Output-Section-Address">Output Section Address</a>: Output section address
<li><a accesskey="4" href="Input-Section.html#Input-Section">Input Section</a>: Input section description
<li><a accesskey="5" href="Output-Section-Data.html#Output-Section-Data">Output Section Data</a>: Output section data
<li><a accesskey="6" href="Output-Section-Keywords.html#Output-Section-Keywords">Output Section Keywords</a>: Output section keywords
<li><a accesskey="7" href="Output-Section-Discarding.html#Output-Section-Discarding">Output Section Discarding</a>: Output section discarding
<li><a accesskey="8" href="Output-Section-Attributes.html#Output-Section-Attributes">Output Section Attributes</a>: Output section attributes
<li><a accesskey="9" href="Overlay-Description.html#Overlay-Description">Overlay Description</a>: Overlay description
</ul>
</body></html>