From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) by sourceware.org (Postfix) with ESMTPS id 2AC42386188E for ; Fri, 1 Dec 2023 09:08:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2AC42386188E 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 2AC42386188E 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=1701421686; cv=none; b=aKXAKR8VtFMdwC1aYSOd8gYrFElYCBgYWqOYIWygfTB0ZdqYju4kwjGQMH0n22uP6j/OLEVbA6ULHC4zQuWdeEbxBVGtt++RDqrEvbyFqFaGP8ZjbcVA6XJolHVvpKW1r1N+cHD8Gs2NfBr3bM+OSVxIJpR/VjpICncrwk6rht0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701421686; c=relaxed/simple; bh=XAC9CSnbzX8BRzCplsfxFxYI9G5QNHGR+3tMeU0T2wg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=Fe3m5ULIv9HDd0DU+GnR3nhHckhBrneMhB4wgbkwGchWbzFj2PXZFR2jm2TkoU454yAsR9MwYzZvp+FMYPunX2KTMJ01b9zHvz7nMSdAJDvJ4CvyjbHIQenW1rJlQ38Lq1/pZvAi2fGNATl9rhDS6kIEMriDep/mn5cIIhFN9JQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from ubuntu.localdomain (unknown [124.89.2.83]) by mail-m121144.qiye.163.com (Hmail) with ESMTPA id 56197AC00A4; Fri, 1 Dec 2023 17:07:57 +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, changjiachen Subject: [PATCH v1 4/5] LoongArch: gas: Add support for tls le relax. Date: Fri, 1 Dec 2023 17:07:29 +0800 Message-Id: <20231201090730.20521-5-changjiachen@stu.xupt.edu.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231201090730.20521-1-changjiachen@stu.xupt.edu.cn> References: <20231201090730.20521-1-changjiachen@stu.xupt.edu.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlCThkZVhlOSEtNTR9NS0JPTVUTARMWGhIXJBQOD1 lXWRgSC1lBWUpJT1VDQlVJVUNIWVdZFhoPEhUdFFlBWU9LSFVKSktISkNVSktLVUtZBg++ X-HM-Tid: 0a8c24a27d2eb039kuuu56197ac00a4 X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NQw6Ijo4ATw9SxU1QksfIiI2 IR8aCyhVSlVKTEtKT0lKTUxDTkhNVTMWGhIXVRgTGhUcERIaGBMeFTsIDw5VAw4LD1UeHw5VGBVF WVdZEgtZQVlKSU9VQ0JVSVVDSFlXWQgBWUFOTklKNwY+ X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,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 List-Id: 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 d1ce111c186..71bce1b85dc 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..182d7f81c71 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,%tls_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,%tls_le_add_r(TLSL1 + 0x8) +st.w $r5,$r4,%le_lo12_r(TLSL1 + 0x8) -- 2.40.0