* [binutils-gdb] Add an option to the gold linker to put its version string into the .comment section.
@ 2023-03-27 10:10 Nick Clifton
0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2023-03-27 10:10 UTC (permalink / raw)
To: bfd-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=eb42b9d6f914b233d740da88d5e21c6690170b7d
commit eb42b9d6f914b233d740da88d5e21c6690170b7d
Author: Nick Clifton <nickc@redhat.com>
Date: Mon Mar 27 11:10:10 2023 +0100
Add an option to the gold linker to put its version string into the .comment section.
PR 30187
* options.h (class General_options): Add enable-linker-version.
* layout.cc (Layout::create_gold_note): If linker-version is enabled put the version string into the .comment section.
Diff:
---
gold/ChangeLog | 7 +++++++
gold/layout.cc | 39 +++++++++++++++++++++++++++++----------
gold/options.h | 4 ++++
3 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 2aec5d608ae..8dfb150f60e 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,10 @@
+2023-03-27 Nick Clifton <nickc@redhat.com>
+
+ PR 30187
+ * options.h (class General_options): Add enable-linker-version.
+ * layout.cc (Layout::create_gold_note): If linker-version is
+ enabled put the version string into the .comment section.
+
2023-01-03 Nick Clifton <nickc@redhat.com>
* po/ro.po: Updated Romainian translation.
diff --git a/gold/layout.cc b/gold/layout.cc
index 899d4af0707..a50086897bb 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -3333,19 +3333,38 @@ Layout::create_gold_note()
std::string desc = std::string("gold ") + gold::get_version_string();
- size_t trailing_padding;
- Output_section* os = this->create_note("GNU", elfcpp::NT_GNU_GOLD_VERSION,
- ".note.gnu.gold-version", desc.size(),
- false, &trailing_padding);
- if (os == NULL)
- return;
+ Output_section* os;
+ Output_section_data* posd;
- Output_section_data* posd = new Output_data_const(desc, 4);
- os->add_output_section_data(posd);
+ if (!parameters->options().enable_linker_version())
+ {
+ size_t trailing_padding;
+
+ os = this->create_note("GNU", elfcpp::NT_GNU_GOLD_VERSION,
+ ".note.gnu.gold-version", desc.size(),
+ false, &trailing_padding);
+ if (os == NULL)
+ return;
+
+ posd = new Output_data_const(desc, 4);
+ os->add_output_section_data(posd);
- if (trailing_padding > 0)
+ if (trailing_padding > 0)
+ {
+ posd = new Output_data_zero_fill(trailing_padding, 0);
+ os->add_output_section_data(posd);
+ }
+ }
+ else
{
- posd = new Output_data_zero_fill(trailing_padding, 0);
+ os = this->choose_output_section(NULL, ".comment",
+ elfcpp::SHT_PROGBITS, 0,
+ false, ORDER_INVALID,
+ false, false, false);
+ if (os == NULL)
+ return;
+
+ posd = new Output_data_const(desc, 1);
os->add_output_section_data(posd);
}
}
diff --git a/gold/options.h b/gold/options.h
index 1aa451c7711..46f658f23ea 100644
--- a/gold/options.h
+++ b/gold/options.h
@@ -847,6 +847,10 @@ class General_options
N_("Enable use of DT_RUNPATH"),
N_("Disable use of DT_RUNPATH"));
+ DEFINE_enable(linker_version, options::EXACTLY_TWO_DASHES, '\0', false,
+ N_("Put the linker version string into the .comment section"),
+ N_("Put the linker version string into the .note.gnu.gold-version section"));
+
DEFINE_bool(enum_size_warning, options::TWO_DASHES, '\0', true, NULL,
N_("(ARM only) Do not warn about objects with incompatible "
"enum sizes"));
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-27 10:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-27 10:10 [binutils-gdb] Add an option to the gold linker to put its version string into the .comment section Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).