Skip to content

Commit

Permalink
[SBCETS] Add SoftBound+CETS compiler pass and runtime library
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Orthen committed Apr 18, 2024
1 parent fed4134 commit 311184f
Show file tree
Hide file tree
Showing 14 changed files with 14,619 additions and 1 deletion.
13 changes: 12 additions & 1 deletion compiler-rt/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ set(ALL_SANITIZER_COMMON_SUPPORTED_ARCH ${X86} ${X86_64} ${PPC64} ${RISCV64}
${ARM32} ${ARM64} ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9})
set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9})
set(ALL_SOFTBOUNDCETS_SUPPORTED_ARCH ${X86} ${X86_64})
set(ALL_CRT_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV32} ${RISCV64} ${VE})
set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})

Expand Down Expand Up @@ -539,6 +540,9 @@ if(APPLE)
list_intersect(ASAN_SUPPORTED_ARCH
ALL_ASAN_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
list_intersect(SOFTBOUNDCETS_SUPPORTED_ARCH
ALL_SOFTBOUNDCETS_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
list_intersect(DFSAN_SUPPORTED_ARCH
ALL_DFSAN_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
Expand Down Expand Up @@ -600,6 +604,7 @@ else()
filter_available_targets(UBSAN_COMMON_SUPPORTED_ARCH
${SANITIZER_COMMON_SUPPORTED_ARCH})
filter_available_targets(ASAN_SUPPORTED_ARCH ${ALL_ASAN_SUPPORTED_ARCH})
filter_available_targets(SOFTBOUNDCETS_SUPPORTED_ARCH ${ALL_SOFTBOUNDCETS_SUPPORTED_ARCH})
filter_available_targets(FUZZER_SUPPORTED_ARCH ${ALL_FUZZER_SUPPORTED_ARCH})
filter_available_targets(DFSAN_SUPPORTED_ARCH ${ALL_DFSAN_SUPPORTED_ARCH})
filter_available_targets(LSAN_SUPPORTED_ARCH ${ALL_LSAN_SUPPORTED_ARCH})
Expand Down Expand Up @@ -640,7 +645,7 @@ if(COMPILER_RT_SUPPORTED_ARCH)
endif()
message(STATUS "Compiler-RT supported architectures: ${COMPILER_RT_SUPPORTED_ARCH}")

set(ALL_SANITIZERS asan;dfsan;msan;hwasan;tsan;safestack;cfi;scudo;ubsan_minimal;gwp_asan)
set(ALL_SANITIZERS asan;softboundcets;dfsan;msan;hwasan;tsan;safestack;cfi;scudo;ubsan_minimal;gwp_asan)
set(COMPILER_RT_SANITIZERS_TO_BUILD all CACHE STRING
"sanitizers to build if supported on the target (all;${ALL_SANITIZERS})")
list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
Expand All @@ -666,6 +671,12 @@ else()
set(COMPILER_RT_HAS_ASAN FALSE)
endif()

if (COMPILER_RT_HAS_SANITIZER_COMMON AND SOFTBOUNDCETS_SUPPORTED_ARCH)
set(COMPILER_RT_HAS_SOFTBOUNDCETS TRUE)
else()
set(COMPILER_RT_HAS_SOFTBOUNDCETS FALSE)
endif()

if (OS_NAME MATCHES "Linux|FreeBSD|Windows|NetBSD|SunOS")
set(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME TRUE)
else()
Expand Down
157 changes: 157 additions & 0 deletions compiler-rt/lib/softboundcets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
set(SOFTBOUNDCETS_SOURCES
softboundcets.cpp
softboundcets-wrappers.cpp
)

set(SOFTBOUNDCETS_HEADERS
softboundcets.h
)

set(SOFTBOUNDCETS_COMMON_CFLAGS ${SANITIZER_COMMON_CFLAGS} -D__SOFTBOUNDCETS_SPATIAL_TEMPORAL=1 -O2)

set(SOFTBOUNDCETS_STANDARD_CFLAGS ${SOFTBOUNDCETS_COMMON_CFLAGS} -DLOG_LEVEL=3 -g)
set(SOFTBOUNDCETS_DYNAMIC_CFLAGS ${SOFTBOUNDCETS_COMMON_CFLAGS} -D__SOFTBOUNDCETS_DYNAMIC_RT=1 -DLOG_LEVEL=3 -O0 -g)
set(SOFTBOUNDCETS_INLINING_CFLAGS ${SOFTBOUNDCETS_COMMON_CFLAGS} -flto -g0)
set(SOFTBOUNDCETS_BENCHMARK_CFLAGS ${SOFTBOUNDCETS_COMMON_CFLAGS} -D__SOFTBOUNDCETS_BENCHMARKING=1 -g -O3)
set(SOFTBOUNDCETS_BENCHMARK_INLINING_CFLAGS ${SOFTBOUNDCETS_COMMON_CFLAGS} -D__SOFTBOUNDCETS_BENCHMARKING=1 -flto -O3 -g0)
set(SOFTBOUNDCETS_BENCHMARK_INLINING_INVALID_LOCKS_CFLAGS ${SOFTBOUNDCETS_COMMON_CFLAGS} -D__SOFTBOUNDCETS_BENCHMARKING=1 -D__SOFTBOUNDCETS_PREVENT_SEGFAULTS_ON_INVALID_LOCKS=1 -flto -O3 -g0)

append_rtti_flag(OFF SANITIZER_COMMON_CFLAGS)

set(SOFTBOUNDCETS_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
set(SOFTBOUNDCETS_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARIES} ${SANITIZER_COMMON_LINK_LIBS})

append_list_if(COMPILER_RT_HAS_LIBDL dl SOFTBOUNDCETS_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBRT rt SOFTBOUNDCETS_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBM m SOFTBOUNDCETS_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBPTHREAD pthread SOFTBOUNDCETS_DYNAMIC_LIBS)
append_list_if(COMPILER_RT_HAS_LIBLOG log SOFTBOUNDCETS_DYNAMIC_LIBS)



add_compiler_rt_component(softboundcets)

add_compiler_rt_object_libraries(RTsoftboundcets_dynamic
OS ${SANITIZER_COMMON_SUPPORTED_OS}
ARCHS ${SOFTBOUNDCETS_SUPPORTED_ARCH}
SOURCES ${SOFTBOUNDCETS_SOURCES}
ADDITIONAL_HEADERS ${SOFTBOUNDCETS_HEADERS}
CFLAGS ${SOFTBOUNDCETS_DYNAMIC_CFLAGS})


add_compiler_rt_object_libraries(RTsoftboundcets
ARCHS ${SOFTBOUNDCETS_SUPPORTED_ARCH}
SOURCES ${SOFTBOUNDCETS_SOURCES}
ADDITIONAL_HEADERS ${SOFTBOUNDCETS_HEADERS}
CFLAGS ${SOFTBOUNDCETS_STANDARD_CFLAGS}
)

add_compiler_rt_object_libraries(RTsoftboundcets_benchmark
ARCHS ${SOFTBOUNDCETS_SUPPORTED_ARCH}
SOURCES ${SOFTBOUNDCETS_SOURCES}
ADDITIONAL_HEADERS ${SOFTBOUNDCETS_HEADERS}
CFLAGS ${SOFTBOUNDCETS_BENCHMARK_CFLAGS}
)

add_compiler_rt_object_libraries(RTsoftboundcets_inlining
ARCHS ${SOFTBOUNDCETS_SUPPORTED_ARCH}
SOURCES ${SOFTBOUNDCETS_SOURCES}
ADDITIONAL_HEADERS ${SOFTBOUNDCETS_HEADERS}
CFLAGS ${SOFTBOUNDCETS_INLINING_CFLAGS}
)

add_compiler_rt_object_libraries(RTsoftboundcets_benchmark_inlining
ARCHS ${SOFTBOUNDCETS_SUPPORTED_ARCH}
SOURCES ${SOFTBOUNDCETS_SOURCES}
ADDITIONAL_HEADERS ${SOFTBOUNDCETS_HEADERS}
CFLAGS ${SOFTBOUNDCETS_BENCHMARK_INLINING_CFLAGS}
)

add_compiler_rt_object_libraries(RTsoftboundcets_benchmark_inlining_invalid_locks
ARCHS ${SOFTBOUNDCETS_SUPPORTED_ARCH}
SOURCES ${SOFTBOUNDCETS_SOURCES}
ADDITIONAL_HEADERS ${SOFTBOUNDCETS_HEADERS}
CFLAGS ${SOFTBOUNDCETS_BENCHMARK_INLINING_INVALID_LOCKS_CFLAGS}
)



include_directories(..)

foreach(arch ${SOFTBOUNDCETS_SUPPORTED_ARCH})
add_compiler_rt_runtime(clang_rt.softboundcets
STATIC
ARCHS ${arch}
OBJECT_LIBS RTsoftboundcets
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
CFLAGS ${SOFTBOUNDCETS_COMMON_CFLAGS}
PARENT_TARGET softboundcets)

add_compiler_rt_runtime(clang_rt.softboundcets_benchmark
STATIC
ARCHS ${arch}
OBJECT_LIBS RTsoftboundcets_benchmark
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
CFLAGS ${SOFTBOUNDCETS_BENCHMARK_CFLAGS}
PARENT_TARGET softboundcets)

add_compiler_rt_runtime(clang_rt.softboundcets_inlining
STATIC
ARCHS ${arch}
OBJECT_LIBS RTsoftboundcets_inlining
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
CFLAGS ${SOFTBOUNDCETS_INLINING_CFLAGS}
PARENT_TARGET softboundcets)

add_compiler_rt_runtime(clang_rt.softboundcets_benchmark_inlining
STATIC
ARCHS ${arch}
OBJECT_LIBS RTsoftboundcets_benchmark_inlining
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
CFLAGS ${SOFTBOUNDCETS_BENCHMARK_INLINING_CFLAGS}
PARENT_TARGET softboundcets)

add_compiler_rt_runtime(clang_rt.softboundcets_benchmark_inlining_invalid_locks
STATIC
ARCHS ${arch}
OBJECT_LIBS RTsoftboundcets_benchmark_inlining_invalid_locks
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
CFLAGS ${SOFTBOUNDCETS_BENCHMARK_INLINING_INVALID_LOCKS_CFLAGS}
PARENT_TARGET softboundcets)

add_compiler_rt_runtime(clang_rt.softboundcets
SHARED
ARCHS ${arch}
OBJECT_LIBS RTsoftboundcets_dynamic
RTInterception
RTSanitizerCommon
RTSanitizerCommonLibc
RTSanitizerCommonCoverage
RTSanitizerCommonSymbolizer
CFLAGS ${SOFTBOUNDCETS_DYNAMIC_CFLAGS}
LINK_FLAGS ${SOFTBOUNDCETS_DYNAMIC_LINK_FLAGS}
LINK_LIBS ${SOFTBOUNDCETS_DYNAMIC_LIBS}
ADDITIONAL_HEADERS ${SOFTBOUNDCETS_HEADERS}
PARENT_TARGET softboundcets)

endforeach()
Loading

0 comments on commit 311184f

Please sign in to comment.