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:
Andrew Burgess
2017-07-28 13:01:10 +01:00
committed by Nick Clifton
parent a808670465
commit 2b94abd48a
20 changed files with 250 additions and 66 deletions

View File

@@ -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"

View File

@@ -0,0 +1,3 @@
# source: align2a.s
# ld: -T align3.t
# error: .*:4: syntax error

View File

@@ -0,0 +1,10 @@
SECTIONS
{
.text : {
SORT_BY_ALIGNMENT (*) (.text .text.*)
}
.data : {
SORT_BY_ALIGNMENT (*) (.data .data.*)
}
}

View File

@@ -0,0 +1,3 @@
# source: align2a.s
# ld: -T align4.t
# error: .*:4: syntax error

View File

@@ -0,0 +1,10 @@
SECTIONS
{
.text : {
SORT_BY_INIT_PRIORITY (*) (.text .text.*)
}
.data : {
SORT_BY_INIT_PRIORITY (*) (.data .data.*)
}
}

View File

@@ -0,0 +1,7 @@
# source: align2a.s
# ld: -T align5.t
# nm: -n
#...
.*foo
#...

View File

@@ -0,0 +1,12 @@
SECTIONS
{
.text : {
SORT_NONE (*) (.text .text.*)
}
.data : {
SORT_NONE (*) (.data .data.*)
foo = .;
}
/DISCARD/ : {*(*)}
}

View 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

View 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
#...

View 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/ : {
* (*)
}
}

View 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

View 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
#...

View 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/ : {
* (*)
}
}

View 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

View 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
#...

View 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/ : {
* (*)
}
}