gold: Move sym declaration just before use
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 19 Dec 2020 21:30:39 +0000 (13:30 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 19 Dec 2020 21:37:04 +0000 (13:37 -0800)
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
gold/incremental.cc
gold/plugin.cc

index 77b1f886c305f82cbb723b346b15434d497d03b0..9614a87f76d169e22a3a4eb9428b1a7448d174a2 100644 (file)
@@ -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
index 1f2ae5b87b3f2fab61e07d151e216bcdca4001f2..525c92cff66053a97f5e8c4c3eaca379157c4f26 100644 (file)
@@ -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;
index fd37957e73c717067a4039188f125470e53cd50b..5f5da5dceaac720799460c14dccc8e602c69576b 100644 (file)
@@ -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);
     }
This page took 0.033971 seconds and 4 git commands to generate.