public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Subject: [PATCH] elfcpp: Add Sym::Sym(unsigned char*) constructor
Date: Sat, 19 Dec 2020 06:57:18 -0800	[thread overview]
Message-ID: <20201219145718.171683-1-hjl.tools@gmail.com> (raw)

GCC 11 failed to build gold at -O0 due to -Wmaybe-uninitialized change
in GCC 11:

    In addition, passing a pointer (or in C++, a reference) to an
uninitialized object to a const-qualified function argument is also
diagnosed by this warning. (-Wuninitialized is issued for built-in
functions known to read the object.) Annotating the function with
attribute access (none) indicates that the argument isn’t used to
access the object and avoids the warning (see Common Function Attributes).

Add Sym::Sym(unsigned char*) constructor to support

  const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
  unsigned char symbuf[sym_size];
  elfcpp::Sym<size, big_endian> sym(symbuf);

	PR gold/27097
	elfcpp.h (Sym::Sym(unsigned char*)): New.
---
 elfcpp/elfcpp.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/elfcpp/elfcpp.h b/elfcpp/elfcpp.h
index 428ecb8935..5ed9711dfa 100644
--- a/elfcpp/elfcpp.h
+++ b/elfcpp/elfcpp.h
@@ -1533,6 +1533,10 @@ class Sym
     : p_(reinterpret_cast<const internal::Sym_data<size>*>(p))
   { }
 
+  Sym(unsigned char* p)
+    : p_(reinterpret_cast<const internal::Sym_data<size>*>(p))
+  { }
+
   template<typename File>
   Sym(File* file, typename File::Location loc)
     : p_(reinterpret_cast<const internal::Sym_data<size>*>(
-- 
2.29.2


             reply	other threads:[~2020-12-19 14:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-19 14:57 H.J. Lu [this message]
2020-12-19 19:59 ` Cary Coutant
2020-12-19 20:12   ` H.J. Lu
2020-12-19 21:02     ` Cary Coutant
2020-12-19 21:31       ` [PATCH] gold: Move sym declaration just before use H.J. Lu

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=20201219145718.171683-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    /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).