public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elfcpp: Add Sym::Sym(unsigned char*) constructor
@ 2020-12-19 14:57 H.J. Lu
  2020-12-19 19:59 ` Cary Coutant
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2020-12-19 14:57 UTC (permalink / raw)
  To: binutils

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-19 21:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19 14:57 [PATCH] elfcpp: Add Sym::Sym(unsigned char*) constructor H.J. Lu
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

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).