binutils-gdb/ld/scripttempl/misc-sections.sc
Jan Beulich 126535bae4 ld: fold .note.GNU-stack during relocatable linking
PR ld/33851

While in all binutils components we've switched the section to be of
SHT_NOTE type, assembly sources as well as other tools may still generate
SHT_PROGBITS instances. When doing relocatable links, input sections with
differing types would cause multiple output sections to be created, which
some tools choke upon. Fold incoming sections into a single one, the type
of which will be the type of the first section encountered.
2026-02-06 08:52:02 +01:00

37 lines
1.1 KiB
Scala

# Copyright (C) 2014-2026 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.
# This script fragment gathers together some of the more miscellaneous
# sections that might appear in a linker's input. It can be invoked
# with a single parameter which is the memory region into which loadable
# sections should be placed. If the parameter is missing, no memory
# section placement is used.
if test "x$2" = "x" ;
then
REGION=""
else
REGION="> $2"
fi
cat <<EOF
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 (INFO) : { *(.comment); LINKER_VERSION; }
.gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
EOF
test -z "${CONSTRUCTING}" && cat <<EOF
.note.GNU-stack : { *(.note.GNU-stack) }
EOF