github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/btf/workarounds.go (about) 1 package btf 2 3 // datasecResolveWorkaround ensures that certain vars in a Datasec are added 4 // to a Spec before the Datasec. This avoids a bug in kernel BTF validation. 5 // 6 // See https://lore.kernel.org/bpf/20230302123440.1193507-1-lmb@isovalent.com/ 7 func datasecResolveWorkaround(b *Builder, ds *Datasec) error { 8 for _, vsi := range ds.Vars { 9 v, ok := vsi.Type.(*Var) 10 if !ok { 11 continue 12 } 13 14 switch v.Type.(type) { 15 case *Typedef, *Volatile, *Const, *Restrict, *typeTag: 16 // NB: We must never call Add on a Datasec, otherwise we risk 17 // infinite recursion. 18 _, err := b.Add(v.Type) 19 if err != nil { 20 return err 21 } 22 } 23 } 24 25 return nil 26 }