From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 9C4503858C27 for ; Sat, 19 Dec 2020 19:59:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9C4503858C27 Received: by mail-il1-x135.google.com with SMTP id q1so5396051ilt.6 for ; Sat, 19 Dec 2020 11:59:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oPTfh9j4YInh06O4wM7M1pBEnoeegaD8+aLwvAREKpQ=; b=eCUSYIMKM/ubnmlbtQ3TFct5JqJEEvp+KJ504BcqlGbP6t+NQKgS3+fcRvgBcWTmzd Ltj2mP2+gKvbkddCeNq2N0MIqUKMDFhPscVdwGQTjNHbqvYwQhSNLbrl8Ys4E6SCBbxN q3q+czmIeYWncXZJQKJLrV+aaH0C3bOWtRrrud3YfOixqhcIhnK9+tknYEruQngASy5M L1tam7Z82fA9pn07mML7QrkB/9SKY3JHy1Hx5jnFdowCVQldkHVoGn9gTeCE/+uJIc58 a4LpAfzUXcr1DE97rnjTdHaCohXYrKwtExo0VHoBEuWiYIAHeCLsUPNCEKxFnMpv6cZP 1skA== X-Gm-Message-State: AOAM533uTfSd0MKhxjOt2xRix5PZPxmQos0+xvFE4KCFwN3o2Kxebpod +6johwCBr2xRuesEGDt8ps88mxWMJf3ApMxVEaY= X-Google-Smtp-Source: ABdhPJyMZYia8l/MMUO0T3uFkSq671jksnSgDCvg9RsHugy/YWrH2wLpnGyG3FQ67RpmIX+LI4zfnSwOI7fsMymUTIQ= X-Received: by 2002:a92:a043:: with SMTP id b3mr10331639ilm.272.1608407975984; Sat, 19 Dec 2020 11:59:35 -0800 (PST) MIME-Version: 1.0 References: <20201219145718.171683-1-hjl.tools@gmail.com> In-Reply-To: <20201219145718.171683-1-hjl.tools@gmail.com> From: Cary Coutant Date: Sat, 19 Dec 2020 11:59:25 -0800 Message-ID: Subject: Re: [PATCH] elfcpp: Add Sym::Sym(unsigned char*) constructor To: "H.J. Lu" Cc: Binutils Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Dec 2020 19:59:37 -0000 Does this patch fix the problem? --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -1397,8 +1397,8 @@ Sized_pluginobj::do_add_symbols(Symbol_table* symtab, { const int sym_size =3D elfcpp::Elf_sizes::sym_size; unsigned char symbuf[sym_size]; - elfcpp::Sym sym(symbuf); elfcpp::Sym_write osym(symbuf); + elfcpp::Sym sym(symbuf); Plugin_recorder* recorder =3D parameters->options().plugins()->recorder(= ); if (recorder !=3D NULL) If not that, then how about this: --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -1397,7 +1397,6 @@ Sized_pluginobj::do_add_symbols(Symbol_table* symtab, { const int sym_size =3D elfcpp::Elf_sizes::sym_size; unsigned char symbuf[sym_size]; - elfcpp::Sym sym(symbuf); elfcpp::Sym_write osym(symbuf); Plugin_recorder* recorder =3D parameters->options().plugins()->recorder(= ); @@ -1480,6 +1479,7 @@ Sized_pluginobj::do_add_symbols(Symbol_table* symtab, osym.put_st_other(vis, 0); osym.put_st_shndx(shndx); + elfcpp::Sym sym(symbuf); this->symbols_[i] =3D symtab->add_from_pluginobj(this, name, ver, &sym= ); } (Sorry, I don't have GCC 11 available to test.) I don't think adding a new constructor is the right solution. -cary On Sat, Dec 19, 2020 at 6:57 AM H.J. Lu wrote: > > 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=E2=80=99t 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 =3D elfcpp::Elf_sizes::sym_size; > unsigned char symbuf[sym_size]; > elfcpp::Sym 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*>(p)) > { } > > + Sym(unsigned char* p) > + : p_(reinterpret_cast*>(p)) > + { } > + > template > Sym(File* file, typename File::Location loc) > : p_(reinterpret_cast*>( > -- > 2.29.2 >