1# SPDX-License-Identifier: GPL-2.0
2CFLAGS = -Wall
3CFLAGS += -Wno-nonnull
4CFLAGS += -D_GNU_SOURCE
5
6TEST_PROGS := binfmt_script non-regular
7TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216
8TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir pipe
9# Makefile is a run-time dependency, since it's accessed by the execveat test
10TEST_FILES := Makefile
11
12TEST_GEN_PROGS += recursion-depth
13
14EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx*	\
15	       $(OUTPUT)/S_I*.test
16
17include ../lib.mk
18
19$(OUTPUT)/subdir:
20	mkdir -p $@
21$(OUTPUT)/script:
22	echo '#!/bin/sh' > $@
23	echo 'exit $$*' >> $@
24	chmod +x $@
25$(OUTPUT)/execveat.symlink: $(OUTPUT)/execveat
26	cd $(OUTPUT) && ln -s -f $(shell basename $<) $(shell basename $@)
27$(OUTPUT)/execveat.denatured: $(OUTPUT)/execveat
28	cp $< $@
29	chmod -x $@
30$(OUTPUT)/load_address_4096: load_address.c
31	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000 -pie -static $< -o $@
32$(OUTPUT)/load_address_2097152: load_address.c
33	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x200000 -pie -static $< -o $@
34$(OUTPUT)/load_address_16777216: load_address.c
35	$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000000 -pie -static $< -o $@
36