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