Skip to content

Commit d7a4929

Browse files
Andre-ARMctmarinas
authored andcommitted
kselftest/arm64: bti: force static linking
The "bti" selftests are built with -nostdlib, which apparently automatically creates a statically linked binary, which is what we want and need for BTI (to avoid interactions with the dynamic linker). However this is not true when building a PIE binary, which some toolchains (Ubuntu) configure as the default. When compiling btitest with such a toolchain, it will create a dynamically linked binary, which will probably fail some tests, as the dynamic linker might not support BTI: =================== TAP version 13 1..18 not ok 1 nohint_func/call_using_br_x0 not ok 2 nohint_func/call_using_br_x16 not ok 3 nohint_func/call_using_blr .... =================== To make sure we create static binaries, add an explicit -static on the linker command line. This forces static linking even if the toolchain defaults to PIE builds, and fixes btitest runs on BTI enabled machines. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Mark Brown <[email protected]> Fixes: 314bcbf ("kselftest: arm64: Add BTI tests") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 0639e02 commit d7a4929

File tree

1 file changed

+2
-2
lines changed
  • tools/testing/selftests/arm64/bti

1 file changed

+2
-2
lines changed

tools/testing/selftests/arm64/bti/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BTI_OBJS = \
3939
teststubs-bti.o \
4040
trampoline-bti.o
4141
gen/btitest: $(BTI_OBJS)
42-
$(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -o $@ $^
42+
$(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^
4343

4444
NOBTI_OBJS = \
4545
test-nobti.o \
@@ -50,7 +50,7 @@ NOBTI_OBJS = \
5050
teststubs-nobti.o \
5151
trampoline-nobti.o
5252
gen/nobtitest: $(NOBTI_OBJS)
53-
$(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -o $@ $^
53+
$(CC) $(CFLAGS_BTI) $(CFLAGS_COMMON) -nostdlib -static -o $@ $^
5454

5555
# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list
5656
# to account for any OUTPUT target-dirs optionally provided by

0 commit comments

Comments
 (0)