From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9662 invoked by alias); 25 Mar 2014 22:50:10 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 9649 invoked by uid 89); 25 Mar 2014 22:50:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f176.google.com Received: from mail-ob0-f176.google.com (HELO mail-ob0-f176.google.com) (209.85.214.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 25 Mar 2014 22:50:07 +0000 Received: by mail-ob0-f176.google.com with SMTP id wp18so1439503obc.35 for ; Tue, 25 Mar 2014 15:50:06 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.227.10 with SMTP id rw10mr1019487oec.51.1395787805954; Tue, 25 Mar 2014 15:50:05 -0700 (PDT) Received: by 10.76.151.198 with HTTP; Tue, 25 Mar 2014 15:50:05 -0700 (PDT) In-Reply-To: <20140325223910.GJ18201@bubble.grove.modra.org> References: <20140325203952.GA11925@intel.com> <20140325223910.GJ18201@bubble.grove.modra.org> Date: Tue, 25 Mar 2014 22:50:00 -0000 Message-ID: Subject: Re: [PATCH] PR ld/16746: Don't issue a warning for reference in LTO IR From: "H.J. Lu" To: Binutils Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00263.txt.bz2 On Tue, Mar 25, 2014 at 3:39 PM, Alan Modra wrote: > On Tue, Mar 25, 2014 at 01:39:52PM -0700, H.J. Lu wrote: >> case WARNC: >> - /* Issue a warning and cycle. */ >> - if (h->u.i.warning != NULL) >> + /* Issue a warning and cycle. Don't issue a warning for >> + reference in LTO IR which may be removed by LTO later. */ >> + if (h->u.i.warning != NULL >> + && (abfd->flags & BFD_PLUGIN) == 0) > > So here you're handling references in LTO IR for warning symbols > defined in real object files or other LTO IR files.. Yes. >> case WARN: >> + /* Don't issue a warning for reference in LTO IR which may be >> + removed by LTO later. Make a warning symbol instead. */ >> + if ((hash_entry_bfd (h)->flags & BFD_PLUGIN) != 0) >> + goto mwarn; >> + > > And here you have the case where the new symbol is a warning symbol, > in either LTO IR or real object files, but the reference was in an LTO > IR file. Yes. > What about the CWARN case, where you already have a definition that > may have been referenced, and the new symbol is a warning symbol? > You'll need to test h->non_ir_ref I think. It is: https://sourceware.org/bugzilla/show_bug.cgi?id=12760 We are getting: [hjl@gnu-6 pr12760]$ cat pr12760a.c extern void bar (); void foo () { bar (); } [hjl@gnu-6 pr12760]$ cat pr12760b.c #define linker_warning(x, msg) \ static const char __warn_##x[] \ __attribute__((used, section(".gnu.warning." #x))) \ = msg void bar (void) {} linker_warning(bar, "Bad bar"); [hjl@gnu-6 pr12760]$ make gcc -B./ -c -o pr12760a.o pr12760a.c gcc -B./ -flto -O2 -ffat-lto-objects -c -o pr12760b.o pr12760b.c ar rcs libpr12760.a pr12760b.o gcc -B./ -O2 -Wl,-e,foo -nostdlib -flto -fuse-linker-plugin -o foo pr12760a.o -Wl,--start-group libpr12760.a -Wl,--end-group pr12760b.o (symbol from plugin): warning: Bad bar [hjl@gnu-6 pr12760]$ It is similar to: https://sourceware.org/bugzilla/show_bug.cgi?id=16756 Since we don't keep the undefined reference when seeing a definition, we lose the reference info. We can't get the correct warning message. -- H.J.