All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kallsyms: ignore local block labels generated by compiler
@ 2022-01-28 10:57 ` Changbin Du
  0 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-01-28 10:57 UTC (permalink / raw)
  To: Nathan Chancellor, Masahiro Yamada, Nick Desaulniers
  Cc: linux-kernel, llvm, linux-riscv, Changbin Du

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 <changbin.du@gmail.com>
---
 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 */
 		".LASANPC",		/* s390 kasan local symbols */
 		"__crc_",		/* modversions */
 		"__efistub_",		/* arm64 EFI stub namespace */
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] kallsyms: ignore local block labels generated by compiler
@ 2022-01-28 10:57 ` Changbin Du
  0 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-01-28 10:57 UTC (permalink / raw)
  To: Nathan Chancellor, Masahiro Yamada, Nick Desaulniers
  Cc: linux-kernel, llvm, linux-riscv, Changbin Du

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 <changbin.du@gmail.com>
---
 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 */
 		".LASANPC",		/* s390 kasan local symbols */
 		"__crc_",		/* modversions */
 		"__efistub_",		/* arm64 EFI stub namespace */
-- 
2.32.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] kallsyms: ignore local block labels generated by compiler
  2022-01-28 10:57 ` Changbin Du
@ 2022-01-28 15:21   ` Changbin Du
  -1 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-01-28 15:21 UTC (permalink / raw)
  To: Changbin Du
  Cc: Nathan Chancellor, Masahiro Yamada, Nick Desaulniers,
	linux-kernel, llvm, linux-riscv

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 <changbin.du@gmail.com>
> ---
>  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'?

>  		".LASANPC",		/* s390 kasan local symbols */
>  		"__crc_",		/* modversions */
>  		"__efistub_",		/* arm64 EFI stub namespace */
> -- 
> 2.32.0
> 

-- 
Cheers,
Changbin Du

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] kallsyms: ignore local block labels generated by compiler
@ 2022-01-28 15:21   ` Changbin Du
  0 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-01-28 15:21 UTC (permalink / raw)
  To: Changbin Du
  Cc: Nathan Chancellor, Masahiro Yamada, Nick Desaulniers,
	linux-kernel, llvm, linux-riscv

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 <changbin.du@gmail.com>
> ---
>  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'?

>  		".LASANPC",		/* s390 kasan local symbols */
>  		"__crc_",		/* modversions */
>  		"__efistub_",		/* arm64 EFI stub namespace */
> -- 
> 2.32.0
> 

-- 
Cheers,
Changbin Du

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] kallsyms: ignore local block labels generated by compiler
  2022-01-28 15:21   ` Changbin Du
@ 2022-01-28 18:59     ` Nick Desaulniers
  -1 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2022-01-28 18:59 UTC (permalink / raw)
  To: Changbin Du, Masahiro Yamada
  Cc: Nathan Chancellor, linux-kernel, llvm, linux-riscv

On Fri, Jan 28, 2022 at 7:21 AM Changbin Du <changbin.du@gmail.com> 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 <changbin.du@gmail.com>
> > ---
> >  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.

>
> >               ".LASANPC",             /* s390 kasan local symbols */
> >               "__crc_",               /* modversions */
> >               "__efistub_",           /* arm64 EFI stub namespace */
> > --
> > 2.32.0
> >
>
> --
> Cheers,
> Changbin Du



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] kallsyms: ignore local block labels generated by compiler
@ 2022-01-28 18:59     ` Nick Desaulniers
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2022-01-28 18:59 UTC (permalink / raw)
  To: Changbin Du, Masahiro Yamada
  Cc: Nathan Chancellor, linux-kernel, llvm, linux-riscv

On Fri, Jan 28, 2022 at 7:21 AM Changbin Du <changbin.du@gmail.com> 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 <changbin.du@gmail.com>
> > ---
> >  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.

>
> >               ".LASANPC",             /* s390 kasan local symbols */
> >               "__crc_",               /* modversions */
> >               "__efistub_",           /* arm64 EFI stub namespace */
> > --
> > 2.32.0
> >
>
> --
> Cheers,
> Changbin Du



-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] kallsyms: ignore local block labels generated by compiler
  2022-01-28 18:59     ` Nick Desaulniers
@ 2022-01-29  0:55       ` Changbin Du
  -1 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-01-29  0:55 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Changbin Du, Masahiro Yamada, Nathan Chancellor, linux-kernel,
	llvm, linux-riscv

On Fri, Jan 28, 2022 at 10:59:55AM -0800, Nick Desaulniers wrote:
> On Fri, Jan 28, 2022 at 7:21 AM Changbin Du <changbin.du@gmail.com> 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 <changbin.du@gmail.com>
> > > ---
> > >  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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] kallsyms: ignore local block labels generated by compiler
@ 2022-01-29  0:55       ` Changbin Du
  0 siblings, 0 replies; 8+ messages in thread
From: Changbin Du @ 2022-01-29  0:55 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Changbin Du, Masahiro Yamada, Nathan Chancellor, linux-kernel,
	llvm, linux-riscv

On Fri, Jan 28, 2022 at 10:59:55AM -0800, Nick Desaulniers wrote:
> On Fri, Jan 28, 2022 at 7:21 AM Changbin Du <changbin.du@gmail.com> 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 <changbin.du@gmail.com>
> > > ---
> > >  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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-01-29  0:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-28 10:57 [PATCH] kallsyms: ignore local block labels generated by compiler Changbin Du
2022-01-28 10:57 ` Changbin Du
2022-01-28 15:21 ` Changbin Du
2022-01-28 15:21   ` Changbin Du
2022-01-28 18:59   ` Nick Desaulniers
2022-01-28 18:59     ` Nick Desaulniers
2022-01-29  0:55     ` Changbin Du
2022-01-29  0:55       ` Changbin Du

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.