Improve the placement of orphan note sections.

PR 32219
This commit is contained in:
Nick Clifton
2024-09-30 14:41:11 +01:00
parent 4339a3ffc3
commit 7ecf0250f7
14 changed files with 71 additions and 13 deletions

View File

@@ -661,6 +661,7 @@ source_sh $srcdir/scripttempl/DWARF.sc
cat <<EOF
${ATTRS_SECTIONS}
.ARC.attributes 0 : { KEEP (*(.ARC.attributes)) }
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
${RELOCATING+${DISCARDED}}

View File

@@ -171,7 +171,7 @@ SECTIONS
EOF
source_sh $srcdir/scripttempl/misc-sections.sc
source_sh $srcdir/scripttempl/misc-sections.sc rom
source_sh $srcdir/scripttempl/DWARF.sc
cat <<EOF

View File

@@ -169,7 +169,7 @@ SECTIONS
EOF
source_sh $srcdir/scripttempl/misc-sections.sc
source_sh $srcdir/scripttempl/misc-sections.sc rom
source_sh $srcdir/scripttempl/DWARF.sc
cat <<EOF

View File

@@ -102,6 +102,10 @@ EOF
cat <<EOF
SECTIONS
{
/* PR 32100: GDB makes use of the fact that the .note.gnu.build-id
section is typically placed next to the ELF headers. */
.note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) } ${RELOCATING+ >INSN}
.text ${RELOCATING+${TEXT_START_ADDR}} :
{
${RELOCATING+${TEXT_START_SYMBOLS}
@@ -175,7 +179,7 @@ SECTIONS
EOF
source_sh $srcdir/scripttempl/misc-sections.sc
source_sh $srcdir/scripttempl/misc-sections.sc DATA
source_sh $srcdir/scripttempl/DWARF.sc
cat <<EOF

View File

@@ -305,6 +305,10 @@ ${RELOCATING- /* For some reason, the Solaris linker makes bad executables
SECTIONS
{
/* PR 32100: GDB makes use of the fact that the .note.gnu.build-id
section is typically placed next to the ELF headers. */
.note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
/* Read-only sections, merged into text segment: */
${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
@@ -549,6 +553,7 @@ source_sh $srcdir/scripttempl/DWARF.sc
cat <<EOF
${ATTRS_SECTIONS}
.xtensa.info : { *(.xtensa.info) }
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
${RELOCATING+${DISCARDED}}

View File

@@ -230,6 +230,11 @@ SECTIONS
${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
${CREATE_PIE+${RELOCATING+. = ${SHLIB_TEXT_START_ADDR:-0} + SIZEOF_HEADERS;}}
/* PR 32100: GDB makes use of the fact that the .note.gnu.build-id
section is typically placed next to the ELF headers. */
.note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
${CREATE_SHLIB-${INTERP}}
${INITIAL_READONLY_SECTIONS}
${TEXT_DYNAMIC+${DYNAMIC}}

View File

@@ -3,10 +3,23 @@
# 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) }
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
@@ -17,4 +30,15 @@ cat <<EOF
.gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
/* Various note sections. Placed here so that they do not get
treated as orphan sections. */
.note.build-id : { *(.note.build-id) } ${RELOCATING+${REGION}}
.note.GNU-stack : { *(.note.GNU-stack) } ${RELOCATING+${REGION}}
.note.gnu-property : { *(.note.gnu-property) } ${RELOCATING+${REGION}}
.note.ABI-tag : { *(.note.ABI-tag) } ${RELOCATING+${REGION}}
.note.package : { *(.note.package) } ${RELOCATING+${REGION}}
.note.dlopen : { *(.note.dlopen) } ${RELOCATING+${REGION}}
.note.netbsd.ident : { *(.note.netbsd.ident) } ${RELOCATING+${REGION}}
.note.openbsd.ident : { *(.note.openbsd.ident) } ${RELOCATING+${REGION}}
EOF

View File

@@ -597,6 +597,8 @@ SHLIB_LARGE_DATA_ADDR=". = SEGMENT_START(\"ldata-segment\", ${SHLIB_LARGE_DATA_A
${TINY_DATA_SECTION}
${TINY_BSS_SECTION}
${STACK_ADDR+${STACK}}
${RELOCATING+${DISCARDED}}
EOF
test -z "${NON_ALLOC_DYN}" || emit_dyn
@@ -608,6 +610,5 @@ cat <<EOF
${ATTRS_SECTIONS}
${OTHER_SECTIONS}
${RELOCATING+${OTHER_SYMBOLS}}
${RELOCATING+${DISCARDED}}
}
EOF

View File

@@ -19,6 +19,10 @@ SEARCH_DIR(.);
${RELOCATING+EXTERN(__ctbp __ep __gp)};
SECTIONS
{
/* PR 32100: GDB makes use of the fact that the .note.gnu.build-id
section is typically placed next to the ELF headers. */
.note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
/* This saves a little space in the ELF file, since the zda starts
at a higher location that the ELF headers take up. */

View File

@@ -19,6 +19,10 @@ SEARCH_DIR(.);
${RELOCATING+EXTERN(__ctbp __ep __gp)};
SECTIONS
{
/* PR 32100: GDB makes use of the fact that the .note.gnu.build-id
section is typically placed next to the ELF headers. */
.note.gnu.build-id ${RELOCATING-0}: { *(.note.gnu.build-id) }
/* This saves a little space in the ELF file, since the zda starts
at a higher location that the ELF headers take up. */