38
4.6.4.2. Input Section Wildcard Patterns
In an input section description, either the file name or the section name or both may be wildcard
patterns.
The file name of
seen in many examples is a simple wildcard pattern for the file name.
*
The wildcard patterns are like those used by the Unix shell.
*
matches any number of characters
?
matches any single character
[
]
chars
matches a single instance of any of the
characters, as in
\
quotes the following character
When a file name is matched with a wildcard, the wildcard characters will not match a
(used to separate directory names on Unix). A pattern consisting of a single
it will always match any file name, whether it contains a
characters will match a
File name wildcard patterns only match files which are explicitly specified on the command line or in
an
command. The linker does not search directories to expand wildcards.
INPUT
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
.data : { *(.data) }
.data1 : { data.o(.data) }
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
wildcard pattern in parentheses (e.g.,
will sort the files or sections into ascending order by name before placing them in the output file.
If you ever get confused about where input sections are going, use the
map file. The map file shows precisely how input sections are mapped to output sections.
This example shows how wildcard patterns might be used to partition files. This linker script directs
the linker to place all
the
section from all files beginning with an upper case character in
.data
the linker will place the
SECTIONS {
.text : { *(.text) }
.DATA : { [A-Z]*(.data) }
.data : { *(.data) }
.bss : { *(.bss) }
}
to match any lower case letter
[a-z]
character.
/
SORT(.text*)
sections in
.text
.text
section in
.data
.data
; the
character may be used to specify a range of
chars
-
or not. In a section name, the wildcard
/
SORT
). When the
and all
sections in
.bss
.
Chapter 4. Linker Scripts
character is an exception;
*
rule will not be used:
data.o
keyword, which appears before a
keyword is used, the linker
SORT
linker option to generate a
-M
. The linker will place
.bss
; for all other files,
.DATA
character
/
Need help?
Do you have a question about the ENTERPRISE LINUX 4 - USING ID and is the answer not in the manual?
Questions and answers