binutils-gdb/ld/testsuite/ld-scripts
Andrew Burgess 8f1732fc2a ld: Allow EXCLUDE_FILE to be used outside of the section list
Currently the EXCLUDE_FILE linker script construct can only be used
within the input section list, and applied only to the section pattern
immediately following the EXCLUDE_FILE.  For example:

    *.o (EXCLUDE_FILE (a.o) .text .rodata)

In this case all sections matching '.text' are included from all files
matching '*.o' but not from the file 'a.o'.  All sections matching
'.rodata' are also included from all files matching '*.o' (incluing from
'a.o').

If the user wants to restrict the inclusion of section '.rodata' so that
this too is not taken from the file 'a.o' then the above example must be
extended like this:

    *.o (EXCLUDE_FILE (a.o) .text EXCLUDE_FILE (a.o) .rodata)

However, due to the internal grammar of the linker script language the
snippet 'EXCLUDE_FILE (a.o) .text' is parsed by a pattern called
'wildcard_spec'.  The same 'wildcard_spec' pattern is also used to parse
the input file name snippet '*.o' in the above examples.  As a result of
this pattern reuse within the linker script grammar then the following
is also a valid linker script construct:

    EXCLUDE_FILE (a.o) *.o (.text .rodata)

However, though the linker accepts this without complaint the
EXCLUDE_FILE part is silently ignored and has no effect.

This commit takes this last example and makes it a useful, valid,
construct.  The last example now means to include sections '.text' and
'.rodata' from all files matching '*.o' except for the file 'a.o'.

If the list of input sections is long, and the user knows that the file
exclusion applies across the list then the second form might be a
clearer alternative to replicating the EXCLUDE_FILE construct.

I've added a set of tests for EXCLUDE_FILE to the linker, including
tests for the new functionality.

ld/ChangeLog:

	* ldlang.h (struct lang_wild_statement_struct): Add
	exclude_name_list field.
	* ldlang.c (walk_wild_file_in_exclude_list): New function.
	(walk_wild_consider_section): Use new
	walk_wild_file_in_exclude_list function.
	(walk_wild_file): Add call to walk_wild_file_in_exclude_list.
	(print_wild_statement): Print new exclude_name_list field.
	(lang_add_wild): Initialise new exclude_name_list field.
	* testsuite/ld-scripts/exclude-file-1.d: New file.
	* testsuite/ld-scripts/exclude-file-1.map: New file.
	* testsuite/ld-scripts/exclude-file-1.t: New file.
	* testsuite/ld-scripts/exclude-file-2.d: New file.
	* testsuite/ld-scripts/exclude-file-2.map: New file.
	* testsuite/ld-scripts/exclude-file-2.t: New file.
	* testsuite/ld-scripts/exclude-file-3.d: New file.
	* testsuite/ld-scripts/exclude-file-3.map: New file.
	* testsuite/ld-scripts/exclude-file-3.t: New file.
	* testsuite/ld-scripts/exclude-file-4.d: New file.
	* testsuite/ld-scripts/exclude-file-4.map: New file.
	* testsuite/ld-scripts/exclude-file-4.t: New file.
	* testsuite/ld-scripts/exclude-file-a.s: New file.
	* testsuite/ld-scripts/exclude-file-b.s: New file.
	* testsuite/ld-scripts/exclude-file.exp: New file.
	* ld.texinfo (Input Section Basics): Update description of
	EXCLUDE_FILE to cover the new features.
	* NEWS: Mention new EXCLUDE_FILE usage.
