From patchwork Fri Mar 6 01:31:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 446978 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 592781400A0 for ; Fri, 6 Mar 2015 12:32:03 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=slTPeqUN; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=SIiKXxBAxVSOViTG6HsJEl79aUyuf3O5TAhLmQ9IQGq Wlc84TWv8toOP+kkPPPV9U2n0qeuJ+W7yOflekYn7yWgkJKbMLhnJ2Cog+dlDQNF ZKz2Hh3b/ldUu0FoFZr91dbo+gRtXgV8YnHmXsJGLf/2Z/0rd7g8+q1FyEPv8I/M = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=QJ77+ZGk/CLbpZbkPlPkJTASveI=; b=slTPeqUN738UAvYWx odMkUz/Pcz3YfoOybuwSbYrqhOQQWAIQ6j9M+O7NFEqpcQPiFMiuyMolMOrrDoDf q2kZUPIvax7xmZDsxhZa83M0/9qXg9iebjuekzUEnI44AcCdXhByHzJbSTdNRZew cPSUQzgfArTurbLY8QYZzkYL9U= Received: (qmail 58605 invoked by alias); 6 Mar 2015 01:31:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 58593 invoked by uid 89); 6 Mar 2015 01:31:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_50, NO_DNS_FOR_FROM, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga11.intel.com Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Mar 2015 01:31:53 +0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 05 Mar 2015 17:31:51 -0800 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([172.25.70.151]) by fmsmga001.fm.intel.com with ESMTP; 05 Mar 2015 17:31:51 -0800 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id CD698200C49; Thu, 5 Mar 2015 17:31:51 -0800 (PST) Date: Thu, 5 Mar 2015 17:31:51 -0800 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Subject: [PATCH] PR target/65248: Copy relocation against protected symbol doesn't work Message-ID: <20150306013151.GA19444@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Protected data symbol means that it can't be pre-emptied. It doesn't mean its address won't be external. This is true for pointer to protected function. With copy relocation, address of protected data defined in the shared library may also be external. We only know that for sure at run-time. TARGET_BINDS_LOCAL_P should return false on protected data symbol. OK for trunk? Thanks. H.J. --- PR target/65248 * output.h (default_binds_local_p_2): New. * varasm.c (default_binds_local_p_2): Renamed to ... (default_binds_local_p_3): This. Don't return true on protected data symbol if protected data may be external. (default_binds_local_p): Use default_binds_local_p_3. (default_binds_local_p_1): Likewise. (default_binds_local_p_2): New. * config/i386/i386.c (TARGET_BINDS_LOCAL_P): Replace darwin_binds_local_p with default_binds_local_p_2. --- gcc/config/i386/i386.c | 3 +++ gcc/output.h | 1 + gcc/varasm.c | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index ab8f03a..41a487a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -51878,6 +51878,9 @@ ix86_initialize_bounds (tree var, tree lb, tree ub, tree *stmts) #if TARGET_MACHO #undef TARGET_BINDS_LOCAL_P #define TARGET_BINDS_LOCAL_P darwin_binds_local_p +#else +#undef TARGET_BINDS_LOCAL_P +#define TARGET_BINDS_LOCAL_P default_binds_local_p_2 #endif #if TARGET_DLLIMPORT_DECL_ATTRIBUTES #undef TARGET_BINDS_LOCAL_P diff --git a/gcc/output.h b/gcc/output.h index 217d979..53e47d0 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -586,6 +586,7 @@ extern void default_asm_output_anchor (rtx); extern bool default_use_anchors_for_symbol_p (const_rtx); extern bool default_binds_local_p (const_tree); extern bool default_binds_local_p_1 (const_tree, int); +extern bool default_binds_local_p_2 (const_tree); extern void default_globalize_label (FILE *, const char *); extern void default_globalize_decl_name (FILE *, tree); extern void default_emit_unwind_label (FILE *, tree, int, int); diff --git a/gcc/varasm.c b/gcc/varasm.c index 8173207..87ac646 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6803,7 +6803,8 @@ resolution_local_p (enum ld_plugin_symbol_resolution resolution) } static bool -default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate) +default_binds_local_p_3 (const_tree exp, bool shlib, bool weak_dominate, + bool extern_protected_data) { /* A non-decl is an entry in the constant pool. */ if (!DECL_P (exp)) @@ -6849,6 +6850,9 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate) or if we have a definition for the symbol. We cannot infer visibility for undefined symbols. */ if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT + && (TREE_CODE (exp) == FUNCTION_DECL + || !extern_protected_data + || DECL_VISIBILITY (exp) != VISIBILITY_PROTECTED) && (DECL_VISIBILITY_SPECIFIED (exp) || defined_locally)) return true; @@ -6884,13 +6888,21 @@ default_binds_local_p_2 (const_tree exp, bool shlib, bool weak_dominate) bool default_binds_local_p (const_tree exp) { - return default_binds_local_p_2 (exp, flag_shlib != 0, true); + return default_binds_local_p_3 (exp, flag_shlib != 0, true, false); +} + +/* Similar to default_binds_local_p, but protected data may be + external. */ +bool +default_binds_local_p_2 (const_tree exp) +{ + return default_binds_local_p_3 (exp, flag_shlib != 0, true, true); } bool default_binds_local_p_1 (const_tree exp, int shlib) { - return default_binds_local_p_2 (exp, shlib != 0, false); + return default_binds_local_p_3 (exp, shlib != 0, false, false); } /* Return true when references to DECL must bind to current definition in