binutils-gdb/include
Andrew Burgess 7bdf4127c3 ld: Allow section groups to be resolved as part of a relocatable link
This commit adds a new linker feature: the ability to resolve section
groups as part of a relocatable link.

Currently section groups are automatically resolved when performing a
final link, and are carried through when performing a relocatable link.
By carried through this means that one copy of each section group (from
all the copies that might be found in all the input files) is placed
into the output file.  Sections that are part of a section group will
not match input section specifiers within a linker script and are
forcibly kept as separate sections.

There is a slight resemblance between section groups and common
section.  Like section groups, common sections are carried through when
performing a relocatable link, and resolved (allocated actual space)
only at final link time.

However, with common sections there is an ability to force the linker to
allocate space for the common sections when performing a relocatable
link, there's currently no such ability for section groups.

This commit adds such a mechanism.  This new facility can be accessed in
two ways, first there's a command line switch --force-group-allocation,
second, there's a new linker script command FORCE_GROUP_ALLOCATION.  If
one of these is used when performing a relocatable link then the linker
will resolve the section groups as though it were performing a final
link, the section group will be deleted, and the members of the group
will be placed like normal input sections.  If there are multiple copies
of the group (from multiple input files) then only one copy of the group
members will be placed, the duplicate copies will be discarded.

Unlike common sections that have the --no-define-common command line
flag, and INHIBIT_COMMON_ALLOCATION linker script command there is no
way to prevent group resolution during a final link, this is because the
ELF gABI specifically prohibits the presence of SHT_GROUP sections in a
fully linked executable.  However, the code as written should make
adding such a feature trivial, setting the new resolve_section_groups
flag to false during a final link should work as you'd expect.

bfd/ChangeLog:

	* elf.c (_bfd_elf_make_section_from_shdr): Don't initially mark
	SEC_GROUP sections as SEC_EXCLUDE.
	(bfd_elf_set_group_contents): Replace use of abort with an assert.
	(assign_section_numbers): Use resolve_section_groups flag instead
	of relocatable link type.
	(_bfd_elf_init_private_section_data): Use resolve_section_groups
	flag instead of checking the final_link flag for part of the
	checks in here.  Fix white space as a result.
	* elflink.c (elf_link_input_bfd): Use resolve_section_groups flag
	instead of relocatable link type.
	(bfd_elf_final_link): Likewise.

include/ChangeLog:

	* bfdlink.h (struct bfd_link_info): Add new resolve_section_groups
	flag.

ld/ChangeLog:

	* ld.h (struct args_type): Add force_group_allocation field.
	* ldgram.y: Add support for FORCE_GROUP_ALLOCATION.
	* ldlex.h: Likewise.
	* ldlex.l: Likewise.
	* lexsup.c: Likewise.
	* ldlang.c (unique_section_p): Check resolve_section_groups flag
	not the relaxable link flag.
	(lang_add_section): Discard section groups when we're resolving
	groups.  Clear the SEC_LINK_ONCE flag if we're resolving section
	groups.
	* ldmain.c (main): Initialise resolve_section_groups flag in
	link_info based on command line flags.
	* testsuite/ld-elf/group11.d: New file.
	* testsuite/ld-elf/group12.d: New file.
	* testsuite/ld-elf/group12.ld: New file.
	* NEWS: Mention new features.
	* ld.texinfo (Options): Document --force-group-allocation.
	(Miscellaneous Commands): Document FORCE_GROUP_ALLOCATION.
2017-06-06 09:53:38 +01:00
..
aout Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
cgen Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
coff Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
elf PPC64_OPT_LOCALENTRY 2017-06-01 22:47:32 +09:30
gdb update copyright year range in GDB files 2017-01-01 10:52:34 +04:00
mach-o Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
nlm Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
opcode S/390: Improve error checking for optional operands 2017-05-30 10:22:25 +02:00
som Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vms Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
COPYING Update the address and phone number of the FSF organization 2005-05-10 10:21:13 +00:00
COPYING3 * COPYING3: New file. Contains version 3 of the GNU General Public License. 2007-07-17 13:50:23 +00:00
ChangeLog ld: Allow section groups to be resolved as part of a relocatable link 2017-06-06 09:53:38 +01:00
ChangeLog-0415 binutils ChangeLog rotation 2016-01-01 22:59:17 +10:30
ChangeLog-2016 ChangeLog rotation 2017-01-02 13:55:05 +10:30
ChangeLog-9103 Add copyright notices 2012-12-10 12:48:03 +00:00
MAINTAINERS Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
alloca-conf.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ansidecl.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
bfdlink.h ld: Allow section groups to be resolved as part of a relocatable link 2017-06-06 09:53:38 +01:00
binary-io.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
bout.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
demangle.h Sync libiberty sources with GCC. 2017-03-13 17:49:32 +00:00
dis-asm.h Move print_insn_XXX to an opcodes internal header 2017-05-24 17:23:52 +01:00
dwarf2.def Add DW_OP_GNU_variable_value 2017-03-14 12:57:48 -07:00
dwarf2.h Sync dwarf headers with master versions in gcc repository. 2017-01-03 15:18:52 +00:00
dyn-string.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
environ.h Fix MinGW compilation warnings due to environ.h 2017-05-31 09:35:07 +03:00
fibheap.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
filenames.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
floatformat.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
fnmatch.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
fopen-bin.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
fopen-same.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
fopen-vms.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
gcc-c-fe.def Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
gcc-c-interface.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
gcc-interface.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
getopt.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
hashtab.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
hp-symtab.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
ieee.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
leb128.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
libiberty.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
longlong.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
lto-symtab.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
md5.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
oasys.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
objalloc.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
obstack.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
os9k.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
partition.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
plugin-api.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
progress.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
safe-ctype.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
sha1.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
simple-object.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
sort.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
splay-tree.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
symcat.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
timeval-utils.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
vtv-change-permission.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
xregex.h merge from gcc 2011-07-25 17:11:48 +00:00
xregex2.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
xtensa-config.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
xtensa-isa-internal.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
xtensa-isa.h Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30