From patchwork Tue Dec 19 06:40:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: changjiachen X-Patchwork-Id: 180779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1751420dyi; Mon, 18 Dec 2023 22:40:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/Qs38V6Ae6Y2Pqy4VB6q9xo6YRA5wlcOmxnDAqKhuPAN2pfIhWTBawYemo9BkDAAfOtRm X-Received: by 2002:a05:620a:f90:b0:77d:78b0:e52e with SMTP id b16-20020a05620a0f9000b0077d78b0e52emr17747311qkn.37.1702968042917; Mon, 18 Dec 2023 22:40:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702968042; cv=pass; d=google.com; s=arc-20160816; b=IvsqRtUulbqa4pKklg2eg+YgMZX7EahRhyfvAONDE+CQwgNAJ2Y02OjyIWiGAxSQNP S9PYOpmX/3rHRGsX9x3S6MN8dsFF9YyZpmdmiBb28fO9gz2R9ykKGFVHU5vw6eTTw5iu HZmGvYSxtIPJVc2PUBtJhHQG/GWgv6XDj5mZzbkfqpfPrPLFD5edImaZ0CNDgMs7oY7g vXjz69q+9gtjLGWRPUl9FGeB/K6SUaNsZMvtFfXsXhWOaTUKUADvVsyTG1+yIjoSsp5y Zt6GqO8liT2e3lDc8rHYmMf9nP0vBIWvnt/SsT3UGtsYBfroXCiigHmNTd1xK7I62Bsi txOQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=wlm3RaXFU0jAJ58eosPmiXo80KvBNm+djFOnaqRA+Qg=; fh=uTF/VfpCAq2GtcL5NdCKul3VKQPlBSDYmUlZE/0CcYM=; b=JZqdDWxYaIrsIgdRIsQXTnnVYGs5wFUysbJ8PMynjXf2zFaIm6UGbq/UwP8Rvxc+MC dJSAWcqA7scB35yUvI8vfEx11iY0nTcn4N1mrogIqRrr1Sz7qNgb6G0JH/XNtxL6xL3q wSL7jQu9POAwW8J30Dg2Tjy7Rhk43dyQCIox5GavogbtAJzmYyBIi3ljA3iraaWLBx5J VDCQYWpIuggs9EFGYxy+SomCdLU9x2womDVnzzyuUP9uknVYcSG2Jgz2PHSc05CW9C1Y H7H9Nv3P8RfwsgO+oEWEOlSGfiUZKqFd85EWh/SqZ4bMz8nfpa4Z6dfrj1QCAJSlM91l HFOg== 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 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c13-20020a05620a11ad00b00780deea6328si5263122qkk.148.2023.12.18.22.40.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 22:40:42 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E86A33860743 for ; Tue, 19 Dec 2023 06:40:39 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-m6026.netease.com (mail-m6026.netease.com [210.79.60.26]) by sourceware.org (Postfix) with ESMTPS id B08C53858C5F for ; Tue, 19 Dec 2023 06:40:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B08C53858C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=stu.xupt.edu.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=stu.xupt.edu.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B08C53858C5F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=210.79.60.26 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968029; cv=none; b=vE3lg8mYazdD/S6/JyirxMQh83784gvgn3g/kYsePJzxIO1MJx3Qux6ovp5uP/I0CpSUQ0rTx6ZH1bZ06wgVRG3v87d0LN6VlqfWUJhM/zkGZOXnZALyO5kkBe4XpPwILOzylfHjNRkgrvxhpVHLY7E/x+Mc1v6bl6zGzUeUan4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968029; c=relaxed/simple; bh=Wqvpm7aNn9n38oe4YzzSH0KycmTvV6hijy2Ew/odn5s=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=RA3U7u6qoX4zU6SRFdYmJscKsu4f4soPh0J6SNYVPN5TourgPUr/NjPjNbkzo6FGUbU+xgCbWrdQquXtqD969xListup51z8KPdJaDVDZLpqdwKlP54NeFIePWoTj0KbRlZnk0UkDUvqv2TTu1DlGUf8sj5hghidu/3yvMYTK0s= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from ubuntu.localdomain (unknown [111.18.37.203]) by mail-m121144.qiye.163.com (Hmail) with ESMTPA id AA962AC00CB; Tue, 19 Dec 2023 14:40:14 +0800 (CST) From: changjiachen To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, cailulu@loongson.cn, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lazy_Linux@126.com, mengqinggang@loongson.cn, changjiachen Subject: [PATCH v4 1/5] LoongArch: bfd: Add support for tls le relax. Date: Tue, 19 Dec 2023 14:40:07 +0800 Message-Id: <20231219064011.90412-2-changjiachen@stu.xupt.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> References: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDT0NKVkxLHRpMSENNH0pLSVUTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSlVKQ1VITFVJS0hZV1kWGg8SFR0UWUFZS1VLVUtVS1kG X-HM-Tid: 0a8c80cdb96cb039kuuuaa962ac00cb X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PCI6Aww*ATw6HS8xQwpRTQMY ARIaCxZVSlVKTEtJQk1DS0pNSU9LVTMWGhIXVRgTGhUcERIaGBMeFTsIDw5VAw4LD1UeHw5VGBVF WVdZEgtZQVlKSkpVSkNVSExVSUtIWVdZCAFZQUpKS05INwY+ X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: 1785691418137590301 X-GMAIL-MSGID: 1785691418137590301 Add tls le relax support and related relocs in bfd. This support does two main things: 1. Implement support for three new relocation items in bfd. The three new relocation items are shown below: R_LARCH_TLS_LE_ADD_R R_LARCH_TLS_LE_HI20_R R_LARCH_TLS_LE_LO12_R 2. ADD a new macro RELOCATE_TLS_TP32_HI20 Handle problems caused by symbol extensions in TLS LE, The processing is similar to the macro RELOCATE_CALC_PC32_HI20 method. 3. Implement the tls le relax function. bfd/ChangeLog: * bfd-in2.h: Add relocs related to tls le relax. * elfnn-loongarch.c: (loongarch_relax_tls_le): New function. (RELOCATE_TLS_TP32_HI20): New macro. (loongarch_elf_check_relocs): Add new reloc support. (perform_relocation): Likewise. (loongarch_elf_relocate_section): Handle new relocs related to relax. (loongarch_elf_relax_section): Likewise. * elfxx-loongarch.c: (LOONGARCH_HOWTO (R_LARCH_TLS_LE_ADD_R)): New reloc how to type. (LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20_R)): Likewise. (LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12_R)): Likewise. * libbfd.h: Add relocs related to tls le relax. * reloc.c: Likewise. --- bfd/bfd-in2.h | 4 +++ bfd/elfnn-loongarch.c | 76 +++++++++++++++++++++++++++++++++++++++++++ bfd/elfxx-loongarch.c | 50 ++++++++++++++++++++++++++++ bfd/libbfd.h | 3 ++ bfd/reloc.c | 6 ++++ 5 files changed, 139 insertions(+) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 040d5560cdf..6b3303d99e9 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7460,8 +7460,12 @@ enum bfd_reloc_code_real BFD_RELOC_LARCH_ADD_ULEB128, BFD_RELOC_LARCH_SUB_ULEB128, BFD_RELOC_LARCH_64_PCREL, + BFD_RELOC_LARCH_TLS_LE_HI20_R, + BFD_RELOC_LARCH_TLS_LE_ADD_R, + BFD_RELOC_LARCH_TLS_LE_LO12_R, BFD_RELOC_UNUSED }; + typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; reloc_howto_type *bfd_reloc_type_lookup diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 024c5d4cd96..9f578af6ae3 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -738,6 +738,7 @@ loongarch_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, break; case R_LARCH_TLS_LE_HI20: + case R_LARCH_TLS_LE_HI20_R: case R_LARCH_SOP_PUSH_TLS_TPREL: if (!bfd_link_executable (info)) return false; @@ -2105,6 +2106,8 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section, case R_LARCH_GOT64_HI12: case R_LARCH_TLS_LE_HI20: case R_LARCH_TLS_LE_LO12: + case R_LARCH_TLS_LE_HI20_R: + case R_LARCH_TLS_LE_LO12_R: case R_LARCH_TLS_LE64_LO20: case R_LARCH_TLS_LE64_HI12: case R_LARCH_TLS_IE_PC_HI20: @@ -2130,6 +2133,7 @@ perform_relocation (const Elf_Internal_Rela *rel, asection *input_section, break; case R_LARCH_RELAX: + case R_LARCH_TLS_LE_ADD_R: break; default: @@ -2310,6 +2314,16 @@ loongarch_reloc_is_fatal (struct bfd_link_info *info, relocation += 0x1000; \ }) +/* Handle problems caused by symbol extensions in TLS LE, The processing + is similar to the macro RELOCATE_CALC_PC32_HI20 method. */ +#define RELOCATE_TLS_TP32_HI20(relocation) \ + ({ \ + bfd_vma __lo = (relocation) & ((bfd_vma)0xfff); \ + if (__lo > 0x7ff) \ + relocation += 0x800; \ + relocation = relocation & ~(bfd_vma)0xfff; \ + }) + /* For example: pc is 0x11000010000100, symbol is 0x1812348ffff812 offset = (0x1812348ffff812 & ~0xfff) - (0x11000010000100 & ~0xfff) = 0x712347ffff000 @@ -3205,6 +3219,13 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, break; + case R_LARCH_TLS_LE_HI20_R: + relocation -= elf_hash_table (info)->tls_sec->vma; + + RELOCATE_TLS_TP32_HI20 (relocation); + + break; + case R_LARCH_PCALA_LO12: /* Not support if sym_addr in 2k page edge. pcalau12i pc_hi20 (sym_addr) @@ -3375,6 +3396,7 @@ loongarch_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, case R_LARCH_TLS_LE_HI20: case R_LARCH_TLS_LE_LO12: + case R_LARCH_TLS_LE_LO12_R: case R_LARCH_TLS_LE64_LO20: case R_LARCH_TLS_LE64_HI12: BFD_ASSERT (resolved_local && elf_hash_table (info)->tls_sec); @@ -3735,6 +3757,49 @@ loongarch_relax_delete_bytes (bfd *abfd, return true; } +/* Relax tls le. + lu12i.w,add.d,addi.w,st.w/addi.w/ld.w + ====> addi.w,st.w/addi.w/ld.w. */ +static bool +loongarch_relax_tls_le (bfd *abfd, asection *sec, + Elf_Internal_Rela *rel, + struct bfd_link_info *link_info, + bfd_vma symval) +{ + bfd_byte *contents = elf_section_data (sec)->this_hdr.contents; + uint32_t insn = bfd_get (32, abfd, contents + rel->r_offset); + static uint32_t insn_rj,insn_rd; + symval = symval - elf_hash_table (link_info)->tls_sec->vma; + /* Whether the symbol offset is in the interval (offset < 0x800). */ + if (ELFNN_R_TYPE ((rel + 1)->r_info) + == R_LARCH_RELAX && symval < 0x800) + { + switch (ELFNN_R_TYPE (rel->r_info)) + { + case R_LARCH_TLS_LE_HI20_R: + case R_LARCH_TLS_LE_ADD_R: + /* delete insn. */ + rel->r_info = ELFNN_R_INFO (0, R_LARCH_NONE); + loongarch_relax_delete_bytes (abfd, sec, rel->r_offset, 4, link_info); + break; + case R_LARCH_TLS_LE_LO12_R: + /* Change rj to $tp. */ + insn_rj = 0x2 << 5; + /* Get rd register. */ + insn_rd = insn & 0x1f; + /* Write symbol offset. */ + symval <<= 10; + /* Writes the modified instruction. */ + insn = insn & 0xffc00000; + insn = insn | symval | insn_rj | insn_rd; + bfd_put (32, abfd, insn, contents + rel->r_offset); + break; + default: + break; + } + } + return true; +} /* Relax pcalau12i,addi.d => pcaddi. */ static bool @@ -4023,6 +4088,17 @@ loongarch_elf_relax_section (bfd *abfd, asection *sec, rel->r_info = ELFNN_R_INFO (0, R_LARCH_NONE); } break; + case R_LARCH_TLS_LE_HI20_R: + case R_LARCH_TLS_LE_LO12_R: + case R_LARCH_TLS_LE_ADD_R: + if (info->relax_pass == 0) + { + if (i + 2 > sec->reloc_count) + break; + loongarch_relax_tls_le (abfd, sec, rel, info, symval); + } + break; + case R_LARCH_PCALA_HI20: if (0 == info->relax_pass && (i + 4) <= sec->reloc_count) loongarch_relax_pcala_addi (abfd, sec, sym_sec, rel, symval, diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c index 7f298c08fd3..9f24307fffd 100644 --- a/bfd/elfxx-loongarch.c +++ b/bfd/elfxx-loongarch.c @@ -1547,6 +1547,56 @@ static loongarch_reloc_howto_type loongarch_howto_table[] = NULL, /* adjust_reloc_bits */ NULL), /* larch_reloc_type_name */ + LOONGARCH_HOWTO (R_LARCH_TLS_LE_HI20_R, /* type (110). */ + 12, /* rightshift. */ + 4, /* size. */ + 20, /* bitsize. */ + false, /* pc_relative. */ + 5, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_LE_HI20_R", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x1ffffe0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_LE_HI20_R, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "le_hi20_r"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_LE_ADD_R, /* type (111). */ + 0, /* rightshift. */ + 0, /* size. */ + 0, /* bitsize. */ + false, /* pc_relative. */ + 0, /* bitpos. */ + complain_overflow_dont, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_LE_ADD_R", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_LE_ADD_R, /* bfd_reloc_code_real_type. */ + NULL, /* adjust_reloc_bits. */ + "le_add_r"), /* larch_reloc_type_name. */ + + LOONGARCH_HOWTO (R_LARCH_TLS_LE_LO12_R, /* type (112). */ + 0, /* rightshift. */ + 4, /* size. */ + 12, /* bitsize. */ + false, /* pc_relative. */ + 10, /* bitpos. */ + complain_overflow_signed, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_LARCH_TLS_LE_LO12_R", /* name. */ + false, /* partial_inplace. */ + 0, /* src_mask. */ + 0x3ffc00, /* dst_mask. */ + false, /* pcrel_offset. */ + BFD_RELOC_LARCH_TLS_LE_LO12_R, /* bfd_reloc_code_real_type. */ + reloc_bits, /* adjust_reloc_bits. */ + "le_lo12_r"), /* larch_reloc_type_name. */ }; reloc_howto_type * diff --git a/bfd/libbfd.h b/bfd/libbfd.h index cc432677a81..4b0e9405e76 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -3599,6 +3599,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_LARCH_ADD_ULEB128", "BFD_RELOC_LARCH_SUB_ULEB128", "BFD_RELOC_LARCH_64_PCREL", + "BFD_RELOC_LARCH_TLS_LE_HI20_R", + "BFD_RELOC_LARCH_TLS_LE_ADD_R", + "BFD_RELOC_LARCH_TLS_LE_LO12_R", "@@overflow: BFD_RELOC_UNUSED@@", }; #endif diff --git a/bfd/reloc.c b/bfd/reloc.c index 93ebad879e0..f6312ff9b77 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -8291,6 +8291,12 @@ ENUMX ENUMX BFD_RELOC_LARCH_64_PCREL +ENUMX + BFD_RELOC_LARCH_TLS_LE_HI20_R +ENUMX + BFD_RELOC_LARCH_TLS_LE_ADD_R +ENUMX + BFD_RELOC_LARCH_TLS_LE_LO12_R ENUMDOC LARCH relocations. From patchwork Tue Dec 19 06:40:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: changjiachen X-Patchwork-Id: 180777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1751369dyi; Mon, 18 Dec 2023 22:40:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWLz6WmXH8znAlUAmzk6cqdDUMIuQ5/rocOIbY0P87/gKSiTgX1lhuM5fhhIK3BkDLUbBI X-Received: by 2002:a05:622a:2d3:b0:423:737d:8776 with SMTP id a19-20020a05622a02d300b00423737d8776mr21903513qtx.3.1702968035621; Mon, 18 Dec 2023 22:40:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702968035; cv=pass; d=google.com; s=arc-20160816; b=p/LeS7pRpFZH3bOOFe8JRrWx5nTLkC/7ZguJTGW/QM9rG3XbyiyUWp0+E4ApvC38dc OgE397rSxSk0Ojq7lrYwx8rnZa60WAlDz3PnSELlKjeX+4QcD/cqUK/gfGE5iISziuuU vKvCUtsPLh07DOuz/S5T9D4vCl1diW4VdFz39CJArDeFPDDBGYSrI3YuuFFzEdyBIaih n6S8bNHKygUVnNvzEmhYVIKMiuToBveZ+Dwp1onzgajBLZ0mlCPff3YB/fkwYqWH5NCy cfWkcQHh9dV/wkk8pjpPaGJPrw1bCUj+cjduu7rydRTOJPBq8ouboyDofUtGdBDqUaR4 pipQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=L0x6f+fjttUIJY48HxbFfmVod0vFWYJOdmHYr5u0yjQ=; fh=uTF/VfpCAq2GtcL5NdCKul3VKQPlBSDYmUlZE/0CcYM=; b=B/HfzwBn+5C42/RoiVAuNNewmjwFrO95UBvEsvIHSqw6eBMaU4MbBY3s5gOjXWVfLB e4tRhW3A8GRM9GB3Kgth7+HXArs13g0yTRq+kXkbZBin1ESoIcl1QEyMF19rumulUuxL xLTDV2x5gDO065XvfaK95n15Uwnj/+0dbpra0X/b1sT19dajlkv+FJnJb9WkFYqsBFhB 3cgmHBV61zYo/Xt9A3NrTy5XjJem0Z8K75kP3nBadm0YP4jCcpZ2AYrgY86AKCPivIK8 fw3HdgvqQ5FAcOpBIZgBqCKeim3uoRQZft+4GttMytZ13wPsNuvZoj0FSXtazEuTelNV 9KBQ== 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 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l26-20020ac8725a000000b00423a15081f0si23605419qtp.682.2023.12.18.22.40.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 22:40:35 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 36F0C3857340 for ; Tue, 19 Dec 2023 06:40:35 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) by sourceware.org (Postfix) with ESMTPS id ED2CE3858439 for ; Tue, 19 Dec 2023 06:40:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED2CE3858439 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=stu.xupt.edu.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=stu.xupt.edu.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED2CE3858439 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968028; cv=none; b=JoQMxZGAgDA5KrJ6Ny6NZIRh+mOswzKpAtIqQHAHzA+bDm90tYastCdmONZO6N3BSGIHtdnFElU8cIqhaxzTjRLe3Uda+MiMej0+qYxJQ2EYJJOXN1q8oyl7okQc2yK6zJJ6oLUSouTrgU3GgtWJlqyC76l9YTqFl2hS9YG+xh4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968028; c=relaxed/simple; bh=ANwCH0ZrhuQTab2IDolZnwLGG1kyrldBahDDPppcy3c=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=peU9FhbDSCsBh2osUOykIxlq1OihDcwyblG/EYTRByMJCZIImSltU2St5ofNm3jdYoui8cai8b8QwzBIwNmELUP+H6ylLwmU4YbapILsAkfDXcQZrCKjrUrwMLWDnd/4OJDDjMA4vUZLG4nUC+O5vufSeqW0GL6IrdprsToz9lY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from ubuntu.localdomain (unknown [111.18.37.203]) by mail-m121144.qiye.163.com (Hmail) with ESMTPA id CA1CEAC00CC; Tue, 19 Dec 2023 14:40:16 +0800 (CST) From: changjiachen To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, cailulu@loongson.cn, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lazy_Linux@126.com, mengqinggang@loongson.cn, changjiachen Subject: [PATCH v4 2/5] LoongArch: include: Add support for tls le relax. Date: Tue, 19 Dec 2023 14:40:08 +0800 Message-Id: <20231219064011.90412-3-changjiachen@stu.xupt.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> References: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDSh4dVkkYSk5DGUodHklJHlUTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSlVKQ1VITFVJS0hZV1kWGg8SFR0UWUFZT0tIVUpKS0hKQ1VKS0tVS1kG X-HM-Tid: 0a8c80cdc1b9b039kuuuca1ceac00cc X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Pkk6TSo*SzwzKy8THgs2TQFR Vj8aCghVSlVKTEtJQk1DS0pDSUtLVTMWGhIXVRgTGhUcERIaGBMeFTsIDw5VAw4LD1UeHw5VGBVF WVdZEgtZQVlKSkpVSkNVSExVSUtIWVdZCAFZQUlOSkM3Bg++ X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, 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: 1785691411109397817 X-GMAIL-MSGID: 1785691411109397817 Add new relocs number for tls le relax. include/ChangeLog: * elf/loongarch.h: (RELOC_NUMBER (R_LARCH_TLS_LE_HI20_R, 110)): New relocs number. (RELOC_NUMBER (R_LARCH_TLS_LE_ADD_R, 111)): Likewise. (RELOC_NUMBER (R_LARCH_TLS_LE_LO12_R, 112)): Likewise. --- include/elf/loongarch.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h index e31395e13d5..bccd36d452e 100644 --- a/include/elf/loongarch.h +++ b/include/elf/loongarch.h @@ -250,6 +250,18 @@ RELOC_NUMBER (R_LARCH_ADD_ULEB128, 107) RELOC_NUMBER (R_LARCH_SUB_ULEB128, 108) RELOC_NUMBER (R_LARCH_64_PCREL, 109) +/* TLS-LE-LUI + lu12i.w rd,%le_hi20_r (sym). */ +RELOC_NUMBER (R_LARCH_TLS_LE_HI20_R, 110) + +/* TLS-LE-ADD + add.d rd,rj,rk,%le_add_r (sym). */ +RELOC_NUMBER (R_LARCH_TLS_LE_ADD_R, 111) + +/* TLS-LE-ST + st.w/addi.w/ld.w rd,rj,%le_lo12_r (sym). */ +RELOC_NUMBER (R_LARCH_TLS_LE_LO12_R, 112) + END_RELOC_NUMBERS (R_LARCH_count) From patchwork Tue Dec 19 06:40:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: changjiachen X-Patchwork-Id: 180776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1751367dyi; Mon, 18 Dec 2023 22:40:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFD1s9yt3+N5GNUreLgHI5zM/cl89hDpzmz3Z30IWT895M9Tl2SPC6xa5MPPfZyHh3VJrvD X-Received: by 2002:a05:620a:1677:b0:77e:fba3:a796 with SMTP id d23-20020a05620a167700b0077efba3a796mr13888023qko.116.1702968035114; Mon, 18 Dec 2023 22:40:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702968035; cv=pass; d=google.com; s=arc-20160816; b=QIb4jnoHXrgkyoYit74RTZEYqA6zfTp/Xb6AdcHCj9rWaasnXv/q6maGxpTLIuEM0/ XEySrciAElWjcKH3eoNH1vw6LX7CqSJHCxwkI+SHSI1Ab+OZwWwP6gOQEktM2i+aC6d/ 3cSRibeO1QWJJgHNIvNcsyCGubNashE8Rhp+vLBEdHIfjNL+iSJ7fFEEegO22yUd1R0l lo+q1TL/DikzeafyaP+8FVDeq02mrO8aUbhfHkZFOidJ7HKR2PkVZeaBhMFB1+ZeSNe+ /bLk7X8a8gAxx86vi0yZlRip2qY3XvRWnEBp7jm6IM2+C2bCgsbajR18AXpbK0tmKbEr 5eqA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=3xa0OFJQI2G5ARX6mpeAKgjJLOKQ8Z4ahMSsHI8Z20Q=; fh=uTF/VfpCAq2GtcL5NdCKul3VKQPlBSDYmUlZE/0CcYM=; b=TumFfHoXrc+BA0zf5szEwx3x4wxEYLs6WNMJOzGfvcDLJhl+U/36dg6Mp3cDSd1suU Fq6tosKWzXVOj3Mk7Apb3vgyzZD1hiWr7nnuQ+ObwramQM50RLYW/3wfNlFB0O6YPKuR vlcDABf3jfxMfZdBRk7sCE+G3iiufKYsNPsmDh/IuSExrtcj5zDYEwf0co+wMt9K/OH1 dfUoh1rYhi1wxA8eV//knFIIEStD7FLDBTQj70l8lOmu7QvORLT7nW/4VmSKKmx8smJ2 27MHfX6/GQY4SM0a+tYgqRUclgLHrmi1zwuBn14SSNlX+VKkaqOldknX1efA8wWShpxi GZxw== 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 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q9-20020a05620a038900b0077fb0b817d3si8770514qkm.123.2023.12.18.22.40.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 22:40:35 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 99859385DC0C for ; Tue, 19 Dec 2023 06:40:34 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) by sourceware.org (Postfix) with ESMTPS id EFC333858298 for ; Tue, 19 Dec 2023 06:40:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EFC333858298 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=stu.xupt.edu.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=stu.xupt.edu.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EFC333858298 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968028; cv=none; b=OOqEqRu77SoNVlgZaHCb3NMVhvKvAlYdW/u1kHWYbc1f1zpBASclWNhmAT1HNYseioUuTwHNV6ldzM/nca63PIYD+gIlSKKOG2CZY3YdsK2ELCi22VadFZV+VJwA31wj/rYPqVGnDIqUR+8kSclfaXNc6G++9Zd8409pXm5GUCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968028; c=relaxed/simple; bh=ALVp2flesggJtG/2+OccU4Q61f3aifHqJjoAxPchBe8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=A4FhOzQXxL+kZMfGyjD4CK1r62PjrOvt3k0D9c7Xo08//Isa7KAu21ytwoJJP9lsgoPIJ20JCR3dIBFkrhdT7g6l+ytP2tPlF5fzKbwIr4Qjl6S7dqFvOOBVLvVZeGF+I+1o7HxmLuREpabqEwSOPXrKegV76tlGIHWLa+y6QAw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from ubuntu.localdomain (unknown [111.18.37.203]) by mail-m121144.qiye.163.com (Hmail) with ESMTPA id 10D06AC00D6; Tue, 19 Dec 2023 14:40:19 +0800 (CST) From: changjiachen To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, cailulu@loongson.cn, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lazy_Linux@126.com, mengqinggang@loongson.cn, changjiachen Subject: [PATCH v4 3/5] LoongArch: opcodes: Add support for tls le relax. Date: Tue, 19 Dec 2023 14:40:09 +0800 Message-Id: <20231219064011.90412-4-changjiachen@stu.xupt.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> References: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVkZSEJDVhgfSRlCGElLQx9JS1UTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSlVKQ1VITFVJS0hZV1kWGg8SFR0UWUFZT0tIVUpKS0hKQ1VKS0tVS1kG X-HM-Tid: 0a8c80cdca79b039kuuu10d06ac00d6 X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Pgg6Fhw6Lzw5GS9KHgtITU02 TU4KCUNVSlVKTEtJQk1DS0lLSUxNVTMWGhIXVRgTGhUcERIaGBMeFTsIDw5VAw4LD1UeHw5VGBVF WVdZEgtZQVlKSkpVSkNVSExVSUtIWVdZCAFZQUlPTkk3Bg++ X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, 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: 1785691410231704333 X-GMAIL-MSGID: 1785691410231704333 Add new opcode for tls le relax. opcode/ChangeLog: * loongarch-opc.c: Add new loongarch opcode. --- opcodes/loongarch-opc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c index 15c7da6340c..f92e437650b 100644 --- a/opcodes/loongarch-opc.c +++ b/opcodes/loongarch-opc.c @@ -399,6 +399,7 @@ static struct loongarch_opcode loongarch_fix_opcodes[] = { 0x000c0000, 0xfffc0000, "bytepick.d", "r0:5,r5:5,r10:5,u15:3", 0, 0, 0, 0 }, { 0x00100000, 0xffff8000, "add.w", "r0:5,r5:5,r10:5", 0, 0, 0, 0 }, { 0x00108000, 0xffff8000, "add.d", "r0:5,r5:5,r10:5", 0, 0, 0, 0 }, + { 0x00108000, 0xffff8000, "add.d", "r0:5,r5:5,r10:5,t", 0, 0, 0, 0 }, { 0x00110000, 0xffff8000, "sub.w", "r0:5,r5:5,r10:5", 0, 0, 0, 0 }, { 0x00118000, 0xffff8000, "sub.d", "r0:5,r5:5,r10:5", 0, 0, 0, 0 }, { 0x00120000, 0xffff8000, "slt", "r0:5,r5:5,r10:5", 0, 0, 0, 0 }, From patchwork Tue Dec 19 06:40:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: changjiachen X-Patchwork-Id: 180778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1751400dyi; Mon, 18 Dec 2023 22:40:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFARZtZ7BrIbvdJ1aTUYC7BlnWyQKY36FNGjvYKOGh7EtTzDwH5K3LQ6XN0E262P+wulfG X-Received: by 2002:ac8:5d46:0:b0:423:a45a:e883 with SMTP id g6-20020ac85d46000000b00423a45ae883mr24881438qtx.51.1702968039771; Mon, 18 Dec 2023 22:40:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702968039; cv=pass; d=google.com; s=arc-20160816; b=0xCZPiKjMIiR0h3WPKHSvcx0lbx8B7gTsJTIuUafSYFE5d8Kux7+JXBLEjHesvELKg 1KAYNvy8w9K9YzP1BrAFXCmRjUjx1wV254f6NiWxHsgzicfiz7fGwz9GphBgIcjEaw3+ 26Tl7ceBRyfg9wd/Y1EvkIP/2eNGqPBuA1umT4VuSpL/aiKBjt+vJn+BIM8P8zpHqb0L OTp+Mq1iceCEpTbwOK051jS5WBXIrfnuu+GeUad5rRyb/zmULbT0NzfpqLaPXH3wdw4N D1/OAaq0WElIaok8eO10pKZtzkcCeO+qfsr8FSfuJU3eCtZfyxGdx3I41XYQstQ4IhwA JWbg== 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:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=11BS/kgty1n1mqnYT2mHVOebqd0dZ5jK4ooeEnbdDXk=; fh=uTF/VfpCAq2GtcL5NdCKul3VKQPlBSDYmUlZE/0CcYM=; b=mHpuJtYcESm19Nw5j4e+A5+2yiCLYpUGyKSOyujSrUAz6UdnqP6GDAyhTfPY7kY4XM y2ChqXijq+byjbnjjZU8Y+m80rR9lbGBat3tm1th+UYJNsvdGDjKoQtz2tysfLs/g3kH 8wZq+ACJ5MrfTC7Cl1HoQU30Rf6LO+8Y2T1SDUeRLCIgDjuMFVuwADV2ZgUTjRqhotoT h3E9JFdJt7i+y4HwgQ0QULDXeRVgtZ7zvsfAQkoufQJrTWg2GjpF4TS7afUR85GZpTFS opCtW83SKCEz4wSqm7C9/yyFGzf6NNUOikgIQcUBfj5k0B+cS4vfBcGdnGs265l3bwtI S90Q== 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id c11-20020ac8660b000000b00423804bda65si24465399qtp.13.2023.12.18.22.40.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 22:40:39 -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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9F80385DC22 for ; Tue, 19 Dec 2023 06:40:37 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-m49197.qiye.163.com (mail-m49197.qiye.163.com [45.254.49.197]) by sourceware.org (Postfix) with ESMTPS id AB6753858001 for ; Tue, 19 Dec 2023 06:40:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AB6753858001 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=stu.xupt.edu.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=stu.xupt.edu.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AB6753858001 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=45.254.49.197 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968028; cv=none; b=IMZMaRu2PRyXukBy3vHJX4McDon2ql3L17hEKbOQw3ev+oNIj8kgItzcc5v29rUISi0y3RGJX/I2D6XcFQogfiit3By47LmMwGMwpWL3z0UQeFm4Qw3mQi0M5TlrTiQ3cExj5uF64OkoC3vB1MBjnhtjsTU3D6IJ+jMrDtVJ68U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968028; c=relaxed/simple; bh=vKD9lgeJnd51CnKwe/wq7VwYAIedLQkWQmUJJ1ltYBA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=IrfCcmw9qu6IDHfGVImWG8lxKsugyzBwv4LfBIdhuJ8SITQE55k351cMK109evLEZwfJPZQTYnnNYnFJIRWishN+7Iy9ydZobS4/oRBBd709RY2ywEnLzbE71uvjltgsCcSwftRIPftB2U47/idC7lcY4RBrHLSL2wfDE/HrOz8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from ubuntu.localdomain (unknown [111.18.37.203]) by mail-m121144.qiye.163.com (Hmail) with ESMTPA id D38B7AC00CA; Tue, 19 Dec 2023 14:40:20 +0800 (CST) From: changjiachen To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, cailulu@loongson.cn, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lazy_Linux@126.com, mengqinggang@loongson.cn, changjiachen Subject: [PATCH v4 4/5] oongArch: gas: Add support for tls le relax. Date: Tue, 19 Dec 2023 14:40:10 +0800 Message-Id: <20231219064011.90412-5-changjiachen@stu.xupt.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> References: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDTk4eVk0eGEJPQxpPGh0aTVUTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSlVKQ1VITFVJS0hZV1kWGg8SFR0UWUFZT0tIVUpKS0hKQ1VKS0tVS1kG X-HM-Tid: 0a8c80cdd17fb039kuuud38b7ac00ca X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MEk6Kyo4Mjw*Ti83NAkTTU1J QwswCk5VSlVKTEtJQk1DS0lKQkNJVTMWGhIXVRgTGhUcERIaGBMeFTsIDw5VAw4LD1UeHw5VGBVF WVdZEgtZQVlKSkpVSkNVSExVSUtIWVdZCAFZQUNLT043Bg++ X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, 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: 1785691415405614709 X-GMAIL-MSGID: 1785691415405614709 Add tls le relax related relocs support and testsuites in gas. The main test is three new relocation items, R_LARCH_TLS_LE_ADD_R, R_LARCH_TLS_LE_HI20_R, R_LARCH_TLS_LE_LO12_R can be generated properly and tls le insn format check. gas/ChangeLog: * config/tc-loongarch.c: (loongarch_args_parser_can_match_arg_helper): Add support for relax. * gas/testsuite/gas/loongarch/reloc.d: Likewise. * gas/testsuite/gas/loongarch/reloc.s: Likewise. * gas/testsuite/gas/loongarch/loongarch.exp: Likewise. * gas/testsuite/gas/loongarch/tls_le_insn_format_check.s: New test. --- gas/config/tc-loongarch.c | 33 +++++++++++++++++-- gas/testsuite/gas/loongarch/loongarch.exp | 9 +++++ gas/testsuite/gas/loongarch/reloc.d | 18 ++++++++++ gas/testsuite/gas/loongarch/reloc.s | 11 +++++++ .../gas/loongarch/tls_le_insn_format_check.s | 5 +++ 5 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 gas/testsuite/gas/loongarch/tls_le_insn_format_check.s diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index 59232832cf7..8a8e53ad3ce 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -636,6 +636,28 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2, break; } break; + /* This is used for TLS, where the fourth operand is %le_add_r, + to get a relocation applied to an add instruction, for relaxation to use. + Two conditions, ip->match_now and reloc_num, are used to check tls insn + to prevent cases like add.d $a0,$a0,$a0,8. */ + case 't': + ip->match_now = + loongarch_parse_expr (arg, ip->reloc_info + ip->reloc_num, + reloc_num_we_have, &reloc_num, &imm) == 0; + + if (!ip->match_now) + break; + + if (reloc_num && + ip->reloc_info[ip->reloc_num].type == BFD_RELOC_LARCH_TLS_LE_ADD_R) + { + ip->reloc_num += reloc_num; + ip->reloc_info[ip->reloc_num].type = BFD_RELOC_LARCH_RELAX; + ip->reloc_info[ip->reloc_num].value = const_0; + ip->reloc_num++; + } + else ip->match_now = 0; + break; case 's': case 'u': ip->match_now = @@ -680,9 +702,8 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2, as_fatal ( _("not support reloc bit-field\nfmt: %c%c %s\nargs: %s"), esc_ch1, esc_ch2, bit_field, arg); - if (ip->reloc_info[0].type >= BFD_RELOC_LARCH_B16 - && ip->reloc_info[0].type < BFD_RELOC_LARCH_64_PCREL) + && ip->reloc_info[0].type < BFD_RELOC_UNUSED) { /* As we compact stack-relocs, it is no need for pop operation. But break out until here in order to check the imm field. @@ -690,6 +711,14 @@ loongarch_args_parser_can_match_arg_helper (char esc_ch1, char esc_ch2, ip->reloc_num += reloc_num; reloc_type = ip->reloc_info[0].type; + if (LARCH_opts.relax + && (BFD_RELOC_LARCH_TLS_LE_HI20_R == reloc_type + || BFD_RELOC_LARCH_TLS_LE_LO12_R == reloc_type)) + { + ip->reloc_info[ip->reloc_num].type = BFD_RELOC_LARCH_RELAX; + ip->reloc_info[ip->reloc_num].value = const_0; + ip->reloc_num++; + } if (LARCH_opts.relax && ip->macro_id && (BFD_RELOC_LARCH_PCALA_HI20 == reloc_type || BFD_RELOC_LARCH_PCALA_LO12 == reloc_type diff --git a/gas/testsuite/gas/loongarch/loongarch.exp b/gas/testsuite/gas/loongarch/loongarch.exp index 6d126fd4b0e..c0aa593d8a8 100644 --- a/gas/testsuite/gas/loongarch/loongarch.exp +++ b/gas/testsuite/gas/loongarch/loongarch.exp @@ -21,4 +21,13 @@ if [istarget loongarch*-*-*] { run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]] gas_test_old bfd_reloc_8.s "" "bfd_reloc_8" + if [file exist "tls_le_insn_format_check.s "] { + set format [run_host_cmd "as" "tls_le_insn_format_check.s"] + if { [ regexp ".*no match insn.*" $format] } { + pass "loongarch tls le insn format pass" + } { + pass "loongarch tls le insn format fail" + } + } + } diff --git a/gas/testsuite/gas/loongarch/reloc.d b/gas/testsuite/gas/loongarch/reloc.d index c3820c55f98..0458830f30b 100644 --- a/gas/testsuite/gas/loongarch/reloc.d +++ b/gas/testsuite/gas/loongarch/reloc.d @@ -165,3 +165,21 @@ Disassembly of section .text: [ ]+134:[ ]+R_LARCH_TLS_LE64_LO20[ ]+TLSL1\+0x8 [ ]+138:[ ]+03000085[ ]+lu52i.d[ ]+\$a1,[ ]+\$a0,[ ]+0 [ ]+138:[ ]+R_LARCH_TLS_LE64_HI12[ ]+TLSL1\+0x8 +[ ]+13c:[ ]+14000004[ ]+lu12i.w[ ]+\$a0,[ ]+0 +[ ]+13c:[ ]+R_LARCH_TLS_LE_HI20_R[ ]+TLSL1 +[ ]+13c:[ ]+R_LARCH_RELAX[ ]+\*ABS\* +[ ]+140:[ ]+001090a5[ ]+add.d[ ]+\$a1,[ ]+\$a1,[ ]+\$a0 +[ ]+140:[ ]+R_LARCH_TLS_LE_ADD_R[ ]+TLSL1 +[ ]+140:[ ]+R_LARCH_RELAX[ ]+\*ABS\* +[ ]+144:[ ]+29800085[ ]+st.w[ ]+\$a1,[ ]+\$a0,[ ]+0 +[ ]+144:[ ]+R_LARCH_TLS_LE_LO12_R[ ]+TLSL1 +[ ]+144:[ ]+R_LARCH_RELAX[ ]+\*ABS\* +[ ]+148:[ ]+14000004[ ]+lu12i.w[ ]+\$a0,[ ]+0 +[ ]+148:[ ]+R_LARCH_TLS_LE_HI20_R[ ]+TLSL1\+0x8 +[ ]+148:[ ]+R_LARCH_RELAX[ ]+\*ABS\* +[ ]+14c:[ ]+001090a5[ ]+add.d[ ]+\$a1,[ ]+\$a1,[ ]+\$a0 +[ ]+14c:[ ]+R_LARCH_TLS_LE_ADD_R[ ]+TLSL1\+0x8 +[ ]+14c:[ ]+R_LARCH_RELAX[ ]+\*ABS\* +[ ]+150:[ ]+29800085[ ]+st.w[ ]+\$a1,[ ]+\$a0,[ ]+0 +[ ]+150:[ ]+R_LARCH_TLS_LE_LO12_R[ ]+TLSL1\+0x8 +[ ]+150:[ ]+R_LARCH_RELAX[ ]+\*ABS\* diff --git a/gas/testsuite/gas/loongarch/reloc.s b/gas/testsuite/gas/loongarch/reloc.s index a67fecd9429..0a343c11225 100644 --- a/gas/testsuite/gas/loongarch/reloc.s +++ b/gas/testsuite/gas/loongarch/reloc.s @@ -142,3 +142,14 @@ lu12i.w $r4,%le_hi20(TLSL1 + 0x8) ori $r5,$r4,%le_lo12(TLSL1 + 0x8) lu32i.d $r4,%le64_lo20(TLSL1 + 0x8) lu52i.d $r5,$r4,%le64_hi12(TLSL1 + 0x8) + + +/* New TLS Insn. */ +lu12i.w $r4,%le_hi20_r(TLSL1) +add.d $r5,$r5,$r4,%le_add_r(TLSL1) +st.w $r5,$r4,%le_lo12_r(TLSL1) + +/* New TLS Insn with addend. */ +lu12i.w $r4,%le_hi20_r(TLSL1 + 0x8) +add.d $r5,$r5,$r4,%le_add_r(TLSL1 + 0x8) +st.w $r5,$r4,%le_lo12_r(TLSL1 + 0x8) diff --git a/gas/testsuite/gas/loongarch/tls_le_insn_format_check.s b/gas/testsuite/gas/loongarch/tls_le_insn_format_check.s new file mode 100644 index 00000000000..12b8b4769cc --- /dev/null +++ b/gas/testsuite/gas/loongarch/tls_le_insn_format_check.s @@ -0,0 +1,5 @@ +/* Assemble the following assembly statements using as. + If a "no match insn" exception is thrown, the test passes; + otherwise, the test fails. */ + +add.d $a0,$a0,$a0,8 From patchwork Tue Dec 19 06:40:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: changjiachen X-Patchwork-Id: 180780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1751753dyi; Mon, 18 Dec 2023 22:41:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFI2UAPtvl4sFXDhsXbHkQPmMFVWxL617C37kV9SlK0jWhnVhMRG5r6M7jXiGAMho3chMHr X-Received: by 2002:a05:620a:1465:b0:77f:588:71ac with SMTP id j5-20020a05620a146500b0077f058871acmr19024471qkl.96.1702968103629; Mon, 18 Dec 2023 22:41:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702968103; cv=pass; d=google.com; s=arc-20160816; b=xMWDvTtP/icg1irj7Ld2O7dhSaSymYt30vC7Znf+UTyys2xSgI5n61uqbbbGlFLv2O V1+7aixm3iDwViXg4ph9gp3sshK30wTm9/OT7aBz/mA9hOGc2XA+XrX0fzfNfhcbmXNF LAFqZlIV82wJM3JH/J6h67DpE3SFjMJ7CzX6SOiZNONpvFifQ4oDFtUbKa9/pmHMoPFI B5orGF1TotQdf6v7UzWj8l9IDEtJbEbjqbKo9NDF+krFbeExtDAN4NONK0/5S39QMsWw Btr+hn6v1VFFIEfa+yLYHILVKOwu3diqk8NJJVwXXRf3GjtM1BZxALlbZNZvHeHyijyf C3XQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=/ek0nhpgZz4YvbYng4OrurAi8nYE4Pr7jHbHkvPGxiI=; fh=uTF/VfpCAq2GtcL5NdCKul3VKQPlBSDYmUlZE/0CcYM=; b=gkFbqQo+ZpaluSNz05C49X7MuEG825sJ/VrJPy7ECc9KM/Aczl0mDGYGmvmTFT4lZS KEz5cva1WpiibJ5+0/j+K9jdtcE4SR6YynixX4zBK2HGrUmBblI1NZyeW28Vu2POxz2J hs/SdeMXFV+Gp1uFWvwbfbjnmJRiigKiLWUpFF9XJoFTaIG8LHgWNjMFKq1+WLjYLYiL ltm9sPE5YL3ncI1gfEH2pvLvSEDIWtgvAAQCjyXKepvMSsOqEVoMr6otzJ0k9CfKgItN wjApn63gQUzjrQGxi2vbiTibxMZTusozT6BxS9Ma/qzHraR7RgKwqDhHD+00E0JDR9eE GwhA== 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w23-20020ae9e517000000b0077faca74aabsi9487624qkf.43.2023.12.18.22.41.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 22:41:43 -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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xupt.edu.cn Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1F2A0385DC14 for ; Tue, 19 Dec 2023 06:41:40 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-m155101.qiye.163.com (mail-m155101.qiye.163.com [101.71.155.101]) by sourceware.org (Postfix) with ESMTPS id 546483858008 for ; Tue, 19 Dec 2023 06:40:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 546483858008 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=stu.xupt.edu.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=stu.xupt.edu.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 546483858008 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=101.71.155.101 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968030; cv=none; b=jZtCQ/q2Qlj5aoSnOUebq8TP+xDUOBbuoTb/aBFY66Etw3N1m2Gfw+zzixJBQYjfDwYkeVJP8cPZ6r+4JrwYY2nY5v7H0JPSnYtOmxmH6MRbx/C753TUxttQI4Ko3fzdETQ6EcACa0AcGhaR0aquYpqF8JCJlZkWAXC5mdGaiPY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702968030; c=relaxed/simple; bh=sbZ5zyAmLUX/FjhVOoAgQas7R7fr+zqRGOUogqk9t+c=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=uzCKl8WC99S4roWM1UoGZDDiBO3l+OEdzOxM8uhnvEx2zynk40iX6P0JVUa2tODvRTbX9/F0wS8U/XD2+ki+TPBSjJgu7w9XIA7qo+0QKYReMo1npSRNtYjPlBE8FPPAqE1f8yfBY04/dfNTQJj+ZmFErW9NctNrZDQLlKvu3ns= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from ubuntu.localdomain (unknown [111.18.37.203]) by mail-m121144.qiye.163.com (Hmail) with ESMTPA id 9F397AC00D4; Tue, 19 Dec 2023 14:40:22 +0800 (CST) From: changjiachen To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, cailulu@loongson.cn, luweining@loongson.cn, wanglei@loongson.cn, hejinyang@loongson.cn, Lazy_Linux@126.com, mengqinggang@loongson.cn, changjiachen Subject: [PATCH v4 5/5] LoongArch: ld: Add support for tls le relax. Date: Tue, 19 Dec 2023 14:40:11 +0800 Message-Id: <20231219064011.90412-6-changjiachen@stu.xupt.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> References: <20231219064011.90412-1-changjiachen@stu.xupt.edu.cn> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDS0NOVh1LT0MdTUMaQhlMTFUTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSlVKQ1VITFVJS0hZV1kWGg8SFR0UWUFZT0tIVUpKS0hKQ1VKS0tVS1kG X-HM-Tid: 0a8c80cdd87bb039kuuu9f397ac00d4 X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PRg6NSo4Gjw8AS8ODgkITUs9 Ok5PCgFVSlVKTEtJQk1DS0lITE1JVTMWGhIXVRgTGhUcERIaGBMeFTsIDw5VAw4LD1UeHw5VGBVF WVdZEgtZQVlKSkpVSkNVSExVSUtIWVdZCAFZQUpKTE9DNwY+ X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, 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: 1785691482323040961 X-GMAIL-MSGID: 1785691482323040961 Add tls le relax related testsuites in ld. The new test cases are mainly tested in three aspects: 1. tls le relax function correctness test. 2. tls le relax boundary check test. 3. tls le relax function compatibility test. --- ld/testsuite/ld-loongarch-elf/old-tls-le.s | 19 +++ .../relax-bound-check-tls-le.s | 48 ++++++ ld/testsuite/ld-loongarch-elf/relax-tls-le.s | 17 ++ ld/testsuite/ld-loongarch-elf/relax.exp | 151 +++++++++++++++++- .../tls-relax-compatible-check-new.s | 29 ++++ .../tls-relax-compatible-check-old.s | 27 ++++ 6 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 ld/testsuite/ld-loongarch-elf/old-tls-le.s create mode 100644 ld/testsuite/ld-loongarch-elf/relax-bound-check-tls-le.s create mode 100644 ld/testsuite/ld-loongarch-elf/relax-tls-le.s create mode 100644 ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-new.s create mode 100644 ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-old.s diff --git a/ld/testsuite/ld-loongarch-elf/old-tls-le.s b/ld/testsuite/ld-loongarch-elf/old-tls-le.s new file mode 100644 index 00000000000..290c4c61c18 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/old-tls-le.s @@ -0,0 +1,19 @@ + .text + .globl aa + .section .tbss,"awT",@nobits + .align 2 + .type aa, @object + .size aa, 4 +aa: + .space 4 + .text + .align 2 + .globl main + .type main, @function +main: + lu12i.w $r12,%le_hi20(aa) + ori $r12,$r12,%le_lo12(aa) + add.d $r12,$r12,$r2 + addi.w $r13,$r0,2 # 0x2 + stptr.w $r13,$r12,0 + diff --git a/ld/testsuite/ld-loongarch-elf/relax-bound-check-tls-le.s b/ld/testsuite/ld-loongarch-elf/relax-bound-check-tls-le.s new file mode 100644 index 00000000000..da62cd0224b --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/relax-bound-check-tls-le.s @@ -0,0 +1,48 @@ + .text + .globl count1 + .section .tbss,"awT",@nobits + .align 2 + .type count1, @object + .size count1, 4 +count1: + .space 0x400 + .globl count2 + .align 2 + .type count2, @object + .size count2, 4 +count2: + .space 0x400 + .globl count3 + .align 2 + .type count3, @object + .size count3, 4 +count3: + .space 0x400 + .globl count4 + .align 2 + .type count4, @object + .size count4, 4 +count4: + .space 4 + .text + .align 2 + .globl main + .type main, @function +main: + lu12i.w $r12,%le_hi20_r(count1) + add.d $r12,$r12,$r2,%le_add_r(count1) + addi.w $r13,$r0,1 + st.w $r13,$r12,%le_lo12_r(count1) + lu12i.w $r12,%le_hi20_r(count2) + add.d $r12,$r12,$r2,%le_add_r(count2) + addi.w $r13,$r0,2 + st.w $r13,$r12,%le_lo12_r(count2) + lu12i.w $r12,%le_hi20(count3) + add.d $r12,$r12,$r2,%le_add_r(count3) + addi.w $r13,$r0,3 + st.w $r13,$r12,%le_lo12_r(count3) + lu12i.w $r12,%le_hi20(count4) + add.d $r12,$r12,$r2,%le_add_r(count4) + addi.w $r13,$r0,4 + st.w $r13,$r12,%le_lo12_r(count4) + diff --git a/ld/testsuite/ld-loongarch-elf/relax-tls-le.s b/ld/testsuite/ld-loongarch-elf/relax-tls-le.s new file mode 100644 index 00000000000..bf605f2bf23 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/relax-tls-le.s @@ -0,0 +1,17 @@ + .text + .globl a + .section .tbss,"awT",@nobits + .align 2 + .type a, @object + .size a, 4 +a: + .space 4 + .text + .align 2 + .globl main + .type main, @function +main: + lu12i.w $r12,%le_hi20_r(a) + add.d $r12,$r12,$r2,%le_add_r(a) + addi.w $r13,$r0,1 # 0x1 + st.w $r13,$r12,%le_lo12_r(a) diff --git a/ld/testsuite/ld-loongarch-elf/relax.exp b/ld/testsuite/ld-loongarch-elf/relax.exp index 24d79ed5c20..5999b37f811 100644 --- a/ld/testsuite/ld-loongarch-elf/relax.exp +++ b/ld/testsuite/ld-loongarch-elf/relax.exp @@ -33,8 +33,90 @@ if [istarget loongarch64-*-*] { "relax" \ ] \ ] + set tls_relax_builds [list \ + [list \ + "tls_relax_builds" \ + "" \ + "" \ + {relax-tls-le.s} \ + {} \ + "relax-tls-le" \ + ] \ + ] + set tls_no_relax_builds [list \ + [list \ + "tls_no_relax_builds" \ + "-Wl,--no-relax" \ + "" \ + {relax-tls-le.s} \ + {} \ + "no-relax-tls-le" \ + ] \ + ] + + set relax_bound_check [list \ + [list \ + "relax_bound_check" \ + "" \ + "" \ + {relax-bound-check-tls-le.s} \ + {} \ + "relax-bound-check-tls-le" \ + ] \ + ] + set no_relax_bound_check [list \ + [list \ + "no_relax_bound_check" \ + "-Wl,--no-relax" \ + "" \ + {relax-bound-check-tls-le.s} \ + {} \ + "no-relax-bound-check-tls-le" \ + ] \ + ] + + set old_tls_le [list \ + [list \ + "old_tls_le" \ + "" \ + "" \ + {old-tls-le.s} \ + {} \ + "old-tls-le" \ + ] \ + ] + + set relax_compatible [list \ + [list \ + "relax_compatible" \ + "" \ + "" \ + {tls-relax-compatible-check-new.s tls-relax-compatible-check-old.s} \ + {} \ + "realx-compatible" \ + ] \ + ] + + set no_relax_compatible [list \ + [list \ + "no_relax_compatible" \ + "-Wl,--no-relax" \ + "" \ + {tls-relax-compatible-check-new.s tls-relax-compatible-check-old.s} \ + {} \ + "no-realx-compatible" \ + ] \ + ] + run_cc_link_tests $pre_builds + run_cc_link_tests $tls_relax_builds + run_cc_link_tests $tls_no_relax_builds + run_cc_link_tests $relax_bound_check + run_cc_link_tests $no_relax_bound_check + run_cc_link_tests $old_tls_le + run_cc_link_tests $relax_compatible + run_cc_link_tests $no_relax_compatible if [file exist "tmpdir/relax"] { set objdump_output [run_host_cmd "objdump" "-d tmpdir/relax"] @@ -114,8 +196,75 @@ if [istarget loongarch64-*-*] { "relax-segment-max" \ ] \ ] - } + if [file exist "tmpdir/relax-tls-le"] { + set objdump_output1 [run_host_cmd "objdump" "-d tmpdir/relax-tls-le"] + if { [ regexp ".addi.*st.*" $objdump_output1] } { + pass "loongarch relax success" + } { + fail "loongarch relax fail" + } + } + if [file exist "tmpdir/no-relax-tls-le"] { + set objdump_output2 [run_host_cmd "objdump" "-d tmpdir/no-relax-tls-le"] + if { [ regexp ".*lu12i.*add.*addi.*st.*" $objdump_output2] } { + pass "loongarch no-relax success" + } { + fail "loongarch no-relax fail" + } + + } + if [file exist "tmpdir/old-tls-le"] { + set objdump_output3 [run_host_cmd "objdump" "-d tmpdir/old-tls-le"] + if { [ regexp ".*lu12i.*ori.*add.*addi.*stptr.*" $objdump_output3] } { + pass "loongarch old tls le success" + } { + fail "loongarch old tls le fail" + } + + } + + if [file exist "tmpdir/realx-compatible"] { + set objdump_output4 [run_host_cmd "objdump" "-d tmpdir/realx-compatible"] + if { [ regexp ".addi.*st.*" $objdump_output4] && \ + [ regexp ".*lu12i.*ori.*add.*addi.*stptr.*" $objdump_output4] } { + pass "loongarch tls le relax compatible check success" + } { + fail "loongarch tls le relax compatible check fail" + } + } + + if [file exist "tmpdir/no-realx-compatible"] { + set objdump_output4 [run_host_cmd "objdump" "-d tmpdir/realx-compatible"] + if { [ regexp ".*lu12i.*add.*addi.*st.*" $objdump_output4] && \ + [ regexp ".*lu12i.*ori.*add.*addi.*stptr.*" $objdump_output4] } { + pass "loongarch tls le no-relax compatible check success" + } { + fail "loongarch tls le no-relax compatible check fail" + } + } + + + if [file exist "tmpdir/relax-bound-check-tls-le"] { + set objdump_output5 [run_host_cmd "objdump" "-d tmpdir/relax-bound-check-tls-le"] + if { [ regexp ".*lu12i.*add.*addi.*st.*" $objdump_output5] && \ + [ regexp ".addi.*st.*" $objdump_output5] } { + pass "loongarch no-relax success" + } { + fail "loongarch no-relax fail" + } + + } + if [file exist "tmpdir/no-relax-bound-check-tls-le"] { + set objdump_output5 [run_host_cmd "objdump" "-d tmpdir/no-relax-bound-check-tls-le"] + if { [ regexp ".*addi.*st.*" $objdump_output5] } { + pass "loongarch no-relax success" + } { + fail "loongarch no-relax fail" + } + } + + } run_ld_link_tests \ [list \ [list \ diff --git a/ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-new.s b/ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-new.s new file mode 100644 index 00000000000..194c7cf6833 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-new.s @@ -0,0 +1,29 @@ + .text + .globl new + .section .tbss,"awT",@nobits + .align 2 + .type new, @object + .size new, 4 +new: + .space 4 + .text + .align 2 + .globl main + .type main, @function +main: +.LFB0 = . + addi.d $r3,$r3,-16 + st.d $r1,$r3,8 + stptr.d $r22,$r3,0 + addi.d $r22,$r3,16 + bl %plt(old) + lu12i.w $r12,%le_hi20_r(new) + add.d $r12,$r12,$r2,%le_add_r(new) + addi.w $r13,$r0,2 # 0x2 + st.w $r13,$r12,%le_lo12_r(new) + or $r12,$r0,$r0 + or $r4,$r12,$r0 + ld.d $r1,$r3,8 + ldptr.d $r22,$r3,0 + addi.d $r3,$r3,16 + jr $r1 diff --git a/ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-old.s b/ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-old.s new file mode 100644 index 00000000000..c50b77f3f5f --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/tls-relax-compatible-check-old.s @@ -0,0 +1,27 @@ + .text + .globl older + .section .tbss,"awT",@nobits + .align 2 + .type older, @object + .size older, 4 +older: + .space 4 + .text + .align 2 + .globl old + .type old, @function +old: +.LFB0 = . + addi.d $r3,$r3,-16 + st.d $r22,$r3,8 + addi.d $r22,$r3,16 + lu12i.w $r12,%le_hi20(older) + ori $r12,$r12,%le_lo12(older) + add.d $r12,$r12,$r2 + addi.w $r13,$r0,1 # 0x1 + stptr.w $r13,$r12,0 + nop + or $r4,$r12,$r0 + ld.d $r22,$r3,8 + addi.d $r3,$r3,16 + jr $r1