bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: properly ignore STT_SECTION symbols in legacy map definitions
@ 2021-09-29 21:38 Toke Høiland-Jørgensen
  2021-09-29 23:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Toke Høiland-Jørgensen @ 2021-09-29 21:38 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Toke Høiland-Jørgensen, Andrii Nakryiko,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Jiri Benc, bpf

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: c3e8c44a9063 ("libbpf: Ignore STT_SECTION symbols in 'maps' section")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
Terribly sorry for not catching this in the previous patch. I was testing with an
object file with only one map definition, which worked fine :(

 tools/lib/bpf/libbpf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 453148fe8b4b..c20b2167e354 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1845,6 +1845,8 @@ static int bpf_object__init_user_maps(struct bpf_object *obj, bool strict)
 			continue;
 		if (sym.st_shndx != obj->efile.maps_shndx)
 			continue;
+		if (GELF_ST_TYPE(sym.st_info) == STT_SECTION)
+			continue;
 		nr_maps++;
 	}
 	/* Assume equally sized map definitions */
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] libbpf: properly ignore STT_SECTION symbols in legacy map definitions
  2021-09-29 21:38 [PATCH bpf-next] libbpf: properly ignore STT_SECTION symbols in legacy map definitions Toke Høiland-Jørgensen
@ 2021-09-29 23:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-09-29 23:00 UTC (permalink / raw)
  To: =?utf-8?b?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2VuIDx0b2tlQHJlZGhhdC5jb20+?=
  Cc: ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, sdf, jbenc, bpf

Hello:

This patch was applied to bpf/bpf-next.git (refs/heads/master):

On Wed, 29 Sep 2021 23:38:37 +0200 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [bpf-next] libbpf: properly ignore STT_SECTION symbols in legacy map definitions
    https://git.kernel.org/bpf/bpf-next/c/161ecd537948

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-29 23:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 21:38 [PATCH bpf-next] libbpf: properly ignore STT_SECTION symbols in legacy map definitions Toke Høiland-Jørgensen
2021-09-29 23:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).