From: Nick Clifton <nickc@redhat.com>
To: ccoutant@gmail.com, iant@google.com
Cc: Binutils <binutils@sourceware.org>, Tom Kacvinsky <tkacvins@gmail.com>
Subject: Fwd: [Bug gold/30187] ld.bfd and ld.gold versions in .comment section of ELF files
Date: Fri, 24 Mar 2023 14:02:55 +0000 [thread overview]
Message-ID: <ba77df02-5583-fb1d-5e1c-812106c2749f@redhat.com> (raw)
In-Reply-To: <bug-30187-203-IEFdc8yfKB@http.sourceware.org/bugzilla/>
[-- Attachment #1: Type: text/plain, Size: 314 bytes --]
Hi Cary, Hi Ian,
Any objection to applying the attached patch (from PR 30187) to gold ?
It adds a linker option to move the gold identifier string from the
.note.gnu.gold-version section to the .comment section, in order to
match the behaviour of lld and then recent update to ld.bfd.
Cheers
Nick
[-- Attachment #2: pr30187.gold.patch --]
[-- Type: text/x-patch, Size: 2174 bytes --]
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"));
next parent reply other threads:[~2023-03-24 14:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <bug-30187-203-IEFdc8yfKB@http.sourceware.org/bugzilla/>
2023-03-24 14:02 ` Nick Clifton [this message]
2023-03-24 17:48 ` Ian Lance Taylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba77df02-5583-fb1d-5e1c-812106c2749f@redhat.com \
--to=nickc@redhat.com \
--cc=binutils@sourceware.org \
--cc=ccoutant@gmail.com \
--cc=iant@google.com \
--cc=tkacvins@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).