]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Fix section counting logic
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 3 Nov 2021 17:32:12 +0000 (10:32 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 3 Nov 2021 20:25:37 +0000 (13:25 -0700)
commita44a832de5fb76f3c9ba58a38bb7ef0906e5f387
treecbaba4bdd1ac6b5bd37756f205ac58b5eccf3280
parent85cbf840e90fbd139359936e27e9620873ce4458
libbpf: Fix section counting logic

e_shnum does include section #0 and as such is exactly the number of ELF
sections that we need to allocate memory for to use section indices as
array indices. Fix the off-by-one error.

This is purely accounting fix, previously we were overallocating one
too many array items. But no correctness errors otherwise.

Fixes: 160574e3580a ("libbpf: Remove assumptions about uniqueness of .rodata/.data/.bss maps")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211103173213.1376990-5-andrii@kernel.org
tools/lib/bpf/libbpf.c