@@ -32,20 +32,6 @@ set(ASAN_SOURCES
32
32
asan_win.cpp
33
33
)
34
34
35
- if (WIN32 )
36
- set (ASAN_DYNAMIC_RUNTIME_THUNK_SOURCES
37
- asan_globals_win.cpp
38
- asan_win_common_runtime_thunk.cpp
39
- asan_win_dynamic_runtime_thunk.cpp
40
- )
41
- set (ASAN_STATIC_RUNTIME_THUNK_SOURCES
42
- asan_globals_win.cpp
43
- asan_malloc_win_thunk.cpp
44
- asan_win_common_runtime_thunk.cpp
45
- asan_win_static_runtime_thunk.cpp
46
- )
47
- endif ()
48
-
49
35
if (NOT WIN32 AND NOT APPLE )
50
36
list (APPEND ASAN_SOURCES
51
37
asan_interceptors_vfork.S
@@ -150,7 +136,7 @@ append_list_if(MINGW "${MINGW_LIBRARIES}" ASAN_DYNAMIC_LIBS)
150
136
add_compiler_rt_object_libraries (RTAsan_dynamic
151
137
OS ${SANITIZER_COMMON_SUPPORTED_OS}
152
138
ARCHS ${ASAN_SUPPORTED_ARCH}
153
- SOURCES ${ASAN_SOURCES}
139
+ SOURCES ${ASAN_SOURCES} ${ASAN_CXX_SOURCES}
154
140
ADDITIONAL_HEADERS ${ASAN_HEADERS}
155
141
CFLAGS ${ASAN_DYNAMIC_CFLAGS}
156
142
DEFS ${ASAN_DYNAMIC_DEFINITIONS} )
@@ -235,52 +221,46 @@ else()
235
221
RTSanitizerCommonSymbolizerInternal
236
222
RTLSanCommon
237
223
RTUbsan )
238
- if (NOT WIN32 )
239
- add_compiler_rt_runtime (clang_rt.asan
240
- STATIC
241
- ARCHS ${ASAN_SUPPORTED_ARCH}
242
- OBJECT_LIBS RTAsan_preinit
243
- RTAsan
244
- ${ASAN_COMMON_RUNTIME_OBJECT_LIBS}
245
- CFLAGS ${ASAN_CFLAGS}
246
- DEFS ${ASAN_COMMON_DEFINITIONS}
247
- PARENT_TARGET asan )
248
224
249
- add_compiler_rt_runtime (clang_rt.asan_cxx
250
- STATIC
251
- ARCHS ${ASAN_SUPPORTED_ARCH}
252
- OBJECT_LIBS RTAsan_cxx
253
- RTUbsan_cxx
254
- CFLAGS ${ASAN_CFLAGS}
255
- DEFS ${ASAN_COMMON_DEFINITIONS}
256
- PARENT_TARGET asan )
225
+ add_compiler_rt_runtime (clang_rt.asan
226
+ STATIC
227
+ ARCHS ${ASAN_SUPPORTED_ARCH}
228
+ OBJECT_LIBS RTAsan_preinit
229
+ RTAsan
230
+ ${ASAN_COMMON_RUNTIME_OBJECT_LIBS}
231
+ CFLAGS ${ASAN_CFLAGS}
232
+ DEFS ${ASAN_COMMON_DEFINITIONS}
233
+ PARENT_TARGET asan )
257
234
258
- add_compiler_rt_runtime (clang_rt.asan_static
259
- STATIC
260
- ARCHS ${ASAN_SUPPORTED_ARCH}
261
- OBJECT_LIBS RTAsan_static
262
- CFLAGS ${ASAN_CFLAGS}
263
- DEFS ${ASAN_COMMON_DEFINITIONS}
264
- PARENT_TARGET asan )
235
+ add_compiler_rt_runtime (clang_rt.asan_cxx
236
+ STATIC
237
+ ARCHS ${ASAN_SUPPORTED_ARCH}
238
+ OBJECT_LIBS RTAsan_cxx
239
+ RTUbsan_cxx
240
+ CFLAGS ${ASAN_CFLAGS}
241
+ DEFS ${ASAN_COMMON_DEFINITIONS}
242
+ PARENT_TARGET asan )
265
243
266
- add_compiler_rt_runtime (clang_rt.asan-preinit
267
- STATIC
268
- ARCHS ${ASAN_SUPPORTED_ARCH}
269
- OBJECT_LIBS RTAsan_preinit
270
- CFLAGS ${ASAN_CFLAGS}
271
- DEFS ${ASAN_COMMON_DEFINITIONS}
272
- PARENT_TARGET asan )
273
- endif ()
244
+ add_compiler_rt_runtime (clang_rt.asan_static
245
+ STATIC
246
+ ARCHS ${ASAN_SUPPORTED_ARCH}
247
+ OBJECT_LIBS RTAsan_static
248
+ CFLAGS ${ASAN_CFLAGS}
249
+ DEFS ${ASAN_COMMON_DEFINITIONS}
250
+ PARENT_TARGET asan )
251
+
252
+ add_compiler_rt_runtime (clang_rt.asan-preinit
253
+ STATIC
254
+ ARCHS ${ASAN_SUPPORTED_ARCH}
255
+ OBJECT_LIBS RTAsan_preinit
256
+ CFLAGS ${ASAN_CFLAGS}
257
+ DEFS ${ASAN_COMMON_DEFINITIONS}
258
+ PARENT_TARGET asan )
274
259
275
260
foreach (arch ${ASAN_SUPPORTED_ARCH} )
276
261
if (COMPILER_RT_HAS_VERSION_SCRIPT )
277
- if (WIN32 )
278
- set (SANITIZER_RT_VERSION_LIST_LIBS clang_rt.asan-${arch} )
279
- else ()
280
- set (SANITIZER_RT_VERSION_LIST_LIBS clang_rt.asan-${arch} clang_rt.asan_cxx-${arch} )
281
- endif ()
282
262
add_sanitizer_rt_version_list (clang_rt.asan-dynamic-${arch}
283
- LIBS ${SANITIZER_RT_VERSION_LIST_LIBS }
263
+ LIBS clang_rt.asan-${arch} clang_rt.asan_cxx-${arch }
284
264
EXTRA asan.syms.extra )
285
265
set (VERSION_SCRIPT_FLAG
286
266
-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.asan-dynamic-${arch}.vers )
@@ -298,11 +278,25 @@ else()
298
278
endif ()
299
279
300
280
set (ASAN_DYNAMIC_WEAK_INTERCEPTION )
281
+ if (WIN32 )
282
+ add_compiler_rt_object_libraries (AsanWeakInterception
283
+ ${SANITIZER_COMMON_SUPPORTED_OS}
284
+ ARCHS ${arch}
285
+ SOURCES
286
+ asan_win_weak_interception.cpp
287
+ CFLAGS ${ASAN_CFLAGS} -DSANITIZER_DYNAMIC
288
+ DEFS ${ASAN_COMMON_DEFINITIONS} )
289
+ set (ASAN_DYNAMIC_WEAK_INTERCEPTION
290
+ AsanWeakInterception
291
+ UbsanWeakInterception
292
+ SancovWeakInterception
293
+ SanitizerCommonWeakInterception )
294
+ endif ()
295
+
301
296
add_compiler_rt_runtime (clang_rt.asan
302
297
SHARED
303
298
ARCHS ${arch}
304
299
OBJECT_LIBS ${ASAN_COMMON_RUNTIME_OBJECT_LIBS}
305
- RTAsan_cxx
306
300
RTAsan_dynamic
307
301
# The only purpose of RTAsan_dynamic_version_script_dummy is to
308
302
# carry a dependency of the shared runtime on the version script.
@@ -330,48 +324,49 @@ else()
330
324
endif ()
331
325
332
326
if (WIN32 )
327
+ add_compiler_rt_object_libraries (AsanDllThunk
328
+ ${SANITIZER_COMMON_SUPPORTED_OS}
329
+ ARCHS ${arch}
330
+ SOURCES asan_globals_win.cpp
331
+ asan_win_dll_thunk.cpp
332
+ CFLAGS ${ASAN_CFLAGS} -DSANITIZER_DLL_THUNK
333
+ DEFS ${ASAN_COMMON_DEFINITIONS} )
334
+
335
+ add_compiler_rt_runtime (clang_rt.asan_dll_thunk
336
+ STATIC
337
+ ARCHS ${arch}
338
+ OBJECT_LIBS AsanDllThunk
339
+ UbsanDllThunk
340
+ SancovDllThunk
341
+ SanitizerCommonDllThunk
342
+ SOURCES $< TARGET_OBJECTS:RTInterception.${arch} >
343
+ PARENT_TARGET asan )
344
+
333
345
set (DYNAMIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_DYNAMIC_RUNTIME_THUNK" )
346
+ if (MSVC )
347
+ list (APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-Zl" )
348
+ elseif (CMAKE_C_COMPILER_ID MATCHES Clang )
349
+ list (APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-nodefaultlibs" )
350
+ endif ()
334
351
335
352
add_compiler_rt_object_libraries (AsanDynamicRuntimeThunk
336
353
${SANITIZER_COMMON_SUPPORTED_OS}
337
354
ARCHS ${arch}
338
- SOURCES ${ASAN_DYNAMIC_RUNTIME_THUNK_SOURCES}
355
+ SOURCES asan_globals_win.cpp
356
+ asan_win_dynamic_runtime_thunk.cpp
339
357
CFLAGS ${ASAN_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
340
358
DEFS ${ASAN_COMMON_DEFINITIONS} )
341
359
342
360
add_compiler_rt_runtime (clang_rt.asan_dynamic_runtime_thunk
343
361
STATIC
344
362
ARCHS ${arch}
345
363
OBJECT_LIBS AsanDynamicRuntimeThunk
346
- UbsanRuntimeThunk
347
- SancovRuntimeThunk
348
- SanitizerRuntimeThunk
364
+ UbsanDynamicRuntimeThunk
365
+ SancovDynamicRuntimeThunk
366
+ SanitizerCommonDynamicRuntimeThunk
349
367
CFLAGS ${ASAN_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
350
368
DEFS ${ASAN_COMMON_DEFINITIONS}
351
369
PARENT_TARGET asan )
352
-
353
- # mingw does not support static linkage of the CRT
354
- if (NOT MINGW )
355
- set (STATIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_STATIC_RUNTIME_THUNK" )
356
-
357
- add_compiler_rt_object_libraries (AsanStaticRuntimeThunk
358
- ${SANITIZER_COMMON_SUPPORTED_OS}
359
- ARCHS ${arch}
360
- SOURCES ${ASAN_STATIC_RUNTIME_THUNK_SOURCES}
361
- CFLAGS ${ASAN_DYNAMIC_CFLAGS} ${STATIC_RUNTIME_THUNK_CFLAGS}
362
- DEFS ${ASAN_DYNAMIC_DEFINITIONS} )
363
-
364
- add_compiler_rt_runtime (clang_rt.asan_static_runtime_thunk
365
- STATIC
366
- ARCHS ${arch}
367
- OBJECT_LIBS AsanStaticRuntimeThunk
368
- UbsanRuntimeThunk
369
- SancovRuntimeThunk
370
- SanitizerRuntimeThunk
371
- CFLAGS ${ASAN_DYNAMIC_CFLAGS} ${STATIC_RUNTIME_THUNK_CFLAGS}
372
- DEFS ${ASAN_DYNAMIC_DEFINITIONS}
373
- PARENT_TARGET asan )
374
- endif ()
375
370
endif ()
376
371
endforeach ()
377
372
endif ()
0 commit comments