From patchwork Thu Oct 11 13:34:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 148632 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp2139313lji; Thu, 11 Oct 2018 06:38:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VnGQC3jJgSJ0l6iSIEX5LJ8lWibpihRX//omKud4p8QKs5Q1oRDkNQ/7k7N/8v2YXDwcF X-Received: by 2002:a63:c20f:: with SMTP id b15-v6mr1491007pgd.13.1539265114082; Thu, 11 Oct 2018 06:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539265114; cv=none; d=google.com; s=arc-20160816; b=iwLJe83/lxdbYURmbDLU35R3uCoDmBTx9743P9zJO/nkuz9yq/rJE1/2VvHqstQF49 S7gnIfM5xC19ttS5NY+sKkn5+rO1uaV1uZ/77VArZb4EyeeTen920PSNIfa1Gercce3L sTHGVUJZArGbG4LHOokAr2F9qoDQoKKj7k/VmZDYoTbXfr1tGExQMAEWCY4MaIxSf4/y cM8hREliQPkTJ2YRsUntT9AOzYQmXmw06iA7HgERzGp3UUmr7OUi/0qVkx6Qpa5AoqtI i0p6xL62QC3TSv6+2i098EUsSLTIR7jrT6oYJVOZzTJtaIVa61FudaRjvnft7k0fpV6w ctsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature; bh=upFD1dE47mRLqYlCDSPTPz/bboMEf10+AnFxSYnoyAk=; b=hypn/8l66mRt8Q9U8kNHaWgWLN6qwQumxRQ4AEgtNDNloXZtNsafQwiWHSdBd+MUTA rWjq+UzUOcGBpuZSaVDTsdIISuzelhqfaYdTm289VdgBKdJzQGE/2GdUiuMI8M/gLzYG FaQQx7sWqbuVg88+JubaoKHzLAHn0ncobO64excie0rvKh7u7yO3YWRWMv+OOg3HJqHn JmwWXZ/q2mUojo62AfoXduaujFITRFt+DKv8kasvXYoo0RbLVy4PixQS73fr6Vupg+VP YwWoaock+FCHEjPmecTlFoJfyyRt+2iv9/MVhUMj1rc57zz5A6BfOaBFPE2clSKRewT/ hVmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=As1bD3ek; spf=pass (google.com: domain of gcc-patches-return-487339-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-487339-patch=linaro.org@gcc.gnu.org" Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 14-v6si23901329ple.236.2018.10.11.06.38.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 06:38:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-487339-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=As1bD3ek; spf=pass (google.com: domain of gcc-patches-return-487339-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-487339-patch=linaro.org@gcc.gnu.org" DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=Vyx63K7BOOr4CV79gDiQFp3zn81BXUyOGnoJCIVKCkQp0tDGtXlJH t1SujMhQbwyNeGjA84oEFuwFS5LfAVVLxo+kho4BRfsLPZGarO6wLRScUbOjWbpj fGiSwxieK3WGagY3iU0yXr31fNyOtFyW8QIm1mIcNfmwt+/f/0qjEQ= 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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=Rw1m9EoNEhwx2dGGsthJXPvkGlU=; b=As1bD3ekclmyVn8+LFXEU74aPE2F 1qkUPxRMojYAV6l0pB9ST6v0BD49XHWYKPQ/LNLy1SeimiA2hMe/2YIgLKE3GxtN koq0ekBsaEd2ySlgv8I2Vs4mfIG2+feHuzHE7nx+7KM/SiE6K5aIy+SuUW56YXB3 MEk/GRLY42XUkho= Received: (qmail 11800 invoked by alias); 11 Oct 2018 13:38:18 -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 11715 invoked by uid 89); 11 Oct 2018 13:38:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 Oct 2018 13:38:16 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w9BDTJmb009450; Thu, 11 Oct 2018 15:38:14 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2mxjgy5m2c-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 11 Oct 2018 15:38:14 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CF87131; Thu, 11 Oct 2018 13:38:13 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id BCF17554F; Thu, 11 Oct 2018 13:38:13 +0000 (GMT) Received: from gnb.st.com (10.75.127.45) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 11 Oct 2018 15:38:13 +0200 From: Christophe Lyon To: CC: Subject: [ARM/FDPIC v3 08/21] [ARM] FDPIC: Ensure local/global binding for function descriptors Date: Thu, 11 Oct 2018 15:34:45 +0200 Message-ID: <20181011133518.17258-9-christophe.lyon@st.com> In-Reply-To: <20181011133518.17258-1-christophe.lyon@st.com> References: <20181011133518.17258-1-christophe.lyon@st.com> MIME-Version: 1.0 X-IsSubscribed: yes Use local binding rules to decide whether we can use GOTOFFFUNCDESC to compute the function address. 2018-XX-XX Christophe Lyon Mickaël Guêné gcc/ * config/arm/arm.c (arm_local_funcdesc_p): New function. (legitimize_pic_address): Ensure binding rules on function pointers in FDPIC mode. (arm_assemble_integer): Likewise. Change-Id: I3fa0b63bc0f672903f405aa72cc46052de1c0feb -- 2.6.3 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index a6dce36..d0144fd 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3768,6 +3768,42 @@ arm_options_perform_arch_sanity_checks (void) } } +/* Test whether a local function descriptor is canonical, i.e., + whether we can use GOTOFFFUNCDESC to compute the address of the + function. */ +static bool +arm_local_funcdesc_p (rtx fnx) +{ + tree fn; + enum symbol_visibility vis; + bool ret; + + if (!TARGET_FDPIC) + return TRUE; + + if (! SYMBOL_REF_LOCAL_P (fnx)) + return FALSE; + + fn = SYMBOL_REF_DECL (fnx); + + if (! fn) + return FALSE; + + vis = DECL_VISIBILITY (fn); + + if (vis == VISIBILITY_PROTECTED) + /* Private function descriptors for protected functions are not + canonical. Temporarily change the visibility to global so that + we can ensure unicity of funcdesc pointers. */ + DECL_VISIBILITY (fn) = VISIBILITY_DEFAULT; + + ret = default_binds_local_p_1 (fn, flag_pic); + + DECL_VISIBILITY (fn) = vis; + + return ret; +} + static void arm_add_gc_roots (void) { @@ -7485,7 +7521,9 @@ legitimize_pic_address (rtx orig, machine_mode mode, rtx reg) || (GET_CODE (orig) == SYMBOL_REF && SYMBOL_REF_LOCAL_P (orig) && (SYMBOL_REF_DECL (orig) - ? !DECL_WEAK (SYMBOL_REF_DECL (orig)) : 1))) + ? !DECL_WEAK (SYMBOL_REF_DECL (orig)) : 1) + && (!SYMBOL_REF_FUNCTION_P(orig) + || arm_local_funcdesc_p (orig)))) && NEED_GOT_RELOC && arm_pic_data_is_text_relative) insn = arm_pic_static_addr (orig, reg); @@ -23053,7 +23091,9 @@ arm_assemble_integer (rtx x, unsigned int size, int aligned_p) || (GET_CODE (x) == SYMBOL_REF && (!SYMBOL_REF_LOCAL_P (x) || (SYMBOL_REF_DECL (x) - ? DECL_WEAK (SYMBOL_REF_DECL (x)) : 0)))) + ? DECL_WEAK (SYMBOL_REF_DECL (x)) : 0) + || (SYMBOL_REF_FUNCTION_P (x) + && !arm_local_funcdesc_p (x))))) { if (TARGET_FDPIC && SYMBOL_REF_FUNCTION_P (x)) fputs ("(GOTFUNCDESC)", asm_out_file);