📄 input-section-wildcards.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%20Wildcards">Input Section Wildcards</a>,
Next:<a rel="next" accesskey="n" href="Input-Section-Common.html#Input%20Section%20Common">Input Section Common</a>,
Previous:<a rel="previous" accesskey="p" href="Input-Section-Basics.html#Input%20Section%20Basics">Input Section Basics</a>,
Up:<a rel="up" accesskey="u" href="Input-Section.html#Input%20Section">Input Section</a>
<hr><br>
</div>
<h5 class="subsubsection">Input section wildcard patterns</h5>
<p>In an input section description, either the file name or the section
name or both may be wildcard patterns.
<p>The file name of <code>*</code> seen in many examples is a simple wildcard
pattern for the file name.
<p>The wildcard patterns are like those used by the Unix shell.
<dl>
<dt><code>*</code>
<dd>matches any number of characters
<br><dt><code>?</code>
<dd>matches any single character
<br><dt><code>[</code><var>chars</var><code>]</code>
<dd>matches a single instance of any of the <var>chars</var>; the <code>-</code>
character may be used to specify a range of characters, as in
<code>[a-z]</code> to match any lower case letter
<br><dt><code>\</code>
<dd>quotes the following character
</dl>
<p>When a file name is matched with a wildcard, the wildcard characters
will not match a <code>/</code> character (used to separate directory names on
Unix). A pattern consisting of a single <code>*</code> character is an
exception; it will always match any file name, whether it contains a
<code>/</code> or not. In a section name, the wildcard characters will match
a <code>/</code> character.
<p>File name wildcard patterns only match files which are explicitly
specified on the command line or in an <code>INPUT</code> command. The linker
does not search directories to expand wildcards.
<p>If a file name matches more than one wildcard pattern, or if a file name
appears explicitly and is also matched by a wildcard pattern, the linker
will use the first match in the linker script. For example, this
sequence of input section descriptions is probably in error, because the
<code>data.o</code> rule will not be used:
<pre class="smallexample"> .data : { *(.data) }
.data1 : { data.o(.data) }
</pre>
<p>Normally, the linker will place files and sections matched by wildcards
in the order in which they are seen during the link. You can change
this by using the <code>SORT</code> keyword, which appears before a wildcard
pattern in parentheses (e.g., <code>SORT(.text*)</code>). When the
<code>SORT</code> keyword is used, the linker will sort the files or sections
into ascending order by name before placing them in the output file.
<p>If you ever get confused about where input sections are going, use the
<code>-M</code> linker option to generate a map file. The map file shows
precisely how input sections are mapped to output sections.
<p>This example shows how wildcard patterns might be used to partition
files. This linker script directs the linker to place all <code>.text</code>
sections in <code>.text</code> and all <code>.bss</code> sections in <code>.bss</code>.
The linker will place the <code>.data</code> section from all files beginning
with an upper case character in <code>.DATA</code>; for all other files, the
linker will place the <code>.data</code> section in <code>.data</code>.
<pre class="smallexample"> SECTIONS {
.text : { *(.text) }
.DATA : { [A-Z]*(.data) }
.data : { *(.data) }
.bss : { *(.bss) }
}
</pre>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -