[llvm] [BPF] Do not emit names for PTR, CONST, VOLATILE and RESTRICT BTF types (PR #163174)

via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 17 13:59:55 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
----------------
eddyz87 wrote:

Nit: this points to `return -EINVAL` for unexpected `vlen` value. Maybe point at the `btf_ref_type_check_meta` itself?

https://github.com/llvm/llvm-project/pull/163174


More information about the llvm-commits mailing list