Re: [PATCH bpf] bpf/btf: Accept function names that contain dots
From: Eduard Zingerman
Date: Mon Jun 19 2023 - 11:25:12 EST
On Mon, 2023-06-19 at 15:55 +0200, Florent Revest wrote:
> On Mon, Jun 19, 2023 at 1:20 PM Florent Revest <revest@xxxxxxxxxxxx> wrote:
> >
> > On Thu, Jun 15, 2023 at 7:05 PM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
> > >
> > > On Thu, 2023-06-15 at 17:44 +0200, Florent Revest wrote:
> > > > An easy reproducer is:
> > > >
> > > > $ touch pwet.c
> > > >
> > > > $ clang -g -fsanitize=kernel-address -c -o pwet.o pwet.c
> > > > $ llvm-dwarfdump pwet.o | grep module_ctor
> > > >
> > > > $ clang -fno-integrated-as -g -fsanitize=kernel-address -c -o pwet.o pwet.c
> > > > $ llvm-dwarfdump pwet.o | grep module_ctor
> > > > DW_AT_name ("asan.module_ctor")
> > >
> > > Interestingly, I am unable to reproduce it using either
> > > clang version 14.0.0-1ubuntu1 or clang main (bd66f4b1da30).
> >
> > Somehow, I didn't think of trying other clang versions! Thanks, that's
> > a good point Eduard. :)
> >
> > I also can't reproduce it on a 14x build.
> >
> > However, I seem to be able to reproduce it on main:
> >
> > git clone https://github.com/llvm/llvm-project.git
> > mkdir llvm-project/build
> > cd llvm-project/build
> > git checkout bd66f4b1da30
> > cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -G
> > "Unix Makefiles" ../llvm
> > make -j $(nproc)
> >
> > bin/clang -fno-integrated-as -g -fsanitize=kernel-address -c -o
> > ~/pwet.o ~/pwet.c
> > bin/llvm-dwarfdump ~/pwet.o | grep module_ctor
> > # Shows module_ctor
> >
> > I started a bisection, hopefully that will point to something interesting
>
> The bisection pointed to a LLVM patch from Nick in October 2022:
> e3bb359aacdd ("[clang][Toolchains][Gnu] pass -g through to assembler")
>
> Based on the context I have, that commit sounds fair enough. I don't
> think LLVM does anything wrong here, it seems like BPF should be the
> one dealing with dots in function debug info.
That explains why I could not reproduce the issue: I tried with gas 2.38.
Using gas 2.40 I see the same behavior as you.
If one tries to generate assembly file with '-fsanitize':
$ clang -fno-integrated-as -g -fsanitize=kernel-address -S -o pwet.s pwet.c
$ cat pwet.s
.text
.file "pwet.c"
.p2align 4, 0x90 # -- Begin function asan.module_ctor
.type asan.module_ctor,@function
asan.module_ctor: # @asan.module_ctor
.Lfunc_begin0:
...
And then compile it using Gnu assembler:
$ as --64 -o pwet.o pwet.s -g -gdwarf-5
The behavior differs between 2.38 and 2.40, the older version does not
produce debug entry for 'asan.module_ctor', while newer does.