structOpsSetAttachTo sets p.AttachTo in the expected "struct_name:memberName" format based on the struct definition. this relies on the assumption that each member in the `.struct_ops` section has a relocation at its starting byte offset.
( sec *elfSection, baseOff uint32, userSt *btf.Struct, progs map[string]*ProgramSpec)
| 226 | // this relies on the assumption that each member in the |
| 227 | // `.struct_ops` section has a relocation at its starting byte offset. |
| 228 | func structOpsSetAttachTo( |
| 229 | sec *elfSection, |
| 230 | baseOff uint32, |
| 231 | userSt *btf.Struct, |
| 232 | progs map[string]*ProgramSpec) error { |
| 233 | for _, m := range userSt.Members { |
| 234 | memberOff := m.Offset |
| 235 | sym, ok := sec.relocations[uint64(baseOff+memberOff.Bytes())] |
| 236 | if !ok { |
| 237 | continue |
| 238 | } |
| 239 | p, ok := progs[sym.Name] |
| 240 | if !ok || p == nil { |
| 241 | return fmt.Errorf("program %s not found", sym.Name) |
| 242 | } |
| 243 | |
| 244 | if p.Type != StructOps { |
| 245 | return fmt.Errorf("program %s is not StructOps", sym.Name) |
| 246 | } |
| 247 | p.AttachTo = userSt.Name + ":" + m.Name |
| 248 | } |
| 249 | return nil |
| 250 | } |
no test coverage detected
searching dependent graphs…