From patchwork Mon Sep 9 15:44:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 173397 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp4536851ilq; Mon, 9 Sep 2019 08:48:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOIp7huV9IGPUeZmGD0fdrStTtECQ3KXMEfzLtjyqyxta8YsqcSmV6/nAJc7ZLmYEJ8Idy X-Received: by 2002:aa7:d8cf:: with SMTP id k15mr25498943eds.195.1568044126497; Mon, 09 Sep 2019 08:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568044126; cv=none; d=google.com; s=arc-20160816; b=urSMUPPnV+OljggoYTgqlkaMmOLiBuSRK5qcVDAefevyiRsjr9dBLTDtCIeiOucHQ8 Eer3Ykv9JChkNO5lRv4RKmJBeg9k/Srw7q1e+9UVBxEMMYnP4tWd9mUtCmOFRoZ9TZgZ Tgpfj6rn4BM82E/T8ybc+Qr+iBtdT/Xgq7jAYdSNugbZkJqvyni2UjZeTS4ZCxxfRfnp yxgFryuiQ7e0ninEGoYAXy1NGjLVmoZTG1KJTROBPNWLp5EvrSLtbpdwFAVsLfBZ8IuH lfNSejmzYbZwEItOeRjlZvuN5NZ45BuhtxRt5MtnLhRezHIl9wKNqk4CetsUGJHemoyl +wiQ== 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:to:from:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature; bh=CBXsndEM3gHUvnQ3DAtdTvD0g56U0EIb/mapmsA6e4M=; b=mqavzo9hSAwYOXZnv3IgUytqZysGuCYyjUyoE4/PAfCvaoqnE6O70iHsH/fa1csoYf 0pCM7yAzhLjBJzNta3rI9wQHZP9o8hKSLBnNTVZPGRKQCg+qEKK4Xnf4mfP+d8jjJ4Ak 66eOyI1wDmFLnP+3wuP7ZQ3ZREWRYg+SC5v6RwiCLnVFUWAdrb8Y1AOTMQQ+kppYLrf/ HnKeAiYcA9fVBO7Jg37FwS3dEfzHxd2lfLxH+a5rxhLoT2tJIoOnuqVfZ9tVDubhDCFD /ymaLIqm0jij4l1zecRpzCO2d7i++3tJ5BaPedJMtC6vAPViuIJFxolakFE75Bzl/pCu uROg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GL24NDKz; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=T7jTqlMv; spf=pass (google.com: domain of gcc-patches-return-508650-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-508650-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 y5si7740713ejq.201.2019.09.09.08.48.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Sep 2019 08:48:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-508650-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=GL24NDKz; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=T7jTqlMv; spf=pass (google.com: domain of gcc-patches-return-508650-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-508650-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:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=WJ+ VqWRWZuWOOyWljOsff2RoAKdmDni8urPQaJ4GvUjHPnaO+zuz+I9B7i91ybKIXsS l+xyZfm1g/8/lRf8KPZ2SM7IiWYki6/6b2rZ7M6XhyiPYHe2GQA7RWwK5bOt9y5/ ANiM8j92udMfXMKaw7+BoHBFaLg1PzReF1s4e4RI= 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:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=default; bh=CDsp7RsbC JhWTDXLCheX7UZz+P0=; b=GL24NDKzOwJN12c4tDh7yZkOi/kTKXbsKEMxK+ct/ eLRW2yBAPJmS2LN5vdehllZz0LCWz2tgk54SqD8JWdjQhkDS9GCiajpYAh8wtTcF Z5fKgWmwqI9MKsi45WuEfG5NLLxYVoIMeGt30ObaU0868qk8zW9/FSQL4bIgI2IV aU= Received: (qmail 120060 invoked by alias); 9 Sep 2019 15:48:22 -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 119926 invoked by uid 89); 9 Sep 2019 15:48:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, 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.1 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Sep 2019 15:48:20 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x89FkgaZ027615 for ; Mon, 9 Sep 2019 17:48:18 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=STMicroelectronics; bh=CBXsndEM3gHUvnQ3DAtdTvD0g56U0EIb/mapmsA6e4M=; b=T7jTqlMvpmGbdHG2Y1TUQcHJqgun5bXd89u5eDPMgPZtZS/mNk3EhMis5n33vAbMput2 k5Zwdx/cXvQUCLliY0FY4lRo3hmROsHJ1VT8LEpyl3+Qt93mrNt3sAJvLap+CU1FfjQ4 OgnE35afOhdBgNxbvCzn+0PhoNGgxJlQeea+kDQKxJWStn31RU0qxRd4xsYxrYqLkNVP k4Kf1YE+78HJ7jSy9hHdbl4d8WcLL+xomE1gkH1SULJwVuCZd8r/TOaW2k982QHtBsIv l/28unVhSaOsvnEvgvTqQRRAE5sfhE2KN0EZCsNt2Thh/de8NIrXHIN4+ki2SNWMOC9K gA== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx08-00178001.pphosted.com with ESMTP id 2uv3ehpjqb-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 09 Sep 2019 17:48:18 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 3F6A123 for ; Mon, 9 Sep 2019 15:48:15 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id A576C2B9BEE for ; Mon, 9 Sep 2019 17:48:14 +0200 (CEST) Received: from gnb.st.com (10.75.127.46) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 9 Sep 2019 17:48:14 +0200 From: Christophe Lyon To: Subject: [ARM/FDPIC v6 08/24] [ARM] FDPIC: Enforce local/global binding for function descriptors Date: Mon, 9 Sep 2019 17:44:50 +0200 Message-ID: <20190909154526.11630-9-christophe.lyon@st.com> In-Reply-To: <20190909154526.11630-1-christophe.lyon@st.com> References: <20190909154526.11630-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. 2019-XX-XX Christophe Lyon Mickaël Guêné gcc/ * config/arm/arm.c (arm_fdpic_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 6ff3001..6b0c95f 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3754,6 +3754,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) { @@ -7534,7 +7570,9 @@ legitimize_pic_address (rtx orig, machine_mode mode, rtx reg, rtx pic_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); @@ -23160,7 +23198,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);