summaryrefslogtreecommitdiff
path: root/ld/scripttempl
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2023-03-15 14:27:21 +0000
committerNick Clifton <nickc@redhat.com>2023-03-15 14:27:21 +0000
commit2d5783fad77c2cb9cdcb396d65fe0a60e3d8938b (patch)
tree6f498d98b1bd86aba1498861443099802ac0f8c8 /ld/scripttempl
parent71f646f2b3fc6e273fd17b5fdc9ba6bae242b330 (diff)
downloadbinutils-gdb-2d5783fad77c2cb9cdcb396d65fe0a60e3d8938b.tar.gz
Add --enable-linker-version option to bfd linker to add an entry in the .comment section.
PR 30187 * NEWS: Mention the new feature. * ld.texi: Document the new feature. * ldgram.y: Handle LINKER_VERSION token. * ldlang.c (lang_add_version): New function. (enable_linker_version): New global variable. * ldlang.h (land_add_version): Prototype. (enable_linker_version): Export. * ldlex.h (OPTION_ENABLE_LINKER_VERSION): Define. (OPTION_DISABLE_LINKER_VERSION): Define. * ldlex.l (LINKER_VERSION): Add token. * lexsup.c (ld_options): Add --enable-linker-version and --disable-linker-version. (parse_args): Handle the new options. * scripttempl/arclinux.sc: Remove stabs and comment sections and replace with inclusion of misc-sections.sc * scripttempl/avr.sc: Likewise. * scripttempl/dlx.sc: Likewise. * scripttempl/elf.sc: Likewise. * scripttempl/elf32cr16.sc: Likewise. * scripttempl/elf32crx.sc: Likewise. * scripttempl/elf32msp430.sc: Likewise. * scripttempl/elf64bpf.sc: Likewise. * scripttempl/elf64hppa.sc: Likewise. * scripttempl/elf_chaos.sc: Likewise. * scripttempl/elfarc.sc: Likewise. * scripttempl/elfarcv2.sc: Likewise. * scripttempl/elfd10v.sc: Likewise. * scripttempl/elfd30v.sc: Likewise. * scripttempl/elfm68hc11.sc: Likewise. * scripttempl/elfm68hc12.sc: Likewise. * scripttempl/elfm9s12z.sc: Likewise. * scripttempl/elfmicroblaze.sc: Likewise. * scripttempl/elfxgate.sc: Likewise. * scripttempl/elfxtensa.sc: Likewise. * scripttempl/epiphany_4x4.sc: Likewise. * scripttempl/ft32.sc: Likewise. * scripttempl/ip2k.sc: Likewise. * scripttempl/iq2000.sc: Likewise. * scripttempl/mep.sc: Likewise. * scripttempl/nds32elf.sc: Likewise. * scripttempl/pru.sc: Likewise. * scripttempl/v850.sc: Likewise. * scripttempl/v850_rh850.sc: Likewise. * scripttempl/visium.sc: Likewise. * scripttempl/xstormy16.sc: Likewise. * scripttempl/z80.sc: Likewise. * testsuite/ld-scripts/script.exp: Run new tests. * scripttempl/misc-sections.sc: New file. * testsuite/ld-scripts/ld-version-2.d: New file. * testsuite/ld-scripts/ld-version.d: New file. * testsuite/ld-scripts/ld-version.t: New file.
Diffstat (limited to 'ld/scripttempl')
-rw-r--r--ld/scripttempl/arclinux.sc13
-rw-r--r--ld/scripttempl/avr.sc11
-rw-r--r--ld/scripttempl/dlx.sc8
-rw-r--r--ld/scripttempl/elf.sc15
-rw-r--r--ld/scripttempl/elf32cr16.sc3
-rw-r--r--ld/scripttempl/elf32crx.sc3
-rw-r--r--ld/scripttempl/elf32msp430.sc9
-rw-r--r--ld/scripttempl/elf64bpf.sc15
-rw-r--r--ld/scripttempl/elf64hppa.sc14
-rw-r--r--ld/scripttempl/elf_chaos.sc11
-rw-r--r--ld/scripttempl/elfarc.sc14
-rw-r--r--ld/scripttempl/elfarcv2.sc10
-rw-r--r--ld/scripttempl/elfd10v.sc11
-rw-r--r--ld/scripttempl/elfd30v.sc11
-rw-r--r--ld/scripttempl/elfm68hc11.sc11
-rw-r--r--ld/scripttempl/elfm68hc12.sc12
-rw-r--r--ld/scripttempl/elfm9s12z.sc12
-rw-r--r--ld/scripttempl/elfmicroblaze.sc6
-rw-r--r--ld/scripttempl/elfxgate.sc12
-rw-r--r--ld/scripttempl/elfxtensa.sc13
-rw-r--r--ld/scripttempl/epiphany_4x4.sc13
-rw-r--r--ld/scripttempl/ft32.sc5
-rw-r--r--ld/scripttempl/ip2k.sc11
-rw-r--r--ld/scripttempl/iq2000.sc12
-rw-r--r--ld/scripttempl/mep.sc12
-rw-r--r--ld/scripttempl/misc-sections.sc20
-rw-r--r--ld/scripttempl/nds32elf.sc13
-rw-r--r--ld/scripttempl/pru.sc10
-rw-r--r--ld/scripttempl/v850.sc11
-rw-r--r--ld/scripttempl/v850_rh850.sc11
-rw-r--r--ld/scripttempl/visium.sc2
-rw-r--r--ld/scripttempl/xstormy16.sc13
-rw-r--r--ld/scripttempl/z80.sc6
33 files changed, 80 insertions, 273 deletions
diff --git a/ld/scripttempl/arclinux.sc b/ld/scripttempl/arclinux.sc
index 7ebf7adbb1b..9c24e5bc12c 100644
--- a/ld/scripttempl/arclinux.sc
+++ b/ld/scripttempl/arclinux.sc
@@ -656,18 +656,7 @@ EOF
test -z "${NON_ALLOC_DYN}" || emit_dyn
-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 : { *(.comment) }
-
-EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
diff --git a/ld/scripttempl/avr.sc b/ld/scripttempl/avr.sc
index 9abfc536121..3677e07eeb9 100644
--- a/ld/scripttempl/avr.sc
+++ b/ld/scripttempl/avr.sc
@@ -328,16 +328,9 @@ cat <<EOF
EOF
fi
-cat <<EOF
+. $srcdir/scripttempl/misc-sections.sc
- /* 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 : { *(.comment) }
+cat <<EOF
.note.gnu.build-id ${RELOCATING-0} : { *(.note.gnu.build-id) }
EOF
diff --git a/ld/scripttempl/dlx.sc b/ld/scripttempl/dlx.sc
index 1a1774c9082..f5673f4c05b 100644
--- a/ld/scripttempl/dlx.sc
+++ b/ld/scripttempl/dlx.sc
@@ -38,5 +38,13 @@ SECTIONS
${RELOCATING+*(COMMON)}
${RELOCATING+end = .;}
}
+
+EOF
+
+. $srcdir/scripttempl/misc-sections.sc
+
+. $srcdir/scripttempl/DWARF.sc
+
+cat <<EOF
}
EOF
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 5d3b0d31b1b..92f100b4623 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -722,20 +722,7 @@ EOF
test -z "${NON_ALLOC_DYN}" || emit_dyn
-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 : { *(.comment) }
-
- .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
-
-EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
diff --git a/ld/scripttempl/elf32cr16.sc b/ld/scripttempl/elf32cr16.sc
index f45ce8071ee..aedc17bd430 100644
--- a/ld/scripttempl/elf32cr16.sc
+++ b/ld/scripttempl/elf32cr16.sc
@@ -169,10 +169,9 @@ SECTIONS
__ISTACK_START = .;
}${RELOCATING+ > ram}
- .comment 0 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elf32crx.sc b/ld/scripttempl/elf32crx.sc
index fa2481358f6..747bfbb1cad 100644
--- a/ld/scripttempl/elf32crx.sc
+++ b/ld/scripttempl/elf32crx.sc
@@ -167,10 +167,9 @@ SECTIONS
__ISTACK_START = .;
} > ram
- .comment 0 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elf32msp430.sc b/ld/scripttempl/elf32msp430.sc
index 83613fc1cb8..4b0ac8d7e93 100644
--- a/ld/scripttempl/elf32msp430.sc
+++ b/ld/scripttempl/elf32msp430.sc
@@ -330,16 +330,9 @@ SECTIONS
/* Stabs for profiling information*/
.profiler 0 : { *(.profiler) }
- /* 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 : { *(.comment) }
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
test -n "${RELOCATING}" && cat <<EOF
diff --git a/ld/scripttempl/elf64bpf.sc b/ld/scripttempl/elf64bpf.sc
index 48cda5b3473..8ff588bc1fb 100644
--- a/ld/scripttempl/elf64bpf.sc
+++ b/ld/scripttempl/elf64bpf.sc
@@ -679,20 +679,7 @@ EOF
test -z "${NON_ALLOC_DYN}" || emit_dyn
-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 : { *(.comment) }
-
- .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
-
-EOF
+. $srcdir/scripttempl/misc-sections.sc
cat <<EOF
${ATTRS_SECTIONS}
diff --git a/ld/scripttempl/elf64hppa.sc b/ld/scripttempl/elf64hppa.sc
index 5f5d690f4dd..e80d2483630 100644
--- a/ld/scripttempl/elf64hppa.sc
+++ b/ld/scripttempl/elf64hppa.sc
@@ -533,19 +533,7 @@ if test -n "${NON_ALLOC_DYN}"; then
rm -f ldscripts/dyntmp.$$
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 : { *(.comment) }
-
-EOF
-
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elf_chaos.sc b/ld/scripttempl/elf_chaos.sc
index 30bbe0b5a6a..f3b2776ef57 100644
--- a/ld/scripttempl/elf_chaos.sc
+++ b/ld/scripttempl/elf_chaos.sc
@@ -325,18 +325,9 @@ cat <<EOF
${RELOCATING+PROVIDE (end = .);}
${STACK_ADDR+${STACK}}
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elfarc.sc b/ld/scripttempl/elfarc.sc
index 1d3c043a4d7..ccba4a1113d 100644
--- a/ld/scripttempl/elfarc.sc
+++ b/ld/scripttempl/elfarc.sc
@@ -409,19 +409,7 @@ test -n "${RELOCATING}" && cat <<EOF
}
EOF
-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 : { *(.comment) }
- .note.gnu.build-id : { *(.note.gnu.build-id) }
-EOF
-
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elfarcv2.sc b/ld/scripttempl/elfarcv2.sc
index bf84c7648db..5b547c15a9f 100644
--- a/ld/scripttempl/elfarcv2.sc
+++ b/ld/scripttempl/elfarcv2.sc
@@ -291,18 +291,10 @@ SECTIONS
${RELOCATING+ PROVIDE (__stack_top = (ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1) & -4);}
${RELOCATING+ PROVIDE (__end_heap = ORIGIN (${DATA_MEMORY}) + LENGTH (${DATA_MEMORY}) - 1);}
- /* 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 : { *(.comment) }
.note.gnu.build-id : { *(.note.gnu.build-id) }
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elfd10v.sc b/ld/scripttempl/elfd10v.sc
index 4261f8371dc..c08192c9288 100644
--- a/ld/scripttempl/elfd10v.sc
+++ b/ld/scripttempl/elfd10v.sc
@@ -172,18 +172,9 @@ SECTIONS
${RELOCATING+$STACK}
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elfd30v.sc b/ld/scripttempl/elfd30v.sc
index 4bb0efcae8a..2c95f5c16ec 100644
--- a/ld/scripttempl/elfd30v.sc
+++ b/ld/scripttempl/elfd30v.sc
@@ -197,18 +197,9 @@ SECTIONS
${RELOCATING+ PROVIDE (__eit_end = .) ; }
} ${RELOCATING+ > eit}
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elfm68hc11.sc b/ld/scripttempl/elfm68hc11.sc
index d029bae34db..e796a5f7ca0 100644
--- a/ld/scripttempl/elfm68hc11.sc
+++ b/ld/scripttempl/elfm68hc11.sc
@@ -428,18 +428,9 @@ SECTIONS
${RELOCATING+${VECTORS}}
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elfm68hc12.sc b/ld/scripttempl/elfm68hc12.sc
index 32ba5c3a16c..6fa708977fa 100644
--- a/ld/scripttempl/elfm68hc12.sc
+++ b/ld/scripttempl/elfm68hc12.sc
@@ -430,17 +430,11 @@ SECTIONS
} ${RELOCATING+ > ${EEPROM_MEMORY}}
${RELOCATING+${VECTORS}}
+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 : { *(.comment) }
+. $srcdir/scripttempl/misc-sections.sc
+cat <<EOF
/* Treatment of DWARF debug section must be at end of the linker
script to avoid problems when there are undefined symbols. It's necessary
to avoid that the DWARF section is relocated before such undefined
diff --git a/ld/scripttempl/elfm9s12z.sc b/ld/scripttempl/elfm9s12z.sc
index aaa137b9196..d77e2130a98 100644
--- a/ld/scripttempl/elfm9s12z.sc
+++ b/ld/scripttempl/elfm9s12z.sc
@@ -420,17 +420,11 @@ SECTIONS
} ${RELOCATING+ > ${EEPROM_MEMORY}}
${RELOCATING+${VECTORS}}
+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 : { *(.comment) }
+. $srcdir/scripttempl/misc-sections.sc
+cat <<EOF
/* Treatment of DWARF debug section must be at end of the linker
script to avoid problems when there are undefined symbols. It's necessary
to avoid that the DWARF section is relocated before such undefined
diff --git a/ld/scripttempl/elfmicroblaze.sc b/ld/scripttempl/elfmicroblaze.sc
index 8d99ea181c6..6c17172bf50 100644
--- a/ld/scripttempl/elfmicroblaze.sc
+++ b/ld/scripttempl/elfmicroblaze.sc
@@ -232,5 +232,11 @@ SECTIONS
${RELOCATING+*(.tbss.*)}
${RELOCATING+*(.gnu.linkonce.tb.*)}
}
+EOF
+
+. $srcdir/scripttempl/misc-sections.sc
+. $srcdir/scripttempl/DWARF.sc
+
+cat <<EOF
}
EOF
diff --git a/ld/scripttempl/elfxgate.sc b/ld/scripttempl/elfxgate.sc
index af8beb0e0cd..f810788929e 100644
--- a/ld/scripttempl/elfxgate.sc
+++ b/ld/scripttempl/elfxgate.sc
@@ -430,19 +430,9 @@ SECTIONS
} ${RELOCATING+ > ${EEPROM_MEMORY}}
${RELOCATING+${VECTORS}}
-
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/elfxtensa.sc b/ld/scripttempl/elfxtensa.sc
index eb0e675b46d..a6cd174ccd0 100644
--- a/ld/scripttempl/elfxtensa.sc
+++ b/ld/scripttempl/elfxtensa.sc
@@ -543,18 +543,7 @@ if test -n "${NON_ALLOC_DYN}"; then
rm -f ldscripts/dyntmp.$$
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 : { *(.comment) }
-
-EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
diff --git a/ld/scripttempl/epiphany_4x4.sc b/ld/scripttempl/epiphany_4x4.sc
index bbed7e1a23c..42e2f7e7613 100644
--- a/ld/scripttempl/epiphany_4x4.sc
+++ b/ld/scripttempl/epiphany_4x4.sc
@@ -626,18 +626,7 @@ if test -n "${NON_ALLOC_DYN}"; then
rm -f ldscripts/dyntmp.$$
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 : { *(.comment) }
-
-EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
diff --git a/ld/scripttempl/ft32.sc b/ld/scripttempl/ft32.sc
index ef7f332aa50..e2d5a6bdfc9 100644
--- a/ld/scripttempl/ft32.sc
+++ b/ld/scripttempl/ft32.sc
@@ -69,10 +69,5 @@ SECTIONS
{
*(.stabstr)
}
-EOF
-
-. $srcdir/scripttempl/DWARF.sc
-
-cat <<EOF
}
EOF
diff --git a/ld/scripttempl/ip2k.sc b/ld/scripttempl/ip2k.sc
index 5e78132e1bf..89a2f1639e7 100644
--- a/ld/scripttempl/ip2k.sc
+++ b/ld/scripttempl/ip2k.sc
@@ -135,17 +135,10 @@ SECTIONS
/* Stack. */
PROVIDE (__stack = 0x01000FFF);
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
+
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/iq2000.sc b/ld/scripttempl/iq2000.sc
index 13c8a905806..44228e7f1a8 100644
--- a/ld/scripttempl/iq2000.sc
+++ b/ld/scripttempl/iq2000.sc
@@ -406,18 +406,10 @@ cat <<EOF
${RELOCATING+_end = .;}
${RELOCATING+PROVIDE (end = .);}
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
+
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/mep.sc b/ld/scripttempl/mep.sc
index 77892cb3831..1a0252d9073 100644
--- a/ld/scripttempl/mep.sc
+++ b/ld/scripttempl/mep.sc
@@ -406,18 +406,10 @@ cat <<EOF
${RELOCATING+PROVIDE (end = .);}
${RELOCATING+${DATA_SEGMENT_END}}
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
+
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/misc-sections.sc b/ld/scripttempl/misc-sections.sc
new file mode 100644
index 00000000000..115ef1a5579
--- /dev/null
+++ b/ld/scripttempl/misc-sections.sc
@@ -0,0 +1,20 @@
+# Copyright (C) 2014-2023 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.
+#
+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 : { *(.comment); LINKER_VERSION; }
+
+ .gnu.build.attributes : { *(.gnu.build.attributes${RELOCATING+ .gnu.build.attributes.*}) }
+
+EOF
diff --git a/ld/scripttempl/nds32elf.sc b/ld/scripttempl/nds32elf.sc
index 279e4249e30..b3acb016780 100644
--- a/ld/scripttempl/nds32elf.sc
+++ b/ld/scripttempl/nds32elf.sc
@@ -601,18 +601,7 @@ EOF
test -z "${NON_ALLOC_DYN}" || emit_dyn
-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 : { *(.comment) }
-
-EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
diff --git a/ld/scripttempl/pru.sc b/ld/scripttempl/pru.sc
index 4229bed99bb..a24005b0f66 100644
--- a/ld/scripttempl/pru.sc
+++ b/ld/scripttempl/pru.sc
@@ -201,17 +201,11 @@ SECTIONS
place it in the target dmem memory. */
.pru_irq_map 0 : { *(.pru_irq_map) }
- /* 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 : { *(.comment) }
.note.gnu.build-id ${RELOCATING-0} : { *(.note.gnu.build-id) }
EOF
+. $srcdir/scripttempl/misc-sections.sc
+
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/v850.sc b/ld/scripttempl/v850.sc
index 713dfaef886..515aeb149a9 100644
--- a/ld/scripttempl/v850.sc
+++ b/ld/scripttempl/v850.sc
@@ -196,17 +196,10 @@ SECTIONS
.note.renesas 0 : { KEEP(*(.note.renesas)) }
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
+
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/v850_rh850.sc b/ld/scripttempl/v850_rh850.sc
index a68ab8e31c2..a06889354ad 100644
--- a/ld/scripttempl/v850_rh850.sc
+++ b/ld/scripttempl/v850_rh850.sc
@@ -216,17 +216,10 @@ SECTIONS
.note.renesas 0 : { KEEP(*(.note.renesas)) }
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
+
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/visium.sc b/ld/scripttempl/visium.sc
index 743553097a7..def19ca84bb 100644
--- a/ld/scripttempl/visium.sc
+++ b/ld/scripttempl/visium.sc
@@ -163,7 +163,7 @@ SECTIONS
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
+ .comment 0 : { *(.comment); LINKER_VERSION; }
EOF
diff --git a/ld/scripttempl/xstormy16.sc b/ld/scripttempl/xstormy16.sc
index e0f7fcc3c7d..2b3c0519619 100644
--- a/ld/scripttempl/xstormy16.sc
+++ b/ld/scripttempl/xstormy16.sc
@@ -203,19 +203,10 @@ SECTIONS
${RELOCATING+PROVIDE (etext = .);}
${RELOCATING+${OTHER_READONLY_SECTIONS}}
-
- /* 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 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
+
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
diff --git a/ld/scripttempl/z80.sc b/ld/scripttempl/z80.sc
index 3e2c48bdc6b..75a6a4a7972 100644
--- a/ld/scripttempl/z80.sc
+++ b/ld/scripttempl/z80.sc
@@ -49,5 +49,11 @@ SECTIONS
*(bss)
${RELOCATING+ __Hbss = .;}
}
+EOF
+
+. $srcdir/scripttempl/misc-sections.sc
+. $srcdir/scripttempl/DWARF.sc
+
+cat <<EOF
}
EOF