2012-06-20 18:18:43 +08:00
|
|
|
# Build system for the common Sanitizer runtime support library components.
|
|
|
|
# These components are shared between AddressSanitizer and ThreadSanitizer.
|
|
|
|
|
[sanitizer] Move termination functions in their own file
Summary:
As suggested by kcc@ in http://reviews.llvm.org/D20084#441418, move the CheckFailed and Die functions, and their associated callback functionalities in their own separate file.
I expended the build rules to include a new rule that would not include those termination functions, so that another project can define their own.
The tests check-{a,t,m,ub,l,e,df}san are all passing.
Reviewers: llvm-commits, kcc
Subscribers: kubabrecka
Differential Revision: http://reviews.llvm.org/D20742
llvm-svn: 271055
2016-05-28 05:57:17 +08:00
|
|
|
set(SANITIZER_SOURCES_NOTERMINATION
|
2019-08-01 02:51:27 +08:00
|
|
|
sanitizer_allocator.cpp
|
|
|
|
sanitizer_common.cpp
|
|
|
|
sanitizer_deadlock_detector1.cpp
|
|
|
|
sanitizer_deadlock_detector2.cpp
|
|
|
|
sanitizer_errno.cpp
|
|
|
|
sanitizer_file.cpp
|
|
|
|
sanitizer_flags.cpp
|
|
|
|
sanitizer_flag_parser.cpp
|
|
|
|
sanitizer_fuchsia.cpp
|
|
|
|
sanitizer_libc.cpp
|
|
|
|
sanitizer_libignore.cpp
|
|
|
|
sanitizer_linux.cpp
|
|
|
|
sanitizer_linux_s390.cpp
|
|
|
|
sanitizer_mac.cpp
|
|
|
|
sanitizer_netbsd.cpp
|
|
|
|
sanitizer_persistent_allocator.cpp
|
|
|
|
sanitizer_platform_limits_freebsd.cpp
|
|
|
|
sanitizer_platform_limits_linux.cpp
|
|
|
|
sanitizer_platform_limits_netbsd.cpp
|
|
|
|
sanitizer_platform_limits_posix.cpp
|
|
|
|
sanitizer_platform_limits_solaris.cpp
|
|
|
|
sanitizer_posix.cpp
|
|
|
|
sanitizer_printf.cpp
|
|
|
|
sanitizer_procmaps_common.cpp
|
|
|
|
sanitizer_procmaps_bsd.cpp
|
2020-01-25 08:33:49 +08:00
|
|
|
sanitizer_procmaps_fuchsia.cpp
|
2019-08-01 02:51:27 +08:00
|
|
|
sanitizer_procmaps_linux.cpp
|
|
|
|
sanitizer_procmaps_mac.cpp
|
|
|
|
sanitizer_procmaps_solaris.cpp
|
|
|
|
sanitizer_solaris.cpp
|
2020-01-29 03:34:53 +08:00
|
|
|
sanitizer_stoptheworld_fuchsia.cpp
|
2019-08-01 02:51:27 +08:00
|
|
|
sanitizer_stoptheworld_mac.cpp
|
|
|
|
sanitizer_suppressions.cpp
|
|
|
|
sanitizer_tls_get_addr.cpp
|
|
|
|
sanitizer_thread_registry.cpp
|
|
|
|
sanitizer_type_traits.cpp
|
|
|
|
sanitizer_win.cpp
|
2019-01-17 02:12:45 +08:00
|
|
|
)
|
2012-06-20 18:18:43 +08:00
|
|
|
|
[sanitizer] Move termination functions in their own file
Summary:
As suggested by kcc@ in http://reviews.llvm.org/D20084#441418, move the CheckFailed and Die functions, and their associated callback functionalities in their own separate file.
I expended the build rules to include a new rule that would not include those termination functions, so that another project can define their own.
The tests check-{a,t,m,ub,l,e,df}san are all passing.
Reviewers: llvm-commits, kcc
Subscribers: kubabrecka
Differential Revision: http://reviews.llvm.org/D20742
llvm-svn: 271055
2016-05-28 05:57:17 +08:00
|
|
|
set(SANITIZER_SOURCES
|
2019-08-01 02:51:27 +08:00
|
|
|
${SANITIZER_SOURCES_NOTERMINATION}
|
|
|
|
sanitizer_termination.cpp
|
|
|
|
)
|
[sanitizer] Move termination functions in their own file
Summary:
As suggested by kcc@ in http://reviews.llvm.org/D20084#441418, move the CheckFailed and Die functions, and their associated callback functionalities in their own separate file.
I expended the build rules to include a new rule that would not include those termination functions, so that another project can define their own.
The tests check-{a,t,m,ub,l,e,df}san are all passing.
Reviewers: llvm-commits, kcc
Subscribers: kubabrecka
Differential Revision: http://reviews.llvm.org/D20742
llvm-svn: 271055
2016-05-28 05:57:17 +08:00
|
|
|
|
2015-07-24 06:05:20 +08:00
|
|
|
# Libc functions stubs. These sources should be linked instead of
|
|
|
|
# SANITIZER_LIBCDEP_SOURCES when sanitizer_common library must not depend on
|
|
|
|
# libc.
|
|
|
|
set(SANITIZER_NOLIBC_SOURCES
|
2019-08-01 02:51:27 +08:00
|
|
|
sanitizer_common_nolibc.cpp
|
|
|
|
)
|
2015-07-24 06:05:20 +08:00
|
|
|
|
2013-05-18 00:17:19 +08:00
|
|
|
set(SANITIZER_LIBCDEP_SOURCES
|
2019-08-01 02:51:27 +08:00
|
|
|
sanitizer_common_libcdep.cpp
|
|
|
|
sanitizer_allocator_checks.cpp
|
|
|
|
sanitizer_linux_libcdep.cpp
|
|
|
|
sanitizer_mac_libcdep.cpp
|
|
|
|
sanitizer_posix_libcdep.cpp
|
|
|
|
sanitizer_stoptheworld_linux_libcdep.cpp
|
|
|
|
sanitizer_stoptheworld_netbsd_libcdep.cpp
|
2019-01-17 02:12:45 +08:00
|
|
|
)
|
2013-05-18 00:17:19 +08:00
|
|
|
|
[sanitizer] Split coverage into separate RT in sanitizer_common
Summary:
`sanitizer_common`'s coverage support is fairly well separated, and libcdep by
default. Several sanitizers don't make use of coverage, and as far as I can
tell do no benefit from the extra dependencies pulled in by the coverage public
interface functions.
The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan,
LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should
add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan.
So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc
anyway), XRay, and the upcoming Scudo minimal runtime.
I tested this with all the sanitizers check-* with gcc & clang, and in
standalone on Linux & Android, and there was no issue. I couldn't test this on
Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of
people for additional scrunity. I couldn't test HWAsan either.
Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski
Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris
Subscribers: mgorny, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D44701
llvm-svn: 328204
2018-03-22 23:04:31 +08:00
|
|
|
set(SANITIZER_COVERAGE_SOURCES
|
2019-08-01 02:51:27 +08:00
|
|
|
sancov_flags.cpp
|
|
|
|
sanitizer_coverage_fuchsia.cpp
|
|
|
|
sanitizer_coverage_libcdep_new.cpp
|
|
|
|
sanitizer_coverage_win_sections.cpp
|
2019-01-17 02:12:45 +08:00
|
|
|
)
|
[sanitizer] Split coverage into separate RT in sanitizer_common
Summary:
`sanitizer_common`'s coverage support is fairly well separated, and libcdep by
default. Several sanitizers don't make use of coverage, and as far as I can
tell do no benefit from the extra dependencies pulled in by the coverage public
interface functions.
The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan,
LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should
add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan.
So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc
anyway), XRay, and the upcoming Scudo minimal runtime.
I tested this with all the sanitizers check-* with gcc & clang, and in
standalone on Linux & Android, and there was no issue. I couldn't test this on
Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of
people for additional scrunity. I couldn't test HWAsan either.
Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski
Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris
Subscribers: mgorny, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D44701
llvm-svn: 328204
2018-03-22 23:04:31 +08:00
|
|
|
|
[sanitizer] Split Symbolizer/StackTraces from core RTSanitizerCommon
Summary:
Host symbolizer & stacktraces related code in their own RT:
`RTSanitizerCommonSymbolizer`, which is "libcdep" by nature. Symbolizer &
stacktraces specific code that used to live in common files is moved to a new
file `sanitizer_symbolizer_report.cc` as is.
The purpose of this is the enforce a separation between code that relies on
symbolization and code that doesn't. This saves the inclusion of spurious code
due to the interface functions with default visibility, and the extra data
associated.
The following sanitizers makefiles were modified & tested locally:
- dfsan: doesn't require the new symbolizer RT
- esan: requires it
- hwasan: requires it
- lsan: requires it
- msan: requires it
- safestack: doesn't require it
- xray: doesn't require it
- tsan: requires it
- ubsan: requires it
- ubsan_minimal: doesn't require it
- scudo: requires it (but not for Fuchsia that has a minimal runtime)
This was tested locally on Linux, Android, Fuchsia.
Reviewers: alekseyshl, eugenis, dberris, kubamracek, vitalybuka, dvyukov, mcgrathr
Reviewed By: alekseyshl, vitalybuka
Subscribers: srhines, kubamracek, mgorny, krytarowski, delcypher, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D45457
llvm-svn: 330131
2018-04-17 00:32:19 +08:00
|
|
|
set(SANITIZER_SYMBOLIZER_SOURCES
|
2019-08-01 02:51:27 +08:00
|
|
|
sanitizer_allocator_report.cpp
|
2021-02-09 13:47:12 +08:00
|
|
|
sanitizer_chained_origin_depot.cpp
|
2019-08-01 02:51:27 +08:00
|
|
|
sanitizer_stackdepot.cpp
|
|
|
|
sanitizer_stacktrace.cpp
|
|
|
|
sanitizer_stacktrace_libcdep.cpp
|
|
|
|
sanitizer_stacktrace_printer.cpp
|
|
|
|
sanitizer_stacktrace_sparc.cpp
|
|
|
|
sanitizer_symbolizer.cpp
|
|
|
|
sanitizer_symbolizer_libbacktrace.cpp
|
|
|
|
sanitizer_symbolizer_libcdep.cpp
|
|
|
|
sanitizer_symbolizer_mac.cpp
|
|
|
|
sanitizer_symbolizer_markup.cpp
|
|
|
|
sanitizer_symbolizer_posix_libcdep.cpp
|
|
|
|
sanitizer_symbolizer_report.cpp
|
|
|
|
sanitizer_symbolizer_win.cpp
|
|
|
|
sanitizer_unwind_linux_libcdep.cpp
|
|
|
|
sanitizer_unwind_win.cpp
|
2019-01-17 02:12:45 +08:00
|
|
|
)
|
[sanitizer] Split Symbolizer/StackTraces from core RTSanitizerCommon
Summary:
Host symbolizer & stacktraces related code in their own RT:
`RTSanitizerCommonSymbolizer`, which is "libcdep" by nature. Symbolizer &
stacktraces specific code that used to live in common files is moved to a new
file `sanitizer_symbolizer_report.cc` as is.
The purpose of this is the enforce a separation between code that relies on
symbolization and code that doesn't. This saves the inclusion of spurious code
due to the interface functions with default visibility, and the extra data
associated.
The following sanitizers makefiles were modified & tested locally:
- dfsan: doesn't require the new symbolizer RT
- esan: requires it
- hwasan: requires it
- lsan: requires it
- msan: requires it
- safestack: doesn't require it
- xray: doesn't require it
- tsan: requires it
- ubsan: requires it
- ubsan_minimal: doesn't require it
- scudo: requires it (but not for Fuchsia that has a minimal runtime)
This was tested locally on Linux, Android, Fuchsia.
Reviewers: alekseyshl, eugenis, dberris, kubamracek, vitalybuka, dvyukov, mcgrathr
Reviewed By: alekseyshl, vitalybuka
Subscribers: srhines, kubamracek, mgorny, krytarowski, delcypher, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D45457
llvm-svn: 330131
2018-04-17 00:32:19 +08:00
|
|
|
|
2012-12-21 22:04:52 +08:00
|
|
|
# Explicitly list all sanitizer_common headers. Not all of these are
|
|
|
|
# included in sanitizer_common source files, but we need to depend on
|
|
|
|
# headers when building our custom unit tests.
|
2018-07-12 21:36:44 +08:00
|
|
|
set(SANITIZER_IMPL_HEADERS
|
2018-07-10 21:00:17 +08:00
|
|
|
sancov_flags.h
|
|
|
|
sancov_flags.inc
|
2014-03-05 21:55:32 +08:00
|
|
|
sanitizer_addrhashmap.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_allocator.h
|
2016-07-21 06:06:41 +08:00
|
|
|
sanitizer_allocator_bytemap.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_allocator_checks.h
|
2016-07-21 06:06:41 +08:00
|
|
|
sanitizer_allocator_combined.h
|
2014-07-08 01:39:31 +08:00
|
|
|
sanitizer_allocator_interface.h
|
2013-05-29 17:15:39 +08:00
|
|
|
sanitizer_allocator_internal.h
|
2016-07-21 06:06:41 +08:00
|
|
|
sanitizer_allocator_local_cache.h
|
|
|
|
sanitizer_allocator_primary32.h
|
|
|
|
sanitizer_allocator_primary64.h
|
2018-06-06 02:02:09 +08:00
|
|
|
sanitizer_allocator_report.h
|
2016-07-21 06:06:41 +08:00
|
|
|
sanitizer_allocator_secondary.h
|
|
|
|
sanitizer_allocator_size_class_map.h
|
|
|
|
sanitizer_allocator_stats.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_asm.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_atomic.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_atomic_clang.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_atomic_clang_mips.h
|
|
|
|
sanitizer_atomic_clang_other.h
|
|
|
|
sanitizer_atomic_clang_x86.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_atomic_msvc.h
|
2014-02-12 15:05:24 +08:00
|
|
|
sanitizer_bitvector.h
|
2014-02-12 19:28:09 +08:00
|
|
|
sanitizer_bvgraph.h
|
2021-02-09 13:47:12 +08:00
|
|
|
sanitizer_chained_origin_depot.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_common.h
|
2013-01-18 21:01:18 +08:00
|
|
|
sanitizer_common_interceptors.inc
|
2014-01-21 21:01:20 +08:00
|
|
|
sanitizer_common_interceptors_format.inc
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_common_interceptors_ioctl.inc
|
|
|
|
sanitizer_common_interface.inc
|
|
|
|
sanitizer_common_interface_posix.inc
|
2013-04-11 22:37:04 +08:00
|
|
|
sanitizer_common_syscalls.inc
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_coverage_interface.inc
|
|
|
|
sanitizer_dbghelp.h
|
2014-02-13 15:44:51 +08:00
|
|
|
sanitizer_deadlock_detector.h
|
2014-02-28 18:48:13 +08:00
|
|
|
sanitizer_deadlock_detector_interface.h
|
2017-07-06 08:50:57 +08:00
|
|
|
sanitizer_errno.h
|
|
|
|
sanitizer_errno_codes.h
|
2017-07-22 09:46:40 +08:00
|
|
|
sanitizer_file.h
|
2015-01-15 23:13:43 +08:00
|
|
|
sanitizer_flag_parser.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_flags.h
|
2015-01-06 10:44:05 +08:00
|
|
|
sanitizer_flags.inc
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_freebsd.h
|
2017-08-02 06:22:25 +08:00
|
|
|
sanitizer_fuchsia.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_getauxval.h
|
2019-02-16 02:38:14 +08:00
|
|
|
sanitizer_hash.h
|
2018-02-15 11:36:16 +08:00
|
|
|
sanitizer_interceptors_ioctl_netbsd.inc
|
2015-02-19 23:15:33 +08:00
|
|
|
sanitizer_interface_internal.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_internal_defs.h
|
2013-01-14 16:23:34 +08:00
|
|
|
sanitizer_lfstack.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_libc.h
|
2013-10-03 21:37:17 +08:00
|
|
|
sanitizer_libignore.h
|
2013-02-27 19:22:40 +08:00
|
|
|
sanitizer_linux.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_list.h
|
2018-11-15 22:20:28 +08:00
|
|
|
sanitizer_local_address_space_view.h
|
2014-02-03 23:45:03 +08:00
|
|
|
sanitizer_mac.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_malloc_mac.inc
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_mutex.h
|
2014-05-21 17:02:13 +08:00
|
|
|
sanitizer_persistent_allocator.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_placement_new.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_platform.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_platform_interceptors.h
|
2017-08-29 05:03:23 +08:00
|
|
|
sanitizer_platform_limits_netbsd.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_platform_limits_posix.h
|
[Sanitizers, CMake] Basic sanitizer Solaris support (PR 33274)
Summary:
This patch, on top of https://reviews.llvm.org/D40898, contains the build system
changes necessary to enable the Solaris/x86 sanitizer port.
The only issue of note is the libclang_rt.sancov_{begin, end} libraries: clang relies on the
linker automatically defining __start_SECNAME and __stop_SECNAME labels for
sections whose names are valid C identifiers. This is a GNU ld extension not present
in the ELF gABI, also implemented by gold and lld, but not by Solaris ld. To work around
this, I automatically link the sancov_{begin,end} libraries into every executable for now.
There seems to be now way to build individual startup objects like crtbegin.o/crtend.o,
so I've followed the lead of libclang_rt.asan-preinit which also contains just a single
object.
Reviewers: kcc, alekseyshl
Reviewed By: alekseyshl
Subscribers: srhines, kubamracek, mgorny, fedor.sergeev, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D40899
llvm-svn: 321373
2017-12-23 02:04:20 +08:00
|
|
|
sanitizer_platform_limits_solaris.h
|
2015-04-09 01:08:24 +08:00
|
|
|
sanitizer_posix.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_procmaps.h
|
2020-05-07 10:05:31 +08:00
|
|
|
sanitizer_ptrauth.h
|
2013-01-11 16:07:43 +08:00
|
|
|
sanitizer_quarantine.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_report_decorator.h
|
2018-08-30 05:00:01 +08:00
|
|
|
sanitizer_ring_buffer.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_signal_interceptors.inc
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_stackdepot.h
|
2014-05-21 17:02:13 +08:00
|
|
|
sanitizer_stackdepotbase.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_stacktrace.h
|
2014-11-06 06:44:36 +08:00
|
|
|
sanitizer_stacktrace_printer.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_stoptheworld.h
|
|
|
|
sanitizer_suppressions.h
|
2012-12-21 22:04:52 +08:00
|
|
|
sanitizer_symbolizer.h
|
2018-05-12 07:52:19 +08:00
|
|
|
sanitizer_symbolizer_fuchsia.h
|
2015-03-03 05:15:09 +08:00
|
|
|
sanitizer_symbolizer_internal.h
|
2014-01-16 21:48:15 +08:00
|
|
|
sanitizer_symbolizer_libbacktrace.h
|
2015-03-12 18:53:18 +08:00
|
|
|
sanitizer_symbolizer_mac.h
|
2013-11-22 16:55:33 +08:00
|
|
|
sanitizer_syscall_generic.inc
|
2015-08-21 22:50:36 +08:00
|
|
|
sanitizer_syscall_linux_aarch64.inc
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_syscall_linux_arm.inc
|
|
|
|
sanitizer_syscall_linux_x86_64.inc
|
2020-09-23 12:58:25 +08:00
|
|
|
sanitizer_syscall_linux_riscv64.inc
|
Add NetBSD syscall hooks skeleton in sanitizers
Summary:
Implement the skeleton of NetBSD syscall hooks for use with sanitizers.
Add a script that generates the rules to handle syscalls
on NetBSD: generate_netbsd_syscalls.awk. It has been written
in NetBSD awk(1) (patched nawk) and is compatible with gawk.
Generate lib/sanitizer_common/sanitizer_platform_limits_netbsd.h
that is a public header for applications, and included as:
<sanitizer_common/sanitizer_platform_limits_netbsd.h>.
Generate sanitizer_syscalls_netbsd.inc that defines all the
syscall rules for NetBSD. This file is modeled after the Linux
specific file: sanitizer_common_syscalls.inc.
Start recognizing NetBSD syscalls with existing sanitizers:
ASan, ESan, HWASan, TSan, MSan.
Sponsored by <The NetBSD Foundation>
Reviewers: joerg, vitalybuka, kcc, dvyukov, eugenis
Reviewed By: vitalybuka
Subscribers: hintonda, kubamracek, mgorny, llvm-commits, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D42048
llvm-svn: 325206
2018-02-15 10:43:02 +08:00
|
|
|
sanitizer_syscalls_netbsd.inc
|
2017-02-03 07:01:51 +08:00
|
|
|
sanitizer_thread_registry.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_tls_get_addr.h
|
2017-12-04 20:30:09 +08:00
|
|
|
sanitizer_vector.h
|
2018-07-10 21:00:17 +08:00
|
|
|
sanitizer_win.h
|
|
|
|
sanitizer_win_defs.h
|
|
|
|
sanitizer_win_dll_thunk.h
|
2019-01-17 02:12:45 +08:00
|
|
|
sanitizer_win_weak_interception.h
|
|
|
|
)
|
2012-12-21 22:04:52 +08:00
|
|
|
|
[sanitizer] Split dll_thunks into different sanitizers.
When the sanitizer is implemented as a static library and is included in the
main executable, we need an auxiliary static library dll_thunk that will be
linked to the dlls that have instrumentation, so they can refer to the runtime
in the main executable. Basically, it uses interception to get a pointer the
function in the main executable and override its function with that pointer.
Before this diff, all of the implementation for dll_thunks was included in asan.
In this diff I split it into different sanitizers, so we can use other
sanitizers regardless of whether we include asan or not.
All the sanitizers include a file sanitizer_win_dll_thunk.cc that register
functions to be intercepted in the binary section: DLLTH
When the dll including dll_thunk is initialized, it will execute
__dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc,
which will consider all the CB registered in the section DLLTH. So, all the
functions registered will be intercepted, and redirected to the implementation
in the main executable.
All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to
include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc
ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and
sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan,
ubsan and sanitizer coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29154
llvm-svn: 293951
2017-02-03 07:01:28 +08:00
|
|
|
include_directories(..)
|
|
|
|
|
2019-01-15 03:18:34 +08:00
|
|
|
set(SANITIZER_COMMON_DEFINITIONS
|
|
|
|
HAVE_RPC_XDR_H=${HAVE_RPC_XDR_H})
|
2015-04-09 16:06:49 +08:00
|
|
|
|
2014-02-18 15:52:40 +08:00
|
|
|
set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
2016-03-05 18:01:04 +08:00
|
|
|
append_rtti_flag(OFF SANITIZER_CFLAGS)
|
2012-06-25 16:40:10 +08:00
|
|
|
|
2015-04-28 07:49:39 +08:00
|
|
|
append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=570
|
2015-01-03 12:29:12 +08:00
|
|
|
SANITIZER_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors
|
|
|
|
SANITIZER_CFLAGS)
|
2013-09-11 17:57:15 +08:00
|
|
|
|
2012-08-10 22:45:52 +08:00
|
|
|
if(APPLE)
|
2015-08-28 06:23:27 +08:00
|
|
|
set(OS_OPTION OS ${SANITIZER_COMMON_SUPPORTED_OS})
|
2012-06-20 18:18:43 +08:00
|
|
|
endif()
|
2012-08-10 22:45:52 +08:00
|
|
|
|
2015-08-28 06:23:27 +08:00
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommon
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
2015-08-28 06:23:27 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
[sanitizer] Move termination functions in their own file
Summary:
As suggested by kcc@ in http://reviews.llvm.org/D20084#441418, move the CheckFailed and Die functions, and their associated callback functionalities in their own separate file.
I expended the build rules to include a new rule that would not include those termination functions, so that another project can define their own.
The tests check-{a,t,m,ub,l,e,df}san are all passing.
Reviewers: llvm-commits, kcc
Subscribers: kubabrecka
Differential Revision: http://reviews.llvm.org/D20742
llvm-svn: 271055
2016-05-28 05:57:17 +08:00
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonNoTermination
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_SOURCES_NOTERMINATION}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
[sanitizer] Move termination functions in their own file
Summary:
As suggested by kcc@ in http://reviews.llvm.org/D20084#441418, move the CheckFailed and Die functions, and their associated callback functionalities in their own separate file.
I expended the build rules to include a new rule that would not include those termination functions, so that another project can define their own.
The tests check-{a,t,m,ub,l,e,df}san are all passing.
Reviewers: llvm-commits, kcc
Subscribers: kubabrecka
Differential Revision: http://reviews.llvm.org/D20742
llvm-svn: 271055
2016-05-28 05:57:17 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2015-08-28 06:23:27 +08:00
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonNoLibc
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_NOLIBC_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
2015-08-28 06:23:27 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonLibc
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_LIBCDEP_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
2015-08-28 06:23:27 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
[sanitizer] Split coverage into separate RT in sanitizer_common
Summary:
`sanitizer_common`'s coverage support is fairly well separated, and libcdep by
default. Several sanitizers don't make use of coverage, and as far as I can
tell do no benefit from the extra dependencies pulled in by the coverage public
interface functions.
The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan,
LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should
add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan.
So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc
anyway), XRay, and the upcoming Scudo minimal runtime.
I tested this with all the sanitizers check-* with gcc & clang, and in
standalone on Linux & Android, and there was no issue. I couldn't test this on
Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of
people for additional scrunity. I couldn't test HWAsan either.
Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski
Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris
Subscribers: mgorny, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D44701
llvm-svn: 328204
2018-03-22 23:04:31 +08:00
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonCoverage
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_COVERAGE_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
[sanitizer] Split coverage into separate RT in sanitizer_common
Summary:
`sanitizer_common`'s coverage support is fairly well separated, and libcdep by
default. Several sanitizers don't make use of coverage, and as far as I can
tell do no benefit from the extra dependencies pulled in by the coverage public
interface functions.
The following sanitizers call `InitializeCoverage` explicitely: MSan, ASan,
LSan, HWAsan, UBSan. On top of this, any sanitizer bundling RTUBSan should
add the coverage RT as well: ASan, Scudo, UBSan, CFI (diag), TSan, MSan, HWAsan.
So in the end the following have no need: DFSan, ESan, CFI, SafeStack (nolibc
anyway), XRay, and the upcoming Scudo minimal runtime.
I tested this with all the sanitizers check-* with gcc & clang, and in
standalone on Linux & Android, and there was no issue. I couldn't test this on
Mac, Fuchsia, BSDs, & Windows for lack of an environment, so adding a bunch of
people for additional scrunity. I couldn't test HWAsan either.
Reviewers: eugenis, vitalybuka, alekseyshl, flowerhack, kubamracek, dberris, rnk, krytarowski
Reviewed By: vitalybuka, alekseyshl, flowerhack, dberris
Subscribers: mgorny, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D44701
llvm-svn: 328204
2018-03-22 23:04:31 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
[sanitizer] Split Symbolizer/StackTraces from core RTSanitizerCommon
Summary:
Host symbolizer & stacktraces related code in their own RT:
`RTSanitizerCommonSymbolizer`, which is "libcdep" by nature. Symbolizer &
stacktraces specific code that used to live in common files is moved to a new
file `sanitizer_symbolizer_report.cc` as is.
The purpose of this is the enforce a separation between code that relies on
symbolization and code that doesn't. This saves the inclusion of spurious code
due to the interface functions with default visibility, and the extra data
associated.
The following sanitizers makefiles were modified & tested locally:
- dfsan: doesn't require the new symbolizer RT
- esan: requires it
- hwasan: requires it
- lsan: requires it
- msan: requires it
- safestack: doesn't require it
- xray: doesn't require it
- tsan: requires it
- ubsan: requires it
- ubsan_minimal: doesn't require it
- scudo: requires it (but not for Fuchsia that has a minimal runtime)
This was tested locally on Linux, Android, Fuchsia.
Reviewers: alekseyshl, eugenis, dberris, kubamracek, vitalybuka, dvyukov, mcgrathr
Reviewed By: alekseyshl, vitalybuka
Subscribers: srhines, kubamracek, mgorny, krytarowski, delcypher, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D45457
llvm-svn: 330131
2018-04-17 00:32:19 +08:00
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonSymbolizer
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_SYMBOLIZER_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
[sanitizer] Split Symbolizer/StackTraces from core RTSanitizerCommon
Summary:
Host symbolizer & stacktraces related code in their own RT:
`RTSanitizerCommonSymbolizer`, which is "libcdep" by nature. Symbolizer &
stacktraces specific code that used to live in common files is moved to a new
file `sanitizer_symbolizer_report.cc` as is.
The purpose of this is the enforce a separation between code that relies on
symbolization and code that doesn't. This saves the inclusion of spurious code
due to the interface functions with default visibility, and the extra data
associated.
The following sanitizers makefiles were modified & tested locally:
- dfsan: doesn't require the new symbolizer RT
- esan: requires it
- hwasan: requires it
- lsan: requires it
- msan: requires it
- safestack: doesn't require it
- xray: doesn't require it
- tsan: requires it
- ubsan: requires it
- ubsan_minimal: doesn't require it
- scudo: requires it (but not for Fuchsia that has a minimal runtime)
This was tested locally on Linux, Android, Fuchsia.
Reviewers: alekseyshl, eugenis, dberris, kubamracek, vitalybuka, dvyukov, mcgrathr
Reviewed By: alekseyshl, vitalybuka
Subscribers: srhines, kubamracek, mgorny, krytarowski, delcypher, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D45457
llvm-svn: 330131
2018-04-17 00:32:19 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2015-08-28 06:23:27 +08:00
|
|
|
|
2017-10-07 09:46:36 +08:00
|
|
|
set(SANITIZER_NO_WEAK_HOOKS_CFLAGS ${SANITIZER_CFLAGS})
|
2017-10-07 11:44:46 +08:00
|
|
|
list(APPEND SANITIZER_NO_WEAK_HOOKS_CFLAGS "-DSANITIZER_SUPPORTS_WEAK_HOOKS=0")
|
2017-10-07 09:46:36 +08:00
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonNoHooks
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
2017-10-07 09:46:36 +08:00
|
|
|
CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonLibcNoHooks
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_LIBCDEP_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
2017-10-07 09:46:36 +08:00
|
|
|
CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2018-04-17 02:17:22 +08:00
|
|
|
add_compiler_rt_object_libraries(RTSanitizerCommonSymbolizerNoHooks
|
|
|
|
${OS_OPTION}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
|
|
|
SOURCES ${SANITIZER_SYMBOLIZER_SOURCES}
|
2018-07-12 21:36:44 +08:00
|
|
|
ADDITIONAL_HEADERS ${SANITIZER_IMPL_HEADERS}
|
2018-04-17 02:17:22 +08:00
|
|
|
CFLAGS ${SANITIZER_NO_WEAK_HOOKS_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
2017-10-07 09:46:36 +08:00
|
|
|
|
2017-02-09 04:43:39 +08:00
|
|
|
if(WIN32)
|
[sanitizer] Use interception to access to strong definitions in the executable.
In Windows, when sanitizers are implemented as a shared library (DLL), users can
redefine and export a new definition for weak functions, in the main executable,
for example:
extern "C" __declspec(dllexport)
void __sanitizer_cov_trace_pc_guard(u32* guard) {
// Different implementation provided by the client.
}
However, other dlls, will continue using the default implementation imported
from the sanitizer dll. This is different in linux, where all the shared
libraries will consider the strong definition.
With the implementation in this diff, when the dll is initialized, it will check
if the main executable exports the definition for some weak function (for
example __sanitizer_cov_trace_pc_guard). If it finds that function, then it will
override the function in the dll with that pointer. So, all the dlls with
instrumentation that import __sanitizer_cov_trace_pc_guard__dll() from asan dll,
will be using the function provided by the main executable.
In other words, when the main executable exports a strong definition for a weak
function, we ensure all the dlls use that implementation instead of the default
weak implementation.
The behavior is similar to linux. Now, every user that want to override a weak
function, only has to define and export it. The same for Linux and Windows, and
it will work fine. So, there is no difference on the user's side.
All the sanitizers will include a file sanitizer_win_weak_interception.cc that
register sanitizer's weak functions to be intercepted in the binary section WEAK
When the sanitizer dll is initialized, it will execute weak_intercept_init()
which will consider all the CB registered in the section WEAK. So, for all the
weak functions registered, we will check if a strong definition is provided in
the main executable.
All the files sanitizer_win_weak_interception.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we include [asan|ubsan|sanitizer_coverage]_win_weak_interception.cc and
sanitizer_win_weak_interception.cc in asan dll, so when it is initialized, it
will consider all the weak functions from asan, ubsan and sanitizer coverage.
After this diff, sanitizer coverage is fixed for MD on Windows. In particular
libFuzzer can provide custom implementation for all sanitizer coverage's weak
functions, and they will be considered by asan dll.
Differential Revision: https://reviews.llvm.org/D29168
llvm-svn: 293958
2017-02-03 07:02:11 +08:00
|
|
|
add_compiler_rt_object_libraries(SanitizerCommonWeakInterception
|
|
|
|
${SANITIZER_COMMON_SUPPORTED_OS}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
2019-08-01 02:51:27 +08:00
|
|
|
SOURCES sanitizer_win_weak_interception.cpp
|
[sanitizer] Use interception to access to strong definitions in the executable.
In Windows, when sanitizers are implemented as a shared library (DLL), users can
redefine and export a new definition for weak functions, in the main executable,
for example:
extern "C" __declspec(dllexport)
void __sanitizer_cov_trace_pc_guard(u32* guard) {
// Different implementation provided by the client.
}
However, other dlls, will continue using the default implementation imported
from the sanitizer dll. This is different in linux, where all the shared
libraries will consider the strong definition.
With the implementation in this diff, when the dll is initialized, it will check
if the main executable exports the definition for some weak function (for
example __sanitizer_cov_trace_pc_guard). If it finds that function, then it will
override the function in the dll with that pointer. So, all the dlls with
instrumentation that import __sanitizer_cov_trace_pc_guard__dll() from asan dll,
will be using the function provided by the main executable.
In other words, when the main executable exports a strong definition for a weak
function, we ensure all the dlls use that implementation instead of the default
weak implementation.
The behavior is similar to linux. Now, every user that want to override a weak
function, only has to define and export it. The same for Linux and Windows, and
it will work fine. So, there is no difference on the user's side.
All the sanitizers will include a file sanitizer_win_weak_interception.cc that
register sanitizer's weak functions to be intercepted in the binary section WEAK
When the sanitizer dll is initialized, it will execute weak_intercept_init()
which will consider all the CB registered in the section WEAK. So, for all the
weak functions registered, we will check if a strong definition is provided in
the main executable.
All the files sanitizer_win_weak_interception.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we include [asan|ubsan|sanitizer_coverage]_win_weak_interception.cc and
sanitizer_win_weak_interception.cc in asan dll, so when it is initialized, it
will consider all the weak functions from asan, ubsan and sanitizer coverage.
After this diff, sanitizer coverage is fixed for MD on Windows. In particular
libFuzzer can provide custom implementation for all sanitizer coverage's weak
functions, and they will be considered by asan dll.
Differential Revision: https://reviews.llvm.org/D29168
llvm-svn: 293958
2017-02-03 07:02:11 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
|
|
|
add_compiler_rt_object_libraries(SancovWeakInterception
|
|
|
|
${SANITIZER_COMMON_SUPPORTED_OS}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
2019-08-01 02:51:27 +08:00
|
|
|
SOURCES sanitizer_coverage_win_weak_interception.cpp
|
[sanitizer] Use interception to access to strong definitions in the executable.
In Windows, when sanitizers are implemented as a shared library (DLL), users can
redefine and export a new definition for weak functions, in the main executable,
for example:
extern "C" __declspec(dllexport)
void __sanitizer_cov_trace_pc_guard(u32* guard) {
// Different implementation provided by the client.
}
However, other dlls, will continue using the default implementation imported
from the sanitizer dll. This is different in linux, where all the shared
libraries will consider the strong definition.
With the implementation in this diff, when the dll is initialized, it will check
if the main executable exports the definition for some weak function (for
example __sanitizer_cov_trace_pc_guard). If it finds that function, then it will
override the function in the dll with that pointer. So, all the dlls with
instrumentation that import __sanitizer_cov_trace_pc_guard__dll() from asan dll,
will be using the function provided by the main executable.
In other words, when the main executable exports a strong definition for a weak
function, we ensure all the dlls use that implementation instead of the default
weak implementation.
The behavior is similar to linux. Now, every user that want to override a weak
function, only has to define and export it. The same for Linux and Windows, and
it will work fine. So, there is no difference on the user's side.
All the sanitizers will include a file sanitizer_win_weak_interception.cc that
register sanitizer's weak functions to be intercepted in the binary section WEAK
When the sanitizer dll is initialized, it will execute weak_intercept_init()
which will consider all the CB registered in the section WEAK. So, for all the
weak functions registered, we will check if a strong definition is provided in
the main executable.
All the files sanitizer_win_weak_interception.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we include [asan|ubsan|sanitizer_coverage]_win_weak_interception.cc and
sanitizer_win_weak_interception.cc in asan dll, so when it is initialized, it
will consider all the weak functions from asan, ubsan and sanitizer coverage.
After this diff, sanitizer coverage is fixed for MD on Windows. In particular
libFuzzer can provide custom implementation for all sanitizer coverage's weak
functions, and they will be considered by asan dll.
Differential Revision: https://reviews.llvm.org/D29168
llvm-svn: 293958
2017-02-03 07:02:11 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DYNAMIC
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
|
|
|
|
[sanitizer] Split dll_thunks into different sanitizers.
When the sanitizer is implemented as a static library and is included in the
main executable, we need an auxiliary static library dll_thunk that will be
linked to the dlls that have instrumentation, so they can refer to the runtime
in the main executable. Basically, it uses interception to get a pointer the
function in the main executable and override its function with that pointer.
Before this diff, all of the implementation for dll_thunks was included in asan.
In this diff I split it into different sanitizers, so we can use other
sanitizers regardless of whether we include asan or not.
All the sanitizers include a file sanitizer_win_dll_thunk.cc that register
functions to be intercepted in the binary section: DLLTH
When the dll including dll_thunk is initialized, it will execute
__dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc,
which will consider all the CB registered in the section DLLTH. So, all the
functions registered will be intercepted, and redirected to the implementation
in the main executable.
All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to
include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc
ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and
sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan,
ubsan and sanitizer coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29154
llvm-svn: 293951
2017-02-03 07:01:28 +08:00
|
|
|
add_compiler_rt_object_libraries(SanitizerCommonDllThunk
|
|
|
|
${SANITIZER_COMMON_SUPPORTED_OS}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
2019-08-01 02:51:27 +08:00
|
|
|
SOURCES sanitizer_win_dll_thunk.cpp
|
[sanitizer] Split dll_thunks into different sanitizers.
When the sanitizer is implemented as a static library and is included in the
main executable, we need an auxiliary static library dll_thunk that will be
linked to the dlls that have instrumentation, so they can refer to the runtime
in the main executable. Basically, it uses interception to get a pointer the
function in the main executable and override its function with that pointer.
Before this diff, all of the implementation for dll_thunks was included in asan.
In this diff I split it into different sanitizers, so we can use other
sanitizers regardless of whether we include asan or not.
All the sanitizers include a file sanitizer_win_dll_thunk.cc that register
functions to be intercepted in the binary section: DLLTH
When the dll including dll_thunk is initialized, it will execute
__dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc,
which will consider all the CB registered in the section DLLTH. So, all the
functions registered will be intercepted, and redirected to the implementation
in the main executable.
All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to
include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc
ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and
sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan,
ubsan and sanitizer coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29154
llvm-svn: 293951
2017-02-03 07:01:28 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
|
|
|
add_compiler_rt_object_libraries(SancovDllThunk
|
|
|
|
${SANITIZER_COMMON_SUPPORTED_OS}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
2019-08-01 02:51:27 +08:00
|
|
|
SOURCES sanitizer_coverage_win_dll_thunk.cpp
|
|
|
|
sanitizer_coverage_win_sections.cpp
|
[sanitizer] Split dll_thunks into different sanitizers.
When the sanitizer is implemented as a static library and is included in the
main executable, we need an auxiliary static library dll_thunk that will be
linked to the dlls that have instrumentation, so they can refer to the runtime
in the main executable. Basically, it uses interception to get a pointer the
function in the main executable and override its function with that pointer.
Before this diff, all of the implementation for dll_thunks was included in asan.
In this diff I split it into different sanitizers, so we can use other
sanitizers regardless of whether we include asan or not.
All the sanitizers include a file sanitizer_win_dll_thunk.cc that register
functions to be intercepted in the binary section: DLLTH
When the dll including dll_thunk is initialized, it will execute
__dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc,
which will consider all the CB registered in the section DLLTH. So, all the
functions registered will be intercepted, and redirected to the implementation
in the main executable.
All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to
include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc
ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and
sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan,
ubsan and sanitizer coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29154
llvm-svn: 293951
2017-02-03 07:01:28 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS} -DSANITIZER_DLL_THUNK
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
[sanitizer] Add dynamic_runtime_thunk for different sanitizers.
In Windows, when the sanitizer is implemented as a shared library (DLL), we need
an auxiliary static library dynamic_runtime_thunk that will be linked to the
main executable and dlls.
In the sanitizer DLL, we are exposing weak functions with WIN_WEAK_EXPORT_DEF(),
which exports the default implementation with __dll suffix. For example: for
sanitizer coverage, the default implementation of __sanitizer_cov_trace_cmp is
exported as: __sanitizer_cov_trace_cmp__dll.
In the dynamic_runtime_thunk static library, we include weak aliases to the
imported implementation from the dll, using the macro WIN_WEAK_IMPORT_DEF().
By default, all users's programs that include calls to weak functions like
__sanitizer_cov_trace_cmp, will be redirected to the implementation in the dll,
when linking to dynamic_runtime_thunk.
After this diff, we are able to compile code with sanitizer coverage
instrumentation on Windows. When the instrumented object files are linked with
clang-rt_asan_dynamic_runtime_thunk-arch.lib all the weak symbols will be
resolved to the implementation imported from asan dll.
All the files sanitizer_dynamic_runtime_thunk.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we compile: [asan|ubsan|sanitizer_coverage]_win_dynamic_runtime_thunk.cc
and sanitizer_win_dynamic_runtime_thunk.cc to generate
asan_dynamic_runtime_thunk.lib, because we include asan, ubsan and sanitizer
coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29158
llvm-svn: 293953
2017-02-03 07:01:41 +08:00
|
|
|
|
|
|
|
set(DYNAMIC_RUNTIME_THUNK_CFLAGS "-DSANITIZER_DYNAMIC_RUNTIME_THUNK")
|
|
|
|
if(MSVC)
|
|
|
|
list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-Zl")
|
|
|
|
elseif(CMAKE_C_COMPILER_ID MATCHES Clang)
|
|
|
|
list(APPEND DYNAMIC_RUNTIME_THUNK_CFLAGS "-nodefaultlibs")
|
|
|
|
endif()
|
|
|
|
add_compiler_rt_object_libraries(SanitizerCommonDynamicRuntimeThunk
|
|
|
|
${SANITIZER_COMMON_SUPPORTED_OS}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
2019-08-01 02:51:27 +08:00
|
|
|
SOURCES sanitizer_win_dynamic_runtime_thunk.cpp
|
[sanitizer] Add dynamic_runtime_thunk for different sanitizers.
In Windows, when the sanitizer is implemented as a shared library (DLL), we need
an auxiliary static library dynamic_runtime_thunk that will be linked to the
main executable and dlls.
In the sanitizer DLL, we are exposing weak functions with WIN_WEAK_EXPORT_DEF(),
which exports the default implementation with __dll suffix. For example: for
sanitizer coverage, the default implementation of __sanitizer_cov_trace_cmp is
exported as: __sanitizer_cov_trace_cmp__dll.
In the dynamic_runtime_thunk static library, we include weak aliases to the
imported implementation from the dll, using the macro WIN_WEAK_IMPORT_DEF().
By default, all users's programs that include calls to weak functions like
__sanitizer_cov_trace_cmp, will be redirected to the implementation in the dll,
when linking to dynamic_runtime_thunk.
After this diff, we are able to compile code with sanitizer coverage
instrumentation on Windows. When the instrumented object files are linked with
clang-rt_asan_dynamic_runtime_thunk-arch.lib all the weak symbols will be
resolved to the implementation imported from asan dll.
All the files sanitizer_dynamic_runtime_thunk.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we compile: [asan|ubsan|sanitizer_coverage]_win_dynamic_runtime_thunk.cc
and sanitizer_win_dynamic_runtime_thunk.cc to generate
asan_dynamic_runtime_thunk.lib, because we include asan, ubsan and sanitizer
coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29158
llvm-svn: 293953
2017-02-03 07:01:41 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
|
|
|
add_compiler_rt_object_libraries(SancovDynamicRuntimeThunk
|
|
|
|
${SANITIZER_COMMON_SUPPORTED_OS}
|
|
|
|
ARCHS ${SANITIZER_COMMON_SUPPORTED_ARCH}
|
2019-08-01 02:51:27 +08:00
|
|
|
SOURCES sanitizer_coverage_win_dynamic_runtime_thunk.cpp
|
|
|
|
sanitizer_coverage_win_sections.cpp
|
[sanitizer] Add dynamic_runtime_thunk for different sanitizers.
In Windows, when the sanitizer is implemented as a shared library (DLL), we need
an auxiliary static library dynamic_runtime_thunk that will be linked to the
main executable and dlls.
In the sanitizer DLL, we are exposing weak functions with WIN_WEAK_EXPORT_DEF(),
which exports the default implementation with __dll suffix. For example: for
sanitizer coverage, the default implementation of __sanitizer_cov_trace_cmp is
exported as: __sanitizer_cov_trace_cmp__dll.
In the dynamic_runtime_thunk static library, we include weak aliases to the
imported implementation from the dll, using the macro WIN_WEAK_IMPORT_DEF().
By default, all users's programs that include calls to weak functions like
__sanitizer_cov_trace_cmp, will be redirected to the implementation in the dll,
when linking to dynamic_runtime_thunk.
After this diff, we are able to compile code with sanitizer coverage
instrumentation on Windows. When the instrumented object files are linked with
clang-rt_asan_dynamic_runtime_thunk-arch.lib all the weak symbols will be
resolved to the implementation imported from asan dll.
All the files sanitizer_dynamic_runtime_thunk.cc are independent, so we do not
need to include a specific list of sanitizers.
Now, we compile: [asan|ubsan|sanitizer_coverage]_win_dynamic_runtime_thunk.cc
and sanitizer_win_dynamic_runtime_thunk.cc to generate
asan_dynamic_runtime_thunk.lib, because we include asan, ubsan and sanitizer
coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29158
llvm-svn: 293953
2017-02-03 07:01:41 +08:00
|
|
|
CFLAGS ${SANITIZER_CFLAGS} ${DYNAMIC_RUNTIME_THUNK_CFLAGS}
|
|
|
|
DEFS ${SANITIZER_COMMON_DEFINITIONS})
|
[sanitizer] Split dll_thunks into different sanitizers.
When the sanitizer is implemented as a static library and is included in the
main executable, we need an auxiliary static library dll_thunk that will be
linked to the dlls that have instrumentation, so they can refer to the runtime
in the main executable. Basically, it uses interception to get a pointer the
function in the main executable and override its function with that pointer.
Before this diff, all of the implementation for dll_thunks was included in asan.
In this diff I split it into different sanitizers, so we can use other
sanitizers regardless of whether we include asan or not.
All the sanitizers include a file sanitizer_win_dll_thunk.cc that register
functions to be intercepted in the binary section: DLLTH
When the dll including dll_thunk is initialized, it will execute
__dll_thunk_init() implemented in: sanitizer_common/sanitizer_win_dll_thunk.cc,
which will consider all the CB registered in the section DLLTH. So, all the
functions registered will be intercepted, and redirected to the implementation
in the main executable.
All the files "sanitizer_win_dll_thunk.cc" are independent, so we don't need to
include a specific list of sanitizers. Now, we compile: asan_win_dll_thunk.cc
ubsan_win_dll_thunk.cc, sanitizer_coverage_win_dll_thunk.cc and
sanitizer_win_dll_thunk.cc, to generate asan_dll_thunk, because we include asan,
ubsan and sanitizer coverage in the address sanitizer library.
Differential Revision: https://reviews.llvm.org/D29154
llvm-svn: 293951
2017-02-03 07:01:28 +08:00
|
|
|
endif()
|
|
|
|
|
2012-09-11 18:50:32 +08:00
|
|
|
# Unit tests for common sanitizer runtime.
|
2014-02-19 19:18:47 +08:00
|
|
|
if(COMPILER_RT_INCLUDE_TESTS)
|
2012-09-11 18:50:32 +08:00
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|