提交 3fcba4dc 编写于 作者: T Toke Høiland-Jørgensen 提交者: Zheng Zengkai

libbpf: Properly ignore STT_SECTION symbols in legacy map definitions

mainline inclusion
from mainline-5.16-rc1
commit 161ecd53
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5EUVD
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=161ecd537948a7003129889b04a3a0858687bc70

-------------------------------------------------

The previous patch to ignore STT_SECTION symbols only added the ignore
condition in one of them. This fails if there's more than one map
definition in the 'maps' section, because the subsequent modulus check will
fail, resulting in error messages like:

libbpf: elf: unable to determine legacy map definition size in ./xdpdump_xdp.o

Fix this by also ignoring STT_SECTION in the first loop.

Fixes: c3e8c44a ("libbpf: Ignore STT_SECTION symbols in 'maps' section")
Signed-off-by: NToke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: NAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210929213837.832449-1-toke@redhat.com
(cherry picked from commit 161ecd53)
Signed-off-by: NWang Yufen <wangyufen@huawei.com>
上级 67d50a55
...@@ -1848,6 +1848,8 @@ static int bpf_object__init_user_maps(struct bpf_object *obj, bool strict) ...@@ -1848,6 +1848,8 @@ static int bpf_object__init_user_maps(struct bpf_object *obj, bool strict)
continue; continue;
if (sym.st_shndx != obj->efile.maps_shndx) if (sym.st_shndx != obj->efile.maps_shndx)
continue; continue;
if (GELF_ST_TYPE(sym.st_info) == STT_SECTION)
continue;
nr_maps++; nr_maps++;
} }
/* Assume equally sized map definitions */ /* Assume equally sized map definitions */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册