From: "H.J. Lu" <hjl.tools@gmail.com>
To: Cary Coutant <ccoutant@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: [PATCH] gold: Move sym declaration just before use
Date: Sat, 19 Dec 2020 13:31:45 -0800 [thread overview]
Message-ID: <CAMe9rOr-gbx+LB_UF1NzqhtUw9vy0zTEQSfqZF3=Sm52zxr+vA@mail.gmail.com> (raw)
In-Reply-To: <CAJimCsHwTt+8_uK55RD6VmuiiaUahoQTW09u3AYo39Kjicc4YQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 262 bytes --]
On Sat, Dec 19, 2020 at 1:02 PM Cary Coutant <ccoutant@gmail.com> wrote:
>
> > Both fixed the build. Here is the complete patch to fox GCC 11 build.
>
> This is OK, with ChangeLog entry. Thanks!
>
> -cary
This is the patch I am checking in.
Thanks.
--
H.J.
[-- Attachment #2: 0001-gold-Move-sym-declaration-just-before-use.patch --]
[-- Type: text/x-patch, Size: 3501 bytes --]
From 68b09ebb5df333e2bac42ed3f8ff7c7e7ab925a1 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 19 Dec 2020 13:30:39 -0800
Subject: [PATCH] gold: Move sym declaration just before use
Move sym declaration just before use to avoid -Wmaybe-uninitialized
warning from GCC 11.
PR gold/27097
* incremental.cc (Sized_relobj_incr::do_add_symbols): Move sym
declaration just before use.
(Sized_incr_dynobj::do_add_symbols): Likewise.
* plugin.cc (Sized_pluginobj::do_add_symbols): Likewise.
---
gold/ChangeLog | 8 ++++++++
gold/incremental.cc | 4 ++--
gold/plugin.cc | 2 +-
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 77b1f886c3..9614a87f76 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,11 @@
+2020-12-19 H.J. Lu <hjl.tools@gmail.com>
+
+ PR gold/27097
+ * incremental.cc (Sized_relobj_incr::do_add_symbols): Move sym
+ declaration just before use.
+ (Sized_incr_dynobj::do_add_symbols): Likewise.
+ * plugin.cc (Sized_pluginobj::do_add_symbols): Likewise.
+
2020-12-15 Cary Coutant <ccoutant@gmail.com>
* dwp.cc (class Dwo_file): Use new Ehdr::get_ei_osabi and
diff --git a/gold/incremental.cc b/gold/incremental.cc
index 1f2ae5b87b..525c92cff6 100644
--- a/gold/incremental.cc
+++ b/gold/incremental.cc
@@ -2129,7 +2129,6 @@ Sized_relobj_incr<size, big_endian>::do_add_symbols(
{
const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
unsigned char symbuf[sym_size];
- elfcpp::Sym<size, big_endian> sym(symbuf);
elfcpp::Sym_write<size, big_endian> osym(symbuf);
typedef typename elfcpp::Elf_types<size>::Elf_WXword Elf_size_type;
@@ -2196,6 +2195,7 @@ Sized_relobj_incr<size, big_endian>::do_add_symbols(
osym.put_st_other(gsym.get_st_other());
osym.put_st_shndx(shndx);
+ elfcpp::Sym<size, big_endian> sym(symbuf);
Symbol* res = symtab->add_from_incrobj(this, name, NULL, &sym);
if (shndx != elfcpp::SHN_UNDEF)
@@ -2730,7 +2730,6 @@ Sized_incr_dynobj<size, big_endian>::do_add_symbols(
{
const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
unsigned char symbuf[sym_size];
- elfcpp::Sym<size, big_endian> sym(symbuf);
elfcpp::Sym_write<size, big_endian> osym(symbuf);
unsigned int nsyms = this->input_reader_.get_global_symbol_count();
@@ -2795,6 +2794,7 @@ Sized_incr_dynobj<size, big_endian>::do_add_symbols(
osym.put_st_other(gsym.get_st_other());
osym.put_st_shndx(shndx);
+ elfcpp::Sym<size, big_endian> sym(symbuf);
Sized_symbol<size>* res =
symtab->add_from_incrobj<size, big_endian>(this, name, NULL, &sym);
this->symbols_[i] = res;
diff --git a/gold/plugin.cc b/gold/plugin.cc
index fd37957e73..5f5da5dcea 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -1397,7 +1397,6 @@ Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab,
{
const int sym_size = elfcpp::Elf_sizes<size>::sym_size;
unsigned char symbuf[sym_size];
- elfcpp::Sym<size, big_endian> sym(symbuf);
elfcpp::Sym_write<size, big_endian> osym(symbuf);
Plugin_recorder* recorder = parameters->options().plugins()->recorder();
@@ -1480,6 +1479,7 @@ Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab,
osym.put_st_other(vis, 0);
osym.put_st_shndx(shndx);
+ elfcpp::Sym<size, big_endian> sym(symbuf);
this->symbols_[i] =
symtab->add_from_pluginobj<size, big_endian>(this, name, ver, &sym);
}
--
2.29.2
prev parent reply other threads:[~2020-12-19 21:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` H.J. Lu [this message]
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='CAMe9rOr-gbx+LB_UF1NzqhtUw9vy0zTEQSfqZF3=Sm52zxr+vA@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=ccoutant@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).