blob: 12c5e27d32c1664061e042dbb38fa49cf767a05a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
David Drysdalec9b26b82014-12-12 16:57:36 -08002CFLAGS = -Wall
Alexey Dobriyan4e7301e2019-05-14 15:44:43 -07003CFLAGS += -Wno-nonnull
4CFLAGS += -D_GNU_SOURCE
David Drysdalec9b26b82014-12-12 16:57:36 -08005
Kees Cook0f712412020-08-14 17:30:17 -07006TEST_PROGS := binfmt_script non-regular
Chris Kennelly206e22f2020-10-15 20:12:36 -07007TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216
Muhammad Usama Anjum908a26e2022-01-27 21:33:45 +05008TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
bamvor.zhangjian@huawei.com80d443e82016-11-29 19:55:51 +08009# Makefile is a run-time dependency, since it's accessed by the execveat test
10TEST_FILES := Makefile
11
Alexey Dobriyan4e7301e2019-05-14 15:44:43 -070012TEST_GEN_PROGS += recursion-depth
13
Kees Cook0f712412020-08-14 17:30:17 -070014EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx* \
15 $(OUTPUT)/S_I*.test
bamvor.zhangjian@huawei.com80d443e82016-11-29 19:55:51 +080016
17include ../lib.mk
18
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080019$(OUTPUT)/subdir:
David Drysdalec9b26b82014-12-12 16:57:36 -080020 mkdir -p $@
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080021$(OUTPUT)/script:
David Drysdalec9b26b82014-12-12 16:57:36 -080022 echo '#!/bin/sh' > $@
23 echo 'exit $$*' >> $@
24 chmod +x $@
bamvor.zhangjian@huawei.coma8ba7982016-11-29 19:55:52 +080025$(OUTPUT)/execveat.symlink: $(OUTPUT)/execveat
26 cd $(OUTPUT) && ln -s -f $(shell basename $<) $(shell basename $@)
27$(OUTPUT)/execveat.denatured: $(OUTPUT)/execveat
David Drysdalec9b26b82014-12-12 16:57:36 -080028 cp $< $@
29 chmod -x $@
Chris Kennelly206e22f2020-10-15 20:12:36 -070030$(OUTPUT)/load_address_4096: load_address.c
Yang Yingliang4d1cd3b2021-05-22 17:41:53 -070031 $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000 -pie -static $< -o $@
Chris Kennelly206e22f2020-10-15 20:12:36 -070032$(OUTPUT)/load_address_2097152: load_address.c
Yang Yingliang4d1cd3b2021-05-22 17:41:53 -070033 $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x200000 -pie -static $< -o $@
Chris Kennelly206e22f2020-10-15 20:12:36 -070034$(OUTPUT)/load_address_16777216: load_address.c
Yang Yingliang4d1cd3b2021-05-22 17:41:53 -070035 $(CC) $(CFLAGS) $(LDFLAGS) -Wl,-z,max-page-size=0x1000000 -pie -static $< -o $@