1
0

proj: Combine test_preload.c and test_wrap.c into intercept.c

This commit is contained in:
2025-01-13 11:16:13 +01:00
parent 6c70a3c401
commit 526893b78a
7 changed files with 383 additions and 330 deletions

View File

@@ -4,24 +4,27 @@ CFLAGS=-std=c99 -pedantic -Wall -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -
.PHONY: all clean
all: default
default: bin main test_preload.so main_wrapped #test_kernel.ko
default: bin main intercept.so main_intercept #test_kernel.ko
bin:
mkdir -p bin/
bin/test_preload.o: src/test_preload.c
$(CC) -fPIC -c -o $@ $^ $(CFLAGS)
bin/main.o: src/main.c
$(CC) -c -o $@ $^ $(CFLAGS)
test_preload.so: bin/test_preload.o
bin/intercept_preload.o: src/intercept.c
$(CC) -fPIC -c -o $@ $^ $(CFLAGS) -DINTERCEPT_PRELOAD
intercept.so: bin/intercept_preload.o
$(CC) -shared -o $@ $^ $(CFLAGS) -lc -ldl
test_kernel.ko: src/test_kernel.c
$(CC) -D__KERNEL__ -DMODULE -I/usr/src/linux/include -o $@ $^
main: src/main.c
main: bin/main.o
$(CC) -o $@ $^ $(CFLAGS) -lc
main_wrapped: src/main.c src/test_wrap.c
main_intercept: bin/main.o src/intercept.c
$(CC) -o $@ $^ $(CFLAGS) -lc -Wl,--wrap=malloc,--wrap=free,--wrap=calloc,--wrap=realloc,--wrap=getopt
clean: