From patchwork Fri Nov 16 15:47:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 151356 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp587986ljp; Fri, 16 Nov 2018 07:51:11 -0800 (PST) X-Google-Smtp-Source: AJdET5d6FC+mogEDwZhhxFwpIvvFKdkEsclkVRoa1BdVNRXXzVsFC7q8dKJvN4N4wJqd7prbNyqh X-Received: by 2002:a62:5d0c:: with SMTP id r12mr12107460pfb.0.1542383471534; Fri, 16 Nov 2018 07:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542383471; cv=none; d=google.com; s=arc-20160816; b=EJ5/c+vRUoghirxsXb5Gq7wnFIsCrDNMffKBBhqFbTHD0nkngjpPM+KvbOux9Vt0Vd chctmtUav6NMBHxkB/tn7d2YwNaDKYbOac0AflM46eQhaxXeB9EtvaY88/6FFx1wRQH2 S0y53OGTs3dsI4H+ZOSoB6AGJnK4HXJgZyBxOaaH2IsFRcMTlRPiaKUgyZL68Pibb6G2 EMKdlz11i1n0jp0vIUaCBSpr6lTkipDjPkHb3oZN19FBVRB9ikvHPJ9WUP0+KU8ugVtl roUGteyr3r2tJkYYtUHihzVbr28TuUawKCnqIE9xmyNGZB/KowtWwucd9Bu4T5wG2qzO vq6g== 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=O9N8xG/f1B8MUgTe0pkCwXyF7I7fCofINDcpI+47q40=; b=0NcI3dcO6+HmXhGWTguqd8ebEKo/oy8DUczTV+ewBGgnPuoE/Dr0DeF4/EXHLlUujp DoqguUVlJtDyCxmRe9sYdSvncMjdBJ+m5kL4WC30U1xUvP1YL3F7krcmWsayKZOEQlD5 KTyPgS8LgA1OOsxPkTuuUx4869v+Z9QVAQJL8iGJFurMSKnIop9icG8/XU06mlUN9p+i 1WZq0Gwalh5O19IMTSMQk4VhknznHb35wYtkA3oO4VeP1Jz9c0kIlau50eOAYGcvQ5qm Anmzr8ytAto0HYvzQB9fWZ8mE7J7Qhc1H5CJQnMM4dwI+qV2Qzrs1UmT51BW7mZwfoSz rctw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=AY+2fTtp; spf=pass (google.com: domain of gcc-patches-return-490270-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-490270-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 131-v6si33388995pfx.213.2018.11.16.07.51.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 07:51:11 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-490270-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=AY+2fTtp; spf=pass (google.com: domain of gcc-patches-return-490270-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-490270-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=u6XwWMsGVGIhJwPPX0LRsXY20rk+1wCs7tEBNxXLNo/TL1CY8m5C2 YPengSWcXpKJb/g61wpF3G4PxoDgqbH8qp4aP5mZMcoUNDfDhrPiWIqdF6kS5L6+ 6iZJtockvxU42uVd5DDiFSs9ddU3anD2brKW5OOBUMuKxPZ3YZhVnM= 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=zVCPwOcTSDdCGVF9BrpduJYNB0g=; b=AY+2fTtph5csym088/Ul7Cy2QRLe b4PSdPg9jz6ucRlTeaEM/S3nZ+R/+H8mtSK4vWlVyo2TUHgXXKJ72LPppAAWdRbL +yLO9APhkivOqy0YuwM7Y57u/kzxF1PELI9I1BowPvfkc1q8fdhWv1yhADrNsXS0 YWGmaFMKE+qMq0c= Received: (qmail 127360 invoked by alias); 16 Nov 2018 15:50:59 -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 126363 invoked by uid 89); 16 Nov 2018 15:50:59 -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; Fri, 16 Nov 2018 15:50:57 +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 wAGFilWu002140; Fri, 16 Nov 2018 16:50:55 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2nsx068w7u-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 16 Nov 2018 16:50:55 +0100 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 1B85634; Fri, 16 Nov 2018 15:50:55 +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 095295015; Fri, 16 Nov 2018 15:50:55 +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; Fri, 16 Nov 2018 16:50:54 +0100 From: Christophe Lyon To: CC: Subject: [ARM/FDPIC v4 08/20] [ARM] FDPIC: Enforce local/global binding for function descriptors Date: Fri, 16 Nov 2018 16:47:36 +0100 Message-ID: <20181116154808.25154-9-christophe.lyon@st.com> In-Reply-To: <20181116154808.25154-1-christophe.lyon@st.com> References: <20181116154808.25154-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): Enforce 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 7e7f747..ca53eae 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3777,6 +3777,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_fdpic_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 uniqueness 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) { @@ -7494,7 +7530,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_fdpic_local_funcdesc_p (orig)))) && NEED_GOT_RELOC && arm_pic_data_is_text_relative) insn = arm_pic_static_addr (orig, reg); @@ -23060,7 +23098,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_fdpic_local_funcdesc_p (x))))) { if (TARGET_FDPIC && SYMBOL_REF_FUNCTION_P (x)) fputs ("(GOTFUNCDESC)", asm_out_file);