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

📄 input-section-basics.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="Input%20Section%20Basics">Input Section Basics</a>,

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

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

<hr><br>

</div>



<h5 class="subsubsection">Input section basics</h5>



   <p>An input section description consists of a file name optionally followed

by a list of section names in parentheses.



   <p>The file name and the section name may be wildcard patterns, which we

describe further below (see <a href="Input-Section-Wildcards.html#Input%20Section%20Wildcards">Input Section Wildcards</a>).



   <p>The most common input section description is to include all input

sections with a particular name in the output section.  For example, to

include all input <code>.text</code> sections, you would write:

<pre class="smallexample">     *(.text)

     </pre>



<p>Here the <code>*</code> is a wildcard which matches any file name.  To exclude a list

of files from matching the file name wildcard, EXCLUDE_FILE may be used to

match all files except the ones specified in the EXCLUDE_FILE list.  For

example:

<pre class="smallexample">     (*(EXCLUDE_FILE (*crtend.o *otherfile.o) .ctors))

     </pre>

   will cause all .ctors sections from all files except <code>crtend.o</code> and

<code>otherfile.o</code> to be included.



   <p>There are two ways to include more than one section:

<pre class="smallexample">     *(.text .rdata)

     *(.text) *(.rdata)

     </pre>



<p>The difference between these is the order in which the <code>.text</code> and

<code>.rdata</code> input sections will appear in the output section.  In the

first example, they will be intermingled, appearing in the same order as

they are found in the linker input.  In the second example, all

<code>.text</code> input sections will appear first, followed by all

<code>.rdata</code> input sections.



   <p>You can specify a file name to include sections from a particular file. 

You would do this if one or more of your files contain special data that

needs to be at a particular location in memory.  For example:

<pre class="smallexample">     data.o(.data)

     </pre>



   <p>If you use a file name without a list of sections, then all sections in

the input file will be included in the output section.  This is not

commonly done, but it may by useful on occasion.  For example:

<pre class="smallexample">     data.o

     </pre>



   <p>When you use a file name which does not contain any wild card

characters, the linker will first see if you also specified the file

name on the linker command line or in an <code>INPUT</code> command.  If you

did not, the linker will attempt to open the file as an input file, as

though it appeared on the command line.  Note that this differs from an

<code>INPUT</code> command, because the linker will not search for the file in

the archive search path.



   </body></html>



⌨️ 快捷键说明

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