SECTIONS.html 7.2 KB

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