Skip to content

Commit e8b4d74

Browse files
committed
refactor Makefile, write it in the real Makefile syntax
1 parent 2042f94 commit e8b4d74

File tree

2 files changed

+25
-41
lines changed

2 files changed

+25
-41
lines changed

Makefile

Lines changed: 24 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,30 @@
1-
BASE = malloc_playground first_fit calc_tcache_idx
2-
V2.23 = fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack house_of_einherjar house_of_force house_of_gods house_of_lore house_of_mind_fastbin house_of_orange house_of_roman house_of_spirit house_of_storm large_bin_attack mmap_overlapping_chunks overlapping_chunks overlapping_chunks_2 poison_null_byte unsafe_unlink unsorted_bin_attack unsorted_bin_into_stack sysmalloc_int_free
3-
V2.24 = fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack house_of_einherjar house_of_force house_of_gods house_of_lore house_of_mind_fastbin house_of_roman house_of_spirit house_of_storm large_bin_attack mmap_overlapping_chunks overlapping_chunks overlapping_chunks_2 poison_null_byte unsafe_unlink unsorted_bin_attack unsorted_bin_into_stack sysmalloc_int_free
4-
V2.27 = fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_force house_of_lore house_of_mind_fastbin house_of_spirit house_of_storm large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink unsorted_bin_attack unsorted_bin_into_stack sysmalloc_int_free house_of_tangerine
5-
V2.31 = fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink sysmalloc_int_free house_of_tangerine
6-
V2.32 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
7-
V2.33 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
8-
V2.34 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
9-
V2.35 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
10-
V2.36 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
11-
V2.37 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
12-
V2.38 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
13-
V2.39 = decrypt_safe_linking fastbin_dup fastbin_dup_consolidate fastbin_dup_into_stack fastbin_reverse_into_tcache house_of_botcake house_of_einherjar house_of_lore house_of_mind_fastbin house_of_spirit large_bin_attack mmap_overlapping_chunks overlapping_chunks poison_null_byte tcache_house_of_spirit tcache_poisoning tcache_stashing_unlink_attack unsafe_unlink safe_link_double_protect house_of_water sysmalloc_int_free house_of_tangerine
14-
15-
# turn technique names into paths
16-
VV2.23 = $(addprefix glibc_2.23/, $(V2.23))
17-
VV2.24 = $(addprefix glibc_2.24/, $(V2.24))
18-
VV2.27 = $(addprefix glibc_2.27/, $(V2.27))
19-
VV2.31 = $(addprefix glibc_2.31/, $(V2.31))
20-
VV2.32 = $(addprefix glibc_2.32/, $(V2.32))
21-
VV2.33 = $(addprefix glibc_2.33/, $(V2.33))
22-
VV2.34 = $(addprefix glibc_2.34/, $(V2.34))
23-
VV2.35 = $(addprefix glibc_2.35/, $(V2.35))
24-
VV2.36 = $(addprefix glibc_2.36/, $(V2.36))
25-
VV2.37 = $(addprefix glibc_2.37/, $(V2.37))
26-
VV2.38 = $(addprefix glibc_2.38/, $(V2.38))
27-
VV2.39 = $(addprefix glibc_2.39/, $(V2.39))
28-
29-
PROGRAMS = $(BASE) $(VV2.23) $(VV2.24) $(VV2.27) $(VV2.31) $(VV2.32) $(VV2.33) $(VV2.34) $(VV2.35) $(VV2.36) $(VV2.37) $(VV2.38) $(VV2.39)
1+
.PHONY: help clean all test
2+
3+
VERSIONS := 2.23 2.24 2.27 2.31 2.32 2.33 2.34 2.35 2.36 2.37 2.38 2.39
4+
TECH_BINS := $(patsubst %.c,%,$(wildcard glibc_*/*.c))
5+
BASE_BINS := $(patsubst %.c,%,$(wildcard *.c))
6+
BINS := $(TECH_BINS) $(BASE_BINS)
7+
8+
help:
9+
@echo 'make help - show this message'
10+
@echo 'make base - build all base binaries, namely `malloc_playground`, `first_fit`, `calc_tcache_idx`'
11+
@echo 'make <version> - build all the techniques for the specific version. e.g. `make v2.39`'
12+
@echo 'make clean - remove all built binaries'
13+
@echo 'make all - build all binaries'
14+
@echo 'make test version=<version> - test run all techniques for the specific version. e.g. `make test version=2.39`'
15+
3016
CFLAGS += -std=c99 -g -Wno-unused-result -Wno-free-nonheap-object
3117
LDLIBS += -ldl
3218

33-
# Convenience to auto-call mcheck before the first malloc()
34-
#CFLAGS += -lmcheck
19+
base: $(BASE_BINS)
20+
21+
$(foreach version,$(VERSIONS),$(eval v$(version): $(patsubst %.c,%,$(wildcard glibc_$(version)/*.c))))
22+
23+
all: $(BINS)
3524

36-
all: $(PROGRAMS)
3725
clean:
38-
rm -f $(PROGRAMS)
26+
@rm -f $(BINS)
27+
@echo "all the built binaries are removed."
3928

4029
define test_poc =
4130
echo $(poc)
@@ -48,10 +37,5 @@ done
4837
echo "success"
4938
endef
5039

51-
#if [ "$$i" == "5" ]; then exit 1; fi;\
52-
53-
test: $(PROGRAMS)
54-
@if [ -z "$(target)" ] || [ -z "$(VV$(target))" ];\
55-
then echo "run 'make test target=<target_version>' to test existing techniques"; exit 1; fi;
56-
57-
@$(foreach poc,$(VV$(target)),$(call test_poc,$(poc));)
40+
test: v$(version)
41+
@$(foreach poc,$(patsubst %.c,%,$(wildcard glibc_$(version)/*.c)),$(call test_poc,$(poc));)

ci/test/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ runs:
1818

1919
- name: test how2heap inside the raw container
2020
run: |
21-
docker run -v /tmp/how2heap:/how2heap ubuntu_test bash -c 'cd /how2heap; ./make test target=${{ inputs.glibc }}'
21+
docker run -v /tmp/how2heap:/how2heap ubuntu_test bash -c 'cd /how2heap; ./make test version=${{ inputs.glibc }}'
2222
shell: bash

0 commit comments

Comments
 (0)