Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3476785rwo; Mon, 24 Jul 2023 11:35:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlE/OdfzrY9qfJS84DRL0Hg73+An1QkxR5F05d9wvs96TsmMvLQ34grJZ9NV5LQV+phMYbkQ X-Received: by 2002:a17:907:784f:b0:99b:445d:45d3 with SMTP id lb15-20020a170907784f00b0099b445d45d3mr9691870ejc.67.1690223704957; Mon, 24 Jul 2023 11:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690223704; cv=none; d=google.com; s=arc-20160816; b=E2Ze/QDn7TA+QIJCH6Y9iL693irVb0l9pgAmGNsj1Cah5fTwqFP13Qx52ImrI2Pfu9 9I4twkfaqKYzurCMtpE9djAiq1KZmAYcM6vDEVr1EtGCXyWMNPDB9kVPmgRBQSQOumGK h3k4VMooNl5pfB2Ckux9CNKj1n9Gciw4uvTSBKuweTKssBis+EvARG3pXsR+NgixeWxx mOYE57eM8RrHPqOLNZmMMMJMQaldUnztyGFJQgeQxwjx46THCGrPtjjgRwIdT0jWKBgr uBePwXCC2N/AQUEQdh2PaeJKf2fx09r/DWFShLtBGHx3nK66knz8L+ZmZbGRJxh5M5Kq Rqmg== 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 :dkim-signature; bh=zrssEvxS+ld6v9SO/J8qoiZubJbMVHvX4b7POb87VbE=; fh=FSu9atl9DWIe1aov4mIRT4R72uuRBdCpyNQUle5ZVW8=; b=By06z359NagVQLyEuJruJ9XZfElXZj3/OW5NMhOmnr0WCeGtbo5TbYx76eadAtwL25 c75Fg19yt1p7Hd5x3LCpgSxsE7H8hSQCbW7+PsP9MI6QBXiSaBpMdl1GrjW5p6jcmsa0 jzgEjT7AzHrDI6Oay+ZifEqhgH0q0+OngRlg2nGT1PSICfnUppRxzCCU1fo4McIOTJOf i8kEeIscfpgIHRYhx2S0IeLaszs1ryZi3yiTh5W9OY531MMo+IA6mv1GhUEkT/kH0w98 QEQRzjPrKuXv6vi6CXshjfCmgWQRg8GCo7XWqowMggI6lgukPlKMn4jICEHglrOhE/s9 k75Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nT369RIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay20-20020a170906d29400b00988635d8c25si6408240ejb.603.2023.07.24.11.34.40; Mon, 24 Jul 2023 11:35:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nT369RIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231888AbjGXRt4 (ORCPT + 99 others); Mon, 24 Jul 2023 13:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231880AbjGXRta (ORCPT ); Mon, 24 Jul 2023 13:49:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 732DF4686 for ; Mon, 24 Jul 2023 10:46:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 529366132A for ; Mon, 24 Jul 2023 17:45:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 808FAC433C8; Mon, 24 Jul 2023 17:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690220723; bh=F0EIIGsmfIB+Y7QbLwduV6cHaLIhokS7WljeV8e+XkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nT369RIaytZKoua0dAoPD1E3ysYvjzoA7UIVRcXqwLuM2p29Xx48/D7VyYYKhumdy k7BNjmgz3bmm1pcPYlKPB8dnI1+ADa9nAw2A22dv8TrStw6hi2GMp7LjhPHQ7xKd77 wlWeQgvB+Cwv35BEJXNdXF6loAJBFGtCQRNHM1oVqyHn6b0cQZOfea5DX8jsJnJkG1 QH18n5Fpu3ILSCclHpkqgMTAeuIwTLVK0/4DLxverZTT9Rmaf3yLLvCrdsq2Xd9/Uc gwbEnL7i4xzLxdznfyc70BcTJiwRgJB6s6AYTtcnvDxIgjU88HFv74nYB5NbS/7pi7 7SiuRtg09vjLQ== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, Will Deacon , Josh Poimboeuf , John Stultz Subject: [PATCH 1/2] scripts/faddr2line: Ignore non-function symbols in readelf output Date: Mon, 24 Jul 2023 18:45:16 +0100 Message-Id: <20230724174517.15736-2-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230724174517.15736-1-will@kernel.org> References: <20230724174517.15736-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Non-function 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 entries from readelf that are not "FUNC" type, so that the size of a symbol is calculated as a delta to the next function address. Cc: Josh Poimboeuf Cc: John Stultz Signed-off-by: Will Deacon --- scripts/faddr2line | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/faddr2line b/scripts/faddr2line index 0e73aca4f908..60368a1cdaed 100755 --- a/scripts/faddr2line +++ b/scripts/faddr2line @@ -179,7 +179,7 @@ __faddr2line() { found=2 break fi - done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v sec=$sym_sec '$7 == sec' | sort --key=2) + done < <(${READELF} --symbols --wide $objfile | sed 's/\[.*\]//' | ${AWK} -v sec=$sym_sec '$4 == "FUNC" && $7 == sec' | sort --key=2) if [[ $found = 0 ]]; then warn "can't find symbol: sym_name: $sym_name sym_sec: $sym_sec sym_addr: $sym_addr sym_elf_size: $sym_elf_size" -- 2.41.0.487.g6d72f3e995-goog