Fix libfuzzer detection and shared object symbols issues
Don't export __throw_length_error, and don't import abort
This commit is contained in:
@@ -21,6 +21,10 @@ target_compile_options(conflict_set PRIVATE -fno-exceptions -fvisibility=hidden)
|
|||||||
target_link_options(conflict_set PRIVATE -nodefaultlibs -lc -fvisibility=hidden)
|
target_link_options(conflict_set PRIVATE -nodefaultlibs -lc -fvisibility=hidden)
|
||||||
add_custom_command(TARGET conflict_set POST_BUILD COMMAND ${CMAKE_STRIP} -x $<TARGET_FILE:conflict_set>)
|
add_custom_command(TARGET conflict_set POST_BUILD COMMAND ${CMAKE_STRIP} -x $<TARGET_FILE:conflict_set>)
|
||||||
|
|
||||||
|
if (NOT APPLE)
|
||||||
|
target_link_options(conflict_set PRIVATE "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/linker.map")
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
# unit test
|
# unit test
|
||||||
@@ -52,7 +56,7 @@ add_test(NAME conflict_set_cxx_api_test COMMAND conflict_set_cxx_api_test)
|
|||||||
target_compile_options(conflict_set_cxx_api_test PRIVATE -Wall -Wextra -Wpedantic -Wunreachable-code -Werror)
|
target_compile_options(conflict_set_cxx_api_test PRIVATE -Wall -Wextra -Wpedantic -Wunreachable-code -Werror)
|
||||||
|
|
||||||
# fuzz test
|
# fuzz test
|
||||||
set(FUZZ_FLAGS "-fsanitize=fuzzer,address,undefined")
|
set(FUZZ_FLAGS "-fsanitize=fuzzer-no-link,address,undefined")
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
set(CMAKE_REQUIRED_LINK_OPTIONS ${FUZZ_FLAGS})
|
set(CMAKE_REQUIRED_LINK_OPTIONS ${FUZZ_FLAGS})
|
||||||
check_cxx_compiler_flag(${FUZZ_FLAGS} HAS_LIB_FUZZER)
|
check_cxx_compiler_flag(${FUZZ_FLAGS} HAS_LIB_FUZZER)
|
||||||
@@ -64,5 +68,5 @@ if (HAS_LIB_FUZZER)
|
|||||||
target_compile_options(conflict_set_fuzz_test PRIVATE -UNDEBUG)
|
target_compile_options(conflict_set_fuzz_test PRIVATE -UNDEBUG)
|
||||||
target_compile_options(conflict_set_fuzz_test PRIVATE -Wall -Wextra -Wpedantic -Wunreachable-code)
|
target_compile_options(conflict_set_fuzz_test PRIVATE -Wall -Wextra -Wpedantic -Wunreachable-code)
|
||||||
target_compile_options(conflict_set_fuzz_test PRIVATE ${FUZZ_FLAGS})
|
target_compile_options(conflict_set_fuzz_test PRIVATE ${FUZZ_FLAGS})
|
||||||
target_link_options(conflict_set_fuzz_test PRIVATE ${FUZZ_FLAGS})
|
target_link_options(conflict_set_fuzz_test PRIVATE ${FUZZ_FLAGS} -fsanitize=fuzzer)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -152,7 +152,7 @@ template <class T> struct ArenaAlloc {
|
|||||||
|
|
||||||
[[nodiscard]] T *allocate(size_t n) {
|
[[nodiscard]] T *allocate(size_t n) {
|
||||||
if (n > 0xfffffffffffffffful / sizeof(T)) { // NOLINT
|
if (n > 0xfffffffffffffffful / sizeof(T)) { // NOLINT
|
||||||
abort();
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<T *>((void *)new (std::align_val_t(alignof(T)), *arena)
|
return static_cast<T *>((void *)new (std::align_val_t(alignof(T)), *arena)
|
||||||
@@ -1136,7 +1136,7 @@ __attribute__((__visibility__("default"))) void ConflictSet_destroy(void *cs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
void __throw_length_error(const char *) { abort(); }
|
void __throw_length_error(const char *) { __builtin_unreachable(); }
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
7
linker.map
Normal file
7
linker.map
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
global:
|
||||||
|
*ConflictSet*;
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
||||||
|
|
Reference in New Issue
Block a user