From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63500 invoked by alias); 12 Oct 2018 11:54:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 63486 invoked by uid 89); 12 Oct 2018 11:54:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_STOCKGEN,SPF_PASS autolearn=ham version=3.3.2 spammy=gonna X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Oct 2018 11:54:07 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 85E1AED1; Fri, 12 Oct 2018 04:54:05 -0700 (PDT) Received: from e120077-lin.cambridge.arm.com (e120077-lin.cambridge.arm.com [10.2.206.194]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BAB8E3F5D3; Fri, 12 Oct 2018 04:54:04 -0700 (PDT) Subject: Re: [ARM/FDPIC v3 08/21] [ARM] FDPIC: Ensure local/global binding for function descriptors To: Christophe Lyon , gcc-patches@gcc.gnu.org Cc: christophe.lyon@linaro.org References: <20181011133518.17258-1-christophe.lyon@st.com> <20181011133518.17258-9-christophe.lyon@st.com> From: "Richard Earnshaw (lists)" Openpgp: preference=signencrypt Message-ID: <059caf38-df6a-a4af-7bd5-30a26a934546@arm.com> Date: Fri, 12 Oct 2018 12:39:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181011133518.17258-9-christophe.lyon@st.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8bit X-SW-Source: 2018-10/txt/msg00749.txt.bz2 On 11/10/18 14:34, Christophe Lyon wrote: > 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 Enforce? > pointers in FDPIC mode. > (arm_assemble_integer): Likewise. > > Change-Id: I3fa0b63bc0f672903f405aa72cc46052de1c0feb > > 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) Given that this function doesn't return what it's name implies when not FDPIC, I think the name should reflect that. Please rename to arm_fdpic_local... > +{ > + 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. */ s/unicity/uniqueness/ > + 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) space before parenthesis > + || 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); > OK with those changes. R. [gonna have to stop now and I'm OoO next week]