binutils-gdb/ld/testsuite
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
..
config ld: Add a linker configure option --enable-relro 2016-06-22 05:37:38 -07:00
ld-aarch64 Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-alpha Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
ld-arc [ARC] Fix parsing dtpoff relocation expression. 2016-09-14 14:04:34 +02:00
ld-arm Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-auto-import
ld-avr Fix PR ld/20545 - relaxation bugs in avr backend 2016-09-06 12:28:37 +05:30
ld-bootstrap
ld-cdtest
ld-checks
ld-cris Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-crx
ld-cygwin
ld-d10v
ld-discard ld: Create test object files based on source file name 2016-11-04 12:04:11 +00:00
ld-elf ld: Create test object files based on source file name 2016-11-04 12:04:11 +00:00
ld-elfcomm Skip ELF STT_COMMON linker tests if shared libraries are not supported. 2016-05-03 10:44:35 +01:00
ld-elfvers
ld-elfvsb Skip debug sections when estimating distances 2016-04-27 09:13:10 -07:00
ld-elfweak
ld-fastcall
ld-frv Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-gc Restrict linker garbage collection personality test to cfi enabled targets. 2016-07-27 12:01:09 +01:00
ld-h8300
ld-i386 Update more tests for objdump change 2016-10-12 09:36:05 +10:30
ld-ia64 Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
ld-ifunc Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-libs
ld-linkonce
ld-m68hc11
ld-m68k Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-mep
ld-metag Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-mips-elf Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
ld-misc
ld-mmix Always descend into output section statements in lang_do_assignments 2016-10-11 18:13:04 +10:30
ld-mn10300
ld-nds32
ld-nios2
ld-pe Fix more linker testsuite failures. 2016-06-28 15:55:22 +01:00
ld-pie Use variable args in run_ld_link_exec_tests 2016-07-21 11:34:45 +09:30
ld-plugin Use variable args in run_ld_link_exec_tests 2016-07-21 11:34:45 +09:30
ld-powerpc PowerPC .gnu.attributes 2016-09-26 18:04:57 +09:30
ld-s390 Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-scripts ld: Allow EXCLUDE_FILE to be used outside of the section list 2016-11-04 12:04:11 +00:00
ld-selective Fix some AVR test failures. 2016-05-04 13:03:52 +01:00
ld-sh Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
ld-shared
ld-size Use variable args in run_ld_link_exec_tests 2016-07-21 11:34:45 +09:30
ld-sparc Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
ld-spu
ld-srec [ARC] XFAIL S-Records tests for both little and big endian ARC target. 2016-06-13 16:15:58 +02:00
ld-tic6x Update more tests for objdump change 2016-10-12 09:36:05 +10:30
ld-tilegx
ld-tilepro
ld-undefined Fix thinko in new weak undefined function test 2016-08-18 20:28:29 +09:30
ld-unique LD/ELF: Unify STB_GNU_UNIQUE handling 2016-05-17 12:21:40 +01:00
ld-v850
ld-vax-elf Enhance objdump so that it will use .got, .plt and .plt.got section symbols when disassembling, and it will use dynamic relocs to interpret entries in the PLT and GOT. 2016-10-11 13:50:10 +01:00
ld-versados
ld-visium
ld-vxworks
ld-x86-64 Update more tests for objdump change 2016-10-12 09:36:05 +10:30
ld-xc16x
ld-xstormy16
ld-xtensa Place .shstrtab section after .symtab and .strtab, thus restoring monotonically increasing section offsets. 2016-08-19 09:16:30 +01:00
ld-z8k ld/testsuite/ld-z8k/test-ld.sh: Remove. Checked in by mistake. 2016-06-04 22:39:46 +02:00
lib ld: Create test object files based on source file name 2016-11-04 12:04:11 +00:00
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-9303