aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-07-11 18:22:52 -0700
committerGitHub <noreply@github.com>2024-07-11 18:22:52 -0700
commita853fe25df1cda0117055c0d836e7b107d98c791 (patch)
tree9429d72552554782a3fbdbd5195c1ec987a37eb7 /clang/lib/CodeGen/CodeGenModule.h
parent1bafe77d773e6cb32243fabbef2c71b4516896fb (diff)
downloadllvm-a853fe25df1cda0117055c0d836e7b107d98c791.zip
llvm-a853fe25df1cda0117055c0d836e7b107d98c791.tar.gz
llvm-a853fe25df1cda0117055c0d836e7b107d98c791.tar.bz2
[nsan] Add nsan_preinit.cpp and make it static library only
#94322 defines .preinit_array to initialize nsan early. DT_PREINIT_ARRAY can only be used with the main executable. GNU ld would complain when a DSO has .preinit_array. Therefore, nsan_preinit.cpp cannot be linked into `libclang_rt.nsan.so` (#98415). Working with @alexander-shaposhnikov, we noticed that `Nsan-x86_64-Test --gtest_output=json` without `.preinit_array` will sigsegv. This is because googletest with the JSON output calls `localtime_r` , which calls `free(0)` and fails when `REAL(free)` remains uninitialized (nullptr). This is benign with the default output because malloc/free are all paired and `REAL(free)(ptr)` is not called. To fix the unittest failure, `__nsan_init` needs to be called early (.preinit_array). `asan/tests/CMakeLists.txt:ASAN_UNITTEST_INSTRUMENTED_LINK_FLAGS` ues `-fsanitize=address` to ensure `asan_preinit.cpp.o` is linked into the unittest executable. Port the approach and remove `NSAN_TEST_RUNTIME_OBJECTS`. Fix #98523 Pull Request: https://github.com/llvm/llvm-project/pull/98564
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
0 files changed, 0 insertions, 0 deletions