libbpf: Ignore exception frame section
PATCH v2 1/1 libbpf: Ignore exception frame section
Exception handling in BPF program is not supported right now, let's skip it. BTW, I found this when building BPF with Zig compiler[1].
[1]: https://github.com/tw4452852/bb
---
v2:
Revise the commit message.
tools/lib/bpf/libbpf.c | 3 ++- tools/lib/bpf/linker.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
tools/lib/bpf/libbpf.c +2 -1
@@ -3867,7 +3867,8 @@ static Elf64_Rel *elf_rel_by_idx(Elf_Data *data, size_t idx)static bool is_sec_name_dwarf (const char *name) {/* approximation, but the actual list is too long */ -return str_has_pfx (name,".debug_" ); +return str_has_pfx (name,".debug_" ) || +strcmp (name,".eh_frame" ) ==0 ; }static bool ignore_elf_section (Elf64_Shdr *hdr,const char *name)
tools/lib/bpf/linker.c +2 -1
@@ -599,7 +599,8 @@ int bpf_linker__add_buf(struct bpf_linker *linker, void *buf, size_t buf_sz,static bool is_dwarf_sec_name (const char *name) {/* approximation, but the actual list is too long */ -return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 ; +return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 || +strcmp (name,".eh_frame" ) ==0 ; }static bool is_ignored_sec (struct src_sec *sec)
Signature · 1 line
2.54.0
Kumar Kartikeya Dwivedi
maintainerQuoted 6 lines · Tw
Exception handling in BPF program is not supported right now, let's skip it. BTW, I found this when building BPF with Zig compiler[1].
[1]: https://github.com/tw4452852/bb
Signed-off-by Tw <[email protected]>
You need to have your full real name in the SoB tag. Patches cannot be accepted otherwise.
pw-bot: cr
Quoted 36 lines
---
v2:
Revise the commit message.tools/lib/bpf/libbpf.c | 3 ++- tools/lib/bpf/linker.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)tools/lib/bpf/libbpf.c +2
-1@@ -3867,7 +3867,8 @@ static Elf64_Rel *elf_rel_by_idx(Elf_Data *data, size_t idx)static bool is_sec_name_dwarf (const char *name) {/* approximation, but the actual list is too long */ -return str_has_pfx (name,".debug_" ); +return str_has_pfx (name,".debug_" ) || +strcmp (name,".eh_frame" ) ==0 ; }static bool ignore_elf_section (Elf64_Shdr *hdr,const char *name)tools/lib/bpf/linker.c +2
-1@@ -599,7 +599,8 @@ int bpf_linker__add_buf(struct bpf_linker *linker, void *buf, size_t buf_sz,static bool is_dwarf_sec_name (const char *name) {/* approximation, but the actual list is too long */ -return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 ; +return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 || +strcmp (name,".eh_frame" ) ==0 ; }static bool is_ignored_sec (struct src_sec *sec)
[email protected]
AI reviewKumar Kartikeya Dwivedi pointed out in both v1 and v2 reviews that the Signed-off-by tag must contain the author's full real name, not just 'Tw'. The v2 review explicitly stated: 'You need to have…
Quoted 8 lines
libbpf: Ignore exception frame section
Exception handling in BPF program is not supported right now, let's skip it. BTW, I found this when building BPF with Zig compiler[1].
[1]: https://github.com/tw4452852/bb
Signed-off-by Tw <[email protected]>
Kumar Kartikeya Dwivedi pointed out in both v1 and v2 reviews that the Signed-off-by tag must contain the author's full real name, not just 'Tw'. The v2 review explicitly stated: 'You need to have your full real name in the SoB tag. Patches cannot be accepted otherwise.'
Could you update the Signed-off-by to include your full name?
tools/lib/bpf/libbpf.c static Elf64_Rel *elf_rel_by_idx(Elf_Data *data, size_t idx) · line 3871
Quoted 11 lines
tools/lib/bpf/libbpf.c +2
-1@@ -3867,7 +3867,8 @@ static Elf64_Rel *elf_rel_by_idx(Elf_Data *data, size_t idx)static bool is_sec_name_dwarf (const char *name) {/* approximation, but the actual list is too long */ -return str_has_pfx (name,".debug_" ); +return str_has_pfx (name,".debug_" ) || +strcmp (name,".eh_frame" ) ==0 ;
This isn't a bug, but could the continuation line be aligned under the first operand (tab + 7 spaces) so the two operands line up? Every other wrapped return statement in libbpf.c uses tab plus seven spaces to align the continuation, like in bpf_map__is_ringbuf():
return map->def.type == BPF_MAP_TYPE_RINGBUF ||
map->def.type == BPF_MAP_TYPE_USER_RINGBUF;Quoted 8 lines
tools/lib/bpf/libbpf.c +0
-0}static bool ignore_elf_section (Elf64_Shdr *hdr,const char *name)tools/lib/bpf/linker.c +0
-0
tools/lib/bpf/linker.c int bpf_linker__add_buf(struct bpf_linker *linker, void *buf, size_t buf_sz, · line 603
Quoted 6 lines
tools/lib/bpf/linker.c +2
-1@@ -599,7 +599,8 @@ int bpf_linker__add_buf(struct bpf_linker *linker, void *buf, size_t buf_sz,static bool is_dwarf_sec_name (const char *name) {/* approximation, but the actual list is too long */ -return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 ; +return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 || +strcmp (name,".eh_frame" ) ==0 ;
This isn't a bug, but since the same .eh_frame check now has to be extended in both is_sec_name_dwarf() and is_dwarf_sec_name(), and their callers ignore_elf_section() and is_ignored_sec() are also near-verbatim copies including the same .rel prefix-stripping and the same BTF section exclusions, would it be worth moving the shared predicate into libbpf_internal.h so future additions only need one edit?
tools/lib/bpf/linker.c int bpf_linker__add_buf(struct bpf_linker *linker, void *buf, size_t buf_sz, · line 606
Quoted 3 lines
tools/lib/bpf/linker.c +0
-0}static bool is_ignored_sec (struct src_sec *sec)
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32731757949
Quoted 4 lines · Tw
Exception handling in BPF program is not supported right now, let's skip it. BTW, I found this when building BPF with Zig compiler[1].
Instruct zig compiler to not generate .eh_frame for BPF object file, which is not supported anyways? That's been a solution for C/C++ compilers so far.
Quoted 43 lines
[1]: https://github.com/tw4452852/bb
Signed-off-by Tw <[email protected]>---
v2:
Revise the commit message.tools/lib/bpf/libbpf.c | 3 ++- tools/lib/bpf/linker.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)tools/lib/bpf/libbpf.c +2
-1@@ -3867,7 +3867,8 @@ static Elf64_Rel *elf_rel_by_idx(Elf_Data *data, size_t idx)static bool is_sec_name_dwarf (const char *name) {/* approximation, but the actual list is too long */ -return str_has_pfx (name,".debug_" ); +return str_has_pfx (name,".debug_" ) || +strcmp (name,".eh_frame" ) ==0 ; }static bool ignore_elf_section (Elf64_Shdr *hdr,const char *name)tools/lib/bpf/linker.c +2
-2@@ -599,7 +599,8 @@ int bpf_linker__add_buf(struct bpf_linker *linker, void *buf, size_t buf_sz,static bool is_dwarf_sec_name (const char *name) {/* approximation, but the actual list is too long */ -return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 ; +return strncmp (name,".debug_" ,sizeof (".debug_" ) -1 ) ==0 || +strcmp (name,".eh_frame" ) ==0 ; }static bool is_ignored_sec (struct src_sec *sec) --2.54.0