@@ -108,8 +108,8 @@ ALLOC_SANITY = -DALLOC_SANITY=0
108108# # not require ALLOC_SANITY is enabled. On MacOS you need
109109# # to set FORTIFY_SOURCE to 0. Leave these commented if
110110# # you aren't enabling them.
111- # MEMCPY_SANITY = -DMEMCPY_SANITY=0 -D_FORTIFY_SOURCE =0
112- # MEMSET_SANITY = -DMEMSET_SANITY=0 -D_FORTIFY_SOURCE =0
111+ MEMCPY_SANITY = -DMEMCPY_SANITY=0
112+ MEMSET_SANITY = -DMEMSET_SANITY=0
113113
114114# # Enable the userfaultfd based uninitialized read detection
115115# # feature. This samples calls to malloc, and allocates raw
@@ -181,6 +181,9 @@ UNAME := $(shell uname)
181181ifeq ($(UNAME ) , Darwin)
182182OS_FLAGS = -framework Security
183183LIBNAME = libisoalloc.dylib
184+ ifeq ($(MEMSET_SANITY ) , -DMEMSET_SANITY=1) || ($(MEMCPY_SANITY ) , -DMEMCPY_SANITY=1)
185+ CFLAGS += -D_FORTIFY_SOURCE=0
186+ endif
184187endif
185188
186189ifeq ($(UNAME ) , Linux)
@@ -218,7 +221,7 @@ BUILD_ERROR_FLAGS := $(BUILD_ERROR_FLAGS) -Werror -pedantic
218221else
219222BUILD_ERROR_FLAGS := $(BUILD_ERROR_FLAGS ) -Wno-attributes -Wno-unused-variable
220223endif
221- CFLAGS = $(COMMON_CFLAGS ) $(SECURITY_FLAGS ) $(BUILD_ERROR_FLAGS ) $(HOOKS ) $(HEAP_PROFILER ) -fvisibility=hidden \
224+ CFLAGS + = $(COMMON_CFLAGS ) $(SECURITY_FLAGS ) $(BUILD_ERROR_FLAGS ) $(HOOKS ) $(HEAP_PROFILER ) -fvisibility=hidden \
222225 -std=c11 $(SANITIZER_SUPPORT ) $(ALLOC_SANITY ) $(MEMCPY_SANITY ) $(UNINIT_READ_SANITY ) $(CPU_PIN ) $(SCHED_GETCPU ) \
223226 $(EXPERIMENTAL ) $(UAF_PTR_PAGE ) $(VERIFY_BIT_SLOT_CACHE ) $(NAMED_MAPPINGS ) $(ABORT_ON_NULL ) $(NO_ZERO_ALLOCATIONS ) \
224227 $(ABORT_NO_ENTROPY ) $(ISO_DTOR_CLEANUP ) $(SHUFFLE_BIT_SLOT_CACHE ) $(USE_SPINLOCK ) $(HUGE_PAGES ) $(USE_MLOCK ) \
@@ -313,6 +316,7 @@ tests: clean library_debug_unit_tests
313316libc_sanity_tests : clean library_debug_unit_tests
314317 $(CC ) $(CFLAGS ) $(EXE_CFLAGS ) $(DEBUG_LOG_FLAGS ) $(GDB_FLAGS ) $(OS_FLAGS ) tests/memset_sanity.c $(ISO_ALLOC_PRINTF_SRC ) -o $(BUILD_DIR ) /memset_sanity $(LDFLAGS )
315318 $(CC ) $(CFLAGS ) $(EXE_CFLAGS ) $(DEBUG_LOG_FLAGS ) $(GDB_FLAGS ) $(OS_FLAGS ) tests/memcpy_sanity.c $(ISO_ALLOC_PRINTF_SRC ) -o $(BUILD_DIR ) /memcpy_sanity $(LDFLAGS )
319+ build/memset_sanity ; build/memcpy_sanity
316320
317321fuzz_test : clean library_debug_unit_tests
318322 @echo " make fuzz_test"
@@ -335,6 +339,9 @@ perf_tests: clean
335339# # compared to the same malloc/free operations
336340malloc_cmp_test : clean
337341 @echo " make malloc_cmp_test"
342+ ifeq ($(MEMSET_SANITY ) , -DMEMSET_SANITY=1) || ($(MEMCPY_SANITY ) , -DMEMCPY_SANITY=1)
343+ $(error "Please unset MEMSET_SANITY/MEMCPY_SANITY before running this test")
344+ endif
338345 $(CC) $(CFLAGS) $(C_SRCS) $(OPTIMIZE) $(EXE_CFLAGS) $(OS_FLAGS) tests/tests.c -o $(BUILD_DIR)/tests
339346 $(CC) $(CFLAGS) $(OPTIMIZE) $(EXE_CFLAGS) $(OS_FLAGS) -DMALLOC_PERF_TEST $(ISO_ALLOC_PRINTF_SRC) tests/tests.c -o $(BUILD_DIR)/malloc_tests
340347 echo "Running IsoAlloc Performance Test"
0 commit comments