From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2932 invoked by alias); 7 Aug 2014 00:55:01 -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 2920 invoked by uid 89); 7 Aug 2014 00:54:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 07 Aug 2014 00:54:58 +0000 Received: by mail-pa0-f50.google.com with SMTP id et14so4323099pad.23 for ; Wed, 06 Aug 2014 17:54:56 -0700 (PDT) X-Received: by 10.70.54.41 with SMTP id g9mr14260833pdp.120.1407372896797; Wed, 06 Aug 2014 17:54:56 -0700 (PDT) Received: from bubble.grove.modra.org ([58.160.155.134]) by mx.google.com with ESMTPSA id do10sm3719076pdb.83.2014.08.06.17.54.54 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 06 Aug 2014 17:54:56 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 5C1CDEA33E5; Thu, 7 Aug 2014 10:24:51 +0930 (CST) Date: Thu, 07 Aug 2014 00:55:00 -0000 From: Alan Modra To: binutils@sourceware.org Cc: "H.J. Lu" Subject: Re: [PATCH] PR ld/16746: Don't issue a warning for reference in LTO IR Message-ID: <20140807005451.GU8921@bubble.grove.modra.org> Mail-Followup-To: binutils@sourceware.org, "H.J. Lu" References: <20140807004158.GT8921@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140807004158.GT8921@bubble.grove.modra.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes X-SW-Source: 2014-08/txt/msg00053.txt.bz2 The thread https://sourceware.org/ml/binutils/2014-03/msg00261.html died without any resolution, I guess a case of me wanting perfection and rejecting the good. So now that I've merged the WARN and CWARN my concern with HJ's patch is covered. This is what I'm about to commit on HJ's behalf. bfd/ PR ld/16746 * linker.c (_bfd_generic_link_add_one_symbol): Don't issue a warning for references in LTO IR to warning symbols. ld/testsuite/ PR ld/16746 * ld-plugin/lto.exp: Add 4 tests for PR ld/16746. * ld-plugin/pr16746a.c: New file. * ld-plugin/pr16746b.c: Likewise. * ld-plugin/pr16746c.c: Likewise. * ld-plugin/pr16746d.c: Likewise. diff --git a/bfd/linker.c b/bfd/linker.c index 93c5465..d4b053c 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -1776,8 +1776,10 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, break; case WARNC: - /* Issue a warning and cycle. */ - if (h->u.i.warning != NULL) + /* Issue a warning and cycle, except when the reference is + in LTO IR. */ + if (h->u.i.warning != NULL + && (abfd->flags & BFD_PLUGIN) == 0) { if (! (*info->callbacks->warning) (info, h->u.i.warning, h->root.string, abfd, @@ -1802,12 +1804,9 @@ _bfd_generic_link_add_one_symbol (struct bfd_link_info *info, break; case WARN: - /* Warn if this symbol has been referenced already, - otherwise add a warning. A symbol has been referenced if - the u.undef.next field is not NULL, or it is the tail of the - undefined symbol list. The REF case above helps to - ensure this. */ - if (h->u.undef.next != NULL || info->hash->undefs_tail == h) + /* Warn if this symbol has been referenced already from non-IR, + otherwise add a warning. */ + if (h->non_ir_ref) { if (! (*info->callbacks->warning) (info, string, h->root.string, hash_entry_bfd (h), NULL, 0)) diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 432c753..7ff5bfb 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -232,6 +232,18 @@ set lto_link_elf_tests [list \ [list "Build libpr15146d.a" \ "$plug_opt" "-flto -O2" \ {pr15146d.c} {} "lib15146d.a"] \ + [list "Build libpr16746a.a" \ + "" "" \ + {pr16746a.c pr16746b.c} {} "lib15146a.a"] \ + [list "Build libpr16746b.a" \ + "$plug_opt" "-O2 -flto" \ + {pr16746c.c pr16746d.c} {} "lib15146b.a"] \ + [list "PR ld/16746 (1)" \ + "-O2 -flto -fuse-linker-plugin tmpdir/pr16746a.o tmpdir/pr16746c.o" "-O2 -flto" \ + {dummy.c} {} "pr16746a.exe"] \ + [list "PR ld/16746 (2)" \ + "-O2 -flto -fuse-linker-plugin tmpdir/pr16746c.o tmpdir/pr16746a.o" "-O2 -flto" \ + {dummy.c} {} "pr16746b.exe"] \ ] # Check final symbols in executables. @@ -335,6 +347,20 @@ if { [is_elf_format] && [check_lto_shared_available] } { } { fail $testname } + set testname "PR ld/16746 (3)" + set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"] + if { [ regexp "warning: foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } { + pass $testname + } { + fail $testname + } + set testname "PR ld/16746 (4)" + set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"] + if { [ regexp "warning: foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } { + pass $testname + } { + fail $testname + } } set testname "Build liblto-11.a" diff --git a/ld/testsuite/ld-plugin/pr16746a.c b/ld/testsuite/ld-plugin/pr16746a.c new file mode 100644 index 0000000..1705ef1 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr16746a.c @@ -0,0 +1,3 @@ +static const char __evoke_link_warning_foobar[] + __attribute__ ((used, section (".gnu.warning.foobar\n\t#"))) + = "foobar"; diff --git a/ld/testsuite/ld-plugin/pr16746b.c b/ld/testsuite/ld-plugin/pr16746b.c new file mode 100644 index 0000000..c3b7a78 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr16746b.c @@ -0,0 +1,5 @@ +static const char __evoke_link_warning_foobar[] + __attribute__ ((used, section (".gnu.warning.foobar\n\t#"))) + = "foobar"; + +void foobar (void) {} diff --git a/ld/testsuite/ld-plugin/pr16746c.c b/ld/testsuite/ld-plugin/pr16746c.c new file mode 100644 index 0000000..fb68ab7 --- /dev/null +++ b/ld/testsuite/ld-plugin/pr16746c.c @@ -0,0 +1,8 @@ +extern void foobar (void); +int +main (int argc, char **argv) +{ + if (__builtin_constant_p (argc)) + foobar (); + return 0; +} diff --git a/ld/testsuite/ld-plugin/pr16746d.c b/ld/testsuite/ld-plugin/pr16746d.c new file mode 100644 index 0000000..1fee4dd --- /dev/null +++ b/ld/testsuite/ld-plugin/pr16746d.c @@ -0,0 +1,8 @@ +extern void foobar (void); +int +main (int argc, char **argv) +{ + if (!__builtin_constant_p (argc)) + foobar (); + return 0; +} -- Alan Modra Australia Development Lab, IBM