From patchwork Mon Dec 5 08:04:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: mengqinggang X-Patchwork-Id: 29578 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2120894wrr; Mon, 5 Dec 2022 00:05:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf5T5Yy3sTNSvIHQ/s7mbWHLtU/tZ/pGE2O1AWos7CMHDsobAYaIe4jlH1oIx4vJCTPhPwD1 X-Received: by 2002:a17:906:ca0e:b0:78c:1f2f:233e with SMTP id jt14-20020a170906ca0e00b0078c1f2f233emr55625228ejb.307.1670227528212; Mon, 05 Dec 2022 00:05:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670227528; cv=none; d=google.com; s=arc-20160816; b=ZPpZDgYs+2NS4nwIOjRg3yO3ykZMJL7X5496ppj2V/p3gjQvJtTd1rGkmjW7jykbtG jJvWbRSvVmHda3vYN29t7p3jr6DN7dlCTo/SGK6aSKHLMI6J/31StUdZLG6Xc+oUR8aL 9ZSFcDrGHwyLP3XI6Uwpu8Mab/wRNbFeZon2IaTIz3PoBaMP9Er0VE2udj9yu952lD9p Fuhtup744U5MXllSImpECywgtmYwbmzEaR7pKImpAdjbpLTg7lQh/zuNiB0CioRMvPCh B5qbi678vCoAHw0TSZ6fDA2VCTGErDAyRxXJ3U6Xqo2qWNO6Eqd+VSjZF9+UYkxAGeb/ C0qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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:dmarc-filter:delivered-to; bh=UvmKMn41dvKOdVWUGBwbkq7Ro30Kw/GzucL/23w6/Rc=; b=YFpvYDMfwlkGlU/KUdGzeBOsjWSyJk8Uq8ozHg3E5Iqv3uk8KxmHOx5DBUHDh7y8rl l0w5x9BPr3Im/hMxtMEeDIUrOQItjNMlDQ+ZQM0zmkdr+U7luPiROZPC13iREVE0mH8e BOzFS5Y9EivxncRW82lXY5h+lqcUu8SQF2h+cCuafxQdaecB5RQ9BuVyZBJ+ub4WolRW al01JbZQ3o4WLxYpu8WvMD6NFgZ8/2Jrt80c8pZd1whSFnbFfw5DKZ76/S4lSXF7uC3Q m2dI1eWixtt+gqPH09Iv0AhW1dJJxus3YwVpb/MtD/ANvFW6AUjeyAzWJqqxXE/SXEuv fadg== ARC-Authentication-Results: i=1; mx.google.com; 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id hg2-20020a1709072cc200b007c0d4287966si5166896ejc.423.2022.12.05.00.05.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 00:05:28 -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; 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 81B473894C0E for ; Mon, 5 Dec 2022 08:05:23 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 39B7D3893657 for ; Mon, 5 Dec 2022 08:05:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 39B7D3893657 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.5]) by gateway (Coremail) with SMTP id _____8AxDOs6po1jzjkDAA--.7421S3; Mon, 05 Dec 2022 16:05:14 +0800 (CST) Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxPuIzpo1jIdYlAA--.27857S3; Mon, 05 Dec 2022 16:05:14 +0800 (CST) From: mengqinggang To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, liuzhensong@loongson.cn, chenglulu@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, mengqinggang Subject: [PATCH v1 1/6] LoongArch: include: Add support for linker relaxation. Date: Mon, 5 Dec 2022 16:04:48 +0800 Message-Id: <20221205080453.1352069-2-mengqinggang@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221205080453.1352069-1-mengqinggang@loongson.cn> References: <20221205080453.1352069-1-mengqinggang@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxPuIzpo1jIdYlAA--.27857S3 X-CM-SenderInfo: 5phqw15lqjwttqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7KrW5Wr45CF1xuw4fXr1kZrb_yoW8Ar13pF 9xAw45CFWFkFnrur9Yvw1xArs3X3yxKFW2qFyfZa10krsrJryUZr47CF1DAFW2qw4YqrWa vryfuw15WF95tr7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUJVWUCwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2 IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE14v26r1j6r4U McvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr 0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU82g43UUUUU== X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP 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.29 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 Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751360501123827914?= X-GMAIL-MSGID: =?utf-8?q?1751360501123827914?= Add relocs and gas LARCH_opts.relax option. include/ChangeLog: * elf/loongarch.h: Add relocs. * opcode/loongarch.h: Add LARCH_opts.relax and macro LARCH_NOP. --- include/elf/loongarch.h | 20 ++++++++++++++++++++ include/opcode/loongarch.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h index a6341b46791..0ecddd17b37 100644 --- a/include/elf/loongarch.h +++ b/include/elf/loongarch.h @@ -229,6 +229,26 @@ RELOC_NUMBER (R_LARCH_32_PCREL, 99) /* RELAX. */ RELOC_NUMBER (R_LARCH_RELAX, 100) +/* relax delete. */ +RELOC_NUMBER (R_LARCH_DELETE, 101) + +/* relax align. */ +RELOC_NUMBER (R_LARCH_ALIGN, 102) + +/* pcaddi. */ +RELOC_NUMBER (R_LARCH_PCREL20_S2, 103) + +/* cfa. */ +RELOC_NUMBER (R_LARCH_CFA, 104) + +/* DW_CFA_advance_loc. */ +RELOC_NUMBER (R_LARCH_ADD6, 105) +RELOC_NUMBER (R_LARCH_SUB6, 106) + +/* unsinged leb128. */ +RELOC_NUMBER (R_LARCH_ADD_ULEB128, 107) +RELOC_NUMBER (R_LARCH_SUB_ULEB128, 108) + END_RELOC_NUMBERS (R_LARCH_count) /* Processor specific flags for the ELF header e_flags field. */ diff --git a/include/opcode/loongarch.h b/include/opcode/loongarch.h index c3922348a56..71570e9acc2 100644 --- a/include/opcode/loongarch.h +++ b/include/opcode/loongarch.h @@ -28,6 +28,8 @@ extern "C" { #endif + #define LARCH_NOP 0x03400000 + typedef uint32_t insn_t; struct loongarch_opcode @@ -228,6 +230,7 @@ dec2 : [1-9][0-9]? #define ase_gpcr isa.use_la_global_with_pcrel #define ase_gabs isa.use_la_global_with_abs + int relax; } LARCH_opts; extern size_t loongarch_insn_length (insn_t insn);