您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

142 行
6.1KB

  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 Address (LD)</title>
  17. <meta name="description" content="Output Section Address (LD)">
  18. <meta name="keywords" content="Output Section Address (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="Input-Section.html#Input-Section" rel="next" title="Input Section">
  27. <link href="Output-Section-Name.html#Output-Section-Name" rel="prev" title="Output Section Name">
  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-Address"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Input-Section.html#Input-Section" accesskey="n" rel="next">Input Section</a>, Previous: <a href="Output-Section-Name.html#Output-Section-Name" accesskey="p" rel="prev">Output Section Name</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-Address-1"></a>
  64. <h4 class="subsection">3.6.3 Output Section Address</h4>
  65. <a name="index-address_002c-section"></a>
  66. <a name="index-section-address"></a>
  67. <p>The <var>address</var> is an expression for the VMA (the virtual memory
  68. address) of the output section. This address is optional, but if it
  69. is provided then the output address will be set exactly as specified.
  70. </p>
  71. <p>If the output address is not specified then one will be chosen for the
  72. section, based on the heuristic below. This address will be adjusted
  73. to fit the alignment requirement of the output section. The
  74. alignment requirement is the strictest alignment of any input section
  75. contained within the output section.
  76. </p>
  77. <p>The output section address heuristic is as follows:
  78. </p>
  79. <ul>
  80. <li> If an output memory <var>region</var> is set for the section then it
  81. is added to this region and its address will be the next free address
  82. in that region.
  83. </li><li> If the MEMORY command has been used to create a list of memory
  84. regions then the first region which has attributes compatible with the
  85. section is selected to contain it. The section&rsquo;s output address will
  86. be the next free address in that region; <a href="MEMORY.html#MEMORY">MEMORY</a>.
  87. </li><li> If no memory regions were specified, or none match the section then
  88. the output address will be based on the current value of the location
  89. counter.
  90. </li></ul>
  91. <p>For example:
  92. </p>
  93. <div class="smallexample">
  94. <pre class="smallexample">.text . : { *(.text) }
  95. </pre></div>
  96. <p>and
  97. </p>
  98. <div class="smallexample">
  99. <pre class="smallexample">.text : { *(.text) }
  100. </pre></div>
  101. <p>are subtly different. The first will set the address of the
  102. &lsquo;<samp>.text</samp>&rsquo; output section to the current value of the location
  103. counter. The second will set it to the current value of the location
  104. counter aligned to the strictest alignment of any of the &lsquo;<samp>.text</samp>&rsquo;
  105. input sections.
  106. </p>
  107. <p>The <var>address</var> may be an arbitrary expression; <a href="Expressions.html#Expressions">Expressions</a>.
  108. For example, if you want to align the section on a 0x10 byte boundary,
  109. so that the lowest four bits of the section address are zero, you could
  110. do something like this:
  111. </p><div class="smallexample">
  112. <pre class="smallexample">.text ALIGN(0x10) : { *(.text) }
  113. </pre></div>
  114. <p>This works because <code>ALIGN</code> returns the current location counter
  115. aligned upward to the specified value.
  116. </p>
  117. <p>Specifying <var>address</var> for a section will change the value of the
  118. location counter, provided that the section is non-empty. (Empty
  119. sections are ignored).
  120. </p>
  121. <hr>
  122. <div class="header">
  123. <p>
  124. Next: <a href="Input-Section.html#Input-Section" accesskey="n" rel="next">Input Section</a>, Previous: <a href="Output-Section-Name.html#Output-Section-Name" accesskey="p" rel="prev">Output Section Name</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>
  125. </div>
  126. </body>
  127. </html>