From patchwork Tue Oct 24 08:52:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 157306 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1805519vqx; Tue, 24 Oct 2023 01:53:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFT9tgOFYz7GYt05pjGgnVQ4OW+8i5EYZ89Fu9tni9EOVrue9tc2nlFAm1i86+mZD1sIwIJ X-Received: by 2002:a05:6a00:1a4e:b0:693:4108:1eb7 with SMTP id h14-20020a056a001a4e00b0069341081eb7mr9508542pfv.30.1698137600950; Tue, 24 Oct 2023 01:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698137600; cv=none; d=google.com; s=arc-20160816; b=i0hZObnWGeOiI7W4+ahTZIT49dPymwjcb81Ox5v8PxX8syt/mHY8nGnzwhQSLp5sVZ rmbyi8avEAEj8qHFWXmlg99frJb2JwQNEpycNI+hTy3xkb7SN6KJfkU8zEu0nRFoofGl Xx71Clln5aueDcclCQSwbB/Q4QilATgqC0F9awDlGaTpKIZ0TLJ1PiyVmEwe+wOJgTii ApvGk+i5TL6io1zYviHsj+TM4AvRzidYwC9YpU8yRZ3Ya5q3FtNCbq54ssJCJWRmol3S TFvgR8VStLAix0FxHLoESMIjdLgYf5WMVFLPPYYmqO8X4tIeCyQ+z+V6j5cFeNdFR2t5 fMjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=9keY+q4ayzhYfj1Sywl/i+fSmvZAiGDKGIdRrjeEPao=; fh=U6xOoS4yrKwokS92UnWWBZ6Bz5Mf5FIxoc6GYbAL22U=; b=bWLoHDB5i108GcR74NG0M1Z8R+8CCg5cLki1gpO+0CJuhCHSt03s+8f48PAqjHx7dc MCcbvH7ZYO3xGQs2zKI2yzBMNDp9yzOgMZuNR3O0rLj0Klf66NFML/WK9VHHR11Oljwg RprlBDzUzJ6uEG6arE1K3HTKka8stuwxZcvJvazbtjzeFmZ7cM9zLgljgHZS9CgLpHir o6VP03VApR9LSO0dLTfHnnJEJ7LIjs1kKCFXHos4uxx9BYbJ76XHNUkwkUR50V5ZASwQ fObzSH6vNZPS/tQwt7ArYZnhP8QIuKIdGy2JJrJyeC8WxkcyYYtRzld5YSlmp9TEKvvY 6dFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Vzmc0dVO; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id w65-20020a636244000000b0057828b85afdsi7818371pgb.795.2023.10.24.01.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 01:53:20 -0700 (PDT) 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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Vzmc0dVO; dkim=neutral (no key) header.i=@linutronix.de; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7B6698030B49; Tue, 24 Oct 2023 01:53:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234019AbjJXIxM (ORCPT + 26 others); Tue, 24 Oct 2023 04:53:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbjJXIxB (ORCPT ); Tue, 24 Oct 2023 04:53:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 854FC1712; Tue, 24 Oct 2023 01:52:45 -0700 (PDT) Date: Tue, 24 Oct 2023 08:52:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1698137563; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9keY+q4ayzhYfj1Sywl/i+fSmvZAiGDKGIdRrjeEPao=; b=Vzmc0dVOKxkFjyP23HLc9Vsg5ONrlxIVzkD6KBjnmq6umrqmIbWZsLNQzH2UhqhublWUl+ JDI79T1ZeB78YndUO6V723oU71nMLIUF+tUACpS8BwjFVrQaj2GVXZIhcLdoTuMC3rNQYB o98E+HXlr2o0L53NmDTOqqZA2R5iN/ERBtw4mIfdLU5e18ubNEP7Eg0GF0ltTmpPbZNbCh 7DHhKOyGPILn7K1GuGlRLc06MTBoN9GZ2cm4FUXOWG3q+Wc7qwZkoDZBVpNJ6pAg7AvbWv qGGs3O+1clAwI+CnXsWZovzlr5f2dM+1alFfQq8iHd5+AFlSFLvt77i3//ahZw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1698137563; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9keY+q4ayzhYfj1Sywl/i+fSmvZAiGDKGIdRrjeEPao=; b=Uv+/y9J7Kixz9OlL6VLhiBIKuu2qHbyaimq0lgu2+GEItQrzNIJn5g5N4KymyqbDKS2/Iu MKQD6jffr2swE6Aw== From: "tip-bot2 for Will Deacon" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] scripts/faddr2line: Skip over mapping symbols in output from readelf Cc: Masahiro Yamada , Will Deacon , Nick Desaulniers , Josh Poimboeuf , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231002165750.1661-4-will@kernel.org> References: <20231002165750.1661-4-will@kernel.org> MIME-Version: 1.0 Message-ID: <169813756305.3135.18196140276976513319.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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]); Tue, 24 Oct 2023 01:53:19 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778664629892521173 X-GMAIL-MSGID: 1780626332705264139 The following commit has been merged into the objtool/core branch of tip: Commit-ID: 60fd39af33d3f63c4c94bd06784ebdf0d883f5c9 Gitweb: https://git.kernel.org/tip/60fd39af33d3f63c4c94bd06784ebdf0d883f5c9 Author: Will Deacon AuthorDate: Mon, 02 Oct 2023 17:57:49 +01:00 Committer: Josh Poimboeuf CommitterDate: Mon, 23 Oct 2023 08:36:46 -07:00 scripts/faddr2line: Skip over mapping symbols in output from readelf Mapping symbols emitted in the readelf output can confuse the 'faddr2line' symbol size calculation, resulting in the erroneous rejection of valid offsets. This is especially prevalent when building an arm64 kernel with CONFIG_CFI_CLANG=y, where most functions are prefixed with a 32-bit data value in a '$d.n' section. For example: 447538: ffff800080014b80 548 FUNC GLOBAL DEFAULT 2 do_one_initcall 104: ffff800080014c74 0 NOTYPE LOCAL DEFAULT 2 $x.73 106: ffff800080014d30 0 NOTYPE LOCAL DEFAULT 2 $x.75 111: ffff800080014da4 0 NOTYPE LOCAL DEFAULT 2 $d.78 112: ffff800080014da8 0 NOTYPE LOCAL DEFAULT 2 $x.79 36: ffff800080014de0 200 FUNC LOCAL DEFAULT 2 run_init_process Adding a warning to do_one_initcall() results in: | WARNING: CPU: 0 PID: 1 at init/main.c:1236 do_one_initcall+0xf4/0x260 Which 'faddr2line' refuses to accept: $ ./scripts/faddr2line vmlinux do_one_initcall+0xf4/0x260 skipping do_one_initcall address at 0xffff800080014c74 due to size mismatch (0x260 != 0x224) no match for do_one_initcall+0xf4/0x260 Filter out these entries from readelf using a shell reimplementation of is_mapping_symbol(), so that the size of a symbol is calculated as a delta to the next symbol present in ksymtab. Suggested-by: Masahiro Yamada Signed-off-by: Will Deacon Reviewed-by: Nick Desaulniers Link: https://lore.kernel.org/r/20231002165750.1661-4-will@kernel.org Signed-off-by: Josh Poimboeuf --- scripts/faddr2line | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/faddr2line b/scripts/faddr2line index 6b82068..587415a 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -179,6 +179,11 @@ __faddr2line() { local cur_sym_elf_size=${fields[2]} local cur_sym_name=${fields[7]:-} + # is_mapping_symbol(cur_sym_name) + if [[ ${cur_sym_name} =~ ^(\.L|L0|\$) ]]; then + continue + fi + if [[ $cur_sym_addr = $sym_addr ]] && [[ $cur_sym_elf_size = $sym_elf_size ]] && [[ $cur_sym_name = $sym_name ]]; then