1<html lang="en"> 2<head> 3<title>SECTIONS - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Scripts.html#Scripts" title="Scripts"> 9<link rel="prev" href="Assignments.html#Assignments" title="Assignments"> 10<link rel="next" href="MEMORY.html#MEMORY" title="MEMORY"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13This file documents the GNU linker LD 14(Sourcery CodeBench Lite 2011.09-69) 15version 2.21.53. 16 17Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 182001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 19 20Permission is granted to copy, distribute and/or modify this document 21under the terms of the GNU Free Documentation License, Version 1.3 22or any later version published by the Free Software Foundation; 23with no Invariant Sections, with no Front-Cover Texts, and with no 24Back-Cover Texts. A copy of the license is included in the 25section entitled ``GNU Free Documentation License''.--> 26<meta http-equiv="Content-Style-Type" content="text/css"> 27<style type="text/css"><!-- 28 pre.display { font-family:inherit } 29 pre.format { font-family:inherit } 30 pre.smalldisplay { font-family:inherit; font-size:smaller } 31 pre.smallformat { font-family:inherit; font-size:smaller } 32 pre.smallexample { font-size:smaller } 33 pre.smalllisp { font-size:smaller } 34 span.sc { font-variant:small-caps } 35 span.roman { font-family:serif; font-weight:normal; } 36 span.sansserif { font-family:sans-serif; font-weight:normal; } 37--></style> 38<link rel="stylesheet" type="text/css" href="../cs.css"> 39</head> 40<body> 41<div class="node"> 42<a name="SECTIONS"></a> 43<p> 44Next: <a rel="next" accesskey="n" href="MEMORY.html#MEMORY">MEMORY</a>, 45Previous: <a rel="previous" accesskey="p" href="Assignments.html#Assignments">Assignments</a>, 46Up: <a rel="up" accesskey="u" href="Scripts.html#Scripts">Scripts</a> 47<hr> 48</div> 49 50<h3 class="section">3.6 SECTIONS Command</h3> 51 52<p><a name="index-SECTIONS-400"></a>The <code>SECTIONS</code> command tells the linker how to map input sections 53into output sections, and how to place the output sections in memory. 54 55 <p>The format of the <code>SECTIONS</code> command is: 56<pre class="smallexample"> SECTIONS 57 { 58 <var>sections-command</var> 59 <var>sections-command</var> 60 ... 61 } 62</pre> 63 <p>Each <var>sections-command</var> may of be one of the following: 64 65 <ul> 66<li>an <code>ENTRY</code> command (see <a href="Entry-Point.html#Entry-Point">Entry command</a>) 67<li>a symbol assignment (see <a href="Assignments.html#Assignments">Assignments</a>) 68<li>an output section description 69<li>an overlay description 70</ul> 71 72 <p>The <code>ENTRY</code> command and symbol assignments are permitted inside the 73<code>SECTIONS</code> command for convenience in using the location counter in 74those commands. This can also make the linker script easier to 75understand because you can use those commands at meaningful points in 76the layout of the output file. 77 78 <p>Output section descriptions and overlay descriptions are described 79below. 80 81 <p>If you do not use a <code>SECTIONS</code> command in your linker script, the 82linker will place each input section into an identically named output 83section in the order that the sections are first encountered in the 84input files. If all input sections are present in the first file, for 85example, the order of sections in the output file will match the order 86in the first input file. The first section will be at address zero. 87 88<ul class="menu"> 89<li><a accesskey="1" href="Output-Section-Description.html#Output-Section-Description">Output Section Description</a>: Output section description 90<li><a accesskey="2" href="Output-Section-Name.html#Output-Section-Name">Output Section Name</a>: Output section name 91<li><a accesskey="3" href="Output-Section-Address.html#Output-Section-Address">Output Section Address</a>: Output section address 92<li><a accesskey="4" href="Input-Section.html#Input-Section">Input Section</a>: Input section description 93<li><a accesskey="5" href="Output-Section-Data.html#Output-Section-Data">Output Section Data</a>: Output section data 94<li><a accesskey="6" href="Output-Section-Keywords.html#Output-Section-Keywords">Output Section Keywords</a>: Output section keywords 95<li><a accesskey="7" href="Output-Section-Discarding.html#Output-Section-Discarding">Output Section Discarding</a>: Output section discarding 96<li><a accesskey="8" href="Output-Section-Attributes.html#Output-Section-Attributes">Output Section Attributes</a>: Output section attributes 97<li><a accesskey="9" href="Overlay-Description.html#Overlay-Description">Overlay Description</a>: Overlay description 98</ul> 99 100 </body></html> 101 102