Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

196 linhas
9.6KB

  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>File Commands (LD)</title>
  17. <meta name="description" content="File Commands (LD)">
  18. <meta name="keywords" content="File 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="Format-Commands.html#Format-Commands" rel="next" title="Format Commands">
  27. <link href="Entry-Point.html#Entry-Point" rel="prev" title="Entry Point">
  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="File-Commands"></a>
  58. <div class="header">
  59. <p>
  60. Next: <a href="Format-Commands.html#Format-Commands" accesskey="n" rel="next">Format Commands</a>, Previous: <a href="Entry-Point.html#Entry-Point" accesskey="p" rel="prev">Entry Point</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="Commands-Dealing-with-Files"></a>
  64. <h4 class="subsection">3.4.2 Commands Dealing with Files</h4>
  65. <a name="index-linker-script-file-commands"></a>
  66. <p>Several linker script commands deal with files.
  67. </p>
  68. <dl compact="compact">
  69. <dt><code>INCLUDE <var>filename</var></code></dt>
  70. <dd><a name="index-INCLUDE-filename"></a>
  71. <a name="index-including-a-linker-script"></a>
  72. <p>Include the linker script <var>filename</var> at this point. The file will
  73. be searched for in the current directory, and in any directory specified
  74. with the <samp>-L</samp> option. You can nest calls to <code>INCLUDE</code> up to
  75. 10 levels deep.
  76. </p>
  77. <p>You can place <code>INCLUDE</code> directives at the top level, in <code>MEMORY</code> or
  78. <code>SECTIONS</code> commands, or in output section descriptions.
  79. </p>
  80. </dd>
  81. <dt><code>INPUT(<var>file</var>, <var>file</var>, &hellip;)</code></dt>
  82. <dt><code>INPUT(<var>file</var> <var>file</var> &hellip;)</code></dt>
  83. <dd><a name="index-INPUT_0028files_0029"></a>
  84. <a name="index-input-files-in-linker-scripts"></a>
  85. <a name="index-input-object-files-in-linker-scripts"></a>
  86. <a name="index-linker-script-input-object-files"></a>
  87. <p>The <code>INPUT</code> command directs the linker to include the named files
  88. in the link, as though they were named on the command line.
  89. </p>
  90. <p>For example, if you always want to include <samp>subr.o</samp> any time you do
  91. a link, but you can&rsquo;t be bothered to put it on every link command line,
  92. then you can put &lsquo;<samp>INPUT (subr.o)</samp>&rsquo; in your linker script.
  93. </p>
  94. <p>In fact, if you like, you can list all of your input files in the linker
  95. script, and then invoke the linker with nothing but a &lsquo;<samp>-T</samp>&rsquo; option.
  96. </p>
  97. <p>In case a <em>sysroot prefix</em> is configured, and the filename starts
  98. with the &lsquo;<samp>/</samp>&rsquo; character, and the script being processed was
  99. located inside the <em>sysroot prefix</em>, the filename will be looked
  100. for in the <em>sysroot prefix</em>. The <em>sysroot prefix</em> can also be forced by specifying
  101. <code>=</code> as the first character in the filename path, or prefixing the
  102. filename path with <code>$SYSROOT</code>. See also the description of
  103. &lsquo;<samp>-L</samp>&rsquo; in <a href="Options.html#Options">Command-line Options</a>.
  104. </p>
  105. <p>If a <em>sysroot prefix</em> is not used then the linker will try to open
  106. the file in the directory containing the linker script. If it is not
  107. found the linker will then search the current directory. If it is still
  108. not found the linker will search through the archive library search
  109. path.
  110. </p>
  111. <p>If you use &lsquo;<samp>INPUT (-l<var>file</var>)</samp>&rsquo;, <code>ld</code> will transform the
  112. name to <code>lib<var>file</var>.a</code>, as with the command-line argument
  113. &lsquo;<samp>-l</samp>&rsquo;.
  114. </p>
  115. <p>When you use the <code>INPUT</code> command in an implicit linker script, the
  116. files will be included in the link at the point at which the linker
  117. script file is included. This can affect archive searching.
  118. </p>
  119. </dd>
  120. <dt><code>GROUP(<var>file</var>, <var>file</var>, &hellip;)</code></dt>
  121. <dt><code>GROUP(<var>file</var> <var>file</var> &hellip;)</code></dt>
  122. <dd><a name="index-GROUP_0028files_0029"></a>
  123. <a name="index-grouping-input-files"></a>
  124. <p>The <code>GROUP</code> command is like <code>INPUT</code>, except that the named
  125. files should all be archives, and they are searched repeatedly until no
  126. new undefined references are created. See the description of &lsquo;<samp>-(</samp>&rsquo;
  127. in <a href="Options.html#Options">Command-line Options</a>.
  128. </p>
  129. </dd>
  130. <dt><code>AS_NEEDED(<var>file</var>, <var>file</var>, &hellip;)</code></dt>
  131. <dt><code>AS_NEEDED(<var>file</var> <var>file</var> &hellip;)</code></dt>
  132. <dd><a name="index-AS_005fNEEDED_0028files_0029"></a>
  133. <p>This construct can appear only inside of the <code>INPUT</code> or <code>GROUP</code>
  134. commands, among other filenames. The files listed will be handled
  135. as if they appear directly in the <code>INPUT</code> or <code>GROUP</code> commands,
  136. with the exception of ELF shared libraries, that will be added only
  137. when they are actually needed. This construct essentially enables
  138. <samp>--as-needed</samp> option for all the files listed inside of it
  139. and restores previous <samp>--as-needed</samp> resp. <samp>--no-as-needed</samp>
  140. setting afterwards.
  141. </p>
  142. </dd>
  143. <dt><code>OUTPUT(<var>filename</var>)</code></dt>
  144. <dd><a name="index-OUTPUT_0028filename_0029"></a>
  145. <a name="index-output-file-name-in-linker-script"></a>
  146. <p>The <code>OUTPUT</code> command names the output file. Using
  147. <code>OUTPUT(<var>filename</var>)</code> in the linker script is exactly like using
  148. &lsquo;<samp>-o <var>filename</var></samp>&rsquo; on the command line (see <a href="Options.html#Options">Command
  149. Line Options</a>). If both are used, the command-line option takes
  150. precedence.
  151. </p>
  152. <p>You can use the <code>OUTPUT</code> command to define a default name for the
  153. output file other than the usual default of <samp>a.out</samp>.
  154. </p>
  155. </dd>
  156. <dt><code>SEARCH_DIR(<var>path</var>)</code></dt>
  157. <dd><a name="index-SEARCH_005fDIR_0028path_0029"></a>
  158. <a name="index-library-search-path-in-linker-script"></a>
  159. <a name="index-archive-search-path-in-linker-script"></a>
  160. <a name="index-search-path-in-linker-script"></a>
  161. <p>The <code>SEARCH_DIR</code> command adds <var>path</var> to the list of paths where
  162. <code>ld</code> looks for archive libraries. Using
  163. <code>SEARCH_DIR(<var>path</var>)</code> is exactly like using &lsquo;<samp>-L <var>path</var></samp>&rsquo;
  164. on the command line (see <a href="Options.html#Options">Command-line Options</a>). If both
  165. are used, then the linker will search both paths. Paths specified using
  166. the command-line option are searched first.
  167. </p>
  168. </dd>
  169. <dt><code>STARTUP(<var>filename</var>)</code></dt>
  170. <dd><a name="index-STARTUP_0028filename_0029"></a>
  171. <a name="index-first-input-file"></a>
  172. <p>The <code>STARTUP</code> command is just like the <code>INPUT</code> command, except
  173. that <var>filename</var> will become the first input file to be linked, as
  174. though it were specified first on the command line. This may be useful
  175. when using a system in which the entry point is always the start of the
  176. first file.
  177. </p></dd>
  178. </dl>
  179. <hr>
  180. <div class="header">
  181. <p>
  182. Next: <a href="Format-Commands.html#Format-Commands" accesskey="n" rel="next">Format Commands</a>, Previous: <a href="Entry-Point.html#Entry-Point" accesskey="p" rel="prev">Entry Point</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>
  183. </div>
  184. </body>
  185. </html>