2016-11-04 12:04:11 +00:00
..
align-with-input.d
align-with-input.t
align.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
align.s
align.t Fix linker testsuite failures for arm-pe targets. 2016-01-20 15:41:06 +00:00
align2.t
align2a.d
align2a.s
align2b.d
align2b.s
align2c.d
align2c.s
alignof.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
alignof.s
alignof.t
assert.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
assert.s
assert.t
assert2.d
assert2.t
assign-loc.d
assign-loc.t
cross1.c
cross1.t
cross2.c
cross2.t Hack crossref tests for powerpc64 2016-05-19 14:07:06 +09:30
cross3.c
cross3.t Hack crossref tests for powerpc64 2016-05-19 14:07:06 +09:30
cross4.c
cross4.t Hack crossref tests for powerpc64 2016-05-19 14:07:06 +09:30
cross5.t Hack crossref tests for powerpc64 2016-05-19 14:07:06 +09:30
cross6.t Hack crossref tests for powerpc64 2016-05-19 14:07:06 +09:30
cross7.t Hack crossref tests for powerpc64 2016-05-19 14:07:06 +09:30
crossref.exp Hack crossref tests for powerpc64 2016-05-19 14:07:06 +09:30
data.d
data.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
data.s
data.t
default-script.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
default-script.s
default-script.t
default-script1.d
default-script2.d
default-script3.d
default-script4.d
defined.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
defined.s
defined.t
defined2.d
defined2.t
defined3.d
defined3.t
defined4.d
defined4.s
defined4.t
defined5.d
defined5.s
defined5.t
defined6.d
defined6.s
defined6.t
dynamic-sections-1.s
dynamic-sections-2.s
dynamic-sections.d
dynamic-sections.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
dynamic-sections.t
empty-address-1.d
empty-address-1.s
empty-address-1.t
empty-address-2.s
empty-address-2a.d
empty-address-2a.t
empty-address-2b.d
empty-address-2b.t
empty-address-3.s
empty-address-3a.d
empty-address-3a.t
empty-address-3b.d
empty-address-3b.t
empty-address-3c.d
empty-address-3c.t
empty-address.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
empty-aligned.d
empty-aligned.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
empty-aligned.s
empty-aligned.t
empty-orphan.d
empty-orphan.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
empty-orphan.s
empty-orphan.t
exclude-file-1.d ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-1.map ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-1.t ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-2.d ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-2.map ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-2.t ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-3.d ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-3.map ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-3.t ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-4.d ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-4.map ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-4.t ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-a.s ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file-b.s ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
exclude-file.exp ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
expr.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
expr1.d
expr1.s
expr1.t
expr2.d
expr2.s
expr2.t
extern.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
extern.s
extern.t
fill.d
fill.t
fill_0.s
fill_1.s
fill_2.s
include-1.d
include-1.t
include-data.t
include-mem.t
include-ram.t
include-sections.t
include-subdata.t
include.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
include.s
log2.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
log2.s
log2.t
map-address.d
map-address.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
map-address.t
memory.t Allow symbols in MEMORY region specification 2015-01-28 15:06:48 +10:30
memory_sym.t Allow symbols in MEMORY region specification 2015-01-28 15:06:48 +10:30
overlay-size-map.d
overlay-size.d Fix RX and M68HC11 linker testsuite failures. 2016-06-28 12:43:14 +01:00
overlay-size.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
overlay-size.s
overlay-size.t
phdrs.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
phdrs.s
phdrs.t
phdrs2.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
phdrs2.s
phdrs2.t
phdrs3.d
phdrs3.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
phdrs3.t
phdrs3a.d
phdrs3a.t
pr14962-2.d
pr14962-2.t Correct script input section pattern 2016-05-09 17:07:33 +09:30
pr14962.d
pr14962.t
pr14962a.s
pr14962b.s
pr18963.d Delay converting linker script defined symbols from absolute 2015-09-18 12:39:16 +09:30
pr18963.t Delay converting linker script defined symbols from absolute 2015-09-18 12:39:16 +09:30
pr20302.d Don't run ld-scripts/pr20302 on linuxaout 2016-06-28 19:09:11 +09:30
print-memory-usage-1.l Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage-1.s Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage-1.t Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage-2.l Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage-2.t Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage-3.l Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage-3.s Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage-3.t Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
print-memory-usage.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
print-memory-usage.t Add new ld option: --print-memory-usage 2015-06-12 11:24:36 +02:00
provide-1.d
provide-1.s
provide-1.t
provide-2.d
provide-2.s
provide-2.t
provide-3.d
provide-3.s
provide-3.t
provide-4-map.d ld: Update expected test results for 32-bit hosts. 2015-01-20 16:03:32 +00:00
provide-4.d ld: Don't evaluate unneeded PROVIDE expressions. 2015-01-20 09:49:27 +00:00
provide-4.t ld: Don't evaluate unneeded PROVIDE expressions. 2015-01-20 09:49:27 +00:00
provide-5-map.d ld: Update expected test results for 32-bit hosts. 2015-01-20 16:03:32 +00:00
provide-5.d ld: Don't evaluate unneeded PROVIDE expressions. 2015-01-20 09:49:27 +00:00
provide-5.s ld: Don't evaluate unneeded PROVIDE expressions. 2015-01-20 09:49:27 +00:00
provide-5.t ld: Don't evaluate unneeded PROVIDE expressions. 2015-01-20 09:49:27 +00:00
provide.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
region-alias-1.d
region-alias-1.t
region-alias-2.d
region-alias-2.t
region-alias-3.d
region-alias-3.t
region-alias-4.d
region-alias-4.t
rgn-at.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
rgn-at.s
rgn-at1.d
rgn-at1.t
rgn-at2.d Fix RX and M68HC11 linker testsuite failures. 2016-06-28 12:43:14 +01:00
rgn-at2.t
rgn-at3.d
rgn-at3.t
rgn-at4.d
rgn-at4.t
rgn-at5.d
rgn-at5.s
rgn-at5.t Correct script input section pattern 2016-05-09 17:07:33 +09:30
rgn-at6.d Fix RX and M68HC11 linker testsuite failures. 2016-06-28 12:43:14 +01:00
rgn-at6.s
rgn-at6.t
rgn-at7.d Fix RX and M68HC11 linker testsuite failures. 2016-06-28 12:43:14 +01:00
rgn-at7.t
rgn-at8.d Fix RX and M68HC11 linker testsuite failures. 2016-06-28 12:43:14 +01:00
rgn-at8.t
rgn-at9.d
rgn-at9.t
rgn-at10.d Fix RX and M68HC11 linker testsuite failures. 2016-06-28 12:43:14 +01:00
rgn-at10.s
rgn-at10.t
rgn-at11.d Fix RX and M68HC11 linker testsuite failures. 2016-06-28 12:43:14 +01:00
rgn-at11.s Re-enable rgn-at11 test for MIPS targets with adjusted section alignment. 2016-01-18 13:00:33 +00:00
rgn-at11.t
rgn-over.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
rgn-over.s
rgn-over1.d
rgn-over1.t
rgn-over2.d
rgn-over2.t
rgn-over3.d
rgn-over3.t
rgn-over4.d
rgn-over4.t
rgn-over5.d
rgn-over5.t
rgn-over6.d
rgn-over6.t
rgn-over7.d PR18452, ld allows overlapping sections 2016-03-30 17:50:03 +10:30
rgn-over7.t
rgn-over8-ok.d
rgn-over8.s
rgn-over8.t
sane1.d
sane1.t
script.exp Allow a second -T<section>=<addr> to override a previous version on the same linker command line. 2016-06-27 16:35:58 +01:00
script.s
script.t
scriptm.t
section-flags-1.s
section-flags-1.t
section-flags-2.s
section-flags-2.t
section-flags.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
section-match-1.d
section-match-1.s
section-match-1.t Correct script input section pattern 2016-05-09 17:07:33 +09:30
section-match.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
size-1.d
size-1.s
size-1.t
size-2.d
size-2.s
size-2.t
size.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
sizeof.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
sizeof.s
sizeof.t
sort.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
sort.t
sort_b_a-1.d
sort_b_a-1.s
sort_b_a.d
sort_b_a.s
sort_b_a.t
sort_b_a_a-1.d
sort_b_a_a-2.d
sort_b_a_a-3.d
sort_b_a_a.t
sort_b_a_n-1.d
sort_b_a_n-2.d
sort_b_a_n-3.d
sort_b_a_n.t
sort_b_n-1.d
sort_b_n-1.s
sort_b_n.d
sort_b_n.s
sort_b_n.t
sort_b_n_a-1.d
sort_b_n_a-2.d
sort_b_n_a-3.d
sort_b_n_a.t
sort_b_n_n-1.d
sort_b_n_n-2.d
sort_b_n_n-3.d
sort_b_n_n.t
sort_n_a-a.s
sort_n_a-b.s
sort_no-1.d
sort_no-2.d
sort_no.t
sysroot-prefix-x.s
sysroot-prefix-y.s
sysroot-prefix.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
weak.exp Copyright update for binutils 2016-01-01 23:00:01 +10:30
weak.t
weak1.s
weak2.s