diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-11-23 12:01:04 -0800 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-11-25 23:05:23 +0100 |
commit | 16e0c35c6f7a2e90d52f3035ecf942af21417b7b (patch) | |
tree | 81514abb33b2931f6db100651643873faa64578d /tools/lib/bpf/gen_loader.c | |
parent | fa721d4f0b91f525339996f4faef7bb072d70162 (diff) | |
download | linux-16e0c35c6f7a2e90d52f3035ecf942af21417b7b.tar.bz2 |
libbpf: Load global data maps lazily on legacy kernels
Load global data maps lazily, if kernel is too old to support global
data. Make sure that programs are still correct by detecting if any of
the to-be-loaded programs have relocation against any of such maps.
This allows to solve the issue ([0]) with bpf_printk() and Clang
generating unnecessary and unreferenced .rodata.strX.Y sections, but it
also goes further along the CO-RE lines, allowing to have a BPF object
in which some code can work on very old kernels and relies only on BPF
maps explicitly, while other BPF programs might enjoy global variable
support. If such programs are correctly set to not load at runtime on
old kernels, bpf_object will load and function correctly now.
[0] https://lore.kernel.org/bpf/CAK-59YFPU3qO+_pXWOH+c1LSA=8WA1yabJZfREjOEXNHAqgXNg@mail.gmail.com/
Fixes: aed659170a31 ("libbpf: Support multiple .rodata.* and .data.* BPF maps")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20211123200105.387855-1-andrii@kernel.org
Diffstat (limited to 'tools/lib/bpf/gen_loader.c')
0 files changed, 0 insertions, 0 deletions