9.5.5.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
chars ; the - character
may be used to specify a range of characters, as in [a-z] to
match any lower case letter |
\ |
quotes the following character |
When a file name is matched with a wildcard, the wildcard characters will not match a /
character (used to separate directory names on UNIX). A pattern consisting of a single *
character is an exception; it will always match any file name, whether it contains a /
or not. In a section name, the wildcard characters will match a /
character.
File name wildcard patterns only match files which are explicitly specified on the command line or in an INPUT
command. The linker does not search directories to expand wild cards.
data.o
rule will not be
used:.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. This can be changed by using the SORT
keyword, which appears before a wildcard pattern in
parentheses (e.g., SORT(.text*)
). When the SORT
keyword is used, the linker will sort the files or
sections into ascending order by name before placing them in the output file.
To verify where the input sections are going, use the -M
linker option to generate a map file. The map file shows precisely how input sections are mapped to output sections.
.text
sections in .text
and all .bss
sections in .bss
. The linker will place
the .data
section from all files beginning with an upper
case character in .DATA
; for all other files, the linker
will place the .data
section in .data
. SECTIONS
{
.text : { *(.text) }
.DATA : { [A-Z]*(.data) }
.data : { *(.data) }
.bss : { *(.bss) }
}