forked from Imagelibrary/binutils-gdb
Make some improvements to how SORT_* specifiers and EXCLUDE_FILE specifiers are handled in the linker script grammar.
* ldgram.y (ldgram_had_keep): Make static. (ldgram_vers_current_lang): Likewise. (filename_spec): New rule. (input_section_spec_no_keep): Use filename_spec. (wildcard_maybe_exclude): New rule. (wildcard_spec): Rename to... (section_name_spec): ...this. (section_NAME_list): Rename to... (section_name_list): ...this. (section_name_spec): Simplifiy and use wildcard_maybe_exclude. * ldlang.c (placed_commons): Delete. (lang_add_wild): No longer set placed_commons. (print_wild_statement): Use full names for SORT specifiers. * testsuite/ld-scripts/align.exp: Run new tests. * testsuite/ld-scripts/align3.d: New file. * testsuite/ld-scripts/align3.t: New file. * testsuite/ld-scripts/align4.d: New file. * testsuite/ld-scripts/align4.t: New file. * testsuite/ld-scripts/align5.d: New file. * testsuite/ld-scripts/align5.t: New file. * testsuite/ld-scripts/exclude-file-5.d: New file. * testsuite/ld-scripts/exclude-file-5.map: New file. * testsuite/ld-scripts/exclude-file-5.t: New file. * testsuite/ld-scripts/exclude-file-6.d: New file. * testsuite/ld-scripts/exclude-file-6.map: New file. * testsuite/ld-scripts/exclude-file-6.t: New file. * NEWS: Mention the changes.
This commit is contained in:
committed by
Nick Clifton
parent
a808670465
commit
2b94abd48a
@@ -47,6 +47,9 @@ if ![ld_link $ld tmpdir/align "$LDFLAGS -T $srcdir/$subdir/align.t tmpdir/align.
|
||||
if ![is_aout_format] {
|
||||
run_dump_test align2a
|
||||
run_dump_test align2b
|
||||
run_dump_test align3
|
||||
run_dump_test align4
|
||||
run_dump_test align5
|
||||
}
|
||||
run_dump_test align2c
|
||||
set LDFLAGS "$saved_LDFLAGS"
|
||||
|
||||
3
ld/testsuite/ld-scripts/align3.d
Normal file
3
ld/testsuite/ld-scripts/align3.d
Normal file
@@ -0,0 +1,3 @@
|
||||
# source: align2a.s
|
||||
# ld: -T align3.t
|
||||
# error: .*:4: syntax error
|
||||
10
ld/testsuite/ld-scripts/align3.t
Normal file
10
ld/testsuite/ld-scripts/align3.t
Normal file
@@ -0,0 +1,10 @@
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
SORT_BY_ALIGNMENT (*) (.text .text.*)
|
||||
}
|
||||
|
||||
.data : {
|
||||
SORT_BY_ALIGNMENT (*) (.data .data.*)
|
||||
}
|
||||
}
|
||||
3
ld/testsuite/ld-scripts/align4.d
Normal file
3
ld/testsuite/ld-scripts/align4.d
Normal file
@@ -0,0 +1,3 @@
|
||||
# source: align2a.s
|
||||
# ld: -T align4.t
|
||||
# error: .*:4: syntax error
|
||||
10
ld/testsuite/ld-scripts/align4.t
Normal file
10
ld/testsuite/ld-scripts/align4.t
Normal file
@@ -0,0 +1,10 @@
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
SORT_BY_INIT_PRIORITY (*) (.text .text.*)
|
||||
}
|
||||
|
||||
.data : {
|
||||
SORT_BY_INIT_PRIORITY (*) (.data .data.*)
|
||||
}
|
||||
}
|
||||
7
ld/testsuite/ld-scripts/align5.d
Normal file
7
ld/testsuite/ld-scripts/align5.d
Normal file
@@ -0,0 +1,7 @@
|
||||
# source: align2a.s
|
||||
# ld: -T align5.t
|
||||
# nm: -n
|
||||
|
||||
#...
|
||||
.*foo
|
||||
#...
|
||||
12
ld/testsuite/ld-scripts/align5.t
Normal file
12
ld/testsuite/ld-scripts/align5.t
Normal file
@@ -0,0 +1,12 @@
|
||||
SECTIONS
|
||||
{
|
||||
.text : {
|
||||
SORT_NONE (*) (.text .text.*)
|
||||
}
|
||||
|
||||
.data : {
|
||||
SORT_NONE (*) (.data .data.*)
|
||||
foo = .;
|
||||
}
|
||||
/DISCARD/ : {*(*)}
|
||||
}
|
||||
5
ld/testsuite/ld-scripts/exclude-file-5.d
Normal file
5
ld/testsuite/ld-scripts/exclude-file-5.d
Normal file
@@ -0,0 +1,5 @@
|
||||
#source: exclude-file-a.s
|
||||
#source: exclude-file-b.s
|
||||
#ld: -T exclude-file-5.t
|
||||
#map: exclude-file-5.map
|
||||
|
||||
8
ld/testsuite/ld-scripts/exclude-file-5.map
Normal file
8
ld/testsuite/ld-scripts/exclude-file-5.map
Normal file
@@ -0,0 +1,8 @@
|
||||
#...
|
||||
\.data +0x[0-9a-f]+ +0x[0-9a-f]+
|
||||
\*\(SORT_BY_NAME\(EXCLUDE_FILE\(\*-b\.o\) \.data\)\)
|
||||
\.data +0x[0-9a-f]+ +0x[0-9a-f]+ tmpdir/exclude-file-a\.o
|
||||
\*\(SORT_BY_NAME\(EXCLUDE_FILE\(\*-a\.o\) \.data\.\*\)\)
|
||||
\.data\.1 +0x[0-9a-f]+ +0x[0-9a-f]+ tmpdir/exclude-file-b\.o
|
||||
|
||||
#...
|
||||
11
ld/testsuite/ld-scripts/exclude-file-5.t
Normal file
11
ld/testsuite/ld-scripts/exclude-file-5.t
Normal file
@@ -0,0 +1,11 @@
|
||||
SECTIONS
|
||||
{
|
||||
.data : {
|
||||
* (SORT_BY_NAME (EXCLUDE_FILE (*-b.o) .data))
|
||||
* (SORT_BY_NAME (SORT_BY_NAME (EXCLUDE_FILE (*-a.o) .data.*)))
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
* (*)
|
||||
}
|
||||
}
|
||||
5
ld/testsuite/ld-scripts/exclude-file-6.d
Normal file
5
ld/testsuite/ld-scripts/exclude-file-6.d
Normal file
@@ -0,0 +1,5 @@
|
||||
#source: exclude-file-a.s
|
||||
#source: exclude-file-b.s
|
||||
#ld: -T exclude-file-6.t
|
||||
#map: exclude-file-6.map
|
||||
|
||||
8
ld/testsuite/ld-scripts/exclude-file-6.map
Normal file
8
ld/testsuite/ld-scripts/exclude-file-6.map
Normal file
@@ -0,0 +1,8 @@
|
||||
#...
|
||||
\.data +0x[0-9a-f]+ +0x[0-9a-f]+
|
||||
\*\(SORT_BY_ALIGNMENT\(SORT_BY_NAME\(EXCLUDE_FILE\(\*-b\.o\) \.data\)\)\)
|
||||
\.data +0x[0-9a-f]+ +0x[0-9a-f]+ tmpdir/exclude-file-a\.o
|
||||
\*\(SORT_BY_NAME\(SORT_BY_ALIGNMENT\(EXCLUDE_FILE\(\*-a\.o\) \.data\.\*\)\)\)
|
||||
\.data\.1 +0x[0-9a-f]+ +0x[0-9a-f]+ tmpdir/exclude-file-b\.o
|
||||
|
||||
#...
|
||||
11
ld/testsuite/ld-scripts/exclude-file-6.t
Normal file
11
ld/testsuite/ld-scripts/exclude-file-6.t
Normal file
@@ -0,0 +1,11 @@
|
||||
SECTIONS
|
||||
{
|
||||
.data : {
|
||||
* (SORT_BY_ALIGNMENT (SORT_BY_NAME (EXCLUDE_FILE (*-b.o) .data)))
|
||||
* (SORT_BY_NAME (SORT_BY_ALIGNMENT (EXCLUDE_FILE (*-a.o) .data.*)))
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
* (*)
|
||||
}
|
||||
}
|
||||
5
ld/testsuite/ld-scripts/exclude-file-7.d
Normal file
5
ld/testsuite/ld-scripts/exclude-file-7.d
Normal file
@@ -0,0 +1,5 @@
|
||||
#source: exclude-file-a.s
|
||||
#source: exclude-file-b.s
|
||||
#ld: -T exclude-file-7.t
|
||||
#map: exclude-file-7.map
|
||||
|
||||
8
ld/testsuite/ld-scripts/exclude-file-7.map
Normal file
8
ld/testsuite/ld-scripts/exclude-file-7.map
Normal file
@@ -0,0 +1,8 @@
|
||||
#...
|
||||
\.data +0x[0-9a-f]+ +0x[0-9a-f]+
|
||||
\*\(SORT_BY_INIT_PRIORITY\(EXCLUDE_FILE\(\*-b\.o\) \.data\)\)
|
||||
\.data +0x[0-9a-f]+ +0x[0-9a-f]+ tmpdir/exclude-file-a\.o
|
||||
\*\(SORT_BY_ALIGNMENT\(EXCLUDE_FILE\(\*-a\.o\) \.data\.\*\)\)
|
||||
\.data\.1 +0x[0-9a-f]+ +0x[0-9a-f]+ tmpdir/exclude-file-b\.o
|
||||
|
||||
#...
|
||||
11
ld/testsuite/ld-scripts/exclude-file-7.t
Normal file
11
ld/testsuite/ld-scripts/exclude-file-7.t
Normal file
@@ -0,0 +1,11 @@
|
||||
SECTIONS
|
||||
{
|
||||
.data : {
|
||||
* (SORT_BY_INIT_PRIORITY (EXCLUDE_FILE (*-b.o) .data))
|
||||
* (SORT_BY_ALIGNMENT (SORT_BY_ALIGNMENT (EXCLUDE_FILE (*-a.o) .data.*)))
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
* (*)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user