+2023-03-15 Nick Clifton <nickc@redhat.com>
+
+ 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.
+
2023-02-23 Fangrui Song <i@maskray.me>
* emultempl/riscvelf.em: Add option parsing.
-*- text -*-
+* For most ELF based targets, if the --enable-linker-version option is used
+ then the version of the linker will be inserted as a string into the .comment
+ section.
+
* The linker script syntax has a new command for output sections: ASCIZ "string"
This will insert a zero-terminated string at the current location.
option is only meaningful on ELF platforms supporting the rtld-audit interface.
The -P option is provided for Solaris compatibility.
+@kindex --enable-linker-version
+@item --enable-linker-version
+Enables the @code{LINKER_VERSION} linker script directive, described
+in @ref{Output Section Data}. If this directive is used in a linker
+script and this option has been enabled then a string containing the
+linker version will be inserted at the current point.
+
+Note - this location of this option on the linker command line is
+significant. It will only affect linker scripts that come after it on
+the command line, or which are built into the linker.
+
+@kindex --disable-linker-version
+@item --disable-linker-version
+Disables the @code{LINKER_VERSION} linker script directive, so that it
+does not insert a version string. This is the default.
+
@kindex --enable-non-contiguous-regions
@item --enable-non-contiguous-regions
This option avoids generating an error if an input section does not
@itemx --version
@itemx -V
Display the version number for @command{ld}. The @option{-V} option also
-lists the supported emulations.
+lists the supported emulations. See also the description of the
+@option{--enable-linker-version} in @ref{Options,,Command-line Options}
+which can be used to insert the linker version string into a binary.
@kindex -x
@kindex --discard-all
precedence. @xref{Output Section Fill}, for details on the fill
expression.
+@kindex LINKER_VERSION
+@cindex LINKER_VERSION
+Inserts a string containing the version of the linker at the current
+point. Note - by default this directive is disabled and will do
+nothing. It only becomes active if the
+@option{--enable-linker-version} command line option is used.
+
+Built-in linker scripts for ELF based targets already include this
+directive in their @samp{.comment} section.
+
@node Output Section Keywords
@subsection Output Section Keywords
There are a couple of keywords which can appear as output section
%token END
%left <token> '('
%token <token> ALIGN_K BLOCK BIND QUAD SQUAD LONG SHORT BYTE ASCIZ
-%token SECTIONS PHDRS INSERT_K AFTER BEFORE
+%token SECTIONS PHDRS INSERT_K AFTER BEFORE LINKER_VERSION
%token DATA_SEGMENT_ALIGN DATA_SEGMENT_RELRO_END DATA_SEGMENT_END
%token SORT_BY_NAME SORT_BY_ALIGNMENT SORT_NONE
%token SORT_BY_INIT_PRIORITY
{
lang_add_fill ($3);
}
+ | LINKER_VERSION
+ {
+ lang_add_version_string ();
+ }
| ASSERT_K
{ ldlex_expression (); }
'(' exp ',' NAME ')' separator
#include "obstack.h"
#include "bfdlink.h"
#include "ctf-api.h"
-
#include "ld.h"
#include "ldmain.h"
#include "ldexp.h"
#include "demangle.h"
#include "hashtab.h"
#include "elf-bfd.h"
+#include "bfdver.h"
+
#if BFD_SUPPORTS_PLUGINS
#include "plugin.h"
-#endif /* BFD_SUPPORTS_PLUGINS */
+#endif
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER))
bool had_output_filename = false;
bool lang_float_flag = false;
bool delete_output_file_on_failure = false;
+bool enable_linker_version = false;
struct lang_phdr *lang_phdr_list;
struct lang_nocrossrefs *nocrossref_list;
struct asneeded_minfo **asneeded_list_tail;
lang_end ();
}
+void
+lang_add_version_string (void)
+{
+ if (! enable_linker_version)
+ return;
+
+ const char * str = "GNU ld ";
+ int len = strlen (str);
+ int i;
+
+ for (i = 0 ; i < len ; i++)
+ lang_add_data (BYTE, exp_intop (str[i]));
+
+ str = BFD_VERSION_STRING;
+ len = strlen (str);
+
+ for (i = 0 ; i < len ; i++)
+ lang_add_data (BYTE, exp_intop (str[i]));
+
+ lang_add_data (BYTE, exp_intop ('\0'));
+}
+
/* EXPORTED TO YACC */
void
extern lang_statement_list_type statement_list;
extern lang_statement_list_type *stat_ptr;
extern bool delete_output_file_on_failure;
+extern bool enable_linker_version;
extern struct bfd_sym_chain entry_symbol;
extern const char *entry_section;
lang_add_gc_name (const char *);
extern bool
-print_one_symbol (struct bfd_link_hash_entry *hash_entry, void *ptr);
+print_one_symbol (struct bfd_link_hash_entry *, void *);
+extern void lang_add_version_string
+ (void);
#endif
OPTION_NO_WARN_EXECSTACK,
OPTION_WARN_RWX_SEGMENTS,
OPTION_NO_WARN_RWX_SEGMENTS,
+ OPTION_ENABLE_LINKER_VERSION,
+ OPTION_DISABLE_LINKER_VERSION,
};
/* The initial parser states. */
<WILD>"SHORT" { RTOKEN(SHORT); }
<WILD>"BYTE" { RTOKEN(BYTE); }
<WILD>"ASCIZ" { RTOKEN(ASCIZ); }
+<WILD>"LINKER_VERSION" { RTOKEN(LINKER_VERSION); }
<SCRIPT>"NOFLOAT" { RTOKEN(NOFLOAT); }
<SCRIPT,EXPRESSION>"NOCROSSREFS" { RTOKEN(NOCROSSREFS); }
<SCRIPT,EXPRESSION>"NOCROSSREFS_TO" { RTOKEN(NOCROSSREFS_TO); }
'\0', NULL, N_("Enable support of non-contiguous memory regions"), TWO_DASHES },
{ {"enable-non-contiguous-regions-warnings", no_argument, NULL, OPTION_NON_CONTIGUOUS_REGIONS_WARNINGS},
'\0', NULL, N_("Enable warnings when --enable-non-contiguous-regions may cause unexpected behaviour"), TWO_DASHES },
+ { {"disable-linker-version", no_argument, NULL, OPTION_DISABLE_LINKER_VERSION},
+ '\0', NULL, N_("Disable the LINKER_VERSION linker script directive"), TWO_DASHES },
+ { {"enable-linker-version", no_argument, NULL, OPTION_ENABLE_LINKER_VERSION},
+ '\0', NULL, N_("Enable the LINKER_VERSION linker script directive"), TWO_DASHES },
{ {"EB", no_argument, NULL, OPTION_EB},
'\0', NULL, N_("Link big-endian objects"), ONE_DASH },
{ {"EL", no_argument, NULL, OPTION_EL},
break;
#endif
+ case OPTION_ENABLE_LINKER_VERSION:
+ enable_linker_version = true;
+ break;
+ case OPTION_DISABLE_LINKER_VERSION:
+ enable_linker_version = false;
+ break;
+
case OPTION_UNDEFINED_VERSION:
link_info.allow_undefined_version = true;
break;
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
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
${RELOCATING+*(COMMON)}
${RELOCATING+end = .;}
}
+
+EOF
+
+. $srcdir/scripttempl/misc-sections.sc
+
+. $srcdir/scripttempl/DWARF.sc
+
+cat <<EOF
}
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
__ISTACK_START = .;
}${RELOCATING+ > ram}
- .comment 0 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
__ISTACK_START = .;
} > ram
- .comment 0 : { *(.comment) }
-
EOF
+. $srcdir/scripttempl/misc-sections.sc
. $srcdir/scripttempl/DWARF.sc
cat <<EOF
/* 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
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}
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
${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
}
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
${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
${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
${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
${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
} ${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
} ${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
${RELOCATING+*(.tbss.*)}
${RELOCATING+*(.gnu.linkonce.tb.*)}
}
+EOF
+
+. $srcdir/scripttempl/misc-sections.sc
+. $srcdir/scripttempl/DWARF.sc
+
+cat <<EOF
}
EOF
} ${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
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
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
{
*(.stabstr)
}
-EOF
-
-. $srcdir/scripttempl/DWARF.sc
-
-cat <<EOF
}
EOF
/* 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
${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
${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
--- /dev/null
+# 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
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
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
.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
.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
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
+ .comment 0 : { *(.comment); LINKER_VERSION; }
EOF
${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
*(bss)
${RELOCATING+ __Hbss = .;}
}
+EOF
+
+. $srcdir/scripttempl/misc-sections.sc
+. $srcdir/scripttempl/DWARF.sc
+
+cat <<EOF
}
EOF
--- /dev/null
+# source: data.s
+# ld: --enable-linker-version -e 0
+# readelf: -p.comment
+# target: [is_elf_format]
+# skip: ft32-*-* pru-*-*
+
+String dump of section '.comment':
+.*GNU ld \(GNU Binutils\) 2.*
--- /dev/null
+# source: data.s
+# ld: --enable-linker-version -T ld-version.t
+# readelf: -p.comment
+# target: [is_elf_format]
+
+String dump of section '.comment':
+.*GNU ld \(GNU Binutils\) 2.*
--- /dev/null
+SECTIONS
+{
+ .comment :
+ {
+ *(.comment);
+ LINKER_VERSION;
+ }
+ /DISCARD/ : { *(*) }
+}
run_dump_test "align-with-input"
run_dump_test "pr20302"
run_dump_test "output-section-types"
+run_dump_test "ld-version"
+run_dump_test "ld-version-2"
run_dump_test "segment-start" {{name (default)}}
run_dump_test "segment-start" {{name (overridden)} \