binutils-gdb/ld/emultempl
Alan Modra 7dba9362c1 Rewrite __start and __stop symbol handling
This arranges for __start and __stop symbols to be defined before
garbage collection, for all target formats.  That should allow the
COFF and PE --gc-sections to keep a singleton orphan input section,
a feature lost by 2017-06-13 commit cbd0eecf26.  The fancier ELF
treatment of keeping all input sections associated with a __start or
__stop symbol, from 2015-10-23 commit 1cce69b9dc, is retained.

.startof. and .sizeof. symbols are deliberately not defined before
garbage collection, so these won't affect garbage collection of
sections.

The patch also ensures __start, __stop, .startof. and .sizeof. symbols
are defined before target size_dynamic_sections is called, albeit
with a preliminary value, so that target code doesn't need to cope
with a symbol changing from undefined at size_dynamic_sections to
defined at relocate_section.

Also, a number of problems with the testcases have been fixed.

	PR ld/20022
	PR ld/21557
	PR ld/21562
	PR ld/21571
include/
	* bfdlink.h (struct bfd_link_hash_entry): Delete undef.section.
bfd/
	* targets.c (struct bfd_target): Add _bfd_define_start_stop.
	(BFD_JUMP_TABLE_LINK): Likewise.
	* elf-bfd.h (bfd_elf_define_start_stop): Declare.
	* elflink.c (_bfd_elf_gc_mark_rsec): Update comment.
	(bfd_elf_define_start_stop): New function.
	* linker.c (bfd_generic_define_start_stop): New function.
	* coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Init
	new field.
	* aout-adobe.c (aout_32_bfd_define_start_stop): Define.
	* aout-target.h (MY_bfd_define_start_stop): Define.
	* aout-tic30.c (MY_bfd_define_start_stop): Define.
	* binary.c (binary_bfd_define_start_stop): Define.
	* bout.c (b_out_bfd_define_start_stop): Define.
	* coff-alpha.c (_bfd_ecoff_bfd_define_start_stop): Define.
	* coff-mips.c (_bfd_ecoff_bfd_define_start_stop): Define.
	* coff-rs6000.c (_bfd_xcoff_bfd_define_start_stop): Define.
	* coffcode.h (coff_bfd_define_start_stop): Define.
	* elfxx-target.h (bfd_elfNN_bfd_define_start_stop): Define.
	* i386msdos.c (msdos_bfd_define_start_stop): Define.
	* i386os9k.c (os9k_bfd_define_start_stop): Define.
	* ieee.c (ieee_bfd_define_start_stop): Define.
	* ihex.c (ihex_bfd_define_start_stop): Define.
	* libbfd-in.h (_bfd_nolink_bfd_define_start_stop): Define.
	* mach-o-target.c (bfd_mach_o_bfd_define_start_stop): Define.
	* mmo.c (mmo_bfd_define_start_stop): Define.
	* nlm-target.h (nlm_bfd_define_start_stop): Define.
	* oasys.c (oasys_bfd_define_start_stop): Define.
	* pef.c (bfd_pef_bfd_define_start_stop): Define.
	* plugin.c (bfd_plugin_bfd_define_start_stop): Define.
	* ppcboot.c (ppcboot_bfd_define_start_stop): Define.
	* som.c (som_bfd_define_start_stop): Define.
	* srec.c (srec_bfd_define_start_stop): Define.
	* tekhex.c (tekhex_bfd_define_start_stop): Define.
	* versados.c (versados_bfd_define_start_stop): Define.
	* vms-alpha.c (vms_bfd_define_start_stop): Define.
	(alpha_vms_bfd_define_start_stop): Define.
	* xsym.c (bfd_sym_bfd_define_start_stop): Define.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
ld/
	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Don't set
	__start/__stop syms here.
	* ldlang.c (lang_set_startof): Delete.
	(start_stop_syms, start_stop_count, start_stop_alloc): New vars.
	(lang_define_start_stop, lang_init_start_stop, foreach_start_stop,
	undef_start_stop, lang_undef_start_stop, lang_init_startof_sizeof,
	set_start_stop, lang_finalize_start_stop): New functions.
	(lang_process): Call _start_stop functions.
	* testsuite/ld-elf/pr21562a.d: Use xfail rather than notarget.
	Correct typos and list of xfail targets.
	* testsuite/ld-elf/pr21562b.d: Likewise.
	* testsuite/ld-elf/pr21562c.d: Likewise.
	* testsuite/ld-elf/pr21562d.d: Likewise.
	* testsuite/ld-elf/pr21562e.d: Likewise.
	* testsuite/ld-elf/pr21562f.d: Likewise.
	* testsuite/ld-elf/pr21562g.d: Likewise.
	* testsuite/ld-elf/pr21562h.d: Likewise.
	* testsuite/ld-elf/pr21562i.d: Likewise.
	* testsuite/ld-elf/pr21562j.d: Likewise.
	* testsuite/ld-elf/pr21562k.d: Likewise.
	* testsuite/ld-elf/pr21562l.d: Likewise.
	* testsuite/ld-elf/pr21562m.d: Likewise.
	* testsuite/ld-elf/pr21562n.d: Likewise.
	* testsuite/ld-elf/sizeofa.d: Likewise.  Adjust to pass for generic ELF.
	* testsuite/ld-elf/sizeofb.d: Likewise.
	* testsuite/ld-elf/startofa.d: Likewise.
	* testsuite/ld-elf/startofb.d: Likewise.
2017-06-16 23:38:28 +09:30
..
README Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
aarch64elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
aix.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
alphaelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
arclinux.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
armcoff.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
armelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
astring.sed
avrelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
beos.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
bfin.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
cr16elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
crxelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
elf-generic.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
elf32.em Rewrite __start and __stop symbol handling 2017-06-16 23:38:28 +09:30
epiphanyelf_4x4.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
genelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
generic.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
gld960.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
gld960c.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
hppaelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ia64elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
irix.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
linux.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
lnk960.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
m68hc1xelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
m68kcoff.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
m68kelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
metagelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
mipself.em MIPS: Add options to control branch ISA checks 2017-01-30 17:16:01 +00:00
mmix-elfnmmo.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
mmixelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
mmo.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
msp430.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
nds32elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
needrelax.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
netbsd.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
nios2elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ostring.sed
pe.em Don't compare boolean values against TRUE or FALSE 2017-05-18 14:59:33 +09:30
pep.em Don't compare boolean values against TRUE or FALSE 2017-05-18 14:59:33 +09:30
ppc32elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ppc64elf.em PPC64_OPT_LOCALENTRY 2017-06-01 22:47:32 +09:30
pruelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
riscvelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
rxelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
scoreelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
sh64elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
solaris2.em Solaris2/LD: Fix anonymous version script acceptance bug 2017-01-24 12:53:52 +00:00
spu_icache.S
spu_icache.o_c Regenerate spu overlay and icache manager files 2014-11-04 22:36:13 +10:30
spu_ovl.S Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
spu_ovl.o_c Regenerate spu_ovl.o_c 2016-10-15 12:53:57 +10:30
spuelf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
sunos.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
tic6xdsbt.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ticoff.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
v850elf.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vanilla.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vms.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vxworks.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
xtensaelf.em Don't compare boolean values against TRUE or FALSE 2017-05-18 14:59:33 +09:30
z80.em Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30

README

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The files in this directory are sourced by genscripts.sh, after
setting some variables to substitute in, to produce
C source files that contain jump tables for each emulation.

Copyright (C) 2012-2017 Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.