moved from ld/emultempl/elf32.em to ld/ldlang.c, so apply approximately
the same change as upstream, which has description:
* ldlang.c (lang_insert_orphan): Add __start_<section> symbol assignment
inside output section statement. Ensure only one set of symbols per
output section.
* emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Add non-dollar
sections before dollar sections. Correct add_child list insertion.
Taken from upstream git commit 7e01d69a19a8fd079887f26853c8565da15ff340,
with permission to use it under GPLv2 from the author.
The change made to bfd/elf.c in upstream revision 1.217.4.3 (which was a
revert of an earlier change), caused objcopy on powerpc to fail to copy
debug info from kernel modules. This had to be fixed by applying the
diff from upstream revision 1.243 on top of it.
__start_SECNAME and __stop_SECNAME symbols are automatically generated
by ld for orphan sections, i.e. those not explicitely referenced by a
linker script. The symbols are supposed to be placed correspondingly
at the start and the end of the section in output file. In some cases
__start_SECNAME may be placed at the address after the end of the
previous section (if any) and before the start the section. This
happens when following conditions are met:
1. the orphan section is found in more than one input file
2. the orphan section has different alignment requirements across input
files
3. the first instance of the section encountered doesn't have the
greatest alignment requirement
In these conditions resulting output section will be placed at address
after the end of the previous section aligned to the greatest alignment
requirement in the inputs, but __start_SECNAME will be placed at address
after the end of the previous section aligned to the alignment
requirement of the first input in which the section is encountered.
See commit message of r196118 for a concrete example of problems caused
by this bug.
The fix is to place __start_SECNAME inside the section and use ABSOLUTE
directive, rather than placing __start_SECNAME outside the section and
trying to guess address alignment.
This fix is in line with upstream binutils change/fix made between
versions 2.19 and 2.20 in revision of 1.307 ldlang.c.
MFC after: 3 weeks
a variety of bugs in binutils related to handling of 64-bit PPC ELF,
provides a GCC configuration for 64-bit PowerPC on FreeBSD, and
associated build systems tweaks.
Obtained from: projects/ppc64
Binutils has a "contrib" subdirectory - thus flattening cannot happen
without renaming the upper level contrib directory in a first pass.
Also, don't record this move and remove any keyword expansion.