From patchwork Thu Dec 14 02:29:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 18026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8277346dys; Wed, 13 Dec 2023 18:30:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2T6nrFokRVPIsh+hNnLw0iUAO2pkbIXiXKzD8rdyIM9e49Y/BiZFKvOZkbSR1yY/1u19O X-Received: by 2002:a05:622a:181:b0:41e:1cc8:f280 with SMTP id s1-20020a05622a018100b0041e1cc8f280mr12724872qtw.59.1702521059143; Wed, 13 Dec 2023 18:30:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702521059; cv=pass; d=google.com; s=arc-20160816; b=wmtvXQQROQCASJ8xgqyQzoznaTqBn0Gs9Rsd2760RDGnL97KSnoaQ0YugJpchYVK7t UxB1ftGHc/czN85LLng2MNsIDjEcRVEB62GmYhk7BM4eFnFCE/atKX5ntSVolbsTQ5oI Bx3aFhKOt4bTnEbfyKn3k/Q+vZo2W3c/gGbeKW2bo2CYk3iZ24XcO99XgvhWudHHx7h1 FgHtKzpvCxZd7WKMDb9zdx3uO5L6oPr+UFkpJl1p6MjDrciu+abRWtj/LoNIv8kq0N3x hP+hI0+tZmBid2ARzw6DiHPoMD0CfzcqsZ5FTYN0mdTfz6gbJsiVXwI9NHaltBtth2rI DU2w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=t+PTao7rzi605mbKse0GtNfKra/dUSE5dO65QoPhomc=; fh=FvlVQEmCpm5H8oBXQswexzCupeeQXnbssobXN+3R2Wg=; b=LeIC1m/Qu0sXusq21MV4c/qcsX9zCaJa3p+9dpePxB0TnwIvwFNluJR/7cB6HzA6iE qm6MXlkJlP1Zs08GfVLV+dKaj8pR9sxPImzfi+jZcTiKpJos2vbhshlO7Dk8Lk6fIxCT 96ZATIa4V0RBPQaYrIm9aHlExdWxpPWEk0fjBkMeFQPY7OI3ZGYAFNqV8czQP7N2ry2v snb/XwfidbQSpbiH+x03FBLgGLRAhMsjSuFoVpkBBAEVPs9kzy/hNO93HLEgBayg7NSV VQ8VUkTaIce+rDhUVBeiP6ImZc0KrkWn8enxQXT6U7CdjTJZpZzIrfVc2BKLYr5WNYC9 Ctbg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id eq20-20020a05622a5e1400b0042586ba8fdbsi15559533qtb.257.2023.12.13.18.30.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 18:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0302F386189D for ; Thu, 14 Dec 2023 02:30:46 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id E0B63385E005 for ; Thu, 14 Dec 2023 02:29:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E0B63385E005 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E0B63385E005 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702520989; cv=none; b=tVS4zku1LEHr0slExzHvoARuKibELKb62rhD5msOiJkp79oq8odaqDH2GOa0BCFfwGLnnHZJyybeOvcSvvYSa299091Y9y3B9/BBK/Nu/g8MZOTcJspOtQUu60Uqk2MT3hFO6wT/Fx2NML3cTGEsKqllKaea/QO+5CGQLGBljuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702520989; c=relaxed/simple; bh=uCurJlQSJ4yHZIfvZytCeaieCM00bqxViMl6xclVsjc=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=bQ33P5ZEiIRlL+USKPTxyQDUWogdQzEK0aRAV3uRBlyid5X3laO6FvAWTLrx9huY7BPQgZxYziY487GKYNRnU2+yza4KJBOPiVjTp+Jhv71JrPyaDADXX5KMmevcD2HqjRZ8kYd1N7XFDxmd50NOMM00LdidS0i2G2BtPdRGwHU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8DxBOuVaHplFeUAAA--.1175S3; Thu, 14 Dec 2023 10:29:41 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Ax_OCUaHpllHwDAA--.20150S4; Thu, 14 Dec 2023 10:29:41 +0800 (CST) From: Lulu Cai To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, mengqinggang@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lulu Cai Subject: [PATCH v2 0/5] LoongArch: Add support for TLS Descriptors (TLSDESC) Date: Thu, 14 Dec 2023 10:29:34 +0800 Message-Id: <20231214022939.1232314-1-cailulu@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Ax_OCUaHpllHwDAA--.20150S4 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAFB2V6Zi0AIgABs0 X-Coremail-Antispam: 1Uk129KBj93XoWxAr1fuw1rtFWrAF4kWw1UXFc_yoWrtw17pa y5ZFnYkF18CFsrXFyDW3y5Z3Z5Xa1xGrW2ga4ftr1akwsaqry0vwn2yrZxXay5Jw4qy34f Zw10vw13WF1UtrbCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9jb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAaw2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0c Ia020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_ Jw1lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwI xGrwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWU XVWUAwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67 kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY 6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0x vEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2Kfnx nUUI43ZEXa7IU8CzuJUUUUU== X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785222722031776227 X-GMAIL-MSGID: 1785222722031776227 In v2, the following changes have been made: 1. The instruction sequences of DESC is modified. 2. Add new tls transition, DESC->IE and IE->LE are supported. 3. Add relaxation for DESC/GD/LD. The detailed description is as follows: 1. The new instruction sequences is: pcalau12i $a0,%desc_pc_hi20(var) #R_LARCH_TLS_DESC_PC_HI20 addi.d $a0,$a0,%desc_add_pc_lo12(var) #R_LARCH_TLS_DESC_ADD_PC_LO12 ld.d $ra,$a0,%desc_ld(var) #R_LARCH_TLS_DESC_LD jirl $ra,$ra,%desc_call(var) #R_LARCH_TLS_DESC_CALL add.d $t0,$a0,$tp 2. For DESC->IE: pcalau12i $a0,%desc_pc_hi20(var) => pcalau12i $a0,%ie_pc_hi20(var) addi.d $a0,$a0,%desc_add_pc_lo12(var) => ld.d $a0,%ie_pc_lo12(var) ld.d $ra,$a0,%desc_ld(var) => NOP jirl $ra,$ra,%desc_call(var) => NOP add.d $t0,$a0,$tp add.d $t0,$a0,$tp For IE->LE: pcalau12i $a0,%ie_pc_hi20(var) => lu12i.w $a0,%le_hi20(var) ld.d $a0,%ie_pc_lo12(var) => ori $a0,$a0,%le_lo12(var) add.d $t0,$a0,$tp add.d $t0,$a0,$tp 3. The instruction sequence of DESC/GD/LD is relaxed when type transition cannot be performed. For DESC: pcalau12i $a0,%desc_pc_hi20(var) addi.d $a0,$a0,%desc_add_pc_lo12(var) after relaxation is: pcaddi $a0,%desc_pcrel_20(var) #R_LARCH_TLS_DESC_PCREL20_S2 For GD: pcalau12i $a0,%gd_pc_hi20(var) addi.d $a0,$a0,%got_pc_lo12(var) after relaxation is: pcaddi $a0,%gd_pcrel_20(var) #R_LARCH_TLS_GD_PCREL20_S2 For LD: pcalau12i $a0,%ld_pc_hi20(var) addi.d $a0,$a0,%got_pc_lo12(var) after relaxation is: pcaddi $a0,%ld_pcrel_20(var) #R_LARCH_TLS_LD_PCREL20_S2 Lulu Cai (4): LoongArch: Add new relocs and macro for TLSDESC. LoongArch: Add support for TLSDESC in ld. LoongArch: Add tls transition support. Transitions between DESC->IE/LE and IE->LE are supported now. LoongArch: Add testsuit for DESC and tls transition and tls relaxation. mengqinggang (1): LoongArch: TLS LD/GD/DESC relaxation. bfd/bfd-in2.h | 15 + bfd/elfnn-loongarch.c | 509 +++++++++++++++++- bfd/elfxx-loongarch.c | 265 ++++++++- bfd/libbfd.h | 15 + bfd/reloc.c | 36 ++ gas/config/tc-loongarch.c | 20 +- gas/testsuite/gas/loongarch/macro_op.d | 128 ++--- gas/testsuite/gas/loongarch/macro_op_32.d | 120 +++-- .../gas/loongarch/macro_op_large_abs.d | 160 +++--- .../gas/loongarch/macro_op_large_pc.d | 160 +++--- gas/testsuite/gas/loongarch/tlsdesc_32.d | 28 + gas/testsuite/gas/loongarch/tlsdesc_32.s | 12 + gas/testsuite/gas/loongarch/tlsdesc_64.d | 28 + gas/testsuite/gas/loongarch/tlsdesc_64.s | 12 + .../gas/loongarch/tlsdesc_large_abs.d | 21 + .../gas/loongarch/tlsdesc_large_abs.s | 9 + .../gas/loongarch/tlsdesc_large_pc.d | 22 + .../gas/loongarch/tlsdesc_large_pc.s | 13 + include/elf/loongarch.h | 26 +- include/opcode/loongarch.h | 6 + ld/testsuite/ld-loongarch-elf/desc-ie.d | 17 + ld/testsuite/ld-loongarch-elf/desc-ie.s | 18 + ld/testsuite/ld-loongarch-elf/desc-le.d | 15 + ld/testsuite/ld-loongarch-elf/desc-le.s | 14 + ld/testsuite/ld-loongarch-elf/ie-le.d | 13 + ld/testsuite/ld-loongarch-elf/ie-le.s | 11 + .../ld-loongarch-elf/ld-loongarch-elf.exp | 7 + ld/testsuite/ld-loongarch-elf/macro_op.d | 391 +++++++------- ld/testsuite/ld-loongarch-elf/macro_op_32.d | 120 +++-- ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d | 57 ++ ld/testsuite/ld-loongarch-elf/tlsdesc-dso.s | 66 +++ opcodes/loongarch-opc.c | 54 ++ 32 files changed, 1825 insertions(+), 563 deletions(-) create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_32.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_32.s create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_64.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_64.s create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_abs.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_abs.s create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_pc.d create mode 100644 gas/testsuite/gas/loongarch/tlsdesc_large_pc.s create mode 100644 ld/testsuite/ld-loongarch-elf/desc-ie.d create mode 100644 ld/testsuite/ld-loongarch-elf/desc-ie.s create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le.d create mode 100644 ld/testsuite/ld-loongarch-elf/desc-le.s create mode 100644 ld/testsuite/ld-loongarch-elf/ie-le.d create mode 100644 ld/testsuite/ld-loongarch-elf/ie-le.s create mode 100644 ld/testsuite/ld-loongarch-elf/tlsdesc-dso.d create mode 100644 ld/testsuite/ld-loongarch-elf/tlsdesc-dso.s