xref: /linux/tools/testing/selftests/exec/Makefile (revision b083cc815376a8ccfba6535b4d59a396b77601d4)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2c9b26b81SDavid DrysdaleCFLAGS = -Wall
34e7301e6SAlexey DobriyanCFLAGS += -Wno-nonnull
4*b083cc81SMickaël SalaünCFLAGS += $(KHDR_INCLUDES)
5*b083cc81SMickaël Salaün
6*b083cc81SMickaël SalaünLDLIBS += -lcap
7c9b26b81SDavid Drysdale
8b57a2907SKees CookALIGNS := 0x1000 0x200000 0x1000000
9b57a2907SKees CookALIGN_PIES        := $(patsubst %,load_address.%,$(ALIGNS))
10b57a2907SKees CookALIGN_STATIC_PIES := $(patsubst %,load_address.static.%,$(ALIGNS))
113545deffSKees CookALIGNMENT_TESTS   := $(ALIGN_PIES) $(ALIGN_STATIC_PIES)
12b57a2907SKees Cook
134893992bSMuhammad Usama AnjumTEST_PROGS := binfmt_script.py
14b57a2907SKees CookTEST_GEN_PROGS := execveat non-regular $(ALIGNMENT_TESTS)
15*b083cc81SMickaël SalaünTEST_GEN_PROGS_EXTENDED := false
16908a26e1SMuhammad Usama AnjumTEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
1780d443e8Sbamvor.zhangjian@huawei.com# Makefile is a run-time dependency, since it's accessed by the execveat test
1880d443e8Sbamvor.zhangjian@huawei.comTEST_FILES := Makefile
1980d443e8Sbamvor.zhangjian@huawei.com
204e7301e6SAlexey DobriyanTEST_GEN_PROGS += recursion-depth
219132c394SKees CookTEST_GEN_PROGS += null-argv
22*b083cc81SMickaël SalaünTEST_GEN_PROGS += check-exec
234e7301e6SAlexey Dobriyan
240f71241aSKees CookEXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx*	\
250f71241aSKees Cook	       $(OUTPUT)/S_I*.test
2680d443e8Sbamvor.zhangjian@huawei.com
2780d443e8Sbamvor.zhangjian@huawei.cominclude ../lib.mk
2880d443e8Sbamvor.zhangjian@huawei.com
29a8ba798bSbamvor.zhangjian@huawei.com$(OUTPUT)/subdir:
30c9b26b81SDavid Drysdale	mkdir -p $@
31472874cfSKees Cook$(OUTPUT)/script: Makefile
32472874cfSKees Cook	echo '#!/bin/bash' > $@
33c9b26b81SDavid Drysdale	echo 'exit $$*' >> $@
34c9b26b81SDavid Drysdale	chmod +x $@
35a8ba798bSbamvor.zhangjian@huawei.com$(OUTPUT)/execveat.symlink: $(OUTPUT)/execveat
36a8ba798bSbamvor.zhangjian@huawei.com	cd $(OUTPUT) && ln -s -f $(shell basename $<) $(shell basename $@)
37a8ba798bSbamvor.zhangjian@huawei.com$(OUTPUT)/execveat.denatured: $(OUTPUT)/execveat
38c9b26b81SDavid Drysdale	cp $< $@
39c9b26b81SDavid Drysdale	chmod -x $@
40b57a2907SKees Cook$(OUTPUT)/load_address.0x%: load_address.c
41b57a2907SKees Cook	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=$(lastword $(subst ., ,$@)) \
42b57a2907SKees Cook		-fPIE -pie $< -o $@
43b57a2907SKees Cook$(OUTPUT)/load_address.static.0x%: load_address.c
44b57a2907SKees Cook	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=$(lastword $(subst ., ,$@)) \
45b57a2907SKees Cook		-fPIE -static-pie $< -o $@
46*b083cc81SMickaël Salaün$(OUTPUT)/false: false.c
47*b083cc81SMickaël Salaün	$(CC) $(CFLAGS) $(LDFLAGS) -static $< -o $@
48