From patchwork Tue Nov 14 01:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 164699 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1584302vqg; Mon, 13 Nov 2023 17:28:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSYcmLgRVs/hiG79K25wXzVwMyj8ANRqaWCAC7eTVscwbCp9obsRzlecda7MoVUD9dT2M1 X-Received: by 2002:a05:622a:50f:b0:41c:157a:6869 with SMTP id l15-20020a05622a050f00b0041c157a6869mr1310335qtx.13.1699925305553; Mon, 13 Nov 2023 17:28:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699925305; cv=pass; d=google.com; s=arc-20160816; b=UzfAtkMV4MlMgxz+5TrYJtKu5PfSaa17X3gLWU0iOFtKKZxb8nBXFz10RSRlO2gwjT GmTheaVYEJxEDqAiS/sjD5GTET/So/m0OQUoZi9j5zXivcdgUam4sPiIhQ+eDaqm6xng 26Op+hPhwti0B7vNP+CSJJ/a7bfDfS1A9NyVc/sK4SSiNJG+DvHWzTp+0rmEDbjkrumM Ootuz/g945FNkFqdLjpfWyV/fG+1anjhB53WT2K4RXeQntNLknn4iQ/5mPMUjFTDZS9h Rsu0YoUAiLZFwA/K92M8ImmyQPj1228ycm375XD3I3QpJDg0XTAv28tYv7csOfMR5J5X eFvw== 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:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=SOr2oe6wiSH1QaS/A69KgDxk5wsELdggIKvotuFOgzc=; fh=DMl6b2Diyq+8PtsEIVjGfhZIW0JkBkdnqSiV7t/s/KA=; b=zaNSWMd5oaOukrAil4ssyfLpo3BsNhqBzgQw4SCRSuoNBWoTVIQvn2ftifBcZ7tOTi t/ugEDaQTD57WA+iPqv1hl0jyb/OvksDfRVdELjpfJkmEd2gEnykKavjm49ZX6StSwa+ cl7TDx7dU/R9mB244Ck1uz+mzI13mE01O8zJPMska6DJYbpVVLQFv8jIdNtaiQRLW0+O QT59gXHX2Meeq5/OhQTLwxxWhbLKZXL2511l6/KYoM3MZx3ESA1D15+7/OLT8VO51rK6 lduR2A+JPt+1+U7v6INBOMaXFej/DLdKMinkXz1bGsudI01aucQVUWnDGtNsu3caKUN1 cffA== 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" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b20-20020a05622a021400b004198b1c4aa8si5287400qtx.639.2023.11.13.17.28.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 17:28:25 -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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E3913853315 for ; Tue, 14 Nov 2023 01:28:25 +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 34EA0386180B for ; Tue, 14 Nov 2023 01:28:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34EA0386180B 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 34EA0386180B 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=1699925300; cv=none; b=S8fEW17Mxsbox2zdCBb/xXD+x1RLdX+JfTB/AtdxmLQsjevZ6MgHeio5F4WINkGH10GVhXIWxfQ/c6IYBegnKiZ5/sbDEYjbt2N3RSbiwuuHSsH4zXsTUPV8GrwYV/v0b8woxGNW2zNrQjk9iMOId4W2XBiPu4MogkCdBvyZBHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699925300; c=relaxed/simple; bh=zLoSWLBax04n8XbZPeyFddHc+WysrgsZimhqW5AQ0MU=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=ue7JaYC3RLdkf777euq+7EYjMu6JAG6RSUmxDa/Mmb545VA4nVGSEClAvRiwmOM5CamXqnal479QqLtNdlSgUQRMgIMBxornKB6RTDeMFGdwj8dgEkqux+grP40SpnoAOyzeTCoDFOyAp3gzwBBYPVA7/5Wfz9DPBF4fWt7iWyc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8Cx77srzVJlTck5AA--.54491S3; Tue, 14 Nov 2023 09:28:11 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxkN0rzVJlWmNBAA--.14777S4; Tue, 14 Nov 2023 09:28:11 +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, Lulu Cai Subject: [PATCH] LoongArch: fix internal error when gas handling unsupported relocation type name. Date: Tue, 14 Nov 2023 09:28:09 +0800 Message-Id: <20231114012809.466953-1-cailulu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8DxkN0rzVJlWmNBAA--.14777S4 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAPB2VRh6kg8wABsB X-Coremail-Antispam: 1Uk129KBj93XoWxJFyfuFy5JF1kKr4kWw17Jwc_yoW5Gr1Upr yxZ3W0krW8CFnrGrWqga45ZF1xJw47Grya9a1SvryI9rWSqry5Zw18tryDXFZ8Ga1qgw4r Xrs5Kw1UZF1UtwcCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUvYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l4IxYO2xFxVAFwI0_Jrv_JF1lx2IqxVAqx4xG 67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MI IYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E 14v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j1YL9U UUUU= X-Spam-Status: No, score=-13.6 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: 1782500877037888090 X-GMAIL-MSGID: 1782500877037888090 --- bfd/elfxx-loongarch.c | 3 --- gas/config/loongarch-parse.y | 6 +++++- gas/testsuite/gas/loongarch/reloc_type.d | 3 +++ gas/testsuite/gas/loongarch/reloc_type.l | 2 ++ gas/testsuite/gas/loongarch/reloc_type.s | 3 +++ 5 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 gas/testsuite/gas/loongarch/reloc_type.d create mode 100644 gas/testsuite/gas/loongarch/reloc_type.l create mode 100644 gas/testsuite/gas/loongarch/reloc_type.s diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c index a970a257aa9..7f298c08fd3 100644 --- a/bfd/elfxx-loongarch.c +++ b/bfd/elfxx-loongarch.c @@ -1629,9 +1629,6 @@ loongarch_larch_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, return lht->bfd_type; } - (*_bfd_error_handler) (_("%pB: unsupported relocation type name %s"), - abfd, l_r_name); - bfd_set_error (bfd_error_bad_value); return BFD_RELOC_NONE; } diff --git a/gas/config/loongarch-parse.y b/gas/config/loongarch-parse.y index f4e1a63b972..2104afe87e8 100644 --- a/gas/config/loongarch-parse.y +++ b/gas/config/loongarch-parse.y @@ -132,7 +132,11 @@ reloc (const char *op_c_str, const char *id_c_str, offsetT addend) if (0 == strcmp (op_c_str, "plt")) btype = BFD_RELOC_LARCH_B26; else - btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str); + { + btype = loongarch_larch_reloc_name_lookup (NULL, op_c_str); + if (btype == BFD_RELOC_NONE) + as_fatal (_("unsupported relocation type name %s"), op_c_str); + } if (id_c_str) { diff --git a/gas/testsuite/gas/loongarch/reloc_type.d b/gas/testsuite/gas/loongarch/reloc_type.d new file mode 100644 index 00000000000..0a8f77825a0 --- /dev/null +++ b/gas/testsuite/gas/loongarch/reloc_type.d @@ -0,0 +1,3 @@ +#as: +#source: reloc_type.s +#error_output: reloc_type.l diff --git a/gas/testsuite/gas/loongarch/reloc_type.l b/gas/testsuite/gas/loongarch/reloc_type.l new file mode 100644 index 00000000000..5f048ca0a7d --- /dev/null +++ b/gas/testsuite/gas/loongarch/reloc_type.l @@ -0,0 +1,2 @@ +.*Assembler messages: +.*Fatal error: unsupported relocation type name (.*)$ diff --git a/gas/testsuite/gas/loongarch/reloc_type.s b/gas/testsuite/gas/loongarch/reloc_type.s new file mode 100644 index 00000000000..2ce277779db --- /dev/null +++ b/gas/testsuite/gas/loongarch/reloc_type.s @@ -0,0 +1,3 @@ +.L1: + nop + addi.d $a0,$a1,%reloc(x)