Pin dependency github.com/cilium/ebpf

Use same as opencontainers/runc
This commit is contained in:
Odin Ugedal
2020-01-24 13:13:44 +01:00
parent 088ee920e0
commit 5ba2a8da09
35 changed files with 600 additions and 2731 deletions

View File

@@ -2,35 +2,23 @@ package ebpf
import (
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/internal/btf"
"github.com/pkg/errors"
)
// link resolves bpf-to-bpf calls.
//
// Each library may contain multiple functions / labels, and is only linked
// Each section may contain multiple functions / labels, and is only linked
// if the program being edited references one of these functions.
//
// Libraries must not require linking themselves.
func link(prog *ProgramSpec, libs []*ProgramSpec) error {
for _, lib := range libs {
insns, err := linkSection(prog.Instructions, lib.Instructions)
// Sections must not require linking themselves.
func link(insns asm.Instructions, sections ...asm.Instructions) (asm.Instructions, error) {
for _, section := range sections {
var err error
insns, err = linkSection(insns, section)
if err != nil {
return errors.Wrapf(err, "linking %s", lib.Name)
}
if len(insns) == len(prog.Instructions) {
continue
}
prog.Instructions = insns
if prog.BTF != nil && lib.BTF != nil {
if err := btf.ProgramAppend(prog.BTF, lib.BTF); err != nil {
return errors.Wrapf(err, "linking BTF of %s", lib.Name)
}
return nil, err
}
}
return nil
return insns, nil
}
func linkSection(insns, section asm.Instructions) (asm.Instructions, error) {