[llvm] [BPF] Do not emit names for PTR, CONST, VOLATILE and RESTRICT BTF types (PR #163174)
Michal R via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 20 06:13:23 PDT 2025
================
@@ -93,7 +93,24 @@ void BTFTypeDerived::completeType(BTFDebug &BDebug) {
return;
IsCompleted = true;
- BTFType.NameOff = BDebug.addString(Name);
+ switch (Kind) {
+ case BTF::BTF_KIND_PTR:
+ case BTF::BTF_KIND_CONST:
+ case BTF::BTF_KIND_VOLATILE:
+ case BTF::BTF_KIND_RESTRICT:
+ // Debug info might contain names for these types, but given that we want
+ // to keep BTF minimal and naming reference types doesn't bring any value
+ // (what matters is the completeness of the base type), we don't emit them.
+ //
+ // Furthermore, the Linux kernel refuses to load BPF programs that contain
+ // BTF with these types named:
+ // https://elixir.bootlin.com/linux/v6.17.1/source/kernel/bpf/btf.c#L2594
----------------
vadorovsky wrote:
Good point, done
https://github.com/llvm/llvm-project/pull/163174
More information about the llvm-commits
mailing list