selftests/bpf: add build ID tests
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 29 Aug 2024 17:42:32 +0000 (10:42 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 11 Sep 2024 16:58:31 +0000 (09:58 -0700)
commit3c217a182018e6c6d381b3fdc32626275eefbfb0
tree81f62219b389a87056cc64f6d14b29c0189cd566
parentd4dd9775ec242425576af93daadb80a34083a53c
selftests/bpf: add build ID tests

Add a new set of tests validating behavior of capturing stack traces
with build ID. We extend uprobe_multi target binary with ability to
trigger uprobe (so that we can capture stack traces from it), but also
we allow to force build ID data to be either resident or non-resident in
memory (see also a comment about quirks of MADV_PAGEOUT).

That way we can validate that in non-sleepable context we won't get
build ID (as expected), but with sleepable uprobes we will get that
build ID regardless of it being physically present in memory.

Also, we add a small add-on linker script which reorders
.note.gnu.build-id section and puts it after (big) .text section,
putting build ID data outside of the very first page of ELF file. This
will test all the relaxations we did in build ID parsing logic in kernel
thanks to freader abstraction.

Reviewed-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20240829174232.3133883-11-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/bpf/prog_tests/build_id.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_build_id.c [new file with mode: 0644]
tools/testing/selftests/bpf/uprobe_multi.c
tools/testing/selftests/bpf/uprobe_multi.ld [new file with mode: 0644]