Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incomplete handling of exception frame sections by using exact string matching instead of prefix matching.
--
--- Patch [1]: [PATCH] libbpf: Ignore exception frame section ---
commit 7e5607d9374ac0c905a5c8970316c258ed4eb5cf
Author: Tw <[email protected]>
libbpf: Ignore exception frame section
This commit updates the ELF section filtering logic to ignore ".eh_frame"
sections during BPF object linking and loading. This resolves issues when
building BPF programs with compilers that emit exception handling frames,
as they are not needed by the kernel.
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index b749c01742ee0..05727c418c402 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -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;
[Severity: Medium]
Does this exact string match correctly handle variants like ".eh_frame_hdr"
or function-split ".eh_frame.*" sections?
If a compiler emits these variant sections, they would bypass this filter and
could potentially cause build-time link failures against STT_SECTION. Would
it be more robust to use a prefix match like str_has_pfx() here, similar to
how ".debug_" is handled?
> }
>
> static bool ignore_elf_section(Elf64_Shdr *hdr, const char *name)
[ ... ]
> diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c
> index 78f92c39290af..1fb0efdbfae7f 100644
> --- a/tools/lib/bpf/linker.c
> +++ b/tools/lib/bpf/linker.c
> @@ -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;
[Severity: Medium]
Similarly, would it be beneficial to use a prefix match (e.g. strncmp) here
to ensure we also ignore related exception frame sections?
> }
>
> static bool is_ignored_sec(struct src_sec *sec)
--
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.