1 # SPDX-License-Identifier: GPL-2.0 << 2 all: 1 all: 3 2 4 include ../lib.mk 3 include ../lib.mk 5 4 6 .PHONY: all all_32 all_64 warn_32bit_failure c 5 .PHONY: all all_32 all_64 warn_32bit_failure clean 7 6 8 UNAME_M := $(shell uname -m) !! 7 TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs ldt_gdt syscall_nt ptrace_syscall \ 9 CAN_BUILD_I386 := $(shell ./check_cc.sh "$(CC) !! 8 test_vsyscall 10 CAN_BUILD_X86_64 := $(shell ./check_cc.sh "$(C !! 9 TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault sigreturn test_syscall_vdso unwind_vdso \ 11 CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh !! 10 test_FCMOV test_FCOMI test_FISTTP 12 << 13 TARGETS_C_BOTHBITS := single_step_syscall sysr << 14 check_initial_reg_stat << 15 test_vsyscall mov_ss_t << 16 syscall_arg_fault fsgs << 17 TARGETS_C_BOTHBITS += nx_stack << 18 TARGETS_C_32BIT_ONLY := entry_from_vm86 test_s << 19 test_FCMOV test_FCOMI << 20 vdso_restorer << 21 TARGETS_C_64BIT_ONLY := fsgsbase sysret_rip sy << 22 corrupt_xstate_header << 23 # Some selftests require 32bit support enabled << 24 TARGETS_C_32BIT_NEEDED := ldt_gdt ptrace_sysca << 25 << 26 TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $ << 27 TARGETS_C_64BIT_ALL := $(TARGETS_C_BOTHBITS) $ << 28 ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),11) << 29 TARGETS_C_64BIT_ALL += $(TARGETS_C_32BIT_NEEDE << 30 endif << 31 11 >> 12 TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) 32 BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) 13 BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) 33 BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64) !! 14 BINARIES_64 := $(TARGETS_C_BOTHBITS:%=%_64) 34 << 35 BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINA << 36 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINA << 37 15 38 CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(K !! 16 CFLAGS := -O2 -g -std=gnu99 -pthread -Wall 39 << 40 # call32_from_64 in thunks.S uses absolute add << 41 ifeq ($(CAN_BUILD_WITH_NOPIE),1) << 42 CFLAGS += -no-pie << 43 << 44 ifneq ($(LLVM),) << 45 # clang only wants to see -no-pie during linki << 46 # linking stage, so a compiler warning is unav << 47 # restructuring the Makefile. Avoid this by si << 48 CFLAGS += -Wno-unused-command-line-argument << 49 endif << 50 endif << 51 17 52 define gen-target-rule-32 !! 18 UNAME_M := $(shell uname -m) 53 $(1) $(1)_32: $(OUTPUT)/$(1)_32 !! 19 CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) 54 .PHONY: $(1) $(1)_32 !! 20 CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) 55 endef << 56 << 57 define gen-target-rule-64 << 58 $(1) $(1)_64: $(OUTPUT)/$(1)_64 << 59 .PHONY: $(1) $(1)_64 << 60 endef << 61 21 62 ifeq ($(CAN_BUILD_I386),1) 22 ifeq ($(CAN_BUILD_I386),1) 63 all: all_32 23 all: all_32 64 TEST_PROGS += $(BINARIES_32) 24 TEST_PROGS += $(BINARIES_32) 65 EXTRA_CFLAGS += -DCAN_BUILD_32 << 66 $(foreach t,$(TARGETS_C_32BIT_ALL),$(eval $(ca << 67 endif 25 endif 68 26 69 ifeq ($(CAN_BUILD_X86_64),1) 27 ifeq ($(CAN_BUILD_X86_64),1) 70 all: all_64 28 all: all_64 71 TEST_PROGS += $(BINARIES_64) 29 TEST_PROGS += $(BINARIES_64) 72 EXTRA_CFLAGS += -DCAN_BUILD_64 << 73 $(foreach t,$(TARGETS_C_64BIT_ALL),$(eval $(ca << 74 endif 30 endif 75 31 76 all_32: $(BINARIES_32) 32 all_32: $(BINARIES_32) 77 33 78 all_64: $(BINARIES_64) 34 all_64: $(BINARIES_64) 79 35 80 EXTRA_CLEAN := $(BINARIES_32) $(BINARIES_64) s !! 36 clean: >> 37 $(RM) $(BINARIES_32) $(BINARIES_64) 81 38 82 $(BINARIES_32): $(OUTPUT)/%_32: %.c helpers.h !! 39 $(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c 83 $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFL !! 40 $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm 84 41 85 $(BINARIES_64): $(OUTPUT)/%_64: %.c helpers.h !! 42 $(TARGETS_C_BOTHBITS:%=%_64): %_64: %.c 86 $(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFL !! 43 $(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl 87 44 88 # x86_64 users should be encouraged to install 45 # x86_64 users should be encouraged to install 32-bit libraries 89 ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01) 46 ifeq ($(CAN_BUILD_I386)$(CAN_BUILD_X86_64),01) 90 all: warn_32bit_failure 47 all: warn_32bit_failure 91 48 92 warn_32bit_failure: 49 warn_32bit_failure: 93 @echo "Warning: you seem to have a bro 50 @echo "Warning: you seem to have a broken 32-bit build" 2>&1; \ 94 echo "environment. This will reduce t 51 echo "environment. This will reduce test coverage of 64-bit" 2>&1; \ 95 echo "kernels. If you are using a Deb 52 echo "kernels. If you are using a Debian-like distribution," 2>&1; \ 96 echo "try:"; 2>&1; \ 53 echo "try:"; 2>&1; \ 97 echo ""; 54 echo ""; \ 98 echo " apt-get install gcc-multilib l 55 echo " apt-get install gcc-multilib libc6-i386 libc6-dev-i386"; \ 99 echo ""; 56 echo ""; \ 100 echo "If you are using a Fedora-like d 57 echo "If you are using a Fedora-like distribution, try:"; \ 101 echo ""; 58 echo ""; \ 102 echo " yum install glibc-devel.*i686" 59 echo " yum install glibc-devel.*i686"; \ 103 echo ""; << 104 echo "If you are using a SUSE-like dis << 105 echo ""; << 106 echo " zypper install gcc-32bit glibc << 107 exit 0; 60 exit 0; 108 endif 61 endif 109 62 110 # Add an additional file to the source file li !! 63 # Some tests have additional dependencies. 111 # add a Makefile dependency on that same file. !! 64 sysret_ss_attrs_64: thunks.S 112 # that the compiler invocation ("$(CC) file1.c !! 65 ptrace_syscall_32: raw_syscall_helper_32.S 113 # the dependencies ("header3.h"), because clan !! 66 test_syscall_vdso_32: thunks_32.S 114 # header files as an input to the compiler inv << 115 define extra-files << 116 $(OUTPUT)/$(1): EXTRA_FILES := $(2) << 117 $(OUTPUT)/$(1): $(2) << 118 endef << 119 << 120 $(eval $(call extra-files,sysret_ss_attrs_64,t << 121 $(eval $(call extra-files,ptrace_syscall_32,ra << 122 $(eval $(call extra-files,test_syscall_vdso_32 << 123 $(eval $(call extra-files,fsgsbase_restore_64, << 124 $(eval $(call extra-files,fsgsbase_restore_32, << 125 $(eval $(call extra-files,sysret_rip_64,clang_ << 126 << 127 # check_initial_reg_state is special: it needs << 128 # needs to be static so that its interpreter d << 129 # state. << 130 $(OUTPUT)/check_initial_reg_state_32: CFLAGS + << 131 $(OUTPUT)/check_initial_reg_state_64: CFLAGS + << 132 << 133 $(OUTPUT)/nx_stack_32: CFLAGS += -Wl,-z,noexec << 134 $(OUTPUT)/nx_stack_64: CFLAGS += -Wl,-z,noexec <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.