From 1372cb567cad10af3f6bf08afa2a01b1f310c424 Mon Sep 17 00:00:00 2001 From: grantseltzer Date: Mon, 27 Jun 2022 11:31:50 -0400 Subject: [PATCH] Add small section in selftest Signed-off-by: grantseltzer --- selftest/tracing/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/selftest/tracing/main.go b/selftest/tracing/main.go index 8acfe7ec..44aa1831 100644 --- a/selftest/tracing/main.go +++ b/selftest/tracing/main.go @@ -11,6 +11,7 @@ import ( "fmt" bpf "github.com/aquasecurity/libbpfgo" + "github.com/aquasecurity/libbpfgo/helpers" ) func main() { @@ -28,7 +29,22 @@ func main() { os.Exit(-1) } - bpfModule.ListProgramNames() + m, err := helpers.NewKernelSymbolsMap() + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(-1) + } + + sym, err := m.GetSymbolByName("system", "__x64_sys_mmap") + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(-1) + } + + if sym.Address == 0 || sym.Name == "" { + fmt.Fprintln(os.Stderr, "could not find symbol to attach to") + os.Exit(-1) + } prog, err := bpfModule.GetProgram("mmap_fentry") if err != nil {