• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/ld.html/
1<html lang="en">
2<head>
3<title>Input Section Basics - Untitled</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Untitled">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Input-Section.html#Input-Section" title="Input Section">
9<link rel="next" href="Input-Section-Wildcards.html#Input-Section-Wildcards" title="Input Section Wildcards">
10<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
11<!--
12This file documents the GNU linker LD
13(Sourcery CodeBench Lite 2011.09-69)
14version 2.21.53.
15
16Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
172001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
18
19Permission is granted to copy, distribute and/or modify this document
20under the terms of the GNU Free Documentation License, Version 1.3
21or any later version published by the Free Software Foundation;
22with no Invariant Sections, with no Front-Cover Texts, and with no
23Back-Cover Texts.  A copy of the license is included in the
24section entitled ``GNU Free Documentation License''.-->
25<meta http-equiv="Content-Style-Type" content="text/css">
26<style type="text/css"><!--
27  pre.display { font-family:inherit }
28  pre.format  { font-family:inherit }
29  pre.smalldisplay { font-family:inherit; font-size:smaller }
30  pre.smallformat  { font-family:inherit; font-size:smaller }
31  pre.smallexample { font-size:smaller }
32  pre.smalllisp    { font-size:smaller }
33  span.sc    { font-variant:small-caps }
34  span.roman { font-family:serif; font-weight:normal; } 
35  span.sansserif { font-family:sans-serif; font-weight:normal; } 
36--></style>
37<link rel="stylesheet" type="text/css" href="../cs.css">
38</head>
39<body>
40<div class="node">
41<a name="Input-Section-Basics"></a>
42<p>
43Next:&nbsp;<a rel="next" accesskey="n" href="Input-Section-Wildcards.html#Input-Section-Wildcards">Input Section Wildcards</a>,
44Up:&nbsp;<a rel="up" accesskey="u" href="Input-Section.html#Input-Section">Input Section</a>
45<hr>
46</div>
47
48<h5 class="subsubsection">3.6.4.1 Input Section Basics</h5>
49
50<p><a name="index-input-section-basics-407"></a>An input section description consists of a file name optionally followed
51by a list of section names in parentheses.
52
53   <p>The file name and the section name may be wildcard patterns, which we
54describe further below (see <a href="Input-Section-Wildcards.html#Input-Section-Wildcards">Input Section Wildcards</a>).
55
56   <p>The most common input section description is to include all input
57sections with a particular name in the output section.  For example, to
58include all input &lsquo;<samp><span class="samp">.text</span></samp>&rsquo; sections, you would write:
59<pre class="smallexample">     *(.text)
60</pre>
61   <p class="noindent">Here the &lsquo;<samp><span class="samp">*</span></samp>&rsquo; is a wildcard which matches any file name.  To exclude a list
62of files from matching the file name wildcard, EXCLUDE_FILE may be used to
63match all files except the ones specified in the EXCLUDE_FILE list.  For
64example:
65<pre class="smallexample">     *(EXCLUDE_FILE (*crtend.o *otherfile.o) .ctors)
66</pre>
67   <p>will cause all .ctors sections from all files except <samp><span class="file">crtend.o</span></samp> and
68<samp><span class="file">otherfile.o</span></samp> to be included.
69
70   <p>There are two ways to include more than one section:
71<pre class="smallexample">     *(.text .rdata)
72     *(.text) *(.rdata)
73</pre>
74   <p class="noindent">The difference between these is the order in which the &lsquo;<samp><span class="samp">.text</span></samp>&rsquo; and
75&lsquo;<samp><span class="samp">.rdata</span></samp>&rsquo; input sections will appear in the output section.  In the
76first example, they will be intermingled, appearing in the same order as
77they are found in the linker input.  In the second example, all
78&lsquo;<samp><span class="samp">.text</span></samp>&rsquo; input sections will appear first, followed by all
79&lsquo;<samp><span class="samp">.rdata</span></samp>&rsquo; input sections.
80
81   <p>You can specify a file name to include sections from a particular file. 
82You would do this if one or more of your files contain special data that
83needs to be at a particular location in memory.  For example:
84<pre class="smallexample">     data.o(.data)
85</pre>
86   <p>To refine the sections that are included based on the section flags
87of an input section, INPUT_SECTION_FLAGS may be used.
88
89   <p>Here is a simple example for using Section header flags for ELF sections:
90
91<pre class="smallexample">     SECTIONS {
92       .text : { INPUT_SECTION_FLAGS (SHF_MERGE &amp; SHF_STRINGS) *(.text) }
93       .text2 :  { INPUT_SECTION_FLAGS (!SHF_WRITE) *(.text) }
94     }
95</pre>
96   <p>In this example, the output section &lsquo;<samp><span class="samp">.text</span></samp>&rsquo; will be comprised of any
97input section matching the name *(.text) whose section header flags
98<code>SHF_MERGE</code> and <code>SHF_STRINGS</code> are set.  The output section
99&lsquo;<samp><span class="samp">.text2</span></samp>&rsquo; will be comprised of any input section matching the name *(.text)
100whose section header flag <code>SHF_WRITE</code> is clear.
101
102   <p>You can also specify files within archives by writing a pattern
103matching the archive, a colon, then the pattern matching the file,
104with no whitespace around the colon.
105
106     <dl>
107<dt>&lsquo;<samp><span class="samp">archive:file</span></samp>&rsquo;<dd>matches file within archive
108<br><dt>&lsquo;<samp><span class="samp">archive:</span></samp>&rsquo;<dd>matches the whole archive
109<br><dt>&lsquo;<samp><span class="samp">:file</span></samp>&rsquo;<dd>matches file but not one in an archive
110</dl>
111
112   <p>Either one or both of &lsquo;<samp><span class="samp">archive</span></samp>&rsquo; and &lsquo;<samp><span class="samp">file</span></samp>&rsquo; can contain shell
113wildcards.  On DOS based file systems, the linker will assume that a
114single letter followed by a colon is a drive specifier, so
115&lsquo;<samp><span class="samp">c:myfile.o</span></samp>&rsquo; is a simple file specification, not &lsquo;<samp><span class="samp">myfile.o</span></samp>&rsquo;
116within an archive called &lsquo;<samp><span class="samp">c</span></samp>&rsquo;.  &lsquo;<samp><span class="samp">archive:file</span></samp>&rsquo; filespecs may
117also be used within an <code>EXCLUDE_FILE</code> list, but may not appear in
118other linker script contexts.  For instance, you cannot extract a file
119from an archive by using &lsquo;<samp><span class="samp">archive:file</span></samp>&rsquo; in an <code>INPUT</code>
120command.
121
122   <p>If you use a file name without a list of sections, then all sections in
123the input file will be included in the output section.  This is not
124commonly done, but it may by useful on occasion.  For example:
125<pre class="smallexample">     data.o
126</pre>
127   <p>When you use a file name which is not an &lsquo;<samp><span class="samp">archive:file</span></samp>&rsquo; specifier
128and does not contain any wild card
129characters, the linker will first see if you also specified the file
130name on the linker command line or in an <code>INPUT</code> command.  If you
131did not, the linker will attempt to open the file as an input file, as
132though it appeared on the command line.  Note that this differs from an
133<code>INPUT</code> command, because the linker will not search for the file in
134the archive search path.
135
136   </body></html>
137
138