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

selftests/x86: Detect -no-pie availability

Some toolchains need -no-pie to build all tests, others do not support
the -no-pie flag at all. Therefore, add another test for the
availability of the flag.

This amends commit 3346a6a4e5ba8c040360f753b26938cec31a4bdc
("selftests: x86: sysret_ss_attrs doesn't build on a PIE build").

Signed-off-by: Florian Weimer <fweimer@redhat.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>

authored by

Florian Weimer and committed by
Shuah Khan (Samsung OSG)
0dd3a694 08529914

+17 -1
+7 -1
tools/testing/selftests/x86/Makefile
··· 8 8 UNAME_M := $(shell uname -m) 9 9 CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) 10 10 CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) 11 + CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie) 11 12 12 13 TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \ 13 14 check_initial_reg_state sigreturn iopl mpx-mini-test ioperm \ ··· 32 31 BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) 33 32 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) 34 33 35 - CFLAGS := -O2 -g -std=gnu99 -pthread -Wall -no-pie 34 + CFLAGS := -O2 -g -std=gnu99 -pthread -Wall 35 + 36 + # call32_from_64 in thunks.S uses absolute addresses. 37 + ifeq ($(CAN_BUILD_WITH_NOPIE),1) 38 + CFLAGS += -no-pie 39 + endif 36 40 37 41 define gen-target-rule-32 38 42 $(1) $(1)_32: $(OUTPUT)/$(1)_32
+10
tools/testing/selftests/x86/trivial_program.c
··· 1 + /* Trivial program to check that compilation with certain flags is working. */ 2 + 3 + #include <stdio.h> 4 + 5 + int 6 + main(void) 7 + { 8 + puts(""); 9 + return 0; 10 + }