From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65025 invoked by alias); 1 Sep 2015 07:51:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 65013 invoked by uid 89); 1 Sep 2015 07:51:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KAM_STOCKGEN,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pa0-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 01 Sep 2015 07:51:21 +0000 Received: by pacdd16 with SMTP id dd16so168072842pac.2 for ; Tue, 01 Sep 2015 00:51:19 -0700 (PDT) X-Received: by 10.68.88.130 with SMTP id bg2mr43754881pbb.129.1441093879236; Tue, 01 Sep 2015 00:51:19 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-155-134.oycza5.sa.bigpond.net.au. [58.160.155.134]) by smtp.gmail.com with ESMTPSA id tq6sm17004044pbc.57.2015.09.01.00.51.18 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 00:51:18 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id B67D3EA0078; Tue, 1 Sep 2015 17:21:13 +0930 (ACST) Date: Tue, 01 Sep 2015 07:51:00 -0000 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: David Edelsohn Subject: [RS6000] Weak functions may not be file local Message-ID: <20150901075113.GQ24814@bubble.grove.modra.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00003.txt.bz2 A weak symbol defined in the current object file may not turn out to be the definition used at link time, if other copies of the symbol exist. This means they can't be considered file local; Calls to weak functions need a nop so that the linker can replace it with a toc restoring insn if the function uses a different toc pointer to its caller (for linker grouping of TOC into multiple sections). Bootstrapped and regression tested powerpc64-linux. OK for active branches? PR target/67417 * config/rs6000/predicates.md (current_file_function_operand): Don't return true for weak symbols. * config/rs6000/rs6000.c (rs6000_function_ok_for_sibcall): Likewise. diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md index 6020a08..2e59b22 100644 --- a/gcc/config/rs6000/predicates.md +++ b/gcc/config/rs6000/predicates.md @@ -883,12 +883,12 @@ (define_predicate "current_file_function_operand" (and (match_code "symbol_ref") (match_test "(DEFAULT_ABI != ABI_AIX || SYMBOL_REF_FUNCTION_P (op)) - && ((SYMBOL_REF_LOCAL_P (op) - && ((DEFAULT_ABI != ABI_AIX - && DEFAULT_ABI != ABI_ELFv2) - || !SYMBOL_REF_EXTERNAL_P (op))) - || (op == XEXP (DECL_RTL (current_function_decl), - 0)))"))) + && (SYMBOL_REF_LOCAL_P (op) + || op == XEXP (DECL_RTL (current_function_decl), 0)) + && !((DEFAULT_ABI == ABI_AIX + || DEFAULT_ABI == ABI_ELFv2) + && (SYMBOL_REF_EXTERNAL_P (op) + || SYMBOL_REF_WEAK (op)))"))) ;; Return 1 if this operand is a valid input for a move insn. (define_predicate "input_operand" diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index e1332c1..fa646b5 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -22659,6 +22659,7 @@ rs6000_function_ok_for_sibcall (tree decl, tree exp) || ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) && decl && !DECL_EXTERNAL (decl) + && !DECL_WEAK (decl) && (*targetm.binds_local_p) (decl)) || (DEFAULT_ABI == ABI_V4 && (!TARGET_SECURE_PLT -- Alan Modra Australia Development Lab, IBM