Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1072349rda; Mon, 23 Oct 2023 01:12:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGMXz+09EJlWnv01FdClx+C8UvwmaRdRSw0OwCuj4So6e3k54+3rKT/MjxHbQbhZT8k79Pf X-Received: by 2002:a17:902:db0c:b0:1ca:7909:6ee6 with SMTP id m12-20020a170902db0c00b001ca79096ee6mr5831205plx.61.1698048772616; Mon, 23 Oct 2023 01:12:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698048772; cv=none; d=google.com; s=arc-20160816; b=Stvki0pS2dIdjk0CFulfiO4V3YBU7u1k0ShiDcpkaMAubj++qk64sCmZw3gACoYE73 Sb//+LQXROWx3EXnboBroE6XZfeuukyZmn36lu22pUHldg7YObk6G/UeWXjBlrN1Jgkx A8TxdfdcWOllBRTefduACTLa0BWP1P29VAfQgGf104LMh/SXYXlC/vQ1PXTCCpSYOnwV 2PgGdLxJxL/eC2UyJPdtD751IrkKcw19HEm5y01JzhFP73XqYRD6nMaQAIyjTOHPK8n0 1C21nR/htXiMDg+bytQgWlFxhAn9TolVDTzeXxJzVHbxnvUeucsScWKTIzIZZnW/Nalf PQOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=P1cG9aMURBN8SfxjY6tjFLK8EyAlHalp6i8ZSJmt2lM=; fh=3j/20F2LKXrdRGvNzW5us/B/H+CmIg1AkSVATQRCgiM=; b=iPdEgfOLAbVde+7z0toW2rbMth8uCp/pqBAEEREXc5ufPa+5ynhOJW2ag3pt5xJCVK 0AIKjPNmr9bgO+jqfQr3EHWo7QfGgzg+EATYjWsWacwVProVoSNt9aa1c7YCrZWCc3V3 5g5KN5McElV/5cJgrl4LCn0EFzwXqaaiNr+Fl+QkV2lwwRrRZUKMa/SpI5nR9ku4V9Ko 8amxCV5tsq/afmJYFcpW+VFcE/yYk5Te1Y3lO20PoFklfXBVQ9To1O0+AwP1Bftwnt9p fOkE3RWI940t+4RIixCoRMhoVKRJYcAZMXXFxFmP4cCxkgeVu+9cmRnE+mKjZZwpKqo9 h1kQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p2-20020a170902e74200b001b8b4330585si6391551plf.510.2023.10.23.01.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 01:12:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id BFCA18095812; Mon, 23 Oct 2023 01:12:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbjJWIMF (ORCPT + 99 others); Mon, 23 Oct 2023 04:12:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbjJWILp (ORCPT ); Mon, 23 Oct 2023 04:11:45 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BECD4B3 for ; Mon, 23 Oct 2023 01:11:42 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxEvC7KjZlfeYzAA--.34662S3; Mon, 23 Oct 2023 16:11:39 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxG9y0KjZlQRAvAA--.34174S9; Mon, 23 Oct 2023 16:11:38 +0800 (CST) From: Tiezhu Yang To: Josh Poimboeuf , Peter Zijlstra , Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH v4 7/8] objtool: Check local label in read_unwind_hints() Date: Mon, 23 Oct 2023 16:11:30 +0800 Message-Id: <1698048691-19521-8-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1698048691-19521-1-git-send-email-yangtiezhu@loongson.cn> References: <1698048691-19521-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8AxG9y0KjZlQRAvAA--.34174S9 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7KFyrZw45KFWrCw4xWF47ZFc_yoW8uw13pF W3G3yYgr40qryxuw17Ga48WasxKws7uF17trZrGr4rAr9Fvr15KasIyr1F9asrWr15uw4U Zas5Ka4j9a1qvabCm3ZEXasCq-sJn29KB7ZKAUJUUUU7529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUBab4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1a6r1DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Cr0_Gr1UM28EF7xvwVC2z280aVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAF wI0_Gr1j6F4UJwAaw2AFwI0_Jrv_JF1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2 xF0cIa020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_ Wrv_ZF1lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x 0EwIxGrwCY1x0262kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwCFI7km07C267AKxVWUXVWUAwC20s026c02F40E14v26r1j6r18MI8I3I0E74 80Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0 I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04 k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jF4EiUUUUU= X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Mon, 23 Oct 2023 01:12:47 -0700 (PDT) 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.6.test]$ gcc --version gcc (GCC) 14.0.0 20231009 (experimental) [fedora@linux 6.6.test]$ as --version GNU assembler (GNU Binutils) 2.41.50.20231009 [fedora@linux 6.6.test]$ readelf -r arch/loongarch/kernel/entry.o | grep -A 2 "rela.discard.unwind_hints" Relocation section '.rela.discard.unwind_hints' at offset 0x458 contains 7 entries: Offset Info Type Sym. Value Sym. Name + Addend 000000000000 000800000063 R_LARCH_32_PCREL 000000000000001c .Lhere_1 + 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 8ddf02f..c2ebb96 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2224,6 +2224,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"); @@ -2251,7 +2252,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.1.0