⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file-commands.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Untitled</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Untitled">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

</head>

<body>

<div class="node">

<p>

Node:<a name="File%20Commands">File Commands</a>,

Next:<a rel="next" accesskey="n" href="Format-Commands.html#Format%20Commands">Format Commands</a>,

Previous:<a rel="previous" accesskey="p" href="Entry-Point.html#Entry%20Point">Entry Point</a>,

Up:<a rel="up" accesskey="u" href="Simple-Commands.html#Simple%20Commands">Simple Commands</a>

<hr><br>

</div>



<h4 class="subsection">Commands dealing with files</h4>



   <p>Several linker script commands deal with files.



     <dl>

<dt><code>INCLUDE </code><var>filename</var><code></code>

     <dd>Include the linker script <var>filename</var> at this point.  The file will

be searched for in the current directory, and in any directory specified

with the <code>-L</code> option.  You can nest calls to <code>INCLUDE</code> up to

10 levels deep.



     <br><dt><code>INPUT(</code><var>file</var><code>, </code><var>file</var><code>, ...)</code>

     <dd><dt><code>INPUT(</code><var>file</var><code> </code><var>file</var><code> ...)</code>

     <dd>The <code>INPUT</code> command directs the linker to include the named files

in the link, as though they were named on the command line.



     <p>For example, if you always want to include <code>subr.o</code> any time you do

a link, but you can't be bothered to put it on every link command line,

then you can put <code>INPUT (subr.o)</code> in your linker script.



     <p>In fact, if you like, you can list all of your input files in the linker

script, and then invoke the linker with nothing but a <code>-T</code> option.



     <p>The linker will first try to open the file in the current directory.  If

it is not found, the linker will search through the archive library

search path.  See the description of <code>-L</code> in <a href="Options.html#Options">Command Line Options</a>.



     <p>If you use <code>INPUT (-l</code><var>file</var><code>)</code>, <code>ld</code> will transform the

name to <code>lib</code><var>file</var><code>.a</code>, as with the command line argument

<code>-l</code>.



     <p>When you use the <code>INPUT</code> command in an implicit linker script, the

files will be included in the link at the point at which the linker

script file is included.  This can affect archive searching.



     <br><dt><code>GROUP(</code><var>file</var><code>, </code><var>file</var><code>, ...)</code>

     <dd><dt><code>GROUP(</code><var>file</var><code> </code><var>file</var><code> ...)</code>

     <dd>The <code>GROUP</code> command is like <code>INPUT</code>, except that the named

files should all be archives, and they are searched repeatedly until no

new undefined references are created.  See the description of <code>-(</code>

in <a href="Options.html#Options">Command Line Options</a>.



     <br><dt><code>OUTPUT(</code><var>filename</var><code>)</code>

     <dd>The <code>OUTPUT</code> command names the output file.  Using

<code>OUTPUT(</code><var>filename</var><code>)</code> in the linker script is exactly like using

<code>-o </code><var>filename</var><code></code> on the command line (see <a href="Options.html#Options">Command Line Options</a>).  If both are used, the command line option takes

precedence.



     <p>You can use the <code>OUTPUT</code> command to define a default name for the

output file other than the usual default of <code>a.out</code>.



     <br><dt><code>SEARCH_DIR(</code><var>path</var><code>)</code>

     <dd>The <code>SEARCH_DIR</code> command adds <var>path</var> to the list of paths where

<code>ld</code> looks for archive libraries.  Using

<code>SEARCH_DIR(</code><var>path</var><code>)</code> is exactly like using <code>-L </code><var>path</var><code></code>

on the command line (see <a href="Options.html#Options">Command Line Options</a>).  If both

are used, then the linker will search both paths.  Paths specified using

the command line option are searched first.



     <br><dt><code>STARTUP(</code><var>filename</var><code>)</code>

     <dd>The <code>STARTUP</code> command is just like the <code>INPUT</code> command, except

that <var>filename</var> will become the first input file to be linked, as

though it were specified first on the command line.  This may be useful

when using a system in which the entry point is always the start of the

first file. 

</dl>



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -