MCPcopy Index your code
hub / github.com/cilium/ebpf / structOpsSetAttachTo

Function structOpsSetAttachTo

struct_ops.go:228–250  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

226// this relies on the assumption that each member in the
227// `.struct_ops` section has a relocation at its starting byte offset.
228func 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}

Callers 1

Calls 1

BytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…