* [PATCH bpf-next] libbpf: Silence newly-added and unused sections @ 2025-09-20 15:35 Yonghong Song 2025-09-20 15:56 ` Alexei Starovoitov 2025-09-21 0:30 ` Eduard Zingerman 0 siblings, 2 replies; 8+ messages in thread From: Yonghong Song @ 2025-09-20 15:35 UTC (permalink / raw) To: bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau With latest llvm22, when building bpf selftest, I got the following info emitted by libbpf: ... libbpf: elf: skipping unrecognized data section(14) .comment libbpf: elf: skipping section(15) .note.GNU-stack (size 0) ... The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. [Nr] Name Type Address Off Size ES Flg Lk Inf Al ... [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 ... Adding the above two sections in elf section ignore list can avoid the above info dump during selftest build. [1] https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 Signed-off-by: Yonghong Song <yonghong.song@linux.dev> --- tools/lib/bpf/libbpf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 5161c2b39875..34aed7904039 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -3788,6 +3788,14 @@ static bool ignore_elf_section(Elf64_Shdr *hdr, const char *name) if (is_sec_name_dwarf(name)) return true; + /* .comment section */ + if (strcmp(name, ".comment") == 0) + return true; + + /* .note.GNU-stack section */ + if (strcmp(name, ".note.GNU-stack") == 0) + return true; + if (str_has_pfx(name, ".rel")) { name += sizeof(".rel") - 1; /* DWARF section relocations */ -- 2.47.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH bpf-next] libbpf: Silence newly-added and unused sections 2025-09-20 15:35 [PATCH bpf-next] libbpf: Silence newly-added and unused sections Yonghong Song @ 2025-09-20 15:56 ` Alexei Starovoitov 2025-09-20 16:18 ` Yonghong Song 2025-09-20 18:50 ` Yonghong Song 2025-09-21 0:30 ` Eduard Zingerman 1 sibling, 2 replies; 8+ messages in thread From: Alexei Starovoitov @ 2025-09-20 15:56 UTC (permalink / raw) To: Yonghong Song Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, Kernel Team, Martin KaFai Lau On Sat, Sep 20, 2025 at 8:35 AM Yonghong Song <yonghong.song@linux.dev> wrote: > > With latest llvm22, when building bpf selftest, I got the following info > emitted by libbpf: > ... > libbpf: elf: skipping unrecognized data section(14) .comment > libbpf: elf: skipping section(15) .note.GNU-stack (size 0) > ... > > The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo > inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class > MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. > [Nr] Name Type Address Off Size ES Flg Lk Inf Al > ... > [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 > [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 > ... > > Adding the above two sections in elf section ignore list can avoid the > above info dump during selftest build. > > [1] https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 Can we revert this instead? Why do we need these sections if we're not doing anything with them? > Signed-off-by: Yonghong Song <yonghong.song@linux.dev> > --- > tools/lib/bpf/libbpf.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 5161c2b39875..34aed7904039 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -3788,6 +3788,14 @@ static bool ignore_elf_section(Elf64_Shdr *hdr, const char *name) > if (is_sec_name_dwarf(name)) > return true; > > + /* .comment section */ > + if (strcmp(name, ".comment") == 0) > + return true; > + > + /* .note.GNU-stack section */ > + if (strcmp(name, ".note.GNU-stack") == 0) > + return true; > + > if (str_has_pfx(name, ".rel")) { > name += sizeof(".rel") - 1; > /* DWARF section relocations */ > -- > 2.47.3 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH bpf-next] libbpf: Silence newly-added and unused sections 2025-09-20 15:56 ` Alexei Starovoitov @ 2025-09-20 16:18 ` Yonghong Song 2025-09-20 18:50 ` Yonghong Song 1 sibling, 0 replies; 8+ messages in thread From: Yonghong Song @ 2025-09-20 16:18 UTC (permalink / raw) To: Alexei Starovoitov Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, Kernel Team, Martin KaFai Lau On 9/20/25 8:56 AM, Alexei Starovoitov wrote: > On Sat, Sep 20, 2025 at 8:35 AM Yonghong Song <yonghong.song@linux.dev> wrote: >> With latest llvm22, when building bpf selftest, I got the following info >> emitted by libbpf: >> ... >> libbpf: elf: skipping unrecognized data section(14) .comment >> libbpf: elf: skipping section(15) .note.GNU-stack (size 0) >> ... >> >> The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo >> inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class >> MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. >> [Nr] Name Type Address Off Size ES Flg Lk Inf Al >> ... >> [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 >> [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 >> ... >> >> Adding the above two sections in elf section ignore list can avoid the >> above info dump during selftest build. >> >> [1] https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 > Can we revert this instead? > Why do we need these sections if we're not doing anything with them? Yes, we can revert at llvm side. It does not add any value to libbpf. Will submit a llvm pull request soon. > >> Signed-off-by: Yonghong Song <yonghong.song@linux.dev> >> --- >> tools/lib/bpf/libbpf.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c >> index 5161c2b39875..34aed7904039 100644 >> --- a/tools/lib/bpf/libbpf.c >> +++ b/tools/lib/bpf/libbpf.c >> @@ -3788,6 +3788,14 @@ static bool ignore_elf_section(Elf64_Shdr *hdr, const char *name) >> if (is_sec_name_dwarf(name)) >> return true; >> >> + /* .comment section */ >> + if (strcmp(name, ".comment") == 0) >> + return true; >> + >> + /* .note.GNU-stack section */ >> + if (strcmp(name, ".note.GNU-stack") == 0) >> + return true; >> + >> if (str_has_pfx(name, ".rel")) { >> name += sizeof(".rel") - 1; >> /* DWARF section relocations */ >> -- >> 2.47.3 >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH bpf-next] libbpf: Silence newly-added and unused sections 2025-09-20 15:56 ` Alexei Starovoitov 2025-09-20 16:18 ` Yonghong Song @ 2025-09-20 18:50 ` Yonghong Song 2025-09-20 22:41 ` Alexei Starovoitov 1 sibling, 1 reply; 8+ messages in thread From: Yonghong Song @ 2025-09-20 18:50 UTC (permalink / raw) To: Alexei Starovoitov Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, Kernel Team, Martin KaFai Lau On 9/20/25 8:56 AM, Alexei Starovoitov wrote: > On Sat, Sep 20, 2025 at 8:35 AM Yonghong Song <yonghong.song@linux.dev> wrote: >> With latest llvm22, when building bpf selftest, I got the following info >> emitted by libbpf: >> ... >> libbpf: elf: skipping unrecognized data section(14) .comment >> libbpf: elf: skipping section(15) .note.GNU-stack (size 0) >> ... >> >> The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo >> inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class >> MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. >> [Nr] Name Type Address Off Size ES Flg Lk Inf Al >> ... >> [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 >> [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 >> ... >> >> Adding the above two sections in elf section ignore list can avoid the >> above info dump during selftest build. >> >> [1] https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 > Can we revert this instead? > Why do we need these sections if we're not doing anything with them? I did further investigation and it looks like it is hard to revert. To make things work at llvm level, we need to revert the following two llvm commits: https://github.com/llvm/llvm-project/commit/87c73f498d3e98c7b6471f81e25b7e08106053fe and then https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 The commit https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 lets BPFMCAsmInfo derives from MCAsmInfoELF, and the commit https://github.com/llvm/llvm-project/commit/87c73f498d3e98c7b6471f81e25b7e08106053fe push printSwitchToSection() to each variant of MCAsmInfo. The MCAsmInfo itself contains + virtual void printSwitchToSection(const MCSection &, uint32_t Subsection, + const Triple &, raw_ostream &) const {} and MCAsmInfoCOFF, MCAsmInfoDarwin and MCAsmInfoELF have their own specific implementation. So if just revert d9489fd073c0e100c6fbb1e5aef140b00cf62b81, then at BPF backend, printSwitchToSection() will be a noop. This will miss a lot of '.seciton ...' cases. For example, there are totally 89 llvm BPF selftest failures. For example, for jump table support, all '.jumptables' section name will not in asm code. Another example, '.BTF' section name will miss as well. So to make the thing work, reverting both commits are necessary. But tt will be hard to revert llvm commit 87c73f498d3e98c7b6471f81e25b7e08106053fe since it contains lots of non-BPF changes. So I recommend to fix the problem at libbpf level. > >> Signed-off-by: Yonghong Song <yonghong.song@linux.dev> >> --- >> tools/lib/bpf/libbpf.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c >> index 5161c2b39875..34aed7904039 100644 >> --- a/tools/lib/bpf/libbpf.c >> +++ b/tools/lib/bpf/libbpf.c >> @@ -3788,6 +3788,14 @@ static bool ignore_elf_section(Elf64_Shdr *hdr, const char *name) >> if (is_sec_name_dwarf(name)) >> return true; >> >> + /* .comment section */ >> + if (strcmp(name, ".comment") == 0) >> + return true; >> + >> + /* .note.GNU-stack section */ >> + if (strcmp(name, ".note.GNU-stack") == 0) >> + return true; >> + >> if (str_has_pfx(name, ".rel")) { >> name += sizeof(".rel") - 1; >> /* DWARF section relocations */ >> -- >> 2.47.3 >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH bpf-next] libbpf: Silence newly-added and unused sections 2025-09-20 18:50 ` Yonghong Song @ 2025-09-20 22:41 ` Alexei Starovoitov 0 siblings, 0 replies; 8+ messages in thread From: Alexei Starovoitov @ 2025-09-20 22:41 UTC (permalink / raw) To: Yonghong Song Cc: bpf, Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, Kernel Team, Martin KaFai Lau On Sat, Sep 20, 2025 at 11:50 AM Yonghong Song <yonghong.song@linux.dev> wrote: > > > > On 9/20/25 8:56 AM, Alexei Starovoitov wrote: > > On Sat, Sep 20, 2025 at 8:35 AM Yonghong Song <yonghong.song@linux.dev> wrote: > >> With latest llvm22, when building bpf selftest, I got the following info > >> emitted by libbpf: > >> ... > >> libbpf: elf: skipping unrecognized data section(14) .comment > >> libbpf: elf: skipping section(15) .note.GNU-stack (size 0) > >> ... > >> > >> The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo > >> inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class > >> MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. > >> [Nr] Name Type Address Off Size ES Flg Lk Inf Al > >> ... > >> [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 > >> [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 > >> ... > >> > >> Adding the above two sections in elf section ignore list can avoid the > >> above info dump during selftest build. > >> > >> [1] https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 > > Can we revert this instead? > > Why do we need these sections if we're not doing anything with them? > > I did further investigation and it looks like it is hard to revert. > To make things work at llvm level, we need to revert the following two llvm commits: > https://github.com/llvm/llvm-project/commit/87c73f498d3e98c7b6471f81e25b7e08106053fe > and then > https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 > > The commit > https://github.com/llvm/llvm-project/commit/d9489fd073c0e100c6fbb1e5aef140b00cf62b81 > lets BPFMCAsmInfo derives from MCAsmInfoELF, and the commit > https://github.com/llvm/llvm-project/commit/87c73f498d3e98c7b6471f81e25b7e08106053fe > push printSwitchToSection() to each variant of MCAsmInfo. The MCAsmInfo itself contains > > + virtual void printSwitchToSection(const MCSection &, uint32_t Subsection, > + const Triple &, raw_ostream &) const {} > > and > MCAsmInfoCOFF, MCAsmInfoDarwin and MCAsmInfoELF have their own specific > implementation. > > So if just revert d9489fd073c0e100c6fbb1e5aef140b00cf62b81, then at BPF backend, > printSwitchToSection() will be a noop. This will miss a lot of '.seciton ...' > cases. For example, there are totally 89 llvm BPF selftest failures. > > For example, for jump table support, all '.jumptables' section name will not in > asm code. Another example, '.BTF' section name will miss as well. > > So to make the thing work, reverting both commits are necessary. > But tt will be hard to revert llvm commit 87c73f498d3e98c7b6471f81e25b7e08106053fe > since it contains lots of non-BPF changes. Hmm. Can filter out these couple section by name in BPFMCAsmInfo ? > So I recommend to fix the problem at libbpf level. It's probably ok, but let's see whether we can do something on llvm side. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH bpf-next] libbpf: Silence newly-added and unused sections 2025-09-20 15:35 [PATCH bpf-next] libbpf: Silence newly-added and unused sections Yonghong Song 2025-09-20 15:56 ` Alexei Starovoitov @ 2025-09-21 0:30 ` Eduard Zingerman 2025-09-21 1:41 ` Yonghong Song 1 sibling, 1 reply; 8+ messages in thread From: Eduard Zingerman @ 2025-09-21 0:30 UTC (permalink / raw) To: Yonghong Song, bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau On Sat, 2025-09-20 at 08:35 -0700, Yonghong Song wrote: > With latest llvm22, when building bpf selftest, I got the following info > emitted by libbpf: > ... > libbpf: elf: skipping unrecognized data section(14) .comment > libbpf: elf: skipping section(15) .note.GNU-stack (size 0) > ... > > The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo > inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class > MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. > [Nr] Name Type Address Off Size ES Flg Lk Inf Al > ... > [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 This section is generated by MCELFStreamer::emitIdent(), virtual function. > [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 And this one is generated by MCELFStreamer::initSections() virtual function and is controlled by NoExecStack formal parameter. MCELFStreamer instance for BPF backend is created by function BPFMCTargetDesc.cpp:createBPFMCStreamer(). I think we can define a sub-class BPFMCELFStreamer, override the above virtual functions and suppress generation of the sections above. [...] ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH bpf-next] libbpf: Silence newly-added and unused sections 2025-09-21 0:30 ` Eduard Zingerman @ 2025-09-21 1:41 ` Yonghong Song 2025-09-21 4:01 ` Eduard Zingerman 0 siblings, 1 reply; 8+ messages in thread From: Yonghong Song @ 2025-09-21 1:41 UTC (permalink / raw) To: Eduard Zingerman, bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau On 9/20/25 5:30 PM, Eduard Zingerman wrote: > On Sat, 2025-09-20 at 08:35 -0700, Yonghong Song wrote: >> With latest llvm22, when building bpf selftest, I got the following info >> emitted by libbpf: >> ... >> libbpf: elf: skipping unrecognized data section(14) .comment >> libbpf: elf: skipping section(15) .note.GNU-stack (size 0) >> ... >> >> The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo >> inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class >> MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. >> [Nr] Name Type Address Off Size ES Flg Lk Inf Al >> ... >> [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 > This section is generated by MCELFStreamer::emitIdent(), virtual > function. > >> [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 > And this one is generated by MCELFStreamer::initSections() virtual > function and is controlled by NoExecStack formal parameter. > > MCELFStreamer instance for BPF backend is created by function > BPFMCTargetDesc.cpp:createBPFMCStreamer(). > > I think we can define a sub-class BPFMCELFStreamer, override the above > virtual functions and suppress generation of the sections above. > > [...] Two llvm pull request: to avoid generating .comment section: https://github.com/llvm/llvm-project/pull/159958 to avoid generating .note.GNU-stack section: https://github.com/llvm/llvm-project/pull/159960 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH bpf-next] libbpf: Silence newly-added and unused sections 2025-09-21 1:41 ` Yonghong Song @ 2025-09-21 4:01 ` Eduard Zingerman 0 siblings, 0 replies; 8+ messages in thread From: Eduard Zingerman @ 2025-09-21 4:01 UTC (permalink / raw) To: Yonghong Song, bpf Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann, kernel-team, Martin KaFai Lau On Sat, 2025-09-20 at 18:41 -0700, Yonghong Song wrote: > > On 9/20/25 5:30 PM, Eduard Zingerman wrote: > > On Sat, 2025-09-20 at 08:35 -0700, Yonghong Song wrote: > > > With latest llvm22, when building bpf selftest, I got the following info > > > emitted by libbpf: > > > ... > > > libbpf: elf: skipping unrecognized data section(14) .comment > > > libbpf: elf: skipping section(15) .note.GNU-stack (size 0) > > > ... > > > > > > The reason is due to llvm patch [1]. Previously, bpf class BPFMCAsmInfo > > > inherits class MCAsmInfo. With [1], BPFMCAsmInfo inherits class > > > MCAsmInfoELF. Such a change added two more sections in the bpf binary, e.g. > > > [Nr] Name Type Address Off Size ES Flg Lk Inf Al > > > ... > > > [23] .comment PROGBITS 0000000000000000 0035ac 00006d 01 MS 0 0 1 > > This section is generated by MCELFStreamer::emitIdent(), virtual > > function. > > > > > [24] .note.GNU-stack PROGBITS 0000000000000000 003619 000000 00 0 0 1 > > And this one is generated by MCELFStreamer::initSections() virtual > > function and is controlled by NoExecStack formal parameter. > > > > MCELFStreamer instance for BPF backend is created by function > > BPFMCTargetDesc.cpp:createBPFMCStreamer(). > > > > I think we can define a sub-class BPFMCELFStreamer, override the above > > virtual functions and suppress generation of the sections above. > > > > [...] > > Two llvm pull request: > to avoid generating .comment section: > https://github.com/llvm/llvm-project/pull/159958 > to avoid generating .note.GNU-stack section: > https://github.com/llvm/llvm-project/pull/159960 Ack, thank you for the links. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-21 4:01 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-09-20 15:35 [PATCH bpf-next] libbpf: Silence newly-added and unused sections Yonghong Song 2025-09-20 15:56 ` Alexei Starovoitov 2025-09-20 16:18 ` Yonghong Song 2025-09-20 18:50 ` Yonghong Song 2025-09-20 22:41 ` Alexei Starovoitov 2025-09-21 0:30 ` Eduard Zingerman 2025-09-21 1:41 ` Yonghong Song 2025-09-21 4:01 ` Eduard Zingerman
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.