1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- This file documents the GNU linker LD
4(GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))
5version 2.36.1.
6
7Copyright (C) 1991-2021 Free Software Foundation, Inc.
8
9Permission is granted to copy, distribute and/or modify this document
10under the terms of the GNU Free Documentation License, Version 1.3
11or any later version published by the Free Software Foundation;
12with no Invariant Sections, with no Front-Cover Texts, and with no
13Back-Cover Texts.  A copy of the license is included in the
14section entitled "GNU Free Documentation License". -->
15<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
16<head>
17<title>LD: SECTIONS</title>
18
19<meta name="description" content="LD: SECTIONS">
20<meta name="keywords" content="LD: SECTIONS">
21<meta name="resource-type" content="document">
22<meta name="distribution" content="global">
23<meta name="Generator" content="makeinfo">
24<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
25<link href="index.html#Top" rel="start" title="Top">
26<link href="LD-Index.html#LD-Index" rel="index" title="LD Index">
27<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
28<link href="Scripts.html#Scripts" rel="up" title="Scripts">
29<link href="Output-Section-Description.html#Output-Section-Description" rel="next" title="Output Section Description">
30<link href="Source-Code-Reference.html#Source-Code-Reference" rel="previous" title="Source Code Reference">
31<style type="text/css">
32<!--
33a.summary-letter {text-decoration: none}
34blockquote.smallquotation {font-size: smaller}
35div.display {margin-left: 3.2em}
36div.example {margin-left: 3.2em}
37div.indentedblock {margin-left: 3.2em}
38div.lisp {margin-left: 3.2em}
39div.smalldisplay {margin-left: 3.2em}
40div.smallexample {margin-left: 3.2em}
41div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
42div.smalllisp {margin-left: 3.2em}
43kbd {font-style:oblique}
44pre.display {font-family: inherit}
45pre.format {font-family: inherit}
46pre.menu-comment {font-family: serif}
47pre.menu-preformatted {font-family: serif}
48pre.smalldisplay {font-family: inherit; font-size: smaller}
49pre.smallexample {font-size: smaller}
50pre.smallformat {font-family: inherit; font-size: smaller}
51pre.smalllisp {font-size: smaller}
52span.nocodebreak {white-space:nowrap}
53span.nolinebreak {white-space:nowrap}
54span.roman {font-family:serif; font-weight:normal}
55span.sansserif {font-family:sans-serif; font-weight:normal}
56ul.no-bullet {list-style: none}
57-->
58</style>
59
60
61</head>
62
63<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
64<a name="SECTIONS"></a>
65<div class="header">
66<p>
67Next: <a href="MEMORY.html#MEMORY" accesskey="n" rel="next">MEMORY</a>, Previous: <a href="Assignments.html#Assignments" accesskey="p" rel="previous">Assignments</a>, Up: <a href="Scripts.html#Scripts" accesskey="u" rel="up">Scripts</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
68</div>
69<hr>
70<a name="SECTIONS-Command"></a>
71<h3 class="section">3.6 SECTIONS Command</h3>
72<a name="index-SECTIONS"></a>
73<p>The <code>SECTIONS</code> command tells the linker how to map input sections
74into output sections, and how to place the output sections in memory.
75</p>
76<p>The format of the <code>SECTIONS</code> command is:
77</p><div class="smallexample">
78<pre class="smallexample">SECTIONS
79{
80  <var>sections-command</var>
81  <var>sections-command</var>
82  &hellip;
83}
84</pre></div>
85
86<p>Each <var>sections-command</var> may of be one of the following:
87</p>
88<ul>
89<li> an <code>ENTRY</code> command (see <a href="Entry-Point.html#Entry-Point">Entry command</a>)
90</li><li> a symbol assignment (see <a href="Assignments.html#Assignments">Assignments</a>)
91</li><li> an output section description
92</li><li> an overlay description
93</li></ul>
94
95<p>The <code>ENTRY</code> command and symbol assignments are permitted inside the
96<code>SECTIONS</code> command for convenience in using the location counter in
97those commands.  This can also make the linker script easier to
98understand because you can use those commands at meaningful points in
99the layout of the output file.
100</p>
101<p>Output section descriptions and overlay descriptions are described
102below.
103</p>
104<p>If you do not use a <code>SECTIONS</code> command in your linker script, the
105linker will place each input section into an identically named output
106section in the order that the sections are first encountered in the
107input files.  If all input sections are present in the first file, for
108example, the order of sections in the output file will match the order
109in the first input file.  The first section will be at address zero.
110</p>
111<table class="menu" border="0" cellspacing="0">
112<tr><td align="left" valign="top">&bull; <a href="Output-Section-Description.html#Output-Section-Description" accesskey="1">Output Section Description</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Output section description
113</td></tr>
114<tr><td align="left" valign="top">&bull; <a href="Output-Section-Name.html#Output-Section-Name" accesskey="2">Output Section Name</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Output section name
115</td></tr>
116<tr><td align="left" valign="top">&bull; <a href="Output-Section-Address.html#Output-Section-Address" accesskey="3">Output Section Address</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Output section address
117</td></tr>
118<tr><td align="left" valign="top">&bull; <a href="Input-Section.html#Input-Section" accesskey="4">Input Section</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Input section description
119</td></tr>
120<tr><td align="left" valign="top">&bull; <a href="Output-Section-Data.html#Output-Section-Data" accesskey="5">Output Section Data</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Output section data
121</td></tr>
122<tr><td align="left" valign="top">&bull; <a href="Output-Section-Keywords.html#Output-Section-Keywords" accesskey="6">Output Section Keywords</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Output section keywords
123</td></tr>
124<tr><td align="left" valign="top">&bull; <a href="Output-Section-Discarding.html#Output-Section-Discarding" accesskey="7">Output Section Discarding</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Output section discarding
125</td></tr>
126<tr><td align="left" valign="top">&bull; <a href="Output-Section-Attributes.html#Output-Section-Attributes" accesskey="8">Output Section Attributes</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Output section attributes
127</td></tr>
128<tr><td align="left" valign="top">&bull; <a href="Overlay-Description.html#Overlay-Description" accesskey="9">Overlay Description</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">Overlay description
129</td></tr>
130</table>
131
132<hr>
133<div class="header">
134<p>
135Next: <a href="MEMORY.html#MEMORY" accesskey="n" rel="next">MEMORY</a>, Previous: <a href="Assignments.html#Assignments" accesskey="p" rel="previous">Assignments</a>, Up: <a href="Scripts.html#Scripts" accesskey="u" rel="up">Scripts</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="LD-Index.html#LD-Index" title="Index" rel="index">Index</a>]</p>
136</div>
137
138
139
140</body>
141</html>
142