Lines Matching +full:pre +full:- +full:programs
1 .. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
4 bpftool-gen
6 -------------------------------------------------------------------------------
7 tool for BPF code-generation
8 -------------------------------------------------------------------------------
19 *OPTIONS* := { |COMMON_OPTIONS| | { **-L** | **--use-loader** } }
38 The rules of BPF static linking are mostly the same as for user-space
56 shorten and simplify code to load and work with BPF programs from userspace
64 In addition to simple and reliable access to maps and programs, skeleton
66 within BPF object. When requested, supported BPF programs will be
68 user in pre-allocated fields in skeleton struct. For BPF programs that
70 but store resulting BPF link in per-program link field. All such set up
73 support to detach programs and free up resources.
76 variables of all supported kinds: mutable, read-only, as well as extern
77 ones. This interface allows to pre-setup initial values of variables before
78 BPF object is loaded and verified by kernel. For non-read-only variables,
84 This ensures skeleton and BPF object file are matching 1-to-1 and always
85 stay in sync. Generated code is dual-licensed under LGPL-2.1 and
86 BSD-2-Clause licenses.
91 keep working with specific maps, programs, etc.
100 - **example__open** and **example__open_opts**.
105 - **example__load**.
106 This function creates maps, loads and verifies BPF programs, initializes
110 - **example__open_and_load** combines **example__open** and
113 - **example__attach** and **example__detach**.
115 already loaded BPF object. Only BPF programs of types supported by libbpf
116 for auto-attachment will be auto-attached and their corresponding BPF
117 links instantiated. For other BPF programs, user can manually create a
122 - **example__destroy**.
123 Detach and unload BPF programs, free up all the resources used by
131 if target kernel supports memory-mapped BPF arrays, same structs can be
132 used to fetch and update (non-read-only) data from userspace, with same
139 corresponding maps, programs, or global variables. They require that the
149 - **example__open(bpf_object\*)**.
153 - **example__destroy()**.
155 programs or maps.
160 CO-RE relocations may be satisfied.
164 calculate CO-RE relocations.
172 CO-RE based application, turning the application portable to different
184 -L, --use-loader
251 * and testmod_map->data.
265 This is example BPF application with three BPF programs and a mix of BPF
269 **$ clang --target=bpf -g example1.bpf.c -o example1.bpf.o**
271 **$ clang --target=bpf -g example2.bpf.c -o example2.bpf.o**
273 **$ clang --target=bpf -g example3.bpf.c -o example3.bpf.o**
285 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
360 skel->rodata->param1 = 128;
363 skel->struct_ops.testmod_map->data = 13;
370 printf("test_2_result: %d\n", skel->bss->test_2_result);
377 printf("my_map name: %s\n", bpf_map__name(skel->maps.my_map));
379 bpf_program__fd(skel->progs.handle_sys_enter));
381 /* detach and re-attach sys_exit program */
382 bpf_link__destroy(skel->links.handle_sys_exit);
383 skel->links.handle_sys_exit =
384 bpf_program__attach(skel->progs.handle_sys_exit);
387 skel->bss->handle_sys_enter_my_static_var);
403 This is a stripped-out version of skeleton generated for above example code.
406 ------------
408 **$ bpftool btf dump file 5.4.0-example.btf format raw**
439 **$ bpftool gen min_core_btf 5.4.0-example.btf 5.4.0-smaller.btf one.bpf.o**
441 **$ bpftool btf dump file 5.4.0-smaller.btf format raw**
458 Now, the "5.4.0-smaller.btf" file may be used by libbpf as an external BTF file
459 when loading the "one.bpf.o" object into the "5.4.0-example" kernel. Note that
465 LIBBPF_OPTS(bpf_object_open_opts, opts, .btf_custom_path = "5.4.0-smaller.btf");