Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

Miscellaneous-Commands.html 11KB

3 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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>Miscellaneous Commands (LD)</title>
  17. <meta name="description" content="Miscellaneous Commands (LD)">
  18. <meta name="keywords" content="Miscellaneous Commands (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="Simple-Commands.html#Simple-Commands" rel="up" title="Simple Commands">
  26. <link href="Assignments.html#Assignments" rel="next" title="Assignments">
  27. <link href="REGION_005fALIAS.html#REGION_005fALIAS" rel="prev" title="REGION_ALIAS">
  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="Miscellaneous-Commands"></a>
  58. <div class="header">
  59. <p>
  60. Previous: <a href="REGION_005fALIAS.html#REGION_005fALIAS" accesskey="p" rel="prev">REGION_ALIAS</a>, Up: <a href="Simple-Commands.html#Simple-Commands" accesskey="u" rel="up">Simple Commands</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="Other-Linker-Script-Commands"></a>
  64. <h4 class="subsection">3.4.5 Other Linker Script Commands</h4>
  65. <p>There are a few other linker scripts commands.
  66. </p>
  67. <dl compact="compact">
  68. <dt><code>ASSERT(<var>exp</var>, <var>message</var>)</code></dt>
  69. <dd><a name="index-ASSERT"></a>
  70. <a name="index-assertion-in-linker-script"></a>
  71. <p>Ensure that <var>exp</var> is non-zero. If it is zero, then exit the linker
  72. with an error code, and print <var>message</var>.
  73. </p>
  74. <p>Note that assertions are checked before the final stages of linking
  75. take place. This means that expressions involving symbols PROVIDEd
  76. inside section definitions will fail if the user has not set values
  77. for those symbols. The only exception to this rule is PROVIDEd
  78. symbols that just reference dot. Thus an assertion like this:
  79. </p>
  80. <div class="smallexample">
  81. <pre class="smallexample"> .stack :
  82. {
  83. PROVIDE (__stack = .);
  84. PROVIDE (__stack_size = 0x100);
  85. ASSERT ((__stack &gt; (_end + __stack_size)), &quot;Error: No room left for the stack&quot;);
  86. }
  87. </pre></div>
  88. <p>will fail if <code>__stack_size</code> is not defined elsewhere. Symbols
  89. PROVIDEd outside of section definitions are evaluated earlier, so they
  90. can be used inside ASSERTions. Thus:
  91. </p>
  92. <div class="smallexample">
  93. <pre class="smallexample"> PROVIDE (__stack_size = 0x100);
  94. .stack :
  95. {
  96. PROVIDE (__stack = .);
  97. ASSERT ((__stack &gt; (_end + __stack_size)), &quot;Error: No room left for the stack&quot;);
  98. }
  99. </pre></div>
  100. <p>will work.
  101. </p>
  102. </dd>
  103. <dt><code>EXTERN(<var>symbol</var> <var>symbol</var> &hellip;)</code></dt>
  104. <dd><a name="index-EXTERN"></a>
  105. <a name="index-undefined-symbol-in-linker-script"></a>
  106. <p>Force <var>symbol</var> to be entered in the output file as an undefined
  107. symbol. Doing this may, for example, trigger linking of additional
  108. modules from standard libraries. You may list several <var>symbol</var>s for
  109. each <code>EXTERN</code>, and you may use <code>EXTERN</code> multiple times. This
  110. command has the same effect as the &lsquo;<samp>-u</samp>&rsquo; command-line option.
  111. </p>
  112. </dd>
  113. <dt><code>FORCE_COMMON_ALLOCATION</code></dt>
  114. <dd><a name="index-FORCE_005fCOMMON_005fALLOCATION"></a>
  115. <a name="index-common-allocation-in-linker-script"></a>
  116. <p>This command has the same effect as the &lsquo;<samp>-d</samp>&rsquo; command-line option:
  117. to make <code>ld</code> assign space to common symbols even if a relocatable
  118. output file is specified (&lsquo;<samp>-r</samp>&rsquo;).
  119. </p>
  120. </dd>
  121. <dt><code>INHIBIT_COMMON_ALLOCATION</code></dt>
  122. <dd><a name="index-INHIBIT_005fCOMMON_005fALLOCATION"></a>
  123. <a name="index-common-allocation-in-linker-script-1"></a>
  124. <p>This command has the same effect as the &lsquo;<samp>--no-define-common</samp>&rsquo;
  125. command-line option: to make <code>ld</code> omit the assignment of addresses
  126. to common symbols even for a non-relocatable output file.
  127. </p>
  128. </dd>
  129. <dt><code>FORCE_GROUP_ALLOCATION</code></dt>
  130. <dd><a name="index-FORCE_005fGROUP_005fALLOCATION"></a>
  131. <a name="index-group-allocation-in-linker-script-1"></a>
  132. <a name="index-section-groups-1"></a>
  133. <a name="index-COMDAT-1"></a>
  134. <p>This command has the same effect as the
  135. &lsquo;<samp>--force-group-allocation</samp>&rsquo; command-line option: to make
  136. <code>ld</code> place section group members like normal input sections,
  137. and to delete the section groups even if a relocatable output file is
  138. specified (&lsquo;<samp>-r</samp>&rsquo;).
  139. </p>
  140. </dd>
  141. <dt><code>INSERT [ AFTER | BEFORE ] <var>output_section</var></code></dt>
  142. <dd><a name="index-INSERT"></a>
  143. <a name="index-insert-user-script-into-default-script"></a>
  144. <p>This command is typically used in a script specified by &lsquo;<samp>-T</samp>&rsquo; to
  145. augment the default <code>SECTIONS</code> with, for example, overlays. It
  146. inserts all prior linker script statements after (or before)
  147. <var>output_section</var>, and also causes &lsquo;<samp>-T</samp>&rsquo; to not override the
  148. default linker script. The exact insertion point is as for orphan
  149. sections. See <a href="Location-Counter.html#Location-Counter">Location Counter</a>. The insertion happens after the
  150. linker has mapped input sections to output sections. Prior to the
  151. insertion, since &lsquo;<samp>-T</samp>&rsquo; scripts are parsed before the default
  152. linker script, statements in the &lsquo;<samp>-T</samp>&rsquo; script occur before the
  153. default linker script statements in the internal linker representation
  154. of the script. In particular, input section assignments will be made
  155. to &lsquo;<samp>-T</samp>&rsquo; output sections before those in the default script. Here
  156. is an example of how a &lsquo;<samp>-T</samp>&rsquo; script using <code>INSERT</code> might look:
  157. </p>
  158. <div class="smallexample">
  159. <pre class="smallexample">SECTIONS
  160. {
  161. OVERLAY :
  162. {
  163. .ov1 { ov1*(.text) }
  164. .ov2 { ov2*(.text) }
  165. }
  166. }
  167. INSERT AFTER .text;
  168. </pre></div>
  169. </dd>
  170. <dt><code>NOCROSSREFS(<var>section</var> <var>section</var> &hellip;)</code></dt>
  171. <dd><a name="index-NOCROSSREFS_0028sections_0029"></a>
  172. <a name="index-cross-references"></a>
  173. <p>This command may be used to tell <code>ld</code> to issue an error about any
  174. references among certain output sections.
  175. </p>
  176. <p>In certain types of programs, particularly on embedded systems when
  177. using overlays, when one section is loaded into memory, another section
  178. will not be. Any direct references between the two sections would be
  179. errors. For example, it would be an error if code in one section called
  180. a function defined in the other section.
  181. </p>
  182. <p>The <code>NOCROSSREFS</code> command takes a list of output section names. If
  183. <code>ld</code> detects any cross references between the sections, it reports
  184. an error and returns a non-zero exit status. Note that the
  185. <code>NOCROSSREFS</code> command uses output section names, not input section
  186. names.
  187. </p>
  188. </dd>
  189. <dt><code>NOCROSSREFS_TO(<var>tosection</var> <var>fromsection</var> &hellip;)</code></dt>
  190. <dd><a name="index-NOCROSSREFS_005fTO_0028tosection-fromsections_0029"></a>
  191. <a name="index-cross-references-1"></a>
  192. <p>This command may be used to tell <code>ld</code> to issue an error about any
  193. references to one section from a list of other sections.
  194. </p>
  195. <p>The <code>NOCROSSREFS</code> command is useful when ensuring that two or more
  196. output sections are entirely independent but there are situations where
  197. a one-way dependency is needed. For example, in a multi-core application
  198. there may be shared code that can be called from each core but for safety
  199. must never call back.
  200. </p>
  201. <p>The <code>NOCROSSREFS_TO</code> command takes a list of output section names.
  202. The first section can not be referenced from any of the other sections.
  203. If <code>ld</code> detects any references to the first section from any of
  204. the other sections, it reports an error and returns a non-zero exit
  205. status. Note that the <code>NOCROSSREFS_TO</code> command uses output section
  206. names, not input section names.
  207. </p>
  208. </dd>
  209. <dt><code>OUTPUT_ARCH(<var>bfdarch</var>)</code></dt>
  210. <dd><a name="index-OUTPUT_005fARCH_0028bfdarch_0029"></a>
  211. <a name="index-machine-architecture"></a>
  212. <a name="index-architecture"></a>
  213. <p>Specify a particular output machine architecture. The argument is one
  214. of the names used by the BFD library (see <a href="BFD.html#BFD">BFD</a>). You can see the
  215. architecture of an object file by using the <code>objdump</code> program with
  216. the &lsquo;<samp>-f</samp>&rsquo; option.
  217. </p>
  218. </dd>
  219. <dt><code>LD_FEATURE(<var>string</var>)</code></dt>
  220. <dd><a name="index-LD_005fFEATURE_0028string_0029"></a>
  221. <p>This command may be used to modify <code>ld</code> behavior. If
  222. <var>string</var> is <code>&quot;SANE_EXPR&quot;</code> then absolute symbols and numbers
  223. in a script are simply treated as numbers everywhere.
  224. See <a href="Expression-Section.html#Expression-Section">Expression Section</a>.
  225. </p></dd>
  226. </dl>
  227. <hr>
  228. <div class="header">
  229. <p>
  230. Previous: <a href="REGION_005fALIAS.html#REGION_005fALIAS" accesskey="p" rel="prev">REGION_ALIAS</a>, Up: <a href="Simple-Commands.html#Simple-Commands" accesskey="u" rel="up">Simple Commands</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>
  231. </div>
  232. </body>
  233. </html>