Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCF7D2CA8 for ; Sat, 29 Jan 2022 00:55:53 +0000 (UTC) Received: by mail-qv1-f42.google.com with SMTP id k4so7450593qvt.6 for ; Fri, 28 Jan 2022 16:55:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/Babq3FplbrE6ia+3+gxSJA2pG5zbSBPMzCgi+sKFdk=; b=nV6ULo6Y+G2Wg4meFRNeDHaMRxniC97fbDBmxkPo51IFlCGPvTZ6twCsybA/0BL4Mo XmUxsMw6AnXwqvl5vtXkHc9lWAYPd7mSCcmSaz5Pryf7dlb1bAtUd6KBE4kYXzRvg9D+ RGAtJhCPbKqKxu5PS9clTuPqVRnYPuVDJh3kuhGpJ75SJ6Z93UCI8iQDmlBcUxPQUrDp 9Yu1j6RCJmWiEjfWisWNyCf17o2BbMzbeM8h9wxt/kx+ZPVp5U4eHmQZL+4pozUZoUFr c7lg5z1VGFQc1iKVOioG1d7Zr542uaHe+GDTZaSLV1E29MZCzvIx3oH73bg1cDSzn1J/ XMOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/Babq3FplbrE6ia+3+gxSJA2pG5zbSBPMzCgi+sKFdk=; b=uttB7ArMFpqJsn9JokWmxZY8bT2yx4G/ObJXqEq08yWVKRnvGSZ3WJwI4uywWp+SVP oHM5UrmkXBRiFrLHRx0gY+zXsOQn4YNQ504EQ3LlcRF39ZJSvGhTHbGC5fK4pdc36T/o b2GhEg2Ki4wSl2sHQE6v2VbsbANHm/T1HjMqxn5/eDwLCI0+9Kzj0sfq55gOuLKxTZ3p hVU3lI9adw8gwrTnXY3lgxkMvVltl3JHlPAv3B2dQdKpa0DLiIhCPpK+KEScoON0EHo9 Z0Zd9wAEVRm1LpSSOgOTZzXcuC10/EEfzJnBOtN+6EGDlmLQwPFS3+cWRmjSIdM8axgo LV9g== X-Gm-Message-State: AOAM533OLyvBLBWZo7V/Zq3+rZQ2ondyVVt1Wc7RQa2v/oTWHoHaQnPF mJvXBQdv/ROfXnNUCCNsQvM= X-Google-Smtp-Source: ABdhPJxrHmBRRiruuUDQEiaw1eOLyEM0h4Jbo1PM/wLrOjvuiUbn5IVtzXefYh10Af7lQDHXfunCLA== X-Received: by 2002:a05:6214:d6e:: with SMTP id 14mr9371496qvs.32.1643417752838; Fri, 28 Jan 2022 16:55:52 -0800 (PST) Received: from mail.google.com ([207.246.89.135]) by smtp.gmail.com with ESMTPSA id z19sm1387496qtj.77.2022.01.28.16.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 16:55:52 -0800 (PST) Date: Sat, 29 Jan 2022 08:55:46 +0800 From: Changbin Du To: Nick Desaulniers Cc: Changbin Du , Masahiro Yamada , Nathan Chancellor , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-riscv@lists.infradead.org Subject: Re: [PATCH] kallsyms: ignore local block labels generated by compiler Message-ID: <20220129005546.3k4xblksuo5lnr3f@mail.google.com> References: <20220128105746.2459-1-changbin.du@gmail.com> <20220128152147.mwjkf45z72qwdikq@mail.google.com> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Fri, Jan 28, 2022 at 10:59:55AM -0800, Nick Desaulniers wrote: > On Fri, Jan 28, 2022 at 7:21 AM Changbin Du wrote: > > > > On Fri, Jan 28, 2022 at 06:57:46PM +0800, Changbin Du wrote: > > > The llvm compiler can generate lots of local block labels and they might > > > overlap with C defined symbols. So let's ignore such local labels. > > > > > > Before this change, dumpstack shows a local symbol for epc: > > > [ 0.040341][ T0] Hardware name: riscv-virtio,qemu (DT) > > > [ 0.040376][ T0] epc : .LBB6_14+0x22/0x6a > > > [ 0.040452][ T0] ra : restore_all+0x12/0x6e > > > > > > After this change, the C defined symbol is shown which is expected: > > > [ 0.035795][ T0] Hardware name: riscv-virtio,qemu (DT) > > > [ 0.036332][ T0] epc : trace_hardirqs_on+0x54/0x13c > > > [ 0.036567][ T0] ra : restore_all+0x12/0x6e > > > > > > Signed-off-by: Changbin Du > > > --- > > > scripts/kallsyms.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c > > > index 54ad86d13784..5f4be9d72a32 100644 > > > --- a/scripts/kallsyms.c > > > +++ b/scripts/kallsyms.c > > > @@ -108,6 +108,7 @@ static bool is_ignored_symbol(const char *name, char type) > > > /* Symbol names that begin with the following are ignored.*/ > > > static const char * const ignored_prefixes[] = { > > > "$", /* local symbols for ARM, MIPS, etc. */ > > > + ".LBB", /* local block labels generated by compiler */ > > I aslo found many symbols like '.Ltmpxxx', '.L__unnamed_xx'. So should we just > > ignore all symbols prefixed by '.L'? > > .L prefixes are "local labels" meaning they don't get an entry in the > symbol table. The trade off is that there is no such convention > between compiler generated local label naming conventions, vs hand > written ones. If we omit all local labels, then it might be > surprising that a handwritten local label disappeared from this list. > I think though that we should omit all local labels, and if someone > needs a label to appear in their dumpstack, then they should simply > drop the .L prefix on their handwritten label. > Agree. I checked vmlinux for riscv and x86, seeing no handwritten function labels prefixed by '.L'. (just some data definition symbols). It should be safte to simply ignore all these symbols. > > > > > ".LASANPC", /* s390 kasan local symbols */ > > > "__crc_", /* modversions */ > > > "__efistub_", /* arm64 EFI stub namespace */ > > > -- > > > 2.32.0 > > > > > > > -- > > Cheers, > > Changbin Du > > > > -- > Thanks, > ~Nick Desaulniers -- Cheers, Changbin Du