bpf: Fix BTF_ID symbol generation
Jiri Olsa
reviewerPATCH 1/1 bpf: Fix BTF_ID symbol generation
Marcus and Nick reported issue where BTF_ID macro generates same symbol in separate objects and that breaks final vmlinux link.
Adding __LINE__ number suffix to make BTF_ID symbol more unique, which is not real fix, but it would help for now and meanwhile we can work on better solution as suggested by Andrii in [2].
[1] https://github.com/ClangBuiltLinux/linux/issues/1913
[2] https://lore.kernel.org/bpf/ZQQVr35crUtN1quS@krava/T/#m64d7c29c407d6adf0e7b420359958b3aafa7bf69
--- include/linux/btf_ids.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/btf_ids.h +1 -1
@@ -49,7 +49,7 @@ word \ ____BTF_ID(symbol, word)#define __ID (prefix) \ - __PASTE(prefix, __COUNTER__) + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__)/* * The BTF_ID defines unique symbol for each ID pointing
Signature · 1 line
2.41.0
Quoted 22 lines · Jiri Olsa
Marcus and Nick reported issue where
BTF_IDmacro generates same symbol in separate objects and that breaks final vmlinux link.Adding
__LINE__number suffix to makeBTF_IDsymbol more unique, which is not real fix, but it would help for now and meanwhile we can work on better solution as suggested by Andrii in [2].[1] https://github.com/ClangBuiltLinux/linux/issues/1913
[2] https://lore.kernel.org/bpf/ZQQVr35crUtN1quS@krava/T/#m64d7c29c407d6adf0e7b420359958b3aafa7bf69Reported-by Marcus Seyfarth <[email protected]>Reported-by Nick Desaulniers <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- include/linux/btf_ids.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/btf_ids.h +0
-0
include/linux/btf_ids.h word \ · line 52
Quoted 5 lines
include/linux/btf_ids.h +1
-1@@ -49,7 +49,7 @@ word \ ____BTF_ID(symbol, word)#define __ID (prefix) \ - __PASTE(prefix, __COUNTER__) + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__)
I think __COUNTER__ and __LINE__ both expand to string literals; you can avoid another expansion via __PASTE by just putting them adjacent, like so:
https://github.com/ClangBuiltLinux/linux/issues/1913#issuecomment-1710794319
I'll send that as a v2 and link back to your v1.
Quoted 6 lines
include/linux/btf_ids.h +0
-1/* * The BTF_ID defines unique symbol for each ID pointing -- 2.41.0
Signature · 2 lines
Thanks, ~Nick Desaulniers
Quoted 26 lines · Nick Desaulniers
Quoted 24 lines · Jiri Olsa
Marcus and Nick reported issue where
BTF_IDmacro generates same symbol in separate objects and that breaks final vmlinux link.Adding
__LINE__number suffix to makeBTF_IDsymbol more unique, which is not real fix, but it would help for now and meanwhile we can work on better solution as suggested by Andrii in [2].[1] https://github.com/ClangBuiltLinux/linux/issues/1913
[2] https://lore.kernel.org/bpf/ZQQVr35crUtN1quS@krava/T/#m64d7c29c407d6adf0e7b420359958b3aafa7bf69Reported-by Marcus Seyfarth <[email protected]>Reported-by Nick Desaulniers <[email protected]>Signed-off-by Jiri Olsa <[email protected]>--- include/linux/btf_ids.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/btf_ids.h +0
-0@@ -49,7 +49,7 @@ word \____BTF_ID (symbol, word)
Quoted 5 lines
include/linux/btf_ids.h word \ · line 52
Quoted 3 lines
include/linux/btf_ids.h +1
-1#define __ID (prefix) \ - __PASTE(prefix, __COUNTER__) + __PASTE(__PASTE(prefix, __COUNTER__), __LINE__)I think
__COUNTER__and__LINE__both expand to string literals; you
ah, no I was wrong.
But this change needs to go into tools/include/linux/btf_ids.h, too.
I'll wrap that up in my v3.
Quoted 16 lines
can avoid another expansion via
__PASTEby just putting them adjacent, like so:
https://github.com/ClangBuiltLinux/linux/issues/1913#issuecomment-1710794319
I'll send that as a v2 and link back to your v1.Quoted 6 lines
include/linux/btf_ids.h +0
-1/* * The BTF_ID defines unique symbol for each ID pointing -- 2.41.0
--
Thanks,
~Nick Desaulniers
Signature · 2 lines
Thanks, ~Nick Desaulniers