Skip to content

Commit

Permalink
btf: export package
Browse files Browse the repository at this point in the history
  • Loading branch information
lmb committed May 11, 2022
1 parent bd1d163 commit 2e33f5e
Show file tree
Hide file tree
Showing 51 changed files with 27 additions and 30 deletions.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ TARGETS := \
testdata/map_spin_lock \
testdata/subprog_reloc \
testdata/fwd_decl \
internal/btf/testdata/relocs \
internal/btf/testdata/relocs_read \
internal/btf/testdata/relocs_read_tgt
btf/testdata/relocs \
btf/testdata/relocs_read \
btf/testdata/relocs_read_tgt

.PHONY: all clean container-all container-shell generate

Expand All @@ -60,7 +60,7 @@ container-shell:

clean:
-$(RM) testdata/*.elf
-$(RM) internal/btf/testdata/*.elf
-$(RM) btf/testdata/*.elf

format:
find . -type f -name "*.c" | xargs clang-format -i
Expand Down Expand Up @@ -95,6 +95,6 @@ testdata/loader-%-eb.elf: testdata/loader.c

# Usage: make VMLINUX=/path/to/vmlinux vmlinux-btf
.PHONY: vmlinux-btf
vmlinux-btf: internal/btf/testdata/vmlinux-btf.gz
internal/btf/testdata/vmlinux-btf.gz: $(VMLINUX)
vmlinux-btf: btf/testdata/vmlinux-btf.gz
btf/testdata/vmlinux-btf.gz: $(VMLINUX)
objcopy --dump-section .BTF=/dev/stdout "$<" /dev/null | gzip > "$@"
File renamed without changes.
4 changes: 2 additions & 2 deletions internal/btf/btf_test.go → btf/btf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestFindVMLinux(t *testing.T) {
}

func TestLoadSpecFromElf(t *testing.T) {
testutils.Files(t, testutils.Glob(t, "../../testdata/loader-e*.elf"), func(t *testing.T, file string) {
testutils.Files(t, testutils.Glob(t, "../testdata/loader-e*.elf"), func(t *testing.T, file string) {
spec := parseELFBTF(t, file)

vt, err := spec.TypeByID(0)
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestGuessBTFByteOrder(t *testing.T) {
}

func TestSpecCopy(t *testing.T) {
spec := parseELFBTF(t, "../../testdata/loader-el.elf")
spec := parseELFBTF(t, "../testdata/loader-el.elf")

if len(spec.types) < 1 {
t.Fatal("Not enough types")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/btf/core_reloc_test.go → btf/core_reloc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/testutils"
)

Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions internal/btf/doc.go → btf/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
//
// The canonical documentation lives in the Linux kernel repository and is
// available at https://www.kernel.org/doc/html/latest/bpf/btf.html
//
// The API is very much unstable. You should only use this via the main
// ebpf library.
package btf
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added btf/testdata/relocs-eb.elf
Binary file not shown.
Binary file added btf/testdata/relocs-el.elf
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/btf/testdata/relocs.c → btf/testdata/relocs.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../../../testdata/common.h"
#include "../../testdata/common.h"
#include "bpf_core_read.h"

enum e {
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "../../../testdata/common.h"
#include "../../testdata/common.h"
#include "bpf_core_read.h"

#define core_access __builtin_preserve_access_index
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/bpf2go/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"text/template"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
)

const ebpfModule = "github.com/cilium/ebpf"
Expand Down
2 changes: 1 addition & 1 deletion cmd/bpf2go/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"testing"

"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/btf"
qt "github.com/frankban/quicktest"
)

Expand Down
2 changes: 1 addition & 1 deletion collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/btf"
)

// CollectionOptions control loading a collection into the kernel.
Expand Down
2 changes: 1 addition & 1 deletion collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/testutils"
)

Expand Down
2 changes: 1 addition & 1 deletion elf_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"strings"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/unix"
)

Expand Down
2 changes: 1 addition & 1 deletion elf_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"syscall"
"testing"

"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/testutils"
"github.com/cilium/ebpf/internal/unix"

Expand Down
2 changes: 1 addition & 1 deletion info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"unsafe"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/sys"
"github.com/cilium/ebpf/internal/unix"
)
Expand Down
Binary file removed internal/btf/testdata/relocs-eb.elf
Binary file not shown.
Binary file removed internal/btf/testdata/relocs-el.elf
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/cmd/gentypes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"sort"
"strings"

"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/sys"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/sys/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package sys

// Regenerate types.go by invoking go generate in the current directory.

//go:generate go run github.com/cilium/ebpf/internal/cmd/gentypes ../btf/testdata/vmlinux-btf.gz
//go:generate go run github.com/cilium/ebpf/internal/cmd/gentypes ../../btf/testdata/vmlinux-btf.gz
2 changes: 1 addition & 1 deletion link/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"fmt"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/sys"
)

Expand Down
2 changes: 1 addition & 1 deletion link/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal/sys"
)

Expand Down
2 changes: 1 addition & 1 deletion linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/btf"
)

// splitSymbols splits insns into subsections delimited by Symbol Instructions.
Expand Down
2 changes: 1 addition & 1 deletion map.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"
"unsafe"

"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/sys"
"github.com/cilium/ebpf/internal/unix"
)
Expand Down
2 changes: 1 addition & 1 deletion map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"unsafe"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/sys"
"github.com/cilium/ebpf/internal/testutils"
"github.com/cilium/ebpf/internal/unix"
Expand Down
2 changes: 1 addition & 1 deletion prog.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/sys"
"github.com/cilium/ebpf/internal/unix"
)
Expand Down
2 changes: 1 addition & 1 deletion prog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
"github.com/google/go-cmp/cmp"

"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/btf"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/btf"
"github.com/cilium/ebpf/internal/sys"
"github.com/cilium/ebpf/internal/testutils"
"github.com/cilium/ebpf/internal/unix"
Expand Down

0 comments on commit 2e33f5e

Please sign in to comment.