From patchwork Wed May 15 12:39:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 164283 Delivered-To: patch@linaro.org Received: by 2002:ac9:2a84:0:0:0:0:0 with SMTP id p4csp604341oca; Wed, 15 May 2019 05:43:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgj3TOswrl+b6ZT9DhVNt5awZpAljDdLriR0IK4ywoa9BCMbO5Ap750ogZKPZ7J7ghNel1 X-Received: by 2002:a63:2d87:: with SMTP id t129mr44002605pgt.451.1557924192439; Wed, 15 May 2019 05:43:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557924192; cv=none; d=google.com; s=arc-20160816; b=yQ2YoUiW9kWBHaILBrg7RG6ZjDRIpsYgEZ06IzD6e/8cPWZk/PRpitoLxAHMXJPNF7 lzCVI5BXSdJabuf3eu127o4W1nQeGSuL4UDbGC46Y5Zcy0O77nlBU71pLO3JMEXdrsLp xRAUgbP6AooIysek4MLohDgLpVYWfwnO2Kj7SWti8+wqqPIICfBv/6xlV30BX5BPC9fS 2tRnKa6v05ZpNXUUBZZ4CXvQylQwb6JT2Q2S1Apz6iGNhTaxBAoLGV9Pq2BfArVWLncB JPd8iM1k6iGTt3a51Lgtxr61vZBl/YEsY1MY9efHbHfBC8NM/Zkg6oANrR9qzDDWtExi FixA== 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=BMTckNDoV46DueOljhQlv5aHn9JSttvpvrHmHcbQBPQ=; b=yMh2OQ09TLQ0NXvpJVwBIgX0vpQJy3stxUPwnNEiGTQOkLyffj0204M8w0QdDcrjzt fdCDTbgL/GXChoFmM6Yd4xYYxThS9HSTbSq/kEr23NDuchoMppiDIwbvKI9v1nbVsvA+ bmZGgyYIm6T7kvC0GAzE9DCEkR3xPCU9VRbxRxzLYiygcDru7c0xsHMVDFcckUQN2myJ Ej/4EdGk2GuAGw1ZnCTNYoZRv2PQC0gDK/icp2tMDDkQ7Ld6oHWRh6ign+n6+arbwPR+ pUWCaqJiVV2qZ3ZOYuQ1LG+N2lT5dFCj91NFyFzhIg+hw8Q8AVqF0Z/oOstzoqjThsC3 ui0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=oupLSSgv; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b="Dm/xdNSo"; spf=pass (google.com: domain of gcc-patches-return-500772-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-500772-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 c6si2058982pfc.235.2019.05.15.05.43.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 May 2019 05:43:12 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-500772-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=oupLSSgv; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b="Dm/xdNSo"; spf=pass (google.com: domain of gcc-patches-return-500772-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="gcc-patches-return-500772-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=n7S /NLCtjfmz9vcB3NoK2P/q2XWcu6AMW331BdeGxOEubZa/K4NFAPZEskv9trzyxHx GuPstmCyn5hSyEcnPyYFn798hOPugvzOAhxYVny/ccdvR0d+TODkPVanxNE6LimK w8mfvyyhAlKQkB4PvwqGKR5npkrB25iryLrHsGpA= 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=BFSOT2KSj 673nflUDqP8x/ZB1XY=; b=oupLSSgvxerq1oy5M6L43zmLydoXrKW/qLQEzYU3k oEUD6Tv5ERM3Ag49m1S4+KdeoUdKHUcDLCcz+61aaAW94ZM86y2E4iP7PHvBvDyw E6rnciC94FoNRglhghAMHrdkyThs4WL1wGmYaODw9aTZ7EkvQeTqwgk53A21o9rB H0= Received: (qmail 106340 invoked by alias); 15 May 2019 12:43:00 -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 106002 invoked by uid 89); 15 May 2019 12:43:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-14.8 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=uniqueness, Private 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; Wed, 15 May 2019 12:42:59 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4FCgG4k014526 for ; Wed, 15 May 2019 14:42:57 +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=BMTckNDoV46DueOljhQlv5aHn9JSttvpvrHmHcbQBPQ=; b=Dm/xdNSoLS6xXKpm4+dxIn/0S6LeIt6zuHA4eAtzpBw6IAAnVyAS+xAK/hwsy1WT8vW2 M8snCC6+L8d7jddY7Zg0flsPOl/zmzEkwncLHewDN7tCSGj3h1JH2eLOGsOrVJd38yVz 6QVN7c+sj9AuzZ5Zh1ukLoR0k+R4GgqvSMzNjOYk4q5Rw2J4eVgf259D0KAViuPEm5FD irCaGrPxnqWk9STxX2uSCzqZSFscME8lI0T9wSYYLUj9ToyPb7ckxWcKlKMRNdklqyci kbpZhALv3v4lpja6HK0IceNq6VzsIceJ8VGTIYn7L/E3tlsvsRxVDdps5ESHvyiQGlJH 2Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2sdn9g0sy6-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 15 May 2019 14:42:57 +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 61B2738 for ; Wed, 15 May 2019 12:42:56 +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 5131F2757 for ; Wed, 15 May 2019 12:42:56 +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; Wed, 15 May 2019 14:42:55 +0200 From: Christophe Lyon To: Subject: [ARM/FDPIC v5 08/21] [ARM] FDPIC: Enforce local/global binding for function descriptors Date: Wed, 15 May 2019 14:39:33 +0200 Message-ID: <20190515124006.25840-9-christophe.lyon@st.com> In-Reply-To: <20190515124006.25840-1-christophe.lyon@st.com> References: <20190515124006.25840-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. 2019-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 dbd1671..40e3f3b 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3790,6 +3790,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) { @@ -7563,7 +7599,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); @@ -23231,7 +23269,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);