Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1608588rdb; Mon, 2 Oct 2023 15:21:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHwZhLc5Tl8E6mhbTlJC+hgZiPVqJajmHZJmenhjOt4afmvgqoIUbUEsf5izNqfarlwBKZ X-Received: by 2002:a17:90b:3b88:b0:274:116b:8f84 with SMTP id pc8-20020a17090b3b8800b00274116b8f84mr12470481pjb.34.1696285287310; Mon, 02 Oct 2023 15:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696285287; cv=none; d=google.com; s=arc-20160816; b=vlz1ns7St5FUp/ppiarOqv2B94Szw5/dtfs/9by60B8rXbjvKYPRy3TBiWyIpLsxC9 WgaRDY8ug93rIZFtcDeTReU8eMZzyy1Z2w9MzIcZiaGZaOU6z5m+9kzje6m0EqPP/0ry iWl8y/weLz2zisrNK4MxxBAIxKei53p0AriUVf1yoOats3xQG2s14++sWzwcx6psDvvw ckhngcsL++FT/0M3W3o66gwzrUZcWli9A/sHigzKo6SFfDIFSTjmAdsb19HiHB2yGFUp qqVlQC8l5mL46R2A0Z7NWd628AcQcoGe0MqPm2vXyu837s8wAQBkee5mldprCLyZm7Gc W83A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6fBgZzG8H8L+RMO629wwCt+NqtJpm6mxiNYmYMNrioQ=; fh=scilAdHnzANmInNSp/ngESS8QzLXo4k1m5+MMoKuvtc=; b=FnHlEUBcJzVvyAIMSqW/cY4ebLYd0ITxNOWs7AbQOuIEfSZzC5fLsXtRuLhPd9/Mn8 HP1tICKqRP8B5oK9hcvX1wyl/1AEKzAvQPFA5IJw77tZCC49OcVjgXWqa21CJjUjkl/w Z/5VKzt67VrdJ/APQqVZjKrX0rD5gI5k4kLoo0Ah/oZIw4Npb7ZXHOp8wu6Ih6sPa4Db BAubLoXPoFb91MAjbLBE2fMpGEZE1fWDE9obdr3kpWtowywmoiKIStcRt5W79C2nzpXl iuR7H8kA9agrNzweZ6jIrwb6cDxnNFkxOkqp3NUZ7iP4r58Y75fRCflPAq9T0a+rcb4M gEjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wRcHmiNt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id nn4-20020a17090b38c400b00277387bc11dsi8824223pjb.188.2023.10.02.15.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 15:21:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wRcHmiNt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3191980A0E3D; Mon, 2 Oct 2023 10:02:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238397AbjJBRCe (ORCPT + 99 others); Mon, 2 Oct 2023 13:02:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238523AbjJBRCc (ORCPT ); Mon, 2 Oct 2023 13:02:32 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB65B3 for ; Mon, 2 Oct 2023 10:02:29 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3232be274a0so2018686f8f.1 for ; Mon, 02 Oct 2023 10:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696266147; x=1696870947; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6fBgZzG8H8L+RMO629wwCt+NqtJpm6mxiNYmYMNrioQ=; b=wRcHmiNtZkoDucBVwQH7YeY2ld2BHTYYbcx0DukRKcgCeWkZ+G3d4daBtvISZUVOfl FI7SK0p/lL7ipw8MtWYoWO7rJ/GFmvY5PyC2/sDLvT3sLmjNbEbi5cmzLrF3un/bo8Bp 3th1WTBVCI4fVYvAbBuhkjqDWdTJmVyQTXVuEHvJ8SETWgPG6JKxVpfP7O9hXsbWii4d aasBE/o3ssBS0G4YiPgcVGo1xl6aB1IiRkDIR/mmwTv9oOCqhI+cVxSc6rpa5Gfva5ky JBEpwtpW72i0OVLzGdaF1WoL6uKIJxfyQAZb6tn142L0kCMgKxeIaHncczcVq3rZFnR2 gktw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696266147; x=1696870947; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6fBgZzG8H8L+RMO629wwCt+NqtJpm6mxiNYmYMNrioQ=; b=k3NwBaWsvOPHHrWLopTQnGTfrIjEI979evQ17YElQLKSstfvGG8AbV9uSCe921Pqc9 WKiUO24ZTFQn/hy0r9XQutLleVnwe5/wrHxGzoDcV11c+qizWpmWcb8z186jVMDk9jYq hc1nHc96lTI0SnGYLvwdYFAWs5AaXjKo0XVnEddfF3HZCdmuwOtUI5iO2E3Cj2amQ8Qp eqf/RRsNJb+/NNMthC90yf9s0jeQPVlyNjhWksRA3Jo+SR1E4WbDxWdySx+/z94c2Gfl X37zOumWJ/kTGrfnj9jrbOoESRbTDD52p8dN1rA13RsUtRH/pqhU825Qu+I+TSVbx575 53QA== X-Gm-Message-State: AOJu0YwGRTExYDZboZ9KSkk3PU0uaNi+Rq3zJP6NteUsGwm3SBsi0QhB hM0B2ewVB0T1Qcs+4pJ9PQpkVATAny+1CfDtFN6Nnw== X-Received: by 2002:a05:6000:1050:b0:323:1e69:7b4 with SMTP id c16-20020a056000105000b003231e6907b4mr132794wrx.31.1696266147248; Mon, 02 Oct 2023 10:02:27 -0700 (PDT) MIME-Version: 1.0 References: <20231002165750.1661-1-will@kernel.org> <20231002165750.1661-4-will@kernel.org> In-Reply-To: <20231002165750.1661-4-will@kernel.org> From: Nick Desaulniers Date: Mon, 2 Oct 2023 10:02:16 -0700 Message-ID: Subject: Re: [PATCH v5 3/3] scripts/faddr2line: Skip over mapping symbols in output from readelf To: Will Deacon Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Josh Poimboeuf , John Stultz , linux-kbuild@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 10:02:44 -0700 (PDT) On Mon, Oct 2, 2023 at 9:58=E2=80=AFAM Will Deacon wrote: > > 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=3Dy, 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_initcal= l > 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_proce= ss > > 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 mismat= ch (0x260 !=3D 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. > > Cc: Josh Poimboeuf > Cc: John Stultz > Suggested-by: Masahiro Yamada > Signed-off-by: Will Deacon Thanks for the patch! Reviewed-by: Nick Desaulniers > --- > scripts/faddr2line | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/scripts/faddr2line b/scripts/faddr2line > index 6b8206802157..587415a52b6f 100755 > --- a/scripts/faddr2line > +++ b/scripts/faddr2line > @@ -179,6 +179,11 @@ __faddr2line() { > local cur_sym_elf_size=3D${fields[2]} > local cur_sym_name=3D${fields[7]:-} > > + # is_mapping_symbol(cur_sym_name) > + if [[ ${cur_sym_name} =3D~ ^(\.L|L0|\$) ]]; then > + continue > + fi > + > if [[ $cur_sym_addr =3D $sym_addr ]] && > [[ $cur_sym_elf_size =3D $sym_elf_size ]] && > [[ $cur_sym_name =3D $sym_name ]]; then > -- > 2.42.0.582.g8ccd20d70d-goog > --=20 Thanks, ~Nick Desaulniers