BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpftool: cast pointers for shadow types explicitly.
@ 2024-03-12  1:37 Kui-Feng Lee
  2024-03-12  5:22 ` Yonghong Song
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Kui-Feng Lee @ 2024-03-12  1:37 UTC (permalink / raw)
  To: bpf, ast, martin.lau, song, kernel-team, andrii
  Cc: sinquersw, kuifeng, Kui-Feng Lee, yhs

According to a report, skeletons fail to assign shadow pointers when being
compiled with C++ programs. Unlike C doing implicit casting for void
pointers, C++ requires an explicit casting.

To support C++, we do explicit casting for each shadow pointer.

Cc: yhs@meta.com
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
---
 tools/bpf/bpftool/gen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 4fa4ade1ce74..dedafea0c127 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -1131,7 +1131,7 @@ static void gen_st_ops_shadow_init(struct btf *btf, struct bpf_object *obj)
 			continue;
 		codegen("\
 			\n\
-				obj->struct_ops.%1$s = bpf_map__initial_value(obj->maps.%1$s, NULL);\n\
+				obj->struct_ops.%1$s = (typeof(obj->struct_ops.%1$s))bpf_map__initial_value(obj->maps.%1$s, NULL);\n\
 			\n\
 			", ident);
 	}
-- 
2.34.1


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

end of thread, other threads:[~2024-03-14 20:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-12  1:37 [PATCH bpf-next] bpftool: cast pointers for shadow types explicitly Kui-Feng Lee
2024-03-12  5:22 ` Yonghong Song
2024-03-12  9:53   ` Quentin Monnet
2024-03-12 22:47 ` Andrii Nakryiko
2024-03-13  0:07   ` Kui-Feng Lee
2024-03-13  0:27     ` Andrii Nakryiko
2024-03-13  0:37       ` Kui-Feng Lee
2024-03-13 15:51         ` Andrii Nakryiko
2024-03-14 20:36           ` Andrii Nakryiko
2024-03-14 20:40 ` 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