Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1347762rdh; Mon, 25 Sep 2023 09:53:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqWcOZa/CBnyy9Ry1r0fV60hZkPODbBILJL6FeQ8//JhmTYnWru4vP5v+AufhFXUxoPL4z X-Received: by 2002:a05:6808:199f:b0:3a8:4d1f:9dd0 with SMTP id bj31-20020a056808199f00b003a84d1f9dd0mr10130870oib.30.1695660837305; Mon, 25 Sep 2023 09:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695660837; cv=none; d=google.com; s=arc-20160816; b=F8jYY4740SAgIasRcPDG+YQ7kIKZh+XdtVZN1P1AIl1WoeMl2s7rWzmw5KkA/s9dP2 kP4joJYi6Z4j1cy2ajNeTGnxNUXX13RbFVDhHQgqJ9QVyejoAhVVbvzc5fe0orySkSQ3 shBMuXFOpbPl+FDaAwDInVaOsivPGS+NhvjxfDazGh9u/LQgQGFRtxfsvGyD4Z3/+3+o LACkOx1T0ambbxAtxwY1nBlcxw+7XK9yjKq+scgM7M93COdtW88mtnRMwEus8IBTaXGK dT3xngpY36jEPGOR3gLtRp2otWBug+5LNsBJ62sl5JOmBZY8KUdy1AQsp8SgvVYzQavE ugdg== 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=hbPpssY94bgjhaqTPf9Rort9iqz1nRw8IqP4a/SvKfc=; fh=wH4y734jVVbpcNjsb7xBMxfTYpuYsWZecRBHRm8pFZU=; b=o1ceOZ3N+D8CNenrwX5BgpwUZ6QuGwlw3f+wJr96IhrbgIm9S7Ln1rqZZAPxH9nKXA cZyyiSoZIcR40IF+9pc1um3+VB6vWGh9Ad73LmdO5YbME/EAvqC4ORDjRauqekMllicp TVQuq8xAq0Ho8woibhjyJ7g+kRU6rHmo2B+UT1wbFEAJf+Zg/pfldj6idDjfWmR96xmv /e+W0PBeK8LiVr8uY/gT3GcNjAvEf1lJOl0w2a6DQWYVreT7gnfnlTMy0CvtLwmiHVqe csdlvqN3gBUyCrt5q3GbyvYolNR9NmxEC4kHeFyXaiImRfMoCriCh6eXucY05NvVI3eX Z6AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KVte+oKF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id by10-20020a056a02058a00b005775156c31esi12880244pgb.92.2023.09.25.09.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 09:53:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KVte+oKF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 42B538068893; Mon, 25 Sep 2023 09:51:22 -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 S229905AbjIYQvG (ORCPT + 99 others); Mon, 25 Sep 2023 12:51:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232469AbjIYQvE (ORCPT ); Mon, 25 Sep 2023 12:51:04 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 725A59F; Mon, 25 Sep 2023 09:50:58 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13BEEC433C7; Mon, 25 Sep 2023 16:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695660658; bh=BpKjGJDg3rOpzfcXTucA8GSwnu0Z6eKivzwSXV+BT6w=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KVte+oKFDGNOMESiUdM0cBhpjHlGl+U0OtqqtF9/s2w6/+Xstf26AEuEgTF3sYeol 6Eo4bBuVURoLvTn2qU2ebhTeGIQ1VeKwcONqD+WKazRg0tQAPT0I893xJp1HL5cQvs e4NcIQjucRUOb9H1LyG/eTWONuAmDPldcSEqRb4hniwobafsJn33XUXjWyxkPcKpXY 1JNjHeeGYHTy0ORhD/ykNy/vcHkHInOBBoxdDYccDAnd6+K0Cv3J39A0P57wa1bkYu cMICcWIPXRfzi7v98cr5Uiqv2mBrzjXc+Lsc1lL9p1es05jUXRv0s1FnoPfPhJzKaw ZhoqD6laX1JBA== Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6c4b7e90e99so3399544a34.0; Mon, 25 Sep 2023 09:50:58 -0700 (PDT) X-Gm-Message-State: AOJu0YzO3jF9OQK9HHrlACR5hikmM1cGHVQD7rGv/cP2OtraogefhGHy 8sYUAr3N8SQoudupct8taNMsXIpl1YK9f27MYvg= X-Received: by 2002:a05:6870:5b8b:b0:1d5:4fb0:105 with SMTP id em11-20020a0568705b8b00b001d54fb00105mr8930862oab.20.1695660657483; Mon, 25 Sep 2023 09:50:57 -0700 (PDT) MIME-Version: 1.0 References: <20230914131225.13415-1-will@kernel.org> <20230914131225.13415-4-will@kernel.org> In-Reply-To: <20230914131225.13415-4-will@kernel.org> From: Masahiro Yamada Date: Tue, 26 Sep 2023 01:50:20 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 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, Nathan Chancellor , Nick Desaulniers , 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=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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, 25 Sep 2023 09:51:22 -0700 (PDT) On Thu, Sep 14, 2023 at 10:12=E2=80=AFPM Will Deacon wrot= e: > > 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 > --- > scripts/faddr2line | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/scripts/faddr2line b/scripts/faddr2line > index 6b8206802157..20d9b3d37843 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)|(\$[adtx]= (\.|$))) ]]; then > + continue > + fi > + Too many parentheses. The latest include/linux/module_symbol.h looks like this. static inline int is_mapping_symbol(const char *str) { if (str[0] =3D=3D '.' && str[1] =3D=3D 'L') return true; if (str[0] =3D=3D 'L' && str[1] =3D=3D '0') return true; return str[0] =3D=3D '$'; } Does this work? 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.283.g2d96d420d3-goog > --=20 Best Regards Masahiro Yamada