Message ID | 20240130061730.21118-7-yangtiezhu@loongson.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-43985-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1030380dyb; Mon, 29 Jan 2024 22:21:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEDXPgLRZuFy2SYLQpwrS5+WWpC+OsTqpZ3VGl757ZbVHqCL4WvMeu2dM0mM3XCuWs0I4A2 X-Received: by 2002:a17:902:d4d2:b0:1d8:c8e8:cf61 with SMTP id o18-20020a170902d4d200b001d8c8e8cf61mr6806336plg.4.1706595661215; Mon, 29 Jan 2024 22:21:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706595661; cv=pass; d=google.com; s=arc-20160816; b=P3+vmYfrnitcJaO8/igdYG3hupY997GbeJJ1O0j7Or+cWY3kKPGw3uZfE6WVF8M2Ov O3QB30cY64sL6m8gKnT0130CKgXp+qe4rcKDjjRl+6P3IsYG59gm3VmFIyidTmFXF7I1 vFiPYMTycPUWDcvpAlbUNulkWOa8sXRcZZZB5qjemiw9Q5dnNfPGJd0nilsUoVQpMd/s 5LE6OmQz/v1knzogiGpmUjW4nIRJfYYVV8nCUFzv4ANCHvr0X5tOFaycGzh6igQWD0Vh 2MHlqSmuW0LrgHEiuWMARTr5HHaXA4aa1NQpy0YrAXXJJePKzb6FD1oCQ+d/x2osOCv7 HKGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=pI67btWiJDl88O9Po4OqU+UY9Tntdl50iqgY/nrf+Sc=; fh=3JsZntdbC0M+r2W9mBgl7JRPxEEj/7A1ld74TBnFi8o=; b=AErXgm9XwiO6PJlSV4zOZ8iwDbi0c6feCPsUPugYtjE1HgQ6WEJ85FSoOq4F2QFHLV aEle3W74eGJIiKnFtYXAIfGqgnB7ftaNzPhz3AegWqgFX2DfASw25089oqQNy2UYwMut vhU2sMRrU/Qnumm3zSdBXt/5TFUluuRpdik4xPTktf5MZLWVtu9n0AtbY8bftHKb0XWh BpdTbn5nCYbnXAlJzmSZQ/THKJjPDjcznheNLWIIxb7sGucy8ZHd/pTc3p6ThO6j/aTa cGlD16J2ycVxkeKwgSJOPb3e70sFf+jRfd817axCfXCy5T9gvOtLg0xxrS3yF+gecGEG OraQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-43985-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43985-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 20-20020a170902e9d400b001d8d3ac3abesi3565094plk.415.2024.01.29.22.21.01 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 22:21:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43985-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=loongson.cn); spf=pass (google.com: domain of linux-kernel+bounces-43985-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43985-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F2FF2288264 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 06:20:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AAAB63F9EF; Tue, 30 Jan 2024 06:19:10 +0000 (UTC) Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3D86138F82 for <linux-kernel@vger.kernel.org>; Tue, 30 Jan 2024 06:19:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706595549; cv=none; b=og3HlB+79nwW5Y3BciEsgeTAVNIpyo+jf3UaCbpR2rwLBj3Qys7OgTd95kzx2wSxRDei+w5k3mCDgdi9dbW4V2im/rwsh/xjm4p7sBPoiIMxtIvlW1Eeg7PA483ysLN/ZX9lIPGcQHu3nv9CH6jNp62vhwrtZVDxad3UN/BHPbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706595549; c=relaxed/simple; bh=S0dLhOoOjHqllmMRbdI054iuekaMA3L7e5M6fpkR0uA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q7bA84gkUMMY+7MV+UhMfldsa1KYfmffFNmwXKu2PSPhccSKaahQLVNBr28MaOjDP9epk4wOG4B6S52wQVtl/XumR6bAgZ2lOLYeH7SZ9mdFwsUyF9rPeERanamvRXGczTr8nla/8hMJRfL+SHVrbvzGa0iKi6+8OjObkkaW5gE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8DxJ+iBlLhlEzYIAA--.5625S3; Tue, 30 Jan 2024 14:17:37 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxnhN7lLhlYXQnAA--.34034S8; Tue, 30 Jan 2024 14:17:36 +0800 (CST) From: Tiezhu Yang <yangtiezhu@loongson.cn> To: Josh Poimboeuf <jpoimboe@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Huacai Chen <chenhuacai@kernel.org> Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v6 6/8] objtool: Check local label in read_unwind_hints() Date: Tue, 30 Jan 2024 14:17:28 +0800 Message-ID: <20240130061730.21118-7-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240130061730.21118-1-yangtiezhu@loongson.cn> References: <20240130061730.21118-1-yangtiezhu@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8BxnhN7lLhlYXQnAA--.34034S8 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7tFW3ArWxurWUtw4UtFyxZwc_yoW8Kry5pF W3G3y3Wr40qry7Zw17ta48W3sxKws7CF17trZrGrWrAry2qw15K3ZIyr1ayFyqgr4Y9w4U XF9Yga4j9a1qywcCm3ZEXasCq-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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789495251799215521 X-GMAIL-MSGID: 1789495251799215521 |
Series |
Add objtool, orc and livepatching support for LoongArch
|
|
Commit Message
Tiezhu Yang
Jan. 30, 2024, 6:17 a.m. UTC
When update the latest upstream gcc and binutils, it generates some
objtool warnings on LoongArch, like this:
arch/loongarch/kernel/entry.o: warning: objtool: ret_from_fork+0x0: unreachable instruction
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.8.test]$ gcc --version
gcc (GCC) 14.0.1 20240129 (experimental)
[fedora@linux 6.8.test]$ as --version
GNU assembler (GNU Binutils) 2.42.50.20240129
[fedora@linux 6.8.test]$ readelf -r arch/loongarch/kernel/entry.o | grep -A 3 "rela.discard.unwind_hints"
Relocation section '.rela.discard.unwind_hints' at offset 0x3a8 contains 7 entries:
Offset Info Type Sym. Value Sym. Name + Addend
000000000000 000a00000063 R_LARCH_32_PCREL 0000000000000000 .Lhere_1 + 0
00000000000c 000b00000063 R_LARCH_32_PCREL 00000000000000a8 .Lhere_50 + 0
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
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 d0e82c729dd9..1009d144f756 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2227,6 +2227,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"); @@ -2254,7 +2255,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;