-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (58 loc) · 3.57 KB
/
Copy pathMakefile
File metadata and controls
71 lines (58 loc) · 3.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# core-timeline — M0 build.
# Run inside the native-arch Linux container (see Dockerfile). Outputs to build/.
#
# crash_demo real ring, MADV_DODUMP -> Gate A (distinguish A/B)
# crash_demo_dontdump real ring, MADV_DONTDUMP -> Gate B control (ring excluded)
# crash_demo_noring libtimeline compiled out -> no-library control
#
# -O0 -g and -fno-omit-frame-pointer keep the crash PC stable and ret_addrs honest.
# -no-pie fixes the load base so gdb symbolizes the crash cleanly for the demo
# ("#0 die () at crash_demo.c") — the reader itself is ASLR-independent regardless.
CC ?= gcc
CFLAGS ?= -O0 -g -fno-omit-frame-pointer -no-pie -Wall -Wextra -std=gnu11
SRC = src
BUILD = build
.PHONY: all clean m5
all: $(BUILD)/crash_demo $(BUILD)/crash_demo_dontdump $(BUILD)/crash_demo_noring
# M5 artifacts: the LD_PRELOAD allocator-wrapper .so, the overhead microbench
# (enabled + disabled variants), and the unmodified target fixtures. Built with
# their own flags (the .so needs -fPIC -shared -ldl; the bench needs -lpthread and
# -O2 to reflect real hot-path codegen). Kept separate from `all` so the M0 build
# stays minimal; `make m5` builds them for the demo / manual runs.
m5: $(BUILD)/tl_preload.so $(BUILD)/alloc_demo $(BUILD)/tl_bench $(BUILD)/tl_bench_disabled
$(BUILD):
mkdir -p $(BUILD)
# --- libtimeline object variants -------------------------------------------
$(BUILD)/libtimeline.o: $(SRC)/libtimeline.c $(SRC)/libtimeline.h | $(BUILD)
$(CC) $(CFLAGS) -c $< -o $@
$(BUILD)/libtimeline_dontdump.o: $(SRC)/libtimeline.c $(SRC)/libtimeline.h | $(BUILD)
$(CC) $(CFLAGS) -DTL_NEGATIVE_DONTDUMP -c $< -o $@
# --- fixtures ---------------------------------------------------------------
# Gate A: real ring, included in the core.
$(BUILD)/crash_demo: $(SRC)/crash_demo.c $(BUILD)/libtimeline.o | $(BUILD)
$(CC) $(CFLAGS) -DUSE_TIMELINE $(SRC)/crash_demo.c $(BUILD)/libtimeline.o -o $@
# Gate B control: same recorder, but the mapping is marked MADV_DONTDUMP.
$(BUILD)/crash_demo_dontdump: $(SRC)/crash_demo.c $(BUILD)/libtimeline_dontdump.o | $(BUILD)
$(CC) $(CFLAGS) -DUSE_TIMELINE $(SRC)/crash_demo.c $(BUILD)/libtimeline_dontdump.o -o $@
# No-library control: timeline calls compiled out, libtimeline NOT linked.
$(BUILD)/crash_demo_noring: $(SRC)/crash_demo.c | $(BUILD)
$(CC) $(CFLAGS) $(SRC)/crash_demo.c -o $@
# --- M5: LD_PRELOAD wrappers + overhead microbench --------------------------
# The preload .so bundles libtimeline.c (self-contained: the target binary needs
# nothing linked). -O2 -fPIC -shared, -ldl for dlsym(RTLD_NEXT, ...).
$(BUILD)/tl_preload.so: $(SRC)/tl_preload.c $(SRC)/libtimeline.c $(SRC)/libtimeline.h | $(BUILD)
$(CC) -O2 -g -fPIC -shared -Wall -Wextra -std=gnu11 \
$(SRC)/tl_preload.c $(SRC)/libtimeline.c -I$(SRC) -ldl -o $@
# Unmodified target fixture (NO libtimeline) — gets its timeline only via preload.
$(BUILD)/alloc_demo: tests/alloc_demo.c | $(BUILD)
$(CC) $(CFLAGS) tests/alloc_demo.c -o $@
# Overhead microbench (-O2 reflects real hot-path codegen; -lpthread for the
# 8-thread contention measurement). Disabled variant compiles tl_mark out.
$(BUILD)/tl_bench: bench/tl_bench.c bench/fat_mark.c $(SRC)/libtimeline.c | $(BUILD)
$(CC) -O2 -g -Wall -Wextra -std=gnu11 \
bench/tl_bench.c bench/fat_mark.c $(SRC)/libtimeline.c -I$(SRC) -lpthread -o $@
$(BUILD)/tl_bench_disabled: bench/tl_bench.c bench/fat_mark.c $(SRC)/libtimeline.c | $(BUILD)
$(CC) -O2 -g -Wall -Wextra -std=gnu11 -DTL_BENCH_DISABLED \
bench/tl_bench.c bench/fat_mark.c $(SRC)/libtimeline.c -I$(SRC) -lpthread -o $@
clean:
rm -rf $(BUILD)