From patchwork Thu Feb 29 11:46:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 86585 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB63F3858408 for ; Thu, 29 Feb 2024 11:49:47 +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 E27813858422 for ; Thu, 29 Feb 2024 11:47:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E27813858422 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 E27813858422 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=1709207237; cv=none; b=GmHQaAFhFssggBRaGpzRg38VcUeeMOVvVvVoq/VaFoWojkz4rqZ2uGgAedJqUHB3hIswCcRW78PSfM37THh7dmZOwIpyJXv4HMTrJSkzcs7QYnYAmclkIrjWd+GTjupcTIl4S9yAS6TeYqldeS6P4HXJWH1sxHdnVNAYZhqXZxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709207237; c=relaxed/simple; bh=Ln91+dQKlRBcdHsPn5EhvGez8PX46TU+mTewITzDg6Q=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=isjTplQzuENHu8sZ1UFwX8bxx3jQrTCgkASdxAoBPj0EmqVvT9SCvewBq6CKRLfbeMtJ6mhlOVfwJciyKZ8WDJ1t4jjNeCRJJrPxVk4MM1wmHE2/lQXYnQVDvqVaL5YCVnVfwJ7FxLGgiNMQAiytemMpvNe4a7R+s3AVh0yabOs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8DxaOjBbuBlHuMSAA--.28271S3; Thu, 29 Feb 2024 19:47:13 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx_c6pbuBloL9KAA--.2410S6; Thu, 29 Feb 2024 19:47:12 +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 v1 7/7] LoongArch: Add gas testsuit for LA32 relocations Date: Thu, 29 Feb 2024 19:46:47 +0800 Message-Id: <20240229114647.1587477-3-cailulu@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240229114647.1587477-1-cailulu@loongson.cn> References: <20240229114647.1587477-1-cailulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Cx_c6pbuBloL9KAA--.2410S6 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQACB2XgQGUEowAAsD X-Coremail-Antispam: 1Uk129KBj93XoWxXFWkXw4UAFWfuFW3XryruFX_yoWrAF43pr 13ZwnI9aykW342gry5Ar15Ar1fXw48Cr4xXayft3yjkw4kJr9xAFnrJrZ2y3yfurs0v34r Zrn2qw18WF4DJwcCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI 0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWrXVW3AwAv7VC2z280 aVAFwI0_Cr0_Gr1UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20x vY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I 3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIx AIcVC0I7IYx2IY67AKxVW7JVWDJwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAI cVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2js IEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jOjjgUUUUU= X-Spam-Status: No, score=-13.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+patchwork=sourceware.org@sourceware.org Test the relocation of the LA32 instruction set. --- gas/testsuite/gas/loongarch/relocs_32.d | 75 +++++++++++++++++++++++++ gas/testsuite/gas/loongarch/relocs_32.s | 61 ++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 gas/testsuite/gas/loongarch/relocs_32.d create mode 100644 gas/testsuite/gas/loongarch/relocs_32.s diff --git a/gas/testsuite/gas/loongarch/relocs_32.d b/gas/testsuite/gas/loongarch/relocs_32.d new file mode 100644 index 00000000000..3e1bb62e263 --- /dev/null +++ b/gas/testsuite/gas/loongarch/relocs_32.d @@ -0,0 +1,75 @@ +#as: -mthin-add-sub +#objdump: -dr +#skip: loongarch64-*-* + +.*:[ ]+file format .* + + +Disassembly of section .text: + +0+ <.*>: + 0: 4c0050a4 jirl \$a0, \$a1, 80 + 0: R_LARCH_B16 .L1 + 4: 50004c00 b 76 # 50 <.L1> + 4: R_LARCH_B26 .L1 + 8: 14000004 lu12i.w \$a0, 0 + 8: R_LARCH_ABS_HI20 .L1 + c: 038000a4 ori \$a0, \$a1, 0x0 + c: R_LARCH_ABS_LO12 .L1 + 10: 1a000004 pcalau12i \$a0, 0 + 10: R_LARCH_PCALA_HI20 .L1 + 14: 02800085 addi.w \$a1, \$a0, 0 + 14: R_LARCH_PCALA_LO12 .L1 + 18: 1a000004 pcalau12i \$a0, 0 + 18: R_LARCH_GOT_PC_HI20 .L1 + 1c: 28800085 ld.w \$a1, \$a0, 0 + 1c: R_LARCH_GOT_PC_LO12 .L1 + 20: 14000004 lu12i.w \$a0, 0 + 20: R_LARCH_GOT_HI20 .L1 + 24: 03800084 ori \$a0, \$a0, 0x0 + 24: R_LARCH_GOT_LO12 .L1 + 28: 14000004 lu12i.w \$a0, 0 + 28: R_LARCH_TLS_LE_HI20 TLSL1 + 2c: 03800085 ori \$a1, \$a0, 0x0 + 2c: R_LARCH_TLS_LE_LO12 TLSL1 + 30: 1a000004 pcalau12i \$a0, 0 + 30: R_LARCH_TLS_IE_PC_HI20 TLSL1 + 34: 02c00005 li.d \$a1, 0 + 34: R_LARCH_TLS_IE_PC_LO12 TLSL1 + 38: 14000004 lu12i.w \$a0, 0 + 38: R_LARCH_TLS_IE_HI20 TLSL1 + 3c: 03800084 ori \$a0, \$a0, 0x0 + 3c: R_LARCH_TLS_IE_LO12 TLSL1 + 40: 1a000004 pcalau12i \$a0, 0 + 40: R_LARCH_TLS_LD_PC_HI20 TLSL1 + 44: 14000004 lu12i.w \$a0, 0 + 44: R_LARCH_TLS_LD_HI20 TLSL1 + 48: 1a000004 pcalau12i \$a0, 0 + 48: R_LARCH_TLS_GD_PC_HI20 TLSL1 + 4c: 14000004 lu12i.w \$a0, 0 + 4c: R_LARCH_TLS_GD_HI20 TLSL1 + +0+50 <.L1>: + 50: 00000000 .word 0x00000000 + 50: R_LARCH_32_PCREL .L2 + +0+54 <.L2>: + 54: 03400000 nop + 58: 03400000 nop + 58: R_LARCH_ALIGN .* + 5c: 03400000 nop + 60: 03400000 nop + 64: 1800000c pcaddi \$t0, 0 + 64: R_LARCH_PCREL20_S2 .L1 + 68: 1a000004 pcalau12i \$a0, 0 + 68: R_LARCH_TLS_DESC_PC_HI20 TLSL1 + 6c: 028000a5 addi.w \$a1, \$a1, 0 + 6c: R_LARCH_TLS_DESC_PC_LO12 TLSL1 + 70: 14000004 lu12i.w \$a0, 0 + 70: R_LARCH_TLS_DESC_HI20 TLSL1 + 74: 03800084 ori \$a0, \$a0, 0x0 + 74: R_LARCH_TLS_DESC_LO12 TLSL1 + 78: 28800081 ld.w \$ra, \$a0, 0 + 78: R_LARCH_TLS_DESC_LD TLSL1 + 7c: 4c000021 jirl \$ra, \$ra, 0 + 7c: R_LARCH_TLS_DESC_CALL TLSL1 diff --git a/gas/testsuite/gas/loongarch/relocs_32.s b/gas/testsuite/gas/loongarch/relocs_32.s new file mode 100644 index 00000000000..c5139a7582c --- /dev/null +++ b/gas/testsuite/gas/loongarch/relocs_32.s @@ -0,0 +1,61 @@ +/* b16. */ +jirl $r4,$r5,%b16(.L1) + +/* b26. */ +b %b26(.L1) + +/* lu12i.w. */ +lu12i.w $r4,%abs_hi20(.L1) + +/* ori */ +ori $r4,$r5,%abs_lo12(.L1) + +pcalau12i $r4,%pc_hi20(.L1) +addi.w $r5,$r4,%pc_lo12(.L1) + +pcalau12i $r4,%got_pc_hi20(.L1) +ld.w $r5,$r4,%got_pc_lo12(.L1) + +lu12i.w $r4,%got_hi20(.L1) +ori $r4,$r4,%got_lo12(.L1) + +/* TLS LE. */ +lu12i.w $r4,%le_hi20(TLSL1) +ori $r5,$r4,%le_lo12(TLSL1) + +/* Part of IE relocs. */ +pcalau12i $r4,%ie_pc_hi20(TLSL1) +addi.d $r5,$r0,%ie_pc_lo12(TLSL1) + +lu12i.w $r4,%ie_hi20(TLSL1) +ori $r4,$r4,%ie_lo12(TLSL1) + +/* Part of LD relocs. */ +pcalau12i $r4,%ld_pc_hi20(TLSL1) +lu12i.w $r4,%ld_hi20(TLSL1) + +/* Part of GD relocs. */ +pcalau12i $r4,%gd_pc_hi20(TLSL1) +lu12i.w $r4,%gd_hi20(TLSL1) + +/* Test insn relocs. */ +.L1: +/* 32-bit PC relative. */ +.4byte .L2-.L1 +.L2: +nop + +/* R_LARCH_ALIGN. */ +.align 4 + +/* R_LARCH_PCREL20_S2. */ +pcaddi $r12,.L1 + +/* Part of DESC relocs. */ +pcalau12i $r4,%desc_pc_hi20(TLSL1) +addi.w $r5,$r5,%desc_pc_lo12(TLSL1) + +lu12i.w $r4,%desc_hi20(TLSL1) +ori $r4,$r4,%desc_lo12(TLSL1) +ld.w $r1,$r4,%desc_ld(TLSL1) +jirl $r1,$r1,%desc_call(TLSL1)