1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 2c9b26b81SDavid DrysdaleCFLAGS = -Wall 34e7301e6SAlexey DobriyanCFLAGS += -Wno-nonnull 44e7301e6SAlexey DobriyanCFLAGS += -D_GNU_SOURCE 5c9b26b81SDavid Drysdale 6b57a2907SKees CookALIGNS := 0x1000 0x200000 0x1000000 7b57a2907SKees CookALIGN_PIES := $(patsubst %,load_address.%,$(ALIGNS)) 8b57a2907SKees CookALIGN_STATIC_PIES := $(patsubst %,load_address.static.%,$(ALIGNS)) 9*3545deffSKees CookALIGNMENT_TESTS := $(ALIGN_PIES) $(ALIGN_STATIC_PIES) 10b57a2907SKees Cook 114893992bSMuhammad Usama AnjumTEST_PROGS := binfmt_script.py 12b57a2907SKees CookTEST_GEN_PROGS := execveat non-regular $(ALIGNMENT_TESTS) 13908a26e1SMuhammad Usama AnjumTEST_GEN_FILES := execveat.symlink execveat.denatured script subdir 1480d443e8S[email protected]# Makefile is a run-time dependency, since it's accessed by the execveat test 1580d443e8S[email protected]TEST_FILES := Makefile 1680d443e8S[email protected] 174e7301e6SAlexey DobriyanTEST_GEN_PROGS += recursion-depth 189132c394SKees CookTEST_GEN_PROGS += null-argv 194e7301e6SAlexey Dobriyan 200f71241aSKees CookEXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx* \ 210f71241aSKees Cook $(OUTPUT)/S_I*.test 2280d443e8S[email protected] 2380d443e8S[email protected]include ../lib.mk 2480d443e8S[email protected] 25a8ba798bS[email protected]$(OUTPUT)/subdir: 26c9b26b81SDavid Drysdale mkdir -p $@ 27472874cfSKees Cook$(OUTPUT)/script: Makefile 28472874cfSKees Cook echo '#!/bin/bash' > $@ 29c9b26b81SDavid Drysdale echo 'exit $$*' >> $@ 30c9b26b81SDavid Drysdale chmod +x $@ 31a8ba798bS[email protected]$(OUTPUT)/execveat.symlink: $(OUTPUT)/execveat 32a8ba798bS[email protected] cd $(OUTPUT) && ln -s -f $(shell basename $<) $(shell basename $@) 33a8ba798bS[email protected]$(OUTPUT)/execveat.denatured: $(OUTPUT)/execveat 34c9b26b81SDavid Drysdale cp $< $@ 35c9b26b81SDavid Drysdale chmod -x $@ 36b57a2907SKees Cook$(OUTPUT)/load_address.0x%: load_address.c 37b57a2907SKees Cook $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=$(lastword $(subst ., ,$@)) \ 38b57a2907SKees Cook -fPIE -pie $< -o $@ 39b57a2907SKees Cook$(OUTPUT)/load_address.static.0x%: load_address.c 40b57a2907SKees Cook $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=$(lastword $(subst ., ,$@)) \ 41b57a2907SKees Cook -fPIE -static-pie $< -o $@ 42