From patchwork Fri Dec 15 10:06:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: changjiachen X-Patchwork-Id: 179144 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp9162704dys; Fri, 15 Dec 2023 02:07:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBSc5BCeZeOqJS7YS5GTeL5ct+gJuIwsnCnb5qyAojLvPDxLDFG3R9s7KO0wy1km3iE0kd X-Received: by 2002:a05:6808:1983:b0:3b9:da2c:e5a9 with SMTP id bj3-20020a056808198300b003b9da2ce5a9mr14491421oib.62.1702634838759; Fri, 15 Dec 2023 02:07:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702634838; cv=pass; d=google.com; s=arc-20160816; b=maFIn/pLEUwkvTbWTNJBeezYCRjzSPofnb8jdNTI0v/NeAk0ZEExhcCJo1GtQ3yaDL rrJ/jrRPSc+JYVqCg47dygzuvLEqN88dV6ClNqYcoWhp1O7L6p7fLLenBgZAdZVNxJR6 5v8/VLp/qn+pMVfYra3908hM+GOtOb0O8LsFB0xah3+U08SqdAFSy5FZOn9ILwGpzjua l1de/QnP09m2EcwNAsfZm1A7uVXp3/HgsZV5aCLMZ4fwJkMkJm6KrNmESxoPeujjuIhV VAYE09iXTx8m73Ilm2TtomZYnjG3vFNbNbMT/k7exq9beXKOn2v35pZwIUmzTY/B0+Iu VlFw== 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=4mqlGAR5ZpT3oAzqkQf6l8xgW1tDh4KjDOVbnj/Kbp4=; fh=uTF/VfpCAq2GtcL5NdCKul3VKQPlBSDYmUlZE/0CcYM=; b=cZeSGIhyHIxAfPWlZ45yCrrs8TkQE05AhRQnJ9a5NjahfquVUeLisCRg+pB1+lcrMx h3p4ILjJgD/4nkcLoGXpgouPCKbg+FPKcgH3h38b42JDdT+KNadvLJ8Adym3oFPxIMOM 33OsJyMXfnOFK+j6g360R1Xfli47PTr+fWLP7i7iCWW9uYuK2NpXyvT88To/a1hsIc4K hg26P2U9DoNL7ODraO/Ol5UpbW8Tl34aJVCQfWGFmS5FgG0Vr6LaGUkvlAV/62GLQ1TH 5rK6LZZMWbA9e167dbzwDlubK6wzgDHwq8QTt7BX681pDcaAJM88Gv0wgVsYE2JpJUCJ MwMA== 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 qd9-20020ad44809000000b0067a5330c2c7si17772268qvb.459.2023.12.15.02.07.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 02:07:18 -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 2F11B3847724 for ; Fri, 15 Dec 2023 10:07:18 +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 CFAB838618E8 for ; Fri, 15 Dec 2023 10:06:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CFAB838618E8 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 CFAB838618E8 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=1702634811; cv=none; b=sZLyBQZjQFIv6S6PYd6Tv5dLKD2AQG+EySEtSSRH1xdkbMLJGKfoNHb7q4ErkBrfbHqc1lPfDwUcRJiVwewN/1HHjJeHWQmfsS/nCYzqUB5Af5NTL5PwfGP4B155K4YCxGJ9CXZgoX+CHhf//zmm2bEDoh0J5qx8BkgHt/7P150= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702634811; c=relaxed/simple; bh=J6boJ2nvyq4E/2NeSecvjyB5TglWnJAKu5fMmleNKw8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=DTLwMxcbLHk6k5ktxYeSs44u43p8ZVp+hn3f2QNUe/PEOqaNQpxj1opbSZuj/ZlcEIQgRo1XuBa4fnaEP09QZ77gGsNOa3xW5ib+pwAzyM/eQV2ms5eLQniy3oLPSyMwgSIdpSi1URLmA36tvhVs6Mx4KaO/nYHttwJckSy2Kzg= 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 08BE2AC00EA; Fri, 15 Dec 2023 18:06:44 +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 v3 4/5] LoongArch: gas: Add support for tls le relax. Date: Fri, 15 Dec 2023 18:06:32 +0800 Message-Id: <20231215100633.65397-5-changjiachen@stu.xupt.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231215100633.65397-1-changjiachen@stu.xupt.edu.cn> References: <20231215100633.65397-1-changjiachen@stu.xupt.edu.cn> MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDS0pOVk4aQ0IdSEwdT05DTFUTARMWGhIXJBQOD1 lXWRgSC1lBWUpKSlVKQ1VITFVJS0hZV1kWGg8SFR0UWUFZT0tIVUpMSk9MQ1VKS0tVSkJLS1kG X-HM-Tid: 0a8c6cf1550eb039kuuu08be2ac00ea X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Mwg6Sio5Azw4TjdRQlEcPQw0 IgwaCSNVSlVKTEtJTUhPQ0tOS0tNVTMWGhIXVRgTGhUcERIaGBMeFTsIDw5VAw4LD1UeHw5VGBVF WVdZEgtZQVlKSkpVSkNVSExVSUtIWVdZCAFZQU5OTUw3Bg++ X-Spam-Status: No, score=-11.7 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: 1785342028831410258 X-GMAIL-MSGID: 1785342028831410258 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. 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/config/tc-loongarch.c | 12 ++++++++++-- gas/testsuite/gas/loongarch/reloc.d | 18 ++++++++++++++++++ gas/testsuite/gas/loongarch/reloc.s | 11 +++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index 59232832cf7..c97288fe0a1 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -680,9 +680,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 +689,15 @@ 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 + || BFD_RELOC_LARCH_TLS_LE_ADD_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/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)