Makefile 1.3 KB

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