elf_resolve_syms_offsets() looks up the symbols in .dynsym and then in .symtab, and skips a table the binary does not have. When .symtab is missing, as in stripped binaries and in the shared libraries most distributions ship, the -ENOENT that elf_sym_iter_new() returns for it is left in err. If every symbol was already found in .dynsym, the function then frees the offsets and returns -ENOENT anyway. As a result, bpf_program__attach_uprobe_multi() with opts->syms fails on such binaries, while attaching the same functions one at a time with bpf_program__attach_uprobe_opts() works. For example, attaching to getppid() in Ubuntu 24.04's libc.so.6, which has no .symtab, fails with -ENOENT. Clear err when a table is missing; the cnt_done check after the loop already reports symbols that were not found. The fix was written with the help of Claude Code, an AI coding assistant, and reviewed and tested by the author: attaching a uprobe_multi to getppid() in libc.so.6 by symbol fails with -ENOENT before this patch and works after it, and the selftest in the next patch fails before it and passes after it. Fixes: 7ace84c68929 ("libbpf: Add elf_resolve_syms_offsets function") Closes: https://github.com/libbpf/libbpf/issues/953 Signed-off-by: Mehmet Rıfat Özkal --- tools/lib/bpf/elf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/elf.c b/tools/lib/bpf/elf.c index 700c3911a..a1fb64e7c 100644 --- a/tools/lib/bpf/elf.c +++ b/tools/lib/bpf/elf.c @@ -438,8 +438,11 @@ int elf_resolve_syms_offsets(const char *binary_path, int cnt, struct elf_sym *sym; err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], st_type); - if (err == -ENOENT) + if (err == -ENOENT) { + /* a missing table is fine, cnt_done decides below */ + err = 0; continue; + } if (err) goto out; -- 2.43.0