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

kselftest/arm64: build BTI tests in output directory

The arm64 BTI selftests are currently built in the source directory,
then the generated binaries are copied to the output directory.
This leaves the object files around in a potentially otherwise pristine
source tree, tainting it for out-of-tree kernel builds.

Prepend $(OUTPUT) to every reference to an object file in the Makefile,
and remove the extra handling and copying. This puts all generated files
under the output directory.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20230815145931.2522557-1-andre.przywara@arm.com
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Andre Przywara and committed by
Will Deacon
e08302ee 46862da1

+20 -27
+20 -25
tools/testing/selftests/arm64/bti/Makefile
··· 2 2 3 3 TEST_GEN_PROGS := btitest nobtitest 4 4 5 - PROGS := $(patsubst %,gen/%,$(TEST_GEN_PROGS)) 6 - 7 5 # These tests are built as freestanding binaries since otherwise BTI 8 6 # support in ld.so is required which is not currently widespread; when 9 7 # it is available it will still be useful to test this separately as the ··· 16 18 BTI_CC_COMMAND = $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -c -o $@ $< 17 19 NOBTI_CC_COMMAND = $(CC) $(CFLAGS_NOBTI) $(CFLAGS_COMMON) -c -o $@ $< 18 20 19 - %-bti.o: %.c 21 + $(OUTPUT)/%-bti.o: %.c 20 22 $(BTI_CC_COMMAND) 21 23 22 - %-bti.o: %.S 24 + $(OUTPUT)/%-bti.o: %.S 23 25 $(BTI_CC_COMMAND) 24 26 25 - %-nobti.o: %.c 27 + $(OUTPUT)/%-nobti.o: %.c 26 28 $(NOBTI_CC_COMMAND) 27 29 28 - %-nobti.o: %.S 30 + $(OUTPUT)/%-nobti.o: %.S 29 31 $(NOBTI_CC_COMMAND) 30 32 31 33 BTI_OBJS = \ 32 - test-bti.o \ 33 - signal-bti.o \ 34 - start-bti.o \ 35 - syscall-bti.o \ 36 - system-bti.o \ 37 - teststubs-bti.o \ 38 - trampoline-bti.o 39 - gen/btitest: $(BTI_OBJS) 34 + $(OUTPUT)/test-bti.o \ 35 + $(OUTPUT)/signal-bti.o \ 36 + $(OUTPUT)/start-bti.o \ 37 + $(OUTPUT)/syscall-bti.o \ 38 + $(OUTPUT)/system-bti.o \ 39 + $(OUTPUT)/teststubs-bti.o \ 40 + $(OUTPUT)/trampoline-bti.o 41 + $(OUTPUT)/btitest: $(BTI_OBJS) 40 42 $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ 41 43 42 44 NOBTI_OBJS = \ 43 - test-nobti.o \ 44 - signal-nobti.o \ 45 - start-nobti.o \ 46 - syscall-nobti.o \ 47 - system-nobti.o \ 48 - teststubs-nobti.o \ 49 - trampoline-nobti.o 50 - gen/nobtitest: $(NOBTI_OBJS) 45 + $(OUTPUT)/test-nobti.o \ 46 + $(OUTPUT)/signal-nobti.o \ 47 + $(OUTPUT)/start-nobti.o \ 48 + $(OUTPUT)/syscall-nobti.o \ 49 + $(OUTPUT)/system-nobti.o \ 50 + $(OUTPUT)/teststubs-nobti.o \ 51 + $(OUTPUT)/trampoline-nobti.o 52 + $(OUTPUT)/nobtitest: $(NOBTI_OBJS) 51 53 $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^ 52 54 53 55 # Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list 54 56 # to account for any OUTPUT target-dirs optionally provided by 55 57 # the toplevel makefile 56 58 include ../../lib.mk 57 - 58 - $(TEST_GEN_PROGS): $(PROGS) 59 - cp $(PROGS) $(OUTPUT)/
-2
tools/testing/selftests/arm64/bti/gen/.gitignore
··· 1 - btitest 2 - nobtitest