Re: [PATCH] vmlinux.lds.h: Force-align ELF notes section to four bytes

From: Josh Poimboeuf
Date: Wed Apr 12 2023 - 12:30:24 EST


On Wed, Apr 12, 2023 at 03:10:14PM +0800, Tianyi Liu wrote:
> On Tue, Apr 11, 2023 at 17:00 , Josh Poimboeuf wrote:
> > On Tue, Feb 14, 2023 at 02:33:02PM +0800, Tianyi Liu wrote:
> > > > LLVM_OBJCOPY=objcopy pahole -J --btf_gen_floats -j
> > > > --skip_encoding_btf_inconsistent_proto --btf_gen_optimized
> > > > .tmp_vmlinux.btf
> > > > btf_encoder__encode: btf__dedup failed!
> > > > Failed to encode BTF
> > > >
> > > > Thanks,
> > > >
> > >
> > > I encountered the same problem when building a new kernel and I found some
> > > reasons for the error.
> > >
> > > In short, enabling CONFIG_X86_KERNEL_IBT will change the order of records in
> > > .notes section. In addition, due to historical problems, the alignment of
> > > records in the .notes section is not unified, which leads to the inability of
> > > gelf_getnote() to read the records after the wrong one.
> >
> > Alexandre, Tianyi, are you still seeing this issue with the latest
> > dwarves? If so can you confirm the below patch fixes it?
> >
>
> Josh, first of all, thank you very much for your help. However, this patch
> doesn't work in my environment. I am using gcc 12.2.1 20230201.
> After compiling, when I use readelf -S to view ELF sections,
> the align of .notes section is still 8:
>
> $ readelf -S .tmp_vmlinux.btf
> [20] .notes NOTE ffffffff8250b570 0170b570
> 0000000000000084 0000000000000000 A 0 0 8

Hm, weird.

> > Apparently the latest dwarves release fixes it on Fedora Rawhide [1],
> > does anybody know if there a specific dwarves and/or libbpf change for
> > this?
> >
>
> It has been fixed in dwarves[1], but it may just be a coincidence.

So just to confirm, the btf__dedup error is gone for you with the latest
dwarves?

--
Josh