From 56ccb5c794dbc4d07755fcdb8a457ec229b75224 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Tue, 3 May 2022 14:26:25 +0100 Subject: [PATCH] Enable memcpy checks for check shim (#515) Build three levels of checking - None - Checks memcpy only - Checks (full) Currently you can build checks without enabling the memcpy protection. This PR fixes that. --- CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9b07b4..9dc5e93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,7 @@ option(SNMALLOC_NO_REALLOCARR "Build without reallocarr exported" ON) # Options that apply only if we're not building the header-only library cmake_dependent_option(SNMALLOC_RUST_SUPPORT "Build static library for rust" OFF "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF) cmake_dependent_option(SNMALLOC_STATIC_LIBRARY "Build static libraries" ON "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF) -cmake_dependent_option(SNMALLOC_MEMCPY_BOUNDS "Perform bounds checks on memcpy with heap objects" OFF "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF) -cmake_dependent_option(SNMALLOC_CHECK_LOADS "Perform bounds checks on the source argument to memcpy with heap objects" OFF "SNMALLOC_MEMCPY_BOUNDS" OFF) +cmake_dependent_option(SNMALLOC_CHECK_LOADS "Perform bounds checks on the source argument to memcpy with heap objects" OFF "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF) cmake_dependent_option(SNMALLOC_OPTIMISE_FOR_CURRENT_MACHINE "Compile for current machine architecture" Off "NOT SNMALLOC_HEADER_ONLY_LIBRARY" OFF) cmake_dependent_option(SNMALLOC_PAGEID "Set an id to memory regions" OFF "NOT SNMALLOC_PAGEID" OFF) if (NOT SNMALLOC_HEADER_ONLY_LIBRARY) @@ -332,9 +331,7 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY) endfunction() set(SHIM_FILES src/snmalloc/override/new.cc) - if (SNMALLOC_MEMCPY_BOUNDS) - list(APPEND SHIM_FILES src/snmalloc/override/memcpy.cc) - endif () + set(SHIM_FILES_MEMCPY src/snmalloc/override/memcpy.cc) if (SNMALLOC_STATIC_LIBRARY) add_shim(snmallocshim-static STATIC ${SHIM_FILES}) @@ -344,7 +341,8 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY) if(NOT WIN32) add_shim(snmallocshim SHARED ${SHIM_FILES}) - add_shim(snmallocshim-checks SHARED ${SHIM_FILES}) + add_shim(snmallocshim-checks-memcpy-only SHARED ${SHIM_FILES} ${SHIM_FILES_MEMCPY}) + add_shim(snmallocshim-checks SHARED ${SHIM_FILES} ${SHIM_FILES_MEMCPY}) target_compile_definitions(snmallocshim-checks PRIVATE SNMALLOC_CHECK_CLIENT) endif()