From patchwork Fri May 25 08:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 136806 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3287474lji; Fri, 25 May 2018 01:29:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqHZ7Hm7URxKl0XBEhZPt5NCJqTd8IkfwP1iXTu8U711nZ1jBKukoLDU2BZJtr09OC5f2kD X-Received: by 2002:a17:902:5327:: with SMTP id b36-v6mr1649636pli.316.1527236980714; Fri, 25 May 2018 01:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527236980; cv=none; d=google.com; s=arc-20160816; b=GqIK3WEHzLWyo7W1hbKwv+hXZ1vtDJT+KCijtkTmuppDOeIYEUJA6bNCKh0MriivDu qnKxB1Lnur23JEEpbBCOWkArGt+UbI7z8oqkkaY71uCyIYZH7HnChE5ZPGkmp8CB+Zxy 0WV6mvc/8hnyszHFMTimQt77TIQn6dK0yYsktjQr5mXHdNMGEPgWEqX+N7mzOcU2xIp8 XkxFzSYYyNc8qBIQEszLLC/NuIX5KQn4TCr9RbHUif07GCOQ08zZXfGLHXmGqf4E1vm0 CFV1A3c9m/AO2MHkZiTOOYD32SVbIT+YWmhBgBH3we5UTYuXcaSwkRDjzZ9L4aSJhybx C81g== 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:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=ZfO32jWbgoUV0Pr2sWC+tCW58DIr3RjlYY72QNPYq0U=; b=Nglx1COKnUTP4lfCIqTSQD4nfW8quvABkjbvzD9QzeCAZrBRjLFEyvmvr+OWhPLV2o 3sX1Pl9IZ32716+I+xFppf+dFoPWo5fnhfyfVvF+igAFLEsC9SRuCVgEICf1KvjFRSi0 cu6wTXJnUcCQ0uW2AFEaiD3pJpZPa+ZxuJAa1nue/oFr0OsAy/Ci+RbydOR6hw+2Mm/d 0RcL/j9r/fIL2VLXrbFqqYRPOgIhzGhDOvUbdhLZWfPZfEOoKvu9kgHNjQwERbGYivP0 1Fg4wqoS2F0Z0uQPRALUNyCquNHE13rxb+SNCL32skO1CX3ZqXhW9Fb3/fKYeOYVc4FZ D1yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=I1lDoviu; spf=pass (google.com: domain of gcc-patches-return-478471-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478471-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 f7-v6si18749566pgq.393.2018.05.25.01.29.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 01:29:40 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-478471-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=I1lDoviu; spf=pass (google.com: domain of gcc-patches-return-478471-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478471-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=MBM G2z5gPs/3kQp+r/pl13vZIBoGSqDxOcaRInFJokH25FRTmWACcbNGPJ3w/xJV7ws UjqCtq/CPqMO/5yB5p7FLL4yRoLYUucMCF+8UKxduYs3GCbUyWaxYgr1pUOte+KG 6Vxln9go9Ilu9ikPnMwWIXMiiKqRlpkx/sXDmzrk= 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=PbC5DylWd t2XYrD0XDmdg+cDsbY=; b=I1lDoviuvUYIRoeQe6NYs2EKDGXYO9gLtXdGPhrar CrAveHc4KQZPOivr7S9iGyTvBh0+ZUepXEAvx8vN67usHvW2BDUjqapXal8hv1E0 L1AJCNtHyKhQF+hJrJIC9a4mFB8A+uBO1oUKkRjiPRx1TxlMv72myH8EdnNZxhcC qc= Received: (qmail 45908 invoked by alias); 25 May 2018 08:08:35 -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 43857 invoked by uid 89); 25 May 2018 08:07:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=Hx-languages-length:4698, start_sequence X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 May 2018 08:07:38 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fM7l8-0003Si-8d for gcc-patches@gcc.gnu.org; Fri, 25 May 2018 04:07:37 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:38714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fM7l7-0003SR-Uj for gcc-patches@gcc.gnu.org; Fri, 25 May 2018 04:07:34 -0400 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 w4P7xBxD003910; Fri, 25 May 2018 10:07:32 +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 2j59prjw2a-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 25 May 2018 10:07:32 +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 6093F31; Fri, 25 May 2018 08:07:32 +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 40559241C; Fri, 25 May 2018 08:07:32 +0000 (GMT) Received: from gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 25 May 2018 10:07:31 +0200 From: Christophe Lyon To: , Subject: [ARM/FDPIC 10/21] [ARM] FDPIC: Implement legitimize_tls_address_fdpic Date: Fri, 25 May 2018 10:03:23 +0200 Message-ID: <20180525080354.13295-11-christophe.lyon@st.com> In-Reply-To: <20180525080354.13295-1-christophe.lyon@st.com> References: <20180525080354.13295-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-25_03:, , signatures=0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 62.209.51.94 X-IsSubscribed: yes Support additional relocations: TLS_GD32_FDPIC, TLS_LDM32_FDPIC, and TLS_IE32_FDPIC. We do not support the GNU2 TLS dialect. 2018-XX-XX Christophe Lyon Mickaël Guêné gcc/ * config/arm/arm.c (tls_reloc): Add TLS_GD32_FDPIC, TLS_LDM32_FDPIC and TLS_IE32_FDPIC. (arm_call_tls_get_addr_fdpic): New. (legitimize_tls_address_fdpic): New. (legitimize_tls_address_not_fdpic): New. (legitimize_tls_address): Add FDPIC support. (arm_emit_tls_decoration): Likewise. Change-Id: I4ea5034ff654540c4658d0a79fb92f70550cdf4a -- 2.6.3 diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 2434602..20b8f66 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -2373,9 +2373,12 @@ char arm_arch_name[] = "__ARM_ARCH_PROFILE__"; enum tls_reloc { TLS_GD32, + TLS_GD32_FDPIC, TLS_LDM32, + TLS_LDM32_FDPIC, TLS_LDO32, TLS_IE32, + TLS_IE32_FDPIC, TLS_LE32, TLS_DESCSEQ /* GNU scheme */ }; @@ -8681,6 +8684,30 @@ load_tls_operand (rtx x, rtx reg) } static rtx_insn * +arm_call_tls_get_addr_fdpic (rtx x, rtx reg, rtx *valuep, int reloc) +{ + rtx sum; + + gcc_assert (reloc != TLS_DESCSEQ); + start_sequence (); + + sum = gen_rtx_UNSPEC (Pmode, + gen_rtvec (2, x, GEN_INT (reloc)), + UNSPEC_TLS); + reg = load_tls_operand (sum, reg); + emit_insn (gen_addsi3 (reg, reg, gen_rtx_REG (Pmode, 9))); + + *valuep = emit_library_call_value (get_tls_get_addr (), NULL_RTX, + LCT_PURE, /* LCT_CONST? */ + Pmode, reg, Pmode); + + rtx_insn *insns = get_insns (); + end_sequence (); + + return insns; +} + +static rtx_insn * arm_call_tls_get_addr (rtx x, rtx reg, rtx *valuep, int reloc) { rtx label, labelno, sum; @@ -8736,8 +8763,84 @@ arm_tls_descseq_addr (rtx x, rtx reg) return reg; } -rtx -legitimize_tls_address (rtx x, rtx reg) +static rtx +legitimize_tls_address_fdpic (rtx x, rtx reg) +{ + rtx dest, ret, eqv, addend, sum, tp; + rtx_insn *insns; + unsigned int model = SYMBOL_REF_TLS_MODEL (x); + + switch (model) + { + case TLS_MODEL_GLOBAL_DYNAMIC: + if (TARGET_GNU2_TLS) + { + abort (); + } + else + { + /* Original scheme. */ + insns = arm_call_tls_get_addr_fdpic (x, reg, &ret, TLS_GD32_FDPIC); + dest = gen_reg_rtx (Pmode); + emit_libcall_block (insns, dest, ret, x); + } + return dest; + break; + + case TLS_MODEL_LOCAL_DYNAMIC: + if (TARGET_GNU2_TLS) + { + abort (); + } + else + { + insns = arm_call_tls_get_addr_fdpic (x, reg, &ret, TLS_LDM32_FDPIC); + /* Attach a unique REG_EQUIV, to allow the RTL optimizers to + share the LDM result with other LD model accesses. */ + eqv = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, const1_rtx), + UNSPEC_TLS); + dest = gen_reg_rtx (Pmode); + emit_libcall_block (insns, dest, ret, eqv); + + /* Load the addend. */ + addend = gen_rtx_UNSPEC (Pmode, + gen_rtvec (2, x, GEN_INT (TLS_LDO32)), + UNSPEC_TLS); + addend = force_reg (SImode, gen_rtx_CONST (SImode, addend)); + dest = gen_rtx_PLUS (Pmode, dest, addend); + } + return dest; + break; + + case TLS_MODEL_INITIAL_EXEC: + sum = gen_rtx_UNSPEC (Pmode, + gen_rtvec (2, x, GEN_INT (TLS_IE32_FDPIC)), + UNSPEC_TLS); + reg = load_tls_operand (sum, reg); + /* FIXME: optimize below? */ + emit_insn (gen_addsi3 (reg, reg, gen_rtx_REG (Pmode, 9))); + emit_insn (gen_movsi (reg, gen_rtx_MEM (Pmode, reg))); + tp = arm_load_tp (NULL_RTX); + + return gen_rtx_PLUS (Pmode, tp, reg); + break; + + case TLS_MODEL_LOCAL_EXEC: + tp = arm_load_tp (NULL_RTX); + reg = gen_rtx_UNSPEC (Pmode, + gen_rtvec (2, x, GEN_INT (TLS_LE32)), + UNSPEC_TLS); + reg = force_reg (SImode, gen_rtx_CONST (SImode, reg)); + + return gen_rtx_PLUS (Pmode, tp, reg); + + default: + abort (); + } +} + +static rtx +legitimize_tls_address_not_fdpic (rtx x, rtx reg) { rtx dest, tp, label, labelno, sum, ret, eqv, addend; rtx_insn *insns; @@ -8831,6 +8934,15 @@ legitimize_tls_address (rtx x, rtx reg) } } +rtx +legitimize_tls_address (rtx x, rtx reg) +{ + if (TARGET_FDPIC) + return legitimize_tls_address_fdpic (x, reg); + else + return legitimize_tls_address_not_fdpic (x, reg); +} + /* Try machine-dependent ways of modifying an illegitimate address to be legitimate. If we find one, return the new, valid address. */ rtx @@ -28022,15 +28134,24 @@ arm_emit_tls_decoration (FILE *fp, rtx x) case TLS_GD32: fputs ("(tlsgd)", fp); break; + case TLS_GD32_FDPIC: + fputs ("(tlsgd_fdpic)", fp); + break; case TLS_LDM32: fputs ("(tlsldm)", fp); break; + case TLS_LDM32_FDPIC: + fputs ("(tlsldm_fdpic)", fp); + break; case TLS_LDO32: fputs ("(tlsldo)", fp); break; case TLS_IE32: fputs ("(gottpoff)", fp); break; + case TLS_IE32_FDPIC: + fputs ("(gottpoff_fdpic)", fp); + break; case TLS_LE32: fputs ("(tpoff)", fp); break;