Showing preview only (2,263K chars total). Download the full file or copy to clipboard to get everything.
Repository: cilium/ebpf
Branch: main
Commit: 729742be0e24
Files: 638
Total size: 2.1 MB
Directory structure:
gitextract_xp4d7it9/
├── .clang-format
├── .gitattributes
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.yml
│ │ └── config.yml
│ ├── dependabot.yml
│ └── workflows/
│ ├── apidiff.yml
│ ├── ci.yml
│ └── trusted.yml
├── .gitignore
├── .golangci.yaml
├── .vimto.toml
├── CODEOWNERS
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── MAINTAINERS.md
├── Makefile
├── README.md
├── asm/
│ ├── alu.go
│ ├── alu_string.go
│ ├── doc.go
│ ├── dsl_test.go
│ ├── func.go
│ ├── func_lin.go
│ ├── func_string.go
│ ├── func_win.go
│ ├── instruction.go
│ ├── instruction_test.go
│ ├── jump.go
│ ├── jump_string.go
│ ├── load_store.go
│ ├── load_store_string.go
│ ├── metadata.go
│ ├── metadata_test.go
│ ├── opcode.go
│ ├── opcode_string.go
│ ├── opcode_test.go
│ └── register.go
├── attachtype_string.go
├── btf/
│ ├── btf.go
│ ├── btf_test.go
│ ├── btf_types.go
│ ├── btf_types_string.go
│ ├── core.go
│ ├── core_reloc_test.go
│ ├── core_test.go
│ ├── dedup.go
│ ├── dedup_test.go
│ ├── doc.go
│ ├── ext_info.go
│ ├── ext_info_test.go
│ ├── feature.go
│ ├── feature_test.go
│ ├── format.go
│ ├── format_test.go
│ ├── fuzz_test.go
│ ├── handle.go
│ ├── handle_test.go
│ ├── kernel.go
│ ├── kernel_test.go
│ ├── marshal.go
│ ├── marshal_test.go
│ ├── strings.go
│ ├── strings_test.go
│ ├── testdata/
│ │ ├── bpf_core_read.h
│ │ ├── btf_testmod.btf
│ │ ├── btf_testmod.btf.base
│ │ ├── fuzz/
│ │ │ └── FuzzExtInfo/
│ │ │ ├── 50a33736610b4a0945179db4c8a88e8247b05fbb25f50ed81e5393baf29bc5bc
│ │ │ ├── 72534f53bd90cb52a017013499b11511535c1295bf0e22f856148c02454c323e
│ │ │ └── a87a26efa64ed50b598ae8e333301d57d5f234527730f042d68ccc736e90c9fa
│ │ ├── relocs-eb.elf
│ │ ├── relocs-el.elf
│ │ ├── relocs.c
│ │ ├── relocs_enum-eb.elf
│ │ ├── relocs_enum-el.elf
│ │ ├── relocs_enum.c
│ │ ├── relocs_read-eb.elf
│ │ ├── relocs_read-el.elf
│ │ ├── relocs_read.c
│ │ ├── relocs_read_tgt-eb.elf
│ │ ├── relocs_read_tgt-el.elf
│ │ ├── relocs_read_tgt.c
│ │ ├── tags-eb.elf
│ │ ├── tags-el.elf
│ │ └── tags.c
│ ├── traversal.go
│ ├── traversal_test.go
│ ├── types.go
│ ├── types_test.go
│ ├── unmarshal.go
│ ├── unmarshal_test.go
│ ├── workarounds.go
│ └── workarounds_test.go
├── cmd/
│ └── bpf2go/
│ ├── README.md
│ ├── doc.go
│ ├── flags.go
│ ├── gen/
│ │ ├── compile.go
│ │ ├── compile_test.go
│ │ ├── doc.go
│ │ ├── output.go
│ │ ├── output.tpl
│ │ ├── output_test.go
│ │ ├── target.go
│ │ ├── target_test.go
│ │ ├── types.go
│ │ └── types_test.go
│ ├── internal/
│ │ └── module.go
│ ├── main.go
│ ├── main_test.go
│ ├── makedep.go
│ ├── makedep_test.go
│ ├── test/
│ │ ├── api_test.go
│ │ ├── doc.go
│ │ ├── test_bpfeb.go
│ │ ├── test_bpfeb.o
│ │ ├── test_bpfel.go
│ │ └── test_bpfel.o
│ ├── testdata/
│ │ ├── minimal-eb.elf
│ │ ├── minimal-el.elf
│ │ └── minimal.c
│ ├── tools.go
│ └── tools_test.go
├── collection.go
├── collection_other.go
├── collection_test.go
├── collection_windows.go
├── collection_windows_test.go
├── cpu.go
├── cpu_other.go
├── cpu_test.go
├── cpu_windows.go
├── doc.go
├── docs/
│ ├── .gitignore
│ ├── Makefile
│ ├── Pipfile
│ ├── README.md
│ ├── ebpf/
│ │ ├── about.md
│ │ ├── concepts/
│ │ │ ├── features.md
│ │ │ ├── global-variables.md
│ │ │ ├── loader.md
│ │ │ ├── object-lifecycle.md
│ │ │ ├── rlimit.md
│ │ │ └── section-naming.md
│ │ ├── contributing/
│ │ │ ├── architecture.md
│ │ │ ├── index.md
│ │ │ ├── new-example.md
│ │ │ ├── new-feature.md
│ │ │ └── windows.md
│ │ ├── guides/
│ │ │ ├── getting-started.md
│ │ │ ├── portable-ebpf.md
│ │ │ └── windows-support.md
│ │ ├── index.md
│ │ ├── stylesheets/
│ │ │ └── extra.css
│ │ └── users.md
│ ├── examples/
│ │ ├── docs.c
│ │ ├── docs_test.go
│ │ ├── features_test.go
│ │ ├── getting_started/
│ │ │ ├── counter.c
│ │ │ ├── counter_bpfeb.go
│ │ │ ├── counter_bpfeb.o
│ │ │ ├── counter_bpfel.go
│ │ │ ├── counter_bpfel.o
│ │ │ ├── gen.go
│ │ │ └── main.go
│ │ ├── rlimit_test.go
│ │ └── variables/
│ │ ├── gen.go
│ │ ├── main.go
│ │ ├── variables.c
│ │ ├── variables_bpfeb.go
│ │ ├── variables_bpfeb.o
│ │ ├── variables_bpfel.go
│ │ └── variables_bpfel.o
│ ├── includes/
│ │ └── glossary.md
│ ├── macros.py
│ ├── mkdocs.yml
│ ├── overrides/
│ │ └── partials/
│ │ └── source-file.html
│ └── vars.yml
├── elf_reader.go
├── elf_reader_test.go
├── elf_sections.go
├── example_sock_elf_test.go
├── example_sock_extract_dist_test.go
├── examples/
│ ├── README.md
│ ├── cgroup_skb/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── cgroup_skb.c
│ │ └── main.go
│ ├── fentry/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── fentry.c
│ │ └── main.go
│ ├── headers/
│ │ ├── LICENSE.BSD-2-Clause
│ │ ├── bpf_endian.h
│ │ ├── bpf_helper_defs.h
│ │ ├── bpf_helpers.h
│ │ ├── bpf_tracing.h
│ │ ├── common.h
│ │ └── update.sh
│ ├── kprobe/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── kprobe.c
│ │ └── main.go
│ ├── kprobe_percpu/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── kprobe_percpu.c
│ │ └── main.go
│ ├── kprobepin/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── kprobe_pin.c
│ │ └── main.go
│ ├── map_in_map/
│ │ └── main.go
│ ├── ringbuffer/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── main.go
│ │ └── ringbuffer.c
│ ├── sched_ext/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── main.go
│ │ └── sched_ext.c
│ ├── tcprtt/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── main.go
│ │ └── tcprtt.c
│ ├── tcprtt_sockops/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── bpf_sockops.h
│ │ ├── main.go
│ │ └── tcprtt_sockops.c
│ ├── tcx/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── main.go
│ │ └── tcx.c
│ ├── tracepoint_in_c/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── main.go
│ │ └── tracepoint.c
│ ├── tracepoint_in_go/
│ │ └── main.go
│ ├── uretprobe/
│ │ ├── bpf_x86_bpfel.go
│ │ ├── bpf_x86_bpfel.o
│ │ ├── main.go
│ │ └── uretprobe.c
│ ├── xdp/
│ │ ├── bpf_bpfeb.go
│ │ ├── bpf_bpfeb.o
│ │ ├── bpf_bpfel.go
│ │ ├── bpf_bpfel.o
│ │ ├── main.go
│ │ └── xdp.c
│ └── xdp_live_frame/
│ ├── bpf_bpfeb.go
│ ├── bpf_bpfeb.o
│ ├── bpf_bpfel.go
│ ├── bpf_bpfel.o
│ ├── main.go
│ └── xdp.c
├── features/
│ ├── doc.go
│ ├── link.go
│ ├── link_test.go
│ ├── map.go
│ ├── map_test.go
│ ├── misc.go
│ ├── misc_test.go
│ ├── prog.go
│ ├── prog_test.go
│ └── version.go
├── fuzz_test.go
├── go.mod
├── go.sum
├── helpers_test.go
├── info.go
├── info_test.go
├── internal/
│ ├── cmd/
│ │ ├── genfunctions.awk
│ │ ├── gensections.awk
│ │ └── genwinfunctions.awk
│ ├── deque.go
│ ├── deque_test.go
│ ├── efw/
│ │ ├── enums.go
│ │ ├── error_reporting.go
│ │ ├── error_reporting_test.go
│ │ ├── fd.go
│ │ ├── map.go
│ │ ├── module.go
│ │ ├── native.go
│ │ ├── object.go
│ │ ├── proc.go
│ │ ├── proc_test.go
│ │ ├── program.go
│ │ ├── result.go
│ │ ├── result_string_windows.go
│ │ ├── result_test.go
│ │ └── structs.go
│ ├── elf.go
│ ├── endian_be.go
│ ├── endian_le.go
│ ├── epoll/
│ │ ├── poller.go
│ │ └── poller_test.go
│ ├── errors.go
│ ├── errors_test.go
│ ├── feature.go
│ ├── feature_test.go
│ ├── io.go
│ ├── io_test.go
│ ├── kallsyms/
│ │ ├── cache.go
│ │ ├── kallsyms.go
│ │ ├── kallsyms_test.go
│ │ ├── reader.go
│ │ └── reader_test.go
│ ├── kconfig/
│ │ ├── kconfig.go
│ │ ├── kconfig_test.go
│ │ └── testdata/
│ │ └── test.kconfig
│ ├── linux/
│ │ ├── auxv.go
│ │ ├── auxv_test.go
│ │ ├── cpu.go
│ │ ├── cpu_test.go
│ │ ├── doc.go
│ │ ├── helper_test.go
│ │ ├── kconfig.go
│ │ ├── platform.go
│ │ ├── statfs.go
│ │ ├── statfs_test.go
│ │ ├── vdso.go
│ │ ├── vdso_test.go
│ │ ├── version.go
│ │ └── version_test.go
│ ├── math.go
│ ├── math_test.go
│ ├── nil.go
│ ├── output.go
│ ├── output_test.go
│ ├── platform/
│ │ ├── constants.go
│ │ ├── constants_test.go
│ │ ├── platform.go
│ │ ├── platform_linux.go
│ │ ├── platform_other.go
│ │ └── platform_windows.go
│ ├── prog.go
│ ├── sys/
│ │ ├── doc.go
│ │ ├── fd.go
│ │ ├── fd_linux_test.go
│ │ ├── fd_other.go
│ │ ├── fd_windows.go
│ │ ├── pinning_other.go
│ │ ├── pinning_windows.go
│ │ ├── ptr.go
│ │ ├── ptr_32_be.go
│ │ ├── ptr_32_le.go
│ │ ├── ptr_64.go
│ │ ├── ptr_test.go
│ │ ├── signals.go
│ │ ├── signals_test.go
│ │ ├── syscall.go
│ │ ├── syscall_other.go
│ │ ├── syscall_test.go
│ │ ├── syscall_windows.go
│ │ └── types.go
│ ├── sysenc/
│ │ ├── buffer.go
│ │ ├── buffer_test.go
│ │ ├── doc.go
│ │ ├── layout.go
│ │ ├── layout_test.go
│ │ ├── marshal.go
│ │ └── marshal_test.go
│ ├── testdata/
│ │ ├── errno524.log
│ │ ├── invalid-R0.log
│ │ ├── invalid-ctx-access.log
│ │ ├── invalid-member.log
│ │ └── issue-43.log
│ ├── testutils/
│ │ ├── bpffs_other.go
│ │ ├── bpffs_windows.go
│ │ ├── bpffs_windows_test.go
│ │ ├── cap.go
│ │ ├── cgroup.go
│ │ ├── chan.go
│ │ ├── checkers.go
│ │ ├── checkers_test.go
│ │ ├── cpu.go
│ │ ├── fd_other.go
│ │ ├── fd_windows.go
│ │ ├── feature.go
│ │ ├── feature_other.go
│ │ ├── feature_test.go
│ │ ├── feature_windows.go
│ │ ├── glob.go
│ │ ├── netns_linux.go
│ │ ├── netns_other.go
│ │ ├── programs.go
│ │ ├── rlimit.go
│ │ ├── seed.go
│ │ └── testmain/
│ │ ├── fd_trace.go
│ │ ├── main.go
│ │ ├── windows.go
│ │ └── windows_test.go
│ ├── tracefs/
│ │ ├── kprobe.go
│ │ ├── kprobe_test.go
│ │ ├── perf_event_test.go
│ │ ├── probetype_string.go
│ │ ├── uprobe.go
│ │ └── uprobe_test.go
│ ├── unix/
│ │ ├── doc.go
│ │ ├── errno_linux.go
│ │ ├── errno_linux_test.go
│ │ ├── errno_other.go
│ │ ├── errno_string_windows.go
│ │ ├── errno_test.go
│ │ ├── errno_windows.go
│ │ ├── error.go
│ │ ├── error_test.go
│ │ ├── strings_other.go
│ │ ├── strings_windows.go
│ │ ├── types_linux.go
│ │ └── types_other.go
│ ├── version.go
│ └── version_test.go
├── link/
│ ├── anchor.go
│ ├── cgroup.go
│ ├── cgroup_test.go
│ ├── doc.go
│ ├── helpers_windows_test.go
│ ├── iter.go
│ ├── iter_test.go
│ ├── kprobe.go
│ ├── kprobe_multi.go
│ ├── kprobe_multi_test.go
│ ├── kprobe_test.go
│ ├── link.go
│ ├── link_other.go
│ ├── link_other_test.go
│ ├── link_test.go
│ ├── link_windows.go
│ ├── link_windows_test.go
│ ├── netfilter.go
│ ├── netfilter_test.go
│ ├── netkit.go
│ ├── netkit_test.go
│ ├── netns.go
│ ├── netns_test.go
│ ├── perf_event.go
│ ├── perf_event_test.go
│ ├── program.go
│ ├── program_test.go
│ ├── query.go
│ ├── query_test.go
│ ├── raw_tracepoint.go
│ ├── raw_tracepoint_test.go
│ ├── socket_filter.go
│ ├── socket_filter_test.go
│ ├── struct_ops.go
│ ├── struct_ops_test.go
│ ├── syscalls.go
│ ├── syscalls_test.go
│ ├── tcx.go
│ ├── tcx_test.go
│ ├── tracepoint.go
│ ├── tracepoint_test.go
│ ├── tracing.go
│ ├── tracing_test.go
│ ├── uprobe.go
│ ├── uprobe_multi.go
│ ├── uprobe_multi_test.go
│ ├── uprobe_test.go
│ ├── xdp.go
│ └── xdp_test.go
├── linker.go
├── linker_test.go
├── map.go
├── map_test.go
├── marshaler_example_test.go
├── marshalers.go
├── marshalers_test.go
├── memory.go
├── memory_test.go
├── memory_unsafe.go
├── memory_unsafe_tag.go
├── memory_unsafe_test.go
├── netlify.toml
├── perf/
│ ├── doc.go
│ ├── reader.go
│ ├── reader_test.go
│ ├── ring.go
│ └── ring_test.go
├── pin/
│ ├── doc.go
│ ├── load.go
│ ├── load_test.go
│ ├── pin.go
│ ├── walk_other.go
│ ├── walk_test.go
│ └── walk_windows.go
├── prog.go
├── prog_linux_test.go
├── prog_test.go
├── ringbuf/
│ ├── doc.go
│ ├── helper_other_test.go
│ ├── helper_test.go
│ ├── helper_windows_test.go
│ ├── reader.go
│ ├── reader_other.go
│ ├── reader_test.go
│ ├── reader_windows.go
│ ├── ring.go
│ ├── ring_other.go
│ └── ring_windows.go
├── rlimit/
│ ├── doc.go
│ ├── rlimit_linux.go
│ ├── rlimit_linux_test.go
│ └── rlimit_other.go
├── scripts/
│ ├── update-efw-deps.sh
│ ├── update-kernel-deps.sh
│ └── windows/
│ ├── README.md
│ ├── Setup.ps1
│ ├── autounattend.xml
│ ├── setup-efw.sh
│ └── setup.sh
├── struct_ops.go
├── struct_ops_test.go
├── syscalls.go
├── syscalls_test.go
├── testdata/
│ ├── arena-eb.elf
│ ├── arena-el.elf
│ ├── arena.c
│ ├── btf_map_init-eb.elf
│ ├── btf_map_init-el.elf
│ ├── btf_map_init.c
│ ├── common.h
│ ├── constants-eb.elf
│ ├── constants-el.elf
│ ├── constants.c
│ ├── docker/
│ │ ├── Dockerfile
│ │ ├── IMAGE
│ │ ├── Makefile
│ │ ├── README.md
│ │ ├── VERSION
│ │ ├── llvm-snapshot.gpg.key
│ │ └── llvm.list
│ ├── errors-eb.elf
│ ├── errors-el.elf
│ ├── errors.c
│ ├── fentry_fexit-eb.elf
│ ├── fentry_fexit-el.elf
│ ├── fentry_fexit.c
│ ├── freplace-eb.elf
│ ├── freplace-el.elf
│ ├── freplace.c
│ ├── fwd_decl-eb.elf
│ ├── fwd_decl-el.elf
│ ├── fwd_decl.c
│ ├── invalid-kfunc-eb.elf
│ ├── invalid-kfunc-el.elf
│ ├── invalid-kfunc.c
│ ├── invalid_btf_map_init-eb.elf
│ ├── invalid_btf_map_init-el.elf
│ ├── invalid_btf_map_init.c
│ ├── invalid_map-eb.elf
│ ├── invalid_map-el.elf
│ ├── invalid_map.c
│ ├── invalid_map_static-eb.elf
│ ├── invalid_map_static-el.elf
│ ├── invalid_map_static.c
│ ├── iproute2_map_compat-eb.elf
│ ├── iproute2_map_compat-el.elf
│ ├── iproute2_map_compat.c
│ ├── kconfig-eb.elf
│ ├── kconfig-el.elf
│ ├── kconfig.c
│ ├── kfunc-eb.elf
│ ├── kfunc-el.elf
│ ├── kfunc-kmod-eb.elf
│ ├── kfunc-kmod-el.elf
│ ├── kfunc-kmod.c
│ ├── kfunc.c
│ ├── ksym-eb.elf
│ ├── ksym-el.elf
│ ├── ksym.c
│ ├── linked-el.elf
│ ├── linked.h
│ ├── linked1-el.elf
│ ├── linked1.c
│ ├── linked2-el.elf
│ ├── linked2.c
│ ├── loader-clang-14-eb.elf
│ ├── loader-clang-14-el.elf
│ ├── loader-clang-17-eb.elf
│ ├── loader-clang-17-el.elf
│ ├── loader-clang-20-eb.elf
│ ├── loader-clang-20-el.elf
│ ├── loader.c
│ ├── loader.h
│ ├── loader_nobtf-eb.elf
│ ├── loader_nobtf-el.elf
│ ├── loader_nobtf.h
│ ├── manyprogs-eb.elf
│ ├── manyprogs-el.elf
│ ├── manyprogs.c
│ ├── map_spin_lock-eb.elf
│ ├── map_spin_lock-el.elf
│ ├── map_spin_lock.c
│ ├── raw_tracepoint-eb.elf
│ ├── raw_tracepoint-el.elf
│ ├── raw_tracepoint.c
│ ├── strings-eb.elf
│ ├── strings-el.elf
│ ├── strings.c
│ ├── struct_ops-eb.elf
│ ├── struct_ops-el.elf
│ ├── struct_ops.c
│ ├── subprog_reloc-eb.elf
│ ├── subprog_reloc-el.elf
│ ├── subprog_reloc.c
│ ├── variables-eb.elf
│ ├── variables-el.elf
│ ├── variables.c
│ └── windows/
│ ├── LICENSE
│ └── cgroup_sock_addr.sys
├── types.go
├── types_string.go
├── types_windows.go
├── types_windows_test.go
├── variable.go
└── variable_test.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .clang-format
================================================
---
Language: Cpp
BasedOnStyle: LLVM
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: true
AlignEscapedNewlines: DontAlign
# mkdocs annotations in source code are written as trailing comments
# and alignment pushes these really far away from the content.
AlignTrailingComments: false
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortFunctionsOnASingleLine: false
BreakBeforeBraces: Attach
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: false
TabWidth: 4
UseTab: ForContinuationAndIndentation
ColumnLimit: 1000
# Go compiler comments need to stay unindented.
CommentPragmas: '^go:.*'
# linux/bpf.h needs to be included before bpf/bpf_helpers.h for types like __u64
# and sorting makes this impossible.
SortIncludes: false
...
================================================
FILE: .gitattributes
================================================
# Force line ending normalisation
* text=auto
# Show types.go in the PR diff view by default
internal/sys/types.go linguist-generated=false
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.yml
================================================
name: Bug report
description: Create a report to help us improve
labels: ["bug"]
assignees: []
body:
- type: markdown
attributes:
value: "Thank you for reporting a bug. Please fill out the fields below."
- type: textarea
attributes:
label: Describe the bug
description: |
A clear and concise description of what the bug is.
Include what you expected to happen instead.
validations:
required: true
- type: textarea
attributes:
label: How to reproduce
description: "Steps to reproduce the behavior."
validations:
required: true
- type: input
id: version
attributes:
label: Version information
description: The output of `go list -m github.com/cilium/ebpf`.
placeholder: github.com/cilium/ebpf vX.Y.Z
validations:
required: true
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
contact_links:
- name: Questions
url: https://github.com/cilium/ebpf/discussions/categories/q-a
about: Please ask and answer questions here.
- name: Slack
url: https://cilium.slack.com/messages/ebpf-go
about: Join our slack.
================================================
FILE: .github/dependabot.yml
================================================
---
version: 2
updates:
- package-ecosystem: "pip"
directory: "/docs"
schedule:
interval: "monthly"
allow:
# Only manage direct dependencies in Pipfile, ignore transient
# dependencies only appearing in Pipfile.lock.
- dependency-name: "*"
dependency-type: "direct"
groups:
docs:
dependency-type: production
applies-to: version-updates
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
================================================
FILE: .github/workflows/apidiff.yml
================================================
name: apidiff
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
go-apidiff:
name: go-apidiff
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
- name: Run go-apidiff
id: apidiff
continue-on-error: true
uses: joelanford/go-apidiff@main
- name: Create apidiff.json
run: |
echo '{"id": ${{ github.event.pull_request.number }}, "semver-type": "${{ steps.apidiff.outputs.semver-type }}"}' > apidiff.json
- name: Upload apidiff.json
uses: actions/upload-artifact@v7
with:
name: apidiff
path: apidiff.json
================================================
FILE: .github/workflows/ci.yml
================================================
name: ci
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
TMPDIR: /tmp
CI_MAX_KERNEL_VERSION: '6.18'
CI_MAX_EFW_VERSION: '1.0.0-rc2'
CI_MIN_CLANG_VERSION: '13'
go_version: '~1.25'
prev_go_version: '~1.24'
CGO_ENABLED: '0'
# Sync with Pipfile and netlify.toml.
python_version: '~3.13'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
build-and-lint:
name: Build and Lint
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '${{ env.go_version }}'
- name: Run staticcheck
uses: dominikh/staticcheck-action@v1
with:
version: "master"
install-go: false
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v9.2.0
- name: Generate and format code
run: |
make clean && make container-all
if ! git diff --exit-code; then
echo "found unformatted source files, or generated files are not up to date, run 'make'" >&2
exit 1
fi
- name: Test bpf2go
run: |
go test -v ./cmd/bpf2go
- name: Build
run: go build -v ./...
cross-build:
name: Cross build
runs-on: ubuntu-22.04
needs: build-and-lint
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '${{ env.go_version }}'
- name: Cross build darwin
env:
GOOS: darwin
run: |
go build -v ./...
go test -c -o /dev/null ./... >/dev/null
- name: Cross build arm32
env:
GOARCH: arm
GOARM: 6
run: |
go build -v ./...
go test -c -o /dev/null ./... >/dev/null
- name: Cross build wasm
env:
GOOS: js
GOARCH: wasm
run: |
go build -v ./...
go test -c -o /dev/null ./... >/dev/null
build-docs:
name: Build Documentation
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
# The mkdocs git-authors plugin needs access to the full revision
# history to correctly generate its statistics.
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '${{ env.go_version }}'
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '${{ env.python_version }}'
cache: 'pipenv'
- name: Install pipenv
run: pip3 install pipenv
- name: Install Dependencies
run: pipenv install
working-directory: ./docs
- name: Build Documentation
run: make build
working-directory: ./docs
test-on-prev-go:
name: Run tests on previous stable Go
runs-on: ubuntu-latest
needs: build-and-lint
timeout-minutes: 15
env:
CI_KERNEL_SELFTESTS: '/usr/src/linux/tools/testing/selftests/bpf'
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '${{ env.prev_go_version }}'
- run: go install lmb.io/vimto@latest
- run: go install gotest.tools/gotestsum@v1.12.3
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86
- run: sudo chmod 0666 /dev/kvm
- name: Test
env:
GOTRACEBACK: crash
CGO_ENABLED: 1 # CGo is required by `-race`
run: |
gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :stable-selftests -- go test -race -timeout 5m -short -count 1 -json ./...
- name: Benchmark
run: vimto -kernel :stable-selftests -- go test -short -run '^$' -bench . -benchtime=1x ./...
- name: Upload coredumps
uses: actions/upload-artifact@v7
if: ${{ failure() }}
with:
name: cores
if-no-files-found: ignore
path: |
**/core-*
**/*.test
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v7
with:
name: Test Results (previous stable Go)
path: junit.xml
test-on-arm64:
name: Run tests on arm64
runs-on: ubuntu-24.04-arm64
needs: build-and-lint
timeout-minutes: 15
env:
EBPF_TEST_IGNORE_VERSION: 'TestKprobeMulti,TestKprobeMultiErrors,TestKprobeMultiCookie,TestKprobeMultiProgramCall,TestHaveBPFLinkKprobeMulti,TestKprobeSession,TestHaveBPFLinkKprobeSession,TestHaveProgramType/LircMode2'
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '${{ env.go_version }}'
- run: go install gotest.tools/gotestsum@v1.12.3
- name: Test
# Skip TestGoarches/loong64 because the GH arm64 Go toolchain seems to be weird.
# Ubuntu 24.04 crashes when executing TestKfunc.
run: gotestsum --ignore-non-json-output-lines --junitfile junit.xml -- -exec 'sudo -E' -short -count 1 -skip '^TestGoarches/loong64$' -skip '^TestKfunc$' -json ./...
- name: Benchmark
run: go test -exec sudo -short -run '^$' -bench . -benchtime=1x ./...
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v7
with:
name: Test Results (arm64)
path: junit.xml
- name: Show dmesg
if: failure()
run: |
sudo dmesg
linux-test:
name: Run tests (Linux)
runs-on: ubuntu-latest
needs: build-and-lint
timeout-minutes: 15
strategy:
matrix:
tag:
- "mainline"
- "stable"
- "6.12"
- "6.6"
- "6.1"
- "5.15"
- "5.10"
- "5.4"
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '${{ env.go_version }}'
- run: go install gotest.tools/gotestsum@v1.12.3
- run: go install lmb.io/vimto@latest
- run: sudo apt-get update && sudo apt-get install -y --no-install-recommends qemu-system-x86
- run: sudo chmod 0666 /dev/kvm
- name: Test
run: gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml -- vimto -kernel :${{ matrix.tag }} -- go test -short -count 1 -json ./...
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v7
with:
name: Test Results (linux ${{ matrix.tag }})
path: junit.xml
windows-test:
name: Run tests (Windows)
runs-on: windows-2022
needs: build-and-lint
timeout-minutes: 15
strategy:
matrix:
version:
- "main"
- "1.0.0-rc1"
env:
# Fix slow Go compile and cache restore
# See https://github.com/actions/setup-go/pull/515
GOCACHE: D:\gocache
GOMODCACHE: D:\gomodcache
# Avoid putting temp on slow C:
TEMP: D:\temp
CI_EFW_VERSION: "0.21.0"
steps:
- run: mkdir D:\temp
shell: pwsh
- name: Get eBPF for Windows download URL
id: determine-url
uses: actions/github-script@v8
with:
script: |
if ("${{ matrix.version }}" != "main") {
// Use version from matrix to fetch from release
const version = "${{ matrix.version }}";
const releaseTag = `Release-v${version}`;
console.log(`Fetching release: ${releaseTag}`);
// Get the release by tag
const release = await github.rest.repos.getReleaseByTag({
owner: 'microsoft',
repo: 'ebpf-for-windows',
tag: releaseTag
});
if (!release.data) {
core.setFailed(`Release ${releaseTag} not found`);
return;
}
console.log(`Found release: ${release.data.name}`);
// Find the Build.Debug.x64.zip asset
const assetName = 'Build.Debug.x64.zip';
const asset = release.data.assets.find(a => a.name === assetName);
if (!asset) {
console.log('Available assets:', release.data.assets.map(a => a.name));
core.setFailed(`${assetName} asset not found in release ${releaseTag}`);
return;
}
const download_url = asset.browser_download_url;
console.log(`Download URL: ${download_url}`);
core.setOutput('download_url', download_url);
return
}
// Get the latest successful merge_group run
const workflow_runs = await github.rest.actions.listWorkflowRuns({
owner: 'microsoft',
repo: 'ebpf-for-windows',
workflow_id: 'cicd.yml',
event: 'schedule',
branch: 'main',
status: 'completed',
per_page: 1
});
if (workflow_runs.data.workflow_runs.length === 0) {
core.setFailed('No successful merge_group workflow runs found');
return;
}
// Get artifacts from this run
const run_id = workflow_runs.data.workflow_runs[0].id;
const run_url = workflow_runs.data.workflow_runs[0].html_url;
console.log(`Using workflow run: ${run_url}`);
// Paginate through all artifacts
let allArtifacts = [];
let page = 1;
while (true) {
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: 'microsoft',
repo: 'ebpf-for-windows',
run_id: run_id,
per_page: 100,
page: page
});
allArtifacts = allArtifacts.concat(artifacts.data.artifacts);
// If we got fewer than 100, we've reached the last page
if (artifacts.data.artifacts.length < 100) break;
page++;
}
// Find the specific artifact
const artifact = allArtifacts.find(a => a.name === 'Build-x64-Debug');
if (!artifact) {
console.log('Available artifacts:', artifacts.data.artifacts.map(a => a.name));
core.setFailed('Build-x64-Debug artifact not found in the workflow run');
return;
}
// Get the download URL via redirect
const response = await github.rest.actions.downloadArtifact({
owner: 'microsoft',
repo: 'ebpf-for-windows',
artifact_id: artifact.id,
archive_format: 'zip',
request: {
redirect: 'manual'
}
});
// Extract the location header which contains the actual download URL
const download_url = response.url;
if (!download_url) {
core.setFailed('Failed to get redirect URL from headers');
return;
}
core.setOutput('download_url', download_url);
- name: Download and Install eBPF for Windows
shell: pwsh
run: |
Invoke-WebRequest -Uri "${{ steps.determine-url.outputs.download_url }}" -OutFile "$env:TEMP\efw.zip"
if ("${{ matrix.version }}" -eq "main") {
# Workflow artifact has nested structure: outer zip contains build-Debug.zip
Expand-Archive -Path "$env:TEMP\efw.zip" -DestinationPath "$env:TEMP"
Expand-Archive -Path "$env:TEMP\build-Debug.zip" -DestinationPath "$env:TEMP\ebpf"
} else {
# Release asset is the final zip, extract directly
Expand-Archive -Path "$env:TEMP\efw.zip" -DestinationPath "$env:TEMP\ebpf"
}
$setupScript = Get-ChildItem -Path "$env:TEMP\ebpf" -Filter "install_ebpf.psm1" -Recurse | Select-Object -First 1
if ($setupScript) {
Write-Host "Found setup script: $($setupScript.FullName)"
$releasePath = "$env:TEMP\ebpf\release"
Rename-Item -Path $setupScript.DirectoryName -NewName $releasePath
Write-Host "Renamed directory to: $releasePath"
Set-Location -Path $releasePath
Write-Host "Changed directory to: $(Get-Location)"
Import-Module .\\install_ebpf.psm1 -ArgumentList ($pwd, "install.log") -Force
Get-PSExec
Install-eBPFComponents -KmTracing $false -KmTraceType "file" -TestMode "Normal"
} else {
Write-Error "Setup script not found in the extracted package"
exit 1
}
- name: Add eBPF for Windows to PATH
shell: pwsh
run: echo "C:\Program Files\ebpf-for-windows\" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '${{ env.go_version }}'
- run: go install gotest.tools/gotestsum@v1.12.3
- name: Test
run: >
gotestsum --raw-command --ignore-non-json-output-lines --junitfile junit.xml --
go test -short -count 1 -json ./...
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v7
with:
name: Test Results (windows ${{ matrix.version }})
path: junit.xml
results:
name: Results
runs-on: ubuntu-latest
needs:
- build-and-lint
- cross-build
- build-docs
- test-on-prev-go
- test-on-arm64
- linux-test
- windows-test
if: always()
steps:
- name: Check Results
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
echo "Some checks failed"
exit 1
else
echo "All checks passed successfully"
fi
================================================
FILE: .github/workflows/trusted.yml
================================================
on:
workflow_run:
workflows: ["apidiff"]
types:
- completed
permissions:
pull-requests: write
jobs:
tag-breaking-change:
name: Tag breaking changes
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request'
steps:
- name: 'Download artifact'
uses: actions/github-script@v8
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "apidiff"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/apidiff.zip', Buffer.from(download.data));
- run: unzip apidiff.zip
- name: 'Add or remove label'
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
var jsonData = JSON.parse(fs.readFileSync('apidiff.json', 'utf8'));
var issueNumber = jsonData.id;
var semverType = jsonData["semver-type"];
if (semverType === 'major') {
// Add 'breaking-change' label
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: ['breaking-change']
});
} else {
// Remove 'breaking-change' label if it exists
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
name: 'breaking-change'
});
} catch (error) {
console.log('Label breaking-change not found or already removed');
}
}
================================================
FILE: .gitignore
================================================
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.o
!*_bpf*.o
# Test binary, build with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
================================================
FILE: .golangci.yaml
================================================
version: "2"
linters:
default: none
enable:
- depguard
- govet
- ineffassign
- misspell
- unused
settings:
depguard:
rules:
no-x-sys-unix:
files:
- '!**/internal/unix/*.go'
- '!**/examples/**/*.go'
- '!**/docs/**/*.go'
deny:
- pkg: golang.org/x/sys/unix
desc: use internal/unix instead
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- github.com/cilium/ebpf
================================================
FILE: .vimto.toml
================================================
kernel="ghcr.io/cilium/ci-kernels:stable"
smp="cpus=2"
memory="1G"
user="root"
setup=[
"mount -t cgroup2 -o nosuid,noexec,nodev cgroup2 /sys/fs/cgroup",
"/bin/sh -c 'modprobe bpf_testmod || true'",
"dmesg --clear",
]
teardown=[
"dmesg --read-clear",
]
================================================
FILE: CODEOWNERS
================================================
* @cilium/ebpf-lib-maintainers
/features/ @rgo3
/link/ @mmat11
/perf/ @florianl
/ringbuf/ @florianl
/btf/ @dylandreimerink
/docs/ @ti-mo
# Windows specific code.
/docs/**/windows*.md @cilium/ebpf-go-windows-reviewers
/internal/efw @cilium/ebpf-go-windows-reviewers
windows/ @cilium/ebpf-go-windows-reviewers # Folders
*windows*.go @cilium/ebpf-go-windows-reviewers # Go code
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at nathanjsweet at gmail dot com or i at lmb dot io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing to ebpf-go
Want to contribute to ebpf-go? There are a few things you need to know.
We wrote a [contribution guide](https://ebpf-go.dev/contributing/) to help you get started.
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017 Nathan Sweet
Copyright (c) 2018, 2019 Cloudflare
Copyright (c) 2019 Authors of Cilium
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: MAINTAINERS.md
================================================
# Maintainers
Maintainers can be found in the [Cilium Maintainers file](https://github.com/cilium/community/blob/main/roles/Maintainers.md)
================================================
FILE: Makefile
================================================
# The development version of clang is distributed as the 'clang' binary,
# while stable/released versions have a version number attached.
# Pin the default clang to a stable version.
CLANG ?= clang-20
STRIP ?= llvm-strip-20
OBJCOPY ?= llvm-objcopy-20
CFLAGS := -O2 -g -Wall -Werror -mcpu=v2 $(CFLAGS)
CI_KERNEL_URL ?= https://github.com/cilium/ci-kernels/raw/master/
# Obtain an absolute path to the directory of the Makefile.
# Assume the Makefile is in the root of the repository.
REPODIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
# Prefer podman if installed, otherwise use docker.
# Note: Setting the var at runtime will always override.
CONTAINER_ENGINE ?= $(if $(shell command -v podman),podman,docker)
# Configure container runtime arguments based on the container engine.
CONTAINER_RUN_ARGS := \
--env MAKEFLAGS \
--env BPF2GO_CC="$(CLANG)" \
--env BPF2GO_CFLAGS="$(CFLAGS)" \
--env HOME=/tmp \
-v "${REPODIR}":/ebpf -w /ebpf \
-v "$(shell go env GOCACHE)":/tmp/.cache/go-build \
-v "$(shell go env GOPATH)":/go \
-v "$(shell go env GOMODCACHE)":/go/pkg/mod
ifeq ($(CONTAINER_ENGINE), podman)
CONTAINER_RUN_ARGS += --log-driver=none --security-opt label=disable
else
CONTAINER_RUN_ARGS += --user "$(shell stat -c '%u:%g' ${REPODIR})"
endif
IMAGE := $(shell cat ${REPODIR}/testdata/docker/IMAGE)
VERSION := $(shell cat ${REPODIR}/testdata/docker/VERSION)
TARGETS_EL := \
testdata/linked1 \
testdata/linked2 \
testdata/linked
TARGETS := \
testdata/loader-clang-14 \
testdata/loader-clang-17 \
testdata/loader-$(CLANG) \
testdata/loader_nobtf \
testdata/manyprogs \
testdata/btf_map_init \
testdata/invalid_map \
testdata/raw_tracepoint \
testdata/invalid_map_static \
testdata/invalid_btf_map_init \
testdata/strings \
testdata/freplace \
testdata/fentry_fexit \
testdata/iproute2_map_compat \
testdata/map_spin_lock \
testdata/subprog_reloc \
testdata/fwd_decl \
testdata/kconfig \
testdata/ksym \
testdata/kfunc \
testdata/invalid-kfunc \
testdata/kfunc-kmod \
testdata/constants \
testdata/errors \
testdata/variables \
testdata/arena \
testdata/struct_ops \
btf/testdata/relocs \
btf/testdata/relocs_read \
btf/testdata/relocs_read_tgt \
btf/testdata/relocs_enum \
btf/testdata/tags \
cmd/bpf2go/testdata/minimal
HEADERS := $(wildcard testdata/*.h)
.PHONY: all clean container-all container-shell generate
.DEFAULT_TARGET = container-all
# Build all ELF binaries using a containerized LLVM toolchain.
container-all:
+${CONTAINER_ENGINE} run --rm -ti ${CONTAINER_RUN_ARGS} \
"${IMAGE}:${VERSION}" \
$(MAKE) all
# (debug) Drop the user into a shell inside the container as root.
# Set BPF2GO_ envs to make 'make generate' just work.
container-shell:
${CONTAINER_ENGINE} run --rm -ti ${CONTAINER_RUN_ARGS} \
"${IMAGE}:${VERSION}"
clean:
find "$(CURDIR)" -name "*.elf" -delete
find "$(CURDIR)" -name "*.o" -delete
format:
find . -type f -name "*.c" | xargs clang-format -i
all: format testdata update-external-deps
ln -srf testdata/loader-$(CLANG)-el.elf testdata/loader-el.elf
ln -srf testdata/loader-$(CLANG)-eb.elf testdata/loader-eb.elf
$(MAKE) generate
generate:
go generate -run "stringer" ./...
go generate -run "gentypes" ./...
go generate -skip "(gentypes|stringer)" ./...
testdata: $(addsuffix -el.elf,$(TARGETS)) $(addsuffix -eb.elf,$(TARGETS)) $(addsuffix -el.elf,$(TARGETS_EL))
testdata/loader-%-el.elf: testdata/loader.c $(HEADERS)
$* $(CFLAGS) -target bpfel -c $< -o $@
$(STRIP) -g $@
testdata/loader-%-eb.elf: testdata/loader.c $(HEADERS)
$* $(CFLAGS) -target bpfeb -c $< -o $@
$(STRIP) -g $@
testdata/loader_nobtf-el.elf: testdata/loader.c $(HEADERS)
$(CLANG) $(CFLAGS) -g0 -D__NOBTF__ -target bpfel -c $< -o $@
testdata/loader_nobtf-eb.elf: testdata/loader.c $(HEADERS)
$(CLANG) $(CFLAGS) -g0 -D__NOBTF__ -target bpfeb -c $< -o $@
%-el.elf: %.c $(HEADERS)
$(CLANG) $(CFLAGS) -target bpfel -c $< -o $@
$(STRIP) -g $@
%-eb.elf: %.c $(HEADERS)
$(CLANG) $(CFLAGS) -target bpfeb -c $< -o $@
$(STRIP) -g $@
testdata/linked-el.elf: testdata/linked1-el.elf testdata/linked2-el.elf
bpftool gen object $@ $^
.PHONY: update-external-deps
update-external-deps:
./scripts/update-kernel-deps.sh
./scripts/update-efw-deps.sh
================================================
FILE: README.md
================================================
# eBPF
[](https://pkg.go.dev/github.com/cilium/ebpf)

ebpf-go is a pure Go library that provides utilities for loading, compiling, and
debugging eBPF programs. It has minimal external dependencies and is intended to
be used in long running processes.
See [ebpf.io](https://ebpf.io) for complementary projects from the wider eBPF
ecosystem.
## Getting Started
Please take a look at our [Getting Started] guide.
[Contributions](https://ebpf-go.dev/contributing) are highly encouraged, as they highlight certain use cases of
eBPF and the library, and help shape the future of the project.
## Getting Help
The community actively monitors our [GitHub Discussions](https://github.com/cilium/ebpf/discussions) page.
Please search for existing threads before starting a new one. Refrain from
opening issues on the bug tracker if you're just starting out or if you're not
sure if something is a bug in the library code.
Alternatively, [join](https://ebpf.io/slack) the
[#ebpf-go](https://cilium.slack.com/messages/ebpf-go) channel on Slack if you
have other questions regarding the project. Note that this channel is ephemeral
and has its history erased past a certain point, which is less helpful for
others running into the same problem later.
## Packages
This library includes the following packages:
* [asm](https://pkg.go.dev/github.com/cilium/ebpf/asm) contains a basic
assembler, allowing you to write eBPF assembly instructions directly
within your Go code. (You don't need to use this if you prefer to write your eBPF program in C.)
* [cmd/bpf2go](https://pkg.go.dev/github.com/cilium/ebpf/cmd/bpf2go) allows
compiling and embedding eBPF programs written in C within Go code. As well as
compiling the C code, it auto-generates Go code for loading and manipulating
the eBPF program and map objects.
* [link](https://pkg.go.dev/github.com/cilium/ebpf/link) allows attaching eBPF
to various hooks
* [perf](https://pkg.go.dev/github.com/cilium/ebpf/perf) allows reading from a
`PERF_EVENT_ARRAY`
* [ringbuf](https://pkg.go.dev/github.com/cilium/ebpf/ringbuf) allows reading from a
`BPF_MAP_TYPE_RINGBUF` map
* [features](https://pkg.go.dev/github.com/cilium/ebpf/features) implements the equivalent
of `bpftool feature probe` for discovering BPF-related kernel features using native Go.
* [rlimit](https://pkg.go.dev/github.com/cilium/ebpf/rlimit) provides a convenient API to lift
the `RLIMIT_MEMLOCK` constraint on kernels before 5.11.
* [btf](https://pkg.go.dev/github.com/cilium/ebpf/btf) allows reading the BPF Type Format.
* [pin](https://pkg.go.dev/github.com/cilium/ebpf/pin) provides APIs for working with pinned objects on bpffs.
## Requirements
* A version of Go that is [supported by
upstream](https://golang.org/doc/devel/release.html#policy)
* Linux (amd64, arm64): CI is run against kernel.org LTS releases. >= 4.4 should work but EOL'ed
versions are not supported.
* Windows (amd64): CI is run against Windows Server 2022. Only the latest eBPF for Windows
release is supported.
* Other architectures are best effort. 32bit arches are not supported.
## License
MIT
### eBPF Gopher
The eBPF honeygopher is based on the Go gopher designed by Renee French.
[Getting Started]: https://ebpf-go.dev/guides/getting-started/
================================================
FILE: asm/alu.go
================================================
package asm
//go:generate go tool stringer -output alu_string.go -type=Source,Endianness,ALUOp
// Source of ALU / ALU64 / Branch operations
//
// msb lsb
// +------------+-+---+
// | op |S|cls|
// +------------+-+---+
type Source uint16
const sourceMask OpCode = 0x0008
// Source bitmask
const (
// InvalidSource is returned by getters when invoked
// on non ALU / branch OpCodes.
InvalidSource Source = 0xffff
// ImmSource src is from constant
ImmSource Source = 0x0000
// RegSource src is from register
RegSource Source = 0x0008
)
// The Endianness of a byte swap instruction.
type Endianness uint8
const endianMask = sourceMask
// Endian flags
const (
InvalidEndian Endianness = 0xff
// Convert to little endian
LE Endianness = 0x00
// Convert to big endian
BE Endianness = 0x08
)
// ALUOp are ALU / ALU64 operations
//
// msb lsb
// +-------+----+-+---+
// | EXT | OP |s|cls|
// +-------+----+-+---+
type ALUOp uint16
const aluMask OpCode = 0x3ff0
const (
// InvalidALUOp is returned by getters when invoked
// on non ALU OpCodes
InvalidALUOp ALUOp = 0xffff
// Add - addition
Add ALUOp = 0x0000
// Sub - subtraction
Sub ALUOp = 0x0010
// Mul - multiplication
Mul ALUOp = 0x0020
// Div - division
Div ALUOp = 0x0030
// SDiv - signed division
SDiv ALUOp = Div + 0x0100
// Or - bitwise or
Or ALUOp = 0x0040
// And - bitwise and
And ALUOp = 0x0050
// LSh - bitwise shift left
LSh ALUOp = 0x0060
// RSh - bitwise shift right
RSh ALUOp = 0x0070
// Neg - sign/unsign signing bit
Neg ALUOp = 0x0080
// Mod - modulo
Mod ALUOp = 0x0090
// SMod - signed modulo
SMod ALUOp = Mod + 0x0100
// Xor - bitwise xor
Xor ALUOp = 0x00a0
// Mov - move value from one place to another
Mov ALUOp = 0x00b0
// MovSX8 - move lower 8 bits, sign extended upper bits of target
MovSX8 ALUOp = Mov + 0x0100
// MovSX16 - move lower 16 bits, sign extended upper bits of target
MovSX16 ALUOp = Mov + 0x0200
// MovSX32 - move lower 32 bits, sign extended upper bits of target
MovSX32 ALUOp = Mov + 0x0300
// ArSh - arithmetic shift
ArSh ALUOp = 0x00c0
// Swap - endian conversions
Swap ALUOp = 0x00d0
)
// HostTo converts from host to another endianness.
func HostTo(endian Endianness, dst Register, size Size) Instruction {
var imm int64
switch size {
case Half:
imm = 16
case Word:
imm = 32
case DWord:
imm = 64
default:
return Instruction{OpCode: InvalidOpCode}
}
return Instruction{
OpCode: OpCode(ALUClass).SetALUOp(Swap).SetSource(Source(endian)),
Dst: dst,
Constant: imm,
}
}
// BSwap unconditionally reverses the order of bytes in a register.
func BSwap(dst Register, size Size) Instruction {
var imm int64
switch size {
case Half:
imm = 16
case Word:
imm = 32
case DWord:
imm = 64
default:
return Instruction{OpCode: InvalidOpCode}
}
return Instruction{
OpCode: OpCode(ALU64Class).SetALUOp(Swap),
Dst: dst,
Constant: imm,
}
}
// Op returns the OpCode for an ALU operation with a given source.
func (op ALUOp) Op(source Source) OpCode {
return OpCode(ALU64Class).SetALUOp(op).SetSource(source)
}
// Reg emits `dst (op) src`.
func (op ALUOp) Reg(dst, src Register) Instruction {
return Instruction{
OpCode: op.Op(RegSource),
Dst: dst,
Src: src,
}
}
// Imm emits `dst (op) value`.
func (op ALUOp) Imm(dst Register, value int32) Instruction {
return Instruction{
OpCode: op.Op(ImmSource),
Dst: dst,
Constant: int64(value),
}
}
// Op32 returns the OpCode for a 32-bit ALU operation with a given source.
func (op ALUOp) Op32(source Source) OpCode {
return OpCode(ALUClass).SetALUOp(op).SetSource(source)
}
// Reg32 emits `dst (op) src`, zeroing the upper 32 bit of dst.
func (op ALUOp) Reg32(dst, src Register) Instruction {
return Instruction{
OpCode: op.Op32(RegSource),
Dst: dst,
Src: src,
}
}
// Imm32 emits `dst (op) value`, zeroing the upper 32 bit of dst.
func (op ALUOp) Imm32(dst Register, value int32) Instruction {
return Instruction{
OpCode: op.Op32(ImmSource),
Dst: dst,
Constant: int64(value),
}
}
================================================
FILE: asm/alu_string.go
================================================
// Code generated by "stringer -output alu_string.go -type=Source,Endianness,ALUOp"; DO NOT EDIT.
package asm
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[InvalidSource-65535]
_ = x[ImmSource-0]
_ = x[RegSource-8]
}
const (
_Source_name_0 = "ImmSource"
_Source_name_1 = "RegSource"
_Source_name_2 = "InvalidSource"
)
func (i Source) String() string {
switch {
case i == 0:
return _Source_name_0
case i == 8:
return _Source_name_1
case i == 65535:
return _Source_name_2
default:
return "Source(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[InvalidEndian-255]
_ = x[LE-0]
_ = x[BE-8]
}
const (
_Endianness_name_0 = "LE"
_Endianness_name_1 = "BE"
_Endianness_name_2 = "InvalidEndian"
)
func (i Endianness) String() string {
switch {
case i == 0:
return _Endianness_name_0
case i == 8:
return _Endianness_name_1
case i == 255:
return _Endianness_name_2
default:
return "Endianness(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[InvalidALUOp-65535]
_ = x[Add-0]
_ = x[Sub-16]
_ = x[Mul-32]
_ = x[Div-48]
_ = x[SDiv-304]
_ = x[Or-64]
_ = x[And-80]
_ = x[LSh-96]
_ = x[RSh-112]
_ = x[Neg-128]
_ = x[Mod-144]
_ = x[SMod-400]
_ = x[Xor-160]
_ = x[Mov-176]
_ = x[MovSX8-432]
_ = x[MovSX16-688]
_ = x[MovSX32-944]
_ = x[ArSh-192]
_ = x[Swap-208]
}
const _ALUOp_name = "AddSubMulDivOrAndLShRShNegModXorMovArShSwapSDivSModMovSX8MovSX16MovSX32InvalidALUOp"
var _ALUOp_map = map[ALUOp]string{
0: _ALUOp_name[0:3],
16: _ALUOp_name[3:6],
32: _ALUOp_name[6:9],
48: _ALUOp_name[9:12],
64: _ALUOp_name[12:14],
80: _ALUOp_name[14:17],
96: _ALUOp_name[17:20],
112: _ALUOp_name[20:23],
128: _ALUOp_name[23:26],
144: _ALUOp_name[26:29],
160: _ALUOp_name[29:32],
176: _ALUOp_name[32:35],
192: _ALUOp_name[35:39],
208: _ALUOp_name[39:43],
304: _ALUOp_name[43:47],
400: _ALUOp_name[47:51],
432: _ALUOp_name[51:57],
688: _ALUOp_name[57:64],
944: _ALUOp_name[64:71],
65535: _ALUOp_name[71:83],
}
func (i ALUOp) String() string {
if str, ok := _ALUOp_map[i]; ok {
return str
}
return "ALUOp(" + strconv.FormatInt(int64(i), 10) + ")"
}
================================================
FILE: asm/doc.go
================================================
// Package asm is an assembler for eBPF bytecode.
package asm
================================================
FILE: asm/dsl_test.go
================================================
package asm
import (
"testing"
)
func TestDSL(t *testing.T) {
testcases := []struct {
name string
have Instruction
want Instruction
}{
{"Call", FnMapLookupElem.Call(), Instruction{OpCode: 0x85, Constant: 1}},
{"Exit", Return(), Instruction{OpCode: 0x95}},
{"LoadAbs", LoadAbs(2, Byte), Instruction{OpCode: 0x30, Constant: 2}},
{"Store", StoreMem(RFP, -4, R0, Word), Instruction{
OpCode: 0x63,
Dst: RFP,
Src: R0,
Offset: -4,
}},
{"Add.Imm", Add.Imm(R1, 22), Instruction{OpCode: 0x07, Dst: R1, Constant: 22}},
{"Add.Reg", Add.Reg(R1, R2), Instruction{OpCode: 0x0f, Dst: R1, Src: R2}},
{"Add.Imm32", Add.Imm32(R1, 22), Instruction{
OpCode: 0x04, Dst: R1, Constant: 22,
}},
{"JSGT.Imm", JSGT.Imm(R1, 4, "foo"), Instruction{
OpCode: 0x65, Dst: R1, Constant: 4, Offset: -1,
}.WithReference("foo")},
{"JSGT.Imm32", JSGT.Imm32(R1, -2, "foo"), Instruction{
OpCode: 0x66, Dst: R1, Constant: -2, Offset: -1,
}.WithReference("foo")},
{"JSLT.Reg", JSLT.Reg(R1, R2, "foo"), Instruction{
OpCode: 0xcd, Dst: R1, Src: R2, Offset: -1,
}.WithReference("foo")},
{"JSLT.Reg32", JSLT.Reg32(R1, R3, "foo"), Instruction{
OpCode: 0xce, Dst: R1, Src: R3, Offset: -1,
}.WithReference("foo")},
}
for _, tc := range testcases {
if !tc.have.equal(tc.want) {
t.Errorf("%s: have %v, want %v", tc.name, tc.have, tc.want)
}
}
}
================================================
FILE: asm/func.go
================================================
package asm
import "github.com/cilium/ebpf/internal/platform"
//go:generate go tool stringer -output func_string.go -type=BuiltinFunc
// BuiltinFunc is a built-in eBPF function.
type BuiltinFunc uint32
// BuiltinFuncForPlatform returns a platform specific function constant.
//
// Use this if the library doesn't provide a constant yet.
func BuiltinFuncForPlatform(plat string, value uint32) (BuiltinFunc, error) {
return platform.EncodeConstant[BuiltinFunc](plat, value)
}
// Call emits a function call.
func (fn BuiltinFunc) Call() Instruction {
return Instruction{
OpCode: OpCode(JumpClass).SetJumpOp(Call),
Constant: int64(fn),
}
}
================================================
FILE: asm/func_lin.go
================================================
// Code generated by internal/cmd/genfunctions.awk; DO NOT EDIT.
package asm
// Code in this file is derived from Linux, available under the GPL-2.0 WITH Linux-syscall-note.
import "github.com/cilium/ebpf/internal/platform"
// Built-in functions (Linux).
const (
FnUnspec = BuiltinFunc(platform.LinuxTag | 0) //lint:ignore SA4016 consistency
FnMapLookupElem = BuiltinFunc(platform.LinuxTag | 1)
FnMapUpdateElem = BuiltinFunc(platform.LinuxTag | 2)
FnMapDeleteElem = BuiltinFunc(platform.LinuxTag | 3)
FnProbeRead = BuiltinFunc(platform.LinuxTag | 4)
FnKtimeGetNs = BuiltinFunc(platform.LinuxTag | 5)
FnTracePrintk = BuiltinFunc(platform.LinuxTag | 6)
FnGetPrandomU32 = BuiltinFunc(platform.LinuxTag | 7)
FnGetSmpProcessorId = BuiltinFunc(platform.LinuxTag | 8)
FnSkbStoreBytes = BuiltinFunc(platform.LinuxTag | 9)
FnL3CsumReplace = BuiltinFunc(platform.LinuxTag | 10)
FnL4CsumReplace = BuiltinFunc(platform.LinuxTag | 11)
FnTailCall = BuiltinFunc(platform.LinuxTag | 12)
FnCloneRedirect = BuiltinFunc(platform.LinuxTag | 13)
FnGetCurrentPidTgid = BuiltinFunc(platform.LinuxTag | 14)
FnGetCurrentUidGid = BuiltinFunc(platform.LinuxTag | 15)
FnGetCurrentComm = BuiltinFunc(platform.LinuxTag | 16)
FnGetCgroupClassid = BuiltinFunc(platform.LinuxTag | 17)
FnSkbVlanPush = BuiltinFunc(platform.LinuxTag | 18)
FnSkbVlanPop = BuiltinFunc(platform.LinuxTag | 19)
FnSkbGetTunnelKey = BuiltinFunc(platform.LinuxTag | 20)
FnSkbSetTunnelKey = BuiltinFunc(platform.LinuxTag | 21)
FnPerfEventRead = BuiltinFunc(platform.LinuxTag | 22)
FnRedirect = BuiltinFunc(platform.LinuxTag | 23)
FnGetRouteRealm = BuiltinFunc(platform.LinuxTag | 24)
FnPerfEventOutput = BuiltinFunc(platform.LinuxTag | 25)
FnSkbLoadBytes = BuiltinFunc(platform.LinuxTag | 26)
FnGetStackid = BuiltinFunc(platform.LinuxTag | 27)
FnCsumDiff = BuiltinFunc(platform.LinuxTag | 28)
FnSkbGetTunnelOpt = BuiltinFunc(platform.LinuxTag | 29)
FnSkbSetTunnelOpt = BuiltinFunc(platform.LinuxTag | 30)
FnSkbChangeProto = BuiltinFunc(platform.LinuxTag | 31)
FnSkbChangeType = BuiltinFunc(platform.LinuxTag | 32)
FnSkbUnderCgroup = BuiltinFunc(platform.LinuxTag | 33)
FnGetHashRecalc = BuiltinFunc(platform.LinuxTag | 34)
FnGetCurrentTask = BuiltinFunc(platform.LinuxTag | 35)
FnProbeWriteUser = BuiltinFunc(platform.LinuxTag | 36)
FnCurrentTaskUnderCgroup = BuiltinFunc(platform.LinuxTag | 37)
FnSkbChangeTail = BuiltinFunc(platform.LinuxTag | 38)
FnSkbPullData = BuiltinFunc(platform.LinuxTag | 39)
FnCsumUpdate = BuiltinFunc(platform.LinuxTag | 40)
FnSetHashInvalid = BuiltinFunc(platform.LinuxTag | 41)
FnGetNumaNodeId = BuiltinFunc(platform.LinuxTag | 42)
FnSkbChangeHead = BuiltinFunc(platform.LinuxTag | 43)
FnXdpAdjustHead = BuiltinFunc(platform.LinuxTag | 44)
FnProbeReadStr = BuiltinFunc(platform.LinuxTag | 45)
FnGetSocketCookie = BuiltinFunc(platform.LinuxTag | 46)
FnGetSocketUid = BuiltinFunc(platform.LinuxTag | 47)
FnSetHash = BuiltinFunc(platform.LinuxTag | 48)
FnSetsockopt = BuiltinFunc(platform.LinuxTag | 49)
FnSkbAdjustRoom = BuiltinFunc(platform.LinuxTag | 50)
FnRedirectMap = BuiltinFunc(platform.LinuxTag | 51)
FnSkRedirectMap = BuiltinFunc(platform.LinuxTag | 52)
FnSockMapUpdate = BuiltinFunc(platform.LinuxTag | 53)
FnXdpAdjustMeta = BuiltinFunc(platform.LinuxTag | 54)
FnPerfEventReadValue = BuiltinFunc(platform.LinuxTag | 55)
FnPerfProgReadValue = BuiltinFunc(platform.LinuxTag | 56)
FnGetsockopt = BuiltinFunc(platform.LinuxTag | 57)
FnOverrideReturn = BuiltinFunc(platform.LinuxTag | 58)
FnSockOpsCbFlagsSet = BuiltinFunc(platform.LinuxTag | 59)
FnMsgRedirectMap = BuiltinFunc(platform.LinuxTag | 60)
FnMsgApplyBytes = BuiltinFunc(platform.LinuxTag | 61)
FnMsgCorkBytes = BuiltinFunc(platform.LinuxTag | 62)
FnMsgPullData = BuiltinFunc(platform.LinuxTag | 63)
FnBind = BuiltinFunc(platform.LinuxTag | 64)
FnXdpAdjustTail = BuiltinFunc(platform.LinuxTag | 65)
FnSkbGetXfrmState = BuiltinFunc(platform.LinuxTag | 66)
FnGetStack = BuiltinFunc(platform.LinuxTag | 67)
FnSkbLoadBytesRelative = BuiltinFunc(platform.LinuxTag | 68)
FnFibLookup = BuiltinFunc(platform.LinuxTag | 69)
FnSockHashUpdate = BuiltinFunc(platform.LinuxTag | 70)
FnMsgRedirectHash = BuiltinFunc(platform.LinuxTag | 71)
FnSkRedirectHash = BuiltinFunc(platform.LinuxTag | 72)
FnLwtPushEncap = BuiltinFunc(platform.LinuxTag | 73)
FnLwtSeg6StoreBytes = BuiltinFunc(platform.LinuxTag | 74)
FnLwtSeg6AdjustSrh = BuiltinFunc(platform.LinuxTag | 75)
FnLwtSeg6Action = BuiltinFunc(platform.LinuxTag | 76)
FnRcRepeat = BuiltinFunc(platform.LinuxTag | 77)
FnRcKeydown = BuiltinFunc(platform.LinuxTag | 78)
FnSkbCgroupId = BuiltinFunc(platform.LinuxTag | 79)
FnGetCurrentCgroupId = BuiltinFunc(platform.LinuxTag | 80)
FnGetLocalStorage = BuiltinFunc(platform.LinuxTag | 81)
FnSkSelectReuseport = BuiltinFunc(platform.LinuxTag | 82)
FnSkbAncestorCgroupId = BuiltinFunc(platform.LinuxTag | 83)
FnSkLookupTcp = BuiltinFunc(platform.LinuxTag | 84)
FnSkLookupUdp = BuiltinFunc(platform.LinuxTag | 85)
FnSkRelease = BuiltinFunc(platform.LinuxTag | 86)
FnMapPushElem = BuiltinFunc(platform.LinuxTag | 87)
FnMapPopElem = BuiltinFunc(platform.LinuxTag | 88)
FnMapPeekElem = BuiltinFunc(platform.LinuxTag | 89)
FnMsgPushData = BuiltinFunc(platform.LinuxTag | 90)
FnMsgPopData = BuiltinFunc(platform.LinuxTag | 91)
FnRcPointerRel = BuiltinFunc(platform.LinuxTag | 92)
FnSpinLock = BuiltinFunc(platform.LinuxTag | 93)
FnSpinUnlock = BuiltinFunc(platform.LinuxTag | 94)
FnSkFullsock = BuiltinFunc(platform.LinuxTag | 95)
FnTcpSock = BuiltinFunc(platform.LinuxTag | 96)
FnSkbEcnSetCe = BuiltinFunc(platform.LinuxTag | 97)
FnGetListenerSock = BuiltinFunc(platform.LinuxTag | 98)
FnSkcLookupTcp = BuiltinFunc(platform.LinuxTag | 99)
FnTcpCheckSyncookie = BuiltinFunc(platform.LinuxTag | 100)
FnSysctlGetName = BuiltinFunc(platform.LinuxTag | 101)
FnSysctlGetCurrentValue = BuiltinFunc(platform.LinuxTag | 102)
FnSysctlGetNewValue = BuiltinFunc(platform.LinuxTag | 103)
FnSysctlSetNewValue = BuiltinFunc(platform.LinuxTag | 104)
FnStrtol = BuiltinFunc(platform.LinuxTag | 105)
FnStrtoul = BuiltinFunc(platform.LinuxTag | 106)
FnSkStorageGet = BuiltinFunc(platform.LinuxTag | 107)
FnSkStorageDelete = BuiltinFunc(platform.LinuxTag | 108)
FnSendSignal = BuiltinFunc(platform.LinuxTag | 109)
FnTcpGenSyncookie = BuiltinFunc(platform.LinuxTag | 110)
FnSkbOutput = BuiltinFunc(platform.LinuxTag | 111)
FnProbeReadUser = BuiltinFunc(platform.LinuxTag | 112)
FnProbeReadKernel = BuiltinFunc(platform.LinuxTag | 113)
FnProbeReadUserStr = BuiltinFunc(platform.LinuxTag | 114)
FnProbeReadKernelStr = BuiltinFunc(platform.LinuxTag | 115)
FnTcpSendAck = BuiltinFunc(platform.LinuxTag | 116)
FnSendSignalThread = BuiltinFunc(platform.LinuxTag | 117)
FnJiffies64 = BuiltinFunc(platform.LinuxTag | 118)
FnReadBranchRecords = BuiltinFunc(platform.LinuxTag | 119)
FnGetNsCurrentPidTgid = BuiltinFunc(platform.LinuxTag | 120)
FnXdpOutput = BuiltinFunc(platform.LinuxTag | 121)
FnGetNetnsCookie = BuiltinFunc(platform.LinuxTag | 122)
FnGetCurrentAncestorCgroupId = BuiltinFunc(platform.LinuxTag | 123)
FnSkAssign = BuiltinFunc(platform.LinuxTag | 124)
FnKtimeGetBootNs = BuiltinFunc(platform.LinuxTag | 125)
FnSeqPrintf = BuiltinFunc(platform.LinuxTag | 126)
FnSeqWrite = BuiltinFunc(platform.LinuxTag | 127)
FnSkCgroupId = BuiltinFunc(platform.LinuxTag | 128)
FnSkAncestorCgroupId = BuiltinFunc(platform.LinuxTag | 129)
FnRingbufOutput = BuiltinFunc(platform.LinuxTag | 130)
FnRingbufReserve = BuiltinFunc(platform.LinuxTag | 131)
FnRingbufSubmit = BuiltinFunc(platform.LinuxTag | 132)
FnRingbufDiscard = BuiltinFunc(platform.LinuxTag | 133)
FnRingbufQuery = BuiltinFunc(platform.LinuxTag | 134)
FnCsumLevel = BuiltinFunc(platform.LinuxTag | 135)
FnSkcToTcp6Sock = BuiltinFunc(platform.LinuxTag | 136)
FnSkcToTcpSock = BuiltinFunc(platform.LinuxTag | 137)
FnSkcToTcpTimewaitSock = BuiltinFunc(platform.LinuxTag | 138)
FnSkcToTcpRequestSock = BuiltinFunc(platform.LinuxTag | 139)
FnSkcToUdp6Sock = BuiltinFunc(platform.LinuxTag | 140)
FnGetTaskStack = BuiltinFunc(platform.LinuxTag | 141)
FnLoadHdrOpt = BuiltinFunc(platform.LinuxTag | 142)
FnStoreHdrOpt = BuiltinFunc(platform.LinuxTag | 143)
FnReserveHdrOpt = BuiltinFunc(platform.LinuxTag | 144)
FnInodeStorageGet = BuiltinFunc(platform.LinuxTag | 145)
FnInodeStorageDelete = BuiltinFunc(platform.LinuxTag | 146)
FnDPath = BuiltinFunc(platform.LinuxTag | 147)
FnCopyFromUser = BuiltinFunc(platform.LinuxTag | 148)
FnSnprintfBtf = BuiltinFunc(platform.LinuxTag | 149)
FnSeqPrintfBtf = BuiltinFunc(platform.LinuxTag | 150)
FnSkbCgroupClassid = BuiltinFunc(platform.LinuxTag | 151)
FnRedirectNeigh = BuiltinFunc(platform.LinuxTag | 152)
FnPerCpuPtr = BuiltinFunc(platform.LinuxTag | 153)
FnThisCpuPtr = BuiltinFunc(platform.LinuxTag | 154)
FnRedirectPeer = BuiltinFunc(platform.LinuxTag | 155)
FnTaskStorageGet = BuiltinFunc(platform.LinuxTag | 156)
FnTaskStorageDelete = BuiltinFunc(platform.LinuxTag | 157)
FnGetCurrentTaskBtf = BuiltinFunc(platform.LinuxTag | 158)
FnBprmOptsSet = BuiltinFunc(platform.LinuxTag | 159)
FnKtimeGetCoarseNs = BuiltinFunc(platform.LinuxTag | 160)
FnImaInodeHash = BuiltinFunc(platform.LinuxTag | 161)
FnSockFromFile = BuiltinFunc(platform.LinuxTag | 162)
FnCheckMtu = BuiltinFunc(platform.LinuxTag | 163)
FnForEachMapElem = BuiltinFunc(platform.LinuxTag | 164)
FnSnprintf = BuiltinFunc(platform.LinuxTag | 165)
FnSysBpf = BuiltinFunc(platform.LinuxTag | 166)
FnBtfFindByNameKind = BuiltinFunc(platform.LinuxTag | 167)
FnSysClose = BuiltinFunc(platform.LinuxTag | 168)
FnTimerInit = BuiltinFunc(platform.LinuxTag | 169)
FnTimerSetCallback = BuiltinFunc(platform.LinuxTag | 170)
FnTimerStart = BuiltinFunc(platform.LinuxTag | 171)
FnTimerCancel = BuiltinFunc(platform.LinuxTag | 172)
FnGetFuncIp = BuiltinFunc(platform.LinuxTag | 173)
FnGetAttachCookie = BuiltinFunc(platform.LinuxTag | 174)
FnTaskPtRegs = BuiltinFunc(platform.LinuxTag | 175)
FnGetBranchSnapshot = BuiltinFunc(platform.LinuxTag | 176)
FnTraceVprintk = BuiltinFunc(platform.LinuxTag | 177)
FnSkcToUnixSock = BuiltinFunc(platform.LinuxTag | 178)
FnKallsymsLookupName = BuiltinFunc(platform.LinuxTag | 179)
FnFindVma = BuiltinFunc(platform.LinuxTag | 180)
FnLoop = BuiltinFunc(platform.LinuxTag | 181)
FnStrncmp = BuiltinFunc(platform.LinuxTag | 182)
FnGetFuncArg = BuiltinFunc(platform.LinuxTag | 183)
FnGetFuncRet = BuiltinFunc(platform.LinuxTag | 184)
FnGetFuncArgCnt = BuiltinFunc(platform.LinuxTag | 185)
FnGetRetval = BuiltinFunc(platform.LinuxTag | 186)
FnSetRetval = BuiltinFunc(platform.LinuxTag | 187)
FnXdpGetBuffLen = BuiltinFunc(platform.LinuxTag | 188)
FnXdpLoadBytes = BuiltinFunc(platform.LinuxTag | 189)
FnXdpStoreBytes = BuiltinFunc(platform.LinuxTag | 190)
FnCopyFromUserTask = BuiltinFunc(platform.LinuxTag | 191)
FnSkbSetTstamp = BuiltinFunc(platform.LinuxTag | 192)
FnImaFileHash = BuiltinFunc(platform.LinuxTag | 193)
FnKptrXchg = BuiltinFunc(platform.LinuxTag | 194)
FnMapLookupPercpuElem = BuiltinFunc(platform.LinuxTag | 195)
FnSkcToMptcpSock = BuiltinFunc(platform.LinuxTag | 196)
FnDynptrFromMem = BuiltinFunc(platform.LinuxTag | 197)
FnRingbufReserveDynptr = BuiltinFunc(platform.LinuxTag | 198)
FnRingbufSubmitDynptr = BuiltinFunc(platform.LinuxTag | 199)
FnRingbufDiscardDynptr = BuiltinFunc(platform.LinuxTag | 200)
FnDynptrRead = BuiltinFunc(platform.LinuxTag | 201)
FnDynptrWrite = BuiltinFunc(platform.LinuxTag | 202)
FnDynptrData = BuiltinFunc(platform.LinuxTag | 203)
FnTcpRawGenSyncookieIpv4 = BuiltinFunc(platform.LinuxTag | 204)
FnTcpRawGenSyncookieIpv6 = BuiltinFunc(platform.LinuxTag | 205)
FnTcpRawCheckSyncookieIpv4 = BuiltinFunc(platform.LinuxTag | 206)
FnTcpRawCheckSyncookieIpv6 = BuiltinFunc(platform.LinuxTag | 207)
FnKtimeGetTaiNs = BuiltinFunc(platform.LinuxTag | 208)
FnUserRingbufDrain = BuiltinFunc(platform.LinuxTag | 209)
FnCgrpStorageGet = BuiltinFunc(platform.LinuxTag | 210)
FnCgrpStorageDelete = BuiltinFunc(platform.LinuxTag | 211)
)
================================================
FILE: asm/func_string.go
================================================
// Code generated by "stringer -output func_string.go -type=BuiltinFunc"; DO NOT EDIT.
package asm
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[FnUnspec-0]
_ = x[FnMapLookupElem-1]
_ = x[FnMapUpdateElem-2]
_ = x[FnMapDeleteElem-3]
_ = x[FnProbeRead-4]
_ = x[FnKtimeGetNs-5]
_ = x[FnTracePrintk-6]
_ = x[FnGetPrandomU32-7]
_ = x[FnGetSmpProcessorId-8]
_ = x[FnSkbStoreBytes-9]
_ = x[FnL3CsumReplace-10]
_ = x[FnL4CsumReplace-11]
_ = x[FnTailCall-12]
_ = x[FnCloneRedirect-13]
_ = x[FnGetCurrentPidTgid-14]
_ = x[FnGetCurrentUidGid-15]
_ = x[FnGetCurrentComm-16]
_ = x[FnGetCgroupClassid-17]
_ = x[FnSkbVlanPush-18]
_ = x[FnSkbVlanPop-19]
_ = x[FnSkbGetTunnelKey-20]
_ = x[FnSkbSetTunnelKey-21]
_ = x[FnPerfEventRead-22]
_ = x[FnRedirect-23]
_ = x[FnGetRouteRealm-24]
_ = x[FnPerfEventOutput-25]
_ = x[FnSkbLoadBytes-26]
_ = x[FnGetStackid-27]
_ = x[FnCsumDiff-28]
_ = x[FnSkbGetTunnelOpt-29]
_ = x[FnSkbSetTunnelOpt-30]
_ = x[FnSkbChangeProto-31]
_ = x[FnSkbChangeType-32]
_ = x[FnSkbUnderCgroup-33]
_ = x[FnGetHashRecalc-34]
_ = x[FnGetCurrentTask-35]
_ = x[FnProbeWriteUser-36]
_ = x[FnCurrentTaskUnderCgroup-37]
_ = x[FnSkbChangeTail-38]
_ = x[FnSkbPullData-39]
_ = x[FnCsumUpdate-40]
_ = x[FnSetHashInvalid-41]
_ = x[FnGetNumaNodeId-42]
_ = x[FnSkbChangeHead-43]
_ = x[FnXdpAdjustHead-44]
_ = x[FnProbeReadStr-45]
_ = x[FnGetSocketCookie-46]
_ = x[FnGetSocketUid-47]
_ = x[FnSetHash-48]
_ = x[FnSetsockopt-49]
_ = x[FnSkbAdjustRoom-50]
_ = x[FnRedirectMap-51]
_ = x[FnSkRedirectMap-52]
_ = x[FnSockMapUpdate-53]
_ = x[FnXdpAdjustMeta-54]
_ = x[FnPerfEventReadValue-55]
_ = x[FnPerfProgReadValue-56]
_ = x[FnGetsockopt-57]
_ = x[FnOverrideReturn-58]
_ = x[FnSockOpsCbFlagsSet-59]
_ = x[FnMsgRedirectMap-60]
_ = x[FnMsgApplyBytes-61]
_ = x[FnMsgCorkBytes-62]
_ = x[FnMsgPullData-63]
_ = x[FnBind-64]
_ = x[FnXdpAdjustTail-65]
_ = x[FnSkbGetXfrmState-66]
_ = x[FnGetStack-67]
_ = x[FnSkbLoadBytesRelative-68]
_ = x[FnFibLookup-69]
_ = x[FnSockHashUpdate-70]
_ = x[FnMsgRedirectHash-71]
_ = x[FnSkRedirectHash-72]
_ = x[FnLwtPushEncap-73]
_ = x[FnLwtSeg6StoreBytes-74]
_ = x[FnLwtSeg6AdjustSrh-75]
_ = x[FnLwtSeg6Action-76]
_ = x[FnRcRepeat-77]
_ = x[FnRcKeydown-78]
_ = x[FnSkbCgroupId-79]
_ = x[FnGetCurrentCgroupId-80]
_ = x[FnGetLocalStorage-81]
_ = x[FnSkSelectReuseport-82]
_ = x[FnSkbAncestorCgroupId-83]
_ = x[FnSkLookupTcp-84]
_ = x[FnSkLookupUdp-85]
_ = x[FnSkRelease-86]
_ = x[FnMapPushElem-87]
_ = x[FnMapPopElem-88]
_ = x[FnMapPeekElem-89]
_ = x[FnMsgPushData-90]
_ = x[FnMsgPopData-91]
_ = x[FnRcPointerRel-92]
_ = x[FnSpinLock-93]
_ = x[FnSpinUnlock-94]
_ = x[FnSkFullsock-95]
_ = x[FnTcpSock-96]
_ = x[FnSkbEcnSetCe-97]
_ = x[FnGetListenerSock-98]
_ = x[FnSkcLookupTcp-99]
_ = x[FnTcpCheckSyncookie-100]
_ = x[FnSysctlGetName-101]
_ = x[FnSysctlGetCurrentValue-102]
_ = x[FnSysctlGetNewValue-103]
_ = x[FnSysctlSetNewValue-104]
_ = x[FnStrtol-105]
_ = x[FnStrtoul-106]
_ = x[FnSkStorageGet-107]
_ = x[FnSkStorageDelete-108]
_ = x[FnSendSignal-109]
_ = x[FnTcpGenSyncookie-110]
_ = x[FnSkbOutput-111]
_ = x[FnProbeReadUser-112]
_ = x[FnProbeReadKernel-113]
_ = x[FnProbeReadUserStr-114]
_ = x[FnProbeReadKernelStr-115]
_ = x[FnTcpSendAck-116]
_ = x[FnSendSignalThread-117]
_ = x[FnJiffies64-118]
_ = x[FnReadBranchRecords-119]
_ = x[FnGetNsCurrentPidTgid-120]
_ = x[FnXdpOutput-121]
_ = x[FnGetNetnsCookie-122]
_ = x[FnGetCurrentAncestorCgroupId-123]
_ = x[FnSkAssign-124]
_ = x[FnKtimeGetBootNs-125]
_ = x[FnSeqPrintf-126]
_ = x[FnSeqWrite-127]
_ = x[FnSkCgroupId-128]
_ = x[FnSkAncestorCgroupId-129]
_ = x[FnRingbufOutput-130]
_ = x[FnRingbufReserve-131]
_ = x[FnRingbufSubmit-132]
_ = x[FnRingbufDiscard-133]
_ = x[FnRingbufQuery-134]
_ = x[FnCsumLevel-135]
_ = x[FnSkcToTcp6Sock-136]
_ = x[FnSkcToTcpSock-137]
_ = x[FnSkcToTcpTimewaitSock-138]
_ = x[FnSkcToTcpRequestSock-139]
_ = x[FnSkcToUdp6Sock-140]
_ = x[FnGetTaskStack-141]
_ = x[FnLoadHdrOpt-142]
_ = x[FnStoreHdrOpt-143]
_ = x[FnReserveHdrOpt-144]
_ = x[FnInodeStorageGet-145]
_ = x[FnInodeStorageDelete-146]
_ = x[FnDPath-147]
_ = x[FnCopyFromUser-148]
_ = x[FnSnprintfBtf-149]
_ = x[FnSeqPrintfBtf-150]
_ = x[FnSkbCgroupClassid-151]
_ = x[FnRedirectNeigh-152]
_ = x[FnPerCpuPtr-153]
_ = x[FnThisCpuPtr-154]
_ = x[FnRedirectPeer-155]
_ = x[FnTaskStorageGet-156]
_ = x[FnTaskStorageDelete-157]
_ = x[FnGetCurrentTaskBtf-158]
_ = x[FnBprmOptsSet-159]
_ = x[FnKtimeGetCoarseNs-160]
_ = x[FnImaInodeHash-161]
_ = x[FnSockFromFile-162]
_ = x[FnCheckMtu-163]
_ = x[FnForEachMapElem-164]
_ = x[FnSnprintf-165]
_ = x[FnSysBpf-166]
_ = x[FnBtfFindByNameKind-167]
_ = x[FnSysClose-168]
_ = x[FnTimerInit-169]
_ = x[FnTimerSetCallback-170]
_ = x[FnTimerStart-171]
_ = x[FnTimerCancel-172]
_ = x[FnGetFuncIp-173]
_ = x[FnGetAttachCookie-174]
_ = x[FnTaskPtRegs-175]
_ = x[FnGetBranchSnapshot-176]
_ = x[FnTraceVprintk-177]
_ = x[FnSkcToUnixSock-178]
_ = x[FnKallsymsLookupName-179]
_ = x[FnFindVma-180]
_ = x[FnLoop-181]
_ = x[FnStrncmp-182]
_ = x[FnGetFuncArg-183]
_ = x[FnGetFuncRet-184]
_ = x[FnGetFuncArgCnt-185]
_ = x[FnGetRetval-186]
_ = x[FnSetRetval-187]
_ = x[FnXdpGetBuffLen-188]
_ = x[FnXdpLoadBytes-189]
_ = x[FnXdpStoreBytes-190]
_ = x[FnCopyFromUserTask-191]
_ = x[FnSkbSetTstamp-192]
_ = x[FnImaFileHash-193]
_ = x[FnKptrXchg-194]
_ = x[FnMapLookupPercpuElem-195]
_ = x[FnSkcToMptcpSock-196]
_ = x[FnDynptrFromMem-197]
_ = x[FnRingbufReserveDynptr-198]
_ = x[FnRingbufSubmitDynptr-199]
_ = x[FnRingbufDiscardDynptr-200]
_ = x[FnDynptrRead-201]
_ = x[FnDynptrWrite-202]
_ = x[FnDynptrData-203]
_ = x[FnTcpRawGenSyncookieIpv4-204]
_ = x[FnTcpRawGenSyncookieIpv6-205]
_ = x[FnTcpRawCheckSyncookieIpv4-206]
_ = x[FnTcpRawCheckSyncookieIpv6-207]
_ = x[FnKtimeGetTaiNs-208]
_ = x[FnUserRingbufDrain-209]
_ = x[FnCgrpStorageGet-210]
_ = x[FnCgrpStorageDelete-211]
_ = x[WindowsFnMapLookupElem-268435457]
_ = x[WindowsFnMapUpdateElem-268435458]
_ = x[WindowsFnMapDeleteElem-268435459]
_ = x[WindowsFnMapLookupAndDeleteElem-268435460]
_ = x[WindowsFnTailCall-268435461]
_ = x[WindowsFnGetPrandomU32-268435462]
_ = x[WindowsFnKtimeGetBootNs-268435463]
_ = x[WindowsFnGetSmpProcessorId-268435464]
_ = x[WindowsFnKtimeGetNs-268435465]
_ = x[WindowsFnCsumDiff-268435466]
_ = x[WindowsFnRingbufOutput-268435467]
_ = x[WindowsFnTracePrintk2-268435468]
_ = x[WindowsFnTracePrintk3-268435469]
_ = x[WindowsFnTracePrintk4-268435470]
_ = x[WindowsFnTracePrintk5-268435471]
_ = x[WindowsFnMapPushElem-268435472]
_ = x[WindowsFnMapPopElem-268435473]
_ = x[WindowsFnMapPeekElem-268435474]
_ = x[WindowsFnGetCurrentPidTgid-268435475]
_ = x[WindowsFnGetCurrentLogonId-268435476]
_ = x[WindowsFnIsCurrentAdmin-268435477]
_ = x[WindowsFnMemcpyS-268435478]
_ = x[WindowsFnMemcmpS-268435479]
_ = x[WindowsFnMemset-268435480]
_ = x[WindowsFnMemmoveS-268435481]
_ = x[WindowsFnGetSocketCookie-268435482]
_ = x[WindowsFnStrncpyS-268435483]
_ = x[WindowsFnStrncatS-268435484]
_ = x[WindowsFnStrnlenS-268435485]
_ = x[WindowsFnKtimeGetBootMs-268435486]
_ = x[WindowsFnKtimeGetMs-268435487]
_ = x[WindowsFnPerfEventOutput-268435488]
_ = x[WindowsFnGetCurrentProcessStartKey-268435489]
_ = x[WindowsFnGetCurrentThreadCreateTime-268435490]
}
const (
_BuiltinFunc_name_0 = "FnUnspecFnMapLookupElemFnMapUpdateElemFnMapDeleteElemFnProbeReadFnKtimeGetNsFnTracePrintkFnGetPrandomU32FnGetSmpProcessorIdFnSkbStoreBytesFnL3CsumReplaceFnL4CsumReplaceFnTailCallFnCloneRedirectFnGetCurrentPidTgidFnGetCurrentUidGidFnGetCurrentCommFnGetCgroupClassidFnSkbVlanPushFnSkbVlanPopFnSkbGetTunnelKeyFnSkbSetTunnelKeyFnPerfEventReadFnRedirectFnGetRouteRealmFnPerfEventOutputFnSkbLoadBytesFnGetStackidFnCsumDiffFnSkbGetTunnelOptFnSkbSetTunnelOptFnSkbChangeProtoFnSkbChangeTypeFnSkbUnderCgroupFnGetHashRecalcFnGetCurrentTaskFnProbeWriteUserFnCurrentTaskUnderCgroupFnSkbChangeTailFnSkbPullDataFnCsumUpdateFnSetHashInvalidFnGetNumaNodeIdFnSkbChangeHeadFnXdpAdjustHeadFnProbeReadStrFnGetSocketCookieFnGetSocketUidFnSetHashFnSetsockoptFnSkbAdjustRoomFnRedirectMapFnSkRedirectMapFnSockMapUpdateFnXdpAdjustMetaFnPerfEventReadValueFnPerfProgReadValueFnGetsockoptFnOverrideReturnFnSockOpsCbFlagsSetFnMsgRedirectMapFnMsgApplyBytesFnMsgCorkBytesFnMsgPullDataFnBindFnXdpAdjustTailFnSkbGetXfrmStateFnGetStackFnSkbLoadBytesRelativeFnFibLookupFnSockHashUpdateFnMsgRedirectHashFnSkRedirectHashFnLwtPushEncapFnLwtSeg6StoreBytesFnLwtSeg6AdjustSrhFnLwtSeg6ActionFnRcRepeatFnRcKeydownFnSkbCgroupIdFnGetCurrentCgroupIdFnGetLocalStorageFnSkSelectReuseportFnSkbAncestorCgroupIdFnSkLookupTcpFnSkLookupUdpFnSkReleaseFnMapPushElemFnMapPopElemFnMapPeekElemFnMsgPushDataFnMsgPopDataFnRcPointerRelFnSpinLockFnSpinUnlockFnSkFullsockFnTcpSockFnSkbEcnSetCeFnGetListenerSockFnSkcLookupTcpFnTcpCheckSyncookieFnSysctlGetNameFnSysctlGetCurrentValueFnSysctlGetNewValueFnSysctlSetNewValueFnStrtolFnStrtoulFnSkStorageGetFnSkStorageDeleteFnSendSignalFnTcpGenSyncookieFnSkbOutputFnProbeReadUserFnProbeReadKernelFnProbeReadUserStrFnProbeReadKernelStrFnTcpSendAckFnSendSignalThreadFnJiffies64FnReadBranchRecordsFnGetNsCurrentPidTgidFnXdpOutputFnGetNetnsCookieFnGetCurrentAncestorCgroupIdFnSkAssignFnKtimeGetBootNsFnSeqPrintfFnSeqWriteFnSkCgroupIdFnSkAncestorCgroupIdFnRingbufOutputFnRingbufReserveFnRingbufSubmitFnRingbufDiscardFnRingbufQueryFnCsumLevelFnSkcToTcp6SockFnSkcToTcpSockFnSkcToTcpTimewaitSockFnSkcToTcpRequestSockFnSkcToUdp6SockFnGetTaskStackFnLoadHdrOptFnStoreHdrOptFnReserveHdrOptFnInodeStorageGetFnInodeStorageDeleteFnDPathFnCopyFromUserFnSnprintfBtfFnSeqPrintfBtfFnSkbCgroupClassidFnRedirectNeighFnPerCpuPtrFnThisCpuPtrFnRedirectPeerFnTaskStorageGetFnTaskStorageDeleteFnGetCurrentTaskBtfFnBprmOptsSetFnKtimeGetCoarseNsFnImaInodeHashFnSockFromFileFnCheckMtuFnForEachMapElemFnSnprintfFnSysBpfFnBtfFindByNameKindFnSysCloseFnTimerInitFnTimerSetCallbackFnTimerStartFnTimerCancelFnGetFuncIpFnGetAttachCookieFnTaskPtRegsFnGetBranchSnapshotFnTraceVprintkFnSkcToUnixSockFnKallsymsLookupNameFnFindVmaFnLoopFnStrncmpFnGetFuncArgFnGetFuncRetFnGetFuncArgCntFnGetRetvalFnSetRetvalFnXdpGetBuffLenFnXdpLoadBytesFnXdpStoreBytesFnCopyFromUserTaskFnSkbSetTstampFnImaFileHashFnKptrXchgFnMapLookupPercpuElemFnSkcToMptcpSockFnDynptrFromMemFnRingbufReserveDynptrFnRingbufSubmitDynptrFnRingbufDiscardDynptrFnDynptrReadFnDynptrWriteFnDynptrDataFnTcpRawGenSyncookieIpv4FnTcpRawGenSyncookieIpv6FnTcpRawCheckSyncookieIpv4FnTcpRawCheckSyncookieIpv6FnKtimeGetTaiNsFnUserRingbufDrainFnCgrpStorageGetFnCgrpStorageDelete"
_BuiltinFunc_name_1 = "WindowsFnMapLookupElemWindowsFnMapUpdateElemWindowsFnMapDeleteElemWindowsFnMapLookupAndDeleteElemWindowsFnTailCallWindowsFnGetPrandomU32WindowsFnKtimeGetBootNsWindowsFnGetSmpProcessorIdWindowsFnKtimeGetNsWindowsFnCsumDiffWindowsFnRingbufOutputWindowsFnTracePrintk2WindowsFnTracePrintk3WindowsFnTracePrintk4WindowsFnTracePrintk5WindowsFnMapPushElemWindowsFnMapPopElemWindowsFnMapPeekElemWindowsFnGetCurrentPidTgidWindowsFnGetCurrentLogonIdWindowsFnIsCurrentAdminWindowsFnMemcpySWindowsFnMemcmpSWindowsFnMemsetWindowsFnMemmoveSWindowsFnGetSocketCookieWindowsFnStrncpySWindowsFnStrncatSWindowsFnStrnlenSWindowsFnKtimeGetBootMsWindowsFnKtimeGetMsWindowsFnPerfEventOutputWindowsFnGetCurrentProcessStartKeyWindowsFnGetCurrentThreadCreateTime"
)
var (
_BuiltinFunc_index_0 = [...]uint16{0, 8, 23, 38, 53, 64, 76, 89, 104, 123, 138, 153, 168, 178, 193, 212, 230, 246, 264, 277, 289, 306, 323, 338, 348, 363, 380, 394, 406, 416, 433, 450, 466, 481, 497, 512, 528, 544, 568, 583, 596, 608, 624, 639, 654, 669, 683, 700, 714, 723, 735, 750, 763, 778, 793, 808, 828, 847, 859, 875, 894, 910, 925, 939, 952, 958, 973, 990, 1000, 1022, 1033, 1049, 1066, 1082, 1096, 1115, 1133, 1148, 1158, 1169, 1182, 1202, 1219, 1238, 1259, 1272, 1285, 1296, 1309, 1321, 1334, 1347, 1359, 1373, 1383, 1395, 1407, 1416, 1429, 1446, 1460, 1479, 1494, 1517, 1536, 1555, 1563, 1572, 1586, 1603, 1615, 1632, 1643, 1658, 1675, 1693, 1713, 1725, 1743, 1754, 1773, 1794, 1805, 1821, 1849, 1859, 1875, 1886, 1896, 1908, 1928, 1943, 1959, 1974, 1990, 2004, 2015, 2030, 2044, 2066, 2087, 2102, 2116, 2128, 2141, 2156, 2173, 2193, 2200, 2214, 2227, 2241, 2259, 2274, 2285, 2297, 2311, 2327, 2346, 2365, 2378, 2396, 2410, 2424, 2434, 2450, 2460, 2468, 2487, 2497, 2508, 2526, 2538, 2551, 2562, 2579, 2591, 2610, 2624, 2639, 2659, 2668, 2674, 2683, 2695, 2707, 2722, 2733, 2744, 2759, 2773, 2788, 2806, 2820, 2833, 2843, 2864, 2880, 2895, 2917, 2938, 2960, 2972, 2985, 2997, 3021, 3045, 3071, 3097, 3112, 3130, 3146, 3165}
_BuiltinFunc_index_1 = [...]uint16{0, 22, 44, 66, 97, 114, 136, 159, 185, 204, 221, 243, 264, 285, 306, 327, 347, 366, 386, 412, 438, 461, 477, 493, 508, 525, 549, 566, 583, 600, 623, 642, 666, 700, 735}
)
func (i BuiltinFunc) String() string {
switch {
case i <= 211:
return _BuiltinFunc_name_0[_BuiltinFunc_index_0[i]:_BuiltinFunc_index_0[i+1]]
case 268435457 <= i && i <= 268435490:
i -= 268435457
return _BuiltinFunc_name_1[_BuiltinFunc_index_1[i]:_BuiltinFunc_index_1[i+1]]
default:
return "BuiltinFunc(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
================================================
FILE: asm/func_win.go
================================================
// Code generated by internal/cmd/genwinfunctions.awk; DO NOT EDIT.
package asm
// Code in this file is derived from eBPF for Windows, available under the MIT License.
import "github.com/cilium/ebpf/internal/platform"
// Built-in functions (Windows).
const (
WindowsFnMapLookupElem = BuiltinFunc(platform.WindowsTag | 1)
WindowsFnMapUpdateElem = BuiltinFunc(platform.WindowsTag | 2)
WindowsFnMapDeleteElem = BuiltinFunc(platform.WindowsTag | 3)
WindowsFnMapLookupAndDeleteElem = BuiltinFunc(platform.WindowsTag | 4)
WindowsFnTailCall = BuiltinFunc(platform.WindowsTag | 5)
WindowsFnGetPrandomU32 = BuiltinFunc(platform.WindowsTag | 6)
WindowsFnKtimeGetBootNs = BuiltinFunc(platform.WindowsTag | 7)
WindowsFnGetSmpProcessorId = BuiltinFunc(platform.WindowsTag | 8)
WindowsFnKtimeGetNs = BuiltinFunc(platform.WindowsTag | 9)
WindowsFnCsumDiff = BuiltinFunc(platform.WindowsTag | 10)
WindowsFnRingbufOutput = BuiltinFunc(platform.WindowsTag | 11)
WindowsFnTracePrintk2 = BuiltinFunc(platform.WindowsTag | 12)
WindowsFnTracePrintk3 = BuiltinFunc(platform.WindowsTag | 13)
WindowsFnTracePrintk4 = BuiltinFunc(platform.WindowsTag | 14)
WindowsFnTracePrintk5 = BuiltinFunc(platform.WindowsTag | 15)
WindowsFnMapPushElem = BuiltinFunc(platform.WindowsTag | 16)
WindowsFnMapPopElem = BuiltinFunc(platform.WindowsTag | 17)
WindowsFnMapPeekElem = BuiltinFunc(platform.WindowsTag | 18)
WindowsFnGetCurrentPidTgid = BuiltinFunc(platform.WindowsTag | 19)
WindowsFnGetCurrentLogonId = BuiltinFunc(platform.WindowsTag | 20)
WindowsFnIsCurrentAdmin = BuiltinFunc(platform.WindowsTag | 21)
WindowsFnMemcpyS = BuiltinFunc(platform.WindowsTag | 22)
WindowsFnMemcmpS = BuiltinFunc(platform.WindowsTag | 23)
WindowsFnMemset = BuiltinFunc(platform.WindowsTag | 24)
WindowsFnMemmoveS = BuiltinFunc(platform.WindowsTag | 25)
WindowsFnGetSocketCookie = BuiltinFunc(platform.WindowsTag | 26)
WindowsFnStrncpyS = BuiltinFunc(platform.WindowsTag | 27)
WindowsFnStrncatS = BuiltinFunc(platform.WindowsTag | 28)
WindowsFnStrnlenS = BuiltinFunc(platform.WindowsTag | 29)
WindowsFnKtimeGetBootMs = BuiltinFunc(platform.WindowsTag | 30)
WindowsFnKtimeGetMs = BuiltinFunc(platform.WindowsTag | 31)
WindowsFnPerfEventOutput = BuiltinFunc(platform.WindowsTag | 32)
WindowsFnGetCurrentProcessStartKey = BuiltinFunc(platform.WindowsTag | 33)
WindowsFnGetCurrentThreadCreateTime = BuiltinFunc(platform.WindowsTag | 34)
)
================================================
FILE: asm/instruction.go
================================================
package asm
import (
"crypto/sha1"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
"math"
"sort"
"strings"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/platform"
"github.com/cilium/ebpf/internal/sys"
)
// InstructionSize is the size of a BPF instruction in bytes
const InstructionSize = 8
// RawInstructionOffset is an offset in units of raw BPF instructions.
type RawInstructionOffset uint64
var ErrUnreferencedSymbol = errors.New("unreferenced symbol")
var ErrUnsatisfiedMapReference = errors.New("unsatisfied map reference")
var ErrUnsatisfiedProgramReference = errors.New("unsatisfied program reference")
// Bytes returns the offset of an instruction in bytes.
func (rio RawInstructionOffset) Bytes() uint64 {
return uint64(rio) * InstructionSize
}
// Instruction is a single eBPF instruction.
type Instruction struct {
OpCode OpCode
Dst Register
Src Register
Offset int16
Constant int64
// Metadata contains optional metadata about this instruction.
Metadata Metadata
}
// Width returns how many raw BPF instructions the Instruction occupies within
// an instruction stream. For example, an Instruction encoding a 64-bit value
// will typically occupy 2 raw instructions, while a 32-bit constant can be
// encoded in a single raw instruction.
func (ins *Instruction) Width() RawInstructionOffset {
return RawInstructionOffset(ins.OpCode.rawInstructions())
}
// Unmarshal decodes a BPF instruction.
func (ins *Instruction) Unmarshal(r io.Reader, bo binary.ByteOrder, platform string) error {
data := make([]byte, InstructionSize)
if _, err := io.ReadFull(r, data); err != nil {
return err
}
ins.OpCode = OpCode(data[0])
regs := data[1]
switch bo {
case binary.LittleEndian:
ins.Dst, ins.Src = Register(regs&0xF), Register(regs>>4)
case binary.BigEndian:
ins.Dst, ins.Src = Register(regs>>4), Register(regs&0xf)
}
ins.Offset = int16(bo.Uint16(data[2:4]))
// Convert to int32 before widening to int64
// to ensure the signed bit is carried over.
ins.Constant = int64(int32(bo.Uint32(data[4:8])))
if ins.IsBuiltinCall() {
if ins.Constant >= 0 {
// Leave negative constants from the instruction stream
// unchanged. These are sometimes used as placeholders for later
// patching.
// This relies on not having a valid platform tag with a high bit set.
fn, err := BuiltinFuncForPlatform(platform, uint32(ins.Constant))
if err != nil {
return err
}
ins.Constant = int64(fn)
}
} else if ins.OpCode.Class().IsALU() {
switch ins.OpCode.ALUOp() {
case Div:
if ins.Offset == 1 {
ins.OpCode = ins.OpCode.SetALUOp(SDiv)
ins.Offset = 0
}
case Mod:
if ins.Offset == 1 {
ins.OpCode = ins.OpCode.SetALUOp(SMod)
ins.Offset = 0
}
case Mov:
switch ins.Offset {
case 8:
ins.OpCode = ins.OpCode.SetALUOp(MovSX8)
ins.Offset = 0
case 16:
ins.OpCode = ins.OpCode.SetALUOp(MovSX16)
ins.Offset = 0
case 32:
ins.OpCode = ins.OpCode.SetALUOp(MovSX32)
ins.Offset = 0
}
}
} else if ins.OpCode.Class() == StXClass &&
ins.OpCode.Mode() == AtomicMode {
// For atomic ops, part of the opcode is stored in the
// constant field. Shift over 8 bytes so we can OR with the actual opcode and
// apply `atomicMask` to avoid merging unknown bits that may be added in the future.
ins.OpCode |= (OpCode((ins.Constant << 8)) & atomicMask)
}
if !ins.OpCode.IsDWordLoad() {
return nil
}
// Pull another instruction from the stream to retrieve the second
// half of the 64-bit immediate value.
if _, err := io.ReadFull(r, data); err != nil {
// No Wrap, to avoid io.EOF clash
return errors.New("64bit immediate is missing second half")
}
// Require that all fields other than the value are zero.
if bo.Uint32(data[0:4]) != 0 {
return errors.New("64bit immediate has non-zero fields")
}
cons1 := uint32(ins.Constant)
cons2 := int32(bo.Uint32(data[4:8]))
ins.Constant = int64(cons2)<<32 | int64(cons1)
return nil
}
// Marshal encodes a BPF instruction.
func (ins Instruction) Marshal(w io.Writer, bo binary.ByteOrder) (uint64, error) {
if ins.OpCode == InvalidOpCode {
return 0, errors.New("invalid opcode")
}
isDWordLoad := ins.OpCode.IsDWordLoad()
cons := int32(ins.Constant)
if isDWordLoad {
// Encode least significant 32bit first for 64bit operations.
cons = int32(uint32(ins.Constant))
}
regs, err := newBPFRegisters(ins.Dst, ins.Src, bo)
if err != nil {
return 0, fmt.Errorf("can't marshal registers: %s", err)
}
if ins.IsBuiltinCall() {
fn := BuiltinFunc(ins.Constant)
plat, value := platform.DecodeConstant(fn)
if plat != platform.Native {
return 0, fmt.Errorf("function %s (%s): %w", fn, plat, internal.ErrNotSupportedOnOS)
}
cons = int32(value)
} else if ins.OpCode.Class().IsALU() {
newOffset := int16(0)
switch ins.OpCode.ALUOp() {
case SDiv:
ins.OpCode = ins.OpCode.SetALUOp(Div)
newOffset = 1
case SMod:
ins.OpCode = ins.OpCode.SetALUOp(Mod)
newOffset = 1
case MovSX8:
ins.OpCode = ins.OpCode.SetALUOp(Mov)
newOffset = 8
case MovSX16:
ins.OpCode = ins.OpCode.SetALUOp(Mov)
newOffset = 16
case MovSX32:
ins.OpCode = ins.OpCode.SetALUOp(Mov)
newOffset = 32
}
if newOffset != 0 && ins.Offset != 0 {
return 0, fmt.Errorf("extended ALU opcodes should have an .Offset of 0: %s", ins)
}
ins.Offset = newOffset
} else if atomic := ins.OpCode.AtomicOp(); atomic != InvalidAtomic {
ins.OpCode = ins.OpCode &^ atomicMask
ins.Constant = int64(atomic >> 8)
}
op, err := ins.OpCode.bpfOpCode()
if err != nil {
return 0, err
}
data := make([]byte, InstructionSize)
data[0] = op
data[1] = byte(regs)
bo.PutUint16(data[2:4], uint16(ins.Offset))
bo.PutUint32(data[4:8], uint32(cons))
if _, err := w.Write(data); err != nil {
return 0, err
}
if !isDWordLoad {
return InstructionSize, nil
}
// The first half of the second part of a double-wide instruction
// must be zero. The second half carries the value.
bo.PutUint32(data[0:4], 0)
bo.PutUint32(data[4:8], uint32(ins.Constant>>32))
if _, err := w.Write(data); err != nil {
return 0, err
}
return 2 * InstructionSize, nil
}
// AssociateMap associates a Map with this Instruction.
//
// Implicitly clears the Instruction's Reference field.
//
// Returns an error if the Instruction is not a map load.
func (ins *Instruction) AssociateMap(m FDer) error {
if !ins.IsLoadFromMap() {
return errors.New("not a load from a map")
}
ins.Metadata.Set(referenceMeta{}, nil)
ins.Metadata.Set(mapMeta{}, m)
return nil
}
func (ins *Instruction) encodeMapFD(fd int) {
// Preserve the offset value for direct map loads.
offset := uint64(ins.Constant) & (math.MaxUint32 << 32)
rawFd := uint64(uint32(fd))
ins.Constant = int64(offset | rawFd)
}
// mapFd returns the map file descriptor stored in the 32 least significant
// bits of ins' Constant field.
func (ins *Instruction) mapFd() int {
return int(int32(ins.Constant))
}
// RewriteMapOffset changes the offset of a direct load from a map.
//
// Returns an error if the instruction is not a direct load.
func (ins *Instruction) RewriteMapOffset(offset uint32) error {
if !ins.OpCode.IsDWordLoad() {
return fmt.Errorf("%s is not a 64 bit load", ins.OpCode)
}
if ins.Src != PseudoMapValue {
return errors.New("not a direct load from a map")
}
fd := uint64(ins.Constant) & math.MaxUint32
ins.Constant = int64(uint64(offset)<<32 | fd)
return nil
}
func (ins *Instruction) mapOffset() uint32 {
return uint32(uint64(ins.Constant) >> 32)
}
// IsLoadFromMap returns true if the instruction loads from a map.
//
// This covers both loading the map pointer and direct map value loads.
func (ins *Instruction) IsLoadFromMap() bool {
return ins.OpCode == LoadImmOp(DWord) && (ins.Src == PseudoMapFD || ins.Src == PseudoMapValue)
}
// IsFunctionCall returns true if the instruction calls another BPF function.
//
// This is not the same thing as a BPF helper call.
func (ins *Instruction) IsFunctionCall() bool {
return ins.OpCode.JumpOp() == Call && ins.Src == PseudoCall
}
// IsKfuncCall returns true if the instruction calls a kfunc.
//
// This is not the same thing as a BPF helper call.
func (ins *Instruction) IsKfuncCall() bool {
return ins.OpCode.JumpOp() == Call && ins.Src == PseudoKfuncCall
}
// IsLoadOfFunctionPointer returns true if the instruction loads a function pointer.
func (ins *Instruction) IsLoadOfFunctionPointer() bool {
return ins.OpCode.IsDWordLoad() && ins.Src == PseudoFunc
}
// IsFunctionReference returns true if the instruction references another BPF
// function, either by invoking a Call jump operation or by loading a function
// pointer.
func (ins *Instruction) IsFunctionReference() bool {
return ins.IsFunctionCall() || ins.IsLoadOfFunctionPointer()
}
// IsBuiltinCall returns true if the instruction is a built-in call, i.e. BPF helper call.
func (ins *Instruction) IsBuiltinCall() bool {
return ins.OpCode.JumpOp() == Call && ins.Src == R0 && ins.Dst == R0
}
// IsConstantLoad returns true if the instruction loads a constant of the
// given size.
func (ins *Instruction) IsConstantLoad(size Size) bool {
return ins.OpCode == LoadImmOp(size) && ins.Src == R0 && ins.Offset == 0
}
// Format implements fmt.Formatter.
func (ins Instruction) Format(f fmt.State, c rune) {
if c != 'v' {
fmt.Fprintf(f, "{UNRECOGNIZED: %c}", c)
return
}
op := ins.OpCode
if op == InvalidOpCode {
fmt.Fprint(f, "INVALID")
return
}
// Omit trailing space for Exit
if op.JumpOp() == Exit {
fmt.Fprint(f, op)
return
}
if ins.IsLoadFromMap() {
fd := ins.mapFd()
m := ins.Map()
switch ins.Src {
case PseudoMapFD:
if m != nil {
fmt.Fprintf(f, "LoadMapPtr dst: %s map: %s", ins.Dst, m)
} else {
fmt.Fprintf(f, "LoadMapPtr dst: %s fd: %d", ins.Dst, fd)
}
case PseudoMapValue:
if m != nil {
fmt.Fprintf(f, "LoadMapValue dst: %s, map: %s off: %d", ins.Dst, m, ins.mapOffset())
} else {
fmt.Fprintf(f, "LoadMapValue dst: %s, fd: %d off: %d", ins.Dst, fd, ins.mapOffset())
}
}
goto ref
}
switch cls := op.Class(); {
case cls.isLoadOrStore():
fmt.Fprintf(f, "%v ", op)
switch op.Mode() {
case ImmMode:
fmt.Fprintf(f, "dst: %s imm: %d", ins.Dst, ins.Constant)
case AbsMode:
fmt.Fprintf(f, "imm: %d", ins.Constant)
case IndMode:
fmt.Fprintf(f, "dst: %s src: %s imm: %d", ins.Dst, ins.Src, ins.Constant)
case MemMode, MemSXMode:
fmt.Fprintf(f, "dst: %s src: %s off: %d imm: %d", ins.Dst, ins.Src, ins.Offset, ins.Constant)
case AtomicMode:
fmt.Fprintf(f, "dst: %s src: %s off: %d", ins.Dst, ins.Src, ins.Offset)
}
case cls.IsALU():
fmt.Fprintf(f, "%v", op)
if op == Swap.Op(ImmSource) {
fmt.Fprintf(f, "%d", ins.Constant)
}
fmt.Fprintf(f, " dst: %s ", ins.Dst)
switch {
case op.ALUOp() == Swap:
break
case op.Source() == ImmSource:
fmt.Fprintf(f, "imm: %d", ins.Constant)
default:
fmt.Fprintf(f, "src: %s", ins.Src)
}
case cls.IsJump():
fmt.Fprintf(f, "%v ", op)
switch jop := op.JumpOp(); jop {
case Call:
switch ins.Src {
case PseudoCall:
// bpf-to-bpf call
fmt.Fprint(f, ins.Constant)
case PseudoKfuncCall:
// kfunc call
fmt.Fprintf(f, "Kfunc(%d)", ins.Constant)
default:
fmt.Fprint(f, BuiltinFunc(ins.Constant))
}
case Ja:
if ins.OpCode.Class() == Jump32Class {
fmt.Fprintf(f, "imm: %d", ins.Constant)
} else {
fmt.Fprintf(f, "off: %d", ins.Offset)
}
default:
fmt.Fprintf(f, "dst: %s off: %d ", ins.Dst, ins.Offset)
if op.Source() == ImmSource {
fmt.Fprintf(f, "imm: %d", ins.Constant)
} else {
fmt.Fprintf(f, "src: %s", ins.Src)
}
}
default:
fmt.Fprintf(f, "%v ", op)
}
ref:
if ins.Reference() != "" {
fmt.Fprintf(f, " <%s>", ins.Reference())
}
}
func (ins Instruction) equal(other Instruction) bool {
return ins.OpCode == other.OpCode &&
ins.Dst == other.Dst &&
ins.Src == other.Src &&
ins.Offset == other.Offset &&
ins.Constant == other.Constant
}
// Size returns the amount of bytes ins would occupy in binary form.
func (ins Instruction) Size() uint64 {
return uint64(InstructionSize * ins.OpCode.rawInstructions())
}
// WithMetadata sets the given Metadata on the Instruction. e.g. to copy
// Metadata from another Instruction when replacing it.
func (ins Instruction) WithMetadata(meta Metadata) Instruction {
ins.Metadata = meta
return ins
}
type symbolMeta struct{}
// WithSymbol marks the Instruction as a Symbol, which other Instructions
// can point to using corresponding calls to WithReference.
func (ins Instruction) WithSymbol(name string) Instruction {
ins.Metadata.Set(symbolMeta{}, name)
return ins
}
// Symbol returns the value ins has been marked with using WithSymbol,
// otherwise returns an empty string. A symbol is often an Instruction
// at the start of a function body.
func (ins Instruction) Symbol() string {
sym, _ := ins.Metadata.Get(symbolMeta{}).(string)
return sym
}
type referenceMeta struct{}
// WithReference makes ins reference another Symbol or map by name.
func (ins Instruction) WithReference(ref string) Instruction {
ins.Metadata.Set(referenceMeta{}, ref)
return ins
}
// Reference returns the Symbol or map name referenced by ins, if any.
func (ins Instruction) Reference() string {
ref, _ := ins.Metadata.Get(referenceMeta{}).(string)
return ref
}
type mapMeta struct{}
// Map returns the Map referenced by ins, if any.
// An Instruction will contain a Map if e.g. it references an existing,
// pinned map that was opened during ELF loading.
func (ins Instruction) Map() FDer {
fd, _ := ins.Metadata.Get(mapMeta{}).(FDer)
return fd
}
type sourceMeta struct{}
// WithSource adds source information about the Instruction.
func (ins Instruction) WithSource(src fmt.Stringer) Instruction {
ins.Metadata.Set(sourceMeta{}, src)
return ins
}
// Source returns source information about the Instruction. The field is
// present when the compiler emits BTF line info about the Instruction and
// usually contains the line of source code responsible for it.
func (ins Instruction) Source() fmt.Stringer {
str, _ := ins.Metadata.Get(sourceMeta{}).(fmt.Stringer)
return str
}
// A Comment can be passed to Instruction.WithSource to add a comment
// to an instruction.
type Comment string
func (s Comment) String() string {
return string(s)
}
// FDer represents a resource tied to an underlying file descriptor.
// Used as a stand-in for e.g. ebpf.Map since that type cannot be
// imported here and FD() is the only method we rely on.
type FDer interface {
FD() int
}
// Instructions is an eBPF program.
type Instructions []Instruction
// AppendInstructions decodes [Instruction] from r and appends them to insns.
func AppendInstructions(insns Instructions, r io.Reader, bo binary.ByteOrder, platform string) (Instructions, error) {
var offset uint64
for {
var ins Instruction
err := ins.Unmarshal(r, bo, platform)
if errors.Is(err, io.EOF) {
break
}
if err != nil {
return nil, fmt.Errorf("offset %d: %w", offset, err)
}
insns = append(insns, ins)
offset += ins.Size()
}
return insns, nil
}
// Name returns the name of the function insns belongs to, if any.
func (insns Instructions) Name() string {
if len(insns) == 0 {
return ""
}
return insns[0].Symbol()
}
func (insns Instructions) String() string {
return fmt.Sprint(insns)
}
// Size returns the amount of bytes insns would occupy in binary form.
func (insns Instructions) Size() uint64 {
var sum uint64
for _, ins := range insns {
sum += ins.Size()
}
return sum
}
// AssociateMap updates all Instructions that Reference the given symbol
// to point to an existing Map m instead.
//
// Returns ErrUnreferencedSymbol error if no references to symbol are found
// in insns. If symbol is anything else than the symbol name of map (e.g.
// a bpf2bpf subprogram), an error is returned.
func (insns Instructions) AssociateMap(symbol string, m FDer) error {
if symbol == "" {
return errors.New("empty symbol")
}
var found bool
for i := range insns {
ins := &insns[i]
if ins.Reference() != symbol {
continue
}
if err := ins.AssociateMap(m); err != nil {
return err
}
found = true
}
if !found {
return fmt.Errorf("symbol %s: %w", symbol, ErrUnreferencedSymbol)
}
return nil
}
// SymbolOffsets returns the set of symbols and their offset in
// the instructions.
func (insns Instructions) SymbolOffsets() (map[string]int, error) {
offsets := make(map[string]int)
for i, ins := range insns {
if ins.Symbol() == "" {
continue
}
if _, ok := offsets[ins.Symbol()]; ok {
return nil, fmt.Errorf("duplicate symbol %s", ins.Symbol())
}
offsets[ins.Symbol()] = i
}
return offsets, nil
}
// FunctionReferences returns a set of symbol names these Instructions make
// bpf-to-bpf calls to.
func (insns Instructions) FunctionReferences() []string {
calls := make(map[string]struct{})
for _, ins := range insns {
if ins.Constant != -1 {
// BPF-to-BPF calls have -1 constants.
continue
}
if ins.Reference() == "" {
continue
}
if !ins.IsFunctionReference() {
continue
}
calls[ins.Reference()] = struct{}{}
}
result := make([]string, 0, len(calls))
for call := range calls {
result = append(result, call)
}
sort.Strings(result)
return result
}
// ReferenceOffsets returns the set of references and their offset in
// the instructions.
func (insns Instructions) ReferenceOffsets() map[string][]int {
offsets := make(map[string][]int)
for i, ins := range insns {
if ins.Reference() == "" {
continue
}
offsets[ins.Reference()] = append(offsets[ins.Reference()], i)
}
return offsets
}
// Format implements fmt.Formatter.
//
// You can control indentation of symbols by
// specifying a width. Setting a precision controls the indentation of
// instructions.
// The default character is a tab, which can be overridden by specifying
// the ' ' space flag.
func (insns Instructions) Format(f fmt.State, c rune) {
if c != 's' && c != 'v' {
fmt.Fprintf(f, "{UNKNOWN FORMAT '%c'}", c)
return
}
// Precision is better in this case, because it allows
// specifying 0 padding easily.
padding, ok := f.Precision()
if !ok {
padding = 1
}
indent := strings.Repeat("\t", padding)
if f.Flag(' ') {
indent = strings.Repeat(" ", padding)
}
symPadding, ok := f.Width()
if !ok {
symPadding = padding - 1
}
if symPadding < 0 {
symPadding = 0
}
symIndent := strings.Repeat("\t", symPadding)
if f.Flag(' ') {
symIndent = strings.Repeat(" ", symPadding)
}
// Guess how many digits we need at most, by assuming that all instructions
// are double wide.
highestOffset := len(insns) * 2
offsetWidth := int(math.Ceil(math.Log10(float64(highestOffset))))
iter := insns.Iterate()
for iter.Next() {
if iter.Ins.Symbol() != "" {
fmt.Fprintf(f, "%s%s:\n", symIndent, iter.Ins.Symbol())
}
if src := iter.Ins.Source(); src != nil {
line := strings.TrimSpace(src.String())
if line != "" {
fmt.Fprintf(f, "%s%*s; %s\n", indent, offsetWidth, " ", line)
}
}
fmt.Fprintf(f, "%s%*d: %v\n", indent, offsetWidth, iter.Offset, iter.Ins)
}
}
// Marshal encodes a BPF program into the kernel format.
//
// insns may be modified if there are unresolved jumps or bpf2bpf calls.
//
// Returns ErrUnsatisfiedProgramReference if there is a Reference Instruction
// without a matching Symbol Instruction within insns.
func (insns Instructions) Marshal(w io.Writer, bo binary.ByteOrder) error {
if err := insns.encodeFunctionReferences(); err != nil {
return err
}
if err := insns.encodeMapPointers(); err != nil {
return err
}
for i, ins := range insns {
if _, err := ins.Marshal(w, bo); err != nil {
return fmt.Errorf("instruction %d: %w", i, err)
}
}
return nil
}
// Tag calculates the kernel tag for a series of instructions.
//
// It mirrors bpf_prog_calc_tag in the kernel and so can be compared
// to ProgramInfo.Tag to figure out whether a loaded program matches
// certain instructions.
//
// Deprecated: The value produced by this method no longer matches tags produced
// by the kernel since Linux 6.18. Use [Instructions.HasTag] instead.
func (insns Instructions) Tag(bo binary.ByteOrder) (string, error) {
// We cannot determine which hashing function to use without probing the kernel.
// So use the legacy SHA-1 implementation and deprecate this method.
return insns.tagSha1(bo)
}
// HasTag returns true if the given tag matches the kernel tag of insns.
func (insns Instructions) HasTag(tag string, bo binary.ByteOrder) (bool, error) {
sha256Tag, err := insns.tagSha256(bo)
if err != nil {
return false, fmt.Errorf("hashing sha256: %w", err)
}
if tag == sha256Tag {
return true, nil
}
sha1Tag, err := insns.tagSha1(bo)
if err != nil {
return false, fmt.Errorf("hashing sha1: %w", err)
}
return tag == sha1Tag, nil
}
// tagSha1 calculates the kernel tag for a series of instructions.
//
// It mirrors bpf_prog_calc_tag in kernels up to v6.18 and can be compared to
// ProgramInfo.Tag to figure out whether a loaded Program matches insns.
func (insns Instructions) tagSha1(bo binary.ByteOrder) (string, error) {
h := sha1.New()
if err := insns.hash(h, bo); err != nil {
return "", err
}
return hex.EncodeToString(h.Sum(nil)[:sys.BPF_TAG_SIZE]), nil
}
// tagSha256 calculates the kernel tag for a series of instructions.
//
// It mirrors bpf_prog_calc_tag in the kernel and can be compared to
// ProgramInfo.Tag to figure out whether a loaded Program matches insns.
func (insns Instructions) tagSha256(bo binary.ByteOrder) (string, error) {
h := sha256.New()
if err := insns.hash(h, bo); err != nil {
return "", err
}
return hex.EncodeToString(h.Sum(nil)[:sys.BPF_TAG_SIZE]), nil
}
// hash calculates the hash of the instruction stream. Map load instructions
// are zeroed out, since these contain map file descriptors or pointers to
// maps, which will be different from load to load and would make the hash
// non-deterministic.
func (insns Instructions) hash(h hash.Hash, bo binary.ByteOrder) error {
for i, ins := range insns {
if ins.IsLoadFromMap() {
ins.Constant = 0
}
_, err := ins.Marshal(h, bo)
if err != nil {
return fmt.Errorf("instruction %d: %w", i, err)
}
}
return nil
}
// encodeFunctionReferences populates the Offset (or Constant, depending on
// the instruction type) field of instructions with a Reference field to point
// to the offset of the corresponding instruction with a matching Symbol field.
//
// Only Reference Instructions that are either jumps or BPF function references
// (calls or function pointer loads) are populated.
//
// Returns ErrUnsatisfiedProgramReference if there is a Reference Instruction
// without at least one corresponding Symbol Instruction within insns.
func (insns Instructions) encodeFunctionReferences() error {
// Index the offsets of instructions tagged as a symbol.
symbolOffsets := make(map[string]RawInstructionOffset)
iter := insns.Iterate()
for iter.Next() {
ins := iter.Ins
if ins.Symbol() == "" {
continue
}
if _, ok := symbolOffsets[ins.Symbol()]; ok {
return fmt.Errorf("duplicate symbol %s", ins.Symbol())
}
symbolOffsets[ins.Symbol()] = iter.Offset
}
// Find all instructions tagged as references to other symbols.
// Depending on the instruction type, populate their constant or offset
// fields to point to the symbol they refer to within the insn stream.
iter = insns.Iterate()
for iter.Next() {
i := iter.Index
offset := iter.Offset
ins := iter.Ins
if ins.Reference() == "" {
continue
}
switch {
case ins.IsFunctionReference() && ins.Constant == -1,
ins.OpCode == Ja.opCode(Jump32Class, ImmSource) && ins.Constant == -1:
symOffset, ok := symbolOffsets[ins.Reference()]
if !ok {
return fmt.Errorf("%s at insn %d: symbol %q: %w", ins.OpCode, i, ins.Reference(), ErrUnsatisfiedProgramReference)
}
ins.Constant = int64(symOffset - offset - 1)
case ins.OpCode.Class().IsJump() && ins.Offset == -1:
symOffset, ok := symbolOffsets[ins.Reference()]
if !ok {
return fmt.Errorf("%s at insn %d: symbol %q: %w", ins.OpCode, i, ins.Reference(), ErrUnsatisfiedProgramReference)
}
ins.Offset = int16(symOffset - offset - 1)
}
}
return nil
}
// encodeMapPointers finds all Map Instructions and encodes their FDs
// into their Constant fields.
func (insns Instructions) encodeMapPointers() error {
iter := insns.Iterate()
for iter.Next() {
ins := iter.Ins
if !ins.IsLoadFromMap() {
continue
}
m := ins.Map()
if m == nil {
continue
}
fd := m.FD()
if fd < 0 {
return fmt.Errorf("map %s: %w", m, sys.ErrClosedFd)
}
ins.encodeMapFD(m.FD())
}
return nil
}
// Iterate allows iterating a BPF program while keeping track of
// various offsets.
//
// Modifying the instruction slice will lead to undefined behaviour.
func (insns Instructions) Iterate() *InstructionIterator {
return &InstructionIterator{insns: insns}
}
// InstructionIterator iterates over a BPF program.
type InstructionIterator struct {
insns Instructions
// The instruction in question.
Ins *Instruction
// The index of the instruction in the original instruction slice.
Index int
// The offset of the instruction in raw BPF instructions. This accounts
// for double-wide instructions.
Offset RawInstructionOffset
}
// Next returns true as long as there are any instructions remaining.
func (iter *InstructionIterator) Next() bool {
if len(iter.insns) == 0 {
return false
}
if iter.Ins != nil {
iter.Index++
iter.Offset += RawInstructionOffset(iter.Ins.OpCode.rawInstructions())
}
iter.Ins = &iter.insns[0]
iter.insns = iter.insns[1:]
return true
}
type bpfRegisters uint8
func newBPFRegisters(dst, src Register, bo binary.ByteOrder) (bpfRegisters, error) {
switch bo {
case binary.LittleEndian:
return bpfRegisters((src << 4) | (dst & 0xF)), nil
case binary.BigEndian:
return bpfRegisters((dst << 4) | (src & 0xF)), nil
default:
return 0, fmt.Errorf("unrecognized ByteOrder %T", bo)
}
}
================================================
FILE: asm/instruction_test.go
================================================
package asm
import (
"bytes"
"encoding/binary"
"encoding/hex"
"fmt"
"io"
"math"
"testing"
"github.com/go-quicktest/qt"
"github.com/cilium/ebpf/internal/platform"
)
var test64bitImmProg = []byte{
// r0 = math.MinInt32 - 1
0x18, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x7f,
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
}
func TestRead64bitImmediate(t *testing.T) {
var ins Instruction
err := ins.Unmarshal(bytes.NewReader(test64bitImmProg), binary.LittleEndian, platform.Linux)
if err != nil {
t.Fatal(err)
}
if c := ins.Constant; c != math.MinInt32-1 {
t.Errorf("Expected immediate to be %v, got %v", int64(math.MinInt32)-1, c)
}
}
func BenchmarkRead64bitImmediate(b *testing.B) {
r := &bytes.Reader{}
for b.Loop() {
r.Reset(test64bitImmProg)
var ins Instruction
if err := ins.Unmarshal(r, binary.LittleEndian, platform.Linux); err != nil {
b.Fatal(err)
}
}
}
func TestWrite64bitImmediate(t *testing.T) {
insns := Instructions{
LoadImm(R0, math.MinInt32-1, DWord),
}
var buf bytes.Buffer
if err := insns.Marshal(&buf, binary.LittleEndian); err != nil {
t.Fatal(err)
}
if prog := buf.Bytes(); !bytes.Equal(prog, test64bitImmProg) {
t.Errorf("Marshalled program does not match:\n%s", hex.Dump(prog))
}
}
func BenchmarkWrite64BitImmediate(b *testing.B) {
ins := LoadImm(R0, math.MinInt32-1, DWord)
var buf bytes.Buffer
for b.Loop() {
buf.Reset()
if _, err := ins.Marshal(&buf, binary.LittleEndian); err != nil {
b.Fatal(err)
}
}
}
func TestAppendInstructions(t *testing.T) {
r := bytes.NewReader(test64bitImmProg)
insns, err := AppendInstructions(nil, r, binary.LittleEndian, platform.Linux)
qt.Assert(t, qt.IsNil(err))
if len(insns) != 1 {
t.Fatalf("Expected one instruction, got %d", len(insns))
}
}
func TestSignedJump(t *testing.T) {
insns := Instructions{
JSGT.Imm(R0, -1, "foo"),
}
insns[0].Offset = 1
err := insns.Marshal(io.Discard, binary.LittleEndian)
if err != nil {
t.Error("Can't marshal signed jump:", err)
}
}
func TestInstructionLoadMapValue(t *testing.T) {
ins := LoadMapValue(R0, 1, 123)
if !ins.IsLoadFromMap() {
t.Error("isLoadFromMap returns false")
}
if fd := ins.mapFd(); fd != 1 {
t.Error("Expected map fd to be 1, got", fd)
}
if off := ins.mapOffset(); off != 123 {
t.Fatal("Expected map offset to be 123 after changing the pointer, got", off)
}
}
func TestInstructionWithMetadata(t *testing.T) {
ins := LoadImm(R0, 123, DWord).WithSymbol("abc")
ins2 := LoadImm(R0, 567, DWord).WithMetadata(ins.Metadata)
if want, got := "abc", ins2.Symbol(); want != got {
t.Fatalf("unexpected Symbol value on ins2: want: %s, got: %s", want, got)
}
if want, got := ins.Metadata, ins2.Metadata; want != got {
t.Fatal("expected ins and isn2 Metadata to match")
}
}
func TestReadCallToNegativeOne(t *testing.T) {
raw := []byte{
0x85, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
}
var ins Instruction
err := ins.Unmarshal(bytes.NewReader(raw), binary.LittleEndian, platform.Linux)
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.Equals(ins.Constant, -1))
}
// You can use format flags to change the way an eBPF
// program is stringified.
func ExampleInstructions_Format() {
insns := Instructions{
FnMapLookupElem.Call().WithSymbol("my_func").WithSource(Comment("bpf_map_lookup_elem()")),
LoadImm(R0, 42, DWord).WithSource(Comment("abc = 42")),
Return(),
}
fmt.Println("Default format:")
fmt.Printf("%v\n", insns)
fmt.Println("Don't indent instructions:")
fmt.Printf("%.0v\n", insns)
fmt.Println("Indent using spaces:")
fmt.Printf("% v\n", insns)
fmt.Println("Control symbol indentation:")
fmt.Printf("%2v\n", insns)
// Output: Default format:
// my_func:
// ; bpf_map_lookup_elem()
// 0: Call FnMapLookupElem
// ; abc = 42
// 1: LdImmDW dst: r0 imm: 42
// 3: Exit
//
// Don't indent instructions:
// my_func:
// ; bpf_map_lookup_elem()
// 0: Call FnMapLookupElem
// ; abc = 42
// 1: LdImmDW dst: r0 imm: 42
// 3: Exit
//
// Indent using spaces:
// my_func:
// ; bpf_map_lookup_elem()
// 0: Call FnMapLookupElem
// ; abc = 42
// 1: LdImmDW dst: r0 imm: 42
// 3: Exit
//
// Control symbol indentation:
// my_func:
// ; bpf_map_lookup_elem()
// 0: Call FnMapLookupElem
// ; abc = 42
// 1: LdImmDW dst: r0 imm: 42
// 3: Exit
}
func TestReadSrcDst(t *testing.T) {
testSrcDstProg := []byte{
// on little-endian: r0 = r1
// on big-endian: be: r1 = r0
0xbf, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
}
testcases := []struct {
bo binary.ByteOrder
dst, src Register
}{
{binary.BigEndian, R1, R0},
{binary.LittleEndian, R0, R1},
}
for _, tc := range testcases {
t.Run(tc.bo.String(), func(t *testing.T) {
var ins Instruction
err := ins.Unmarshal(bytes.NewReader(testSrcDstProg), tc.bo, platform.Linux)
if err != nil {
t.Fatal(err)
}
if ins.Dst != tc.dst {
t.Errorf("Expected destination to be %v, got %v", tc.dst, ins.Dst)
}
if ins.Src != tc.src {
t.Errorf("Expected source to be %v, got %v", tc.src, ins.Src)
}
})
}
}
func TestInstructionIterator(t *testing.T) {
insns := Instructions{
LoadImm(R0, 0, Word),
LoadImm(R0, 0, DWord),
Return(),
}
offsets := []RawInstructionOffset{0, 1, 3}
iter := insns.Iterate()
for i := 0; i < len(insns); i++ {
if !iter.Next() {
t.Fatalf("Expected %dth call to Next to return true", i)
}
if iter.Ins == nil {
t.Errorf("Expected iter.Ins to be non-nil")
}
if iter.Index != i {
t.Errorf("Expected iter.Index to be %d, got %d", i, iter.Index)
}
if iter.Offset != offsets[i] {
t.Errorf("Expected iter.Offset to be %d, got %d", offsets[i], iter.Offset)
}
}
}
func TestMetadataCopyOnWrite(t *testing.T) {
// Setting metadata should copy Instruction and modify the metadata pointer
// of the new object without touching the old Instruction.
// Reference
ins := Ja.Label("my_func")
ins2 := ins.WithReference("my_func2")
qt.Assert(t, qt.Equals(ins.Reference(), "my_func"), qt.Commentf("WithReference updated ins"))
qt.Assert(t, qt.Equals(ins2.Reference(), "my_func2"), qt.Commentf("WithReference didn't update ins2"))
// Symbol
ins = Ja.Label("").WithSymbol("my_sym")
ins2 = ins.WithSymbol("my_sym2")
qt.Assert(t, qt.Equals(ins.Symbol(), "my_sym"), qt.Commentf("WithSymbol updated ins"))
qt.Assert(t, qt.Equals(ins2.Symbol(), "my_sym2"), qt.Commentf("WithSymbol didn't update ins2"))
// Map
ins = LoadMapPtr(R1, 0)
ins2 = ins
testMap := testFDer(1)
qt.Assert(t, qt.IsNil(ins2.AssociateMap(testMap)), qt.Commentf("failed to associate map with ins2"))
qt.Assert(t, qt.IsNil(ins.Map()), qt.Commentf("AssociateMap updated ins"))
qt.Assert(t, qt.Equals[FDer](ins2.Map(), testMap), qt.Commentf("AssociateMap didn't update ins2"))
}
type testFDer int
func (t testFDer) FD() int {
return int(t)
}
func TestAtomics(t *testing.T) {
rawInsns := []byte{
0xc3, 0x21, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // lock *(u32 *)(r1 + 0x1) += w2
0xc3, 0x21, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, // lock *(u32 *)(r1 + 0x1) &= w2
0xc3, 0x21, 0x01, 0x00, 0xa0, 0x00, 0x00, 0x00, // lock *(u32 *)(r1 + 0x1) ^= w2
0xc3, 0x21, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, // lock *(u32 *)(r1 + 0x1) |= w2
0xdb, 0x21, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // lock *(u64 *)(r1 + 0x1) += r2
0xdb, 0x21, 0x01, 0x00, 0x50, 0x00, 0x00, 0x00, // lock *(u64 *)(r1 + 0x1) &= r2
0xdb, 0x21, 0x01, 0x00, 0xa0, 0x00, 0x00, 0x00, // lock *(u64 *)(r1 + 0x1) ^= r2
0xdb, 0x21, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, // lock *(u64 *)(r1 + 0x1) |= r2
0xc3, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // w0 = atomic_fetch_add((u32 *)(r1 + 0x0), w0)
0xc3, 0x01, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, // w0 = atomic_fetch_and((u32 *)(r1 + 0x0), w0)
0xc3, 0x01, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, // w0 = atomic_fetch_xor((u32 *)(r1 + 0x0), w0)
0xc3, 0x01, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, // w0 = atomic_fetch_or((u32 *)(r1 + 0x0), w0)
0xdb, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // r0 = atomic_fetch_add((u64 *)(r1 + 0x0), r0)
0xdb, 0x01, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, // r0 = atomic_fetch_and((u64 *)(r1 + 0x0), r0)
0xdb, 0x01, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, // r0 = atomic_fetch_xor((u64 *)(r1 + 0x0), r0)
0xdb, 0x01, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, // r0 = atomic_fetch_or((u64 *)(r1 + 0x0), r0)
0xc3, 0x01, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, // w0 = xchg32_32(r1 + 0x0, w0)
0xdb, 0x01, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, // r0 = xchg_64(r1 + 0x0, r0)
0xc3, 0x11, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, // w0 = cmpxchg32_32(r1 + 0x0, w0, w1)
0xdb, 0x11, 0x00, 0x00, 0xf1, 0x00, 0x00, 0x00, // r0 = cmpxchg_64(r1 + 0x0, r0, r1)
}
insns, err := AppendInstructions(nil, bytes.NewReader(rawInsns), binary.LittleEndian, platform.Linux)
if err != nil {
t.Fatal(err)
}
lines := []string{
"StXAtomicAddW dst: r1 src: r2 off: 1",
"StXAtomicAndW dst: r1 src: r2 off: 1",
"StXAtomicXorW dst: r1 src: r2 off: 1",
"StXAtomicOrW dst: r1 src: r2 off: 1",
"StXAtomicAddDW dst: r1 src: r2 off: 1",
"StXAtomicAndDW dst: r1 src: r2 off: 1",
"StXAtomicXorDW dst: r1 src: r2 off: 1",
"StXAtomicOrDW dst: r1 src: r2 off: 1",
"StXAtomicFetchAddW dst: r1 src: r0 off: 0",
"StXAtomicFetchAndW dst: r1 src: r0 off: 0",
"StXAtomicFetchXorW dst: r1 src: r0 off: 0",
"StXAtomicFetchOrW dst: r1 src: r0 off: 0",
"StXAtomicFetchAddDW dst: r1 src: r0 off: 0",
"StXAtomicFetchAndDW dst: r1 src: r0 off: 0",
"StXAtomicFetchXorDW dst: r1 src: r0 off: 0",
"StXAtomicFetchOrDW dst: r1 src: r0 off: 0",
"StXAtomicXchgW dst: r1 src: r0 off: 0",
"StXAtomicXchgDW dst: r1 src: r0 off: 0",
"StXAtomicCmpXchgW dst: r1 src: r1 off: 0",
"StXAtomicCmpXchgDW dst: r1 src: r1 off: 0",
}
for i, ins := range insns {
if want, got := lines[i], fmt.Sprint(ins); want != got {
t.Errorf("Expected %q, got %q", want, got)
}
}
// Marshal and unmarshal again to make sure the instructions are
// still valid.
var buf bytes.Buffer
err = insns.Marshal(&buf, binary.LittleEndian)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(buf.Bytes(), rawInsns) {
t.Error("Expected instructions to be equal after marshalling")
}
}
func TestISAv4(t *testing.T) {
rawInsns := []byte{
0xd7, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, // r1 = bswap16 r1
0xd7, 0x02, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, // r2 = bswap32 r2
0xd7, 0x03, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, // r3 = bswap64 r3
0x91, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // r1 = *(s8 *)(r4 + 0x0)
0x89, 0x52, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // r2 = *(s16 *)(r5 + 0x4)
0x81, 0x63, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // r3 = *(s32 *)(r6 + 0x8)
0x91, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // r1 = *(s8 *)(r4 + 0x0)
0x89, 0x52, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, // r2 = *(s16 *)(r5 + 0x4)
0xbf, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // r1 = (s8)r4
0xbf, 0x52, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // r2 = (s16)r5
0xbf, 0x63, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, // r3 = (s32)r6
0xbc, 0x31, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, // w1 = (s8)w3
0xbc, 0x42, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // w2 = (s16)w4
0x06, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, // gotol +3
0x3f, 0x31, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // r1 s/= r3
0x9f, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // r2 s%= r4
0x3c, 0x31, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // w1 s/= w3
0x9c, 0x42, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // w2 s%= w4
0xd3, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // w0 = load_acquire((u8 *)(r1 + 0x0))
0xcb, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // w0 = load_acquire((u16 *)(r1 + 0x0))
0xc3, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // w0 = load_acquire((u32 *)(r1 + 0x0))
0xdb, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // r0 = load_acquire((u64 *)(r1 + 0x0))
0xd3, 0x21, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, // store_release((u8 *)(r1 + 0x0), w2)
0xcb, 0x21, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, // store_release((u16 *)(r1 + 0x0), w2)
0xc3, 0x21, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, // store_release((u32 *)(r1 + 0x0), w2)
0xdb, 0x21, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, // store_release((u64 *)(r1 + 0x0), r2)
}
insns, err := AppendInstructions(nil, bytes.NewReader(rawInsns), binary.LittleEndian, platform.Linux)
if err != nil {
t.Fatal(err)
}
lines := []string{
"BSwap16 dst: r1 ",
"BSwap32 dst: r2 ",
"BSwap64 dst: r3 ",
"LdXMemSXB dst: r1 src: r4 off: 0 imm: 0",
"LdXMemSXH dst: r2 src: r5 off: 4 imm: 0",
"LdXMemSXW dst: r3 src: r6 off: 8 imm: 0",
"LdXMemSXB dst: r1 src: r4 off: 0 imm: 0",
"LdXMemSXH dst: r2 src: r5 off: 4 imm: 0",
"MovSX8Reg dst: r1 src: r4",
"MovSX16Reg dst: r2 src: r5",
"MovSX32Reg dst: r3 src: r6",
"MovSX8Reg32 dst: r1 src: r3",
"MovSX16Reg32 dst: r2 src: r4",
"Ja32 imm: 3",
"SDivReg dst: r1 src: r3",
"SModReg dst: r2 src: r4",
"SDivReg32 dst: r1 src: r3",
"SModReg32 dst: r2 src: r4",
"StXAtomicLdAcqB dst: r0 src: r1 off: 0",
"StXAtomicLdAcqH dst: r0 src: r1 off: 0",
"StXAtomicLdAcqW dst: r0 src: r1 off: 0",
"StXAtomicLdAcqDW dst: r0 src: r1 off: 0",
"StXAtomicStRelB dst: r1 src: r2 off: 0",
"StXAtomicStRelH dst: r1 src: r2 off: 0",
"StXAtomicStRelW dst: r1 src: r2 off: 0",
"StXAtomicStRelDW dst: r1 src: r2 off: 0",
}
for i, ins := range insns {
if want, got := lines[i], fmt.Sprint(ins); want != got {
t.Errorf("Expected %q, got %q", want, got)
}
}
// Marshal and unmarshal again to make sure the instructions are
// still valid.
var buf bytes.Buffer
err = insns.Marshal(&buf, binary.LittleEndian)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(buf.Bytes(), rawInsns) {
t.Error("Expected instructions to be equal after marshalling")
}
}
func TestLongJumpPatching(t *testing.T) {
insns := Instructions{
LongJump("exit"),
Xor.Reg(R0, R0),
Xor.Reg(R0, R0),
Xor.Reg(R0, R0),
Return().WithSymbol("exit"),
}
err := insns.encodeFunctionReferences()
if err != nil {
t.Fatal(err)
}
if insns[0].Constant != 3 {
t.Errorf("Expected offset to be 3, got %d", insns[1].Constant)
}
}
================================================
FILE: asm/jump.go
================================================
package asm
//go:generate go tool stringer -output jump_string.go -type=JumpOp
// JumpOp affect control flow.
//
// msb lsb
// +----+-+---+
// |OP |s|cls|
// +----+-+---+
type JumpOp uint8
const jumpMask OpCode = 0xf0
const (
// InvalidJumpOp is returned by getters when invoked
// on non branch OpCodes
InvalidJumpOp JumpOp = 0xff
// Ja jumps by offset unconditionally
Ja JumpOp = 0x00
// JEq jumps by offset if r == imm
JEq JumpOp = 0x10
// JGT jumps by offset if r > imm
JGT JumpOp = 0x20
// JGE jumps by offset if r >= imm
JGE JumpOp = 0x30
// JSet jumps by offset if r & imm
JSet JumpOp = 0x40
// JNE jumps by offset if r != imm
JNE JumpOp = 0x50
// JSGT jumps by offset if signed r > signed imm
JSGT JumpOp = 0x60
// JSGE jumps by offset if signed r >= signed imm
JSGE JumpOp = 0x70
// Call builtin or user defined function from imm
Call JumpOp = 0x80
// Exit ends execution, with value in r0
Exit JumpOp = 0x90
// JLT jumps by offset if r < imm
JLT JumpOp = 0xa0
// JLE jumps by offset if r <= imm
JLE JumpOp = 0xb0
// JSLT jumps by offset if signed r < signed imm
JSLT JumpOp = 0xc0
// JSLE jumps by offset if signed r <= signed imm
JSLE JumpOp = 0xd0
)
// Return emits an exit instruction.
//
// Requires a return value in R0.
func Return() Instruction {
return Instruction{
OpCode: OpCode(JumpClass).SetJumpOp(Exit),
}
}
// Op returns the OpCode for a given jump source.
func (op JumpOp) Op(source Source) OpCode {
return OpCode(JumpClass).SetJumpOp(op).SetSource(source)
}
// Imm compares 64 bit dst to 64 bit value (sign extended), and adjusts PC by offset if the condition is fulfilled.
func (op JumpOp) Imm(dst Register, value int32, label string) Instruction {
return Instruction{
OpCode: op.opCode(JumpClass, ImmSource),
Dst: dst,
Offset: -1,
Constant: int64(value),
}.WithReference(label)
}
// Imm32 compares 32 bit dst to 32 bit value, and adjusts PC by offset if the condition is fulfilled.
// Requires kernel 5.1.
func (op JumpOp) Imm32(dst Register, value int32, label string) Instruction {
return Instruction{
OpCode: op.opCode(Jump32Class, ImmSource),
Dst: dst,
Offset: -1,
Constant: int64(value),
}.WithReference(label)
}
// Reg compares 64 bit dst to 64 bit src, and adjusts PC by offset if the condition is fulfilled.
func (op JumpOp) Reg(dst, src Register, label string) Instruction {
return Instruction{
OpCode: op.opCode(JumpClass, RegSource),
Dst: dst,
Src: src,
Offset: -1,
}.WithReference(label)
}
// Reg32 compares 32 bit dst to 32 bit src, and adjusts PC by offset if the condition is fulfilled.
// Requires kernel 5.1.
func (op JumpOp) Reg32(dst, src Register, label string) Instruction {
return Instruction{
OpCode: op.opCode(Jump32Class, RegSource),
Dst: dst,
Src: src,
Offset: -1,
}.WithReference(label)
}
func (op JumpOp) opCode(class Class, source Source) OpCode {
if op == Exit || op == Call {
return InvalidOpCode
}
return OpCode(class).SetJumpOp(op).SetSource(source)
}
// LongJump returns a jump always instruction with a range of [-2^31, 2^31 - 1].
func LongJump(label string) Instruction {
return Instruction{
OpCode: Ja.opCode(Jump32Class, ImmSource),
Constant: -1,
}.WithReference(label)
}
// Label adjusts PC to the address of the label.
func (op JumpOp) Label(label string) Instruction {
if op == Call {
return Instruction{
OpCode: OpCode(JumpClass).SetJumpOp(Call),
Src: PseudoCall,
Constant: -1,
}.WithReference(label)
}
return Instruction{
OpCode: OpCode(JumpClass).SetJumpOp(op),
Offset: -1,
}.WithReference(label)
}
================================================
FILE: asm/jump_string.go
================================================
// Code generated by "stringer -output jump_string.go -type=JumpOp"; DO NOT EDIT.
package asm
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[InvalidJumpOp-255]
_ = x[Ja-0]
_ = x[JEq-16]
_ = x[JGT-32]
_ = x[JGE-48]
_ = x[JSet-64]
_ = x[JNE-80]
_ = x[JSGT-96]
_ = x[JSGE-112]
_ = x[Call-128]
_ = x[Exit-144]
_ = x[JLT-160]
_ = x[JLE-176]
_ = x[JSLT-192]
_ = x[JSLE-208]
}
const _JumpOp_name = "JaJEqJGTJGEJSetJNEJSGTJSGECallExitJLTJLEJSLTJSLEInvalidJumpOp"
var _JumpOp_map = map[JumpOp]string{
0: _JumpOp_name[0:2],
16: _JumpOp_name[2:5],
32: _JumpOp_name[5:8],
48: _JumpOp_name[8:11],
64: _JumpOp_name[11:15],
80: _JumpOp_name[15:18],
96: _JumpOp_name[18:22],
112: _JumpOp_name[22:26],
128: _JumpOp_name[26:30],
144: _JumpOp_name[30:34],
160: _JumpOp_name[34:37],
176: _JumpOp_name[37:40],
192: _JumpOp_name[40:44],
208: _JumpOp_name[44:48],
255: _JumpOp_name[48:61],
}
func (i JumpOp) String() string {
if str, ok := _JumpOp_map[i]; ok {
return str
}
return "JumpOp(" + strconv.FormatInt(int64(i), 10) + ")"
}
================================================
FILE: asm/load_store.go
================================================
package asm
import "fmt"
//go:generate go tool stringer -output load_store_string.go -type=Mode,Size
// Mode for load and store operations
//
// msb lsb
// +---+--+---+
// |MDE|sz|cls|
// +---+--+---+
type Mode uint8
const modeMask OpCode = 0xe0
const (
// InvalidMode is returned by getters when invoked
// on non load / store OpCodes
InvalidMode Mode = 0xff
// ImmMode - immediate value
ImmMode Mode = 0x00
// AbsMode - immediate value + offset
AbsMode Mode = 0x20
// IndMode - indirect (imm+src)
IndMode Mode = 0x40
// MemMode - load from memory
MemMode Mode = 0x60
// MemSXMode - load from memory, sign extension
MemSXMode Mode = 0x80
// AtomicMode - add atomically across processors.
AtomicMode Mode = 0xc0
)
const atomicMask OpCode = 0x0001_ff00
type AtomicOp uint32
const (
InvalidAtomic AtomicOp = 0xffff_ffff
// AddAtomic - add src to memory address dst atomically
AddAtomic AtomicOp = AtomicOp(Add) << 8
// FetchAdd - add src to memory address dst atomically, store result in src
FetchAdd AtomicOp = AddAtomic | fetch
// AndAtomic - bitwise AND src with memory address at dst atomically
AndAtomic AtomicOp = AtomicOp(And) << 8
// FetchAnd - bitwise AND src with memory address at dst atomically, store result in src
FetchAnd AtomicOp = AndAtomic | fetch
// OrAtomic - bitwise OR src with memory address at dst atomically
OrAtomic AtomicOp = AtomicOp(Or) << 8
// FetchOr - bitwise OR src with memory address at dst atomically, store result in src
FetchOr AtomicOp = OrAtomic | fetch
// XorAtomic - bitwise XOR src with memory address at dst atomically
XorAtomic AtomicOp = AtomicOp(Xor) << 8
// FetchXor - bitwise XOR src with memory address at dst atomically, store result in src
FetchXor AtomicOp = XorAtomic | fetch
// Xchg - atomically exchange the old value with the new value
//
// src gets populated with the old value of *(size *)(dst + offset).
Xchg AtomicOp = 0x0000_e000 | fetch
// CmpXchg - atomically compare and exchange the old value with the new value
//
// Compares R0 and *(size *)(dst + offset), writes src to *(size *)(dst + offset) on match.
// R0 gets populated with the old value of *(size *)(dst + offset), even if no exchange occurs.
CmpXchg AtomicOp = 0x0000_f000 | fetch
// fetch modifier for copy-modify-write atomics
fetch AtomicOp = 0x0000_0100
// loadAcquire - atomically load with acquire semantics
loadAcquire AtomicOp = 0x0001_0000
// storeRelease - atomically store with release semantics
storeRelease AtomicOp = 0x0001_1000
)
func (op AtomicOp) String() string {
var name string
switch op {
case AddAtomic, AndAtomic, OrAtomic, XorAtomic:
name = ALUOp(op >> 8).String()
case FetchAdd, FetchAnd, FetchOr, FetchXor:
name = "Fetch" + ALUOp((op^fetch)>>8).String()
case Xchg:
name = "Xchg"
case CmpXchg:
name = "CmpXchg"
case loadAcquire:
name = "LdAcq"
case storeRelease:
name = "StRel"
default:
name = fmt.Sprintf("AtomicOp(%#x)", uint32(op))
}
return name
}
func (op AtomicOp) OpCode(size Size) OpCode {
switch op {
case AddAtomic, AndAtomic, OrAtomic, XorAtomic,
FetchAdd, FetchAnd, FetchOr, FetchXor,
Xchg, CmpXchg:
switch size {
case Byte, Half:
// 8-bit and 16-bit atomic copy-modify-write atomics are not supported
return InvalidOpCode
}
}
return OpCode(StXClass).SetMode(AtomicMode).SetSize(size).SetAtomicOp(op)
}
// Mem emits `*(size *)(dst + offset) (op) src`.
func (op AtomicOp) Mem(dst, src Register, size Size, offset int16) Instruction {
return Instruction{
OpCode: op.OpCode(size),
Dst: dst,
Src: src,
Offset: offset,
}
}
// Emits `lock-acquire dst = *(size *)(src + offset)`.
func LoadAcquire(dst, src Register, size Size, offset int16) Instruction {
return Instruction{
OpCode: loadAcquire.OpCode(size),
Dst: dst,
Src: src,
Offset: offset,
}
}
// Emits `lock-release *(size *)(dst + offset) = src`.
func StoreRelease(dst, src Register, size Size, offset int16) Instruction {
return Instruction{
OpCode: storeRelease.OpCode(size),
Dst: dst,
Src: src,
Offset: offset,
}
}
// Size of load and store operations
//
// msb lsb
// +---+--+---+
// |mde|SZ|cls|
// +---+--+---+
type Size uint8
const sizeMask OpCode = 0x18
const (
// InvalidSize is returned by getters when invoked
// on non load / store OpCodes
InvalidSize Size = 0xff
// DWord - double word; 64 bits
DWord Size = 0x18
// Word - word; 32 bits
Word Size = 0x00
// Half - half-word; 16 bits
Half Size = 0x08
// Byte - byte; 8 bits
Byte Size = 0x10
)
// Sizeof returns the size in bytes.
func (s Size) Sizeof() int {
switch s {
case DWord:
return 8
case Word:
return 4
case Half:
return 2
case Byte:
return 1
default:
return -1
}
}
// LoadMemOp returns the OpCode to load a value of given size from memory.
func LoadMemOp(size Size) OpCode {
return OpCode(LdXClass).SetMode(MemMode).SetSize(size)
}
// LoadMemSXOp returns the OpCode to load a value of given size from memory sign extended.
func LoadMemSXOp(size Size) OpCode {
return OpCode(LdXClass).SetMode(MemSXMode).SetSize(size)
}
// LoadMem emits `dst = *(size *)(src + offset)`.
func LoadMem(dst, src Register, offset int16, size Size) Instruction {
return Instruction{
OpCode: LoadMemOp(size),
Dst: dst,
Src: src,
Offset: offset,
}
}
// LoadMemSX emits `dst = *(size *)(src + offset)` but sign extends dst.
func LoadMemSX(dst, src Register, offset int16, size Size) Instruction {
if size == DWord {
return Instruction{OpCode: InvalidOpCode}
}
return Instruction{
OpCode: LoadMemSXOp(size),
Dst: dst,
Src: src,
Offset: offset,
}
}
// LoadImmOp returns the OpCode to load an immediate of given size.
//
// As of kernel 4.20, only DWord size is accepted.
func LoadImmOp(size Size) OpCode {
return OpCode(LdClass).SetMode(ImmMode).SetSize(size)
}
// LoadImm emits `dst = (size)value`.
//
// As of kernel 4.20, only DWord size is accepted.
func LoadImm(dst Register, value int64, size Size) Instruction {
return Instruction{
OpCode: LoadImmOp(size),
Dst: dst,
Constant: value,
}
}
// LoadMapPtr stores a pointer to a map in dst.
func LoadMapPtr(dst Register, fd int) Instruction {
if fd < 0 {
return Instruction{OpCode: InvalidOpCode}
}
return Instruction{
OpCode: LoadImmOp(DWord),
Dst: dst,
Src: PseudoMapFD,
Constant: int64(uint32(fd)),
}
}
// LoadMapValue stores a pointer to the value at a certain offset of a map.
func LoadMapValue(dst Register, fd int, offset uint32) Instruction {
if fd < 0 {
return Instruction{OpCode: InvalidOpCode}
}
fdAndOffset := (uint64(offset) << 32) | uint64(uint32(fd))
return Instruction{
OpCode: LoadImmOp(DWord),
Dst: dst,
Src: PseudoMapValue,
Constant: int64(fdAndOffset),
}
}
// LoadIndOp returns the OpCode for loading a value of given size from an sk_buff.
func LoadIndOp(size Size) OpCode {
return OpCode(LdClass).SetMode(IndMode).SetSize(size)
}
// LoadInd emits `dst = ntoh(*(size *)(((sk_buff *)R6)->data + src + offset))`.
func LoadInd(dst, src Register, offset int32, size Size) Instruction {
return Instruction{
OpCode: LoadIndOp(size),
Dst: dst,
Src: src,
Constant: int64(offset),
}
}
// LoadAbsOp returns the OpCode for loading a value of given size from an sk_buff.
func LoadAbsOp(size Size) OpCode {
return OpCode(LdClass).SetMode(AbsMode).SetSize(size)
}
// LoadAbs emits `r0 = ntoh(*(size *)(((sk_buff *)R6)->data + offset))`.
func LoadAbs(offset int32, size Size) Instruction {
return Instruction{
OpCode: LoadAbsOp(size),
Dst: R0,
Constant: int64(offset),
}
}
// StoreMemOp returns the OpCode for storing a register of given size in memory.
func StoreMemOp(size Size) OpCode {
return OpCode(StXClass).SetMode(MemMode).SetSize(size)
}
// StoreMem emits `*(size *)(dst + offset) = src`
func StoreMem(dst Register, offset int16, src Register, size Size) Instruction {
return Instruction{
OpCode: StoreMemOp(size),
Dst: dst,
Src: src,
Offset: offset,
}
}
// StoreImmOp returns the OpCode for storing an immediate of given size in memory.
func StoreImmOp(size Size) OpCode {
return OpCode(StClass).SetMode(MemMode).SetSize(size)
}
// StoreImm emits `*(size *)(dst + offset) = value`.
func StoreImm(dst Register, offset int16, value int64, size Size) Instruction {
if size == DWord {
return Instruction{OpCode: InvalidOpCode}
}
return Instruction{
OpCode: StoreImmOp(size),
Dst: dst,
Offset: offset,
Constant: value,
}
}
// StoreXAddOp returns the OpCode to atomically add a register to a value in memory.
func StoreXAddOp(size Size) OpCode {
return AddAtomic.OpCode(size)
}
// StoreXAdd atomically adds src to *dst.
func StoreXAdd(dst, src Register, size Size) Instruction {
return AddAtomic.Mem(dst, src, size, 0)
}
================================================
FILE: asm/load_store_string.go
================================================
// Code generated by "stringer -output load_store_string.go -type=Mode,Size"; DO NOT EDIT.
package asm
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[InvalidMode-255]
_ = x[ImmMode-0]
_ = x[AbsMode-32]
_ = x[IndMode-64]
_ = x[MemMode-96]
_ = x[MemSXMode-128]
_ = x[AtomicMode-192]
}
const (
_Mode_name_0 = "ImmMode"
_Mode_name_1 = "AbsMode"
_Mode_name_2 = "IndMode"
_Mode_name_3 = "MemMode"
_Mode_name_4 = "MemSXMode"
_Mode_name_5 = "AtomicMode"
_Mode_name_6 = "InvalidMode"
)
func (i Mode) String() string {
switch {
case i == 0:
return _Mode_name_0
case i == 32:
return _Mode_name_1
case i == 64:
return _Mode_name_2
case i == 96:
return _Mode_name_3
case i == 128:
return _Mode_name_4
case i == 192:
return _Mode_name_5
case i == 255:
return _Mode_name_6
default:
return "Mode(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[InvalidSize-255]
_ = x[DWord-24]
_ = x[Word-0]
_ = x[Half-8]
_ = x[Byte-16]
}
const (
_Size_name_0 = "Word"
_Size_name_1 = "Half"
_Size_name_2 = "Byte"
_Size_name_3 = "DWord"
_Size_name_4 = "InvalidSize"
)
func (i Size) String() string {
switch {
case i == 0:
return _Size_name_0
case i == 8:
return _Size_name_1
case i == 16:
return _Size_name_2
case i == 24:
return _Size_name_3
case i == 255:
return _Size_name_4
default:
return "Size(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
================================================
FILE: asm/metadata.go
================================================
package asm
// Metadata contains metadata about an instruction.
type Metadata struct {
head *metaElement
}
type metaElement struct {
next *metaElement
key, value interface{}
}
// Find the element containing key.
//
// Returns nil if there is no such element.
func (m *Metadata) find(key interface{}) *metaElement {
for e := m.head; e != nil; e = e.next {
if e.key == key {
return e
}
}
return nil
}
// Remove an element from the linked list.
//
// Copies as many elements of the list as necessary to remove r, but doesn't
// perform a full copy.
func (m *Metadata) remove(r *metaElement) {
current := &m.head
for e := m.head; e != nil; e = e.next {
if e == r {
// We've found the element we want to remove.
*current = e.next
// No need to copy the tail.
return
}
// There is another element in front of the one we want to remove.
// We have to copy it to be able to change metaElement.next.
cpy := &metaElement{key: e.key, value: e.value}
*current = cpy
current = &cpy.next
}
}
// Set a key to a value.
//
// If value is nil, the key is removed. Avoids modifying old metadata by
// copying if necessary.
func (m *Metadata) Set(key, value interface{}) {
if e := m.find(key); e != nil {
if e.value == value {
// Key is present and the value is the same. Nothing to do.
return
}
// Key is present with a different value. Create a copy of the list
// which doesn't have the element in it.
m.remove(e)
}
// m.head is now a linked list that doesn't contain key.
if value == nil {
return
}
m.head = &metaElement{key: key, value: value, next: m.head}
}
// Get the value of a key.
//
// Returns nil if no value with the given key is present.
func (m *Metadata) Get(key interface{}) interface{} {
if e := m.find(key); e != nil {
return e.value
}
return nil
}
================================================
FILE: asm/metadata_test.go
================================================
package asm
import (
"testing"
"unsafe"
"github.com/go-quicktest/qt"
)
func TestMetadata(t *testing.T) {
var m Metadata
// Metadata should be the size of a pointer.
qt.Assert(t, qt.Equals(unsafe.Sizeof(m), unsafe.Sizeof(uintptr(0))))
// A lookup in a nil meta should return nil.
qt.Assert(t, qt.IsNil(m.Get(bool(false))))
// We can look up anything we inserted.
m.Set(bool(false), int(0))
m.Set(int(1), int(1))
qt.Assert(t, qt.Equals(m.Get(bool(false)), 0))
qt.Assert(t, qt.Equals(m.Get(1), 1))
// We have copy on write semantics
old := m
m.Set(bool(false), int(1))
qt.Assert(t, qt.Equals(m.Get(bool(false)), 1))
qt.Assert(t, qt.Equals(m.Get(int(1)), 1))
qt.Assert(t, qt.Equals(old.Get(bool(false)), 0))
qt.Assert(t, qt.Equals(old.Get(int(1)), 1))
// Newtypes are handled distinctly.
type b bool
m.Set(b(false), int(42))
qt.Assert(t, qt.Equals(m.Get(bool(false)), 1))
qt.Assert(t, qt.Equals(m.Get(int(1)), 1))
qt.Assert(t, qt.Equals(m.Get(b(false)), 42))
// Setting nil removes a key.
m.Set(bool(false), nil)
qt.Assert(t, qt.IsNil(m.Get(bool(false))))
qt.Assert(t, qt.Equals(m.Get(int(1)), 1))
qt.Assert(t, qt.Equals(m.Get(b(false)), 42))
}
func BenchmarkMetadata(b *testing.B) {
// Assume that three bits of metadata on a single instruction is
// our worst case.
const worstCaseItems = 3
type t struct{}
b.Run("add first", func(b *testing.B) {
b.ReportAllocs()
for b.Loop() {
var v Metadata
v.Set(t{}, 0)
}
})
b.Run("add last", func(b *testing.B) {
var m Metadata
for i := 0; i < worstCaseItems-1; i++ {
m.Set(i, i)
}
b.ReportAllocs()
for b.Loop() {
v := m
v.Set(t{}, 0)
}
})
b.Run("add existing", func(b *testing.B) {
var m Metadata
for i := 0; i < worstCaseItems-1; i++ {
m.Set(i, i)
}
m.Set(t{}, 0)
b.ReportAllocs()
for b.Loop() {
v := m
v.Set(t{}, 0)
}
})
b.Run("get miss", func(b *testing.B) {
var m Metadata
for i := 0; i < worstCaseItems; i++ {
m.Set(i, i)
}
b.ReportAllocs()
for b.Loop() {
if m.Get(t{}) != nil {
b.Fatal("got result from miss")
}
}
})
}
================================================
FILE: asm/opcode.go
================================================
package asm
import (
"fmt"
"strings"
)
//go:generate go tool stringer -output opcode_string.go -type=Class
// Class of operations
//
// msb lsb
// +---+--+---+
// | ?? |CLS|
// +---+--+---+
type Class uint8
const classMask OpCode = 0x07
const (
// LdClass loads immediate values into registers.
// Also used for non-standard load operations from cBPF.
LdClass Class = 0x00
// LdXClass loads memory into registers.
LdXClass Class = 0x01
// StClass stores immediate values to memory.
StClass Class = 0x02
// StXClass stores registers to memory.
StXClass Class = 0x03
// ALUClass describes arithmetic operators.
ALUClass Class = 0x04
// JumpClass describes jump operators.
JumpClass Class = 0x05
// Jump32Class describes jump operators with 32-bit comparisons.
// Requires kernel 5.1.
Jump32Class Class = 0x06
// ALU64Class describes arithmetic operators in 64-bit mode.
ALU64Class Class = 0x07
)
// IsLoad checks if this is either LdClass or LdXClass.
func (cls Class) IsLoad() bool {
return cls == LdClass || cls == LdXClass
}
// IsStore checks if this is either StClass or StXClass.
func (cls Class) IsStore() bool {
return cls == StClass || cls == StXClass
}
func (cls Class) isLoadOrStore() bool {
return cls.IsLoad() || cls.IsStore()
}
// IsALU checks if this is either ALUClass or ALU64Class.
func (cls Class) IsALU() bool {
return cls == ALUClass || cls == ALU64Class
}
// IsJump checks if this is either JumpClass or Jump32Class.
func (cls Class) IsJump() bool {
return cls == JumpClass || cls == Jump32Class
}
func (cls Class) isJumpOrALU() bool {
return cls.IsJump() || cls.IsALU()
}
// OpCode represents a single operation.
// It is not a 1:1 mapping to real eBPF opcodes.
//
// The encoding varies based on a 3-bit Class:
//
// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
// ??? | CLS
//
// For ALUClass and ALUCLass32:
//
// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
// 0 | OPC |S| CLS
//
// For LdClass, LdXclass, StClass and StXClass:
//
// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
// 0 | MDE |SIZ| CLS
//
// For StXClass where MDE == AtomicMode:
//
// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
// 0 | ATOMIC OP | MDE |SIZ| CLS
//
// For JumpClass, Jump32Class:
//
// 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
// 0 | OPC |S| CLS
type OpCode uint32
// InvalidOpCode is returned by setters on OpCode
const InvalidOpCode OpCode = 0xffff
// bpfOpCode returns the actual BPF opcode.
func (op OpCode) bpfOpCode() (byte, error) {
const opCodeMask = 0xff
if !valid(op, opCodeMask) {
return 0, fmt.Errorf("invalid opcode %x", op)
}
return byte(op & opCodeMask), nil
}
// rawInstructions returns the number of BPF instructions required
// to encode this opcode.
func (op OpCode) rawInstructions() int {
if op.IsDWordLoad() {
return 2
}
return 1
}
func (op OpCode) IsDWordLoad() bool {
return op == LoadImmOp(DWord)
}
// Class returns the class of operation.
func (op OpCode) Class() Class {
return Class(op & classMask)
}
// Mode returns the mode for load and store operations.
func (op OpCode) Mode() Mode {
if !op.Class().isLoadOrStore() {
return InvalidMode
}
return Mode(op & modeMask)
}
// Size returns the size for load and store operations.
func (op OpCode) Size() Size {
if !op.Class().isLoadOrStore() {
return InvalidSize
}
return Size(op & sizeMask)
}
// AtomicOp returns the type of atomic operation.
func (op OpCode) AtomicOp() AtomicOp {
if op.Class() != StXClass || op.Mode() != AtomicMode {
return InvalidAtomic
}
return AtomicOp(op & atomicMask)
}
// Source returns the source for branch and ALU operations.
func (op OpCode) Source() Source {
if !op.Class().isJumpOrALU() || op.ALUOp() == Swap {
return InvalidSource
}
return Source(op & sourceMask)
}
// ALUOp returns the ALUOp.
func (op OpCode) ALUOp() ALUOp {
if !op.Class().IsALU() {
return InvalidALUOp
}
return ALUOp(op & aluMask)
}
// Endianness returns the Endianness for a byte swap instruction.
func (op OpCode) Endianness() Endianness {
if op.ALUOp() != Swap {
return InvalidEndian
}
return Endianness(op & endianMask)
}
// JumpOp returns the JumpOp.
// Returns InvalidJumpOp if it doesn't encode a jump.
func (op OpCode) JumpOp() JumpOp {
if !op.Class().IsJump() {
return InvalidJumpOp
}
jumpOp := JumpOp(op & jumpMask)
// Some JumpOps are only supported by JumpClass, not Jump32Class.
if op.Class() == Jump32Class && (jumpOp == Exit || jumpOp == Call) {
return InvalidJumpOp
}
return jumpOp
}
// SetMode sets the mode on load and store operations.
//
// Returns InvalidOpCode if op is of the wrong class.
func (op OpCode) SetMode(mode Mode) OpCode {
if !op.Class().isLoadOrStore() || !valid(OpCode(mode), modeMask) {
return InvalidOpCode
}
return (op & ^modeMask) | OpCode(mode)
}
// SetSize sets the size on load and store operations.
//
// Returns InvalidOpCode if op is of the wrong class.
func (op OpCode) SetSize(size Size) OpCode {
if !op.Class().isLoadOrStore() || !valid(OpCode(size), sizeMask) {
return InvalidOpCode
}
return (op & ^sizeMask) | OpCode(size)
}
func (op OpCode) SetAtomicOp(atomic AtomicOp) OpCode {
if op.Class() != StXClass || op.Mode() != AtomicMode || !valid(OpCode(atomic), atomicMask) {
return InvalidOpCode
}
return (op & ^atomicMask) | OpCode(atomic)
}
// SetSource sets the source on jump and ALU operations.
//
// Returns InvalidOpCode if op is of the wrong class.
func (op OpCode) SetSource(source Source) OpCode {
if !op.Class().isJumpOrALU() || !valid(OpCode(source), sourceMask) {
return InvalidOpCode
}
return (op & ^sourceMask) | OpCode(source)
}
// SetALUOp sets the ALUOp on ALU operations.
//
// Returns InvalidOpCode if op is of the wrong class.
func (op OpCode) SetALUOp(alu ALUOp) OpCode {
if !op.Class().IsALU() || !valid(OpCode(alu), aluMask) {
return InvalidOpCode
}
return (op & ^aluMask) | OpCode(alu)
}
// SetJumpOp sets the JumpOp on jump operations.
//
// Returns InvalidOpCode if op is of the wrong class.
func (op OpCode) SetJumpOp(jump JumpOp) OpCode {
if !op.Class().IsJump() || !valid(OpCode(jump), jumpMask) {
return InvalidOpCode
}
newOp := (op & ^jumpMask) | OpCode(jump)
// Check newOp is legal.
if newOp.JumpOp() == InvalidJumpOp {
return InvalidOpCode
}
return newOp
}
func (op OpCode) String() string {
var f strings.Builder
switch class := op.Class(); {
case class.isLoadOrStore():
f.WriteString(strings.TrimSuffix(class.String(), "Class"))
mode := op.Mode()
f.WriteString(strings.TrimSuffix(mode.String(), "Mode"))
if atomic := op.AtomicOp(); atomic != InvalidAtomic {
f.WriteString(strings.TrimSuffix(atomic.String(), "Atomic"))
}
switch op.Size() {
case DWord:
f.WriteString("DW")
case Word:
f.WriteString("W")
case Half:
f.WriteString("H")
case Byte:
f.WriteString("B")
}
case class.IsALU():
if op.ALUOp() == Swap && op.Class() == ALU64Class {
// B to make BSwap, uncontitional byte swap
f.WriteString("B")
}
f.WriteString(op.ALUOp().String())
if op.ALUOp() == Swap {
if op.Class() == ALUClass {
// Width for Endian is controlled by Constant
f.WriteString(op.Endianness().String())
}
} else {
f.WriteString(strings.TrimSuffix(op.Source().String(), "Source"))
if class == ALUClass {
f.WriteString("32")
}
}
case class.IsJump():
f.WriteString(op.JumpOp().String())
if class == Jump32Class {
f.WriteString("32")
}
if jop := op.JumpOp(); jop != Exit && jop != Call && jop != Ja {
f.WriteString(strings.TrimSuffix(op.Source().String(), "Source"))
}
default:
fmt.Fprintf(&f, "OpCode(%#x)", uint8(op))
}
return f.String()
}
// valid returns true if all bits in value are covered by mask.
func valid(value, mask OpCode) bool {
return value & ^mask == 0
}
================================================
FILE: asm/opcode_string.go
================================================
// Code generated by "stringer -output opcode_string.go -type=Class"; DO NOT EDIT.
package asm
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[LdClass-0]
_ = x[LdXClass-1]
_ = x[StClass-2]
_ = x[StXClass-3]
_ = x[ALUClass-4]
_ = x[JumpClass-5]
_ = x[Jump32Class-6]
_ = x[ALU64Class-7]
}
const _Class_name = "LdClassLdXClassStClassStXClassALUClassJumpClassJump32ClassALU64Class"
var _Class_index = [...]uint8{0, 7, 15, 22, 30, 38, 47, 58, 68}
func (i Class) String() string {
idx := int(i) - 0
if i < 0 || idx >= len(_Class_index)-1 {
return "Class(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _Class_name[_Class_index[idx]:_Class_index[idx+1]]
}
================================================
FILE: asm/opcode_test.go
================================================
package asm
import (
"fmt"
"testing"
"github.com/go-quicktest/qt"
)
func TestGetSetJumpOp(t *testing.T) {
test := func(class Class, op JumpOp, valid bool) {
t.Run(fmt.Sprintf("%s-%s", class, op), func(t *testing.T) {
opcode := OpCode(class).SetJumpOp(op)
if valid {
qt.Assert(t, qt.Not(qt.Equals(opcode, InvalidOpCode)))
qt.Assert(t, qt.Equals(opcode.JumpOp(), op))
} else {
qt.Assert(t, qt.Equals(opcode, InvalidOpCode))
qt.Assert(t, qt.Equals(opcode.JumpOp(), InvalidJumpOp))
}
})
}
// Exit and call aren't allowed with Jump32
test(Jump32Class, Exit, false)
test(Jump32Class, Call, false)
// But are with Jump
test(JumpClass, Exit, true)
test(JumpClass, Call, true)
// All other ops work
for _, op := range []JumpOp{
Ja,
JEq,
JGT,
JGE,
JSet,
JNE,
JSGT,
JSGE,
JLT,
JLE,
JSLT,
JSLE,
} {
test(Jump32Class, op, true)
test(JumpClass, op, true)
}
}
================================================
FILE: asm/register.go
================================================
package asm
import (
"fmt"
)
// Register is the source or destination of most operations.
type Register uint8
// R0 contains return values.
const R0 Register = 0
// Registers for function arguments.
const (
R1 Register = R0 + 1 + iota
R2
R3
R4
R5
)
// Callee saved registers preserved by function calls.
const (
R6 Register = R5 + 1 + iota
R7
R8
R9
)
// Read-only frame pointer to access stack.
const (
R10 Register = R9 + 1
RFP = R10
)
// Pseudo registers used by 64bit loads and jumps
const (
PseudoMapFD = R1 // BPF_PSEUDO_MAP_FD
PseudoMapValue = R2 // BPF_PSEUDO_MAP_VALUE
PseudoCall = R1 // BPF_PSEUDO_CALL
PseudoFunc = R4 // BPF_PSEUDO_FUNC
PseudoKfuncCall = R2 // BPF_PSEUDO_KFUNC_CALL
)
func (r Register) String() string {
v := uint8(r)
if v == 10 {
return "rfp"
}
return fmt.Sprintf("r%d", v)
}
================================================
FILE: attachtype_string.go
================================================
// Code generated by "stringer -type AttachType -trimprefix Attach"; DO NOT EDIT.
package ebpf
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[AttachNone-0]
_ = x[AttachCGroupInetIngress-0]
_ = x[AttachCGroupInetEgress-1]
_ = x[AttachCGroupInetSockCreate-2]
_ = x[AttachCGroupSockOps-3]
_ = x[AttachSkSKBStreamParser-4]
_ = x[AttachSkSKBStreamVerdict-5]
_ = x[AttachCGroupDevice-6]
_ = x[AttachSkMsgVerdict-7]
_ = x[AttachCGroupInet4Bind-8]
_ = x[AttachCGroupInet6Bind-9]
_ = x[AttachCGroupInet4Connect-10]
_ = x[AttachCGroupInet6Connect-11]
_ = x[AttachCGroupInet4PostBind-12]
_ = x[AttachCGroupInet6PostBind-13]
_ = x[AttachCGroupUDP4Sendmsg-14]
_ = x[AttachCGroupUDP6Sendmsg-15]
_ = x[AttachLircMode2-16]
_ = x[AttachFlowDissector-17]
_ = x[AttachCGroupSysctl-18]
_ = x[AttachCGroupUDP4Recvmsg-19]
_ = x[AttachCGroupUDP6Recvmsg-20]
_ = x[AttachCGroupGetsockopt-21]
_ = x[AttachCGroupSetsockopt-22]
_ = x[AttachTraceRawTp-23]
_ = x[AttachTraceFEntry-24]
_ = x[AttachTraceFExit-25]
_ = x[AttachModifyReturn-26]
_ = x[AttachLSMMac-27]
_ = x[AttachTraceIter-28]
_ = x[AttachCgroupInet4GetPeername-29]
_ = x[AttachCgroupInet6GetPeername-30]
_ = x[AttachCgroupInet4GetSockname-31]
_ = x[AttachCgroupInet6GetSockname-32]
_ = x[AttachXDPDevMap-33]
_ = x[AttachCgroupInetSockRelease-34]
_ = x[AttachXDPCPUMap-35]
_ = x[AttachSkLookup-36]
_ = x[AttachXDP-37]
_ = x[AttachSkSKBVerdict-38]
_ = x[AttachSkReuseportSelect-39]
_ = x[AttachSkReuseportSelectOrMigrate-40]
_ = x[AttachPerfEvent-41]
_ = x[AttachTraceKprobeMulti-42]
_ = x[AttachTraceKprobeSession-56]
_ = x[AttachLSMCgroup-43]
_ = x[AttachStructOps-44]
_ = x[AttachNetfilter-45]
_ = x[AttachTCXIngress-46]
_ = x[AttachTCXEgress-47]
_ = x[AttachTraceUprobeMulti-48]
_ = x[AttachCgroupUnixConnect-49]
_ = x[AttachCgroupUnixSendmsg-50]
_ = x[AttachCgroupUnixRecvmsg-51]
_ = x[AttachCgroupUnixGetpeername-52]
_ = x[AttachCgroupUnixGetsockname-53]
_ = x[AttachNetkitPrimary-54]
_ = x[AttachNetkitPeer-55]
_ = x[AttachWindowsXDP-268435457]
_ = x[AttachWindowsBind-268435458]
_ = x[AttachWindowsCGroupInet4Connect-268435459]
_ = x[AttachWindowsCGroupInet6Connect-268435460]
_ = x[AttachWindowsCgroupInet4RecvAccept-268435461]
_ = x[AttachWindowsCgroupInet6RecvAccept-268435462]
_ = x[AttachWindowsCGroupSockOps-268435463]
_ = x[AttachWindowsSample-268435464]
_ = x[AttachWindowsXDPTest-268435465]
}
const (
_AttachType_name_0 = "NoneCGroupInetEgressCGroupInetSockCreateCGroupSockOpsSkSKBStreamParserSkSKBStreamVerdictCGroupDeviceSkMsgVerdictCGroupInet4BindCGroupInet6BindCGroupInet4ConnectCGroupInet6ConnectCGroupInet4PostBindCGroupInet6PostBindCGroupUDP4SendmsgCGroupUDP6SendmsgLircMode2FlowDissectorCGroupSysctlCGroupUDP4RecvmsgCGroupUDP6RecvmsgCGroupGetsockoptCGroupSetsockoptTraceRawTpTraceFEntryTraceFExitModifyReturnLSMMacTraceIterCgroupInet4GetPeernameCgroupInet6GetPeernameCgroupInet4GetSocknameCgroupInet6GetSocknameXDPDevMapCgroupInetSockReleaseXDPCPUMapSkLookupXDPSkSKBVerdictSkReuseportSelectSkReuseportSelectOrMigratePerfEventTraceKprobeMultiLSMCgroupStructOpsNetfilterTCXIngressTCXEgressTraceUprobeMultiCgroupUnixConnectCgroupUnixSendmsgCgroupUnixRecvmsgCgroupUnixGetpeernameCgroupUnixGetsocknameNetkitPrimaryNetkitPeerTraceKprobeSession"
_AttachType_name_1 = "WindowsXDPWindowsBindWindowsCGroupInet4ConnectWindowsCGroupInet6ConnectWindowsCgroupInet4RecvAcceptWindowsCgroupInet6RecvAcceptWindowsCGroupSockOpsWindowsSampleWindowsXDPTest"
)
var (
_AttachType_index_0 = [...]uint16{0, 4, 20, 40, 53, 70, 88, 100, 112, 127, 142, 160, 178, 197, 216, 233, 250, 259, 272, 284, 301, 318, 334, 350, 360, 371, 381, 393, 399, 408, 430, 452, 474, 496, 505, 526, 535, 543, 546, 558, 575, 601, 610, 626, 635, 644, 653, 663, 672, 688, 705, 722, 739, 760, 781, 794, 804, 822}
_AttachType_index_1 = [...]uint8{0, 10, 21, 46, 71, 99, 127, 147, 160, 174}
)
func (i AttachType) String() string {
switch {
case i <= 56:
return _AttachType_name_0[_AttachType_index_0[i]:_AttachType_index_0[i+1]]
case 268435457 <= i && i <= 268435465:
i -= 268435457
return _AttachType_name_1[_AttachType_index_1[i]:_AttachType_index_1[i+1]]
default:
return "AttachType(" + strconv.FormatInt(int64(i), 10) + ")"
}
}
================================================
FILE: btf/btf.go
================================================
package btf
import (
"debug/elf"
"errors"
"fmt"
"io"
"iter"
"maps"
"math"
"os"
"reflect"
"slices"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/sys"
)
const btfMagic = 0xeB9F
// Errors returned by BTF functions.
var (
ErrNotSupported = internal.ErrNotSupported
ErrNotFound = errors.New("not found")
ErrNoExtendedInfo = errors.New("no extended info")
ErrMultipleMatches = errors.New("multiple matching types")
)
// ID represents the unique ID of a BTF object.
type ID = sys.BTFID
type elfData struct {
sectionSizes map[string]uint32
symbolOffsets map[elfSymbol]uint32
fixups map[Type]bool
}
type elfSymbol struct {
section string
name string
}
// Spec allows querying a set of Types and loading the set into the
// kernel.
type Spec struct {
*decoder
// Additional data from ELF, may be nil.
elf *elfData
}
// LoadSpec opens file and calls LoadSpecFromReader on it.
func LoadSpec(file string) (*Spec, error) {
fh, err := os.Open(file)
if err != nil {
return nil, err
}
defer fh.Close()
return LoadSpecFromReader(fh)
}
// LoadSpecFromReader reads from an ELF or a raw BTF blob.
//
// Returns ErrNotFound if reading from an ELF which contains no BTF. ExtInfos
// may be nil.
func LoadSpecFromReader(rd io.ReaderAt) (*Spec, error) {
file, err := internal.NewSafeELFFile(rd)
if err != nil {
raw, err := io.ReadAll(io.NewSectionReader(rd, 0, math.MaxInt64))
if err != nil {
return nil, fmt.Errorf("read raw BTF: %w", err)
}
return loadRawSpec(raw, nil)
}
return loadSpecFromELF(file)
}
// LoadSpecAndExtInfosFromReader reads from an ELF.
//
// ExtInfos may be nil if the ELF doesn't contain section metadata.
// Returns ErrNotFound if the ELF contains no BTF.
func LoadSpecAndExtInfosFromReader(rd io.ReaderAt) (*Spec, *ExtInfos, error) {
file, err := internal.NewSafeELFFile(rd)
if err != nil {
return nil, nil, err
}
spec, err := loadSpecFromELF(file)
if err != nil {
return nil, nil, err
}
extInfos, err := loadExtInfosFromELF(file, spec)
if err != nil && !errors.Is(err, ErrNotFound) {
return nil, nil, err
}
return spec, extInfos, nil
}
// symbolOffsets extracts all symbols offsets from an ELF and indexes them by
// section and variable name.
//
// References to variables in BTF data sections carry unsigned 32-bit offsets.
// Some ELF symbols (e.g. in vmlinux) may point to virtual memory that is well
// beyond this range. Since these symbols cannot be described by BTF info,
// ignore them here.
func symbolOffsets(file *internal.SafeELFFile) (map[elfSymbol]uint32, error) {
symbols, err := file.Symbols()
if err != nil {
return nil, fmt.Errorf("can't read symbols: %v", err)
}
offsets := make(map[elfSymbol]uint32)
for _, sym := range symbols {
if idx := sym.Section; idx >= elf.SHN_LORESERVE && idx <= elf.SHN_HIRESERVE {
// Ignore things like SHN_ABS
continue
}
if sym.Value > math.MaxUint32 {
// VarSecinfo offset is u32, cannot reference symbols in higher regions.
continue
}
if int(sym.Section) >= len(file.Sections) {
return nil, fmt.Errorf("symbol %s: invalid section %d", sym.Name, sym.Section)
}
secName := file.Sections[sym.Section].Name
offsets[elfSymbol{secName, sym.Name}] = uint32(sym.Value)
}
return offsets, nil
}
func loadSpecFromELF(file *internal.SafeELFFile) (*Spec, error) {
var (
btfSection *elf.Section
sectionSizes = make(map[string]uint32)
)
for _, sec := range file.Sections {
switch sec.Name {
case ".BTF":
btfSection = sec
default:
if sec.Type != elf.SHT_PROGBITS && sec.Type != elf.SHT_NOBITS {
break
}
if sec.Size > math.MaxUint32 {
return nil, fmt.Errorf("section %s exceeds maximum size", sec.Name)
}
sectionSizes[sec.Name] = uint32(sec.Size)
}
}
if btfSection == nil {
return nil, fmt.Errorf("btf: %w", ErrNotFound)
}
offsets, err := symbolOffsets(file)
if err != nil {
return nil, err
}
rawBTF, err := btfSection.Data()
if err != nil {
return nil, fmt.Errorf("reading .BTF section: %w", err)
}
spec, err := loadRawSpec(rawBTF, nil)
if err != nil {
return nil, err
}
if spec.decoder.byteOrder != file.ByteOrder {
return nil, fmt.Errorf("BTF byte order %s does not match ELF byte order %s", spec.decoder.byteOrder, file.ByteOrder)
}
spec.elf = &elfData{
sectionSizes,
offsets,
make(map[Type]bool),
}
return spec, nil
}
func loadRawSpec(btf []byte, base *Spec) (*Spec, error) {
var (
baseDecoder *decoder
baseStrings *stringTable
err error
)
if base != nil {
baseDecoder = base.decoder
baseStrings = base.strings
}
header, bo, err := parseBTFHeader(btf)
if err != nil {
return nil, fmt.Errorf("parsing .BTF header: %v", err)
}
if header.HdrLen > uint32(len(btf)) {
return nil, fmt.Errorf("BTF header length is out of bounds")
}
btf = btf[header.HdrLen:]
if int(header.StringOff+header.StringLen) > len(btf) {
return nil, fmt.Errorf("string table is out of bounds")
}
stringsSection := btf[header.StringOff : header.StringOff+header.StringLen]
rawStrings, err := newStringTable(stringsSection, baseStrings)
if err != nil {
return nil, fmt.Errorf("read string section: %w", err)
}
if int(header.TypeOff+header.TypeLen) > len(btf) {
return nil, fmt.Errorf("types section is out of bounds")
}
typesSection := btf[header.TypeOff : header.TypeOff+header.TypeLen]
decoder, err := newDecoder(typesSection, bo, rawStrings, baseDecoder)
if err != nil {
return nil, err
}
return &Spec{decoder, nil}, nil
}
// fixupDatasec attempts to patch up missing info in Datasecs and its members by
// supplementing them with information from the ELF headers and symbol table.
func (elf *elfData) fixupDatasec(typ Type) error {
if elf == nil {
return nil
}
if ds, ok := typ.(*Datasec); ok {
if elf.fixups[ds] {
return nil
}
elf.fixups[ds] = true
name := ds.Name
// Some Datasecs are virtual and don't have corresponding ELF sections.
switch name {
case ".ksyms":
// .ksyms describes forward declarations of kfunc signatures, as well as
// references to kernel symbols.
// Nothing to fix up, all sizes and offsets are 0.
for _, vsi := range ds.Vars {
switch t := vsi.Type.(type) {
case *Func:
continue
case *Var:
if _, ok := t.Type.(*Void); !ok {
return fmt.Errorf("data section %s: expected %s to be *Void, not %T: %w", name, vsi.Type.TypeName(), vsi.Type, ErrNotSupported)
}
default:
return fmt.Errorf("data section %s: expected to be either *btf.Func or *btf.Var, not %T: %w", name, vsi.Type, ErrNotSupported)
}
}
return nil
case ".kconfig":
// .kconfig has a size of 0 and has all members' offsets set to 0.
// Fix up all offsets and set the Datasec's size.
if err := fixupDatasecLayout(ds); err != nil {
return err
}
// Fix up extern to global linkage to avoid a BTF verifier error.
for _, vsi := range ds.Vars {
vsi.Type.(*Var).Linkage = GlobalVar
}
return nil
}
if ds.Size != 0 {
return nil
}
ds.Size, ok = elf.sectionSizes[name]
if !ok {
return fmt.Errorf("data section %s: missing size", name)
}
for i := range ds.Vars {
symName := ds.Vars[i].Type.TypeName()
ds.Vars[i].Offset, ok = elf.symbolOffsets[elfSymbol{name, symName}]
if !ok {
return fmt.Errorf("data section %s: missing offset for symbol %s", name, symName)
}
}
}
return nil
}
// fixupDatasecLayout populates ds.Vars[].Offset according to var sizes and
// alignment. Calculate and set ds.Size.
func fixupDatasecLayout(ds *Datasec) error {
var off uint32
for i, vsi := range ds.Vars {
v, ok := vsi.Type.(*Var)
if !ok {
return fmt.Errorf("member %d: unsupported type %T", i, vsi.Type)
}
size, err := Sizeof(v.Type)
if err != nil {
return fmt.Errorf("variable %s: getting size: %w", v.Name, err)
}
align, err := alignof(v.Type)
if err != nil {
return fmt.Errorf("variable %s: getting alignment: %w", v.Name, err)
}
// Align the current member based on the offset of the end of the previous
// member and the alignment of the current member.
off = internal.Align(off, uint32(align))
ds.Vars[i].Offset = off
off += uint32(size)
}
ds.Size = off
return nil
}
// Copy a Spec.
//
// All contained types are duplicated while preserving any modifications made
// to them.
func (s *Spec) Copy() *Spec {
if s == nil {
return nil
}
cpy := &Spec{
s.decoder.Copy(),
nil,
}
if s.elf != nil {
cpy.elf = &elfData{
s.elf.sectionSizes,
s.elf.symbolOffsets,
maps.Clone(s.elf.fixups),
}
}
return cpy
}
// TypeByID returns the BTF Type with the given type ID.
//
// Returns an error wrapping ErrNotFound if a Type with the given ID
// does not exist in the Spec.
func (s *Spec) TypeByID(id TypeID) (Type, error) {
typ, err := s.decoder.TypeByID(id)
if err != nil {
return nil, fmt.Errorf("inflate type: %w", err)
}
if err := s.elf.fixupDatasec(typ); err != nil {
return nil, err
}
return typ, nil
}
// TypeID returns the ID for a given Type.
//
// Returns an error wrapping [ErrNotFound] if the type isn't part of the Spec.
func (s *Spec) TypeID(typ Type) (TypeID, error) {
return s.decoder.TypeID(typ)
}
// AnyTypesByName returns a list of BTF Types with the given name.
//
// If the BTF blob describes multiple compilation units like vmlinux, multiple
// Types with the same name and kind can exist, but might not describe the same
// data structure.
//
// Returns an error wrapping ErrNotFound if no matching Type exists in the Spec.
func (s *Spec) AnyTypesByName(name string) ([]Type, error) {
types, err := s.TypesByName(newEssentialName(name))
if err != nil {
return nil, err
}
for i := 0; i < len(types); i++ {
// Match against the full name, not just the essential one
// in case the type being looked up is a struct flavor.
if types[i].TypeName() != name {
types = slices.Delete(types, i, i+1)
continue
}
if err := s.elf.fixupDatasec(types[i]); err != nil {
return nil, err
}
}
return types, nil
}
// AnyTypeByName returns a Type with the given name.
//
// Returns an error if multiple types of that name exist.
func (s *Spec) AnyTypeByName(name string) (Type, error) {
types, err := s.AnyTypesByName(name)
if err != nil {
return nil, err
}
if len(types) > 1 {
return nil, fmt.Errorf("found multiple types: %v", types)
}
return types[0], nil
}
// TypeByName searches for a Type with a specific name. Since multiple Types
// with the same name can exist, the parameter typ is taken to narrow down the
// search in case of a clash.
//
// typ must be a non-nil pointer to an implementation of a Type. On success, the
// address of the found Type will be copied to typ.
//
// Returns an error wrapping ErrNotFound if no matching Type exists in the Spec.
// Returns an error wrapping ErrMultipleTypes if multiple candidates are found.
func (s *Spec) TypeByName(name string, typ interface{}) error {
typeInterface := reflect.TypeOf((*Type)(nil)).Elem()
// typ may be **T or *Type
typValue := reflect.ValueOf(typ)
if typValue.Kind() != reflect.Ptr {
return fmt.Errorf("%T is not a pointer", typ)
}
typPtr := typValue.Elem()
if !typPtr.CanSet() {
return fmt.Errorf("%T cannot be set", typ)
}
wanted := typPtr.Type()
if wanted == typeInterface {
// This is *Type. Unwrap the value's type.
wanted = typPtr.Elem().Type()
}
if !wanted.AssignableTo(typeInterface) {
return fmt.Errorf("%T does not satisfy Type interface", typ)
}
types, err := s.AnyTypesByName(name)
if err != nil {
return err
}
var candidate Type
for _, typ := range types {
if reflect.TypeOf(typ) != wanted {
continue
}
if candidate != nil {
return fmt.Errorf("type %s(%T): %w", name, typ, ErrMultipleMatches)
}
candidate = typ
}
if candidate == nil {
return fmt.Errorf("%s %s: %w", wanted, name, ErrNotFound)
}
typPtr.Set(reflect.ValueOf(candidate))
return nil
}
// LoadSplitSpec loads split BTF from the given file.
//
// Types from base are used to resolve references in the split BTF.
// The returned Spec only contains types from the split BTF, not from the base.
func LoadSplitSpec(file string, base *Spec) (*Spec, error) {
fh, err := os.Open(file)
if err != nil {
return nil, err
}
defer fh.Close()
return LoadSplitSpecFromReader(fh, base)
}
// LoadSplitSpecFromReader loads split BTF from a reader.
//
// Types from base are used to resolve references in the split BTF.
// The returned Spec only contains types from the split BTF, not from the base.
func LoadSplitSpecFromReader(r io.ReaderAt, base *Spec) (*Spec, error) {
raw, err := io.ReadAll(io.NewSectionReader(r, 0, math.MaxInt64))
if err != nil {
return nil, fmt.Errorf("read raw BTF: %w", err)
}
return loadRawSpec(raw, base)
}
// All iterates over all types.
func (s *Spec) All() iter.Seq2[Type, error] {
return func(yield func(Type, error) bool) {
for id := s.firstTypeID; ; id++ {
typ, err := s.TypeByID(id)
if errors.Is(err, ErrNotFound) {
return
} else if err != nil {
yield(nil, err)
return
}
// Skip declTags, during unmarshaling declTags become `Tags` fields of other types.
// We keep them in the spec to avoid holes in the ID space, but for the purposes of
// iteration, they are not useful to the user.
if _, ok := typ.(*declTag); ok {
continue
}
if !yield(typ, nil) {
return
}
}
}
}
================================================
FILE: btf/btf_test.go
================================================
package btf
import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io/fs"
"os"
"runtime"
"sync"
"sync/atomic"
"testing"
"github.com/go-quicktest/qt"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/testutils"
)
func vmlinuxSpec(tb testing.TB) *Spec {
tb.Helper()
// /sys/kernel/btf was introduced in 341dfcf8d78e ("btf: expose BTF info
// through sysfs"), which shipped in Linux 5.4.
if _, err := os.Stat("/sys/kernel/btf/vmlinux"); errors.Is(err, fs.ErrNotExist) {
tb.Skip("No /sys/kernel/btf/vmlinux")
}
spec, err := LoadKernelSpec()
if err != nil {
tb.Fatal(err)
}
return spec
}
type specAndRawBTF struct {
raw []byte
spec *Spec
}
var vmlinuxTestdata = sync.OnceValues(func() (specAndRawBTF, error) {
b, err := internal.ReadAllCompressed("testdata/vmlinux.btf.gz")
if err != nil {
return specAndRawBTF{}, err
}
spec, err := loadRawSpec(b, nil)
if err != nil {
return specAndRawBTF{}, err
}
return specAndRawBTF{b, spec}, nil
})
func vmlinuxTestdataSpec(tb testing.TB) *Spec {
tb.Helper()
td, err := vmlinuxTestdata()
if err != nil {
tb.Fatal(err)
}
return td.spec.Copy()
}
func vmlinuxTestdataBytes(tb testing.TB) []byte {
tb.Helper()
td, err := vmlinuxTestdata()
if err != nil {
tb.Fatal(err)
}
return td.raw
}
func parseELFBTF(tb testing.TB, file string) *Spec {
tb.Helper()
spec, err := LoadSpec(file)
if err != nil {
tb.Fatal("Can't load BTF:", err)
}
return spec
}
func TestAnyTypesByName(t *testing.T) {
testutils.Files(t, testutils.Glob(t, "testdata/relocs-*.elf"), func(t *testing.T, file string) {
spec := parseELFBTF(t, file)
types, err := spec.AnyTypesByName("ambiguous")
if err != nil {
t.Fatal(err)
}
if len(types) != 1 {
t.Fatalf("expected to receive exactly 1 types from querying ambiguous type, got: %v", types)
}
types, err = spec.AnyTypesByName("ambiguous___flavour")
if err != nil {
t.Fatal(err)
}
if len(types) != 1 {
t.Fatalf("expected to receive exactly 1 type from querying ambiguous flavour, got: %v", types)
}
})
}
func TestTypeByNameAmbiguous(t *testing.T) {
testutils.Files(t, testutils.Glob(t, "testdata/relocs-*.elf"), func(t *testing.T, file string) {
spec := parseELFBTF(t, file)
var typ *Struct
if err := spec.TypeByName("ambiguous", &typ); err != nil {
t.Fatal(err)
}
if name := typ.TypeName(); name != "ambiguous" {
t.Fatal("expected type name 'ambiguous', got:", name)
}
if err := spec.TypeByName("ambiguous___flavour", &typ); err != nil {
t.Fatal(err)
}
if name := typ.TypeName(); name != "ambiguous___flavour" {
t.Fatal("expected type name 'ambiguous___flavour', got:", name)
}
})
}
func TestTypeByName(t *testing.T) {
spec := vmlinuxTestdataSpec(t)
for _, typ := range []interface{}{
nil,
Struct{},
&Struct{},
[]Struct{},
&[]Struct{},
map[int]Struct{},
&map[int]Struct{},
int(0),
new(int),
} {
t.Run(fmt.Sprintf("%T", typ), func(t *testing.T) {
// spec.TypeByName MUST fail if typ is a nil btf.Type.
if err := spec.TypeByName("iphdr", typ); err == nil {
t.Fatalf("TypeByName does not fail with type %T", typ)
}
})
}
// spec.TypeByName MUST return the same address for multiple calls with the same type name.
var iphdr1, iphdr2 *Struct
if err := spec.TypeByName("iphdr", &iphdr1); err != nil {
t.Fatal(err)
}
if err := spec.TypeByName("iphdr", &iphdr2); err != nil {
t.Fatal(err)
}
if iphdr1 != iphdr2 {
t.Fatal("multiple TypeByName calls for `iphdr` name do not return the same addresses")
}
// It's valid to pass a *Type to TypeByName.
typ := Type(iphdr2)
if err := spec.TypeByName("iphdr", &typ); err != nil {
t.Fatal("Can't look up using *Type:", err)
}
// Excerpt from linux/ip.h, https://elixir.bootlin.com/linux/latest/A/ident/iphdr
//
// struct iphdr {
// #if defined(__LITTLE_ENDIAN_BITFIELD)
// __u8 ihl:4, version:4;
// #elif defined (__BIG_ENDIAN_BITFIELD)
// __u8 version:4, ihl:4;
// #else
// ...
// }
//
// The BTF we test against is for little endian.
m := iphdr1.Members[1]
if m.Name != "version" {
t.Fatal("Expected version as the second member, got", m.Name)
}
td, ok := m.Type.(*Typedef)
if !ok {
t.Fatalf("version member of iphdr should be a __u8 typedef: actual: %T", m.Type)
}
u8, ok := td.Type.(*Int)
if !ok {
t.Fatalf("__u8 typedef should point to an Int type: actual: %T", td.Type)
}
if m.BitfieldSize != 4 {
t.Fatalf("incorrect bitfield size: expected: 4 actual: %d", m.BitfieldSize)
}
if u8.Encoding != 0 {
t.Fatalf("incorrect encoding of an __u8 int: expected: 0 actual: %x", u8.Encoding)
}
if m.Offset != 4 {
t.Fatalf("incorrect bitfield offset: expected: 4 actual: %d", m.Offset)
}
}
func BenchmarkParseVmlinux(b *testing.B) {
vmlinux := vmlinuxTestdataBytes(b)
b.ReportAllocs()
for b.Loop() {
if _, err := loadRawSpec(vmlinux, nil); err != nil {
b.Fatal("Can't load BTF:", err)
}
}
}
func BenchmarkIterateVmlinux(b *testing.B) {
vmlinux := vmlinuxTestdataBytes(b)
b.ReportAllocs()
for b.Loop() {
spec, err := loadRawSpec(vmlinux, nil)
if err != nil {
b.Fatal("Can't load BTF:", err)
}
for range spec.All() {
}
}
}
func TestParseCurrentKernelBTF(t *testing.T) {
spec := vmlinuxSpec(t)
if len(spec.offsets) == 0 {
t.Fatal("Empty kernel BTF")
}
}
func TestFindVMLinux(t *testing.T) {
file, err := findVMLinux()
testutils.SkipIfNotSupported(t, err)
if err != nil {
t.Fatal("Can't find vmlinux:", err)
}
defer file.Close()
spec, err := LoadSpecFromReader(file)
if err != nil {
t.Fatal("Can't load BTF:", err)
}
if len(spec.offsets) == 0 {
t.Fatal("Empty kernel BTF")
}
}
func TestLoadSpecFromElf(t *testing.T) {
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)
if err != nil {
t.Error("Can't retrieve void type by ID:", err)
}
if _, ok := vt.(*Void); !ok {
t.Errorf("Expected Void for type id 0, but got: %T", vt)
}
var bpfMapDef *Struct
if err := spec.TypeByName("bpf_map_def", &bpfMapDef); err != nil {
t.Error("Can't find bpf_map_def:", err)
}
var tmp *Void
if err := spec.TypeByName("totally_bogus_type", &tmp); !errors.Is(err, ErrNotFound) {
t.Error("TypeByName doesn't return ErrNotFound:", err)
}
var fn *Func
if err := spec.TypeByName("global_fn", &fn); err != nil {
t.Error("Can't find global_fn():", err)
} else {
if fn.Linkage != GlobalFunc {
t.Error("Expected global linkage:", fn)
}
}
var v *Var
if err := spec.TypeByName("key3", &v); err != nil {
t.Error("Can't find key3:", err)
} else {
if v.Linkage != GlobalVar {
t.Error("Expected global linkage:", v)
}
}
})
}
func TestVerifierError(t *testing.T) {
b, err := NewBuilder([]Type{&Int{Encoding: 255}}, nil)
qt.Assert(t, qt.IsNil(err))
_, err = NewHandle(b)
testutils.SkipIfNotSupported(t, err)
var ve *internal.VerifierError
if !errors.As(err, &ve) {
t.Fatalf("expected a VerifierError, got: %v", err)
}
}
func TestSpecCopy(t *testing.T) {
qt.Check(t, qt.IsNil((*Spec)(nil).Copy()))
spec := parseELFBTF(t, "../testdata/loader-el.elf")
cpy := spec.Copy()
have := typesFromSpec(t, spec)
qt.Assert(t, qt.IsTrue(len(have) > 0))
want := typesFromSpec(t, cpy)
qt.Assert(t, qt.HasLen(want, len(have)))
for i := range want {
if _, ok := have[i].(*Void); ok {
// Since Void is an empty struct, a Type interface value containing
// &Void{} stores (*Void, nil). Since interface equality first compares
// the type and then the concrete value, Void is always equal.
continue
}
if have[i] == want[i] {
t.Fatalf("Type at index %d is not a copy: %T == %T", i, have[i], want[i])
}
}
}
func TestSpecCopyModifications(t *testing.T) {
spec := specFromTypes(t, []Type{&Int{Name: "a", Size: 4}})
typ, err := spec.TypeByID(1)
qt.Assert(t, qt.IsNil(err))
i := typ.(*Int)
i.Name = "b"
i.Size = 2
cpy := spec.Copy()
typ2, err := cpy.TypeByID(1)
qt.Assert(t, qt.IsNil(err))
i2 := typ2.(*Int)
qt.Assert(t, qt.Not(qt.Equals(i2, i)), qt.Commentf("Types are distinct"))
qt.Assert(t, qt.DeepEquals(i2, i), qt.Commentf("Modifications are preserved"))
i.Name = "bar"
qt.Assert(t, qt.Equals(i2.Name, "b"))
}
func TestSpecTypeByID(t *testing.T) {
spec := specFromTypes(t, nil)
_, err := spec.TypeByID(0)
qt.Assert(t, qt.IsNil(err))
_, err = spec.TypeByID(1)
qt.Assert(t, qt.ErrorIs(err, ErrNotFound))
}
func ExampleSpec_TypeByName() {
// Acquire a Spec via one of its constructors.
spec := new(Spec)
// Declare a variable of the desired type
var foo *Struct
if err := spec.TypeByName("foo", &foo); err != nil {
// There is no struct with name foo, or there
// are multiple possibilities.
}
// We've found struct foo
fmt.Println(foo.Name)
}
func TestTypesIterator(t *testing.T) {
types := []Type{(*Void)(nil), &Int{Size: 4}, &Int{Size: 2}}
b, err := NewBuilder(types[1:], nil)
if err != nil {
t.Fatal(err)
}
raw, err := b.Marshal(nil, nil)
if err != nil {
t.Fatal(err)
}
spec, err := LoadSpecFromReader(bytes.NewReader(raw))
if err != nil {
t.Fatal(err)
}
var have []Type
for typ, err := range spec.All() {
qt.Assert(t, qt.IsNil(err))
have = append(have, typ)
}
qt.Assert(t, qt.DeepEquals(have, types))
}
func TestLoadSplitSpec(t *testing.T) {
spec, err := LoadSpec("testdata/btf_testmod.btf.base")
if err != nil {
t.Fatal(err)
}
splitSpec, err := LoadSplitSpec("testdata/btf_testmod.btf", spec)
if err != nil {
t.Fatal(err)
}
var fnType *Func
qt.Assert(t, qt.IsNil(splitSpec.TypeByName("bpf_testmod_init", &fnType)))
typeID, err := splitSpec.TypeID(fnType)
qt.Assert(t, qt.IsNil(err))
typeByID, err := splitSpec.TypeByID(typeID)
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.Equals(typeByID, Type(fnType)))
fnProto := fnType.Type.(*FuncProto)
// 'int' is defined in the base BTF...
intType, err := spec.AnyTypeByName("int")
qt.Assert(t, qt.IsNil(err))
// ... but not in the split BTF
_, err = splitSpec.AnyTypeByName("int")
qt.Assert(t, qt.ErrorIs(err, ErrNotFound))
qt.Assert(t, qt.Equals(fnProto.Return, intType),
qt.Commentf("types found in base of split spec should be reused"))
fnProto.Params = []FuncParam{{"a", &Pointer{(*Void)(nil)}}}
// The behaviour of copying a split spec is quite subtle. When initially
// creating a split spec, types in the split base are shared. This allows
// amortising the cost of decoding vmlinux.
//
// However, we currently define copying a spec to be like forking a process:
// in-memory changes to types are preserved. After the copy finished we have
// two fully independent states.
//
// For split BTF this means that we also need to copy the base and ensure
// that future references to a modified type work correctly.
splitSpecCopy := splitSpec.Copy()
var fnCopyType *Func
qt.Assert(t, qt.IsNil(splitSpecCopy.TypeByName("bpf_testmod_init", &fnCopyType)))
qt.Assert(t, testutils.IsDeepCopy(fnCopyType, fnType))
// Pull out a second type which refers to "int" in the base, but which hasn't
// been inflated yet. This forces inflating int from the base.
var str *Struct
qt.Assert(t, qt.IsNil(splitSpecCopy.TypeByName("bpf_testmod_struct_arg_1", &str)))
// Ensure that the int types are indeed the same.
qt.Assert(t, qt.Equals(str.Members[0].Type, fnCopyType.Type.(*FuncProto).Return))
copyTypeID, err := splitSpecCopy.TypeID(fnCopyType)
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.Equals(copyTypeID, typeID), qt.Commentf("ID of copied type must match"))
}
func TestFixupDatasecLayout(t *testing.T) {
ds := &Datasec{
Size: 0, // Populated by fixup.
Vars: []VarSecinfo{
{Type: &Var{Type: &Int{Size: 4}}},
{Type: &Var{Type: &Int{Size: 1}}},
{Type: &Var{Type: &Int{Size: 1}}},
{Type: &Var{Type: &Int{Size: 2}}},
{Type: &Var{Type: &Int{Size: 16}}},
{Type: &Var{Type: &Int{Size: 8}}},
},
}
qt.Assert(t, qt.IsNil(fixupDatasecLayout(ds)))
qt.Assert(t, qt.Equals(ds.Size, 40))
qt.Assert(t, qt.Equals(ds.Vars[0].Offset, 0))
qt.Assert(t, qt.Equals(ds.Vars[1].Offset, 4))
qt.Assert(t, qt.Equals(ds.Vars[2].Offset, 5))
qt.Assert(t, qt.Equals(ds.Vars[3].Offset, 6))
qt.Assert(t, qt.Equals(ds.Vars[4].Offset, 16))
qt.Assert(t, qt.Equals(ds.Vars[5].Offset, 32))
}
func TestSpecConcurrentAccess(t *testing.T) {
spec := vmlinuxTestdataSpec(t)
maxprocs := runtime.GOMAXPROCS(0)
if maxprocs < 2 {
t.Error("GOMAXPROCS is lower than 2:", maxprocs)
}
var cond atomic.Int64
var wg sync.WaitGroup
for i := 0; i < maxprocs; i++ {
wg.Add(1)
go func() {
defer wg.Done()
n := cond.Add(1)
for cond.Load() != int64(maxprocs) {
// Spin to increase the chances of a race.
}
if n%2 == 0 {
_, _ = spec.AnyTypeByName("gov_update_cpu_data")
} else {
_ = spec.Copy()
}
}()
// Try to get the Goroutines scheduled and spinning.
runtime.Gosched()
}
wg.Wait()
}
func TestLoadEmptyRawSpec(t *testing.T) {
buf, err := binary.Append(nil, binary.LittleEndian, &btfHeader{
Magic: btfMagic,
Version: 1,
Flags: 0,
HdrLen: uint32(btfHeaderLen),
TypeOff: 0,
TypeLen: 0,
StringOff: 0,
StringLen: 0,
})
qt.Assert(t, qt.IsNil(err))
_, err = loadRawSpec(buf, nil)
qt.Assert(t, qt.IsNil(err))
}
func BenchmarkSpecCopy(b *testing.B) {
spec := vmlinuxTestdataSpec(b)
for b.Loop() {
spec.Copy()
}
}
func BenchmarkSpecTypeByID(b *testing.B) {
spec := vmlinuxTestdataSpec(b)
b.ReportAllocs()
for b.Loop() {
_, err := spec.TypeByID(1)
if err != nil {
b.Fatal(err)
}
}
}
func BenchmarkInspektorGadget(b *testing.B) {
// This benchmark is the baseline for what Inspektor Gadget loads for a
// common configuration.
types := []string{
"pt_regs",
"file",
"inode",
"super_block",
"socket",
"syscall_trace_enter",
"task_struct",
"nsproxy",
"mnt_namespace",
// "fanotify_event",
"pid",
"trace_event_raw_sched_process_exec",
"fs_struct",
"path",
"mount",
"qstr",
"vfsmount",
"dentry",
// "bpf_func_id",
"mm_struct",
"syscall_trace_exit",
"linux_binprm",
"sock",
"net",
"inet_sock",
}
vmlinux, err := internal.ReadAllCompressed("testdata/vmlinux.btf.gz")
qt.Assert(b, qt.IsNil(err))
var rd bytes.Reader
for b.Loop() {
rd.Reset(vmlinux)
spec, err := LoadSpecFromReader(&rd)
if err != nil {
b.Fatal(err)
}
var s *Struct
for _, name := range types {
if err := spec.TypeByName(name, &s); err != nil {
b.Fatal(name, err)
}
}
}
}
================================================
FILE: btf/btf_types.go
================================================
package btf
import (
"encoding/binary"
"errors"
"fmt"
"unsafe"
)
//go:generate go tool stringer -linecomment -output=btf_types_string.go -type=FuncLinkage,VarLinkage,btfKind
// btfKind describes a Type.
type btfKind uint8
// Equivalents of the BTF_KIND_* constants.
const (
kindUnknown btfKind = iota // Unknown
kindInt // Int
kindPointer // Pointer
kindArray // Array
kindStruct // Struct
kindUnion // Union
kindEnum // Enum
kindForward // Forward
kindTypedef // Typedef
kindVolatile // Volatile
kindConst // Const
kindRestrict // Restrict
// Added ~4.20
kindFunc // Func
kindFuncProto // FuncProto
// Added ~5.1
kindVar // Var
kindDatasec // Datasec
// Added ~5.13
kindFloat // Float
// Added 5.16
kindDeclTag // DeclTag
// Added 5.17
kindTypeTag // TypeTag
// Added 6.0
kindEnum64 // Enum64
)
// FuncLinkage describes BTF function linkage metadata.
type FuncLinkage int
// Equivalent of enum btf_func_linkage.
const (
StaticFunc FuncLinkage = iota // static
GlobalFunc // global
ExternFunc // extern
)
// VarLinkage describes BTF variable linkage metadata.
type VarLinkage int
const (
StaticVar VarLinkage = iota // static
GlobalVar // global
ExternVar // extern
)
const (
btfTypeKindShift = 24
btfTypeKindLen = 5
btfTypeVlenShift = 0
btfTypeVlenMask = 16
btfTypeKindFlagShift = 31
btfTypeKindFlagMask = 1
)
var btfHeaderLen = binary.Size(&btfHeader{})
type btfHeader struct {
Magic uint16
Version uint8
Flags uint8
HdrLen uint32
TypeOff uint32
TypeLen uint32
StringOff uint32
StringLen uint32
}
// parseBTFHeader parses the header of the .BTF section.
func parseBTFHeader(buf []byte) (*btfHeader, binary.ByteOrder, error) {
var header btfHeader
var bo binary.ByteOrder
for _, order := range []binary.ByteOrder{binary.LittleEndian, binary.BigEndian} {
n, err := binary.Decode(buf, order, &header)
if err != nil {
return nil, nil, fmt.Errorf("read header: %v", err)
}
if header.Magic != btfMagic {
continue
}
buf = buf[n:]
bo = order
break
}
if bo == nil {
return nil, nil, fmt.Errorf("no valid BTF header")
}
if header.Version != 1 {
return nil, nil, fmt.Errorf("unexpected version %v", header.Version)
}
if header.Flags != 0 {
return nil, nil, fmt.Errorf("unsupported flags %v", header.Flags)
}
remainder := int64(header.HdrLen) - int64(binary.Size(&header))
if remainder < 0 {
return nil, nil, errors.New("header length shorter than btfHeader size")
}
for _, b := range buf[:remainder] {
if b != 0 {
return nil, nil, errors.New("header contains non-zero trailer")
}
}
return &header, bo, nil
}
// btfType is equivalent to struct btf_type in Documentation/bpf/btf.rst.
type btfType struct {
NameOff uint32
/* "info" bits arrangement
* bits 0-15: vlen (e.g. # of struct's members), linkage
* bits 16-23: unused
* bits 24-28: kind (e.g. int, ptr, array...etc)
* bits 29-30: unused
* bit 31: kind_flag, currently used by
* struct, union and fwd
*/
Info uint32
/* "size" is used by INT, ENUM, STRUCT and UNION.
* "size" tells the size of the type it is describing.
*
* "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
* FUNC and FUNC_PROTO.
* "type" is a type_id referring to another type.
*/
SizeType uint32
}
var btfTypeSize = int(unsafe.Sizeof(btfType{}))
func unmarshalBtfType(bt *btfType, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfTypeSize {
return 0, fmt.Errorf("not enough bytes to unmarshal btfType")
}
bt.NameOff = bo.Uint32(b[0:])
bt.Info = bo.Uint32(b[4:])
bt.SizeType = bo.Uint32(b[8:])
return btfTypeSize, nil
}
func mask(len uint32) uint32 {
return (1 << len) - 1
}
func readBits(value, len, shift uint32) uint32 {
return (value >> shift) & mask(len)
}
func writeBits(value, len, shift, new uint32) uint32 {
value &^= mask(len) << shift
value |= (new & mask(len)) << shift
return value
}
func (bt *btfType) info(len, shift uint32) uint32 {
return readBits(bt.Info, len, shift)
}
func (bt *btfType) setInfo(value, len, shift uint32) {
bt.Info = writeBits(bt.Info, len, shift, value)
}
func (bt *btfType) Kind() btfKind {
return btfKind(bt.info(btfTypeKindLen, btfTypeKindShift))
}
func (bt *btfType) SetKind(kind btfKind) {
bt.setInfo(uint32(kind), btfTypeKindLen, btfTypeKindShift)
}
func (bt *btfType) Vlen() int {
return int(bt.info(btfTypeVlenMask, btfTypeVlenShift))
}
func (bt *btfType) SetVlen(vlen int) {
bt.setInfo(uint32(vlen), btfTypeVlenMask, btfTypeVlenShift)
}
func (bt *btfType) kindFlagBool() bool {
return bt.info(btfTypeKindFlagMask, btfTypeKindFlagShift) == 1
}
func (bt *btfType) setKindFlagBool(set bool) {
var value uint32
if set {
value = 1
}
bt.setInfo(value, btfTypeKindFlagMask, btfTypeKindFlagShift)
}
// Bitfield returns true if the struct or union contain a bitfield.
func (bt *btfType) Bitfield() bool {
return bt.kindFlagBool()
}
func (bt *btfType) SetBitfield(isBitfield bool) {
bt.setKindFlagBool(isBitfield)
}
func (bt *btfType) FwdKind() FwdKind {
return FwdKind(bt.info(btfTypeKindFlagMask, btfTypeKindFlagShift))
}
func (bt *btfType) SetFwdKind(kind FwdKind) {
bt.setInfo(uint32(kind), btfTypeKindFlagMask, btfTypeKindFlagShift)
}
func (bt *btfType) Signed() bool {
return bt.kindFlagBool()
}
func (bt *btfType) SetSigned(signed bool) {
bt.setKindFlagBool(signed)
}
func (bt *btfType) Linkage() FuncLinkage {
return FuncLinkage(bt.info(btfTypeVlenMask, btfTypeVlenShift))
}
func (bt *btfType) SetLinkage(linkage FuncLinkage) {
bt.setInfo(uint32(linkage), btfTypeVlenMask, btfTypeVlenShift)
}
func (bt *btfType) Type() TypeID {
// TODO: Panic here if wrong kind?
return TypeID(bt.SizeType)
}
func (bt *btfType) SetType(id TypeID) {
bt.SizeType = uint32(id)
}
func (bt *btfType) Size() uint32 {
// TODO: Panic here if wrong kind?
return bt.SizeType
}
func (bt *btfType) SetSize(size uint32) {
bt.SizeType = size
}
func (bt *btfType) Encode(buf []byte, bo binary.ByteOrder) (int, error) {
if len(buf) < btfTypeSize {
return 0, fmt.Errorf("not enough bytes to marshal btfType")
}
bo.PutUint32(buf[0:], bt.NameOff)
bo.PutUint32(buf[4:], bt.Info)
bo.PutUint32(buf[8:], bt.SizeType)
return btfTypeSize, nil
}
// DataLen returns the length of additional type specific data in bytes.
func (bt *btfType) DataLen() (int, error) {
switch bt.Kind() {
case kindInt:
return int(unsafe.Sizeof(btfInt{})), nil
case kindPointer:
case kindArray:
return int(unsafe.Sizeof(btfArray{})), nil
case kindStruct:
fallthrough
case kindUnion:
return int(unsafe.Sizeof(btfMember{})) * bt.Vlen(), nil
case kindEnum:
return int(unsafe.Sizeof(btfEnum{})) * bt.Vlen(), nil
case kindForward:
case kindTypedef:
case kindVolatile:
case kindConst:
case kindRestrict:
case kindFunc:
case kindFuncProto:
return int(unsafe.Sizeof(btfParam{})) * bt.Vlen(), nil
case kindVar:
return int(unsafe.Sizeof(btfVariable{})), nil
case kindDatasec:
return int(unsafe.Sizeof(btfVarSecinfo{})) * bt.Vlen(), nil
case kindFloat:
case kindDeclTag:
return int(unsafe.Sizeof(btfDeclTag{})), nil
case kindTypeTag:
case kindEnum64:
return int(unsafe.Sizeof(btfEnum64{})) * bt.Vlen(), nil
default:
return 0, fmt.Errorf("unknown kind: %v", bt.Kind())
}
return 0, nil
}
// btfInt encodes additional data for integers.
//
// ? ? ? ? e e e e o o o o o o o o ? ? ? ? ? ? ? ? b b b b b b b b
// ? = undefined
// e = encoding
// o = offset (bitfields?)
// b = bits (bitfields)
type btfInt struct {
Raw uint32
}
const (
btfIntEncodingLen = 4
btfIntEncodingShift = 24
btfIntOffsetLen = 8
btfIntOffsetShift = 16
btfIntBitsLen = 8
btfIntBitsShift = 0
)
var btfIntLen = int(unsafe.Sizeof(btfInt{}))
func unmarshalBtfInt(bi *btfInt, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfIntLen {
return 0, fmt.Errorf("not enough bytes to unmarshal btfInt")
}
bi.Raw = bo.Uint32(b[0:])
return btfIntLen, nil
}
func (bi btfInt) Encoding() IntEncoding {
return IntEncoding(readBits(bi.Raw, btfIntEncodingLen, btfIntEncodingShift))
}
func (bi *btfInt) SetEncoding(e IntEncoding) {
bi.Raw = writeBits(uint32(bi.Raw), btfIntEncodingLen, btfIntEncodingShift, uint32(e))
}
func (bi btfInt) Offset() Bits {
return Bits(readBits(bi.Raw, btfIntOffsetLen, btfIntOffsetShift))
}
func (bi *btfInt) SetOffset(offset uint32) {
bi.Raw = writeBits(bi.Raw, btfIntOffsetLen, btfIntOffsetShift, offset)
}
func (bi btfInt) Bits() Bits {
return Bits(readBits(bi.Raw, btfIntBitsLen, btfIntBitsShift))
}
func (bi *btfInt) SetBits(bits byte) {
bi.Raw = writeBits(bi.Raw, btfIntBitsLen, btfIntBitsShift, uint32(bits))
}
type btfArray struct {
Type TypeID
IndexType TypeID
Nelems uint32
}
var btfArrayLen = int(unsafe.Sizeof(btfArray{}))
func unmarshalBtfArray(ba *btfArray, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfArrayLen {
return 0, fmt.Errorf("not enough bytes to unmarshal btfArray")
}
ba.Type = TypeID(bo.Uint32(b[0:]))
ba.IndexType = TypeID(bo.Uint32(b[4:]))
ba.Nelems = bo.Uint32(b[8:])
return btfArrayLen, nil
}
type btfMember struct {
NameOff uint32
Type TypeID
Offset uint32
}
var btfMemberLen = int(unsafe.Sizeof(btfMember{}))
func unmarshalBtfMember(bm *btfMember, b []byte, bo binary.ByteOrder) (int, error) {
if btfMemberLen > len(b) {
return 0, fmt.Errorf("not enough bytes to unmarshal btfMember")
}
bm.NameOff = bo.Uint32(b[0:])
bm.Type = TypeID(bo.Uint32(b[4:]))
bm.Offset = bo.Uint32(b[8:])
return btfMemberLen, nil
}
type btfVarSecinfo struct {
Type TypeID
Offset uint32
Size uint32
}
var btfVarSecinfoLen = int(unsafe.Sizeof(btfVarSecinfo{}))
func unmarshalBtfVarSecInfo(bvsi *btfVarSecinfo, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfVarSecinfoLen {
return 0, fmt.Errorf("not enough bytes to unmarshal btfVarSecinfo")
}
bvsi.Type = TypeID(bo.Uint32(b[0:]))
bvsi.Offset = bo.Uint32(b[4:])
bvsi.Size = bo.Uint32(b[8:])
return btfVarSecinfoLen, nil
}
type btfVariable struct {
Linkage uint32
}
var btfVariableLen = int(unsafe.Sizeof(btfVariable{}))
func unmarshalBtfVariable(bv *btfVariable, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfVariableLen {
return 0, fmt.Errorf("not enough bytes to unmarshal btfVariable")
}
bv.Linkage = bo.Uint32(b[0:])
return btfVariableLen, nil
}
type btfEnum struct {
NameOff uint32
Val uint32
}
var btfEnumLen = int(unsafe.Sizeof(btfEnum{}))
func unmarshalBtfEnum(be *btfEnum, b []byte, bo binary.ByteOrder) (int, error) {
if btfEnumLen > len(b) {
return 0, fmt.Errorf("not enough bytes to unmarshal btfEnum")
}
be.NameOff = bo.Uint32(b[0:])
be.Val = bo.Uint32(b[4:])
return btfEnumLen, nil
}
type btfEnum64 struct {
NameOff uint32
ValLo32 uint32
ValHi32 uint32
}
var btfEnum64Len = int(unsafe.Sizeof(btfEnum64{}))
func unmarshalBtfEnum64(enum *btfEnum64, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfEnum64Len {
return 0, fmt.Errorf("not enough bytes to unmarshal btfEnum64")
}
enum.NameOff = bo.Uint32(b[0:])
enum.ValLo32 = bo.Uint32(b[4:])
enum.ValHi32 = bo.Uint32(b[8:])
return btfEnum64Len, nil
}
type btfParam struct {
NameOff uint32
Type TypeID
}
var btfParamLen = int(unsafe.Sizeof(btfParam{}))
func unmarshalBtfParam(param *btfParam, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfParamLen {
return 0, fmt.Errorf("not enough bytes to unmarshal btfParam")
}
param.NameOff = bo.Uint32(b[0:])
param.Type = TypeID(bo.Uint32(b[4:]))
return btfParamLen, nil
}
type btfDeclTag struct {
ComponentIdx uint32
}
var btfDeclTagLen = int(unsafe.Sizeof(btfDeclTag{}))
func unmarshalBtfDeclTag(bdt *btfDeclTag, b []byte, bo binary.ByteOrder) (int, error) {
if len(b) < btfDeclTagLen {
return 0, fmt.Errorf("not enough bytes to unmarshal btfDeclTag")
}
bdt.ComponentIdx = bo.Uint32(b[0:])
return btfDeclTagLen, nil
}
================================================
FILE: btf/btf_types_string.go
================================================
// Code generated by "stringer -linecomment -output=btf_types_string.go -type=FuncLinkage,VarLinkage,btfKind"; DO NOT EDIT.
package btf
import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[StaticFunc-0]
_ = x[GlobalFunc-1]
_ = x[ExternFunc-2]
}
const _FuncLinkage_name = "staticglobalextern"
var _FuncLinkage_index = [...]uint8{0, 6, 12, 18}
func (i FuncLinkage) String() string {
idx := int(i) - 0
if i < 0 || idx >= len(_FuncLinkage_index)-1 {
return "FuncLinkage(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _FuncLinkage_name[_FuncLinkage_index[idx]:_FuncLinkage_index[idx+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[StaticVar-0]
_ = x[GlobalVar-1]
_ = x[ExternVar-2]
}
const _VarLinkage_name = "staticglobalextern"
var _VarLinkage_index = [...]uint8{0, 6, 12, 18}
func (i VarLinkage) String() string {
idx := int(i) - 0
if i < 0 || idx >= len(_VarLinkage_index)-1 {
return "VarLinkage(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _VarLinkage_name[_VarLinkage_index[idx]:_VarLinkage_index[idx+1]]
}
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[kindUnknown-0]
_ = x[kindInt-1]
_ = x[kindPointer-2]
_ = x[kindArray-3]
_ = x[kindStruct-4]
_ = x[kindUnion-5]
_ = x[kindEnum-6]
_ = x[kindForward-7]
_ = x[kindTypedef-8]
_ = x[kindVolatile-9]
_ = x[kindConst-10]
_ = x[kindRestrict-11]
_ = x[kindFunc-12]
_ = x[kindFuncProto-13]
_ = x[kindVar-14]
_ = x[kindDatasec-15]
_ = x[kindFloat-16]
_ = x[kindDeclTag-17]
_ = x[kindTypeTag-18]
_ = x[kindEnum64-19]
}
const _btfKind_name = "UnknownIntPointerArrayStructUnionEnumForwardTypedefVolatileConstRestrictFuncFuncProtoVarDatasecFloatDeclTagTypeTagEnum64"
var _btfKind_index = [...]uint8{0, 7, 10, 17, 22, 28, 33, 37, 44, 51, 59, 64, 72, 76, 85, 88, 95, 100, 107, 114, 120}
func (i btfKind) String() string {
idx := int(i) - 0
if i < 0 || idx >= len(_btfKind_index)-1 {
return "btfKind(" + strconv.FormatInt(int64(i), 10) + ")"
}
return _btfKind_name[_btfKind_index[idx]:_btfKind_index[idx+1]]
}
================================================
FILE: btf/core.go
================================================
package btf
import (
"encoding/binary"
"errors"
"fmt"
"math"
"reflect"
"strconv"
"strings"
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/platform"
)
// Code in this file is derived from libbpf, which is available under a BSD
// 2-Clause license.
// A constant used when CO-RE relocation has to remove instructions.
//
// Taken from libbpf.
const COREBadRelocationSentinel = 0xbad2310
// COREFixup is the result of computing a CO-RE relocation for a target.
type COREFixup struct {
kind coreKind
local uint64
target uint64
// True if there is no valid fixup. The instruction is replaced with an
// invalid dummy.
poison bool
// True if the validation of the local value should be skipped. Used by
// some kinds of bitfield relocations.
skipLocalValidation bool
}
func (f *COREFixup) equal(other COREFixup) bool {
return f.local == other.local && f.target == other.target
}
func (f *COREFixup) String() string {
if f.poison {
return fmt.Sprintf("%s=poison", f.kind)
}
return fmt.Sprintf("%s=%d->%d", f.kind, f.local, f.target)
}
func (f *COREFixup) Apply(ins *asm.Instruction) error {
if !platform.IsLinux {
return fmt.Errorf("CO-RE fixup: %w", internal.ErrNotSupportedOnOS)
}
if f.poison {
// Relocation is poisoned, replace the instruction with an invalid one.
if ins.OpCode.IsDWordLoad() {
// Replace a dword load with a invalid dword load to preserve instruction size.
*ins = asm.LoadImm(asm.R10, COREBadRelocationSentinel, asm.DWord)
} else {
// Replace all single size instruction with a invalid call instruction.
*ins = asm.BuiltinFunc(COREBadRelocationSentinel).Call()
}
// Add context to the kernel verifier output.
if source := ins.Source(); source != nil {
*ins = ins.WithSource(asm.Comment(fmt.Sprintf("instruction poisoned by CO-RE: %s", source)))
} else {
*ins = ins.WithSource(asm.Comment("instruction poisoned by CO-RE"))
}
return nil
}
switch class := ins.OpCode.Class(); class {
case asm.LdXClass, asm.StClass, asm.StXClass:
if want := int16(f.local); !f.skipLocalValidation && want != ins.Offset {
return fmt.Errorf("invalid offset %d, expected %d", ins.Offset, f.local)
}
if f.target > math.MaxInt16 {
return fmt.Errorf("offset %d exceeds MaxInt16", f.target)
}
ins.Offset = int16(f.target)
case asm.LdClass:
if !ins.IsConstantLoad(asm.DWord) {
return fmt.Errorf("not a dword-sized immediate load")
}
if want := int64(f.local); !f.skipLocalValidation && want != ins.Constant {
return fmt.Errorf("invalid immediate %d, expected %d (fixup: %v)", ins.Constant, want, f)
}
ins.Constant = int64(f.target)
case asm.ALUClass:
if ins.OpCode.ALUOp() == asm.Swap {
return fmt.Errorf("relocation against swap")
}
fallthrough
case asm.ALU64Class:
if src := ins.OpCode.Source(); src != asm.ImmSource {
return fmt.Errorf("invalid source %s", src)
}
if want := int64(f.local); !f.skipLocalValidation && want != ins.Constant {
return fmt.Errorf("invalid immediate %d, expected %d (fixup: %v, kind: %v, ins: %v)", ins.Constant, want, f, f.kind, ins)
}
if f.target > math.MaxInt32 {
return fmt.Errorf("immediate %d exceeds MaxInt32", f.target)
}
ins.Constant = int64(f.target)
default:
return fmt.Errorf("invalid class %s", class)
}
return nil
}
func (f COREFixup) i
gitextract_xp4d7it9/ ├── .clang-format ├── .gitattributes ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.yml │ │ └── config.yml │ ├── dependabot.yml │ └── workflows/ │ ├── apidiff.yml │ ├── ci.yml │ └── trusted.yml ├── .gitignore ├── .golangci.yaml ├── .vimto.toml ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MAINTAINERS.md ├── Makefile ├── README.md ├── asm/ │ ├── alu.go │ ├── alu_string.go │ ├── doc.go │ ├── dsl_test.go │ ├── func.go │ ├── func_lin.go │ ├── func_string.go │ ├── func_win.go │ ├── instruction.go │ ├── instruction_test.go │ ├── jump.go │ ├── jump_string.go │ ├── load_store.go │ ├── load_store_string.go │ ├── metadata.go │ ├── metadata_test.go │ ├── opcode.go │ ├── opcode_string.go │ ├── opcode_test.go │ └── register.go ├── attachtype_string.go ├── btf/ │ ├── btf.go │ ├── btf_test.go │ ├── btf_types.go │ ├── btf_types_string.go │ ├── core.go │ ├── core_reloc_test.go │ ├── core_test.go │ ├── dedup.go │ ├── dedup_test.go │ ├── doc.go │ ├── ext_info.go │ ├── ext_info_test.go │ ├── feature.go │ ├── feature_test.go │ ├── format.go │ ├── format_test.go │ ├── fuzz_test.go │ ├── handle.go │ ├── handle_test.go │ ├── kernel.go │ ├── kernel_test.go │ ├── marshal.go │ ├── marshal_test.go │ ├── strings.go │ ├── strings_test.go │ ├── testdata/ │ │ ├── bpf_core_read.h │ │ ├── btf_testmod.btf │ │ ├── btf_testmod.btf.base │ │ ├── fuzz/ │ │ │ └── FuzzExtInfo/ │ │ │ ├── 50a33736610b4a0945179db4c8a88e8247b05fbb25f50ed81e5393baf29bc5bc │ │ │ ├── 72534f53bd90cb52a017013499b11511535c1295bf0e22f856148c02454c323e │ │ │ └── a87a26efa64ed50b598ae8e333301d57d5f234527730f042d68ccc736e90c9fa │ │ ├── relocs-eb.elf │ │ ├── relocs-el.elf │ │ ├── relocs.c │ │ ├── relocs_enum-eb.elf │ │ ├── relocs_enum-el.elf │ │ ├── relocs_enum.c │ │ ├── relocs_read-eb.elf │ │ ├── relocs_read-el.elf │ │ ├── relocs_read.c │ │ ├── relocs_read_tgt-eb.elf │ │ ├── relocs_read_tgt-el.elf │ │ ├── relocs_read_tgt.c │ │ ├── tags-eb.elf │ │ ├── tags-el.elf │ │ └── tags.c │ ├── traversal.go │ ├── traversal_test.go │ ├── types.go │ ├── types_test.go │ ├── unmarshal.go │ ├── unmarshal_test.go │ ├── workarounds.go │ └── workarounds_test.go ├── cmd/ │ └── bpf2go/ │ ├── README.md │ ├── doc.go │ ├── flags.go │ ├── gen/ │ │ ├── compile.go │ │ ├── compile_test.go │ │ ├── doc.go │ │ ├── output.go │ │ ├── output.tpl │ │ ├── output_test.go │ │ ├── target.go │ │ ├── target_test.go │ │ ├── types.go │ │ └── types_test.go │ ├── internal/ │ │ └── module.go │ ├── main.go │ ├── main_test.go │ ├── makedep.go │ ├── makedep_test.go │ ├── test/ │ │ ├── api_test.go │ │ ├── doc.go │ │ ├── test_bpfeb.go │ │ ├── test_bpfeb.o │ │ ├── test_bpfel.go │ │ └── test_bpfel.o │ ├── testdata/ │ │ ├── minimal-eb.elf │ │ ├── minimal-el.elf │ │ └── minimal.c │ ├── tools.go │ └── tools_test.go ├── collection.go ├── collection_other.go ├── collection_test.go ├── collection_windows.go ├── collection_windows_test.go ├── cpu.go ├── cpu_other.go ├── cpu_test.go ├── cpu_windows.go ├── doc.go ├── docs/ │ ├── .gitignore │ ├── Makefile │ ├── Pipfile │ ├── README.md │ ├── ebpf/ │ │ ├── about.md │ │ ├── concepts/ │ │ │ ├── features.md │ │ │ ├── global-variables.md │ │ │ ├── loader.md │ │ │ ├── object-lifecycle.md │ │ │ ├── rlimit.md │ │ │ └── section-naming.md │ │ ├── contributing/ │ │ │ ├── architecture.md │ │ │ ├── index.md │ │ │ ├── new-example.md │ │ │ ├── new-feature.md │ │ │ └── windows.md │ │ ├── guides/ │ │ │ ├── getting-started.md │ │ │ ├── portable-ebpf.md │ │ │ └── windows-support.md │ │ ├── index.md │ │ ├── stylesheets/ │ │ │ └── extra.css │ │ └── users.md │ ├── examples/ │ │ ├── docs.c │ │ ├── docs_test.go │ │ ├── features_test.go │ │ ├── getting_started/ │ │ │ ├── counter.c │ │ │ ├── counter_bpfeb.go │ │ │ ├── counter_bpfeb.o │ │ │ ├── counter_bpfel.go │ │ │ ├── counter_bpfel.o │ │ │ ├── gen.go │ │ │ └── main.go │ │ ├── rlimit_test.go │ │ └── variables/ │ │ ├── gen.go │ │ ├── main.go │ │ ├── variables.c │ │ ├── variables_bpfeb.go │ │ ├── variables_bpfeb.o │ │ ├── variables_bpfel.go │ │ └── variables_bpfel.o │ ├── includes/ │ │ └── glossary.md │ ├── macros.py │ ├── mkdocs.yml │ ├── overrides/ │ │ └── partials/ │ │ └── source-file.html │ └── vars.yml ├── elf_reader.go ├── elf_reader_test.go ├── elf_sections.go ├── example_sock_elf_test.go ├── example_sock_extract_dist_test.go ├── examples/ │ ├── README.md │ ├── cgroup_skb/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── cgroup_skb.c │ │ └── main.go │ ├── fentry/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── fentry.c │ │ └── main.go │ ├── headers/ │ │ ├── LICENSE.BSD-2-Clause │ │ ├── bpf_endian.h │ │ ├── bpf_helper_defs.h │ │ ├── bpf_helpers.h │ │ ├── bpf_tracing.h │ │ ├── common.h │ │ └── update.sh │ ├── kprobe/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── kprobe.c │ │ └── main.go │ ├── kprobe_percpu/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── kprobe_percpu.c │ │ └── main.go │ ├── kprobepin/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── kprobe_pin.c │ │ └── main.go │ ├── map_in_map/ │ │ └── main.go │ ├── ringbuffer/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── main.go │ │ └── ringbuffer.c │ ├── sched_ext/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── main.go │ │ └── sched_ext.c │ ├── tcprtt/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── main.go │ │ └── tcprtt.c │ ├── tcprtt_sockops/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── bpf_sockops.h │ │ ├── main.go │ │ └── tcprtt_sockops.c │ ├── tcx/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── main.go │ │ └── tcx.c │ ├── tracepoint_in_c/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── main.go │ │ └── tracepoint.c │ ├── tracepoint_in_go/ │ │ └── main.go │ ├── uretprobe/ │ │ ├── bpf_x86_bpfel.go │ │ ├── bpf_x86_bpfel.o │ │ ├── main.go │ │ └── uretprobe.c │ ├── xdp/ │ │ ├── bpf_bpfeb.go │ │ ├── bpf_bpfeb.o │ │ ├── bpf_bpfel.go │ │ ├── bpf_bpfel.o │ │ ├── main.go │ │ └── xdp.c │ └── xdp_live_frame/ │ ├── bpf_bpfeb.go │ ├── bpf_bpfeb.o │ ├── bpf_bpfel.go │ ├── bpf_bpfel.o │ ├── main.go │ └── xdp.c ├── features/ │ ├── doc.go │ ├── link.go │ ├── link_test.go │ ├── map.go │ ├── map_test.go │ ├── misc.go │ ├── misc_test.go │ ├── prog.go │ ├── prog_test.go │ └── version.go ├── fuzz_test.go ├── go.mod ├── go.sum ├── helpers_test.go ├── info.go ├── info_test.go ├── internal/ │ ├── cmd/ │ │ ├── genfunctions.awk │ │ ├── gensections.awk │ │ └── genwinfunctions.awk │ ├── deque.go │ ├── deque_test.go │ ├── efw/ │ │ ├── enums.go │ │ ├── error_reporting.go │ │ ├── error_reporting_test.go │ │ ├── fd.go │ │ ├── map.go │ │ ├── module.go │ │ ├── native.go │ │ ├── object.go │ │ ├── proc.go │ │ ├── proc_test.go │ │ ├── program.go │ │ ├── result.go │ │ ├── result_string_windows.go │ │ ├── result_test.go │ │ └── structs.go │ ├── elf.go │ ├── endian_be.go │ ├── endian_le.go │ ├── epoll/ │ │ ├── poller.go │ │ └── poller_test.go │ ├── errors.go │ ├── errors_test.go │ ├── feature.go │ ├── feature_test.go │ ├── io.go │ ├── io_test.go │ ├── kallsyms/ │ │ ├── cache.go │ │ ├── kallsyms.go │ │ ├── kallsyms_test.go │ │ ├── reader.go │ │ └── reader_test.go │ ├── kconfig/ │ │ ├── kconfig.go │ │ ├── kconfig_test.go │ │ └── testdata/ │ │ └── test.kconfig │ ├── linux/ │ │ ├── auxv.go │ │ ├── auxv_test.go │ │ ├── cpu.go │ │ ├── cpu_test.go │ │ ├── doc.go │ │ ├── helper_test.go │ │ ├── kconfig.go │ │ ├── platform.go │ │ ├── statfs.go │ │ ├── statfs_test.go │ │ ├── vdso.go │ │ ├── vdso_test.go │ │ ├── version.go │ │ └── version_test.go │ ├── math.go │ ├── math_test.go │ ├── nil.go │ ├── output.go │ ├── output_test.go │ ├── platform/ │ │ ├── constants.go │ │ ├── constants_test.go │ │ ├── platform.go │ │ ├── platform_linux.go │ │ ├── platform_other.go │ │ └── platform_windows.go │ ├── prog.go │ ├── sys/ │ │ ├── doc.go │ │ ├── fd.go │ │ ├── fd_linux_test.go │ │ ├── fd_other.go │ │ ├── fd_windows.go │ │ ├── pinning_other.go │ │ ├── pinning_windows.go │ │ ├── ptr.go │ │ ├── ptr_32_be.go │ │ ├── ptr_32_le.go │ │ ├── ptr_64.go │ │ ├── ptr_test.go │ │ ├── signals.go │ │ ├── signals_test.go │ │ ├── syscall.go │ │ ├── syscall_other.go │ │ ├── syscall_test.go │ │ ├── syscall_windows.go │ │ └── types.go │ ├── sysenc/ │ │ ├── buffer.go │ │ ├── buffer_test.go │ │ ├── doc.go │ │ ├── layout.go │ │ ├── layout_test.go │ │ ├── marshal.go │ │ └── marshal_test.go │ ├── testdata/ │ │ ├── errno524.log │ │ ├── invalid-R0.log │ │ ├── invalid-ctx-access.log │ │ ├── invalid-member.log │ │ └── issue-43.log │ ├── testutils/ │ │ ├── bpffs_other.go │ │ ├── bpffs_windows.go │ │ ├── bpffs_windows_test.go │ │ ├── cap.go │ │ ├── cgroup.go │ │ ├── chan.go │ │ ├── checkers.go │ │ ├── checkers_test.go │ │ ├── cpu.go │ │ ├── fd_other.go │ │ ├── fd_windows.go │ │ ├── feature.go │ │ ├── feature_other.go │ │ ├── feature_test.go │ │ ├── feature_windows.go │ │ ├── glob.go │ │ ├── netns_linux.go │ │ ├── netns_other.go │ │ ├── programs.go │ │ ├── rlimit.go │ │ ├── seed.go │ │ └── testmain/ │ │ ├── fd_trace.go │ │ ├── main.go │ │ ├── windows.go │ │ └── windows_test.go │ ├── tracefs/ │ │ ├── kprobe.go │ │ ├── kprobe_test.go │ │ ├── perf_event_test.go │ │ ├── probetype_string.go │ │ ├── uprobe.go │ │ └── uprobe_test.go │ ├── unix/ │ │ ├── doc.go │ │ ├── errno_linux.go │ │ ├── errno_linux_test.go │ │ ├── errno_other.go │ │ ├── errno_string_windows.go │ │ ├── errno_test.go │ │ ├── errno_windows.go │ │ ├── error.go │ │ ├── error_test.go │ │ ├── strings_other.go │ │ ├── strings_windows.go │ │ ├── types_linux.go │ │ └── types_other.go │ ├── version.go │ └── version_test.go ├── link/ │ ├── anchor.go │ ├── cgroup.go │ ├── cgroup_test.go │ ├── doc.go │ ├── helpers_windows_test.go │ ├── iter.go │ ├── iter_test.go │ ├── kprobe.go │ ├── kprobe_multi.go │ ├── kprobe_multi_test.go │ ├── kprobe_test.go │ ├── link.go │ ├── link_other.go │ ├── link_other_test.go │ ├── link_test.go │ ├── link_windows.go │ ├── link_windows_test.go │ ├── netfilter.go │ ├── netfilter_test.go │ ├── netkit.go │ ├── netkit_test.go │ ├── netns.go │ ├── netns_test.go │ ├── perf_event.go │ ├── perf_event_test.go │ ├── program.go │ ├── program_test.go │ ├── query.go │ ├── query_test.go │ ├── raw_tracepoint.go │ ├── raw_tracepoint_test.go │ ├── socket_filter.go │ ├── socket_filter_test.go │ ├── struct_ops.go │ ├── struct_ops_test.go │ ├── syscalls.go │ ├── syscalls_test.go │ ├── tcx.go │ ├── tcx_test.go │ ├── tracepoint.go │ ├── tracepoint_test.go │ ├── tracing.go │ ├── tracing_test.go │ ├── uprobe.go │ ├── uprobe_multi.go │ ├── uprobe_multi_test.go │ ├── uprobe_test.go │ ├── xdp.go │ └── xdp_test.go ├── linker.go ├── linker_test.go ├── map.go ├── map_test.go ├── marshaler_example_test.go ├── marshalers.go ├── marshalers_test.go ├── memory.go ├── memory_test.go ├── memory_unsafe.go ├── memory_unsafe_tag.go ├── memory_unsafe_test.go ├── netlify.toml ├── perf/ │ ├── doc.go │ ├── reader.go │ ├── reader_test.go │ ├── ring.go │ └── ring_test.go ├── pin/ │ ├── doc.go │ ├── load.go │ ├── load_test.go │ ├── pin.go │ ├── walk_other.go │ ├── walk_test.go │ └── walk_windows.go ├── prog.go ├── prog_linux_test.go ├── prog_test.go ├── ringbuf/ │ ├── doc.go │ ├── helper_other_test.go │ ├── helper_test.go │ ├── helper_windows_test.go │ ├── reader.go │ ├── reader_other.go │ ├── reader_test.go │ ├── reader_windows.go │ ├── ring.go │ ├── ring_other.go │ └── ring_windows.go ├── rlimit/ │ ├── doc.go │ ├── rlimit_linux.go │ ├── rlimit_linux_test.go │ └── rlimit_other.go ├── scripts/ │ ├── update-efw-deps.sh │ ├── update-kernel-deps.sh │ └── windows/ │ ├── README.md │ ├── Setup.ps1 │ ├── autounattend.xml │ ├── setup-efw.sh │ └── setup.sh ├── struct_ops.go ├── struct_ops_test.go ├── syscalls.go ├── syscalls_test.go ├── testdata/ │ ├── arena-eb.elf │ ├── arena-el.elf │ ├── arena.c │ ├── btf_map_init-eb.elf │ ├── btf_map_init-el.elf │ ├── btf_map_init.c │ ├── common.h │ ├── constants-eb.elf │ ├── constants-el.elf │ ├── constants.c │ ├── docker/ │ │ ├── Dockerfile │ │ ├── IMAGE │ │ ├── Makefile │ │ ├── README.md │ │ ├── VERSION │ │ ├── llvm-snapshot.gpg.key │ │ └── llvm.list │ ├── errors-eb.elf │ ├── errors-el.elf │ ├── errors.c │ ├── fentry_fexit-eb.elf │ ├── fentry_fexit-el.elf │ ├── fentry_fexit.c │ ├── freplace-eb.elf │ ├── freplace-el.elf │ ├── freplace.c │ ├── fwd_decl-eb.elf │ ├── fwd_decl-el.elf │ ├── fwd_decl.c │ ├── invalid-kfunc-eb.elf │ ├── invalid-kfunc-el.elf │ ├── invalid-kfunc.c │ ├── invalid_btf_map_init-eb.elf │ ├── invalid_btf_map_init-el.elf │ ├── invalid_btf_map_init.c │ ├── invalid_map-eb.elf │ ├── invalid_map-el.elf │ ├── invalid_map.c │ ├── invalid_map_static-eb.elf │ ├── invalid_map_static-el.elf │ ├── invalid_map_static.c │ ├── iproute2_map_compat-eb.elf │ ├── iproute2_map_compat-el.elf │ ├── iproute2_map_compat.c │ ├── kconfig-eb.elf │ ├── kconfig-el.elf │ ├── kconfig.c │ ├── kfunc-eb.elf │ ├── kfunc-el.elf │ ├── kfunc-kmod-eb.elf │ ├── kfunc-kmod-el.elf │ ├── kfunc-kmod.c │ ├── kfunc.c │ ├── ksym-eb.elf │ ├── ksym-el.elf │ ├── ksym.c │ ├── linked-el.elf │ ├── linked.h │ ├── linked1-el.elf │ ├── linked1.c │ ├── linked2-el.elf │ ├── linked2.c │ ├── loader-clang-14-eb.elf │ ├── loader-clang-14-el.elf │ ├── loader-clang-17-eb.elf │ ├── loader-clang-17-el.elf │ ├── loader-clang-20-eb.elf │ ├── loader-clang-20-el.elf │ ├── loader.c │ ├── loader.h │ ├── loader_nobtf-eb.elf │ ├── loader_nobtf-el.elf │ ├── loader_nobtf.h │ ├── manyprogs-eb.elf │ ├── manyprogs-el.elf │ ├── manyprogs.c │ ├── map_spin_lock-eb.elf │ ├── map_spin_lock-el.elf │ ├── map_spin_lock.c │ ├── raw_tracepoint-eb.elf │ ├── raw_tracepoint-el.elf │ ├── raw_tracepoint.c │ ├── strings-eb.elf │ ├── strings-el.elf │ ├── strings.c │ ├── struct_ops-eb.elf │ ├── struct_ops-el.elf │ ├── struct_ops.c │ ├── subprog_reloc-eb.elf │ ├── subprog_reloc-el.elf │ ├── subprog_reloc.c │ ├── variables-eb.elf │ ├── variables-el.elf │ ├── variables.c │ └── windows/ │ ├── LICENSE │ └── cgroup_sock_addr.sys ├── types.go ├── types_string.go ├── types_windows.go ├── types_windows_test.go ├── variable.go └── variable_test.go
Showing preview only (416K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (5111 symbols across 425 files)
FILE: asm/alu.go
type Source (line 11) | type Source
constant sourceMask (line 13) | sourceMask OpCode = 0x0008
constant InvalidSource (line 19) | InvalidSource Source = 0xffff
constant ImmSource (line 21) | ImmSource Source = 0x0000
constant RegSource (line 23) | RegSource Source = 0x0008
type Endianness (line 27) | type Endianness
constant endianMask (line 29) | endianMask = sourceMask
constant InvalidEndian (line 33) | InvalidEndian Endianness = 0xff
constant LE (line 35) | LE Endianness = 0x00
constant BE (line 37) | BE Endianness = 0x08
type ALUOp (line 46) | type ALUOp
method Op (line 137) | func (op ALUOp) Op(source Source) OpCode {
method Reg (line 142) | func (op ALUOp) Reg(dst, src Register) Instruction {
method Imm (line 151) | func (op ALUOp) Imm(dst Register, value int32) Instruction {
method Op32 (line 160) | func (op ALUOp) Op32(source Source) OpCode {
method Reg32 (line 165) | func (op ALUOp) Reg32(dst, src Register) Instruction {
method Imm32 (line 174) | func (op ALUOp) Imm32(dst Register, value int32) Instruction {
constant aluMask (line 48) | aluMask OpCode = 0x3ff0
constant InvalidALUOp (line 53) | InvalidALUOp ALUOp = 0xffff
constant Add (line 55) | Add ALUOp = 0x0000
constant Sub (line 57) | Sub ALUOp = 0x0010
constant Mul (line 59) | Mul ALUOp = 0x0020
constant Div (line 61) | Div ALUOp = 0x0030
constant SDiv (line 63) | SDiv ALUOp = Div + 0x0100
constant Or (line 65) | Or ALUOp = 0x0040
constant And (line 67) | And ALUOp = 0x0050
constant LSh (line 69) | LSh ALUOp = 0x0060
constant RSh (line 71) | RSh ALUOp = 0x0070
constant Neg (line 73) | Neg ALUOp = 0x0080
constant Mod (line 75) | Mod ALUOp = 0x0090
constant SMod (line 77) | SMod ALUOp = Mod + 0x0100
constant Xor (line 79) | Xor ALUOp = 0x00a0
constant Mov (line 81) | Mov ALUOp = 0x00b0
constant MovSX8 (line 83) | MovSX8 ALUOp = Mov + 0x0100
constant MovSX16 (line 85) | MovSX16 ALUOp = Mov + 0x0200
constant MovSX32 (line 87) | MovSX32 ALUOp = Mov + 0x0300
constant ArSh (line 89) | ArSh ALUOp = 0x00c0
constant Swap (line 91) | Swap ALUOp = 0x00d0
function HostTo (line 95) | func HostTo(endian Endianness, dst Register, size Size) Instruction {
function BSwap (line 116) | func BSwap(dst Register, size Size) Instruction {
FILE: asm/alu_string.go
function _ (line 7) | func _() {
constant _Source_name_0 (line 17) | _Source_name_0 = "ImmSource"
constant _Source_name_1 (line 18) | _Source_name_1 = "RegSource"
constant _Source_name_2 (line 19) | _Source_name_2 = "InvalidSource"
method String (line 22) | func (i Source) String() string {
function _ (line 34) | func _() {
constant _Endianness_name_0 (line 44) | _Endianness_name_0 = "LE"
constant _Endianness_name_1 (line 45) | _Endianness_name_1 = "BE"
constant _Endianness_name_2 (line 46) | _Endianness_name_2 = "InvalidEndian"
method String (line 49) | func (i Endianness) String() string {
function _ (line 61) | func _() {
constant _ALUOp_name (line 87) | _ALUOp_name = "AddSubMulDivOrAndLShRShNegModXorMovArShSwapSDivSModMovSX8...
method String (line 112) | func (i ALUOp) String() string {
FILE: asm/dsl_test.go
function TestDSL (line 7) | func TestDSL(t *testing.T) {
FILE: asm/func.go
type BuiltinFunc (line 8) | type BuiltinFunc
method Call (line 18) | func (fn BuiltinFunc) Call() Instruction {
function BuiltinFuncForPlatform (line 13) | func BuiltinFuncForPlatform(plat string, value uint32) (BuiltinFunc, err...
FILE: asm/func_lin.go
constant FnUnspec (line 11) | FnUnspec = BuiltinFunc(platform.LinuxTag | 0)
constant FnMapLookupElem (line 12) | FnMapLookupElem = BuiltinFunc(platform.LinuxTag | 1)
constant FnMapUpdateElem (line 13) | FnMapUpdateElem = BuiltinFunc(platform.LinuxTag | 2)
constant FnMapDeleteElem (line 14) | FnMapDeleteElem = BuiltinFunc(platform.LinuxTag | 3)
constant FnProbeRead (line 15) | FnProbeRead = BuiltinFunc(platform.LinuxTag | 4)
constant FnKtimeGetNs (line 16) | FnKtimeGetNs = BuiltinFunc(platform.LinuxTag | 5)
constant FnTracePrintk (line 17) | FnTracePrintk = BuiltinFunc(platform.LinuxTag | 6)
constant FnGetPrandomU32 (line 18) | FnGetPrandomU32 = BuiltinFunc(platform.LinuxTag | 7)
constant FnGetSmpProcessorId (line 19) | FnGetSmpProcessorId = BuiltinFunc(platform.LinuxTag | 8)
constant FnSkbStoreBytes (line 20) | FnSkbStoreBytes = BuiltinFunc(platform.LinuxTag | 9)
constant FnL3CsumReplace (line 21) | FnL3CsumReplace = BuiltinFunc(platform.LinuxTag | 10)
constant FnL4CsumReplace (line 22) | FnL4CsumReplace = BuiltinFunc(platform.LinuxTag | 11)
constant FnTailCall (line 23) | FnTailCall = BuiltinFunc(platform.LinuxTag | 12)
constant FnCloneRedirect (line 24) | FnCloneRedirect = BuiltinFunc(platform.LinuxTag | 13)
constant FnGetCurrentPidTgid (line 25) | FnGetCurrentPidTgid = BuiltinFunc(platform.LinuxTag | 14)
constant FnGetCurrentUidGid (line 26) | FnGetCurrentUidGid = BuiltinFunc(platform.LinuxTag | 15)
constant FnGetCurrentComm (line 27) | FnGetCurrentComm = BuiltinFunc(platform.LinuxTag | 16)
constant FnGetCgroupClassid (line 28) | FnGetCgroupClassid = BuiltinFunc(platform.LinuxTag | 17)
constant FnSkbVlanPush (line 29) | FnSkbVlanPush = BuiltinFunc(platform.LinuxTag | 18)
constant FnSkbVlanPop (line 30) | FnSkbVlanPop = BuiltinFunc(platform.LinuxTag | 19)
constant FnSkbGetTunnelKey (line 31) | FnSkbGetTunnelKey = BuiltinFunc(platform.LinuxTag | 20)
constant FnSkbSetTunnelKey (line 32) | FnSkbSetTunnelKey = BuiltinFunc(platform.LinuxTag | 21)
constant FnPerfEventRead (line 33) | FnPerfEventRead = BuiltinFunc(platform.LinuxTag | 22)
constant FnRedirect (line 34) | FnRedirect = BuiltinFunc(platform.LinuxTag | 23)
constant FnGetRouteRealm (line 35) | FnGetRouteRealm = BuiltinFunc(platform.LinuxTag | 24)
constant FnPerfEventOutput (line 36) | FnPerfEventOutput = BuiltinFunc(platform.LinuxTag | 25)
constant FnSkbLoadBytes (line 37) | FnSkbLoadBytes = BuiltinFunc(platform.LinuxTag | 26)
constant FnGetStackid (line 38) | FnGetStackid = BuiltinFunc(platform.LinuxTag | 27)
constant FnCsumDiff (line 39) | FnCsumDiff = BuiltinFunc(platform.LinuxTag | 28)
constant FnSkbGetTunnelOpt (line 40) | FnSkbGetTunnelOpt = BuiltinFunc(platform.LinuxTag | 29)
constant FnSkbSetTunnelOpt (line 41) | FnSkbSetTunnelOpt = BuiltinFunc(platform.LinuxTag | 30)
constant FnSkbChangeProto (line 42) | FnSkbChangeProto = BuiltinFunc(platform.LinuxTag | 31)
constant FnSkbChangeType (line 43) | FnSkbChangeType = BuiltinFunc(platform.LinuxTag | 32)
constant FnSkbUnderCgroup (line 44) | FnSkbUnderCgroup = BuiltinFunc(platform.LinuxTag | 33)
constant FnGetHashRecalc (line 45) | FnGetHashRecalc = BuiltinFunc(platform.LinuxTag | 34)
constant FnGetCurrentTask (line 46) | FnGetCurrentTask = BuiltinFunc(platform.LinuxTag | 35)
constant FnProbeWriteUser (line 47) | FnProbeWriteUser = BuiltinFunc(platform.LinuxTag | 36)
constant FnCurrentTaskUnderCgroup (line 48) | FnCurrentTaskUnderCgroup = BuiltinFunc(platform.LinuxTag | 37)
constant FnSkbChangeTail (line 49) | FnSkbChangeTail = BuiltinFunc(platform.LinuxTag | 38)
constant FnSkbPullData (line 50) | FnSkbPullData = BuiltinFunc(platform.LinuxTag | 39)
constant FnCsumUpdate (line 51) | FnCsumUpdate = BuiltinFunc(platform.LinuxTag | 40)
constant FnSetHashInvalid (line 52) | FnSetHashInvalid = BuiltinFunc(platform.LinuxTag | 41)
constant FnGetNumaNodeId (line 53) | FnGetNumaNodeId = BuiltinFunc(platform.LinuxTag | 42)
constant FnSkbChangeHead (line 54) | FnSkbChangeHead = BuiltinFunc(platform.LinuxTag | 43)
constant FnXdpAdjustHead (line 55) | FnXdpAdjustHead = BuiltinFunc(platform.LinuxTag | 44)
constant FnProbeReadStr (line 56) | FnProbeReadStr = BuiltinFunc(platform.LinuxTag | 45)
constant FnGetSocketCookie (line 57) | FnGetSocketCookie = BuiltinFunc(platform.LinuxTag | 46)
constant FnGetSocketUid (line 58) | FnGetSocketUid = BuiltinFunc(platform.LinuxTag | 47)
constant FnSetHash (line 59) | FnSetHash = BuiltinFunc(platform.LinuxTag | 48)
constant FnSetsockopt (line 60) | FnSetsockopt = BuiltinFunc(platform.LinuxTag | 49)
constant FnSkbAdjustRoom (line 61) | FnSkbAdjustRoom = BuiltinFunc(platform.LinuxTag | 50)
constant FnRedirectMap (line 62) | FnRedirectMap = BuiltinFunc(platform.LinuxTag | 51)
constant FnSkRedirectMap (line 63) | FnSkRedirectMap = BuiltinFunc(platform.LinuxTag | 52)
constant FnSockMapUpdate (line 64) | FnSockMapUpdate = BuiltinFunc(platform.LinuxTag | 53)
constant FnXdpAdjustMeta (line 65) | FnXdpAdjustMeta = BuiltinFunc(platform.LinuxTag | 54)
constant FnPerfEventReadValue (line 66) | FnPerfEventReadValue = BuiltinFunc(platform.LinuxTag | 55)
constant FnPerfProgReadValue (line 67) | FnPerfProgReadValue = BuiltinFunc(platform.LinuxTag | 56)
constant FnGetsockopt (line 68) | FnGetsockopt = BuiltinFunc(platform.LinuxTag | 57)
constant FnOverrideReturn (line 69) | FnOverrideReturn = BuiltinFunc(platform.LinuxTag | 58)
constant FnSockOpsCbFlagsSet (line 70) | FnSockOpsCbFlagsSet = BuiltinFunc(platform.LinuxTag | 59)
constant FnMsgRedirectMap (line 71) | FnMsgRedirectMap = BuiltinFunc(platform.LinuxTag | 60)
constant FnMsgApplyBytes (line 72) | FnMsgApplyBytes = BuiltinFunc(platform.LinuxTag | 61)
constant FnMsgCorkBytes (line 73) | FnMsgCorkBytes = BuiltinFunc(platform.LinuxTag | 62)
constant FnMsgPullData (line 74) | FnMsgPullData = BuiltinFunc(platform.LinuxTag | 63)
constant FnBind (line 75) | FnBind = BuiltinFunc(platform.LinuxTag | 64)
constant FnXdpAdjustTail (line 76) | FnXdpAdjustTail = BuiltinFunc(platform.LinuxTag | 65)
constant FnSkbGetXfrmState (line 77) | FnSkbGetXfrmState = BuiltinFunc(platform.LinuxTag | 66)
constant FnGetStack (line 78) | FnGetStack = BuiltinFunc(platform.LinuxTag | 67)
constant FnSkbLoadBytesRelative (line 79) | FnSkbLoadBytesRelative = BuiltinFunc(platform.LinuxTag | 68)
constant FnFibLookup (line 80) | FnFibLookup = BuiltinFunc(platform.LinuxTag | 69)
constant FnSockHashUpdate (line 81) | FnSockHashUpdate = BuiltinFunc(platform.LinuxTag | 70)
constant FnMsgRedirectHash (line 82) | FnMsgRedirectHash = BuiltinFunc(platform.LinuxTag | 71)
constant FnSkRedirectHash (line 83) | FnSkRedirectHash = BuiltinFunc(platform.LinuxTag | 72)
constant FnLwtPushEncap (line 84) | FnLwtPushEncap = BuiltinFunc(platform.LinuxTag | 73)
constant FnLwtSeg6StoreBytes (line 85) | FnLwtSeg6StoreBytes = BuiltinFunc(platform.LinuxTag | 74)
constant FnLwtSeg6AdjustSrh (line 86) | FnLwtSeg6AdjustSrh = BuiltinFunc(platform.LinuxTag | 75)
constant FnLwtSeg6Action (line 87) | FnLwtSeg6Action = BuiltinFunc(platform.LinuxTag | 76)
constant FnRcRepeat (line 88) | FnRcRepeat = BuiltinFunc(platform.LinuxTag | 77)
constant FnRcKeydown (line 89) | FnRcKeydown = BuiltinFunc(platform.LinuxTag | 78)
constant FnSkbCgroupId (line 90) | FnSkbCgroupId = BuiltinFunc(platform.LinuxTag | 79)
constant FnGetCurrentCgroupId (line 91) | FnGetCurrentCgroupId = BuiltinFunc(platform.LinuxTag | 80)
constant FnGetLocalStorage (line 92) | FnGetLocalStorage = BuiltinFunc(platform.LinuxTag | 81)
constant FnSkSelectReuseport (line 93) | FnSkSelectReuseport = BuiltinFunc(platform.LinuxTag | 82)
constant FnSkbAncestorCgroupId (line 94) | FnSkbAncestorCgroupId = BuiltinFunc(platform.LinuxTag | 83)
constant FnSkLookupTcp (line 95) | FnSkLookupTcp = BuiltinFunc(platform.LinuxTag | 84)
constant FnSkLookupUdp (line 96) | FnSkLookupUdp = BuiltinFunc(platform.LinuxTag | 85)
constant FnSkRelease (line 97) | FnSkRelease = BuiltinFunc(platform.LinuxTag | 86)
constant FnMapPushElem (line 98) | FnMapPushElem = BuiltinFunc(platform.LinuxTag | 87)
constant FnMapPopElem (line 99) | FnMapPopElem = BuiltinFunc(platform.LinuxTag | 88)
constant FnMapPeekElem (line 100) | FnMapPeekElem = BuiltinFunc(platform.LinuxTag | 89)
constant FnMsgPushData (line 101) | FnMsgPushData = BuiltinFunc(platform.LinuxTag | 90)
constant FnMsgPopData (line 102) | FnMsgPopData = BuiltinFunc(platform.LinuxTag | 91)
constant FnRcPointerRel (line 103) | FnRcPointerRel = BuiltinFunc(platform.LinuxTag | 92)
constant FnSpinLock (line 104) | FnSpinLock = BuiltinFunc(platform.LinuxTag | 93)
constant FnSpinUnlock (line 105) | FnSpinUnlock = BuiltinFunc(platform.LinuxTag | 94)
constant FnSkFullsock (line 106) | FnSkFullsock = BuiltinFunc(platform.LinuxTag | 95)
constant FnTcpSock (line 107) | FnTcpSock = BuiltinFunc(platform.LinuxTag | 96)
constant FnSkbEcnSetCe (line 108) | FnSkbEcnSetCe = BuiltinFunc(platform.LinuxTag | 97)
constant FnGetListenerSock (line 109) | FnGetListenerSock = BuiltinFunc(platform.LinuxTag | 98)
constant FnSkcLookupTcp (line 110) | FnSkcLookupTcp = BuiltinFunc(platform.LinuxTag | 99)
constant FnTcpCheckSyncookie (line 111) | FnTcpCheckSyncookie = BuiltinFunc(platform.LinuxTag | 100)
constant FnSysctlGetName (line 112) | FnSysctlGetName = BuiltinFunc(platform.LinuxTag | 101)
constant FnSysctlGetCurrentValue (line 113) | FnSysctlGetCurrentValue = BuiltinFunc(platform.LinuxTag | 102)
constant FnSysctlGetNewValue (line 114) | FnSysctlGetNewValue = BuiltinFunc(platform.LinuxTag | 103)
constant FnSysctlSetNewValue (line 115) | FnSysctlSetNewValue = BuiltinFunc(platform.LinuxTag | 104)
constant FnStrtol (line 116) | FnStrtol = BuiltinFunc(platform.LinuxTag | 105)
constant FnStrtoul (line 117) | FnStrtoul = BuiltinFunc(platform.LinuxTag | 106)
constant FnSkStorageGet (line 118) | FnSkStorageGet = BuiltinFunc(platform.LinuxTag | 107)
constant FnSkStorageDelete (line 119) | FnSkStorageDelete = BuiltinFunc(platform.LinuxTag | 108)
constant FnSendSignal (line 120) | FnSendSignal = BuiltinFunc(platform.LinuxTag | 109)
constant FnTcpGenSyncookie (line 121) | FnTcpGenSyncookie = BuiltinFunc(platform.LinuxTag | 110)
constant FnSkbOutput (line 122) | FnSkbOutput = BuiltinFunc(platform.LinuxTag | 111)
constant FnProbeReadUser (line 123) | FnProbeReadUser = BuiltinFunc(platform.LinuxTag | 112)
constant FnProbeReadKernel (line 124) | FnProbeReadKernel = BuiltinFunc(platform.LinuxTag | 113)
constant FnProbeReadUserStr (line 125) | FnProbeReadUserStr = BuiltinFunc(platform.LinuxTag | 114)
constant FnProbeReadKernelStr (line 126) | FnProbeReadKernelStr = BuiltinFunc(platform.LinuxTag | 115)
constant FnTcpSendAck (line 127) | FnTcpSendAck = BuiltinFunc(platform.LinuxTag | 116)
constant FnSendSignalThread (line 128) | FnSendSignalThread = BuiltinFunc(platform.LinuxTag | 117)
constant FnJiffies64 (line 129) | FnJiffies64 = BuiltinFunc(platform.LinuxTag | 118)
constant FnReadBranchRecords (line 130) | FnReadBranchRecords = BuiltinFunc(platform.LinuxTag | 119)
constant FnGetNsCurrentPidTgid (line 131) | FnGetNsCurrentPidTgid = BuiltinFunc(platform.LinuxTag | 120)
constant FnXdpOutput (line 132) | FnXdpOutput = BuiltinFunc(platform.LinuxTag | 121)
constant FnGetNetnsCookie (line 133) | FnGetNetnsCookie = BuiltinFunc(platform.LinuxTag | 122)
constant FnGetCurrentAncestorCgroupId (line 134) | FnGetCurrentAncestorCgroupId = BuiltinFunc(platform.LinuxTag | 123)
constant FnSkAssign (line 135) | FnSkAssign = BuiltinFunc(platform.LinuxTag | 124)
constant FnKtimeGetBootNs (line 136) | FnKtimeGetBootNs = BuiltinFunc(platform.LinuxTag | 125)
constant FnSeqPrintf (line 137) | FnSeqPrintf = BuiltinFunc(platform.LinuxTag | 126)
constant FnSeqWrite (line 138) | FnSeqWrite = BuiltinFunc(platform.LinuxTag | 127)
constant FnSkCgroupId (line 139) | FnSkCgroupId = BuiltinFunc(platform.LinuxTag | 128)
constant FnSkAncestorCgroupId (line 140) | FnSkAncestorCgroupId = BuiltinFunc(platform.LinuxTag | 129)
constant FnRingbufOutput (line 141) | FnRingbufOutput = BuiltinFunc(platform.LinuxTag | 130)
constant FnRingbufReserve (line 142) | FnRingbufReserve = BuiltinFunc(platform.LinuxTag | 131)
constant FnRingbufSubmit (line 143) | FnRingbufSubmit = BuiltinFunc(platform.LinuxTag | 132)
constant FnRingbufDiscard (line 144) | FnRingbufDiscard = BuiltinFunc(platform.LinuxTag | 133)
constant FnRingbufQuery (line 145) | FnRingbufQuery = BuiltinFunc(platform.LinuxTag | 134)
constant FnCsumLevel (line 146) | FnCsumLevel = BuiltinFunc(platform.LinuxTag | 135)
constant FnSkcToTcp6Sock (line 147) | FnSkcToTcp6Sock = BuiltinFunc(platform.LinuxTag | 136)
constant FnSkcToTcpSock (line 148) | FnSkcToTcpSock = BuiltinFunc(platform.LinuxTag | 137)
constant FnSkcToTcpTimewaitSock (line 149) | FnSkcToTcpTimewaitSock = BuiltinFunc(platform.LinuxTag | 138)
constant FnSkcToTcpRequestSock (line 150) | FnSkcToTcpRequestSock = BuiltinFunc(platform.LinuxTag | 139)
constant FnSkcToUdp6Sock (line 151) | FnSkcToUdp6Sock = BuiltinFunc(platform.LinuxTag | 140)
constant FnGetTaskStack (line 152) | FnGetTaskStack = BuiltinFunc(platform.LinuxTag | 141)
constant FnLoadHdrOpt (line 153) | FnLoadHdrOpt = BuiltinFunc(platform.LinuxTag | 142)
constant FnStoreHdrOpt (line 154) | FnStoreHdrOpt = BuiltinFunc(platform.LinuxTag | 143)
constant FnReserveHdrOpt (line 155) | FnReserveHdrOpt = BuiltinFunc(platform.LinuxTag | 144)
constant FnInodeStorageGet (line 156) | FnInodeStorageGet = BuiltinFunc(platform.LinuxTag | 145)
constant FnInodeStorageDelete (line 157) | FnInodeStorageDelete = BuiltinFunc(platform.LinuxTag | 146)
constant FnDPath (line 158) | FnDPath = BuiltinFunc(platform.LinuxTag | 147)
constant FnCopyFromUser (line 159) | FnCopyFromUser = BuiltinFunc(platform.LinuxTag | 148)
constant FnSnprintfBtf (line 160) | FnSnprintfBtf = BuiltinFunc(platform.LinuxTag | 149)
constant FnSeqPrintfBtf (line 161) | FnSeqPrintfBtf = BuiltinFunc(platform.LinuxTag | 150)
constant FnSkbCgroupClassid (line 162) | FnSkbCgroupClassid = BuiltinFunc(platform.LinuxTag | 151)
constant FnRedirectNeigh (line 163) | FnRedirectNeigh = BuiltinFunc(platform.LinuxTag | 152)
constant FnPerCpuPtr (line 164) | FnPerCpuPtr = BuiltinFunc(platform.LinuxTag | 153)
constant FnThisCpuPtr (line 165) | FnThisCpuPtr = BuiltinFunc(platform.LinuxTag | 154)
constant FnRedirectPeer (line 166) | FnRedirectPeer = BuiltinFunc(platform.LinuxTag | 155)
constant FnTaskStorageGet (line 167) | FnTaskStorageGet = BuiltinFunc(platform.LinuxTag | 156)
constant FnTaskStorageDelete (line 168) | FnTaskStorageDelete = BuiltinFunc(platform.LinuxTag | 157)
constant FnGetCurrentTaskBtf (line 169) | FnGetCurrentTaskBtf = BuiltinFunc(platform.LinuxTag | 158)
constant FnBprmOptsSet (line 170) | FnBprmOptsSet = BuiltinFunc(platform.LinuxTag | 159)
constant FnKtimeGetCoarseNs (line 171) | FnKtimeGetCoarseNs = BuiltinFunc(platform.LinuxTag | 160)
constant FnImaInodeHash (line 172) | FnImaInodeHash = BuiltinFunc(platform.LinuxTag | 161)
constant FnSockFromFile (line 173) | FnSockFromFile = BuiltinFunc(platform.LinuxTag | 162)
constant FnCheckMtu (line 174) | FnCheckMtu = BuiltinFunc(platform.LinuxTag | 163)
constant FnForEachMapElem (line 175) | FnForEachMapElem = BuiltinFunc(platform.LinuxTag | 164)
constant FnSnprintf (line 176) | FnSnprintf = BuiltinFunc(platform.LinuxTag | 165)
constant FnSysBpf (line 177) | FnSysBpf = BuiltinFunc(platform.LinuxTag | 166)
constant FnBtfFindByNameKind (line 178) | FnBtfFindByNameKind = BuiltinFunc(platform.LinuxTag | 167)
constant FnSysClose (line 179) | FnSysClose = BuiltinFunc(platform.LinuxTag | 168)
constant FnTimerInit (line 180) | FnTimerInit = BuiltinFunc(platform.LinuxTag | 169)
constant FnTimerSetCallback (line 181) | FnTimerSetCallback = BuiltinFunc(platform.LinuxTag | 170)
constant FnTimerStart (line 182) | FnTimerStart = BuiltinFunc(platform.LinuxTag | 171)
constant FnTimerCancel (line 183) | FnTimerCancel = BuiltinFunc(platform.LinuxTag | 172)
constant FnGetFuncIp (line 184) | FnGetFuncIp = BuiltinFunc(platform.LinuxTag | 173)
constant FnGetAttachCookie (line 185) | FnGetAttachCookie = BuiltinFunc(platform.LinuxTag | 174)
constant FnTaskPtRegs (line 186) | FnTaskPtRegs = BuiltinFunc(platform.LinuxTag | 175)
constant FnGetBranchSnapshot (line 187) | FnGetBranchSnapshot = BuiltinFunc(platform.LinuxTag | 176)
constant FnTraceVprintk (line 188) | FnTraceVprintk = BuiltinFunc(platform.LinuxTag | 177)
constant FnSkcToUnixSock (line 189) | FnSkcToUnixSock = BuiltinFunc(platform.LinuxTag | 178)
constant FnKallsymsLookupName (line 190) | FnKallsymsLookupName = BuiltinFunc(platform.LinuxTag | 179)
constant FnFindVma (line 191) | FnFindVma = BuiltinFunc(platform.LinuxTag | 180)
constant FnLoop (line 192) | FnLoop = BuiltinFunc(platform.LinuxTag | 181)
constant FnStrncmp (line 193) | FnStrncmp = BuiltinFunc(platform.LinuxTag | 182)
constant FnGetFuncArg (line 194) | FnGetFuncArg = BuiltinFunc(platform.LinuxTag | 183)
constant FnGetFuncRet (line 195) | FnGetFuncRet = BuiltinFunc(platform.LinuxTag | 184)
constant FnGetFuncArgCnt (line 196) | FnGetFuncArgCnt = BuiltinFunc(platform.LinuxTag | 185)
constant FnGetRetval (line 197) | FnGetRetval = BuiltinFunc(platform.LinuxTag | 186)
constant FnSetRetval (line 198) | FnSetRetval = BuiltinFunc(platform.LinuxTag | 187)
constant FnXdpGetBuffLen (line 199) | FnXdpGetBuffLen = BuiltinFunc(platform.LinuxTag | 188)
constant FnXdpLoadBytes (line 200) | FnXdpLoadBytes = BuiltinFunc(platform.LinuxTag | 189)
constant FnXdpStoreBytes (line 201) | FnXdpStoreBytes = BuiltinFunc(platform.LinuxTag | 190)
constant FnCopyFromUserTask (line 202) | FnCopyFromUserTask = BuiltinFunc(platform.LinuxTag | 191)
constant FnSkbSetTstamp (line 203) | FnSkbSetTstamp = BuiltinFunc(platform.LinuxTag | 192)
constant FnImaFileHash (line 204) | FnImaFileHash = BuiltinFunc(platform.LinuxTag | 193)
constant FnKptrXchg (line 205) | FnKptrXchg = BuiltinFunc(platform.LinuxTag | 194)
constant FnMapLookupPercpuElem (line 206) | FnMapLookupPercpuElem = BuiltinFunc(platform.LinuxTag | 195)
constant FnSkcToMptcpSock (line 207) | FnSkcToMptcpSock = BuiltinFunc(platform.LinuxTag | 196)
constant FnDynptrFromMem (line 208) | FnDynptrFromMem = BuiltinFunc(platform.LinuxTag | 197)
constant FnRingbufReserveDynptr (line 209) | FnRingbufReserveDynptr = BuiltinFunc(platform.LinuxTag | 198)
constant FnRingbufSubmitDynptr (line 210) | FnRingbufSubmitDynptr = BuiltinFunc(platform.LinuxTag | 199)
constant FnRingbufDiscardDynptr (line 211) | FnRingbufDiscardDynptr = BuiltinFunc(platform.LinuxTag | 200)
constant FnDynptrRead (line 212) | FnDynptrRead = BuiltinFunc(platform.LinuxTag | 201)
constant FnDynptrWrite (line 213) | FnDynptrWrite = BuiltinFunc(platform.LinuxTag | 202)
constant FnDynptrData (line 214) | FnDynptrData = BuiltinFunc(platform.LinuxTag | 203)
constant FnTcpRawGenSyncookieIpv4 (line 215) | FnTcpRawGenSyncookieIpv4 = BuiltinFunc(platform.LinuxTag | 204)
constant FnTcpRawGenSyncookieIpv6 (line 216) | FnTcpRawGenSyncookieIpv6 = BuiltinFunc(platform.LinuxTag | 205)
constant FnTcpRawCheckSyncookieIpv4 (line 217) | FnTcpRawCheckSyncookieIpv4 = BuiltinFunc(platform.LinuxTag | 206)
constant FnTcpRawCheckSyncookieIpv6 (line 218) | FnTcpRawCheckSyncookieIpv6 = BuiltinFunc(platform.LinuxTag | 207)
constant FnKtimeGetTaiNs (line 219) | FnKtimeGetTaiNs = BuiltinFunc(platform.LinuxTag | 208)
constant FnUserRingbufDrain (line 220) | FnUserRingbufDrain = BuiltinFunc(platform.LinuxTag | 209)
constant FnCgrpStorageGet (line 221) | FnCgrpStorageGet = BuiltinFunc(platform.LinuxTag | 210)
constant FnCgrpStorageDelete (line 222) | FnCgrpStorageDelete = BuiltinFunc(platform.LinuxTag | 211)
FILE: asm/func_string.go
function _ (line 7) | func _() {
constant _BuiltinFunc_name_0 (line 260) | _BuiltinFunc_name_0 = "FnUnspecFnMapLookupElemFnMapUpdateElemFnMapDelete...
constant _BuiltinFunc_name_1 (line 261) | _BuiltinFunc_name_1 = "WindowsFnMapLookupElemWindowsFnMapUpdateElemWindo...
method String (line 269) | func (i BuiltinFunc) String() string {
FILE: asm/func_win.go
constant WindowsFnMapLookupElem (line 11) | WindowsFnMapLookupElem = BuiltinFunc(platform.WindowsTag | 1)
constant WindowsFnMapUpdateElem (line 12) | WindowsFnMapUpdateElem = BuiltinFunc(platform.WindowsTag | 2)
constant WindowsFnMapDeleteElem (line 13) | WindowsFnMapDeleteElem = BuiltinFunc(platform.WindowsTag | 3)
constant WindowsFnMapLookupAndDeleteElem (line 14) | WindowsFnMapLookupAndDeleteElem = BuiltinFunc(platform.WindowsTag | 4)
constant WindowsFnTailCall (line 15) | WindowsFnTailCall = BuiltinFunc(platform.WindowsTag | 5)
constant WindowsFnGetPrandomU32 (line 16) | WindowsFnGetPrandomU32 = BuiltinFunc(platform.WindowsTag | 6)
constant WindowsFnKtimeGetBootNs (line 17) | WindowsFnKtimeGetBootNs = BuiltinFunc(platform.WindowsTag | 7)
constant WindowsFnGetSmpProcessorId (line 18) | WindowsFnGetSmpProcessorId = BuiltinFunc(platform.WindowsTag | 8)
constant WindowsFnKtimeGetNs (line 19) | WindowsFnKtimeGetNs = BuiltinFunc(platform.WindowsTag | 9)
constant WindowsFnCsumDiff (line 20) | WindowsFnCsumDiff = BuiltinFunc(platform.WindowsTag | 10)
constant WindowsFnRingbufOutput (line 21) | WindowsFnRingbufOutput = BuiltinFunc(platform.WindowsTag | 11)
constant WindowsFnTracePrintk2 (line 22) | WindowsFnTracePrintk2 = BuiltinFunc(platform.WindowsTag | 12)
constant WindowsFnTracePrintk3 (line 23) | WindowsFnTracePrintk3 = BuiltinFunc(platform.WindowsTag | 13)
constant WindowsFnTracePrintk4 (line 24) | WindowsFnTracePrintk4 = BuiltinFunc(platform.WindowsTag | 14)
constant WindowsFnTracePrintk5 (line 25) | WindowsFnTracePrintk5 = BuiltinFunc(platform.WindowsTag | 15)
constant WindowsFnMapPushElem (line 26) | WindowsFnMapPushElem = BuiltinFunc(platform.WindowsTag | 16)
constant WindowsFnMapPopElem (line 27) | WindowsFnMapPopElem = BuiltinFunc(platform.WindowsTag | 17)
constant WindowsFnMapPeekElem (line 28) | WindowsFnMapPeekElem = BuiltinFunc(platform.WindowsTag | 18)
constant WindowsFnGetCurrentPidTgid (line 29) | WindowsFnGetCurrentPidTgid = BuiltinFunc(platform.WindowsTag | 19)
constant WindowsFnGetCurrentLogonId (line 30) | WindowsFnGetCurrentLogonId = BuiltinFunc(platform.WindowsTag | 20)
constant WindowsFnIsCurrentAdmin (line 31) | WindowsFnIsCurrentAdmin = BuiltinFunc(platform.WindowsTag | 21)
constant WindowsFnMemcpyS (line 32) | WindowsFnMemcpyS = BuiltinFunc(platform.WindowsTag | 22)
constant WindowsFnMemcmpS (line 33) | WindowsFnMemcmpS = BuiltinFunc(platform.WindowsTag | 23)
constant WindowsFnMemset (line 34) | WindowsFnMemset = BuiltinFunc(platform.WindowsTag | 24)
constant WindowsFnMemmoveS (line 35) | WindowsFnMemmoveS = BuiltinFunc(platform.WindowsTag | 25)
constant WindowsFnGetSocketCookie (line 36) | WindowsFnGetSocketCookie = BuiltinFunc(platform.WindowsTag | 26)
constant WindowsFnStrncpyS (line 37) | WindowsFnStrncpyS = BuiltinFunc(platform.WindowsTag | 27)
constant WindowsFnStrncatS (line 38) | WindowsFnStrncatS = BuiltinFunc(platform.WindowsTag | 28)
constant WindowsFnStrnlenS (line 39) | WindowsFnStrnlenS = BuiltinFunc(platform.WindowsTag | 29)
constant WindowsFnKtimeGetBootMs (line 40) | WindowsFnKtimeGetBootMs = BuiltinFunc(platform.WindowsTag | 30)
constant WindowsFnKtimeGetMs (line 41) | WindowsFnKtimeGetMs = BuiltinFunc(platform.WindowsTag | 31)
constant WindowsFnPerfEventOutput (line 42) | WindowsFnPerfEventOutput = BuiltinFunc(platform.WindowsTag | 32)
constant WindowsFnGetCurrentProcessStartKey (line 43) | WindowsFnGetCurrentProcessStartKey = BuiltinFunc(platform.WindowsTag | 33)
constant WindowsFnGetCurrentThreadCreateTime (line 44) | WindowsFnGetCurrentThreadCreateTime = BuiltinFunc(platform.WindowsTag | 34)
FILE: asm/instruction.go
constant InstructionSize (line 22) | InstructionSize = 8
type RawInstructionOffset (line 25) | type RawInstructionOffset
method Bytes (line 32) | func (rio RawInstructionOffset) Bytes() uint64 {
type Instruction (line 37) | type Instruction struct
method Width (line 52) | func (ins *Instruction) Width() RawInstructionOffset {
method Unmarshal (line 57) | func (ins *Instruction) Unmarshal(r io.Reader, bo binary.ByteOrder, pl...
method Marshal (line 148) | func (ins Instruction) Marshal(w io.Writer, bo binary.ByteOrder) (uint...
method AssociateMap (line 235) | func (ins *Instruction) AssociateMap(m FDer) error {
method encodeMapFD (line 246) | func (ins *Instruction) encodeMapFD(fd int) {
method mapFd (line 255) | func (ins *Instruction) mapFd() int {
method RewriteMapOffset (line 262) | func (ins *Instruction) RewriteMapOffset(offset uint32) error {
method mapOffset (line 276) | func (ins *Instruction) mapOffset() uint32 {
method IsLoadFromMap (line 283) | func (ins *Instruction) IsLoadFromMap() bool {
method IsFunctionCall (line 290) | func (ins *Instruction) IsFunctionCall() bool {
method IsKfuncCall (line 297) | func (ins *Instruction) IsKfuncCall() bool {
method IsLoadOfFunctionPointer (line 302) | func (ins *Instruction) IsLoadOfFunctionPointer() bool {
method IsFunctionReference (line 309) | func (ins *Instruction) IsFunctionReference() bool {
method IsBuiltinCall (line 314) | func (ins *Instruction) IsBuiltinCall() bool {
method IsConstantLoad (line 320) | func (ins *Instruction) IsConstantLoad(size Size) bool {
method Format (line 325) | func (ins Instruction) Format(f fmt.State, c rune) {
method equal (line 438) | func (ins Instruction) equal(other Instruction) bool {
method Size (line 447) | func (ins Instruction) Size() uint64 {
method WithMetadata (line 453) | func (ins Instruction) WithMetadata(meta Metadata) Instruction {
method WithSymbol (line 462) | func (ins Instruction) WithSymbol(name string) Instruction {
method Symbol (line 470) | func (ins Instruction) Symbol() string {
method WithReference (line 478) | func (ins Instruction) WithReference(ref string) Instruction {
method Reference (line 484) | func (ins Instruction) Reference() string {
method Map (line 494) | func (ins Instruction) Map() FDer {
method WithSource (line 502) | func (ins Instruction) WithSource(src fmt.Stringer) Instruction {
method Source (line 510) | func (ins Instruction) Source() fmt.Stringer {
type symbolMeta (line 458) | type symbolMeta struct
type referenceMeta (line 475) | type referenceMeta struct
type mapMeta (line 489) | type mapMeta struct
type sourceMeta (line 499) | type sourceMeta struct
type Comment (line 517) | type Comment
method String (line 519) | func (s Comment) String() string {
type FDer (line 526) | type FDer interface
type Instructions (line 531) | type Instructions
method Name (line 554) | func (insns Instructions) Name() string {
method String (line 561) | func (insns Instructions) String() string {
method Size (line 566) | func (insns Instructions) Size() uint64 {
method AssociateMap (line 580) | func (insns Instructions) AssociateMap(symbol string, m FDer) error {
method SymbolOffsets (line 608) | func (insns Instructions) SymbolOffsets() (map[string]int, error) {
method FunctionReferences (line 628) | func (insns Instructions) FunctionReferences() []string {
method ReferenceOffsets (line 658) | func (insns Instructions) ReferenceOffsets() map[string][]int {
method Format (line 679) | func (insns Instructions) Format(f fmt.State, c rune) {
method Marshal (line 736) | func (insns Instructions) Marshal(w io.Writer, bo binary.ByteOrder) er...
method Tag (line 761) | func (insns Instructions) Tag(bo binary.ByteOrder) (string, error) {
method HasTag (line 768) | func (insns Instructions) HasTag(tag string, bo binary.ByteOrder) (boo...
method tagSha1 (line 789) | func (insns Instructions) tagSha1(bo binary.ByteOrder) (string, error) {
method tagSha256 (line 801) | func (insns Instructions) tagSha256(bo binary.ByteOrder) (string, erro...
method hash (line 813) | func (insns Instructions) hash(h hash.Hash, bo binary.ByteOrder) error {
method encodeFunctionReferences (line 835) | func (insns Instructions) encodeFunctionReferences() error {
method encodeMapPointers (line 891) | func (insns Instructions) encodeMapPointers() error {
method Iterate (line 920) | func (insns Instructions) Iterate() *InstructionIterator {
function AppendInstructions (line 534) | func AppendInstructions(insns Instructions, r io.Reader, bo binary.ByteO...
type InstructionIterator (line 925) | type InstructionIterator struct
method Next (line 937) | func (iter *InstructionIterator) Next() bool {
type bpfRegisters (line 951) | type bpfRegisters
function newBPFRegisters (line 953) | func newBPFRegisters(dst, src Register, bo binary.ByteOrder) (bpfRegiste...
FILE: asm/instruction_test.go
function TestRead64bitImmediate (line 23) | func TestRead64bitImmediate(t *testing.T) {
function BenchmarkRead64bitImmediate (line 35) | func BenchmarkRead64bitImmediate(b *testing.B) {
function TestWrite64bitImmediate (line 47) | func TestWrite64bitImmediate(t *testing.T) {
function BenchmarkWrite64BitImmediate (line 62) | func BenchmarkWrite64BitImmediate(b *testing.B) {
function TestAppendInstructions (line 75) | func TestAppendInstructions(t *testing.T) {
function TestSignedJump (line 86) | func TestSignedJump(t *testing.T) {
function TestInstructionLoadMapValue (line 99) | func TestInstructionLoadMapValue(t *testing.T) {
function TestInstructionWithMetadata (line 112) | func TestInstructionWithMetadata(t *testing.T) {
function TestReadCallToNegativeOne (line 125) | func TestReadCallToNegativeOne(t *testing.T) {
function ExampleInstructions_Format (line 137) | func ExampleInstructions_Format() {
function TestReadSrcDst (line 190) | func TestReadSrcDst(t *testing.T) {
function TestInstructionIterator (line 222) | func TestInstructionIterator(t *testing.T) {
function TestMetadataCopyOnWrite (line 248) | func TestMetadataCopyOnWrite(t *testing.T) {
type testFDer (line 277) | type testFDer
method FD (line 279) | func (t testFDer) FD() int {
function TestAtomics (line 283) | func TestAtomics(t *testing.T) {
function TestISAv4 (line 359) | func TestISAv4(t *testing.T) {
function TestLongJumpPatching (line 451) | func TestLongJumpPatching(t *testing.T) {
FILE: asm/jump.go
type JumpOp (line 11) | type JumpOp
method Op (line 59) | func (op JumpOp) Op(source Source) OpCode {
method Imm (line 64) | func (op JumpOp) Imm(dst Register, value int32, label string) Instruct...
method Imm32 (line 75) | func (op JumpOp) Imm32(dst Register, value int32, label string) Instru...
method Reg (line 85) | func (op JumpOp) Reg(dst, src Register, label string) Instruction {
method Reg32 (line 96) | func (op JumpOp) Reg32(dst, src Register, label string) Instruction {
method opCode (line 105) | func (op JumpOp) opCode(class Class, source Source) OpCode {
method Label (line 122) | func (op JumpOp) Label(label string) Instruction {
constant jumpMask (line 13) | jumpMask OpCode = 0xf0
constant InvalidJumpOp (line 18) | InvalidJumpOp JumpOp = 0xff
constant Ja (line 20) | Ja JumpOp = 0x00
constant JEq (line 22) | JEq JumpOp = 0x10
constant JGT (line 24) | JGT JumpOp = 0x20
constant JGE (line 26) | JGE JumpOp = 0x30
constant JSet (line 28) | JSet JumpOp = 0x40
constant JNE (line 30) | JNE JumpOp = 0x50
constant JSGT (line 32) | JSGT JumpOp = 0x60
constant JSGE (line 34) | JSGE JumpOp = 0x70
constant Call (line 36) | Call JumpOp = 0x80
constant Exit (line 38) | Exit JumpOp = 0x90
constant JLT (line 40) | JLT JumpOp = 0xa0
constant JLE (line 42) | JLE JumpOp = 0xb0
constant JSLT (line 44) | JSLT JumpOp = 0xc0
constant JSLE (line 46) | JSLE JumpOp = 0xd0
function Return (line 52) | func Return() Instruction {
function LongJump (line 114) | func LongJump(label string) Instruction {
FILE: asm/jump_string.go
function _ (line 7) | func _() {
constant _JumpOp_name (line 28) | _JumpOp_name = "JaJEqJGTJGEJSetJNEJSGTJSGECallExitJLTJLEJSLTJSLEInvalidJ...
method String (line 48) | func (i JumpOp) String() string {
FILE: asm/load_store.go
type Mode (line 13) | type Mode
constant modeMask (line 15) | modeMask OpCode = 0xe0
constant InvalidMode (line 20) | InvalidMode Mode = 0xff
constant ImmMode (line 22) | ImmMode Mode = 0x00
constant AbsMode (line 24) | AbsMode Mode = 0x20
constant IndMode (line 26) | IndMode Mode = 0x40
constant MemMode (line 28) | MemMode Mode = 0x60
constant MemSXMode (line 30) | MemSXMode Mode = 0x80
constant AtomicMode (line 32) | AtomicMode Mode = 0xc0
constant atomicMask (line 35) | atomicMask OpCode = 0x0001_ff00
type AtomicOp (line 37) | type AtomicOp
method String (line 77) | func (op AtomicOp) String() string {
method OpCode (line 99) | func (op AtomicOp) OpCode(size Size) OpCode {
method Mem (line 115) | func (op AtomicOp) Mem(dst, src Register, size Size, offset int16) Ins...
constant InvalidAtomic (line 40) | InvalidAtomic AtomicOp = 0xffff_ffff
constant AddAtomic (line 43) | AddAtomic AtomicOp = AtomicOp(Add) << 8
constant FetchAdd (line 45) | FetchAdd AtomicOp = AddAtomic | fetch
constant AndAtomic (line 47) | AndAtomic AtomicOp = AtomicOp(And) << 8
constant FetchAnd (line 49) | FetchAnd AtomicOp = AndAtomic | fetch
constant OrAtomic (line 51) | OrAtomic AtomicOp = AtomicOp(Or) << 8
constant FetchOr (line 53) | FetchOr AtomicOp = OrAtomic | fetch
constant XorAtomic (line 55) | XorAtomic AtomicOp = AtomicOp(Xor) << 8
constant FetchXor (line 57) | FetchXor AtomicOp = XorAtomic | fetch
constant Xchg (line 62) | Xchg AtomicOp = 0x0000_e000 | fetch
constant CmpXchg (line 67) | CmpXchg AtomicOp = 0x0000_f000 | fetch
constant fetch (line 70) | fetch AtomicOp = 0x0000_0100
constant loadAcquire (line 72) | loadAcquire AtomicOp = 0x0001_0000
constant storeRelease (line 74) | storeRelease AtomicOp = 0x0001_1000
function LoadAcquire (line 125) | func LoadAcquire(dst, src Register, size Size, offset int16) Instruction {
function StoreRelease (line 135) | func StoreRelease(dst, src Register, size Size, offset int16) Instruction {
type Size (line 150) | type Size
method Sizeof (line 169) | func (s Size) Sizeof() int {
constant sizeMask (line 152) | sizeMask OpCode = 0x18
constant InvalidSize (line 157) | InvalidSize Size = 0xff
constant DWord (line 159) | DWord Size = 0x18
constant Word (line 161) | Word Size = 0x00
constant Half (line 163) | Half Size = 0x08
constant Byte (line 165) | Byte Size = 0x10
function LoadMemOp (line 185) | func LoadMemOp(size Size) OpCode {
function LoadMemSXOp (line 190) | func LoadMemSXOp(size Size) OpCode {
function LoadMem (line 195) | func LoadMem(dst, src Register, offset int16, size Size) Instruction {
function LoadMemSX (line 205) | func LoadMemSX(dst, src Register, offset int16, size Size) Instruction {
function LoadImmOp (line 221) | func LoadImmOp(size Size) OpCode {
function LoadImm (line 228) | func LoadImm(dst Register, value int64, size Size) Instruction {
function LoadMapPtr (line 237) | func LoadMapPtr(dst Register, fd int) Instruction {
function LoadMapValue (line 251) | func LoadMapValue(dst Register, fd int, offset uint32) Instruction {
function LoadIndOp (line 266) | func LoadIndOp(size Size) OpCode {
function LoadInd (line 271) | func LoadInd(dst, src Register, offset int32, size Size) Instruction {
function LoadAbsOp (line 281) | func LoadAbsOp(size Size) OpCode {
function LoadAbs (line 286) | func LoadAbs(offset int32, size Size) Instruction {
function StoreMemOp (line 295) | func StoreMemOp(size Size) OpCode {
function StoreMem (line 300) | func StoreMem(dst Register, offset int16, src Register, size Size) Instr...
function StoreImmOp (line 310) | func StoreImmOp(size Size) OpCode {
function StoreImm (line 315) | func StoreImm(dst Register, offset int16, value int64, size Size) Instru...
function StoreXAddOp (line 329) | func StoreXAddOp(size Size) OpCode {
function StoreXAdd (line 334) | func StoreXAdd(dst, src Register, size Size) Instruction {
FILE: asm/load_store_string.go
function _ (line 7) | func _() {
constant _Mode_name_0 (line 21) | _Mode_name_0 = "ImmMode"
constant _Mode_name_1 (line 22) | _Mode_name_1 = "AbsMode"
constant _Mode_name_2 (line 23) | _Mode_name_2 = "IndMode"
constant _Mode_name_3 (line 24) | _Mode_name_3 = "MemMode"
constant _Mode_name_4 (line 25) | _Mode_name_4 = "MemSXMode"
constant _Mode_name_5 (line 26) | _Mode_name_5 = "AtomicMode"
constant _Mode_name_6 (line 27) | _Mode_name_6 = "InvalidMode"
method String (line 30) | func (i Mode) String() string {
function _ (line 50) | func _() {
constant _Size_name_0 (line 62) | _Size_name_0 = "Word"
constant _Size_name_1 (line 63) | _Size_name_1 = "Half"
constant _Size_name_2 (line 64) | _Size_name_2 = "Byte"
constant _Size_name_3 (line 65) | _Size_name_3 = "DWord"
constant _Size_name_4 (line 66) | _Size_name_4 = "InvalidSize"
method String (line 69) | func (i Size) String() string {
FILE: asm/metadata.go
type Metadata (line 4) | type Metadata struct
method find (line 16) | func (m *Metadata) find(key interface{}) *metaElement {
method remove (line 29) | func (m *Metadata) remove(r *metaElement) {
method Set (line 52) | func (m *Metadata) Set(key, value interface{}) {
method Get (line 75) | func (m *Metadata) Get(key interface{}) interface{} {
type metaElement (line 8) | type metaElement struct
FILE: asm/metadata_test.go
function TestMetadata (line 10) | func TestMetadata(t *testing.T) {
function BenchmarkMetadata (line 47) | func BenchmarkMetadata(b *testing.B) {
FILE: asm/opcode.go
type Class (line 16) | type Class
method IsLoad (line 42) | func (cls Class) IsLoad() bool {
method IsStore (line 47) | func (cls Class) IsStore() bool {
method isLoadOrStore (line 51) | func (cls Class) isLoadOrStore() bool {
method IsALU (line 56) | func (cls Class) IsALU() bool {
method IsJump (line 61) | func (cls Class) IsJump() bool {
method isJumpOrALU (line 65) | func (cls Class) isJumpOrALU() bool {
constant classMask (line 18) | classMask OpCode = 0x07
constant LdClass (line 23) | LdClass Class = 0x00
constant LdXClass (line 25) | LdXClass Class = 0x01
constant StClass (line 27) | StClass Class = 0x02
constant StXClass (line 29) | StXClass Class = 0x03
constant ALUClass (line 31) | ALUClass Class = 0x04
constant JumpClass (line 33) | JumpClass Class = 0x05
constant Jump32Class (line 36) | Jump32Class Class = 0x06
constant ALU64Class (line 38) | ALU64Class Class = 0x07
type OpCode (line 96) | type OpCode
method bpfOpCode (line 102) | func (op OpCode) bpfOpCode() (byte, error) {
method rawInstructions (line 114) | func (op OpCode) rawInstructions() int {
method IsDWordLoad (line 121) | func (op OpCode) IsDWordLoad() bool {
method Class (line 126) | func (op OpCode) Class() Class {
method Mode (line 131) | func (op OpCode) Mode() Mode {
method Size (line 139) | func (op OpCode) Size() Size {
method AtomicOp (line 147) | func (op OpCode) AtomicOp() AtomicOp {
method Source (line 155) | func (op OpCode) Source() Source {
method ALUOp (line 163) | func (op OpCode) ALUOp() ALUOp {
method Endianness (line 171) | func (op OpCode) Endianness() Endianness {
method JumpOp (line 180) | func (op OpCode) JumpOp() JumpOp {
method SetMode (line 198) | func (op OpCode) SetMode(mode Mode) OpCode {
method SetSize (line 208) | func (op OpCode) SetSize(size Size) OpCode {
method SetAtomicOp (line 215) | func (op OpCode) SetAtomicOp(atomic AtomicOp) OpCode {
method SetSource (line 225) | func (op OpCode) SetSource(source Source) OpCode {
method SetALUOp (line 235) | func (op OpCode) SetALUOp(alu ALUOp) OpCode {
method SetJumpOp (line 245) | func (op OpCode) SetJumpOp(jump JumpOp) OpCode {
method String (line 260) | func (op OpCode) String() string {
constant InvalidOpCode (line 99) | InvalidOpCode OpCode = 0xffff
function valid (line 325) | func valid(value, mask OpCode) bool {
FILE: asm/opcode_string.go
function _ (line 7) | func _() {
constant _Class_name (line 21) | _Class_name = "LdClassLdXClassStClassStXClassALUClassJumpClassJump32Clas...
method String (line 25) | func (i Class) String() string {
FILE: asm/opcode_test.go
function TestGetSetJumpOp (line 10) | func TestGetSetJumpOp(t *testing.T) {
FILE: asm/register.go
type Register (line 8) | type Register
method String (line 45) | func (r Register) String() string {
constant R0 (line 11) | R0 Register = 0
constant R1 (line 15) | R1 Register = R0 + 1 + iota
constant R2 (line 16) | R2
constant R3 (line 17) | R3
constant R4 (line 18) | R4
constant R5 (line 19) | R5
constant R6 (line 24) | R6 Register = R5 + 1 + iota
constant R7 (line 25) | R7
constant R8 (line 26) | R8
constant R9 (line 27) | R9
constant R10 (line 32) | R10 Register = R9 + 1
constant RFP (line 33) | RFP = R10
constant PseudoMapFD (line 38) | PseudoMapFD = R1
constant PseudoMapValue (line 39) | PseudoMapValue = R2
constant PseudoCall (line 40) | PseudoCall = R1
constant PseudoFunc (line 41) | PseudoFunc = R4
constant PseudoKfuncCall (line 42) | PseudoKfuncCall = R2
FILE: attachtype_string.go
function _ (line 7) | func _() {
constant _AttachType_name_0 (line 81) | _AttachType_name_0 = "NoneCGroupInetEgressCGroupInetSockCreateCGroupSock...
constant _AttachType_name_1 (line 82) | _AttachType_name_1 = "WindowsXDPWindowsBindWindowsCGroupInet4ConnectWind...
method String (line 90) | func (i AttachType) String() string {
FILE: btf/btf.go
constant btfMagic (line 19) | btfMagic = 0xeB9F
type elfData (line 32) | type elfData struct
method fixupDatasec (line 242) | func (elf *elfData) fixupDatasec(typ Type) error {
type elfSymbol (line 38) | type elfSymbol struct
type Spec (line 45) | type Spec struct
method Copy (line 349) | func (s *Spec) Copy() *Spec {
method TypeByID (line 374) | func (s *Spec) TypeByID(id TypeID) (Type, error) {
method TypeID (line 390) | func (s *Spec) TypeID(typ Type) (TypeID, error) {
method AnyTypesByName (line 401) | func (s *Spec) AnyTypesByName(name string) ([]Type, error) {
method AnyTypeByName (line 426) | func (s *Spec) AnyTypeByName(name string) (Type, error) {
method TypeByName (line 448) | func (s *Spec) TypeByName(name string, typ interface{}) error {
method All (line 527) | func (s *Spec) All() iter.Seq2[Type, error] {
function LoadSpec (line 53) | func LoadSpec(file string) (*Spec, error) {
function LoadSpecFromReader (line 67) | func LoadSpecFromReader(rd io.ReaderAt) (*Spec, error) {
function LoadSpecAndExtInfosFromReader (line 85) | func LoadSpecAndExtInfosFromReader(rd io.ReaderAt) (*Spec, *ExtInfos, er...
function symbolOffsets (line 111) | func symbolOffsets(file *internal.SafeELFFile) (map[elfSymbol]uint32, er...
function loadSpecFromELF (line 140) | func loadSpecFromELF(file *internal.SafeELFFile) (*Spec, error) {
function loadRawSpec (line 195) | func loadRawSpec(btf []byte, base *Spec) (*Spec, error) {
function fixupDatasecLayout (line 313) | func fixupDatasecLayout(ds *Datasec) error {
function LoadSplitSpec (line 503) | func LoadSplitSpec(file string, base *Spec) (*Spec, error) {
function LoadSplitSpecFromReader (line 517) | func LoadSplitSpecFromReader(r io.ReaderAt, base *Spec) (*Spec, error) {
FILE: btf/btf_test.go
function vmlinuxSpec (line 21) | func vmlinuxSpec(tb testing.TB) *Spec {
type specAndRawBTF (line 37) | type specAndRawBTF struct
function vmlinuxTestdataSpec (line 56) | func vmlinuxTestdataSpec(tb testing.TB) *Spec {
function vmlinuxTestdataBytes (line 67) | func vmlinuxTestdataBytes(tb testing.TB) []byte {
function parseELFBTF (line 78) | func parseELFBTF(tb testing.TB, file string) *Spec {
function TestAnyTypesByName (line 89) | func TestAnyTypesByName(t *testing.T) {
function TestTypeByNameAmbiguous (line 113) | func TestTypeByNameAmbiguous(t *testing.T) {
function TestTypeByName (line 136) | func TestTypeByName(t *testing.T) {
function BenchmarkParseVmlinux (line 212) | func BenchmarkParseVmlinux(b *testing.B) {
function BenchmarkIterateVmlinux (line 223) | func BenchmarkIterateVmlinux(b *testing.B) {
function TestParseCurrentKernelBTF (line 238) | func TestParseCurrentKernelBTF(t *testing.T) {
function TestFindVMLinux (line 246) | func TestFindVMLinux(t *testing.T) {
function TestLoadSpecFromElf (line 264) | func TestLoadSpecFromElf(t *testing.T) {
function TestVerifierError (line 306) | func TestVerifierError(t *testing.T) {
function TestSpecCopy (line 317) | func TestSpecCopy(t *testing.T) {
function TestSpecCopyModifications (line 343) | func TestSpecCopyModifications(t *testing.T) {
function TestSpecTypeByID (line 365) | func TestSpecTypeByID(t *testing.T) {
function ExampleSpec_TypeByName (line 375) | func ExampleSpec_TypeByName() {
function TestTypesIterator (line 391) | func TestTypesIterator(t *testing.T) {
function TestLoadSplitSpec (line 418) | func TestLoadSplitSpec(t *testing.T) {
function TestFixupDatasecLayout (line 481) | func TestFixupDatasecLayout(t *testing.T) {
function TestSpecConcurrentAccess (line 505) | func TestSpecConcurrentAccess(t *testing.T) {
function TestLoadEmptyRawSpec (line 538) | func TestLoadEmptyRawSpec(t *testing.T) {
function BenchmarkSpecCopy (line 555) | func BenchmarkSpecCopy(b *testing.B) {
function BenchmarkSpecTypeByID (line 563) | func BenchmarkSpecTypeByID(b *testing.B) {
function BenchmarkInspektorGadget (line 575) | func BenchmarkInspektorGadget(b *testing.B) {
FILE: btf/btf_types.go
type btfKind (line 13) | type btfKind
constant kindUnknown (line 17) | kindUnknown btfKind = iota
constant kindInt (line 18) | kindInt
constant kindPointer (line 19) | kindPointer
constant kindArray (line 20) | kindArray
constant kindStruct (line 21) | kindStruct
constant kindUnion (line 22) | kindUnion
constant kindEnum (line 23) | kindEnum
constant kindForward (line 24) | kindForward
constant kindTypedef (line 25) | kindTypedef
constant kindVolatile (line 26) | kindVolatile
constant kindConst (line 27) | kindConst
constant kindRestrict (line 28) | kindRestrict
constant kindFunc (line 30) | kindFunc
constant kindFuncProto (line 31) | kindFuncProto
constant kindVar (line 33) | kindVar
constant kindDatasec (line 34) | kindDatasec
constant kindFloat (line 36) | kindFloat
constant kindDeclTag (line 38) | kindDeclTag
constant kindTypeTag (line 40) | kindTypeTag
constant kindEnum64 (line 42) | kindEnum64
type FuncLinkage (line 46) | type FuncLinkage
constant StaticFunc (line 50) | StaticFunc FuncLinkage = iota
constant GlobalFunc (line 51) | GlobalFunc
constant ExternFunc (line 52) | ExternFunc
type VarLinkage (line 56) | type VarLinkage
constant StaticVar (line 59) | StaticVar VarLinkage = iota
constant GlobalVar (line 60) | GlobalVar
constant ExternVar (line 61) | ExternVar
constant btfTypeKindShift (line 65) | btfTypeKindShift = 24
constant btfTypeKindLen (line 66) | btfTypeKindLen = 5
constant btfTypeVlenShift (line 67) | btfTypeVlenShift = 0
constant btfTypeVlenMask (line 68) | btfTypeVlenMask = 16
constant btfTypeKindFlagShift (line 69) | btfTypeKindFlagShift = 31
constant btfTypeKindFlagMask (line 70) | btfTypeKindFlagMask = 1
type btfHeader (line 75) | type btfHeader struct
function parseBTFHeader (line 88) | func parseBTFHeader(buf []byte) (*btfHeader, binary.ByteOrder, error) {
type btfType (line 133) | type btfType struct
method info (line 181) | func (bt *btfType) info(len, shift uint32) uint32 {
method setInfo (line 185) | func (bt *btfType) setInfo(value, len, shift uint32) {
method Kind (line 189) | func (bt *btfType) Kind() btfKind {
method SetKind (line 193) | func (bt *btfType) SetKind(kind btfKind) {
method Vlen (line 197) | func (bt *btfType) Vlen() int {
method SetVlen (line 201) | func (bt *btfType) SetVlen(vlen int) {
method kindFlagBool (line 205) | func (bt *btfType) kindFlagBool() bool {
method setKindFlagBool (line 209) | func (bt *btfType) setKindFlagBool(set bool) {
method Bitfield (line 218) | func (bt *btfType) Bitfield() bool {
method SetBitfield (line 222) | func (bt *btfType) SetBitfield(isBitfield bool) {
method FwdKind (line 226) | func (bt *btfType) FwdKind() FwdKind {
method SetFwdKind (line 230) | func (bt *btfType) SetFwdKind(kind FwdKind) {
method Signed (line 234) | func (bt *btfType) Signed() bool {
method SetSigned (line 238) | func (bt *btfType) SetSigned(signed bool) {
method Linkage (line 242) | func (bt *btfType) Linkage() FuncLinkage {
method SetLinkage (line 246) | func (bt *btfType) SetLinkage(linkage FuncLinkage) {
method Type (line 250) | func (bt *btfType) Type() TypeID {
method SetType (line 255) | func (bt *btfType) SetType(id TypeID) {
method Size (line 259) | func (bt *btfType) Size() uint32 {
method SetSize (line 264) | func (bt *btfType) SetSize(size uint32) {
method Encode (line 268) | func (bt *btfType) Encode(buf []byte, bo binary.ByteOrder) (int, error) {
method DataLen (line 279) | func (bt *btfType) DataLen() (int, error) {
function unmarshalBtfType (line 156) | func unmarshalBtfType(bt *btfType, b []byte, bo binary.ByteOrder) (int, ...
function mask (line 167) | func mask(len uint32) uint32 {
function readBits (line 171) | func readBits(value, len, shift uint32) uint32 {
function writeBits (line 175) | func writeBits(value, len, shift, new uint32) uint32 {
type btfInt (line 324) | type btfInt struct
method Encoding (line 348) | func (bi btfInt) Encoding() IntEncoding {
method SetEncoding (line 352) | func (bi *btfInt) SetEncoding(e IntEncoding) {
method Offset (line 356) | func (bi btfInt) Offset() Bits {
method SetOffset (line 360) | func (bi *btfInt) SetOffset(offset uint32) {
method Bits (line 364) | func (bi btfInt) Bits() Bits {
method SetBits (line 368) | func (bi *btfInt) SetBits(bits byte) {
constant btfIntEncodingLen (line 329) | btfIntEncodingLen = 4
constant btfIntEncodingShift (line 330) | btfIntEncodingShift = 24
constant btfIntOffsetLen (line 331) | btfIntOffsetLen = 8
constant btfIntOffsetShift (line 332) | btfIntOffsetShift = 16
constant btfIntBitsLen (line 333) | btfIntBitsLen = 8
constant btfIntBitsShift (line 334) | btfIntBitsShift = 0
function unmarshalBtfInt (line 339) | func unmarshalBtfInt(bi *btfInt, b []byte, bo binary.ByteOrder) (int, er...
type btfArray (line 372) | type btfArray struct
function unmarshalBtfArray (line 380) | func unmarshalBtfArray(ba *btfArray, b []byte, bo binary.ByteOrder) (int...
type btfMember (line 391) | type btfMember struct
function unmarshalBtfMember (line 399) | func unmarshalBtfMember(bm *btfMember, b []byte, bo binary.ByteOrder) (i...
type btfVarSecinfo (line 410) | type btfVarSecinfo struct
function unmarshalBtfVarSecInfo (line 418) | func unmarshalBtfVarSecInfo(bvsi *btfVarSecinfo, b []byte, bo binary.Byt...
type btfVariable (line 429) | type btfVariable struct
function unmarshalBtfVariable (line 435) | func unmarshalBtfVariable(bv *btfVariable, b []byte, bo binary.ByteOrder...
type btfEnum (line 444) | type btfEnum struct
function unmarshalBtfEnum (line 451) | func unmarshalBtfEnum(be *btfEnum, b []byte, bo binary.ByteOrder) (int, ...
type btfEnum64 (line 461) | type btfEnum64 struct
function unmarshalBtfEnum64 (line 469) | func unmarshalBtfEnum64(enum *btfEnum64, b []byte, bo binary.ByteOrder) ...
type btfParam (line 481) | type btfParam struct
function unmarshalBtfParam (line 488) | func unmarshalBtfParam(param *btfParam, b []byte, bo binary.ByteOrder) (...
type btfDeclTag (line 499) | type btfDeclTag struct
function unmarshalBtfDeclTag (line 505) | func unmarshalBtfDeclTag(bdt *btfDeclTag, b []byte, bo binary.ByteOrder)...
FILE: btf/btf_types_string.go
function _ (line 7) | func _() {
constant _FuncLinkage_name (line 16) | _FuncLinkage_name = "staticglobalextern"
method String (line 20) | func (i FuncLinkage) String() string {
function _ (line 27) | func _() {
constant _VarLinkage_name (line 36) | _VarLinkage_name = "staticglobalextern"
method String (line 40) | func (i VarLinkage) String() string {
function _ (line 47) | func _() {
constant _btfKind_name (line 73) | _btfKind_name = "UnknownIntPointerArrayStructUnionEnumForwardTypedefVola...
method String (line 77) | func (i btfKind) String() string {
FILE: btf/core.go
constant COREBadRelocationSentinel (line 23) | COREBadRelocationSentinel = 0xbad2310
type COREFixup (line 26) | type COREFixup struct
method equal (line 38) | func (f *COREFixup) equal(other COREFixup) bool {
method String (line 42) | func (f *COREFixup) String() string {
method Apply (line 49) | func (f *COREFixup) Apply(ins *asm.Instruction) error {
method isNonExistant (line 126) | func (f COREFixup) isNonExistant() bool {
type coreKind (line 131) | type coreKind
method checksForExistence (line 149) | func (k coreKind) checksForExistence() bool {
method String (line 153) | func (k coreKind) String() string {
constant reloFieldByteOffset (line 134) | reloFieldByteOffset coreKind = iota
constant reloFieldByteSize (line 135) | reloFieldByteSize
constant reloFieldExists (line 136) | reloFieldExists
constant reloFieldSigned (line 137) | reloFieldSigned
constant reloFieldLShiftU64 (line 138) | reloFieldLShiftU64
constant reloFieldRShiftU64 (line 139) | reloFieldRShiftU64
constant reloTypeIDLocal (line 140) | reloTypeIDLocal
constant reloTypeIDTarget (line 141) | reloTypeIDTarget
constant reloTypeExists (line 142) | reloTypeExists
constant reloTypeSize (line 143) | reloTypeSize
constant reloEnumvalExists (line 144) | reloEnumvalExists
constant reloEnumvalValue (line 145) | reloEnumvalValue
constant reloTypeMatches (line 146) | reloTypeMatches
function CORERelocate (line 202) | func CORERelocate(relos []*CORERelocation, targets []*Spec, bo binary.By...
function coreCalculateFixups (line 300) | func coreCalculateFixups(relos []*CORERelocation, targets []Type, bo bin...
function coreCalculateFixup (line 359) | func coreCalculateFixup(relo *CORERelocation, target Type, bo binary.Byt...
function boolToUint64 (line 547) | func boolToUint64(val bool) uint64 {
type coreAccessor (line 582) | type coreAccessor
method String (line 604) | func (ca coreAccessor) String() string {
method enumValue (line 612) | func (ca coreAccessor) enumValue(t Type) (*EnumValue, error) {
function parseCOREAccessor (line 584) | func parseCOREAccessor(accessor string) (coreAccessor, error) {
type coreField (line 636) | type coreField struct
method adjustOffsetToNthElement (line 651) | func (cf *coreField) adjustOffsetToNthElement(n int) error {
method adjustOffsetBits (line 665) | func (cf *coreField) adjustOffsetBits(offset Bits) error {
method sizeBits (line 688) | func (cf *coreField) sizeBits() (Bits, error) {
function coreFindField (line 708) | func coreFindField(localT Type, localAcc coreAccessor, targetT Type) (co...
function coreFindMember (line 852) | func coreFindMember(typ composite, name string) (Member, bool, error) {
function coreFindEnumValue (line 906) | func coreFindEnumValue(local Type, localAcc coreAccessor, target Type) (...
function CheckTypeCompatibility (line 932) | func CheckTypeCompatibility(localType Type, targetType Type) error {
type pair (line 936) | type pair struct
function coreAreTypesCompatible (line 963) | func coreAreTypesCompatible(localType Type, targetType Type, visited map...
function coreAreMembersCompatible (line 1044) | func coreAreMembersCompatible(localType Type, targetType Type) error {
function coreEssentialNamesMatch (line 1087) | func coreEssentialNamesMatch(a, b string) bool {
function coreTypesMatch (line 1125) | func coreTypesMatch(localType Type, targetType Type, visited map[pair]st...
function coreEncodingMatches (line 1234) | func coreEncodingMatches(local, target *Int) bool {
function coreEnumsMatch (line 1241) | func coreEnumsMatch(local *Enum, target *Enum) error {
FILE: btf/core_reloc_test.go
function TestCORERelocationLoad (line 19) | func TestCORERelocationLoad(t *testing.T) {
function TestCORERelocationRead (line 70) | func TestCORERelocationRead(t *testing.T) {
function TestLD64IMMReloc (line 125) | func TestLD64IMMReloc(t *testing.T) {
function TestCOREPoisonLineInfo (line 148) | func TestCOREPoisonLineInfo(t *testing.T) {
FILE: btf/core_test.go
function TestCheckTypeCompatibility (line 19) | func TestCheckTypeCompatibility(t *testing.T) {
function TestCOREAreMembersCompatible (line 91) | func TestCOREAreMembersCompatible(t *testing.T) {
function TestCOREAccessor (line 148) | func TestCOREAccessor(t *testing.T) {
function TestCOREFindEnumValue (line 175) | func TestCOREFindEnumValue(t *testing.T) {
function TestCOREFindField (line 233) | func TestCOREFindField(t *testing.T) {
function TestCOREFindFieldCyclical (line 500) | func TestCOREFindFieldCyclical(t *testing.T) {
function TestCORERelocation (line 531) | func TestCORERelocation(t *testing.T) {
function TestCOREReloFieldSigned (line 585) | func TestCOREReloFieldSigned(t *testing.T) {
function TestCOREReloFieldShiftU64 (line 606) | func TestCOREReloFieldShiftU64(t *testing.T) {
function TestCORERelosKmodTypeID (line 624) | func TestCORERelosKmodTypeID(t *testing.T) {
function BenchmarkCORESkBuff (line 659) | func BenchmarkCORESkBuff(b *testing.B) {
function TestCORETypesMatch (line 708) | func TestCORETypesMatch(t *testing.T) {
function dummyTypeID (line 933) | func dummyTypeID(Type) (TypeID, error) {
FILE: btf/dedup.go
type deduper (line 20) | type deduper struct
method deduplicate (line 45) | func (d *deduper) deduplicate(t Type) (Type, error) {
method hashInsert (line 71) | func (d *deduper) hashInsert(t Type) (Type, error) {
method hash (line 121) | func (d *deduper) hash(t Type, depthBudget int) (uint64, error) {
method typesEquivalent (line 358) | func (d *deduper) typesEquivalent(ta, tb Type, visited []Type) error {
method compositeEquivalent (line 594) | func (d *deduper) compositeEquivalent(at, bt Type, visited []Type) err...
function newDeduper (line 34) | func newDeduper() *deduper {
type hashCacheKey (line 112) | type hashCacheKey struct
type typKey (line 350) | type typKey struct
FILE: btf/dedup_test.go
function countTypes (line 9) | func countTypes(typs ...Type) int {
function TestDedupSKBuff (line 20) | func TestDedupSKBuff(t *testing.T) {
function TestDedupVmlinux (line 46) | func TestDedupVmlinux(t *testing.T) {
function BenchmarkDeduplicateSKBuff (line 88) | func BenchmarkDeduplicateSKBuff(b *testing.B) {
function BenchmarkDeduplicateVMLinux (line 116) | func BenchmarkDeduplicateVMLinux(b *testing.B) {
FILE: btf/ext_info.go
type ExtInfos (line 18) | type ExtInfos struct
method Section (line 27) | func (ei *ExtInfos) Section(name string) (FuncOffsets, LineOffsets, CO...
function loadExtInfosFromELF (line 38) | func loadExtInfosFromELF(file *internal.SafeELFFile, spec *Spec) (*ExtIn...
function loadExtInfos (line 52) | func loadExtInfos(r io.ReaderAt, bo binary.ByteOrder, spec *Spec) (*ExtI...
function MarshalExtInfos (line 121) | func MarshalExtInfos(insns asm.Instructions, b *Builder) (funcInfos, lin...
type btfExtHeader (line 172) | type btfExtHeader struct
method funcInfoStart (line 215) | func (h *btfExtHeader) funcInfoStart() int64 {
method lineInfoStart (line 221) | func (h *btfExtHeader) lineInfoStart() int64 {
method coreReloStart (line 227) | func (h *btfExtHeader) coreReloStart(ch *btfExtCOREHeader) int64 {
function parseBTFExtHeader (line 188) | func parseBTFExtHeader(r io.Reader, bo binary.ByteOrder) (*btfExtHeader,...
type btfExtCOREHeader (line 233) | type btfExtCOREHeader struct
function parseBTFExtCOREHeader (line 241) | func parseBTFExtCOREHeader(r io.Reader, bo binary.ByteOrder, extHeader *...
type btfExtInfoSec (line 257) | type btfExtInfoSec struct
function parseExtInfoSec (line 266) | func parseExtInfoSec(r io.Reader, bo binary.ByteOrder, strings *stringTa...
function parseExtInfoRecordSize (line 290) | func parseExtInfoRecordSize(r io.Reader, bo binary.ByteOrder) (uint32, e...
type FuncOffset (line 317) | type FuncOffset struct
method marshal (line 385) | func (fi *FuncOffset) marshal(w *bytes.Buffer, b *Builder) error {
type bpfFuncInfo (line 322) | type bpfFuncInfo struct
function newFuncOffset (line 328) | func newFuncOffset(fi bpfFuncInfo, spec *Spec) (*FuncOffset, error) {
function newFuncOffsets (line 350) | func newFuncOffsets(bfis []bpfFuncInfo, spec *Spec) (FuncOffsets, error) {
function LoadFuncInfos (line 369) | func LoadFuncInfos(reader io.Reader, bo binary.ByteOrder, recordNum uint...
function parseFuncInfos (line 403) | func parseFuncInfos(r io.Reader, bo binary.ByteOrder, strings *stringTab...
function parseFuncInfoRecords (line 431) | func parseFuncInfoRecords(r io.Reader, bo binary.ByteOrder, recordSize u...
type Line (line 465) | type Line struct
method FileName (line 472) | func (li *Line) FileName() string {
method Line (line 476) | func (li *Line) Line() string {
method LineNumber (line 480) | func (li *Line) LineNumber() uint32 {
method LineColumn (line 484) | func (li *Line) LineColumn() uint32 {
method String (line 488) | func (li *Line) String() string {
type LineOffset (line 496) | type LineOffset struct
method marshal (line 573) | func (li *LineOffset) marshal(w *bytes.Buffer, b *Builder) error {
constant bpfLineShift (line 503) | bpfLineShift = 10
constant bpfLineMax (line 504) | bpfLineMax = (1 << (32 - bpfLineShift)) - 1
constant bpfColumnMax (line 505) | bpfColumnMax = (1 << bpfLineShift) - 1
type bpfLineInfo (line 508) | type bpfLineInfo struct
function LoadLineInfos (line 517) | func LoadLineInfos(reader io.Reader, bo binary.ByteOrder, recordNum uint...
function newLineInfo (line 532) | func newLineInfo(li bpfLineInfo, strings *stringTable) (LineOffset, erro...
function newLineInfos (line 557) | func newLineInfos(blis []bpfLineInfo, strings *stringTable) (LineOffsets...
function parseLineInfos (line 611) | func parseLineInfos(r io.Reader, bo binary.ByteOrder, strings *stringTab...
function parseLineInfoRecords (line 639) | func parseLineInfoRecords(r io.Reader, bo binary.ByteOrder, recordSize u...
type bpfCORERelo (line 667) | type bpfCORERelo struct
type CORERelocation (line 674) | type CORERelocation struct
method String (line 683) | func (cr *CORERelocation) String() string {
type coreRelocationMeta (line 687) | type coreRelocationMeta struct
function CORERelocationMetadata (line 690) | func CORERelocationMetadata(ins *asm.Instruction) *CORERelocation {
function WithCORERelocationMetadata (line 697) | func WithCORERelocationMetadata(ins asm.Instruction, relo *CORERelocatio...
type CORERelocationOffset (line 707) | type CORERelocationOffset struct
function newRelocationInfo (line 712) | func newRelocationInfo(relo bpfCORERelo, spec *Spec, strings *stringTabl...
function newRelocationInfos (line 739) | func newRelocationInfos(brs []bpfCORERelo, spec *Spec, strings *stringTa...
function parseCORERelos (line 761) | func parseCORERelos(r io.Reader, bo binary.ByteOrder, strings *stringTab...
function parseCOREReloRecords (line 793) | func parseCOREReloRecords(r io.Reader, bo binary.ByteOrder, recordNum ui...
FILE: btf/ext_info_test.go
function TestParseExtInfoBigRecordSize (line 14) | func TestParseExtInfoBigRecordSize(t *testing.T) {
function BenchmarkParseLineInfoRecords (line 30) | func BenchmarkParseLineInfoRecords(b *testing.B) {
function TestParseLineInfoRecordsAllocations (line 42) | func TestParseLineInfoRecordsAllocations(t *testing.T) {
FILE: btf/feature.go
function probeBTF (line 137) | func probeBTF(typ Type) error {
FILE: btf/feature_test.go
function TestHaveBTF (line 9) | func TestHaveBTF(t *testing.T) {
function TestHaveMapBTF (line 13) | func TestHaveMapBTF(t *testing.T) {
function TestHaveProgBTF (line 17) | func TestHaveProgBTF(t *testing.T) {
function TestHaveFuncLinkage (line 21) | func TestHaveFuncLinkage(t *testing.T) {
function TestHaveDeclTags (line 25) | func TestHaveDeclTags(t *testing.T) {
function TestHaveTypeTags (line 29) | func TestHaveTypeTags(t *testing.T) {
function TestHaveEnum64 (line 33) | func TestHaveEnum64(t *testing.T) {
FILE: btf/format.go
type GoFormatter (line 14) | type GoFormatter struct
method TypeDeclaration (line 31) | func (gf *GoFormatter) TypeDeclaration(name string, typ Type) (string,...
method identifier (line 39) | func (gf *GoFormatter) identifier(s string) string {
method enumIdentifier (line 47) | func (gf *GoFormatter) enumIdentifier(name, element string) string {
method writeTypeDecl (line 61) | func (gf *GoFormatter) writeTypeDecl(name string, typ Type) error {
method writeType (line 99) | func (gf *GoFormatter) writeType(typ Type, depth int) error {
method writeTypeLit (line 119) | func (gf *GoFormatter) writeTypeLit(typ Type, depth int) error {
method writeIntLit (line 178) | func (gf *GoFormatter) writeIntLit(i *Int) error {
method writeStructLit (line 210) | func (gf *GoFormatter) writeStructLit(size uint32, members []Member, d...
method writeStructField (line 248) | func (gf *GoFormatter) writeStructField(m Member, depth int) error {
method writeDatasecLit (line 300) | func (gf *GoFormatter) writeDatasecLit(ds *Datasec, depth int) error {
method writePadding (line 336) | func (gf *GoFormatter) writePadding(bytes uint32) {
function skipQualifiers (line 342) | func skipQualifiers(typ Type) Type {
FILE: btf/format_test.go
function TestGoTypeDeclaration (line 12) | func TestGoTypeDeclaration(t *testing.T) {
function TestGoTypeDeclarationNamed (line 153) | func TestGoTypeDeclarationNamed(t *testing.T) {
function TestGoTypeDeclarationQualifiers (line 201) | func TestGoTypeDeclarationQualifiers(t *testing.T) {
function TestGoTypeDeclarationCycle (line 223) | func TestGoTypeDeclarationCycle(t *testing.T) {
function TestRejectBogusTypes (line 234) | func TestRejectBogusTypes(t *testing.T) {
function mustGoTypeDeclaration (line 260) | func mustGoTypeDeclaration(tb testing.TB, typ Type, names map[Type]strin...
FILE: btf/fuzz_test.go
function FuzzSpec (line 15) | func FuzzSpec(f *testing.F) {
function FuzzExtInfo (line 43) | func FuzzExtInfo(f *testing.F) {
function mustBTFHeader (line 70) | func mustBTFHeader(f *testing.F) []byte {
FILE: btf/handle.go
type Handle (line 16) | type Handle struct
method Spec (line 141) | func (h *Handle) Spec(base *Spec) (*Spec, error) {
method Close (line 161) | func (h *Handle) Close() error {
method FD (line 170) | func (h *Handle) FD() int {
method Info (line 175) | func (h *Handle) Info() (*HandleInfo, error) {
function NewHandle (line 28) | func NewHandle(b *Builder) (*Handle, error) {
function NewHandleFromRawBTF (line 43) | func NewHandleFromRawBTF(btf []byte) (*Handle, error) {
function NewHandleFromID (line 116) | func NewHandleFromID(id ID) (*Handle, error) {
type HandleInfo (line 180) | type HandleInfo struct
method IsVmlinux (line 231) | func (i *HandleInfo) IsVmlinux() bool {
method IsModule (line 236) | func (i *HandleInfo) IsModule() bool {
function newHandleInfoFromFD (line 197) | func newHandleInfoFromFD(fd *sys.FD) (*HandleInfo, error) {
type HandleIterator (line 241) | type HandleIterator struct
method Next (line 254) | func (it *HandleIterator) Next() bool {
method Take (line 296) | func (it *HandleIterator) Take() *Handle {
method Err (line 303) | func (it *HandleIterator) Err() error {
function FindHandle (line 313) | func FindHandle(predicate func(info *HandleInfo) bool) (*Handle, error) {
FILE: btf/handle_test.go
function TestHandleIterator (line 11) | func TestHandleIterator(t *testing.T) {
function TestParseModuleSplitSpec (line 50) | func TestParseModuleSplitSpec(t *testing.T) {
function ExampleHandleIterator (line 86) | func ExampleHandleIterator() {
FILE: btf/kernel.go
function FlushKernelSpec (line 29) | func FlushKernelSpec() {
function LoadKernelSpec (line 43) | func LoadKernelSpec() (*Spec, error) {
function loadCachedKernelSpec (line 51) | func loadCachedKernelSpec() (*Spec, error) {
function LoadKernelModuleSpec (line 84) | func LoadKernelModuleSpec(module string) (*Spec, error) {
function loadCachedKernelModuleSpec (line 92) | func loadCachedKernelModuleSpec(module string) (*Spec, error) {
function loadKernelSpec (line 125) | func loadKernelSpec() (*Spec, error) {
function loadKernelModuleSpec (line 171) | func loadKernelModuleSpec(module string, base *Spec) (*Spec, error) {
function findVMLinux (line 191) | func findVMLinux() (*os.File, error) {
type Cache (line 227) | type Cache struct
method Kernel (line 264) | func (c *Cache) Kernel() (*Spec, error) {
method Module (line 278) | func (c *Cache) Module(name string) (*Spec, error) {
method Modules (line 310) | func (c *Cache) Modules() ([]string, error) {
function NewCache (line 236) | func NewCache() *Cache {
FILE: btf/kernel_test.go
function TestLoadKernelSpec (line 13) | func TestLoadKernelSpec(t *testing.T) {
function TestLoadKernelModuleSpec (line 33) | func TestLoadKernelModuleSpec(t *testing.T) {
function TestCache (line 42) | func TestCache(t *testing.T) {
FILE: btf/marshal.go
type MarshalOptions (line 16) | type MarshalOptions struct
function KernelMarshalOptions (line 32) | func KernelMarshalOptions() *MarshalOptions {
type encoder (line 44) | type encoder struct
method allocateIDs (line 283) | func (e *encoder) allocateIDs(root Type) error {
method id (line 307) | func (e *encoder) id(typ Type) TypeID {
method deflatePending (line 320) | func (e *encoder) deflatePending(buf []byte) ([]byte, error) {
method deflateType (line 343) | func (e *encoder) deflateType(buf []byte, typ Type) (_ []byte, err err...
method deflateInt (line 467) | func (e *encoder) deflateInt(buf []byte, raw *btfType, i *Int) ([]byte...
method deflateDeclTag (line 479) | func (e *encoder) deflateDeclTag(buf []byte, raw *btfType, tag *declTa...
method deflateConst (line 506) | func (e *encoder) deflateConst(raw *btfType, c *Const) {
method deflateTypeTag (line 511) | func (e *encoder) deflateTypeTag(raw *btfType, tag *TypeTag) (err erro...
method deflateUnion (line 525) | func (e *encoder) deflateUnion(buf []byte, raw *btfType, union *Union)...
method deflateMembers (line 531) | func (e *encoder) deflateMembers(buf []byte, header *btfType, members ...
method deflateEnum (line 566) | func (e *encoder) deflateEnum(buf []byte, raw *btfType, enum *Enum) ([...
method deflateEnumValues (line 575) | func (e *encoder) deflateEnumValues(buf []byte, enum *Enum) ([]byte, e...
method deflateEnum64 (line 608) | func (e *encoder) deflateEnum64(buf []byte, raw *btfType, enum *Enum) ...
method deflateEnum64Values (line 642) | func (e *encoder) deflateEnum64Values(buf []byte, values []EnumValue) ...
method deflateFuncParams (line 666) | func (e *encoder) deflateFuncParams(buf []byte, params []FuncParam) ([...
method deflateVarSecinfos (line 688) | func (e *encoder) deflateVarSecinfos(buf []byte, vars []VarSecinfo) ([...
function getByteSlice (line 61) | func getByteSlice() *[]byte {
function putByteSlice (line 65) | func putByteSlice(buf *[]byte) {
type Builder (line 74) | type Builder struct
method Empty (line 122) | func (b *Builder) Empty() bool {
method Add (line 131) | func (b *Builder) Add(typ Type) (TypeID, error) {
method Spec (line 179) | func (b *Builder) Spec() (*Spec, error) {
method Marshal (line 191) | func (b *Builder) Marshal(buf []byte, opts *MarshalOptions) ([]byte, e...
method addString (line 275) | func (b *Builder) addString(str string) (uint32, error) {
type BuilderOptions (line 85) | type BuilderOptions struct
function NewBuilder (line 95) | func NewBuilder(types []Type, opts *BuilderOptions) (*Builder, error) {
function MarshalMapKV (line 711) | func MarshalMapKV(key, value Type) (_ *Handle, keyID, valueID TypeID, er...
FILE: btf/marshal_test.go
function TestBuilderMarshal (line 14) | func TestBuilderMarshal(t *testing.T) {
function TestBuilderAdd (line 41) | func TestBuilderAdd(t *testing.T) {
function TestBuilderSpec (line 79) | func TestBuilderSpec(t *testing.T) {
function TestRoundtripVMlinux (line 95) | func TestRoundtripVMlinux(t *testing.T) {
function TestMarshalEnum64 (line 136) | func TestMarshalEnum64(t *testing.T) {
function TestMarshalDeclTags (line 173) | func TestMarshalDeclTags(t *testing.T) {
function TestMarshalTypeTags (line 200) | func TestMarshalTypeTags(t *testing.T) {
function BenchmarkMarshaler (line 233) | func BenchmarkMarshaler(b *testing.B) {
function BenchmarkBuildVmlinux (line 247) | func BenchmarkBuildVmlinux(b *testing.B) {
function marshalNativeEndian (line 261) | func marshalNativeEndian(tb testing.TB, types []Type) []byte {
function specFromTypes (line 271) | func specFromTypes(tb testing.TB, types []Type) *Spec {
function typesFromSpec (line 281) | func typesFromSpec(tb testing.TB, spec *Spec) []Type {
FILE: btf/strings.go
type stringTable (line 16) | type stringTable struct
method Lookup (line 60) | func (st *stringTable) Lookup(offset uint32) (string, error) {
method LookupBytes (line 70) | func (st *stringTable) LookupBytes(offset uint32) ([]byte, error) {
method lookupSlow (line 79) | func (st *stringTable) lookupSlow(offset uint32) ([]byte, error) {
method LookupCached (line 102) | func (cst *stringTable) LookupCached(offset uint32) (string, error) {
type sizedReader (line 25) | type sizedReader interface
function readStringTable (line 30) | func readStringTable(r sizedReader, base *stringTable) (*stringTable, er...
function newStringTable (line 39) | func newStringTable(bytes []byte, base *stringTable) (*stringTable, erro...
type stringTableBuilder (line 128) | type stringTableBuilder struct
method Add (line 154) | func (stb *stringTableBuilder) Add(str string) (uint32, error) {
method append (line 167) | func (stb *stringTableBuilder) append(str string) uint32 {
method Lookup (line 177) | func (stb *stringTableBuilder) Lookup(str string) (uint32, error) {
method Length (line 187) | func (stb *stringTableBuilder) Length() int {
method AppendEncoded (line 192) | func (stb *stringTableBuilder) AppendEncoded(buf []byte) []byte {
method Copy (line 203) | func (stb *stringTableBuilder) Copy() *stringTableBuilder {
function newStringTableBuilder (line 136) | func newStringTableBuilder(capacity int) *stringTableBuilder {
FILE: btf/strings_test.go
function TestStringTable (line 11) | func TestStringTable(t *testing.T) {
function TestEmptyStringTable (line 65) | func TestEmptyStringTable(t *testing.T) {
function TestStringTableBuilder (line 75) | func TestStringTableBuilder(t *testing.T) {
function BenchmarkStringTableZeroLookup (line 101) | func BenchmarkStringTableZeroLookup(b *testing.B) {
FILE: btf/testdata/bpf_core_read.h
type bpf_field_info_kind (line 13) | enum bpf_field_info_kind {
type bpf_type_id_kind (line 23) | enum bpf_type_id_kind {
type bpf_type_info_kind (line 29) | enum bpf_type_info_kind {
type bpf_enum_value_kind (line 36) | enum bpf_enum_value_kind {
FILE: btf/testdata/relocs.c
type e (line 4) | enum e {
type e64 (line 10) | enum e64 {
type e_t (line 14) | typedef enum e e_t;
type s (line 16) | struct s {
type s_t (line 22) | typedef struct s s_t;
type u_t (line 30) | typedef union u u_t;
function type_ids (line 46) | int type_ids() {
function types (line 107) | int types() {
function enums (line 165) | int enums() {
function fields (line 218) | int fields() {
type ambiguous (line 275) | struct ambiguous {
type ambiguous___flavour (line 280) | struct ambiguous___flavour {
function err_ambiguous (line 285) | int err_ambiguous() {
function err_ambiguous_flavour (line 289) | int err_ambiguous_flavour() {
FILE: btf/testdata/relocs_enum.c
type cgroup_subsys_id (line 3) | enum cgroup_subsys_id {
function core_ld64imm (line 11) | int core_ld64imm() {
FILE: btf/testdata/relocs_read.c
type s (line 7) | struct s {
type u8 (line 12) | typedef unsigned char u8;
type u16 (line 13) | typedef unsigned short u16;
type u32 (line 14) | typedef unsigned int u32;
type u64 (line 15) | typedef unsigned long u64;
type bits (line 18) | struct bits {
type nonexist (line 27) | struct nonexist {
type nonexist_enum (line 31) | enum nonexist_enum { NON_EXIST = 1 }
function read_subprog (line 35) | __attribute__((noinline)) int read_subprog() {
function reads (line 108) | int reads() {
FILE: btf/testdata/relocs_read_tgt.c
type s (line 7) | struct s {
type s (line 12) | struct s
type my_u32 (line 14) | typedef unsigned int my_u32;
type u8 (line 15) | typedef unsigned char u8;
type u16 (line 16) | typedef unsigned short u16;
type u32 (line 17) | typedef unsigned int u32;
type u64 (line 18) | typedef unsigned long u64;
type bits (line 20) | struct bits {
type bits (line 30) | struct bits
FILE: btf/testdata/tags.c
type s (line 9) | struct s {
type tagB (line 19) | typedef tagB char td;
type s (line 21) | struct s
function normalDecl1 (line 27) | int tagE normalDecl1(char tagB x, char tagC y) {
function normalDecl2 (line 31) | int tagE normalDecl2(char tagB x, char tagC y) {
function prog (line 35) | int prog(char *ctx) {
FILE: btf/traversal.go
function postorder (line 12) | func postorder(root Type, visited map[Type]struct{}) iter.Seq[Type] {
function visitInPostorder (line 20) | func visitInPostorder(root Type, visited map[Type]struct{}, yield func(t...
function children (line 39) | func children(typ Type) iter.Seq[*Type] {
FILE: btf/traversal_test.go
function TestPostorderTraversal (line 10) | func TestPostorderTraversal(t *testing.T) {
function TestPostorderTraversalVmlinux (line 35) | func TestPostorderTraversalVmlinux(t *testing.T) {
function TestChildren (line 65) | func TestChildren(t *testing.T) {
function BenchmarkPostorderTraversal (line 88) | func BenchmarkPostorderTraversal(b *testing.B) {
FILE: btf/types.go
constant maxResolveDepth (line 17) | maxResolveDepth = 32
type Type (line 44) | type Type interface
type Void (line 83) | type Void struct
method Format (line 85) | func (v *Void) Format(fs fmt.State, verb rune) { formatType(fs, verb, ...
method TypeName (line 86) | func (v *Void) TypeName() string { return "" }
method size (line 87) | func (v *Void) size() uint32 { return 0 }
method copy (line 88) | func (v *Void) copy() Type { return (*Void)(nil) }
type IntEncoding (line 90) | type IntEncoding
method String (line 102) | func (ie IntEncoding) String() string {
constant Unsigned (line 96) | Unsigned IntEncoding = 0
constant Signed (line 97) | Signed IntEncoding = 1
constant Char (line 98) | Char IntEncoding = 2
constant Bool (line 99) | Bool IntEncoding = 4
type Int (line 121) | type Int struct
method Format (line 129) | func (i *Int) Format(fs fmt.State, verb rune) {
method TypeName (line 133) | func (i *Int) TypeName() string { return i.Name }
method size (line 134) | func (i *Int) size() uint32 { return i.Size }
method copy (line 135) | func (i *Int) copy() Type {
type Pointer (line 141) | type Pointer struct
method Format (line 145) | func (p *Pointer) Format(fs fmt.State, verb rune) {
method TypeName (line 149) | func (p *Pointer) TypeName() string { return "" }
method size (line 150) | func (p *Pointer) size() uint32 { return 8 }
method copy (line 151) | func (p *Pointer) copy() Type {
type Array (line 157) | type Array struct
method Format (line 163) | func (arr *Array) Format(fs fmt.State, verb rune) {
method TypeName (line 167) | func (arr *Array) TypeName() string { return "" }
method copy (line 169) | func (arr *Array) copy() Type {
type Struct (line 175) | type Struct struct
method Format (line 189) | func (s *Struct) Format(fs fmt.State, verb rune) {
method TypeName (line 194) | func (s *Struct) TypeName() string { return s.Name }
method size (line 196) | func (s *Struct) size() uint32 { return s.Size }
method copy (line 198) | func (s *Struct) copy() Type {
method members (line 205) | func (s *Struct) members() []Member {
type Union (line 210) | type Union struct
method Format (line 224) | func (u *Union) Format(fs fmt.State, verb rune) {
method TypeName (line 229) | func (u *Union) TypeName() string { return u.Name }
method size (line 231) | func (u *Union) size() uint32 { return u.Size }
method copy (line 233) | func (u *Union) copy() Type {
method members (line 240) | func (u *Union) members() []Member {
function memberNames (line 248) | func memberNames(members []Member, max int) []string {
function copyMembers (line 267) | func copyMembers(orig []Member) []Member {
function copyTags (line 276) | func copyTags(orig []string) []string {
type composite (line 285) | type composite interface
type Bits (line 296) | type Bits
method Bytes (line 299) | func (b Bits) Bytes() uint32 {
type Member (line 306) | type Member struct
type Enum (line 315) | type Enum struct
method Format (line 324) | func (e *Enum) Format(fs fmt.State, verb rune) {
method TypeName (line 328) | func (e *Enum) TypeName() string { return e.Name }
method size (line 338) | func (e *Enum) size() uint32 { return e.Size }
method copy (line 339) | func (e *Enum) copy() Type {
type EnumValue (line 333) | type EnumValue struct
type FwdKind (line 347) | type FwdKind
method String (line 355) | func (fk FwdKind) String() string {
constant FwdStruct (line 351) | FwdStruct FwdKind = iota
constant FwdUnion (line 352) | FwdUnion
type Fwd (line 367) | type Fwd struct
method Format (line 372) | func (f *Fwd) Format(fs fmt.State, verb rune) {
method TypeName (line 376) | func (f *Fwd) TypeName() string { return f.Name }
method copy (line 378) | func (f *Fwd) copy() Type {
method matches (line 383) | func (f *Fwd) matches(typ Type) bool {
type Typedef (line 396) | type Typedef struct
method Format (line 402) | func (td *Typedef) Format(fs fmt.State, verb rune) {
method TypeName (line 406) | func (td *Typedef) TypeName() string { return td.Name }
method copy (line 408) | func (td *Typedef) copy() Type {
type Volatile (line 415) | type Volatile struct
method Format (line 419) | func (v *Volatile) Format(fs fmt.State, verb rune) {
method TypeName (line 423) | func (v *Volatile) TypeName() string { return "" }
method qualify (line 425) | func (v *Volatile) qualify() Type { return v.Type }
method copy (line 426) | func (v *Volatile) copy() Type {
type Const (line 432) | type Const struct
method Format (line 436) | func (c *Const) Format(fs fmt.State, verb rune) {
method TypeName (line 440) | func (c *Const) TypeName() string { return "" }
method qualify (line 442) | func (c *Const) qualify() Type { return c.Type }
method copy (line 443) | func (c *Const) copy() Type {
type Restrict (line 449) | type Restrict struct
method Format (line 453) | func (r *Restrict) Format(fs fmt.State, verb rune) {
method TypeName (line 457) | func (r *Restrict) TypeName() string { return "" }
method qualify (line 459) | func (r *Restrict) qualify() Type { return r.Type }
method copy (line 460) | func (r *Restrict) copy() Type {
type Func (line 466) | type Func struct
method Format (line 491) | func (f *Func) Format(fs fmt.State, verb rune) {
method TypeName (line 495) | func (f *Func) TypeName() string { return f.Name }
method copy (line 497) | func (f *Func) copy() Type {
type funcInfoMeta (line 478) | type funcInfoMeta struct
function FuncMetadata (line 480) | func FuncMetadata(ins *asm.Instruction) *Func {
function WithFuncMetadata (line 486) | func WithFuncMetadata(ins asm.Instruction, fn *Func) asm.Instruction {
type FuncProto (line 511) | type FuncProto struct
method Format (line 516) | func (fp *FuncProto) Format(fs fmt.State, verb rune) {
method TypeName (line 520) | func (fp *FuncProto) TypeName() string { return "" }
method copy (line 522) | func (fp *FuncProto) copy() Type {
type FuncParam (line 529) | type FuncParam struct
type Var (line 535) | type Var struct
method Format (line 542) | func (v *Var) Format(fs fmt.State, verb rune) {
method TypeName (line 546) | func (v *Var) TypeName() string { return v.Name }
method copy (line 548) | func (v *Var) copy() Type {
type Datasec (line 555) | type Datasec struct
method Format (line 561) | func (ds *Datasec) Format(fs fmt.State, verb rune) {
method TypeName (line 565) | func (ds *Datasec) TypeName() string { return ds.Name }
method size (line 567) | func (ds *Datasec) size() uint32 { return ds.Size }
method copy (line 569) | func (ds *Datasec) copy() Type {
type VarSecinfo (line 579) | type VarSecinfo struct
type Float (line 587) | type Float struct
method Format (line 594) | func (f *Float) Format(fs fmt.State, verb rune) {
method TypeName (line 598) | func (f *Float) TypeName() string { return f.Name }
method size (line 599) | func (f *Float) size() uint32 { return f.Size }
method copy (line 600) | func (f *Float) copy() Type {
type declTag (line 606) | type declTag struct
method Format (line 615) | func (dt *declTag) Format(fs fmt.State, verb rune) {
method TypeName (line 619) | func (dt *declTag) TypeName() string { return "" }
method copy (line 620) | func (dt *declTag) copy() Type {
type TypeTag (line 632) | type TypeTag struct
method Format (line 637) | func (tt *TypeTag) Format(fs fmt.State, verb rune) {
method TypeName (line 641) | func (tt *TypeTag) TypeName() string { return "" }
method qualify (line 642) | func (tt *TypeTag) qualify() Type { return tt.Type }
method copy (line 643) | func (tt *TypeTag) copy() Type {
type cycle (line 649) | type cycle struct
method ID (line 653) | func (c *cycle) ID() TypeID { return math.MaxUint32 }
method Format (line 654) | func (c *cycle) Format(fs fmt.State, verb rune) { formatType(fs, verb,...
method TypeName (line 655) | func (c *cycle) TypeName() string { return "" }
method copy (line 656) | func (c *cycle) copy() Type {
type sizer (line 661) | type sizer interface
type qualifier (line 674) | type qualifier interface
function Sizeof (line 690) | func Sizeof(typ Type) (int, error) {
function alignof (line 744) | func alignof(typ Type) (int, error) {
function Copy (line 768) | func Copy(typ Type) Type {
function copyType (line 772) | func copyType(typ Type, ids map[Type]TypeID, copies map[Type]Type, copie...
type essentialName (line 801) | type essentialName
function newEssentialName (line 809) | func newEssentialName(name string) essentialName {
function UnderlyingType (line 821) | func UnderlyingType(typ Type) Type {
function QualifiedType (line 837) | func QualifiedType(typ Type) Type {
function As (line 855) | func As[T Type](typ Type) (T, bool) {
type formatState (line 876) | type formatState struct
type formattableType (line 882) | type formattableType interface
function formatType (line 892) | func formatType(f fmt.State, verb rune, t formattableType, extra ...inte...
FILE: btf/types_test.go
function TestSizeof (line 15) | func TestSizeof(t *testing.T) {
function TestCopy (line 41) | func TestCopy(t *testing.T) {
function TestAs (line 75) | func TestAs(t *testing.T) {
function BenchmarkCopy (line 110) | func BenchmarkCopy(b *testing.B) {
function ExampleType_validTypes (line 124) | func ExampleType_validTypes() {
function TestType (line 144) | func TestType(t *testing.T) {
function TestTagMarshaling (line 220) | func TestTagMarshaling(t *testing.T) {
function countChildren (line 247) | func countChildren(t *testing.T, typ reflect.Type) int {
type testFormattableType (line 267) | type testFormattableType struct
method TypeName (line 274) | func (tft *testFormattableType) TypeName() string { return tft.name }
method Format (line 275) | func (tft *testFormattableType) Format(fs fmt.State, verb rune) {
function TestFormatType (line 279) | func TestFormatType(t *testing.T) {
function TestFormatCompoundTypes (line 326) | func TestFormatCompoundTypes(t *testing.T) {
function newCyclicalType (line 343) | func newCyclicalType(n int) Type {
function TestUnderlyingType (line 369) | func TestUnderlyingType(t *testing.T) {
function TestInflateLegacyBitfield (line 401) | func TestInflateLegacyBitfield(t *testing.T) {
function TestMemberNames (line 488) | func TestMemberNames(t *testing.T) {
function BenchmarkWalk (line 498) | func BenchmarkWalk(b *testing.B) {
function TestTagUnmarshaling (line 532) | func TestTagUnmarshaling(t *testing.T) {
function BenchmarkUnderlyingType (line 590) | func BenchmarkUnderlyingType(b *testing.B) {
function ExampleAs (line 611) | func ExampleAs() {
FILE: btf/unmarshal.go
type sharedBuf (line 21) | type sharedBuf struct
type decoder (line 25) | type decoder struct
method Copy (line 203) | func (d *decoder) Copy() *decoder {
method copy (line 211) | func (d *decoder) copy(copiedTypes map[Type]Type) *decoder {
method TypeID (line 246) | func (d *decoder) TypeID(typ Type) (TypeID, error) {
method TypesByName (line 266) | func (d *decoder) TypesByName(name essentialName) ([]Type, error) {
method TypeByID (line 290) | func (d *decoder) TypeByID(id TypeID) (Type, error) {
method inflateType (line 297) | func (d *decoder) inflateType(id TypeID) (typ Type, err error) {
function newDecoder (line 48) | func newDecoder(raw []byte, bo binary.ByteOrder, strings *stringTable, b...
function allBtfTypeOffsets (line 146) | func allBtfTypeOffsets(buf []byte, bo binary.ByteOrder, header *btfType)...
function rebaseDecoder (line 177) | func rebaseDecoder(d *decoder, base *decoder) (*decoder, error) {
type fuzzyStringIndex (line 724) | type fuzzyStringIndex struct
method Add (line 739) | func (idx *fuzzyStringIndex) Add(name []byte, id TypeID) {
method Build (line 747) | func (idx *fuzzyStringIndex) Build() {
method Find (line 756) | func (idx *fuzzyStringIndex) Find(name string) iter.Seq[TypeID] {
function newFuzzyStringIndex (line 729) | func newFuzzyStringIndex(capacity int) *fuzzyStringIndex {
type fuzzyStringIndexEntry (line 777) | type fuzzyStringIndexEntry
method hash (line 783) | func (e fuzzyStringIndexEntry) hash() uint32 {
method id (line 787) | func (e fuzzyStringIndexEntry) id() TypeID {
function newFuzzyStringIndexEntry (line 779) | func newFuzzyStringIndexEntry(hash uint32, id TypeID) fuzzyStringIndexEn...
FILE: btf/unmarshal_test.go
function TestFuzzyStringIndex (line 11) | func TestFuzzyStringIndex(t *testing.T) {
FILE: btf/workarounds.go
function datasecResolveWorkaround (line 7) | func datasecResolveWorkaround(b *Builder, ds *Datasec) error {
FILE: btf/workarounds_test.go
function TestDatasecResolveWorkaround (line 14) | func TestDatasecResolveWorkaround(t *testing.T) {
function TestEmptyBTFWithStringTableWorkaround (line 71) | func TestEmptyBTFWithStringTableWorkaround(t *testing.T) {
FILE: cmd/bpf2go/flags.go
type buildTags (line 13) | type buildTags struct
method String (line 19) | func (bt *buildTags) String() string {
method Set (line 27) | func (bt *buildTags) Set(value string) error {
function andConstraints (line 37) | func andConstraints(x, y constraint.Expr) constraint.Expr {
FILE: cmd/bpf2go/gen/compile.go
type CompileArgs (line 13) | type CompileArgs struct
function insertDefaultFlags (line 31) | func insertDefaultFlags(flags []string) []string {
function Compile (line 61) | func Compile(args CompileArgs) error {
FILE: cmd/bpf2go/gen/compile_test.go
constant minimalSocketFilter (line 14) | minimalSocketFilter = `__attribute__((section("socket"), used)) int main...
function TestCompile (line 16) | func TestCompile(t *testing.T) {
function TestReproducibleCompile (line 45) | func TestReproducibleCompile(t *testing.T) {
function TestTriggerMissingTarget (line 91) | func TestTriggerMissingTarget(t *testing.T) {
function mustWriteFile (line 111) | func mustWriteFile(tb testing.TB, dir, name, contents string) {
FILE: cmd/bpf2go/gen/output.go
type templateName (line 28) | type templateName
method maybeExport (line 30) | func (n templateName) maybeExport(str string) string {
method Bytes (line 38) | func (n templateName) Bytes() string {
method Specs (line 42) | func (n templateName) Specs() string {
method ProgramSpecs (line 46) | func (n templateName) ProgramSpecs() string {
method MapSpecs (line 50) | func (n templateName) MapSpecs() string {
method VariableSpecs (line 54) | func (n templateName) VariableSpecs() string {
method Load (line 58) | func (n templateName) Load() string {
method LoadObjects (line 62) | func (n templateName) LoadObjects() string {
method Objects (line 66) | func (n templateName) Objects() string {
method Maps (line 70) | func (n templateName) Maps() string {
method Variables (line 74) | func (n templateName) Variables() string {
method Programs (line 78) | func (n templateName) Programs() string {
method CloseHelper (line 82) | func (n templateName) CloseHelper() string {
type GenerateArgs (line 86) | type GenerateArgs struct
function Generate (line 110) | func Generate(args GenerateArgs) error {
function sortTypes (line 212) | func sortTypes(typeNames map[btf.Type]string) ([]btf.Type, error) {
function toUpperFirst (line 234) | func toUpperFirst(str string) string {
FILE: cmd/bpf2go/gen/output_test.go
function TestOrderTypes (line 17) | func TestOrderTypes(t *testing.T) {
function TestPackageImport (line 69) | func TestPackageImport(t *testing.T) {
function TestCustomIdentifier (line 83) | func TestCustomIdentifier(t *testing.T) {
function TestObjects (line 98) | func TestObjects(t *testing.T) {
function TestGenerateStructTypes (line 122) | func TestGenerateStructTypes(t *testing.T) {
FILE: cmd/bpf2go/gen/target.go
type Target (line 33) | type Target struct
method IsGeneric (line 50) | func (tgt *Target) IsGeneric() bool {
method Suffix (line 56) | func (tgt *Target) Suffix() string {
method ObsoleteSuffix (line 74) | func (tgt *Target) ObsoleteSuffix() string {
function TargetsByGoArch (line 45) | func TargetsByGoArch() map[GoArch]Target {
type GoArch (line 86) | type GoArch
type GoArches (line 88) | type GoArches
method Constraint (line 91) | func (arches GoArches) Constraint() constraint.Expr {
function FindTarget (line 113) | func FindTarget(id string) (Target, GoArches, error) {
function orConstraints (line 150) | func orConstraints(x, y constraint.Expr) constraint.Expr {
FILE: cmd/bpf2go/gen/target_test.go
function TestCollectTargets (line 14) | func TestCollectTargets(t *testing.T) {
function TestCollectTargetsErrors (line 91) | func TestCollectTargetsErrors(t *testing.T) {
function TestGoarches (line 111) | func TestGoarches(t *testing.T) {
function TestClangTargets (line 128) | func TestClangTargets(t *testing.T) {
function goBin (line 151) | func goBin(t *testing.T) string {
FILE: cmd/bpf2go/gen/types.go
function CollectGlobalTypes (line 16) | func CollectGlobalTypes(spec *ebpf.CollectionSpec) []btf.Type {
function collectMapTypes (line 30) | func collectMapTypes(types []btf.Type, maps map[string]*ebpf.MapSpec) []...
function collectVariableTypes (line 45) | func collectVariableTypes(types []btf.Type, vars map[string]*ebpf.Variab...
function addType (line 55) | func addType(types []btf.Type, incoming btf.Type) []btf.Type {
function selectType (line 78) | func selectType(t btf.Type) btf.Type {
FILE: cmd/bpf2go/gen/types_test.go
function mustAnyTypeByName (line 16) | func mustAnyTypeByName(t *testing.T, spec *ebpf.CollectionSpec, name str...
function TestCollectGlobalTypes (line 24) | func TestCollectGlobalTypes(t *testing.T) {
FILE: cmd/bpf2go/internal/module.go
constant CurrentModule (line 9) | CurrentModule = "github.com/cilium/ebpf"
FILE: cmd/bpf2go/main.go
constant helpText (line 24) | helpText = `Usage: %[1]s [options] <ident> <source file> [-- <C flags>]
function run (line 48) | func run(stdout io.Writer, args []string) (err error) {
type bpf2go (line 60) | type bpf2go struct
method Debugln (line 94) | func (b2g *bpf2go) Debugln(a ...any) {
method convertAll (line 303) | func (b2g *bpf2go) convertAll() (err error) {
method convert (line 326) | func (b2g *bpf2go) convert(tgt gen.Target, goarches gen.GoArches) (err...
method removeOldOutputFiles (line 489) | func (b2g *bpf2go) removeOldOutputFiles(outputStem string, tgt gen.Tar...
function newB2G (line 100) | func newB2G(stdout io.Writer, args []string) (*bpf2go, error) {
type cTypes (line 248) | type cTypes
method String (line 252) | func (ct *cTypes) String() string {
method Set (line 263) | func (ct *cTypes) Set(value string) error {
constant validCTypeChars (line 259) | validCTypeChars = `[a-z0-9_]`
function getEnv (line 282) | func getEnv(key, defaultVal string) string {
function getBool (line 289) | func getBool(key string, defaultVal bool) bool {
function printTargets (line 511) | func printTargets(w io.Writer) {
function collectCTypes (line 528) | func collectCTypes(types *btf.Spec, names []string) ([]btf.Type, error) {
constant gopackageEnv (line 540) | gopackageEnv = "GOPACKAGE"
function main (line 542) | func main() {
FILE: cmd/bpf2go/main_test.go
constant minimalSocketFilter (line 22) | minimalSocketFilter = `__attribute__((section("socket"), used)) int main...
function TestRun (line 24) | func TestRun(t *testing.T) {
function TestHelp (line 111) | func TestHelp(t *testing.T) {
function TestErrorMentionsEnvVar (line 123) | func TestErrorMentionsEnvVar(t *testing.T) {
function TestDisableStripping (line 128) | func TestDisableStripping(t *testing.T) {
function TestConvertGOARCH (line 147) | func TestConvertGOARCH(t *testing.T) {
function TestCTypes (line 171) | func TestCTypes(t *testing.T) {
function TestParseArgs (line 205) | func TestParseArgs(t *testing.T) {
function mustWriteFile (line 409) | func mustWriteFile(tb testing.TB, dir, name, contents string) {
FILE: cmd/bpf2go/makedep.go
function adjustDependencies (line 15) | func adjustDependencies(w io.Writer, baseDir string, deps []dependency) ...
type dependency (line 48) | type dependency struct
function parseDependencies (line 53) | func parseDependencies(baseDir string, in io.Reader) ([]dependency, erro...
FILE: cmd/bpf2go/makedep_test.go
function TestParseDependencies (line 12) | func TestParseDependencies(t *testing.T) {
FILE: cmd/bpf2go/test/api_test.go
function TestLoadingSpec (line 15) | func TestLoadingSpec(t *testing.T) {
function TestLoadingObjects (line 26) | func TestLoadingObjects(t *testing.T) {
function TestTypes (line 41) | func TestTypes(t *testing.T) {
FILE: cmd/bpf2go/test/test_bpfeb.go
type testBar (line 16) | type testBar struct
type testBarfoo (line 23) | type testBarfoo struct
type testBaz (line 31) | type testBaz struct
type testE (line 36) | type testE
constant testEHOOPY (line 39) | testEHOOPY testE = 0
constant testEFROOD (line 40) | testEFROOD testE = 1
type testUbar (line 43) | type testUbar struct
function loadTest (line 50) | func loadTest() (*ebpf.CollectionSpec, error) {
function loadTestObjects (line 69) | func loadTestObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type testSpecs (line 81) | type testSpecs struct
type testProgramSpecs (line 90) | type testProgramSpecs struct
type testMapSpecs (line 97) | type testMapSpecs struct
type testVariableSpecs (line 104) | type testVariableSpecs struct
type testObjects (line 117) | type testObjects struct
method Close (line 123) | func (o *testObjects) Close() error {
type testMaps (line 133) | type testMaps struct
method Close (line 137) | func (m *testMaps) Close() error {
type testVariables (line 146) | type testVariables struct
type testPrograms (line 159) | type testPrograms struct
method Close (line 163) | func (p *testPrograms) Close() error {
function _TestClose (line 169) | func _TestClose(closers ...io.Closer) error {
FILE: cmd/bpf2go/test/test_bpfel.go
type testBar (line 16) | type testBar struct
type testBarfoo (line 23) | type testBarfoo struct
type testBaz (line 31) | type testBaz struct
type testE (line 36) | type testE
constant testEHOOPY (line 39) | testEHOOPY testE = 0
constant testEFROOD (line 40) | testEFROOD testE = 1
type testUbar (line 43) | type testUbar struct
function loadTest (line 50) | func loadTest() (*ebpf.CollectionSpec, error) {
function loadTestObjects (line 69) | func loadTestObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type testSpecs (line 81) | type testSpecs struct
type testProgramSpecs (line 90) | type testProgramSpecs struct
type testMapSpecs (line 97) | type testMapSpecs struct
type testVariableSpecs (line 104) | type testVariableSpecs struct
type testObjects (line 117) | type testObjects struct
method Close (line 123) | func (o *testObjects) Close() error {
type testMaps (line 133) | type testMaps struct
method Close (line 137) | func (m *testMaps) Close() error {
type testVariables (line 146) | type testVariables struct
type testPrograms (line 159) | type testPrograms struct
method Close (line 163) | func (p *testPrograms) Close() error {
function _TestClose (line 169) | func _TestClose(closers ...io.Closer) error {
FILE: cmd/bpf2go/testdata/minimal.c
type e (line 5) | enum e { HOOPY, FROOD }
type longint (line 7) | typedef long long int longint;
type barfoo (line 9) | typedef struct {
type baz (line 15) | typedef struct {
type bar (line 19) | struct bar {
type e (line 31) | enum e
type e (line 37) | enum e
type bar (line 42) | struct bar
function filter (line 45) | int filter() {
FILE: cmd/bpf2go/tools.go
function splitCFlagsFromArgs (line 11) | func splitCFlagsFromArgs(in []string) (args, cflags []string) {
function splitArguments (line 21) | func splitArguments(in string) ([]string, error) {
FILE: cmd/bpf2go/tools_test.go
function TestSplitArguments (line 10) | func TestSplitArguments(t *testing.T) {
FILE: collection.go
type CollectionOptions (line 25) | type CollectionOptions struct
type CollectionSpec (line 42) | type CollectionSpec struct
method Copy (line 61) | func (cs *CollectionSpec) Copy() *CollectionSpec {
method Assign (line 118) | func (cs *CollectionSpec) Assign(to interface{}) error {
method LoadAndAssign (line 174) | func (cs *CollectionSpec) LoadAndAssign(to interface{}, opts *Collecti...
function copyMapOfSpecs (line 84) | func copyMapOfSpecs[T interface{ Copy() T }](m map[string]T) map[string]T {
type Collection (line 248) | type Collection struct
method Assign (line 841) | func (coll *Collection) Assign(to interface{}) error {
method Close (line 898) | func (coll *Collection) Close() {
method DetachMap (line 912) | func (coll *Collection) DetachMap(name string) *Map {
method DetachProgram (line 923) | func (coll *Collection) DetachProgram(name string) *Program {
function NewCollection (line 263) | func NewCollection(spec *CollectionSpec) (*Collection, error) {
function NewCollectionWithOptions (line 272) | func NewCollectionWithOptions(spec *CollectionSpec, opts CollectionOptio...
type collectionLoader (line 319) | type collectionLoader struct
method close (line 380) | func (cl *collectionLoader) close() {
method loadMap (line 389) | func (cl *collectionLoader) loadMap(mapName string) (*Map, error) {
method loadProgram (line 448) | func (cl *collectionLoader) loadProgram(progName string) (*Program, er...
method loadVariable (line 502) | func (cl *collectionLoader) loadVariable(varName string) (*Variable, e...
method populateDeferredMaps (line 549) | func (cl *collectionLoader) populateDeferredMaps() error {
method populateStructOps (line 612) | func (cl *collectionLoader) populateStructOps(m *Map, mapSpec *MapSpec...
function newCollectionLoader (line 328) | func newCollectionLoader(coll *CollectionSpec, opts *CollectionOptions) ...
function populateKallsyms (line 357) | func populateKallsyms(progs map[string]*ProgramSpec) error {
function resolveKconfig (line 703) | func resolveKconfig(m *MapSpec) error {
function LoadCollection (line 804) | func LoadCollection(file string) (*Collection, error) {
type structField (line 930) | type structField struct
function ebpfFields (line 937) | func ebpfFields(structVal reflect.Value, visited map[reflect.Type]bool) ...
function assignValues (line 1001) | func assignValues(to interface{},
FILE: collection_other.go
function loadCollectionFromNativeImage (line 7) | func loadCollectionFromNativeImage(_ string) (*Collection, error) {
FILE: collection_test.go
function TestMain (line 22) | func TestMain(m *testing.M) {
function TestCollectionSpecNotModified (line 26) | func TestCollectionSpecNotModified(t *testing.T) {
function TestCollectionSpecCopy (line 71) | func TestCollectionSpecCopy(t *testing.T) {
function TestCollectionSpecMapReplacements (line 128) | func TestCollectionSpecMapReplacements(t *testing.T) {
function TestCollectionSpecMapReplacements_NonExistingMap (line 171) | func TestCollectionSpecMapReplacements_NonExistingMap(t *testing.T) {
function TestCollectionSpecMapReplacements_SpecMismatch (line 197) | func TestCollectionSpecMapReplacements_SpecMismatch(t *testing.T) {
function TestMapReplacementsDataSections (line 231) | func TestMapReplacementsDataSections(t *testing.T) {
function TestCollectionSpec_LoadAndAssign_LazyLoading (line 260) | func TestCollectionSpec_LoadAndAssign_LazyLoading(t *testing.T) {
function TestCollectionSpecAssign (line 312) | func TestCollectionSpecAssign(t *testing.T) {
function TestNewCollectionFdLeak (line 375) | func TestNewCollectionFdLeak(t *testing.T) {
function TestAssignValues (line 390) | func TestAssignValues(t *testing.T) {
function TestCollectionAssign (line 456) | func TestCollectionAssign(t *testing.T) {
function TestCollectionAssignFail (line 498) | func TestCollectionAssignFail(t *testing.T) {
function TestIncompleteLoadAndAssign (line 535) | func TestIncompleteLoadAndAssign(t *testing.T) {
function BenchmarkNewCollection (line 580) | func BenchmarkNewCollection(b *testing.B) {
function BenchmarkNewCollectionManyProgs (line 604) | func BenchmarkNewCollectionManyProgs(b *testing.B) {
function BenchmarkLoadCollectionManyProgs (line 624) | func BenchmarkLoadCollectionManyProgs(b *testing.B) {
function ExampleCollectionSpec_Assign (line 644) | func ExampleCollectionSpec_Assign() {
function ExampleCollectionSpec_LoadAndAssign (line 686) | func ExampleCollectionSpec_LoadAndAssign() {
function TestStructOpsMapSpecSimpleLoadAndAssign (line 720) | func TestStructOpsMapSpecSimpleLoadAndAssign(t *testing.T) {
function TestLinkedELF (line 850) | func TestLinkedELF(t *testing.T) {
FILE: collection_windows.go
function loadCollectionFromNativeImage (line 13) | func loadCollectionFromNativeImage(file string) (_ *Collection, err erro...
FILE: collection_windows_test.go
function TestLoadNativeImage (line 11) | func TestLoadNativeImage(t *testing.T) {
FILE: cpu.go
function PossibleCPU (line 5) | func PossibleCPU() (int, error) {
function MustPossibleCPU (line 11) | func MustPossibleCPU() int {
FILE: cpu_test.go
function TestPossibleCPU (line 9) | func TestPossibleCPU(t *testing.T) {
FILE: docs/examples/docs.c
function my_prog (line 17) | int my_prog() {
FILE: docs/examples/docs_test.go
function DocLoadCollectionSpec (line 11) | func DocLoadCollectionSpec() {
function DocNewCollection (line 36) | func DocNewCollection() {
type myObjs (line 60) | type myObjs struct
method Close (line 65) | func (objs *myObjs) Close() error {
function DocLoadAndAssign (line 77) | func DocLoadAndAssign() {
function DocBTFTypeByName (line 99) | func DocBTFTypeByName() {
FILE: docs/examples/features_test.go
function DocDetectXDP (line 13) | func DocDetectXDP() {
FILE: docs/examples/getting_started/counter.c
function count_packets (line 17) | int count_packets() {
FILE: docs/examples/getting_started/counter_bpfeb.go
function loadCounter (line 16) | func loadCounter() (*ebpf.CollectionSpec, error) {
function loadCounterObjects (line 35) | func loadCounterObjects(obj interface{}, opts *ebpf.CollectionOptions) e...
type counterSpecs (line 47) | type counterSpecs struct
type counterProgramSpecs (line 56) | type counterProgramSpecs struct
type counterMapSpecs (line 63) | type counterMapSpecs struct
type counterVariableSpecs (line 70) | type counterVariableSpecs struct
type counterObjects (line 76) | type counterObjects struct
method Close (line 82) | func (o *counterObjects) Close() error {
type counterMaps (line 92) | type counterMaps struct
method Close (line 96) | func (m *counterMaps) Close() error {
type counterVariables (line 105) | type counterVariables struct
type counterPrograms (line 111) | type counterPrograms struct
method Close (line 115) | func (p *counterPrograms) Close() error {
function _CounterClose (line 121) | func _CounterClose(closers ...io.Closer) error {
FILE: docs/examples/getting_started/counter_bpfel.go
function loadCounter (line 16) | func loadCounter() (*ebpf.CollectionSpec, error) {
function loadCounterObjects (line 35) | func loadCounterObjects(obj interface{}, opts *ebpf.CollectionOptions) e...
type counterSpecs (line 47) | type counterSpecs struct
type counterProgramSpecs (line 56) | type counterProgramSpecs struct
type counterMapSpecs (line 63) | type counterMapSpecs struct
type counterVariableSpecs (line 70) | type counterVariableSpecs struct
type counterObjects (line 76) | type counterObjects struct
method Close (line 82) | func (o *counterObjects) Close() error {
type counterMaps (line 92) | type counterMaps struct
method Close (line 96) | func (m *counterMaps) Close() error {
type counterVariables (line 105) | type counterVariables struct
type counterPrograms (line 111) | type counterPrograms struct
method Close (line 115) | func (p *counterPrograms) Close() error {
function _CounterClose (line 121) | func _CounterClose(closers ...io.Closer) error {
FILE: docs/examples/getting_started/main.go
function main (line 17) | func main() {
FILE: docs/examples/rlimit_test.go
function init (line 8) | func init() {
FILE: docs/examples/variables/main.go
function main (line 9) | func main() {
function DocVariablesSetConst (line 15) | func DocVariablesSetConst() {
function DocVariablesSetGlobal (line 56) | func DocVariablesSetGlobal() {
function panicf (line 104) | func panicf(format string, args ...interface{}) {
FILE: docs/examples/variables/variables.c
function const_example (line 12) | int const_example() {
function global_example (line 20) | int global_example() {
function hidden_example (line 29) | int hidden_example() {
FILE: docs/examples/variables/variables_bpfeb.go
function loadVariables (line 16) | func loadVariables() (*ebpf.CollectionSpec, error) {
function loadVariablesObjects (line 35) | func loadVariablesObjects(obj interface{}, opts *ebpf.CollectionOptions)...
type variablesSpecs (line 47) | type variablesSpecs struct
type variablesProgramSpecs (line 56) | type variablesProgramSpecs struct
type variablesMapSpecs (line 65) | type variablesMapSpecs struct
type variablesVariableSpecs (line 71) | type variablesVariableSpecs struct
type variablesObjects (line 79) | type variablesObjects struct
method Close (line 85) | func (o *variablesObjects) Close() error {
type variablesMaps (line 95) | type variablesMaps struct
method Close (line 98) | func (m *variablesMaps) Close() error {
type variablesVariables (line 105) | type variablesVariables struct
type variablesPrograms (line 113) | type variablesPrograms struct
method Close (line 119) | func (p *variablesPrograms) Close() error {
function _VariablesClose (line 127) | func _VariablesClose(closers ...io.Closer) error {
FILE: docs/examples/variables/variables_bpfel.go
function loadVariables (line 16) | func loadVariables() (*ebpf.CollectionSpec, error) {
function loadVariablesObjects (line 35) | func loadVariablesObjects(obj interface{}, opts *ebpf.CollectionOptions)...
type variablesSpecs (line 47) | type variablesSpecs struct
type variablesProgramSpecs (line 56) | type variablesProgramSpecs struct
type variablesMapSpecs (line 65) | type variablesMapSpecs struct
type variablesVariableSpecs (line 71) | type variablesVariableSpecs struct
type variablesObjects (line 79) | type variablesObjects struct
method Close (line 85) | func (o *variablesObjects) Close() error {
type variablesMaps (line 95) | type variablesMaps struct
method Close (line 98) | func (m *variablesMaps) Close() error {
type variablesVariables (line 105) | type variablesVariables struct
type variablesPrograms (line 113) | type variablesPrograms struct
method Close (line 119) | func (p *variablesPrograms) Close() error {
function _VariablesClose (line 127) | func _VariablesClose(closers ...io.Closer) error {
FILE: docs/macros.py
function define_env (line 16) | def define_env(env: MacrosPlugin):
function code_example (line 115) | def code_example(
function inner_body (line 150) | def inner_body(path: str, sym: str) -> str:
function full_body (line 166) | def full_body(path: str, sym: str) -> str:
function _get_body (line 173) | def _get_body(
function _search_body (line 232) | def _search_body(path: str, sym: str) -> List[str]:
FILE: elf_reader.go
type kconfigMetaKey (line 25) | type kconfigMetaKey struct
type kconfigMeta (line 27) | type kconfigMeta struct
type kfuncMetaKey (line 32) | type kfuncMetaKey struct
type kfuncMeta (line 34) | type kfuncMeta struct
type ksymMetaKey (line 39) | type ksymMetaKey struct
type ksymMeta (line 41) | type ksymMeta struct
type elfCode (line 48) | type elfCode struct
method assignSymbols (line 296) | func (ec *elfCode) assignSymbols(symbols []elf.Symbol) {
method loadRelocations (line 339) | func (ec *elfCode) loadRelocations(relSections map[elf.SectionIndex]*e...
method loadProgramSections (line 370) | func (ec *elfCode) loadProgramSections() (map[string]*ProgramSpec, err...
method loadFunctions (line 437) | func (ec *elfCode) loadFunctions(sec *elfSection) (map[string]asm.Inst...
method relocateInstruction (line 579) | func (ec *elfCode) relocateInstruction(ins *asm.Instruction, rel elf.S...
method loadMaps (line 796) | func (ec *elfCode) loadMaps() error {
method sectionVars (line 856) | func (ec *elfCode) sectionVars(spec *btf.Spec, sec string) (map[string...
method loadBTFMaps (line 882) | func (ec *elfCode) loadBTFMaps() error {
method loadDataSections (line 1264) | func (ec *elfCode) loadDataSections() error {
method loadKconfigSection (line 1415) | func (ec *elfCode) loadKconfigSection() error {
method loadKsymsSection (line 1449) | func (ec *elfCode) loadKsymsSection() error {
method associateStructOpsRelocs (line 1479) | func (ec *elfCode) associateStructOpsRelocs(progs map[string]*ProgramS...
method createStructOpsMap (line 1518) | func (ec *elfCode) createStructOpsMap(vsi btf.VarSecinfo, userData []b...
method loadSectionRelocations (line 1640) | func (ec *elfCode) loadSectionRelocations(sec *elf.Section, symbols []...
function LoadCollectionSpec (line 63) | func LoadCollectionSpec(file string) (*CollectionSpec, error) {
function LoadCollectionSpecFromReader (line 78) | func LoadCollectionSpecFromReader(rd io.ReaderAt) (*CollectionSpec, erro...
function loadLicense (line 214) | func loadLicense(sec *elf.Section) (string, error) {
function loadVersion (line 226) | func loadVersion(sec *elf.Section, bo binary.ByteOrder) (uint32, error) {
function isDataSection (line 238) | func isDataSection(name string) bool {
function isConstantDataSection (line 242) | func isConstantDataSection(name string) bool {
function isKconfigSection (line 246) | func isKconfigSection(name string) bool {
type elfSectionKind (line 250) | type elfSectionKind
constant undefSection (line 253) | undefSection elfSectionKind = iota
constant mapSection (line 254) | mapSection
constant btfMapSection (line 255) | btfMapSection
constant programSection (line 256) | programSection
constant dataSection (line 257) | dataSection
constant structOpsSection (line 258) | structOpsSection
type elfSection (line 261) | type elfSection struct
method symbolsSorted (line 284) | func (es *elfSection) symbolsSorted() iter.Seq2[uint64, elf.Symbol] {
function newElfSection (line 273) | func newElfSection(section *elf.Section, kind elfSectionKind) *elfSection {
function take (line 500) | func take[T any](q *[]T, f func(T) bool) *T {
function assignMetadata (line 516) | func assignMetadata(ins *asm.Instruction, raw asm.RawInstructionOffset,
function referenceRelativeJump (line 542) | func referenceRelativeJump(ins *asm.Instruction, offset uint64, symbols ...
function jumpTarget (line 562) | func jumpTarget(offset uint64, ins asm.Instruction) uint64 {
function mapSpecFromBTF (line 950) | func mapSpecFromBTF(es *elfSection, sym elf.Symbol, v *btf.Var, def *btf...
function uintFromBTF (line 1157) | func uintFromBTF(typ btf.Type) (uint64, error) {
function resolveBTFArrayMacro (line 1180) | func resolveBTFArrayMacro(typ btf.Type) (btf.Type, error) {
function valuesRelocations (line 1198) | func valuesRelocations(es *elfSection, sym elf.Symbol, member btf.Member...
function resolveBTFValuesContents (line 1241) | func resolveBTFValuesContents(es *elfSection, sym elf.Symbol, member btf...
type libbpfElfSectionDef (line 1562) | type libbpfElfSectionDef struct
type libbpfElfSectionFlag (line 1569) | type libbpfElfSectionFlag
constant _SEC_NONE (line 1573) | _SEC_NONE libbpfElfSectionFlag = 0
constant _SEC_EXP_ATTACH_OPT (line 1575) | _SEC_EXP_ATTACH_OPT libbpfElfSectionFlag = 1 << (iota - 1)
constant _SEC_ATTACHABLE (line 1576) | _SEC_ATTACHABLE
constant _SEC_ATTACH_BTF (line 1577) | _SEC_ATTACH_BTF
constant _SEC_SLEEPABLE (line 1578) | _SEC_SLEEPABLE
constant _SEC_XDP_FRAGS (line 1579) | _SEC_XDP_FRAGS
constant _SEC_USDT (line 1580) | _SEC_USDT
constant _SEC_ATTACHABLE_OPT (line 1582) | _SEC_ATTACHABLE_OPT = _SEC_ATTACHABLE | _SEC_EXP_ATTACH_OPT
function getProgType (line 1585) | func getProgType(sectionName string) (ProgramType, AttachType, uint32, s...
function matchSectionName (line 1624) | func matchSectionName(sectionName, pattern string) (extra string, found ...
FILE: elf_reader_test.go
function TestLoadCollectionSpec (line 45) | func TestLoadCollectionSpec(t *testing.T) {
function testLoadCollectionSpec (line 258) | func testLoadCollectionSpec(t *testing.T, got, want *CollectionSpec) {
function BenchmarkELFLoader (line 274) | func BenchmarkELFLoader(b *testing.B) {
function TestDataSections (line 282) | func TestDataSections(t *testing.T) {
function TestInlineASMConstant (line 304) | func TestInlineASMConstant(t *testing.T) {
function TestFreezeRodata (line 329) | func TestFreezeRodata(t *testing.T) {
function TestCollectionSpecDetach (line 348) | func TestCollectionSpecDetach(t *testing.T) {
function TestLoadInvalidMap (line 377) | func TestLoadInvalidMap(t *testing.T) {
function TestLoadInvalidMapMissingSymbol (line 397) | func TestLoadInvalidMapMissingSymbol(t *testing.T) {
function TestLoadInitializedBTFMap (line 406) | func TestLoadInitializedBTFMap(t *testing.T) {
function TestLoadInvalidInitializedBTFMap (line 487) | func TestLoadInvalidInitializedBTFMap(t *testing.T) {
function TestStringSection (line 496) | func TestStringSection(t *testing.T) {
function TestLoadRawTracepoint (line 554) | func TestLoadRawTracepoint(t *testing.T) {
function TestTailCall (line 576) | func TestTailCall(t *testing.T) {
function TestKconfig (line 608) | func TestKconfig(t *testing.T) {
function TestKsym (line 630) | func TestKsym(t *testing.T) {
function TestKsymWeakMissing (line 665) | func TestKsymWeakMissing(t *testing.T) {
function TestKfunc (line 683) | func TestKfunc(t *testing.T) {
function TestWeakKfunc (line 709) | func TestWeakKfunc(t *testing.T) {
function TestInvalidKfunc (line 738) | func TestInvalidKfunc(t *testing.T) {
function TestKfuncKmod (line 755) | func TestKfuncKmod(t *testing.T) {
function TestSubprogRelocation (line 783) | func TestSubprogRelocation(t *testing.T) {
function TestUnassignedProgArray (line 812) | func TestUnassignedProgArray(t *testing.T) {
function TestIPRoute2Compat (line 834) | func TestIPRoute2Compat(t *testing.T) {
function TestArena (line 889) | func TestArena(t *testing.T) {
function TestStructOps (line 913) | func TestStructOps(t *testing.T) {
function TestLibBPFCompat (line 1014) | func TestLibBPFCompat(t *testing.T) {
function loadTargetProgram (line 1200) | func loadTargetProgram(tb testing.TB, spec *CollectionSpec, file, progra...
function sourceOfBTF (line 1238) | func sourceOfBTF(tb testing.TB, path string) []string {
function TestELFSectionProgramTypes (line 1256) | func TestELFSectionProgramTypes(t *testing.T) {
function TestMatchSectionName (line 1358) | func TestMatchSectionName(t *testing.T) {
function selftestName (line 1397) | func selftestName(path string) string {
FILE: example_sock_elf_test.go
function Example_socketELF (line 84) | func Example_socketELF() {
function openRawSock (line 146) | func openRawSock(index int) (int, error) {
function htons (line 162) | func htons(i uint16) uint16 {
FILE: example_sock_extract_dist_test.go
function Example_extractDistance (line 46) | func Example_extractDistance() {
function newDistanceFilter (line 80) | func newDistanceFilter() (*ebpf.Program, *ebpf.Map, error) {
function minDistance (line 164) | func minDistance(TTLs *ebpf.Map) (int, error) {
FILE: examples/cgroup_skb/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/cgroup_skb/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/cgroup_skb/cgroup_skb.c
function count_egress_packets (line 15) | int count_egress_packets(struct __sk_buff *skb) {
FILE: examples/cgroup_skb/main.go
function main (line 24) | func main() {
function detectCgroupPath (line 72) | func detectCgroupPath() (string, error) {
FILE: examples/fentry/bpf_bpfeb.go
type bpfEvent (line 16) | type bpfEvent struct
function loadBpf (line 26) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 45) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 57) | type bpfSpecs struct
type bpfProgramSpecs (line 66) | type bpfProgramSpecs struct
type bpfMapSpecs (line 73) | type bpfMapSpecs struct
type bpfVariableSpecs (line 80) | type bpfVariableSpecs struct
type bpfObjects (line 86) | type bpfObjects struct
method Close (line 92) | func (o *bpfObjects) Close() error {
type bpfMaps (line 102) | type bpfMaps struct
method Close (line 106) | func (m *bpfMaps) Close() error {
type bpfVariables (line 115) | type bpfVariables struct
type bpfPrograms (line 121) | type bpfPrograms struct
method Close (line 125) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 131) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/fentry/bpf_bpfel.go
type bpfEvent (line 16) | type bpfEvent struct
function loadBpf (line 26) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 45) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 57) | type bpfSpecs struct
type bpfProgramSpecs (line 66) | type bpfProgramSpecs struct
type bpfMapSpecs (line 73) | type bpfMapSpecs struct
type bpfVariableSpecs (line 80) | type bpfVariableSpecs struct
type bpfObjects (line 86) | type bpfObjects struct
method Close (line 92) | func (o *bpfObjects) Close() error {
type bpfMaps (line 102) | type bpfMaps struct
method Close (line 106) | func (m *bpfMaps) Close() error {
type bpfVariables (line 115) | type bpfVariables struct
type bpfPrograms (line 121) | type bpfPrograms struct
method Close (line 125) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 131) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/fentry/fentry.c
type sock_common (line 30) | struct sock_common {
type sock (line 53) | struct sock {
type event (line 60) | struct event
type event (line 68) | struct event {
function BPF_PROG (line 77) | int BPF_PROG(tcp_connect, struct sock *sk) {
FILE: examples/fentry/main.go
function main (line 34) | func main() {
function intToIP (line 110) | func intToIP(ipNum uint32) net.IP {
FILE: examples/headers/bpf_helper_defs.h
type bpf_fib_lookup (line 4) | struct bpf_fib_lookup
type bpf_sk_lookup (line 5) | struct bpf_sk_lookup
type bpf_perf_event_data (line 6) | struct bpf_perf_event_data
type bpf_perf_event_value (line 7) | struct bpf_perf_event_value
type bpf_pidns_info (line 8) | struct bpf_pidns_info
type bpf_redir_neigh (line 9) | struct bpf_redir_neigh
type bpf_sock (line 10) | struct bpf_sock
type bpf_sock_addr (line 11) | struct bpf_sock_addr
type bpf_sock_ops (line 12) | struct bpf_sock_ops
type bpf_sock_tuple (line 13) | struct bpf_sock_tuple
type bpf_spin_lock (line 14) | struct bpf_spin_lock
type bpf_sysctl (line 15) | struct bpf_sysctl
type bpf_tcp_sock (line 16) | struct bpf_tcp_sock
type bpf_tunnel_key (line 17) | struct bpf_tunnel_key
type bpf_xfrm_state (line 18) | struct bpf_xfrm_state
type linux_binprm (line 19) | struct linux_binprm
type pt_regs (line 20) | struct pt_regs
type sk_reuseport_md (line 21) | struct sk_reuseport_md
type sockaddr (line 22) | struct sockaddr
type tcphdr (line 23) | struct tcphdr
type seq_file (line 24) | struct seq_file
type tcp6_sock (line 25) | struct tcp6_sock
type tcp_sock (line 26) | struct tcp_sock
type tcp_timewait_sock (line 27) | struct tcp_timewait_sock
type tcp_request_sock (line 28) | struct tcp_request_sock
type udp6_sock (line 29) | struct udp6_sock
type unix_sock (line 30) | struct unix_sock
type task_struct (line 31) | struct task_struct
type __sk_buff (line 32) | struct __sk_buff
type sk_msg_md (line 33) | struct sk_msg_md
type xdp_md (line 34) | struct xdp_md
type path (line 35) | struct path
type btf_ptr (line 36) | struct btf_ptr
type inode (line 37) | struct inode
type socket (line 38) | struct socket
type file (line 39) | struct file
type bpf_timer (line 40) | struct bpf_timer
type __sk_buff (line 222) | struct __sk_buff
type __sk_buff (line 251) | struct __sk_buff
type __sk_buff (line 287) | struct __sk_buff
type __sk_buff (line 350) | struct __sk_buff
type __sk_buff (line 417) | struct __sk_buff
type __sk_buff (line 437) | struct __sk_buff
type __sk_buff (line 453) | struct __sk_buff
type __sk_buff (line 508) | struct __sk_buff
type bpf_tunnel_key (line 508) | struct bpf_tunnel_key
type __sk_buff (line 549) | struct __sk_buff
type bpf_tunnel_key (line 549) | struct bpf_tunnel_key
type __sk_buff (line 637) | struct __sk_buff
type __sk_buff (line 806) | struct __sk_buff
type __sk_buff (line 820) | struct __sk_buff
type __sk_buff (line 851) | struct __sk_buff
type __sk_buff (line 882) | struct __sk_buff
type __sk_buff (line 897) | struct __sk_buff
type __sk_buff (line 917) | struct __sk_buff
type __sk_buff (line 993) | struct __sk_buff
type __sk_buff (line 1033) | struct __sk_buff
type __sk_buff (line 1049) | struct __sk_buff
type __sk_buff (line 1061) | struct __sk_buff
type __sk_buff (line 1101) | struct __sk_buff
type xdp_md (line 1120) | struct xdp_md
type __sk_buff (line 1167) | struct __sk_buff
type __sk_buff (line 1178) | struct __sk_buff
type __sk_buff (line 1267) | struct __sk_buff
type __sk_buff (line 1311) | struct __sk_buff
type bpf_sock_ops (line 1334) | struct bpf_sock_ops
type xdp_md (line 1367) | struct xdp_md
type bpf_perf_event_value (line 1421) | struct bpf_perf_event_value
type bpf_perf_event_data (line 1436) | struct bpf_perf_event_data
type bpf_perf_event_value (line 1436) | struct bpf_perf_event_value
type pt_regs (line 1494) | struct pt_regs
type bpf_sock_ops (line 1542) | struct bpf_sock_ops
type sk_msg_md (line 1560) | struct sk_msg_md
type sk_msg_md (line 1598) | struct sk_msg_md
type sk_msg_md (line 1620) | struct sk_msg_md
type sk_msg_md (line 1655) | struct sk_msg_md
type bpf_sock_addr (line 1677) | struct bpf_sock_addr
type sockaddr (line 1677) | struct sockaddr
type xdp_md (line 1695) | struct xdp_md
type __sk_buff (line 1715) | struct __sk_buff
type bpf_xfrm_state (line 1715) | struct bpf_xfrm_state
type bpf_fib_lookup (line 1816) | struct bpf_fib_lookup
type bpf_sock_ops (line 1839) | struct bpf_sock_ops
type sk_msg_md (line 1857) | struct sk_msg_md
type __sk_buff (line 1875) | struct __sk_buff
type __sk_buff (line 1916) | struct __sk_buff
type __sk_buff (line 1935) | struct __sk_buff
type __sk_buff (line 1955) | struct __sk_buff
type __sk_buff (line 1988) | struct __sk_buff
type __sk_buff (line 2061) | struct __sk_buff
type sk_reuseport_md (line 2106) | struct sk_reuseport_md
type __sk_buff (line 2128) | struct __sk_buff
type bpf_sock (line 2169) | struct bpf_sock
type bpf_sock_tuple (line 2169) | struct bpf_sock_tuple
type bpf_sock (line 2210) | struct bpf_sock
type bpf_sock_tuple (line 2210) | struct bpf_sock_tuple
type sk_msg_md (line 2276) | struct sk_msg_md
type sk_msg_md (line 2292) | struct sk_msg_md
type bpf_spin_lock (line 2362) | struct bpf_spin_lock
type bpf_spin_lock (line 2373) | struct bpf_spin_lock
type bpf_sock (line 2385) | struct bpf_sock
type bpf_sock (line 2385) | struct bpf_sock
type bpf_tcp_sock (line 2397) | struct bpf_tcp_sock
type bpf_sock (line 2397) | struct bpf_sock
type __sk_buff (line 2411) | struct __sk_buff
type bpf_sock (line 2423) | struct bpf_sock
type bpf_sock (line 2423) | struct bpf_sock
type bpf_sock (line 2446) | struct bpf_sock
type bpf_sock_tuple (line 2446) | struct bpf_sock_tuple
type tcphdr (line 2465) | struct tcphdr
type bpf_sysctl (line 2485) | struct bpf_sysctl
type bpf_sysctl (line 2508) | struct bpf_sysctl
type bpf_sysctl (line 2529) | struct bpf_sysctl
type bpf_sysctl (line 2550) | struct bpf_sysctl
type tcphdr (line 2702) | struct tcphdr
type bpf_perf_event_data (line 2874) | struct bpf_perf_event_data
type bpf_pidns_info (line 2890) | struct bpf_pidns_info
type seq_file (line 3037) | struct seq_file
type seq_file (line 3051) | struct seq_file
type __sk_buff (line 3217) | struct __sk_buff
type tcp6_sock (line 3227) | struct tcp6_sock
type tcp_sock (line 3237) | struct tcp_sock
type tcp_timewait_sock (line 3247) | struct tcp_timewait_sock
type tcp_request_sock (line 3257) | struct tcp_request_sock
type udp6_sock (line 3267) | struct udp6_sock
type task_struct (line 3303) | struct task_struct
type bpf_sock_ops (line 3370) | struct bpf_sock_ops
type bpf_sock_ops (line 3407) | struct bpf_sock_ops
type bpf_sock_ops (line 3433) | struct bpf_sock_ops
type path (line 3493) | struct path
type btf_ptr (line 3544) | struct btf_ptr
type seq_file (line 3556) | struct seq_file
type btf_ptr (line 3556) | struct btf_ptr
type __sk_buff (line 3569) | struct __sk_buff
type bpf_redir_neigh (line 3594) | struct bpf_redir_neigh
type task_struct (line 3683) | struct task_struct
type task_struct (line 3695) | struct task_struct
type task_struct (line 3707) | struct task_struct
type linux_binprm (line 3721) | struct linux_binprm
type inode (line 3749) | struct inode
type socket (line 3761) | struct socket
type file (line 3761) | struct file
type bpf_timer (line 3948) | struct bpf_timer
type bpf_timer (line 3963) | struct bpf_timer
type bpf_timer (line 3993) | struct bpf_timer
type bpf_timer (line 4007) | struct bpf_timer
type task_struct (line 4046) | struct task_struct
type unix_sock (line 4095) | struct unix_sock
type task_struct (line 4137) | struct task_struct
FILE: examples/headers/bpf_helpers.h
function __always_inline (line 98) | static __always_inline void
type bpf_map_def (line 130) | struct bpf_map_def {
type libbpf_pin_type (line 138) | enum libbpf_pin_type {
type libbpf_tristate (line 144) | enum libbpf_tristate {
FILE: examples/headers/bpf_tracing.h
type pt_regs (line 147) | struct pt_regs
type pt_regs (line 199) | struct pt_regs
type pt_regs (line 299) | struct pt_regs
type pt_regs (line 427) | struct pt_regs
FILE: examples/headers/common.h
type __u8 (line 5) | typedef unsigned char __u8;
type __s16 (line 6) | typedef short int __s16;
type __u16 (line 7) | typedef short unsigned int __u16;
type __s32 (line 8) | typedef int __s32;
type __u32 (line 9) | typedef unsigned int __u32;
type __s64 (line 10) | typedef long long int __s64;
type __u64 (line 11) | typedef long long unsigned int __u64;
type __u8 (line 12) | typedef __u8 u8;
type __s16 (line 13) | typedef __s16 s16;
type __u16 (line 14) | typedef __u16 u16;
type __s32 (line 15) | typedef __s32 s32;
type __u32 (line 16) | typedef __u32 u32;
type __s64 (line 17) | typedef __s64 s64;
type __u64 (line 18) | typedef __u64 u64;
type __u16 (line 19) | typedef __u16 __le16;
type __u16 (line 20) | typedef __u16 __be16;
type __u32 (line 21) | typedef __u32 __be32;
type __u64 (line 22) | typedef __u64 __be64;
type __u32 (line 23) | typedef __u32 __wsum;
type bpf_map_type (line 27) | enum bpf_map_type {
type xdp_action (line 59) | enum xdp_action {
type tc_action (line 67) | enum tc_action {
type xdp_md (line 80) | struct xdp_md {
type __u16 (line 89) | typedef __u16 __sum16;
type ethhdr (line 93) | struct ethhdr {
type iphdr (line 99) | struct iphdr {
type pt_regs (line 127) | struct pt_regs {
FILE: examples/kprobe/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/kprobe/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/kprobe/kprobe.c
function kprobe_execve (line 15) | int kprobe_execve() {
FILE: examples/kprobe/main.go
constant mapKey (line 19) | mapKey uint32 = 0
function main (line 21) | func main() {
FILE: examples/kprobe_percpu/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/kprobe_percpu/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/kprobe_percpu/kprobe_percpu.c
function kprobe_execve (line 15) | int kprobe_execve() {
FILE: examples/kprobe_percpu/main.go
constant mapKey (line 19) | mapKey uint32 = 0
function main (line 21) | func main() {
FILE: examples/kprobepin/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/kprobepin/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/kprobepin/kprobe_pin.c
function kprobe_execve (line 16) | int kprobe_execve() {
FILE: examples/kprobepin/main.go
constant mapKey (line 23) | mapKey uint32 = 0
constant bpfFSPath (line 24) | bpfFSPath = "/sys/fs/bpf"
function main (line 27) | func main() {
FILE: examples/map_in_map/main.go
constant BPF_F_INNER_MAP (line 19) | BPF_F_INNER_MAP = 0x1000
function main (line 21) | func main() {
FILE: examples/ringbuffer/bpf_bpfeb.go
type bpfEvent (line 16) | type bpfEvent struct
function loadBpf (line 23) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 42) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 54) | type bpfSpecs struct
type bpfProgramSpecs (line 63) | type bpfProgramSpecs struct
type bpfMapSpecs (line 70) | type bpfMapSpecs struct
type bpfVariableSpecs (line 77) | type bpfVariableSpecs struct
type bpfObjects (line 83) | type bpfObjects struct
method Close (line 89) | func (o *bpfObjects) Close() error {
type bpfMaps (line 99) | type bpfMaps struct
method Close (line 103) | func (m *bpfMaps) Close() error {
type bpfVariables (line 112) | type bpfVariables struct
type bpfPrograms (line 118) | type bpfPrograms struct
method Close (line 122) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 128) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/ringbuffer/bpf_bpfel.go
type bpfEvent (line 16) | type bpfEvent struct
function loadBpf (line 23) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 42) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 54) | type bpfSpecs struct
type bpfProgramSpecs (line 63) | type bpfProgramSpecs struct
type bpfMapSpecs (line 70) | type bpfMapSpecs struct
type bpfVariableSpecs (line 77) | type bpfVariableSpecs struct
type bpfObjects (line 83) | type bpfObjects struct
method Close (line 89) | func (o *bpfObjects) Close() error {
type bpfMaps (line 99) | type bpfMaps struct
method Close (line 103) | func (m *bpfMaps) Close() error {
type bpfVariables (line 112) | type bpfVariables struct
type bpfPrograms (line 118) | type bpfPrograms struct
method Close (line 122) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 128) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/ringbuffer/main.go
function main (line 23) | func main() {
FILE: examples/ringbuffer/ringbuffer.c
type event (line 11) | struct event {
type event (line 19) | struct event
function kprobe_execve (line 23) | int kprobe_execve(struct pt_regs *ctx) {
FILE: examples/sched_ext/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 62) | type bpfMapSpecs struct
type bpfVariableSpecs (line 69) | type bpfVariableSpecs struct
type bpfObjects (line 75) | type bpfObjects struct
method Close (line 81) | func (o *bpfObjects) Close() error {
type bpfMaps (line 91) | type bpfMaps struct
method Close (line 95) | func (m *bpfMaps) Close() error {
type bpfVariables (line 104) | type bpfVariables struct
type bpfPrograms (line 110) | type bpfPrograms struct
method Close (line 113) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 117) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/sched_ext/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 62) | type bpfMapSpecs struct
type bpfVariableSpecs (line 69) | type bpfVariableSpecs struct
type bpfObjects (line 75) | type bpfObjects struct
method Close (line 81) | func (o *bpfObjects) Close() error {
type bpfMaps (line 91) | type bpfMaps struct
method Close (line 95) | func (m *bpfMaps) Close() error {
type bpfVariables (line 104) | type bpfVariables struct
type bpfPrograms (line 110) | type bpfPrograms struct
method Close (line 113) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 117) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/sched_ext/main.go
function main (line 25) | func main() {
FILE: examples/sched_ext/sched_ext.c
type sched_ext_ops (line 8) | struct sched_ext_ops {
type sched_ext_ops (line 13) | struct sched_ext_ops
FILE: examples/tcprtt/bpf_bpfeb.go
type bpfEvent (line 16) | type bpfEvent struct
function loadBpf (line 26) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 45) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 57) | type bpfSpecs struct
type bpfProgramSpecs (line 66) | type bpfProgramSpecs struct
type bpfMapSpecs (line 73) | type bpfMapSpecs struct
type bpfVariableSpecs (line 80) | type bpfVariableSpecs struct
type bpfObjects (line 86) | type bpfObjects struct
method Close (line 92) | func (o *bpfObjects) Close() error {
type bpfMaps (line 102) | type bpfMaps struct
method Close (line 106) | func (m *bpfMaps) Close() error {
type bpfVariables (line 115) | type bpfVariables struct
type bpfPrograms (line 121) | type bpfPrograms struct
method Close (line 125) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 131) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tcprtt/bpf_bpfel.go
type bpfEvent (line 16) | type bpfEvent struct
function loadBpf (line 26) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 45) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 57) | type bpfSpecs struct
type bpfProgramSpecs (line 66) | type bpfProgramSpecs struct
type bpfMapSpecs (line 73) | type bpfMapSpecs struct
type bpfVariableSpecs (line 80) | type bpfVariableSpecs struct
type bpfObjects (line 86) | type bpfObjects struct
method Close (line 92) | func (o *bpfObjects) Close() error {
type bpfMaps (line 102) | type bpfMaps struct
method Close (line 106) | func (m *bpfMaps) Close() error {
type bpfVariables (line 115) | type bpfVariables struct
type bpfPrograms (line 121) | type bpfPrograms struct
method Close (line 125) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 131) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tcprtt/main.go
function main (line 35) | func main() {
function readLoop (line 78) | func readLoop(rd *ringbuf.Reader) {
function intToIP (line 109) | func intToIP(ipNum uint32) net.IP {
FILE: examples/tcprtt/tcprtt.c
type sock_common (line 29) | struct sock_common {
type sock (line 55) | struct sock {
type tcp_sock (line 64) | struct tcp_sock {
type event (line 71) | struct event
type event (line 79) | struct event {
function BPF_PROG (line 88) | int BPF_PROG(tcp_close, struct sock *sk) {
FILE: examples/tcprtt_sockops/bpf_bpfeb.go
type bpfRttEvent (line 16) | type bpfRttEvent struct
type bpfSkInfo (line 25) | type bpfSkInfo struct
type bpfSkKey (line 32) | type bpfSkKey struct
function loadBpf (line 41) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 60) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 72) | type bpfSpecs struct
type bpfProgramSpecs (line 81) | type bpfProgramSpecs struct
type bpfMapSpecs (line 88) | type bpfMapSpecs struct
type bpfVariableSpecs (line 96) | type bpfVariableSpecs struct
type bpfObjects (line 102) | type bpfObjects struct
method Close (line 108) | func (o *bpfObjects) Close() error {
type bpfMaps (line 118) | type bpfMaps struct
method Close (line 123) | func (m *bpfMaps) Close() error {
type bpfVariables (line 133) | type bpfVariables struct
type bpfPrograms (line 139) | type bpfPrograms struct
method Close (line 143) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 149) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tcprtt_sockops/bpf_bpfel.go
type bpfRttEvent (line 16) | type bpfRttEvent struct
type bpfSkInfo (line 25) | type bpfSkInfo struct
type bpfSkKey (line 32) | type bpfSkKey struct
function loadBpf (line 41) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 60) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 72) | type bpfSpecs struct
type bpfProgramSpecs (line 81) | type bpfProgramSpecs struct
type bpfMapSpecs (line 88) | type bpfMapSpecs struct
type bpfVariableSpecs (line 96) | type bpfVariableSpecs struct
type bpfObjects (line 102) | type bpfObjects struct
method Close (line 108) | func (o *bpfObjects) Close() error {
type bpfMaps (line 118) | type bpfMaps struct
method Close (line 123) | func (m *bpfMaps) Close() error {
type bpfVariables (line 133) | type bpfVariables struct
type bpfPrograms (line 139) | type bpfPrograms struct
method Close (line 143) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 149) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tcprtt_sockops/bpf_sockops.h
type bpf_sock_ops (line 71) | struct bpf_sock_ops {
FILE: examples/tcprtt_sockops/main.go
function main (line 44) | func main() {
function findCgroupPath (line 98) | func findCgroupPath() (string, error) {
function readLoop (line 113) | func readLoop(rd *ringbuf.Reader) {
function intToIP (line 144) | func intToIP(ipNum uint32) net.IP {
FILE: examples/tcprtt_sockops/tcprtt_sockops.c
type sk_key (line 22) | struct sk_key
type sk_info (line 23) | struct sk_info
type sk_key (line 26) | struct sk_key {
type sk_info (line 33) | struct sk_info {
type rtt_event (line 41) | struct rtt_event
type rtt_event (line 44) | struct rtt_event {
function init_sk_key (line 52) | static inline void init_sk_key(struct bpf_sock_ops *skops, struct sk_key...
function bpf_sock_ops_establish_cb (line 59) | static inline void bpf_sock_ops_establish_cb(struct bpf_sock_ops *skops,...
function bpf_sock_ops_rtt_cb (line 83) | static inline void bpf_sock_ops_rtt_cb(struct bpf_sock_ops *skops) {
function bpf_sock_ops_state_cb (line 128) | static inline void bpf_sock_ops_state_cb(struct bpf_sock_ops *skops) {
function bpf_sockops_cb (line 141) | int bpf_sockops_cb(struct bpf_sock_ops *skops) {
FILE: examples/tcx/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 64) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 78) | type bpfObjects struct
method Close (line 84) | func (o *bpfObjects) Close() error {
type bpfMaps (line 94) | type bpfMaps struct
method Close (line 97) | func (m *bpfMaps) Close() error {
type bpfVariables (line 104) | type bpfVariables struct
type bpfPrograms (line 112) | type bpfPrograms struct
method Close (line 117) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 124) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tcx/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 64) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 78) | type bpfObjects struct
method Close (line 84) | func (o *bpfObjects) Close() error {
type bpfMaps (line 94) | type bpfMaps struct
method Close (line 97) | func (m *bpfMaps) Close() error {
type bpfVariables (line 104) | type bpfVariables struct
type bpfPrograms (line 112) | type bpfPrograms struct
method Close (line 117) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 124) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tcx/main.go
function main (line 22) | func main() {
function formatCounters (line 82) | func formatCounters(ingressVar, egressVar *ebpf.Variable) (string, error) {
FILE: examples/tcx/tcx.c
function ingress_prog_func (line 11) | int ingress_prog_func(struct __sk_buff *skb) {
function egress_prog_func (line 17) | int egress_prog_func(struct __sk_buff *skb) {
FILE: examples/tracepoint_in_c/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tracepoint_in_c/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/tracepoint_in_c/main.go
constant mapKey (line 19) | mapKey uint32 = 0
function main (line 21) | func main() {
FILE: examples/tracepoint_in_c/tracepoint.c
type alloc_info (line 16) | struct alloc_info {
function mm_page_alloc (line 29) | int mm_page_alloc(struct alloc_info *info) {
FILE: examples/tracepoint_in_go/main.go
function main (line 29) | func main() {
FILE: examples/uretprobe/bpf_x86_bpfel.go
type bpfEvent (line 16) | type bpfEvent struct
function loadBpf (line 23) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 42) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 54) | type bpfSpecs struct
type bpfProgramSpecs (line 63) | type bpfProgramSpecs struct
type bpfMapSpecs (line 70) | type bpfMapSpecs struct
type bpfVariableSpecs (line 77) | type bpfVariableSpecs struct
type bpfObjects (line 83) | type bpfObjects struct
method Close (line 89) | func (o *bpfObjects) Close() error {
type bpfMaps (line 99) | type bpfMaps struct
method Close (line 103) | func (m *bpfMaps) Close() error {
type bpfVariables (line 112) | type bpfVariables struct
type bpfPrograms (line 118) | type bpfPrograms struct
method Close (line 122) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 128) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/uretprobe/main.go
constant binPath (line 33) | binPath = "/bin/bash"
constant symbol (line 34) | symbol = "readline"
function main (line 37) | func main() {
FILE: examples/uretprobe/uretprobe.c
type event (line 9) | struct event {
type event (line 16) | struct event
function uretprobe_bash_readline (line 20) | int uretprobe_bash_readline(struct pt_regs *ctx) {
FILE: examples/xdp/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/xdp/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 63) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 96) | func (m *bpfMaps) Close() error {
type bpfVariables (line 105) | type bpfVariables struct
type bpfPrograms (line 111) | type bpfPrograms struct
method Close (line 115) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 121) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/xdp/main.go
function main (line 28) | func main() {
function formatMapContents (line 73) | func formatMapContents(m *ebpf.Map) (string, error) {
FILE: examples/xdp/xdp.c
function __always_inline (line 22) | static __always_inline int parse_ip_src_addr(struct xdp_md *ctx, __u32 *...
function xdp_prog_func (line 49) | int xdp_prog_func(struct xdp_md *ctx) {
FILE: examples/xdp_live_frame/bpf_bpfeb.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 64) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 95) | func (m *bpfMaps) Close() error {
type bpfVariables (line 102) | type bpfVariables struct
type bpfPrograms (line 108) | type bpfPrograms struct
method Close (line 113) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 120) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/xdp_live_frame/bpf_bpfel.go
function loadBpf (line 16) | func loadBpf() (*ebpf.CollectionSpec, error) {
function loadBpfObjects (line 35) | func loadBpfObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
type bpfSpecs (line 47) | type bpfSpecs struct
type bpfProgramSpecs (line 56) | type bpfProgramSpecs struct
type bpfMapSpecs (line 64) | type bpfMapSpecs struct
type bpfVariableSpecs (line 70) | type bpfVariableSpecs struct
type bpfObjects (line 76) | type bpfObjects struct
method Close (line 82) | func (o *bpfObjects) Close() error {
type bpfMaps (line 92) | type bpfMaps struct
method Close (line 95) | func (m *bpfMaps) Close() error {
type bpfVariables (line 102) | type bpfVariables struct
type bpfPrograms (line 108) | type bpfPrograms struct
method Close (line 113) | func (p *bpfPrograms) Close() error {
function _BpfClose (line 120) | func _BpfClose(closers ...io.Closer) error {
FILE: examples/xdp_live_frame/main.go
function main (line 29) | func main() {
function buildUDPPacket (line 111) | func buildUDPPacket(srcMAC, dstMAC net.HardwareAddr, srcIP, dstIP net.IP...
function ipChecksum (line 156) | func ipChecksum(header []byte) uint16 {
FILE: examples/xdp_live_frame/xdp.c
function xdp_prog_tx (line 15) | int xdp_prog_tx(struct xdp_md *ctx) {
function xdp_prog_pass (line 22) | int xdp_prog_pass(struct xdp_md *ctx) {
FILE: features/link.go
function HaveBPFLinkUprobeMulti (line 16) | func HaveBPFLinkUprobeMulti() error {
function HaveBPFLinkKprobeMulti (line 66) | func HaveBPFLinkKprobeMulti() error {
function HaveBPFLinkKprobeSession (line 114) | func HaveBPFLinkKprobeSession() error {
FILE: features/link_test.go
function TestHaveBPFLinkUprobeMulti (line 9) | func TestHaveBPFLinkUprobeMulti(t *testing.T) {
function TestHaveBPFLinkKprobeMulti (line 13) | func TestHaveBPFLinkKprobeMulti(t *testing.T) {
function TestHaveBPFLinkKprobeSession (line 17) | func TestHaveBPFLinkKprobeSession(t *testing.T) {
FILE: features/map.go
function HaveMapType (line 18) | func HaveMapType(mt ebpf.MapType) error {
function probeCgroupStorageMap (line 22) | func probeCgroupStorageMap(mt sys.MapType) error {
function probeStorageMap (line 33) | func probeStorageMap(mt sys.MapType) error {
function probeNestedMap (line 55) | func probeNestedMap(mt sys.MapType) error {
function probeMap (line 68) | func probeMap(attr *sys.MapCreateAttr) error {
function createMap (line 79) | func createMap(attr *sys.MapCreateAttr) error {
function init (line 259) | func init() {
type MapFlags (line 271) | type MapFlags
constant BPF_F_NO_PREALLOC (line 275) | BPF_F_NO_PREALLOC = sys.BPF_F_NO_PREALLOC
constant BPF_F_RDONLY_PROG (line 276) | BPF_F_RDONLY_PROG = sys.BPF_F_RDONLY_PROG
constant BPF_F_WRONLY_PROG (line 277) | BPF_F_WRONLY_PROG = sys.BPF_F_WRONLY_PROG
constant BPF_F_MMAPABLE (line 278) | BPF_F_MMAPABLE = sys.BPF_F_MMAPABLE
constant BPF_F_INNER_MAP (line 279) | BPF_F_INNER_MAP = sys.BPF_F_INNER_MAP
function HaveMapFlag (line 286) | func HaveMapFlag(flag MapFlags) (err error) {
function probeMapFlag (line 290) | func probeMapFlag(attr *sys.MapCreateAttr) error {
function init (line 358) | func init() {
FILE: features/map_test.go
function TestHaveMapType (line 13) | func TestHaveMapType(t *testing.T) {
function TestHaveMapFlag (line 17) | func TestHaveMapFlag(t *testing.T) {
function TestHaveMapTypeInvalid (line 21) | func TestHaveMapTypeInvalid(t *testing.T) {
FILE: features/misc.go
function HaveLargeInstructions (line 18) | func HaveLargeInstructions() error {
function HaveBoundedLoops (line 42) | func HaveBoundedLoops() error {
function HaveV2ISA (line 63) | func HaveV2ISA() error {
function HaveV3ISA (line 89) | func HaveV3ISA() error {
function HaveV4ISA (line 115) | func HaveV4ISA() error {
FILE: features/misc_test.go
function TestHaveLargeInstructions (line 9) | func TestHaveLargeInstructions(t *testing.T) {
function TestHaveBoundedLoops (line 13) | func TestHaveBoundedLoops(t *testing.T) {
function TestHaveV2ISA (line 17) | func TestHaveV2ISA(t *testing.T) {
function TestHaveV3ISA (line 21) | func TestHaveV3ISA(t *testing.T) {
function TestHaveV4ISA (line 25) | func TestHaveV4ISA(t *testing.T) {
FILE: features/prog.go
function HaveProgramType (line 20) | func HaveProgramType(pt ebpf.ProgramType) (err error) {
function probeProgram (line 24) | func probeProgram(spec *ebpf.ProgramSpec) error {
function init (line 199) | func init() {
type helperKey (line 209) | type helperKey struct
function HaveProgramHelper (line 236) | func HaveProgramHelper(pt ebpf.ProgramType, helper asm.BuiltinFunc) error {
function haveProgramHelper (line 240) | func haveProgramHelper(pt ebpf.ProgramType, helper asm.BuiltinFunc) error {
function logContainsAll (line 314) | func logContainsAll(log []string, needles ...string) bool {
function helperProbeNotImplemented (line 326) | func helperProbeNotImplemented(pt ebpf.ProgramType) bool {
FILE: features/prog_test.go
function TestMain (line 16) | func TestMain(m *testing.M) {
function TestHaveProgramType (line 20) | func TestHaveProgramType(t *testing.T) {
function TestHaveProgramTypeInvalid (line 24) | func TestHaveProgramTypeInvalid(t *testing.T) {
function TestHaveProgramHelper (line 32) | func TestHaveProgramHelper(t *testing.T) {
function TestHelperProbeNotImplemented (line 89) | func TestHelperProbeNotImplemented(t *testing.T) {
FILE: features/version.go
function LinuxVersionCode (line 12) | func LinuxVersionCode() (uint32, error) {
FILE: fuzz_test.go
function FuzzLoadCollectionSpec (line 9) | func FuzzLoadCollectionSpec(f *testing.F) {
FILE: helpers_test.go
function requireTestmod (line 56) | func requireTestmod(tb testing.TB) {
function requireTestmodOps (line 70) | func requireTestmodOps(tb testing.TB) {
function newMap (line 83) | func newMap(tb testing.TB, spec *MapSpec, opts *MapOptions) (*Map, error) {
function mustNewMap (line 102) | func mustNewMap(tb testing.TB, spec *MapSpec, opts *MapOptions) *Map {
function createMap (line 111) | func createMap(tb testing.TB, typ MapType, maxEntries uint32) *Map {
function createMapInMap (line 123) | func createMapInMap(tb testing.TB, outer, inner MapType) *Map {
function newProgram (line 139) | func newProgram(tb testing.TB, spec *ProgramSpec, opts *ProgramOptions) ...
function mustNewProgram (line 158) | func mustNewProgram(tb testing.TB, spec *ProgramSpec, opts *ProgramOptio...
function createProgram (line 166) | func createProgram(tb testing.TB, typ ProgramType, retval int64) *Program {
function createBasicProgram (line 192) | func createBasicProgram(tb testing.TB) *Program {
function newCollection (line 196) | func newCollection(tb testing.TB, spec *CollectionSpec, opts *Collection...
function mustNewCollection (line 217) | func mustNewCollection(tb testing.TB, spec *CollectionSpec, opts *Collec...
function loadAndAssign (line 224) | func loadAndAssign(tb testing.TB, spec *CollectionSpec, to any, opts *Co...
function mustLoadAndAssign (line 232) | func mustLoadAndAssign(tb testing.TB, spec *CollectionSpec, to any, opts...
function mustRun (line 236) | func mustRun(tb testing.TB, prog *Program, opts *RunOptions) (retval uin...
function fixupMapType (line 266) | func fixupMapType(typ MapType) MapType {
function fixupMapSpec (line 303) | func fixupMapSpec(spec *MapSpec) *MapSpec {
function fixupProgramType (line 317) | func fixupProgramType(typ ProgramType) ProgramType {
function fixupProgramSpec (line 332) | func fixupProgramSpec(spec *ProgramSpec) *ProgramSpec {
function fixupCollectionSpec (line 356) | func fixupCollectionSpec(spec *CollectionSpec) *CollectionSpec {
FILE: info.go
type MapInfo (line 40) | type MapInfo struct
method ID (line 173) | func (mi *MapInfo) ID() (MapID, bool) {
method BTFID (line 185) | func (mi *MapInfo) BTFID() (btf.ID, bool) {
method MapExtra (line 195) | func (mi *MapInfo) MapExtra() (uint64, bool) {
method Memlock (line 204) | func (mi *MapInfo) Memlock() (uint64, bool) {
method Frozen (line 214) | func (mi *MapInfo) Frozen() bool {
function minimalMapInfoFromFd (line 71) | func minimalMapInfoFromFd(fd *sys.FD) (*MapInfo, error) {
function newMapInfoFromFd (line 97) | func newMapInfoFromFd(fd *sys.FD) (*MapInfo, error) {
function readMapInfoFromProc (line 141) | func readMapInfoFromProc(fd *sys.FD, mi *MapInfo) error {
type ProgramStats (line 223) | type ProgramStats struct
function newProgramStatsFromFd (line 242) | func newProgramStatsFromFd(fd *sys.FD) (*ProgramStats, error) {
type programJitedInfo (line 256) | type programJitedInfo struct
type ProgramInfo (line 291) | type ProgramInfo struct
method ID (line 570) | func (pi *ProgramInfo) ID() (ProgramID, bool) {
method CreatedByUID (line 579) | func (pi *ProgramInfo) CreatedByUID() (uint32, bool) {
method BTFID (line 591) | func (pi *ProgramInfo) BTFID() (btf.ID, bool) {
method btfSpec (line 596) | func (pi *ProgramInfo) btfSpec() (*btf.Spec, error) {
method LineInfos (line 630) | func (pi *ProgramInfo) LineInfos() (btf.LineOffsets, error) {
method Instructions (line 671) | func (pi *ProgramInfo) Instructions() (asm.Instructions, error) {
method JitedSize (line 746) | func (pi *ProgramInfo) JitedSize() (uint32, error) {
method TranslatedSize (line 757) | func (pi *ProgramInfo) TranslatedSize() (int, error) {
method MapIDs (line 769) | func (pi *ProgramInfo) MapIDs() ([]MapID, bool) {
method LoadTime (line 778) | func (pi *ProgramInfo) LoadTime() (time.Duration, bool) {
method VerifiedInstructions (line 788) | func (pi *ProgramInfo) VerifiedInstructions() (uint32, bool) {
method JitedKsymAddrs (line 803) | func (pi *ProgramInfo) JitedKsymAddrs() ([]uintptr, bool) {
method JitedInsns (line 825) | func (pi *ProgramInfo) JitedInsns() ([]byte, bool) {
method JitedLineInfos (line 834) | func (pi *ProgramInfo) JitedLineInfos() ([]uint64, bool) {
method JitedFuncLens (line 843) | func (pi *ProgramInfo) JitedFuncLens() ([]uint32, bool) {
method FuncInfos (line 858) | func (pi *ProgramInfo) FuncInfos() (btf.FuncOffsets, error) {
method Memlock (line 881) | func (pi *ProgramInfo) Memlock() (uint64, bool) {
function minimalProgramInfoFromFd (line 330) | func minimalProgramInfoFromFd(fd *sys.FD) (*ProgramInfo, error) {
function newProgramInfoFromFd (line 353) | func newProgramInfoFromFd(fd *sys.FD) (*ProgramInfo, error) {
function readNameFromFunc (line 512) | func readNameFromFunc(pi *ProgramInfo) (string, error) {
function readProgramInfoFromProc (line 540) | func readProgramInfoFromProc(fd *sys.FD, pi *ProgramInfo) error {
function scanFdInfo (line 885) | func scanFdInfo(fd *sys.FD, fields map[string]interface{}) error {
function scanFdInfoReader (line 902) | func scanFdInfoReader(r io.Reader, fields map[string]interface{}) error {
function zero (line 947) | func zero(arg any) bool {
function EnableStats (line 969) | func EnableStats(which uint32) (io.Closer, error) {
FILE: info_test.go
function validateMapInfo (line 52) | func validateMapInfo(t *testing.T, info *MapInfo, spec *MapSpec) {
function TestMapInfo (line 65) | func TestMapInfo(t *testing.T) {
function TestMapInfoFromProc (line 74) | func TestMapInfoFromProc(t *testing.T) {
function TestMapInfoFromProcOuterMap (line 85) | func TestMapInfoFromProcOuterMap(t *testing.T) {
function BenchmarkNewMapFromFD (line 108) | func BenchmarkNewMapFromFD(b *testing.B) {
function BenchmarkMapInfo (line 120) | func BenchmarkMapInfo(b *testing.B) {
function validateProgInfo (line 132) | func validateProgInfo(t *testing.T, spec *ProgramSpec, info *ProgramInfo) {
function TestProgramInfo (line 151) | func TestProgramInfo(t *testing.T) {
function BenchmarkNewProgramFromFD (line 214) | func BenchmarkNewProgramFromFD(b *testing.B) {
function BenchmarkProgramInfo (line 227) | func BenchmarkProgramInfo(b *testing.B) {
function TestProgramInfoProc (line 240) | func TestProgramInfoProc(t *testing.T) {
function TestProgramInfoBTF (line 252) | func TestProgramInfoBTF(t *testing.T) {
function TestProgramInfoMapIDs (line 303) | func TestProgramInfoMapIDs(t *testing.T) {
function TestProgramInfoMapIDsNoMaps (line 338) | func TestProgramInfoMapIDsNoMaps(t *testing.T) {
function TestScanFdInfoReader (line 357) | func TestScanFdInfoReader(t *testing.T) {
function BenchmarkScanFdInfoReader (line 382) | func BenchmarkScanFdInfoReader(b *testing.B) {
function TestProgramStats (line 409) | func TestProgramStats(t *testing.T) {
function BenchmarkStats (line 432) | func BenchmarkStats(b *testing.B) {
function testStats (line 457) | func testStats(tb testing.TB, prog *Program) error {
function TestHaveProgramInfoMapIDs (line 493) | func TestHaveProgramInfoMapIDs(t *testing.T) {
function TestProgInfoExtBTF (line 497) | func TestProgInfoExtBTF(t *testing.T) {
function TestInfoExportedFields (line 558) | func TestInfoExportedFields(t *testing.T) {
function TestZero (line 590) | func TestZero(t *testing.T) {
FILE: internal/deque.go
type Deque (line 6) | type Deque struct
method Reset (line 13) | func (dq *Deque[T]) Reset() {
method Empty (line 23) | func (dq *Deque[T]) Empty() bool {
method Push (line 28) | func (dq *Deque[T]) Push(e T) {
method Shift (line 35) | func (dq *Deque[T]) Shift() T {
method Pop (line 50) | func (dq *Deque[T]) Pop() T {
method Grow (line 66) | func (dq *Deque[T]) Grow(n int) {
FILE: internal/deque_test.go
function TestDeque (line 5) | func TestDeque(t *testing.T) {
FILE: internal/efw/enums.go
function EbpfGetEbpfAttachType (line 21) | func EbpfGetEbpfAttachType(attachType uint32) (windows.GUID, error) {
function EbpfGetBpfProgramType (line 42) | func EbpfGetBpfProgramType(programType windows.GUID) (uint32, error) {
function EbpfGetBpfAttachType (line 58) | func EbpfGetBpfAttachType(attachType windows.GUID) (uint32, error) {
FILE: internal/efw/error_reporting.go
function init (line 15) | func init() {
function configureCRTErrorReporting (line 36) | func configureCRTErrorReporting() error {
function isDebuggerPresent (line 142) | func isDebuggerPresent() bool {
FILE: internal/efw/error_reporting_test.go
function TestConfigureErrorReporting (line 11) | func TestConfigureErrorReporting(t *testing.T) {
function TestIsDebuggerPresent (line 15) | func TestIsDebuggerPresent(t *testing.T) {
FILE: internal/efw/fd.go
function EbpfCloseFd (line 13) | func EbpfCloseFd(fd int) error {
function EbpfDuplicateFd (line 25) | func EbpfDuplicateFd(fd int) (int, error) {
FILE: internal/efw/map.go
function EbpfRingBufferMapMapBuffer (line 24) | func EbpfRingBufferMapMapBuffer(mapFd int) (consumer, producer, data *ui...
function EbpfRingBufferMapUnmapBuffer (line 51) | func EbpfRingBufferMapUnmapBuffer(mapFd int, consumer, producer, data *u...
function EbpfMapSetWaitHandle (line 74) | func EbpfMapSetWaitHandle(mapFd int, index uint64, handle windows.Handle...
function EbpfRingBufferMapWrite (line 96) | func EbpfRingBufferMapWrite(ringBufferMapFd int, data []byte) error {
FILE: internal/efw/module.go
type FD (line 16) | type FD
type Size (line 21) | type Size
type Int (line 24) | type Int
type ObjectType (line 29) | type ObjectType
constant EBPF_OBJECT_UNKNOWN (line 32) | EBPF_OBJECT_UNKNOWN ObjectType = iota
constant EBPF_OBJECT_MAP (line 33) | EBPF_OBJECT_MAP
constant EBPF_OBJECT_LINK (line 34) | EBPF_OBJECT_LINK
constant EBPF_OBJECT_PROGRAM (line 35) | EBPF_OBJECT_PROGRAM
FILE: internal/efw/native.go
function EbpfObjectLoadNativeFds (line 23) | func EbpfObjectLoadNativeFds(fileName string, mapFds []FD, programFds []...
FILE: internal/efw/object.go
constant _EBPF_MAX_PIN_PATH_LENGTH (line 13) | _EBPF_MAX_PIN_PATH_LENGTH = 256
function EbpfObjectGetInfoByFd (line 26) | func EbpfObjectGetInfoByFd(fd int, info unsafe.Pointer, info_size *uint3...
function EbpfObjectUnpin (line 45) | func EbpfObjectUnpin(path string) error {
function EbpfGetNextPinnedObjectPath (line 70) | func EbpfGetNextPinnedObjectPath(startPath string, objectType ObjectType...
function EbpfCanonicalizePinPath (line 99) | func EbpfCanonicalizePinPath(input string) (string, error) {
FILE: internal/efw/proc.go
type proc (line 20) | type proc struct
method Find (line 28) | func (p proc) Find() (uintptr, error) {
function newProc (line 24) | func newProc(name string) proc {
function uint32Result (line 39) | func uint32Result(r1, _ uintptr, _ syscall.Errno) uint32 {
function errorResult (line 44) | func errorResult(r1, _ uintptr, errNo syscall.Errno) error {
FILE: internal/efw/proc_test.go
function TestNewProc (line 11) | func TestNewProc(t *testing.T) {
function TestCall (line 16) | func TestCall(t *testing.T) {
FILE: internal/efw/program.go
function EbpfProgramAttachFds (line 24) | func EbpfProgramAttachFds(fd int, attachType windows.GUID, params unsafe...
FILE: internal/efw/result.go
type Result (line 6) | type Result
method Error (line 48) | func (r Result) Error() string {
constant EBPF_SUCCESS (line 11) | EBPF_SUCCESS Result = iota
constant EBPF_VERIFICATION_FAILED (line 12) | EBPF_VERIFICATION_FAILED
constant EBPF_JIT_COMPILATION_FAILED (line 13) | EBPF_JIT_COMPILATION_FAILED
constant EBPF_PROGRAM_LOAD_FAILED (line 14) | EBPF_PROGRAM_LOAD_FAILED
constant EBPF_INVALID_FD (line 15) | EBPF_INVALID_FD
constant EBPF_INVALID_OBJECT (line 16) | EBPF_INVALID_OBJECT
constant EBPF_INVALID_ARGUMENT (line 17) | EBPF_INVALID_ARGUMENT
constant EBPF_OBJECT_NOT_FOUND (line 18) | EBPF_OBJECT_NOT_FOUND
constant EBPF_OBJECT_ALREADY_EXISTS (line 19) | EBPF_OBJECT_ALREADY_EXISTS
constant EBPF_FILE_NOT_FOUND (line 20) | EBPF_FILE_NOT_FOUND
constant EBPF_ALREADY_PINNED (line 21) | EBPF_ALREADY_PINNED
constant EBPF_NOT_PINNED (line 22) | EBPF_NOT_PINNED
constant EBPF_NO_MEMORY (line 23) | EBPF_NO_MEMORY
constant EBPF_PROGRAM_TOO_LARGE (line 24) | EBPF_PROGRAM_TOO_LARGE
constant EBPF_RPC_EXCEPTION (line 25) | EBPF_RPC_EXCEPTION
constant EBPF_ALREADY_INITIALIZED (line 26) | EBPF_ALREADY_INITIALIZED
constant EBPF_ELF_PARSING_FAILED (line 27) | EBPF_ELF_PARSING_FAILED
constant EBPF_FAILED (line 28) | EBPF_FAILED
constant EBPF_OPERATION_NOT_SUPPORTED (line 29) | EBPF_OPERATION_NOT_SUPPORTED
constant EBPF_KEY_NOT_FOUND (line 30) | EBPF_KEY_NOT_FOUND
constant EBPF_ACCESS_DENIED (line 31) | EBPF_ACCESS_DENIED
constant EBPF_BLOCKED_BY_POLICY (line 32) | EBPF_BLOCKED_BY_POLICY
constant EBPF_ARITHMETIC_OVERFLOW (line 33) | EBPF_ARITHMETIC_OVERFLOW
constant EBPF_EXTENSION_FAILED_TO_LOAD (line 34) | EBPF_EXTENSION_FAILED_TO_LOAD
constant EBPF_INSUFFICIENT_BUFFER (line 35) | EBPF_INSUFFICIENT_BUFFER
constant EBPF_NO_MORE_KEYS (line 36) | EBPF_NO_MORE_KEYS
constant EBPF_KEY_ALREADY_EXISTS (line 37) | EBPF_KEY_ALREADY_EXISTS
constant EBPF_NO_MORE_TAIL_CALLS (line 38) | EBPF_NO_MORE_TAIL_CALLS
constant EBPF_PENDING (line 39) | EBPF_PENDING
constant EBPF_OUT_OF_SPACE (line 40) | EBPF_OUT_OF_SPACE
constant EBPF_CANCELED (line 41) | EBPF_CANCELED
constant EBPF_INVALID_POINTER (line 42) | EBPF_INVALID_POINTER
constant EBPF_TIMEOUT (line 43) | EBPF_TIMEOUT
constant EBPF_STALE_ID (line 44) | EBPF_STALE_ID
constant EBPF_INVALID_STATE (line 45) | EBPF_INVALID_STATE
function resultToError (line 52) | func resultToError(res Result) error {
FILE: internal/efw/result_string_windows.go
function _ (line 7) | func _() {
constant _Result_name (line 48) | _Result_name = "EBPF_SUCCESSEBPF_VERIFICATION_FAILEDEBPF_JIT_COMPILATION...
method String (line 52) | func (i Result) String() string {
FILE: internal/efw/result_test.go
function TestResultToError (line 11) | func TestResultToError(t *testing.T) {
FILE: internal/efw/structs.go
constant _BPF_OBJ_NAME_LEN (line 8) | _BPF_OBJ_NAME_LEN = 64
type BpfMapInfo (line 11) | type BpfMapInfo struct
type BpfProgInfo (line 25) | type BpfProgInfo struct
FILE: internal/elf.go
type SafeELFFile (line 9) | type SafeELFFile struct
method Symbols (line 62) | func (se *SafeELFFile) Symbols() (syms []elf.Symbol, err error) {
method DynamicSymbols (line 78) | func (se *SafeELFFile) DynamicSymbols() (syms []elf.Symbol, err error) {
method SectionsByType (line 94) | func (se *SafeELFFile) SectionsByType(typ elf.SectionType) []*elf.Sect...
function NewSafeELFFile (line 19) | func NewSafeELFFile(r io.ReaderAt) (safe *SafeELFFile, err error) {
function OpenSafeELFFile (line 42) | func OpenSafeELFFile(path string) (safe *SafeELFFile, err error) {
FILE: internal/epoll/poller.go
type Poller (line 28) | type Poller struct
method Close (line 90) | func (p *Poller) Close() error {
method Add (line 130) | func (p *Poller) Add(fd int, id int) error {
method Wait (line 166) | func (p *Poller) Wait(events []unix.EpollEvent, deadline time.Time) (i...
method wakeWaitForClose (line 223) | func (p *Poller) wakeWaitForClose() error {
method Flush (line 235) | func (p *Poller) Flush() error {
function New (line 40) | func New() (_ *Poller, err error) {
type temporaryError (line 218) | type temporaryError interface
type eventFd (line 252) | type eventFd struct
method close (line 268) | func (efd *eventFd) close() error {
method add (line 272) | func (efd *eventFd) add(n uint64) error {
method read (line 279) | func (efd *eventFd) read() (uint64, error) {
function newEventFd (line 259) | func newEventFd() (*eventFd, error) {
FILE: internal/epoll/poller_test.go
function TestPoller (line 17) | func TestPoller(t *testing.T) {
function TestPollerDeadline (line 86) | func TestPollerDeadline(t *testing.T) {
function TestPollerFlush (line 114) | func TestPollerFlush(t *testing.T) {
function mustNewPoller (line 135) | func mustNewPoller(t *testing.T) (*eventFd, *Poller) {
FILE: internal/errors.go
function ErrorWithLog (line 15) | func ErrorWithLog(source string, err error, log []byte) *VerifierError {
type VerifierError (line 43) | type VerifierError struct
method Unwrap (line 51) | func (le *VerifierError) Unwrap() error {
method Error (line 55) | func (le *VerifierError) Error() string {
method Format (line 128) | func (le *VerifierError) Format(f fmt.State, verb rune) {
function includePreviousLine (line 91) | func includePreviousLine(line string) bool {
FILE: internal/errors_test.go
function TestVerifierErrorWhitespace (line 11) | func TestVerifierErrorWhitespace(t *testing.T) {
function TestVerifierErrorWrapping (line 34) | func TestVerifierErrorWrapping(t *testing.T) {
function TestVerifierErrorSummary (line 45) | func TestVerifierErrorSummary(t *testing.T) {
function readErrorFromFile (line 69) | func readErrorFromFile(tb testing.TB, file string) *VerifierError {
FILE: internal/feature.go
type UnsupportedFeatureError (line 24) | type UnsupportedFeatureError struct
method Error (line 37) | func (ufe *UnsupportedFeatureError) Error() string {
method Is (line 45) | func (ufe *UnsupportedFeatureError) Is(target error) bool {
type FeatureTest (line 52) | type FeatureTest struct
method execute (line 109) | func (ft *FeatureTest) execute() error {
type FeatureTestFn (line 73) | type FeatureTestFn
function NewFeatureTest (line 81) | func NewFeatureTest(name string, fn FeatureTestFn, versions ...string) f...
type FeatureMatrix (line 163) | type FeatureMatrix
method Result (line 170) | func (fm FeatureMatrix[K]) Result(key K) error {
type FeatureCache (line 186) | type FeatureCache struct
function NewFeatureCache (line 192) | func NewFeatureCache[K comparable](newTest func(K) *FeatureTest) *Featur...
method Result (line 199) | func (fc *FeatureCache[K]) Result(key K) error {
method retrieve (line 208) | func (fc *FeatureCache[K]) retrieve(key K) *FeatureTest {
FILE: internal/feature_test.go
function TestMain (line 15) | func TestMain(m *testing.M) {
function TestFeatureTest (line 19) | func TestFeatureTest(t *testing.T) {
function TestFeatureTestNotSupportedOnOS (line 80) | func TestFeatureTestNotSupportedOnOS(t *testing.T) {
FILE: internal/io.go
function NewBufferedSectionReader (line 25) | func NewBufferedSectionReader(ra io.ReaderAt, off, n int64) *bufio.Reader {
type DiscardZeroes (line 40) | type DiscardZeroes struct
method Write (line 42) | func (DiscardZeroes) Write(p []byte) (int, error) {
function ReadAllCompressed (line 52) | func ReadAllCompressed(file string) ([]byte, error) {
function ReadUint64FromFile (line 71) | func ReadUint64FromFile(format string, path ...string) (uint64, error) {
type uint64FromFileKey (line 90) | type uint64FromFileKey struct
function ReadUint64FromFileOnce (line 102) | func ReadUint64FromFileOnce(format string, path ...string) (uint64, erro...
FILE: internal/io_test.go
function TestDiscardZero (line 9) | func TestDiscardZero(t *testing.T) {
FILE: internal/kallsyms/cache.go
type cache (line 5) | type cache struct
method Load (line 9) | func (c *cache[K, V]) Load(key K) (value V, _ bool) {
method Store (line 18) | func (c *cache[K, V]) Store(key K, value V) {
FILE: internal/kallsyms/kallsyms.go
function AssignAddresses (line 26) | func AssignAddresses(symbols map[string]uint64) error {
function assignAddresses (line 74) | func assignAddresses(f io.Reader, symbols map[string]uint64) error {
type ksym (line 119) | type ksym struct
function parseSymbol (line 133) | func parseSymbol(r *reader, types []rune) (s ksym, err error, skip bool) {
FILE: internal/kallsyms/kallsyms_test.go
function TestParseSyms (line 30) | func TestParseSyms(t *testing.T) {
function TestParseProcKallsyms (line 44) | func TestParseProcKallsyms(t *testing.T) {
function TestAssignAddressesCaching (line 56) | func TestAssignAddressesCaching(t *testing.T) {
function TestAssignAddresses (line 75) | func TestAssignAddresses(t *testing.T) {
function BenchmarkAssignAddresses (line 96) | func BenchmarkAssignAddresses(b *testing.B) {
function BenchmarkAssignAddressesKallsyms (line 111) | func BenchmarkAssignAddressesKallsyms(b *testing.B) {
function mustOpenProcKallsyms (line 131) | func mustOpenProcKallsyms(tb testing.TB) *os.File {
FILE: internal/kallsyms/reader.go
type reader (line 16) | type reader struct
method Bytes (line 31) | func (r *reader) Bytes() []byte {
method Text (line 36) | func (r *reader) Text() string {
method Line (line 49) | func (r *reader) Line() bool {
method Word (line 72) | func (r *reader) Word() bool {
method Err (line 87) | func (r *reader) Err() error {
function newReader (line 24) | func newReader(r io.Reader) *reader {
FILE: internal/kallsyms/reader_test.go
function TestReader (line 10) | func TestReader(t *testing.T) {
FILE: internal/kconfig/kconfig.go
function Parse (line 23) | func Parse(source io.ReaderAt, filter map[string]struct{}) (map[string]s...
function processKconfigLine (line 63) | func processKconfigLine(line []byte, m map[string]string, filter map[str...
function PutValue (line 100) | func PutValue(data []byte, typ btf.Type, value string) error {
type triState (line 117) | type triState
constant TriNo (line 120) | TriNo triState = 0
constant TriYes (line 121) | TriYes triState = 1
constant TriModule (line 122) | TriModule triState = 2
function putValueTri (line 125) | func putValueTri(data []byte, typ btf.Type, value string) error {
function putValueString (line 173) | func putValueString(data []byte, typ btf.Type, value string) error {
function putValueNumber (line 207) | func putValueNumber(data []byte, typ btf.Type, value string) error {
function PutInteger (line 241) | func PutInteger(data []byte, integer *btf.Int, n uint64) error {
FILE: internal/kconfig/kconfig_test.go
function BenchmarkParse (line 14) | func BenchmarkParse(b *testing.B) {
function BenchmarkParseFiltered (line 31) | func BenchmarkParseFiltered(b *testing.B) {
function TestParse (line 53) | func TestParse(t *testing.T) {
function TestParseFiltered (line 80) | func TestParseFiltered(t *testing.T) {
function TestParseGzipped (line 100) | func TestParseGzipped(t *testing.T) {
function TestParseGzippedFiltered (line 115) | func TestParseGzippedFiltered(t *testing.T) {
function TestProcessKconfigBadLine (line 135) | func TestProcessKconfigBadLine(t *testing.T) {
function TestPutValue (line 147) | func TestPutValue(t *testing.T) {
function TestPutInteger (line 413) | func TestPutInteger(t *testing.T) {
function TestPutIntegerError (line 519) | func TestPutIntegerError(t *testing.T) {
FILE: internal/linux/auxv.go
type auxvPairReader (line 12) | type auxvPairReader interface
constant _AT_NULL (line 19) | _AT_NULL = 0
constant _AT_SYSINFO_EHDR (line 20) | _AT_SYSINFO_EHDR = 33
type auxvRuntimeReader (line 23) | type auxvRuntimeReader struct
method Close (line 28) | func (r *auxvRuntimeReader) Close() error {
method ReadAuxvPair (line 32) | func (r *auxvRuntimeReader) ReadAuxvPair() (uint64, uint64, error) {
function newAuxvRuntimeReader (line 49) | func newAuxvRuntimeReader() (auxvPairReader, error) {
FILE: internal/linux/auxv_test.go
type auxvFileReader (line 15) | type auxvFileReader struct
method Close (line 21) | func (r *auxvFileReader) Close() error {
method ReadAuxvPair (line 33) | func (r *auxvFileReader) ReadAuxvPair() (tag, value uint64, _ error) {
type auxvPair32 (line 25) | type auxvPair32 struct
type auxvPair64 (line 29) | type auxvPair
Condensed preview — 638 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,382K chars).
[
{
"path": ".clang-format",
"chars": 863,
"preview": "---\nLanguage: Cpp\nBasedOnStyle: LLVM\nAlignAfterOpenBracket: DontAlign\nAlignConsecutiveAssignments: true\nAlignE"
},
{
"path": ".gitattributes",
"chars": 140,
"preview": "# Force line ending normalisation\n*\ttext=auto\n# Show types.go in the PR diff view by default\ninternal/sys/types.go lingu"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.yml",
"chars": 858,
"preview": "name: Bug report\ndescription: Create a report to help us improve\nlabels: [\"bug\"]\nassignees: []\n\nbody:\n - type: markdown"
},
{
"path": ".github/ISSUE_TEMPLATE/config.yml",
"chars": 245,
"preview": "contact_links:\n - name: Questions\n url: https://github.com/cilium/ebpf/discussions/categories/q-a\n about: Please "
},
{
"path": ".github/dependabot.yml",
"chars": 507,
"preview": "---\nversion: 2\nupdates:\n - package-ecosystem: \"pip\"\n directory: \"/docs\"\n schedule:\n interval: \"monthly\"\n "
},
{
"path": ".github/workflows/apidiff.yml",
"chars": 827,
"preview": "name: apidiff\non:\n push:\n branches: [ \"main\" ]\n pull_request:\n branches: [ \"main\" ]\n\njobs:\n go-apidiff:\n nam"
},
{
"path": ".github/workflows/ci.yml",
"chars": 14323,
"preview": "name: ci\non:\n push:\n branches: [ \"main\" ]\n pull_request:\n branches: [ \"main\" ]\n\nenv:\n TMPDIR: /tmp\n CI_MAX_KER"
},
{
"path": ".github/workflows/trusted.yml",
"chars": 2377,
"preview": "on:\n workflow_run:\n workflows: [\"apidiff\"]\n types:\n - completed\n\npermissions:\n pull-requests: write\n\njobs:\n"
},
{
"path": ".gitignore",
"chars": 206,
"preview": "# Binaries for programs and plugins\n*.exe\n*.exe~\n*.dll\n*.so\n*.dylib\n*.o\n!*_bpf*.o\n\n# Test binary, build with `go test -c"
},
{
"path": ".golangci.yaml",
"chars": 545,
"preview": "version: \"2\"\nlinters:\n default: none\n enable:\n - depguard\n - govet\n - ineffassign\n - misspell\n - unused"
},
{
"path": ".vimto.toml",
"chars": 260,
"preview": "kernel=\"ghcr.io/cilium/ci-kernels:stable\"\nsmp=\"cpus=2\"\nmemory=\"1G\"\nuser=\"root\"\nsetup=[\n \"mount -t cgroup2 -o nosuid,noe"
},
{
"path": "CODEOWNERS",
"chars": 380,
"preview": "* @cilium/ebpf-lib-maintainers\n\n/features/ @rgo3\n/link/ @mmat11\n\n/perf/ @florianl\n/ringbuf/ @florianl\n\n/btf/ @dylandreim"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 3245,
"preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nIn the interest of fostering an open and welcoming environment, w"
},
{
"path": "CONTRIBUTING.md",
"chars": 192,
"preview": "# Contributing to ebpf-go\n\nWant to contribute to ebpf-go? There are a few things you need to know.\n\nWe wrote a [contribu"
},
{
"path": "LICENSE",
"chars": 1142,
"preview": "MIT License\n\nCopyright (c) 2017 Nathan Sweet\nCopyright (c) 2018, 2019 Cloudflare\nCopyright (c) 2019 Authors of Cilium\n\nP"
},
{
"path": "MAINTAINERS.md",
"chars": 141,
"preview": "# Maintainers\n\nMaintainers can be found in the [Cilium Maintainers file](https://github.com/cilium/community/blob/main/r"
},
{
"path": "Makefile",
"chars": 4254,
"preview": "# The development version of clang is distributed as the 'clang' binary,\n# while stable/released versions have a version"
},
{
"path": "README.md",
"chars": 3371,
"preview": "# eBPF\n\n[](https://pkg.go.dev/github.com/cilium/ebpf)\n\n![Hon"
},
{
"path": "asm/alu.go",
"chars": 4112,
"preview": "package asm\n\n//go:generate go tool stringer -output alu_string.go -type=Source,Endianness,ALUOp\n\n// Source of ALU / ALU6"
},
{
"path": "asm/alu_string.go",
"chars": 2672,
"preview": "// Code generated by \"stringer -output alu_string.go -type=Source,Endianness,ALUOp\"; DO NOT EDIT.\n\npackage asm\n\nimport \""
},
{
"path": "asm/doc.go",
"chars": 62,
"preview": "// Package asm is an assembler for eBPF bytecode.\npackage asm\n"
},
{
"path": "asm/dsl_test.go",
"chars": 1383,
"preview": "package asm\n\nimport (\n\t\"testing\"\n)\n\nfunc TestDSL(t *testing.T) {\n\ttestcases := []struct {\n\t\tname string\n\t\thave Instructi"
},
{
"path": "asm/func.go",
"chars": 650,
"preview": "package asm\n\nimport \"github.com/cilium/ebpf/internal/platform\"\n\n//go:generate go tool stringer -output func_string.go -t"
},
{
"path": "asm/func_lin.go",
"chars": 14821,
"preview": "// Code generated by internal/cmd/genfunctions.awk; DO NOT EDIT.\n\npackage asm\n\n// Code in this file is derived from Lin"
},
{
"path": "asm/func_string.go",
"chars": 13267,
"preview": "// Code generated by \"stringer -output func_string.go -type=BuiltinFunc\"; DO NOT EDIT.\n\npackage asm\n\nimport \"strconv\"\n\nf"
},
{
"path": "asm/func_win.go",
"chars": 2874,
"preview": "// Code generated by internal/cmd/genwinfunctions.awk; DO NOT EDIT.\n\npackage asm\n\n// Code in this file is derived from e"
},
{
"path": "asm/instruction.go",
"chars": 26172,
"preview": "package asm\n\nimport (\n\t\"crypto/sha1\"\n\t\"crypto/sha256\"\n\t\"encoding/binary\"\n\t\"encoding/hex\"\n\t\"errors\"\n\t\"fmt\"\n\t\"hash\"\n\t\"io\"\n"
},
{
"path": "asm/instruction_test.go",
"chars": 14122,
"preview": "package asm\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"encoding/hex\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"testing\"\n\n\t\"github.com/go-quick"
},
{
"path": "asm/jump.go",
"chars": 3639,
"preview": "package asm\n\n//go:generate go tool stringer -output jump_string.go -type=JumpOp\n\n// JumpOp affect control flow.\n//\n//\tms"
},
{
"path": "asm/jump_string.go",
"chars": 1214,
"preview": "// Code generated by \"stringer -output jump_string.go -type=JumpOp\"; DO NOT EDIT.\n\npackage asm\n\nimport \"strconv\"\n\nfunc _"
},
{
"path": "asm/load_store.go",
"chars": 8848,
"preview": "package asm\n\nimport \"fmt\"\n\n//go:generate go tool stringer -output load_store_string.go -type=Mode,Size\n\n// Mode for load"
},
{
"path": "asm/load_store_string.go",
"chars": 1727,
"preview": "// Code generated by \"stringer -output load_store_string.go -type=Mode,Size\"; DO NOT EDIT.\n\npackage asm\n\nimport \"strconv"
},
{
"path": "asm/metadata.go",
"chars": 1837,
"preview": "package asm\n\n// Metadata contains metadata about an instruction.\ntype Metadata struct {\n\thead *metaElement\n}\n\ntype metaE"
},
{
"path": "asm/metadata_test.go",
"chars": 2109,
"preview": "package asm\n\nimport (\n\t\"testing\"\n\t\"unsafe\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc TestMetadata(t *testing.T) {\n\tvar m Me"
},
{
"path": "asm/opcode.go",
"chars": 8119,
"preview": "package asm\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n)\n\n//go:generate go tool stringer -output opcode_string.go -type=Class\n\n// Class"
},
{
"path": "asm/opcode_string.go",
"chars": 826,
"preview": "// Code generated by \"stringer -output opcode_string.go -type=Class\"; DO NOT EDIT.\n\npackage asm\n\nimport \"strconv\"\n\nfunc "
},
{
"path": "asm/opcode_test.go",
"chars": 927,
"preview": "package asm\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc TestGetSetJumpOp(t *testing.T) {\n\ttest :="
},
{
"path": "asm/register.go",
"chars": 859,
"preview": "package asm\n\nimport (\n\t\"fmt\"\n)\n\n// Register is the source or destination of most operations.\ntype Register uint8\n\n// R0 "
},
{
"path": "attachtype_string.go",
"chars": 4379,
"preview": "// Code generated by \"stringer -type AttachType -trimprefix Attach\"; DO NOT EDIT.\n\npackage ebpf\n\nimport \"strconv\"\n\nfunc "
},
{
"path": "btf/btf.go",
"chars": 13457,
"preview": "package btf\n\nimport (\n\t\"debug/elf\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"iter\"\n\t\"maps\"\n\t\"math\"\n\t\"os\"\n\t\"reflect\"\n\t\"slices\"\n\n\t\"github.c"
},
{
"path": "btf/btf_test.go",
"chars": 14570,
"preview": "package btf\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io/fs\"\n\t\"os\"\n\t\"runtime\"\n\t\"sync\"\n\t\"sync/atomic\"\n\t\"te"
},
{
"path": "btf/btf_types.go",
"chars": 12209,
"preview": "package btf\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"unsafe\"\n)\n\n//go:generate go tool stringer -linecomment -outp"
},
{
"path": "btf/btf_types_string.go",
"chars": 2442,
"preview": "// Code generated by \"stringer -linecomment -output=btf_types_string.go -type=FuncLinkage,VarLinkage,btfKind\"; DO NOT ED"
},
{
"path": "btf/core.go",
"chars": 37945,
"preview": "package btf\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/cilium/"
},
{
"path": "btf/core_reloc_test.go",
"chars": 4030,
"preview": "package btf_test\n\nimport (\n\t\"bytes\"\n\t\"io\"\n\t\"os\"\n\t\"slices\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf\"\n\t\"github.com/"
},
{
"path": "btf/core_test.go",
"chars": 23976,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"slices\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/google/go-cmp/cmp\"\n\n\t\"github."
},
{
"path": "btf/dedup.go",
"chars": 15041,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"hash/maphash\"\n\t\"slices\"\n)\n\n// deduper deduplicates BTF types by finding all typ"
},
{
"path": "btf/dedup_test.go",
"chars": 3025,
"preview": "package btf\n\nimport (\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc countTypes(typs ...Type) int {\n\ti := 0\n\tvisited "
},
{
"path": "btf/doc.go",
"chars": 228,
"preview": "// Package btf handles data encoded according to the BPF Type Format.\n//\n// The canonical documentation lives in the Lin"
},
{
"path": "btf/ext_info.go",
"chars": 22842,
"preview": "package btf\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"sort\"\n\n\t\"github.com/cilium/ebpf/asm\"\n"
},
{
"path": "btf/ext_info_test.go",
"chars": 1425,
"preview": "package btf\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf/internal\"\n\n\t\"github.co"
},
{
"path": "btf/feature.go",
"chars": 3344,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"math\"\n\n\t\"github.com/cilium/ebpf/internal\"\n\t\"github.com/cilium/ebpf/internal/sys\"\n\t\"git"
},
{
"path": "btf/feature_test.go",
"chars": 669,
"preview": "package btf\n\nimport (\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf/internal/testutils\"\n)\n\nfunc TestHaveBTF(t *testing.T) {\n\ttest"
},
{
"path": "btf/format.go",
"chars": 7798,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nvar errNestedTooDeep = errors.New(\"nested too deep\")\n\n// GoFormatte"
},
{
"path": "btf/format_test.go",
"chars": 6697,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"go/format\"\n\t\"math\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestGoTypeDeclaration(t *testi"
},
{
"path": "btf/fuzz_test.go",
"chars": 1483,
"preview": "package btf\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"io\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n\n\t\"github.com/c"
},
{
"path": "btf/handle.go",
"chars": 8340,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"math\"\n\t\"os\"\n\n\t\"github.com/cilium/ebpf/internal\"\n\t\"github.com/cilium/ebpf/intern"
},
{
"path": "btf/handle_test.go",
"chars": 2119,
"preview": "package btf_test\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf/btf\"\n\t\"github.com/cilium/ebpf/internal/testutils\""
},
{
"path": "btf/kernel.go",
"chars": 7901,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"slices\"\n\t\"sort\"\n\t\"sync\"\n\n\t\"github.com/cilium/"
},
{
"path": "btf/kernel_test.go",
"chars": 2415,
"preview": "package btf\n\nimport (\n\t\"os\"\n\t\"runtime\"\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf/internal/testutils\"\n\n\t\"github.com/go-quickte"
},
{
"path": "btf/marshal.go",
"chars": 17011,
"preview": "package btf\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"maps\"\n\t\"math\"\n\t\"slices\"\n\t\"sync\"\n\t\"unsafe\"\n\n\t\"github.com/cili"
},
{
"path": "btf/marshal_test.go",
"chars": 6845,
"preview": "package btf\n\nimport (\n\t\"math\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n\t\"github.com/google/go-cmp/cmp\"\n\n\t\"github.com/ci"
},
{
"path": "btf/strings.go",
"chars": 4780,
"preview": "package btf\n\nimport (\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"maps\"\n\t\"strings\"\n\t\"sync\"\n)\n\n// stringTable contains a sequence o"
},
{
"path": "btf/strings_test.go",
"chars": 2705,
"preview": "package btf\n\nimport (\n\t\"bytes\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc TestStringTable(t *testing.T"
},
{
"path": "btf/testdata/bpf_core_read.h",
"chars": 18423,
"preview": "/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */\n#ifndef __BPF_CORE_READ_H__\n#define __BPF_CORE_READ_H__\n\n/*\n *"
},
{
"path": "btf/testdata/fuzz/FuzzExtInfo/50a33736610b4a0945179db4c8a88e8247b05fbb25f50ed81e5393baf29bc5bc",
"chars": 143,
"preview": "go test fuzz v1\n[]byte(\"\\x9f\\xeb\\x01\\x00\\x1c\\x00\\x00\\x00\\x00\\x00\\x00\\x00000\\x10\\x00\\x00\\x00\\x000000\\xf3\\xff\\xff\\xff0\\x00"
},
{
"path": "btf/testdata/fuzz/FuzzExtInfo/72534f53bd90cb52a017013499b11511535c1295bf0e22f856148c02454c323e",
"chars": 116,
"preview": "go test fuzz v1\n[]byte(\"\\x9f\\xeb\\x01\\x00\\x18\\x00\\x00\\x00\\x00\\x00\\x00\\x000000000000000\\x00\\x00\\x000000\")\n[]byte(\"0\")\n"
},
{
"path": "btf/testdata/fuzz/FuzzExtInfo/a87a26efa64ed50b598ae8e333301d57d5f234527730f042d68ccc736e90c9fa",
"chars": 128,
"preview": "go test fuzz v1\n[]byte(\"\\x9f\\xeb\\x01\\x00\\x1c\\x00\\x00\\x00\\x00\\x00\\x00\\x000000\\xe8\\xff\\xff\\xff000000000\\x00\\x00\\x00\")\n[]by"
},
{
"path": "btf/testdata/relocs.c",
"chars": 6403,
"preview": "#include \"../../testdata/common.h\"\n#include \"bpf_core_read.h\"\n\nenum e {\n\tZERO = 0,\n\tONE,\n\tTWO,\n};\n\nenum e64 {\n\tLARGE = 0"
},
{
"path": "btf/testdata/relocs_enum.c",
"chars": 450,
"preview": "#include \"bpf_core_read.h\"\n\nenum cgroup_subsys_id {\n\tcpuset_cgrp_id,\n\tcpuset_cgrp_id_lublub,\n\tCGROUP_SUBSYS_COUNT,\n};\n\n#"
},
{
"path": "btf/testdata/relocs_read.c",
"chars": 2477,
"preview": "#include \"../../testdata/common.h\"\n#include \"bpf_core_read.h\"\n\n// Struct with the members declared in the wrong order. A"
},
{
"path": "btf/testdata/relocs_read_tgt.c",
"chars": 698,
"preview": "/*\n\tThis file exists to emit ELFs with specific BTF types to use as target BTF\n\tin tests. It can be made redundant when "
},
{
"path": "btf/testdata/tags.c",
"chars": 763,
"preview": "#include \"../../testdata/common.h\"\n\n#define tagA __attribute__((btf_decl_tag(\"a\")))\n#define tagB __attribute__((btf_decl"
},
{
"path": "btf/traversal.go",
"chars": 3422,
"preview": "package btf\n\nimport (\n\t\"fmt\"\n\t\"iter\"\n)\n\n// Functions to traverse a cyclic graph of types. The below was very useful:\n// "
},
{
"path": "btf/traversal_test.go",
"chars": 2390,
"preview": "package btf\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc TestPostorderTraversal(t *testing.T) {\n\tp"
},
{
"path": "btf/types.go",
"chars": 21643,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math\"\n\t\"strings\"\n\n\t\"github.com/cilium/ebpf/asm\"\n\t\"github.com/cilium/ebpf/"
},
{
"path": "btf/types_test.go",
"chars": 15266,
"preview": "package btf\n\nimport (\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n\t\"github.com/google"
},
{
"path": "btf/unmarshal.go",
"chars": 18804,
"preview": "package btf\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"fmt\"\n\t\"hash/maphash\"\n\t\"io\"\n\t\"iter\"\n\t\"maps\"\n\t\"math\"\n\t\"slices\"\n\t\"sync\""
},
{
"path": "btf/unmarshal_test.go",
"chars": 787,
"preview": "package btf\n\nimport (\n\t\"iter\"\n\t\"math\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc TestFuzzyStringIndex(t *testing."
},
{
"path": "btf/workarounds.go",
"chars": 659,
"preview": "package btf\n\n// datasecResolveWorkaround ensures that certain vars in a Datasec are added\n// to a Spec before the Datase"
},
{
"path": "btf/workarounds_test.go",
"chars": 1501,
"preview": "package btf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf/internal\"\n\t\"github.com/cilium/ebpf/internal/"
},
{
"path": "cmd/bpf2go/README.md",
"chars": 1463,
"preview": "bpf2go\n===\n\n`bpf2go` compiles a C source file into eBPF bytecode and then emits a\nGo file containing the eBPF. The goal "
},
{
"path": "cmd/bpf2go/doc.go",
"chars": 126,
"preview": "//go:build !windows\n\n// Program bpf2go embeds eBPF in Go.\n//\n// Please see the README for details how to use it.\npackage"
},
{
"path": "cmd/bpf2go/flags.go",
"chars": 729,
"preview": "//go:build !windows\n\npackage main\n\nimport (\n\t\"flag\"\n\t\"go/build/constraint\"\n)\n\n// buildTags is a comma-separated list of "
},
{
"path": "cmd/bpf2go/gen/compile.go",
"chars": 2784,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\ntype CompileArgs struc"
},
{
"path": "cmd/bpf2go/gen/compile_test.go",
"chars": 2490,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"bytes\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf/internal"
},
{
"path": "cmd/bpf2go/gen/doc.go",
"chars": 90,
"preview": "// Package gen contains utilities to generate Go bindings for eBPF ELF files.\npackage gen\n"
},
{
"path": "cmd/bpf2go/gen/output.go",
"chars": 5593,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"bytes\"\n\t_ \"embed\"\n\t\"fmt\"\n\t\"go/build/constraint\"\n\t\"go/token\"\n\t\"io\"\n\t\"sort\"\n\t"
},
{
"path": "cmd/bpf2go/gen/output.tpl",
"chars": 4075,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n{{ with .Constraints }}//go:build {{ . }}{{ end }}\n\npackage {{ .Package }}\n\nim"
},
{
"path": "cmd/bpf2go/gen/output_test.go",
"chars": 3847,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n\n\t\"githu"
},
{
"path": "cmd/bpf2go/gen/target.go",
"chars": 4118,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"go/build/constraint\"\n\t\"maps\"\n\t\"runtime\"\n\t\"slices\"\n)\n\nvar E"
},
{
"path": "cmd/bpf2go/gen/target_test.go",
"chars": 3419,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"errors\"\n\t\"os/exec\"\n\t\"slices\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nf"
},
{
"path": "cmd/bpf2go/gen/types.go",
"chars": 2396,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"cmp\"\n\t\"slices\"\n\n\t\"github.com/cilium/ebpf\"\n\t\"github.com/cilium/ebpf/btf\"\n)\n\n"
},
{
"path": "cmd/bpf2go/gen/types_test.go",
"chars": 1033,
"preview": "//go:build !windows\n\npackage gen\n\nimport (\n\t\"testing\"\n\n\t\"github.com/cilium/ebpf\"\n\t\"github.com/cilium/ebpf/btf\"\n\t\"github."
},
{
"path": "cmd/bpf2go/internal/module.go",
"chars": 379,
"preview": "package internal\n\n// We used to have some clever code here which relied on debug.ReadBuildInfo().\n// This is broken due "
},
{
"path": "cmd/bpf2go/main.go",
"chars": 13899,
"preview": "//go:build !windows\n\npackage main\n\nimport (\n\t\"errors\"\n\t\"flag\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t"
},
{
"path": "cmd/bpf2go/main_test.go",
"chars": 11114,
"preview": "//go:build !windows\n\npackage main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"testing"
},
{
"path": "cmd/bpf2go/makedep.go",
"chars": 2166,
"preview": "//go:build !windows\n\npackage main\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\nfunc"
},
{
"path": "cmd/bpf2go/makedep_test.go",
"chars": 1002,
"preview": "//go:build !windows\n\npackage main\n\nimport (\n\t\"bytes\"\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestParseDependencies(t *t"
},
{
"path": "cmd/bpf2go/test/api_test.go",
"chars": 1625,
"preview": "//go:build linux\n\npackage test\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n\t\"unsafe\"\n\n\t\"github.com/go-quicktest/qt\"\n\n\t\"github.com/ci"
},
{
"path": "cmd/bpf2go/test/doc.go",
"chars": 170,
"preview": "// Package test checks that the code generated by bpf2go conforms to a\n// specific API.\npackage test\n\n//go:generate go t"
},
{
"path": "cmd/bpf2go/test/test_bpfeb.go",
"chars": 4107,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage test\n\nimport ("
},
{
"path": "cmd/bpf2go/test/test_bpfel.go",
"chars": 4166,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "cmd/bpf2go/testdata/minimal.c",
"chars": 795,
"preview": "#include \"../../../testdata/common.h\"\n\nchar __license[] __section(\"license\") = \"MIT\";\n\nenum e { HOOPY, FROOD };\n\ntypedef"
},
{
"path": "cmd/bpf2go/tools.go",
"chars": 1161,
"preview": "//go:build !windows\n\npackage main\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"strings\"\n)\n\nfunc splitCFlagsFromArgs(in []string) (args, "
},
{
"path": "cmd/bpf2go/tools_test.go",
"chars": 957,
"preview": "//go:build !windows\n\npackage main\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n)\n\nfunc TestSplitArguments(t *testing.T) {\n\ttestcases "
},
{
"path": "collection.go",
"chars": 30153,
"preview": "package ebpf\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"reflect\"\n\t\"runtime\"\n\t\"slices\"\n\t\"strings\"\n\n"
},
{
"path": "collection_other.go",
"chars": 189,
"preview": "//go:build !windows\n\npackage ebpf\n\nimport \"github.com/cilium/ebpf/internal\"\n\nfunc loadCollectionFromNativeImage(_ string"
},
{
"path": "collection_test.go",
"chars": 18264,
"preview": "package ebpf\n\nimport (\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"reflect\"\n\t\"slices\"\n\t\"testing\"\n\n\t\"github.com/go-"
},
{
"path": "collection_windows.go",
"chars": 3260,
"preview": "package ebpf\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"unsafe\"\n\n\t\"github.com/cilium/ebpf/internal/efw\"\n\t\"github.com/cilium/ebpf/inter"
},
{
"path": "collection_windows_test.go",
"chars": 1171,
"preview": "package ebpf\n\nimport (\n\t\"path/filepath\"\n\t\"sort\"\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc TestLoadNativeImage(t "
},
{
"path": "cpu.go",
"chars": 401,
"preview": "package ebpf\n\n// PossibleCPU returns the max number of CPUs a system may possibly have\n// Logical CPU numbers must be of"
},
{
"path": "cpu_other.go",
"chars": 224,
"preview": "//go:build !windows\n\npackage ebpf\n\nimport (\n\t\"sync\"\n\n\t\"github.com/cilium/ebpf/internal/linux\"\n)\n\nvar possibleCPU = sync."
},
{
"path": "cpu_test.go",
"chars": 197,
"preview": "package ebpf\n\nimport (\n\t\"testing\"\n\n\t\"github.com/go-quicktest/qt\"\n)\n\nfunc TestPossibleCPU(t *testing.T) {\n\tnum, err := Po"
},
{
"path": "cpu_windows.go",
"chars": 203,
"preview": "package ebpf\n\nimport (\n\t\"sync\"\n\n\t\"golang.org/x/sys/windows\"\n)\n\nvar possibleCPU = sync.OnceValues(func() (int, error) {\n\t"
},
{
"path": "doc.go",
"chars": 1358,
"preview": "// Package ebpf is a toolkit for working with eBPF programs.\n//\n// eBPF programs are small snippets of code which are ex"
},
{
"path": "docs/.gitignore",
"chars": 50,
"preview": "# Python\n__pycache__\n\n# Build output\nbuild/\nsite/\n"
},
{
"path": "docs/Makefile",
"chars": 755,
"preview": "build: pipenv\n\t@# Run a production build of the documentation. Strict mode makes warnings fatal.\n\tpipenv run mkdocs buil"
},
{
"path": "docs/Pipfile",
"chars": 348,
"preview": "[[source]]\nurl = \"https://pypi.org/simple\"\nverify_ssl = true\nname = \"pypi\"\n\n[packages]\nmkdocs = \"*\"\npymdown-extensions ="
},
{
"path": "docs/README.md",
"chars": 715,
"preview": "# epbf-go documentation\n\nThe documentation project uses Pipenv to manage its dependencies, which will\nautomatically crea"
},
{
"path": "docs/ebpf/about.md",
"chars": 1096,
"preview": "The project was initially created in 2017 as\n[`newtools/ebpf`](https://github.com/newtools/ebpf) by a group of passionat"
},
{
"path": "docs/ebpf/concepts/features.md",
"chars": 2694,
"preview": "# Feature Detection\n\nFeature detection allows applications to check which eBPF-related features are\nsupported by the Lin"
},
{
"path": "docs/ebpf/concepts/global-variables.md",
"chars": 7685,
"preview": "{{ linux_version(\"5.2\", \"For all global variable-related BPF operations,\nthe kernel needs to understand the BPF_PSEUDO_M"
},
{
"path": "docs/ebpf/concepts/loader.md",
"chars": 4378,
"preview": "# Loading Objects\n\n{{ proj }} ships an eBPF object (ELF) loader that aims to be compatible with the\nupstream libbpf and "
},
{
"path": "docs/ebpf/concepts/object-lifecycle.md",
"chars": 4524,
"preview": "!!! info \"\"\n This is an advanced topic and does not need to be fully understood in order\n to get started writing u"
},
{
"path": "docs/ebpf/concepts/rlimit.md",
"chars": 3633,
"preview": "# Resource Limits\n\nCreating eBPF objects (Maps, Programs, even BTF blobs) requires kernel memory\nallocation. Before kern"
},
{
"path": "docs/ebpf/concepts/section-naming.md",
"chars": 16175,
"preview": "You may have seen the `SEC()` macro used around eBPF C code. This macro sends\na hint to the compiler to place a symbol ("
},
{
"path": "docs/ebpf/contributing/architecture.md",
"chars": 4062,
"preview": "Architecture of the library\n===\n\nThe bulk of the functionality of the library split across the `ebpf`, `btf` and\n`link` "
},
{
"path": "docs/ebpf/contributing/index.md",
"chars": 3565,
"preview": "# How to contribute\n\nDevelopment happens on [GitHub](https://github.com/cilium/ebpf) and contributions in\nall forms are "
},
{
"path": "docs/ebpf/contributing/new-example.md",
"chars": 1086,
"preview": "# Adding a new example\n\nThe library includes some examples to make getting started easier.\nThe aim of the examples is to"
},
{
"path": "docs/ebpf/contributing/new-feature.md",
"chars": 1527,
"preview": "# Adding a new feature\n\nWe're very much looking for contributions which flesh out the functionality of\nthe library.\n\n1. "
},
{
"path": "docs/ebpf/contributing/windows.md",
"chars": 8556,
"preview": "# Working on the Windows port\n\nThe library has basic support for interacting with eBPF for Windows (efW).\nThings are sub"
},
{
"path": "docs/ebpf/guides/getting-started.md",
"chars": 12020,
"preview": "# Getting Started with eBPF in Go\n\nIn this guide, we'll walk you through building a new eBPF-powered Go application\nfrom"
},
{
"path": "docs/ebpf/guides/portable-ebpf.md",
"chars": 3191,
"preview": "# Shipping Portable eBPF-powered Applications\n\n!!! incomplete\n This guide builds on Getting Started.\n \n Documen"
},
{
"path": "docs/ebpf/guides/windows-support.md",
"chars": 2370,
"preview": "# Windows support\n\nThe library has preliminary support for the [eBPF for Windows] runtime, allowing\nyou to build Go appl"
},
{
"path": "docs/ebpf/index.md",
"chars": 1451,
"preview": "<style>\n .md-content .md-typeset h1 {\n display: none;\n }\n</style>\n\n<p align=\"center\" class=\"tagline\">The eBPF Libra"
},
{
"path": "docs/ebpf/stylesheets/extra.css",
"chars": 2411,
"preview": "/* Tagline on landing page. */\n.tagline {\n font-size: 3em;\n font-weight: 900;\n letter-spacing: -0.5px;\n background: "
},
{
"path": "docs/ebpf/users.md",
"chars": 3198,
"preview": "# Projects built with {{ proj }}\n\nBelow is a non-comprehensive list of open-source software built with {{ proj }},\njust "
},
{
"path": "docs/examples/docs.c",
"chars": 469,
"preview": "//go:build ignore\n\n// DocMyMapProgram {\n#include <linux/bpf.h>\n#include <bpf/bpf_helpers.h>\n\n// Declare a hash map calle"
},
{
"path": "docs/examples/docs_test.go",
"chars": 2497,
"preview": "//go:build linux\n\npackage examples\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/cilium/ebpf\"\n)\n\nfunc DocLoadCollectionSpec() {\n\t// Par"
},
{
"path": "docs/examples/features_test.go",
"chars": 690,
"preview": "//go:build linux\n\npackage examples\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\n\t\"github.com/cilium/ebpf\"\n\t\"github.com/cilium/ebpf/featur"
},
{
"path": "docs/examples/getting_started/counter.c",
"chars": 643,
"preview": "// getting_started_counter {\n// (1)!\n//go:build ignore\n\n#include <linux/bpf.h> // (2)!\n#include <bpf/bpf_helpers.h>\n\nstr"
},
{
"path": "docs/examples/getting_started/counter_bpfeb.go",
"chars": 3224,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "docs/examples/getting_started/counter_bpfel.go",
"chars": 3283,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "docs/examples/getting_started/gen.go",
"chars": 122,
"preview": "//go:build linux\n\n// getting_started_gen {\npackage main\n\n//go:generate go tool bpf2go -tags linux counter counter.c\n\n// "
},
{
"path": "docs/examples/getting_started/main.go",
"chars": 1542,
"preview": "//go:build linux\n\n// getting_started_main {\npackage main\n\nimport (\n\t\"log\"\n\t\"net\"\n\t\"os\"\n\t\"os/signal\"\n\t\"time\"\n\n\t\"github.co"
},
{
"path": "docs/examples/rlimit_test.go",
"chars": 177,
"preview": "//go:build linux\n\npackage examples\n\n// DocRlimit {\nimport \"github.com/cilium/ebpf/rlimit\"\n\nfunc init() {\n\tif err := rlim"
},
{
"path": "docs/examples/variables/gen.go",
"chars": 65,
"preview": "package main\n\n//go:generate go tool bpf2go variables variables.c\n"
},
{
"path": "docs/examples/variables/main.go",
"chars": 2547,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/cilium/ebpf\"\n)\n\nfunc main() {\n\tDocVariablesSetConst()\n\tDocVariablesSetGlobal"
},
{
"path": "docs/examples/variables/variables.c",
"chars": 568,
"preview": "//go:build ignore\n\n#include <linux/bpf.h>\n#include <bpf/bpf_helpers.h>\n\n// Remove when toolchain Docker image ships with"
},
{
"path": "docs/examples/variables/variables_bpfeb.go",
"chars": 3663,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build mips || mips64 || ppc64 || s390x\n\npackage main\n\nimport (\n\t\"bytes\"\n\t"
},
{
"path": "docs/examples/variables/variables_bpfel.go",
"chars": 3722,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build 386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || pp"
},
{
"path": "docs/includes/glossary.md",
"chars": 1909,
"preview": "<!-- This snippet is automatically included on every page and takes care of automatically highlighting terminology. -->\n"
},
{
"path": "docs/macros.py",
"chars": 7496,
"preview": "\"\"\"Macro definitions for documentation.\"\"\"\n\n# Use built-in 'list' type when upgrading to Python 3.9.\n\nimport glob\nimport"
},
{
"path": "docs/mkdocs.yml",
"chars": 4619,
"preview": "site_name: \"ebpf-go Documentation\"\nsite_description: Pure-Go library to read, modify and load eBPF programs and attach t"
},
{
"path": "docs/overrides/partials/source-file.html",
"chars": 286,
"preview": "<hr>\n<div class=\"md-source-file\">\n <small>\n {% if page.meta.git_revision_date_localized %}\n Last updated {{ page."
},
{
"path": "docs/vars.yml",
"chars": 92,
"preview": "# Variables accessible in documentation using e.g. '{{ proj }}'.\nextra:\n proj: \"`ebpf-go`\"\n"
},
{
"path": "elf_reader.go",
"chars": 48779,
"preview": "package ebpf\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"debug/elf\"\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"iter\"\n\t\"maps\"\n\t\"math\"\n"
},
{
"path": "elf_reader_test.go",
"chars": 39326,
"preview": "package ebpf\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"flag\"\n\t\"fmt\"\n\t\"maps\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\""
},
{
"path": "elf_sections.go",
"chars": 8863,
"preview": "// Code generated by internal/cmd/gensections.awk; DO NOT EDIT.\n\npackage ebpf\n\n// Code in this file is derived from libb"
},
{
"path": "example_sock_elf_test.go",
"chars": 8157,
"preview": "//go:build linux\n\npackage ebpf_test\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"flag\"\n\t\"fmt\"\n\t\"syscall\"\n\t\"time\"\n\t\"unsafe\"\n\n\t"
},
{
"path": "example_sock_extract_dist_test.go",
"chars": 5180,
"preview": "//go:build linux\n\npackage ebpf_test\n\n// This code is derived from https://github.com/cloudflare/cloudflare-blog/tree/mas"
},
{
"path": "examples/README.md",
"chars": 2275,
"preview": "# Examples\n\nA collection of programs showing how to use the library.\nPlease see our [guide on what makes a good example]"
},
{
"path": "examples/cgroup_skb/bpf_bpfeb.go",
"chars": 3060,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "examples/cgroup_skb/bpf_bpfel.go",
"chars": 3119,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "examples/cgroup_skb/cgroup_skb.c",
"chars": 532,
"preview": "//go:build ignore\n\n#include \"common.h\"\n\nchar __license[] SEC(\"license\") = \"Dual MIT/GPL\";\n\nstruct {\n\t__uint(type, BPF_MA"
},
{
"path": "examples/cgroup_skb/main.go",
"chars": 2228,
"preview": "//go:build linux\n\n// This program demonstrates attaching an eBPF program to a control group.\n// The eBPF program will be"
},
{
"path": "examples/fentry/bpf_bpfeb.go",
"chars": 3142,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "examples/fentry/bpf_bpfel.go",
"chars": 3201,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "examples/fentry/fentry.c",
"chars": 2287,
"preview": "//go:build ignore\n\n#include \"common.h\"\n\n#include \"bpf_endian.h\"\n#include \"bpf_tracing.h\"\n\n#define AF_INET 2\n#define TASK"
},
{
"path": "examples/fentry/main.go",
"chars": 2621,
"preview": "//go:build linux\n\n// This program demonstrates attaching a fentry eBPF program to\n// tcp_connect. It prints the command/"
},
{
"path": "examples/headers/LICENSE.BSD-2-Clause",
"chars": 1641,
"preview": "Valid-License-Identifier: BSD-2-Clause\nSPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html\nUsage-Guide:\n To use the B"
},
{
"path": "examples/headers/bpf_endian.h",
"chars": 3750,
"preview": "/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */\n#ifndef __BPF_ENDIAN__\n#define __BPF_ENDIAN__\n\n/*\n * Isolate b"
},
{
"path": "examples/headers/bpf_helper_defs.h",
"chars": 152512,
"preview": "/* This is auto-generated file. See bpf_doc.py for details. */\n\n/* Forward declarations of BPF structs */\nstruct bpf_fib"
},
{
"path": "examples/headers/bpf_helpers.h",
"chars": 8808,
"preview": "/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */\n#ifndef __BPF_HELPERS__\n#define __BPF_HELPERS__\n\n/*\n * Note th"
},
{
"path": "examples/headers/bpf_tracing.h",
"chars": 20645,
"preview": "/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */\n#ifndef __BPF_TRACING_H__\n#define __BPF_TRACING_H__\n\n/* Scan t"
},
{
"path": "examples/headers/common.h",
"chars": 3794,
"preview": "// This is a compact version of `vmlinux.h` to be used in the examples using C code.\n\n#pragma once\n\ntypedef unsigned cha"
},
{
"path": "examples/headers/update.sh",
"chars": 511,
"preview": "#!/usr/bin/env bash\n\n# Version of libbpf to fetch headers from\nLIBBPF_VERSION=0.6.1\n\n# The headers we want\nprefix=libbpf"
},
{
"path": "examples/kprobe/bpf_bpfeb.go",
"chars": 3033,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "examples/kprobe/bpf_bpfel.go",
"chars": 3092,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "examples/kprobe/kprobe.c",
"chars": 503,
"preview": "//go:build ignore\n\n#include \"common.h\"\n\nchar __license[] SEC(\"license\") = \"Dual MIT/GPL\";\n\nstruct {\n\t__uint(type, BPF_MA"
},
{
"path": "examples/kprobe/main.go",
"chars": 1659,
"preview": "//go:build linux\n\n// This program demonstrates attaching an eBPF program to a kernel symbol.\n// The eBPF program will be"
},
{
"path": "examples/kprobe_percpu/bpf_bpfeb.go",
"chars": 3033,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "examples/kprobe_percpu/bpf_bpfel.go",
"chars": 3092,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "examples/kprobe_percpu/kprobe_percpu.c",
"chars": 510,
"preview": "//go:build ignore\n\n#include \"common.h\"\n\nchar __license[] SEC(\"license\") = \"Dual MIT/GPL\";\n\nstruct {\n\t__uint(type, BPF_MA"
},
{
"path": "examples/kprobe_percpu/main.go",
"chars": 1811,
"preview": "//go:build linux\n\n// This program demonstrates attaching an eBPF program to a kernel symbol and\n// using percpu map to c"
},
{
"path": "examples/kprobepin/bpf_bpfeb.go",
"chars": 3033,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "examples/kprobepin/bpf_bpfel.go",
"chars": 3092,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "examples/kprobepin/kprobe_pin.c",
"chars": 541,
"preview": "//go:build ignore\n\n#include \"common.h\"\n\nchar __license[] SEC(\"license\") = \"Dual MIT/GPL\";\n\nstruct {\n\t__uint(type, BPF_MA"
},
{
"path": "examples/kprobepin/main.go",
"chars": 2114,
"preview": "//go:build linux\n\n// This program demonstrates attaching an eBPF program to a kernel symbol.\n// The eBPF program will be"
},
{
"path": "examples/map_in_map/main.go",
"chars": 3567,
"preview": "//go:build linux\n\n// An example of using maps within maps. This example demonstrates a few\n// features. Firstly, creatin"
},
{
"path": "examples/ringbuffer/bpf_bpfeb.go",
"chars": 3107,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "examples/ringbuffer/bpf_bpfel.go",
"chars": 3166,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "examples/ringbuffer/main.go",
"chars": 2293,
"preview": "//go:build linux\n\npackage main\n\nimport (\n\t\"bytes\"\n\t\"encoding/binary\"\n\t\"errors\"\n\t\"log\"\n\t\"os\"\n\t\"os/signal\"\n\t\"syscall\"\n\n\t\"g"
},
{
"path": "examples/ringbuffer/ringbuffer.c",
"chars": 719,
"preview": "//go:build ignore\n\n#include \"common.h\"\n\n#ifndef TASK_COMM_LEN\n#define TASK_COMM_LEN 16\n#endif\n\nchar __license[] SEC(\"lic"
},
{
"path": "examples/sched_ext/bpf_bpfeb.go",
"chars": 2922,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
},
{
"path": "examples/sched_ext/bpf_bpfel.go",
"chars": 2981,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (386 || amd64 || arm || arm64 || loong64 || mips64le || mipsle || p"
},
{
"path": "examples/sched_ext/main.go",
"chars": 1032,
"preview": "//go:build linux\n\npackage main\n\nimport (\n\t\"log\"\n\t\"os\"\n\t\"os/signal\"\n\t\"syscall\"\n\n\t\"github.com/cilium/ebpf/link\"\n\t\"github.c"
},
{
"path": "examples/sched_ext/sched_ext.c",
"chars": 245,
"preview": "//go:build ignore\n\n#include \"bpf_endian.h\"\n#include \"common.h\"\n\nchar __license[] SEC(\"license\") = \"Dual MIT/GPL\";\n\nstruc"
},
{
"path": "examples/tcprtt/bpf_bpfeb.go",
"chars": 3129,
"preview": "// Code generated by bpf2go; DO NOT EDIT.\n//go:build (mips || mips64 || ppc64 || s390x) && linux\n\npackage main\n\nimport ("
}
]
// ... and 438 more files (download for full content)
About this extraction
This page contains the full source code of the cilium/ebpf GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 638 files (2.1 MB), approximately 568.9k tokens, and a symbol index with 5111 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.