Skip to content

Commit e08302e

Browse files
Andre-ARMwilldeacon
authored andcommitted
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 <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 46862da commit e08302e

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

tools/testing/selftests/arm64/bti/Makefile

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
TEST_GEN_PROGS := btitest nobtitest
44

5-
PROGS := $(patsubst %,gen/%,$(TEST_GEN_PROGS))
6-
75
# These tests are built as freestanding binaries since otherwise BTI
86
# support in ld.so is required which is not currently widespread; when
97
# it is available it will still be useful to test this separately as the
@@ -18,44 +16,41 @@ CFLAGS_COMMON = -ffreestanding -Wall -Wextra $(CFLAGS)
1816
BTI_CC_COMMAND = $(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -c -o $@ $<
1917
NOBTI_CC_COMMAND = $(CC) $(CFLAGS_NOBTI) $(CFLAGS_COMMON) -c -o $@ $<
2018

21-
%-bti.o: %.c
19+
$(OUTPUT)/%-bti.o: %.c
2220
$(BTI_CC_COMMAND)
2321

24-
%-bti.o: %.S
22+
$(OUTPUT)/%-bti.o: %.S
2523
$(BTI_CC_COMMAND)
2624

27-
%-nobti.o: %.c
25+
$(OUTPUT)/%-nobti.o: %.c
2826
$(NOBTI_CC_COMMAND)
2927

30-
%-nobti.o: %.S
28+
$(OUTPUT)/%-nobti.o: %.S
3129
$(NOBTI_CC_COMMAND)
3230

3331
BTI_OBJS = \
34-
test-bti.o \
35-
signal-bti.o \
36-
start-bti.o \
37-
syscall-bti.o \
38-
system-bti.o \
39-
teststubs-bti.o \
40-
trampoline-bti.o
41-
gen/btitest: $(BTI_OBJS)
32+
$(OUTPUT)/test-bti.o \
33+
$(OUTPUT)/signal-bti.o \
34+
$(OUTPUT)/start-bti.o \
35+
$(OUTPUT)/syscall-bti.o \
36+
$(OUTPUT)/system-bti.o \
37+
$(OUTPUT)/teststubs-bti.o \
38+
$(OUTPUT)/trampoline-bti.o
39+
$(OUTPUT)/btitest: $(BTI_OBJS)
4240
$(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^
4341

4442
NOBTI_OBJS = \
45-
test-nobti.o \
46-
signal-nobti.o \
47-
start-nobti.o \
48-
syscall-nobti.o \
49-
system-nobti.o \
50-
teststubs-nobti.o \
51-
trampoline-nobti.o
52-
gen/nobtitest: $(NOBTI_OBJS)
43+
$(OUTPUT)/test-nobti.o \
44+
$(OUTPUT)/signal-nobti.o \
45+
$(OUTPUT)/start-nobti.o \
46+
$(OUTPUT)/syscall-nobti.o \
47+
$(OUTPUT)/system-nobti.o \
48+
$(OUTPUT)/teststubs-nobti.o \
49+
$(OUTPUT)/trampoline-nobti.o
50+
$(OUTPUT)/nobtitest: $(NOBTI_OBJS)
5351
$(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^
5452

5553
# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list
5654
# to account for any OUTPUT target-dirs optionally provided by
5755
# the toplevel makefile
5856
include ../../lib.mk
59-
60-
$(TEST_GEN_PROGS): $(PROGS)
61-
cp $(PROGS) $(OUTPUT)/

tools/testing/selftests/arm64/bti/gen/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)