Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

154 lines
7.4KB

  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 Arm Embedded Toolchain 10-2020-q4-major)
  5. version 2.35.1.
  6. Copyright (C) 1991-2020 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 6.5, http://www.gnu.org/software/texinfo/ -->
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>Output Section Data (LD)</title>
  17. <meta name="description" content="Output Section Data (LD)">
  18. <meta name="keywords" content="Output Section Data (LD)">
  19. <meta name="resource-type" content="document">
  20. <meta name="distribution" content="global">
  21. <meta name="Generator" content="makeinfo">
  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="SECTIONS.html#SECTIONS" rel="up" title="SECTIONS">
  26. <link href="Output-Section-Keywords.html#Output-Section-Keywords" rel="next" title="Output Section Keywords">
  27. <link href="Input-Section-Example.html#Input-Section-Example" rel="prev" title="Input Section Example">
  28. <style type="text/css">
  29. <!--
  30. a.summary-letter {text-decoration: none}
  31. blockquote.indentedblock {margin-right: 0em}
  32. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  33. blockquote.smallquotation {font-size: smaller}
  34. div.display {margin-left: 3.2em}
  35. div.example {margin-left: 3.2em}
  36. div.lisp {margin-left: 3.2em}
  37. div.smalldisplay {margin-left: 3.2em}
  38. div.smallexample {margin-left: 3.2em}
  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.nolinebreak {white-space: nowrap}
  50. span.roman {font-family: initial; font-weight: normal}
  51. span.sansserif {font-family: sans-serif; font-weight: normal}
  52. ul.no-bullet {list-style: none}
  53. -->
  54. </style>
  55. </head>
  56. <body lang="en">
  57. <a name="Output-Section-Data"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Output-Section-Keywords.html#Output-Section-Keywords" accesskey="n" rel="next">Output Section Keywords</a>, Previous: <a href="Input-Section.html#Input-Section" accesskey="p" rel="prev">Input Section</a>, Up: <a href="SECTIONS.html#SECTIONS" accesskey="u" rel="up">SECTIONS</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>
  61. </div>
  62. <hr>
  63. <a name="Output-Section-Data-1"></a>
  64. <h4 class="subsection">3.6.5 Output Section Data</h4>
  65. <a name="index-data"></a>
  66. <a name="index-section-data"></a>
  67. <a name="index-output-section-data"></a>
  68. <a name="index-BYTE_0028expression_0029"></a>
  69. <a name="index-SHORT_0028expression_0029"></a>
  70. <a name="index-LONG_0028expression_0029"></a>
  71. <a name="index-QUAD_0028expression_0029"></a>
  72. <a name="index-SQUAD_0028expression_0029"></a>
  73. <p>You can include explicit bytes of data in an output section by using
  74. <code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, <code>QUAD</code>, or <code>SQUAD</code> as
  75. an output section command. Each keyword is followed by an expression in
  76. parentheses providing the value to store (see <a href="Expressions.html#Expressions">Expressions</a>). The
  77. value of the expression is stored at the current value of the location
  78. counter.
  79. </p>
  80. <p>The <code>BYTE</code>, <code>SHORT</code>, <code>LONG</code>, and <code>QUAD</code> commands
  81. store one, two, four, and eight bytes (respectively). After storing the
  82. bytes, the location counter is incremented by the number of bytes
  83. stored.
  84. </p>
  85. <p>For example, this will store the byte 1 followed by the four byte value
  86. of the symbol &lsquo;<samp>addr</samp>&rsquo;:
  87. </p><div class="smallexample">
  88. <pre class="smallexample">BYTE(1)
  89. LONG(addr)
  90. </pre></div>
  91. <p>When using a 64 bit host or target, <code>QUAD</code> and <code>SQUAD</code> are the
  92. same; they both store an 8 byte, or 64 bit, value. When both host and
  93. target are 32 bits, an expression is computed as 32 bits. In this case
  94. <code>QUAD</code> stores a 32 bit value zero extended to 64 bits, and
  95. <code>SQUAD</code> stores a 32 bit value sign extended to 64 bits.
  96. </p>
  97. <p>If the object file format of the output file has an explicit endianness,
  98. which is the normal case, the value will be stored in that endianness.
  99. When the object file format does not have an explicit endianness, as is
  100. true of, for example, S-records, the value will be stored in the
  101. endianness of the first input object file.
  102. </p>
  103. <p>Note&mdash;these commands only work inside a section description and not
  104. between them, so the following will produce an error from the linker:
  105. </p><div class="smallexample">
  106. <pre class="smallexample">SECTIONS {&nbsp;.text : {&nbsp;*(.text) }&nbsp;LONG(1) .data : {&nbsp;*(.data) }&nbsp;}&nbsp;</pre></div>
  107. <p>whereas this will work:
  108. </p><div class="smallexample">
  109. <pre class="smallexample">SECTIONS {&nbsp;.text : {&nbsp;*(.text) ; LONG(1) }&nbsp;.data : {&nbsp;*(.data) }&nbsp;}&nbsp;</pre></div>
  110. <a name="index-FILL_0028expression_0029"></a>
  111. <a name="index-holes_002c-filling"></a>
  112. <a name="index-unspecified-memory"></a>
  113. <p>You may use the <code>FILL</code> command to set the fill pattern for the
  114. current section. It is followed by an expression in parentheses. Any
  115. otherwise unspecified regions of memory within the section (for example,
  116. gaps left due to the required alignment of input sections) are filled
  117. with the value of the expression, repeated as
  118. necessary. A <code>FILL</code> statement covers memory locations after the
  119. point at which it occurs in the section definition; by including more
  120. than one <code>FILL</code> statement, you can have different fill patterns in
  121. different parts of an output section.
  122. </p>
  123. <p>This example shows how to fill unspecified regions of memory with the
  124. value &lsquo;<samp>0x90</samp>&rsquo;:
  125. </p><div class="smallexample">
  126. <pre class="smallexample">FILL(0x90909090)
  127. </pre></div>
  128. <p>The <code>FILL</code> command is similar to the &lsquo;<samp>=<var>fillexp</var></samp>&rsquo; output
  129. section attribute, but it only affects the
  130. part of the section following the <code>FILL</code> command, rather than the
  131. entire section. If both are used, the <code>FILL</code> command takes
  132. precedence. See <a href="Output-Section-Fill.html#Output-Section-Fill">Output Section Fill</a>, for details on the fill
  133. expression.
  134. </p>
  135. <hr>
  136. <div class="header">
  137. <p>
  138. Next: <a href="Output-Section-Keywords.html#Output-Section-Keywords" accesskey="n" rel="next">Output Section Keywords</a>, Previous: <a href="Input-Section.html#Input-Section" accesskey="p" rel="prev">Input Section</a>, Up: <a href="SECTIONS.html#SECTIONS" accesskey="u" rel="up">SECTIONS</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>
  139. </div>
  140. </body>
  141. </html>