From patchwork Fri Jul 13 16:11:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 141923 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp989941ljj; Fri, 13 Jul 2018 09:15:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfkmmEHse8ZF3ochcC1k+ZaqDRZSCXdQ/4rVM+jmdTF9kAabwPmwVyKm1a4YXOy2oOjInOS X-Received: by 2002:a17:902:4603:: with SMTP id o3-v6mr6820201pld.49.1531498503499; Fri, 13 Jul 2018 09:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531498503; cv=none; d=google.com; s=arc-20160816; b=SpxMgi7Z7WR2/LZcHWWV4Sw3DwM0UwLSOdYF9QYchIDckhzzSWMRRW9rNMp+xwMvc9 VxaYjUpeHHvckbH5QG0/0FHw0wWk4Zj5vZ0trJGOvISh3dgAjOu1MoDcN+OZeReHpZhc RZlqY3F5brcQQyav+44T8Jm9JSaBvDw4Gc7vspyjHNdXKghQXcqTTwE/ve7Z4biyP64M MpHYedUKZT1kgpeED9u05qE6wvIrxGYFOpCml2x3pSrzuyxptcUDquKyNBM2FjmAvV0u PSSK8QMyG77dI7D+AoOn03tWm6iV3/rPtqRbqOdL9+LGqlEZ82i1dfwkezw6f3YqAI4g zP6g== 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 :arc-authentication-results; bh=lC5q2Vl6DArJ2pOcCu6NzoHk5o4vX2edXUjTC7u97sQ=; b=YNHWAdat7Q02lVu5gTw56AFrZ08AfSnaVd/7RFnGscDixnZCrpemx01jxT+0ajJdJy UJH+2DzmBd1cEyykNh+0ClRsDp4+y3bVxSSIrqhuBkpJS60WxpzcbI4Hn7TC4zKkFP3x JNo+I9Qm5IxELcOVfjIs4hfWXDsIDbKhhjEJJwRZFyqobencDTE2ptCalWiOMmvME2hT 4F37acbdihgKXRuFtYQy9Ne9Rh2XwZTVIGjBbNKBuUDGV07nnR2VzHBMxLrSpSMpo/P/ cA7bKSgfTI0L4okBLWKh57YZeZsGEem0CJf1iXxxL7aMNo/zUQti80vl/47Lfd0QdBTK 1sIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Dy1WYbZK; spf=pass (google.com: domain of gcc-patches-return-481518-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-481518-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 d20-v6si22376275pgb.682.2018.07.13.09.15.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 09:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-481518-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=Dy1WYbZK; spf=pass (google.com: domain of gcc-patches-return-481518-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-481518-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=ANKKJbxlzy3s1FvOMmZj4/Zu4seolj6cqDMsTIWv0pA4BCEV4cfJs KJ6udMpUDUhVaxZ5lNrSoBzuQQvYEGARxMSBhyc6HDDYhVLdii9sxHjuuHMXviJU A21ABYqtCZd6rE2odqVCqm/OF5Yn+HAsqdZwAGoG0xpCFHoatbhO70= 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=nmUY91z8gBlMi2NB6GTc7RjsQ5k=; b=Dy1WYbZKMMTUnw2A5RyNPF//VVIM HXePmBZOdrhw1XSzyKwWpkSPWDvdLcdpQ/cg8qlA2ktYZVV90379WtHqtrTtfKEy WGM0MqBWyJNo4YXwHFtH5GJ5mL/ZB1Uwlb9POev43r1NAhJMLW8nmpVhUwoAhAfl UevE3lCeJHHATpg= Received: (qmail 25682 invoked by alias); 13 Jul 2018 16:14:47 -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 25618 invoked by uid 89); 13 Jul 2018 16:14:46 -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, 13 Jul 2018 16:14:44 +0000 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w6DGEEEf008283; Fri, 13 Jul 2018 18:14:41 +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 2k6y3vr2gb-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 13 Jul 2018 18:14:41 +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 6EECB31; Fri, 13 Jul 2018 16:14:41 +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 58802A6B1; Fri, 13 Jul 2018 16:14:41 +0000 (GMT) Received: from gnb.st.com (10.75.127.48) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 13 Jul 2018 18:14:40 +0200 From: To: CC: Subject: [ARM/FDPIC v2 08/21] [ARM] FDPIC: Ensure local/global binding for function descriptors Date: Fri, 13 Jul 2018 18:11:03 +0200 Message-ID: <20180713161136.29104-9-christophe.lyon@st.com> In-Reply-To: <20180713161136.29104-1-christophe.lyon@st.com> References: <20180713161136.29104-1-christophe.lyon@st.com> MIME-Version: 1.0 X-IsSubscribed: yes From: Christophe Lyon 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 c9f391b..51da2bc 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3764,6 +3764,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) { @@ -7481,7 +7517,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); @@ -23069,7 +23107,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);