Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Run resolve_btfids only for relevant .test.o objects

A selftest targeting resolve_btfids functionality relies on a resolved
.BTF_ids section to be available in the TRUNNER_BINARY. The underlying
BTF data is taken from a special BPF program (btf_data.c), and so
resolve_btfids is executed as a part of a TRUNNER_BINARY build recipe
on the final binary.

Subsequent patches in this series allow resolve_btfids to modify BTF
before resolving the symbols, which means that the test needs access
to that modified BTF [1]. Currently the test simply reads in
btf_data.bpf.o on the assumption that BTF hasn't changed.

Implement resolve_btfids call only for particular test objects (just
resolve_btfids.test.o for now). The test objects are linked into the
TRUNNER_BINARY, and so .BTF_ids section will be available there.

This will make it trivial for the resolve_btfids test to access BTF
modified by resolve_btfids.

[1] https://lore.kernel.org/bpf/CAErzpmvsgSDe-QcWH8SFFErL6y3p3zrqNri5-UHJ9iK2ChyiBw@mail.gmail.com/

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Tested-by: Alan Maguire <alan.maguire@oracle.com>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/20251219181825.1289460-2-ihor.solodrai@linux.dev

authored by

Ihor Solodrai and committed by
Andrii Nakryiko
014e1cdb 903922cf

+6 -2
+6 -2
tools/testing/selftests/bpf/Makefile
··· 643 643 ) > $$@) 644 644 endif 645 645 646 + $(TRUNNER_OUTPUT)/resolve_btfids.test.o: $(RESOLVE_BTFIDS) $(TRUNNER_OUTPUT)/btf_data.bpf.o 647 + $(TRUNNER_OUTPUT)/resolve_btfids.test.o: private TEST_NEEDS_BTFIDS = 1 648 + 646 649 # compile individual test files 647 650 # Note: we cd into output directory to ensure embedded BPF object is found 648 651 $(TRUNNER_TEST_OBJS): $(TRUNNER_OUTPUT)/%.test.o: \ ··· 653 650 | $(TRUNNER_OUTPUT)/%.test.d 654 651 $$(call msg,TEST-OBJ,$(TRUNNER_BINARY),$$@) 655 652 $(Q)cd $$(@D) && $$(CC) -I. $$(CFLAGS) -MMD -MT $$@ -c $(CURDIR)/$$< $$(LDLIBS) -o $$(@F) 653 + $$(if $$(TEST_NEEDS_BTFIDS), \ 654 + $$(call msg,BTFIDS,$(TRUNNER_BINARY),$$@) \ 655 + $(RESOLVE_BTFIDS) --btf $(TRUNNER_OUTPUT)/btf_data.bpf.o $$@) 656 656 657 657 $(TRUNNER_TEST_OBJS:.o=.d): $(TRUNNER_OUTPUT)/%.test.d: \ 658 658 $(TRUNNER_TESTS_DIR)/%.c \ ··· 701 695 $(OUTPUT)/$(TRUNNER_BINARY): $(TRUNNER_TEST_OBJS) \ 702 696 $(TRUNNER_EXTRA_OBJS) $$(BPFOBJ) \ 703 697 $(TRUNNER_LIB_OBJS) \ 704 - $(RESOLVE_BTFIDS) \ 705 698 $(TRUNNER_BPFTOOL) \ 706 699 $(OUTPUT)/veristat \ 707 700 | $(TRUNNER_BINARY)-extras 708 701 $$(call msg,BINARY,,$$@) 709 702 $(Q)$$(CC) $$(CFLAGS) $$(filter %.a %.o,$$^) $$(LDLIBS) $$(LLVM_LDLIBS) $$(LDFLAGS) $$(LLVM_LDFLAGS) -o $$@ 710 - $(Q)$(RESOLVE_BTFIDS) --btf $(TRUNNER_OUTPUT)/btf_data.bpf.o $$@ 711 703 $(Q)ln -sf $(if $2,..,.)/tools/build/bpftool/$(USE_BOOTSTRAP)bpftool \ 712 704 $(OUTPUT)/$(if $2,$2/)bpftool 713 705