18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ciCFLAGS = -Wall
38c2ecf20Sopenharmony_ciCFLAGS += -Wno-nonnull
48c2ecf20Sopenharmony_ciCFLAGS += -D_GNU_SOURCE
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciTEST_PROGS := binfmt_script
78c2ecf20Sopenharmony_ciTEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216 non-regular
88c2ecf20Sopenharmony_ciTEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
98c2ecf20Sopenharmony_ci# Makefile is a run-time dependency, since it's accessed by the execveat test
108c2ecf20Sopenharmony_ciTEST_FILES := Makefile
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciTEST_GEN_PROGS += recursion-depth
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciEXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx*	\
158c2ecf20Sopenharmony_ci	       $(OUTPUT)/S_I*.test
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciinclude ../lib.mk
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci$(OUTPUT)/subdir:
208c2ecf20Sopenharmony_ci	mkdir -p $@
218c2ecf20Sopenharmony_ci$(OUTPUT)/script:
228c2ecf20Sopenharmony_ci	echo '#!/bin/sh' > $@
238c2ecf20Sopenharmony_ci	echo 'exit $$*' >> $@
248c2ecf20Sopenharmony_ci	chmod +x $@
258c2ecf20Sopenharmony_ci$(OUTPUT)/execveat.symlink: $(OUTPUT)/execveat
268c2ecf20Sopenharmony_ci	cd $(OUTPUT) && ln -s -f $(shell basename $<) $(shell basename $@)
278c2ecf20Sopenharmony_ci$(OUTPUT)/execveat.denatured: $(OUTPUT)/execveat
288c2ecf20Sopenharmony_ci	cp $< $@
298c2ecf20Sopenharmony_ci	chmod -x $@
308c2ecf20Sopenharmony_ci$(OUTPUT)/load_address_4096: load_address.c
318c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000 -pie -static $< -o $@
328c2ecf20Sopenharmony_ci$(OUTPUT)/load_address_2097152: load_address.c
338c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x200000 -pie -static $< -o $@
348c2ecf20Sopenharmony_ci$(OUTPUT)/load_address_16777216: load_address.c
358c2ecf20Sopenharmony_ci	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000000 -pie -static $< -o $@
36