]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Support initialized global variables
authorAndrii Nakryiko <andriin@fb.com>
Thu, 21 Nov 2019 07:07:43 +0000 (23:07 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 25 Nov 2019 00:58:45 +0000 (16:58 -0800)
commita8cd108374e5453c2b5923d318c9730fe5d958f0
tree1f046a91c4fdc56fabf6559e47fd5793a08df058
parent97b169d23b0e692556f09fa02c5622e45e158192
libbpf: Support initialized global variables

Initialized global variables are no different in ELF from static variables,
and don't require any extra support from libbpf. But they are matching
semantics of global data (backed by BPF maps) more closely, preventing
LLVM/Clang from aggressively inlining constant values and not requiring
volatile incantations to prevent those. This patch enables global variables.
It still disables uninitialized variables, which will be put into special COM
(common) ELF section, because BPF doesn't allow uninitialized data to be
accessed.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20191121070743.1309473-5-andriin@fb.com
14 files changed:
tools/lib/bpf/libbpf.c
tools/testing/selftests/bpf/progs/test_core_reloc_arrays.c
tools/testing/selftests/bpf/progs/test_core_reloc_bitfields_direct.c
tools/testing/selftests/bpf/progs/test_core_reloc_bitfields_probed.c
tools/testing/selftests/bpf/progs/test_core_reloc_existence.c
tools/testing/selftests/bpf/progs/test_core_reloc_flavors.c
tools/testing/selftests/bpf/progs/test_core_reloc_ints.c
tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c
tools/testing/selftests/bpf/progs/test_core_reloc_misc.c
tools/testing/selftests/bpf/progs/test_core_reloc_mods.c
tools/testing/selftests/bpf/progs/test_core_reloc_nesting.c
tools/testing/selftests/bpf/progs/test_core_reloc_primitives.c
tools/testing/selftests/bpf/progs/test_core_reloc_ptr_as_arr.c
tools/testing/selftests/bpf/progs/test_core_reloc_size.c