Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

libbpf: Use proper errno value in linker

Return values of the linker_append_sec_data() and the
linker_append_elf_relos() functions are propagated all the
way up to users of libbpf API. In some error cases these
functions return -1 which will be seen as -EPERM from user's
point of view. Instead, return a more reasonable -EINVAL.

Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs")
Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250430120820.2262053-1-a.s.protopopov@gmail.com

authored by

Anton Protopopov and committed by
Andrii Nakryiko
358b1c0f 38d976c3

+2 -2
+2 -2
tools/lib/bpf/linker.c
··· 1376 1376 } else { 1377 1377 if (!secs_match(dst_sec, src_sec)) { 1378 1378 pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name); 1379 - return -1; 1379 + return -EINVAL; 1380 1380 } 1381 1381 1382 1382 /* "license" and "version" sections are deduped */ ··· 2223 2223 } 2224 2224 } else if (!secs_match(dst_sec, src_sec)) { 2225 2225 pr_warn("sections %s are not compatible\n", src_sec->sec_name); 2226 - return -1; 2226 + return -EINVAL; 2227 2227 } 2228 2228 2229 2229 /* shdr->sh_link points to SYMTAB */