Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4561571rdh; Wed, 29 Nov 2023 05:07:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFYIz0e/Kevkc8YnRAQXz3DLFeHrEFro3wnWLStqDts/n2ivrbOwKPqZhbJqnEcYO1jQBue X-Received: by 2002:a05:6a21:186:b0:18d:17c4:a602 with SMTP id le6-20020a056a21018600b0018d17c4a602mr1692415pzb.10.1701263262014; Wed, 29 Nov 2023 05:07:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701263262; cv=none; d=google.com; s=arc-20160816; b=dYS1zvQ7MeL3eWjoE9NTMBq+cEjWChf443RlSCyTdaToySSFSE4iK2tFbbGB7QPQbP G0oo/AyMM857zOyDWt8vwnVnusF6XX6qJXURF0xi/AGWugPOLSrXBqwYWju1rYkR9+oA NT8QeYiEuxpzyea8wJIEaDRgzn2Xn6sN11kZ9Gx24qIK61JZkXkdOo55j5lMnhCH/hLO 8QFiC3z4/C4/DpG2FAL6+wdRDcDl1LSJbLZJzt6JnRffjTF4FzE74YaFjPVxqhn9M4ak R/cAOMvwFrdhUGHdsRFbLn7bVbEaxe+5CROZDdr1WcW3U483miu1Oqq/3T7Al+h1emsm Nwmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=goO01TuZTAMylgq4COXzot8T/ZP8z9p+2aiCmmwp/Dc=; fh=3JsZntdbC0M+r2W9mBgl7JRPxEEj/7A1ld74TBnFi8o=; b=y4Idw2Rep9KYL7HTEHUCA4iiBEt7txNwhaxGVEwOQglCMt3n8cH8w1tMJoh9nPbeEK BIX2rkFXobvFwYs05AHE/D5fdgy2ftlsY+3MilhpILXiguIq/MALoC83NMXs/8OM3Pl0 2NhH4xwARZfCPCCApGmSNqlxANE6HR0O4PYq35IDBEALNW22gzLxGbOyX0nrhge+W5sG 0XjXDvRHtoi0TDRimGYhX9mLDTftLpH8d4fzlXoqQXKJZFl7Q1DiCePwAaAOC8JhPuxS kxjBvfEVtMmmoS2q4IWf9P2wDYSWK3rDuDgRSy2JW4Aor4PUnqmPf8Lx1iLiEr7RRHyd xM4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x7-20020a631707000000b005c5e27a88d7si4121651pgl.567.2023.11.29.05.07.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 05:07:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 033048030BBB; Wed, 29 Nov 2023 05:07:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233805AbjK2NHQ (ORCPT + 99 others); Wed, 29 Nov 2023 08:07:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233252AbjK2NHD (ORCPT ); Wed, 29 Nov 2023 08:07:03 -0500 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 59A5B10E5 for ; Wed, 29 Nov 2023 05:07:09 -0800 (PST) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8Cxrut8N2dldqc9AA--.54172S3; Wed, 29 Nov 2023 21:07:08 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Axzy91N2dlVtNPAA--.45987S9; Wed, 29 Nov 2023 21:07:07 +0800 (CST) From: Tiezhu Yang To: Josh Poimboeuf , Peter Zijlstra , Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v5 7/8] objtool: Check local label in read_unwind_hints() Date: Wed, 29 Nov 2023 21:07:00 +0800 Message-ID: <20231129130701.27744-8-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231129130701.27744-1-yangtiezhu@loongson.cn> References: <20231129130701.27744-1-yangtiezhu@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Axzy91N2dlVtNPAA--.45987S9 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7KFyrZw45KFWrZr15Gr4rJFc_yoW8tFy7pF W3C3y5Wr40qryxZw17KFy8WasxKws7CF17trZrGr4rAry2qr15G3ZIyr1Y9F9rGr15uw4U XFy5Ka4j9w1qywcCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v2 6r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26ryj6F1UMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU8EeHDUUUUU== X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 05:07:40 -0800 (PST) When update the latest upstream gcc and binutils which enables linker relaxation by default, it generates more objtool warnings on LoongArch. We can see that the reloc sym name is local label instead of section in relocation section '.rela.discard.unwind_hints', in this case, the reloc sym type is STT_NOTYPE instead of STT_SECTION. Let us check it to not return -1, then use reloc->sym->offset instead of reloc addend which is 0 to find the corresponding instruction. Here are some detailed info: [fedora@linux 6.7.test]$ gcc --version gcc (GCC) 14.0.0 20231127 (experimental) [fedora@linux 6.7.test]$ as --version GNU assembler (GNU Binutils) 2.41.50.20231127 [fedora@linux 6.7.test]$ readelf -r arch/loongarch/kernel/entry.o | grep -A 3 "rela.discard.unwind_hints" Relocation section '.rela.discard.unwind_hints' at offset 0x420 contains 7 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 001300000063 R_LARCH_32_PCREL 0000000000000000 .Lhere_1 + 0 00000000000c 001400000063 R_LARCH_32_PCREL 00000000000000a8 .Lhere_50 + 0 Signed-off-by: Tiezhu Yang --- tools/objtool/check.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 395fce41fb81..039b8ac53da6 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2240,6 +2240,7 @@ static int read_unwind_hints(struct objtool_file *file) struct unwind_hint *hint; struct instruction *insn; struct reloc *reloc; + unsigned long offset; int i; sec = find_section_by_name(file->elf, ".discard.unwind_hints"); @@ -2267,7 +2268,16 @@ static int read_unwind_hints(struct objtool_file *file) return -1; } - insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc)); + if (reloc->sym->type == STT_SECTION) { + offset = reloc_addend(reloc); + } else if (reloc->sym->local_label) { + offset = reloc->sym->offset; + } else { + WARN("unexpected relocation symbol type in %s", sec->rsec->name); + return -1; + } + + insn = find_insn(file, reloc->sym->sec, offset); if (!insn) { WARN("can't find insn for unwind_hints[%d]", i); return -1; -- 2.42.0