diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1784,6 +1784,10 @@ def fno_sanitize_address_outline_instrumentation : Flag<["-"], "fno-sanitize-address-outline-instrumentation">, Group, HelpText<"Use default code inlining logic for the address sanitizer">; +defm sanitize_stable_abi + : OptInCC1FFlag<"sanitize-stable-abi", "Stable ", "Conventional ", + "ABI instrumentation for sanitizer runtime. Default: Conventional">; + def fsanitize_memtag_mode_EQ : Joined<["-"], "fsanitize-memtag-mode=">, Group, HelpText<"Set default MTE mode to 'sync' (default) or 'async'">; diff --git a/clang/include/clang/Driver/SanitizerArgs.h b/clang/include/clang/Driver/SanitizerArgs.h --- a/clang/include/clang/Driver/SanitizerArgs.h +++ b/clang/include/clang/Driver/SanitizerArgs.h @@ -42,6 +42,7 @@ bool CfiCanonicalJumpTables = false; int AsanFieldPadding = 0; bool SharedRuntime = false; + bool StableABI = false; bool AsanUseAfterScope = true; bool AsanPoisonCustomArrayCookie = false; bool AsanGlobalsDeadStripping = false; diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -912,6 +912,9 @@ } } + StableABI = Args.hasFlag(options::OPT_fsanitize_stable_abi, + options::OPT_fno_sanitize_stable_abi, false); + AsanUseAfterScope = Args.hasFlag( options::OPT_fsanitize_address_use_after_scope, options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope); @@ -1282,6 +1285,16 @@ CmdArgs.push_back("-asan-instrumentation-with-call-threshold=0"); } + // When emitting Stable ABI instrumentation, force outlining calls and avoid + // inlining shadow memory poisoning. While this is a big performance burden + // for now it allows full abstraction from implementation details. + if (StableABI) { + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-asan-instrumentation-with-call-threshold=0"); + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back("-asan-max-inline-poisoning-size=0"); + } + // Only pass the option to the frontend if the user requested, // otherwise the frontend will just use the codegen default. if (AsanDtorKind != llvm::AsanDtorKind::Invalid) { diff --git a/clang/test/Driver/fsanitize-stable-abi.c b/clang/test/Driver/fsanitize-stable-abi.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/fsanitize-stable-abi.c @@ -0,0 +1,15 @@ +// RUN: %clang --target=arm64-apple-darwin -fsanitize-stable-abi %s -### 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CHECK-ASAN-STABLE-WARN +// CHECK-ASAN-STABLE-WARN: warning: argument unused during compilation: '-fsanitize-stable-abi' +// RUN: %clang --target=arm64-apple-darwin -fsanitize=address -fsanitize-stable-abi %s -### 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CHECK-ASAN-STABLE-OK +// RUN: %clang --target=arm64-apple-darwin -fsanitize=address -fno-sanitize-stable-abi -fsanitize-stable-abi %s -### 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CHECK-ASAN-STABLE-OK +// CHECK-ASAN-STABLE-OK: "-mllvm" "-asan-instrumentation-with-call-threshold=0" +// CHECK-ASAN-STABLE-OK: "-mllvm" "-asan-max-inline-poisoning-size=0" +// RUN: %clang --target=arm64-apple-darwin -fsanitize=address -fno-sanitize-stable-abi %s -### 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CHECK-NO-ASAN-STABLE-OK +// RUN: %clang --target=arm64-apple-darwin -fsanitize=address -fsanitize-stable-abi -fno-sanitize-stable-abi %s -### 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CHECK-NO-ASAN-STABLE-OK +// CHECK-NO-ASAN-STABLE-OK-NOT: "-mllvm" "-asan-instrumentation-with-call-threshold=0" +// CHECK-NO-ASAN-STABLE-OK-NOT: "-mllvm" "-asan-max-inline-poisoning-size=0" diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake --- a/compiler-rt/cmake/config-ix.cmake +++ b/compiler-rt/cmake/config-ix.cmake @@ -704,7 +704,7 @@ endif() message(STATUS "Compiler-RT supported architectures: ${COMPILER_RT_SUPPORTED_ARCH}") -set(ALL_SANITIZERS asan;dfsan;msan;hwasan;tsan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan) +set(ALL_SANITIZERS asan;dfsan;msan;hwasan;tsan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;asan_abi) 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}") @@ -724,6 +724,11 @@ set(COMPILER_RT_HAS_INTERCEPTION FALSE) endif() +if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH AND APPLE) + set(COMPILER_RT_HAS_ASAN_ABI TRUE) +else() + set(COMPILER_RT_HAS_ASAN_ABI FALSE) +endif() if (COMPILER_RT_HAS_SANITIZER_COMMON AND ASAN_SUPPORTED_ARCH) set(COMPILER_RT_HAS_ASAN TRUE) else() diff --git a/compiler-rt/docs/ASanABI.rst b/compiler-rt/docs/ASanABI.rst new file mode 100644 --- /dev/null +++ b/compiler-rt/docs/ASanABI.rst @@ -0,0 +1,53 @@ +.. _BuildingCompilerRT: + +============================ +Darwin Sanitizers Stable ABI +============================ + +Some OSes like Darwin want to include the AddressSanitizer runtime by establishing a stable ASan ABI. lib/asan_abi contains a secondary stable ABI for Darwin use and potentially others. The Stable ABI has minimal impact on the community, prioritizing stability over performance. + +The Stable ABI is isolated by a “shim” layer which maps the unstable ABI to the stable ABI. It consists of a static library (libclang_rt.asan_abi_osx.a) that contains simple mappings of the existing ASan ABI to the smaller Stable ABI. After linking with the static shim library, only calls to the Stable ABI remain. + + Sample content of the shim: + + .. code-block:: c + + ... + void __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); } + void __asan_load2(uptr p) { __asan_abi_loadn(p, 2, true); } + void __asan_noabort_load16(uptr p) { __asan_abi_loadn(p, 16, false); } + void __asan_poison_cxx_array_cookie(uptr p) { __asan_abi_pac(p); } + ... + +The shim library is only used when -fsanitize-stable-abi is specified in the Clang driver and the emitted instrumentation favors runtime calls over inline expansion. + +Maintenance +----------- + +The maintenance burden on the sanitizer developer community should be negligible. Stable ABI tests should always pass for non-Darwin platforms. Changes to the existing ABI requiring changes to the shim should been infrequent as the existing ASan ABI has long been relatively stable anyway. Rarely, when a change that impacts the contract between LLVM and the shim occurs, some simple responses should suffice. Among such foreseeable changes are: 1) changes to a function signature, 2) additions of new functions, or 3) deprecation of an existing function. + + Following are some examples of reasonable responses to such changes: + + * An existing ABI function is changed to return the input parameter on success or NULL on failure. In this scenario, a reasonable change to the shim would be to modify the function signature appropriately and to simply guess at a common-sense implementation. + + .. code-block:: c + + uptr __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); return p; } + + * An additional function is added for performance reasons. It has a very similar function signature to other similarly named functions and logically is an extension of that same pattern. In this case it would make sense to apply the same logic as the existing entry points: + + .. code-block:: c + + void __asan_load128(uptr p) { __asan_abi_loadn(p, 128, true); } + + * An entry point is added to the existing ABI for which there is no obvious stable ABI implementation: In this case, doing nothing in a no-op stub would be acceptable, assuming existing features of ASan can still work without an actual implementation of this new function. + + .. code-block:: c + + void __asan_prefetch(uptr p) { } + + * An entrypoint in the existing ABI is deprecated and/or deleted: + + .. code-block:: c + + (Delete the entrypoint from the shim.) diff --git a/compiler-rt/lib/asan_abi/CMakeLists.txt b/compiler-rt/lib/asan_abi/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/compiler-rt/lib/asan_abi/CMakeLists.txt @@ -0,0 +1,35 @@ +# Build for the ASAN Stable ABI runtime support library. +set(ASAN_ABI_SOURCES + asan_abi_shim.cpp + ) + +set(ASAN_ABI_HEADERS + ../asan/asan_interface_internal.h + asan_abi.h + ) + +include_directories(..) + +add_compiler_rt_component(asan_abi) + +if (APPLE) + # TODO: set in config-ix.cmake + set(ASAN_ABI_SUPPORTED_OS osx) + set(ASAN_ABI_SUPPORTED_ARCHS ${X86_64} ${ARM64}) + # Compile Stable API sources into an object library. + add_compiler_rt_object_libraries(RTASAN_ABI + OS ${ASAN_ABI_SUPPORTED_OS} + ARCHS ${ASAN_ABI_SUPPORTED_ARCHS} + SOURCES ${ASAN_ABI_SOURCES} + ADDITIONAL_HEADERS ${ASAN_ABI_HEADERS} + CFLAGS ${SANITIZER_COMMON_CFLAGS}) + + add_compiler_rt_runtime(clang_rt.asan_abi + STATIC + OS ${ASAN_ABI_SUPPORTED_OS} + ARCHS ${ASAN_ABI_SUPPORTED_ARCHS} + OBJECT_LIBS RTASAN_ABI + CFLAGS ${SANITIZER_COMMON_CFLAGS} + LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} + PARENT_TARGET asan_abi) +endif() diff --git a/compiler-rt/lib/asan_abi/asan_abi.h b/compiler-rt/lib/asan_abi/asan_abi.h new file mode 100644 --- /dev/null +++ b/compiler-rt/lib/asan_abi/asan_abi.h @@ -0,0 +1,84 @@ +//===-asan_abi.h - ASan Stable ABI Interface-------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef ASAN_ABI_H +#define ASAN_ABI_H + +#include +#include +#include + +extern "C" { +// Functions concerning instrumented global variables: +void __asan_abi_register_image_globals(); +void __asan_abi_unregister_image_globals(); + +// Functions concerning dynamic library initialization +void __asan_abi_before_dynamic_init(const char *module_name); +void __asan_abi_after_dynamic_init(); + +// Functions concerning block memory destinations +void *__asan_abi_memcpy(void *d, const void *s, size_t n); +void *__asan_abi_memmove(void *d, const void *s, size_t n); +void *__asan_abi_memset(void *p, int c, size_t n); + +// Functions concerning RTL startup and initialization +void __asan_abi_init(); +void __asan_abi_handle_no_return(); + +// Functions concerning memory load and store reporting +void __asan_abi_report_load_n(void *p, size_t n, bool abort); +void __asan_abi_report_exp_load_n(void *p, size_t n, int exp, bool abort); +void __asan_abi_report_store_n(void *p, size_t n, bool abort); +void __asan_abi_report_exp_store_n(void *p, size_t n, int exp, bool abort); + +// Functions concerning memory load and store +void __asan_abi_load_n(void *p, size_t n, bool abort); +void __asan_abi_exp_load_n(void *p, size_t n, int exp, bool abort); +void __asan_abi_store_n(void *p, size_t n, bool abort); +void __asan_abi_exp_store_n(void *p, size_t n, int exp, bool abort); + +// Functions concerning query about whether memory is poisoned +int __asan_abi_address_is_poisoned(void const volatile *p); +void *__asan_abi_region_is_poisoned(void const volatile *p, size_t size); + +// Functions concerning the poisoning of memory +void __asan_abi_unpoison_memory_region(void const volatile *p, size_t n); +void __asan_abi_poison_memory_region(void const volatile *p, size_t n); + +// Functions concerning the partial poisoning of memory +void __asan_abi_set_shadow_xx_n(void *p, unsigned char xx, size_t n); + +// Functions concerning stack poisoning +void __asan_abi_poison_stack_memory(void *p, size_t n); +void __asan_abi_unpoison_stack_memory(void *p, size_t n); + +// Functions concerning redzone poisoning +void __asan_abi_poison_intra_object_redzone(void *p, size_t size); +void __asan_abi_unpoison_intra_object_redzone(void *p, size_t size); + +// Functions concerning array cookie poisoning +void __asan_abi_poison_cxx_array_cookie(void *p); +void *__asan_abi_load_cxx_array_cookie(void **p); + +// Functions concerning fake stacks +void *__asan_abi_get_current_fake_stack(); +void *__asan_abi_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, + void **end); +// Functions concerning poisoning and unpoisoning fake stack alloca +void __asan_abi_alloca_poison(void *addr, size_t size); +void __asan_abi_allocas_unpoison(void *top, void *bottom); + +// Functions concerning fake stack malloc +void *__asan_abi_stack_malloc_n(size_t scale, size_t size); +void *__asan_abi_stack_malloc_always_n(size_t scale, size_t size); + +// Functions concerning fake stack free +void __asan_abi_stack_free_n(int scale, void *p, size_t n); +} +#endif // ASAN_ABI_H diff --git a/compiler-rt/lib/asan_abi/asan_abi.cpp b/compiler-rt/lib/asan_abi/asan_abi.cpp new file mode 100644 --- /dev/null +++ b/compiler-rt/lib/asan_abi/asan_abi.cpp @@ -0,0 +1,85 @@ +//===-asan_abi.cpp - ASan Stable ABI---------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "asan_abi.h" + +extern "C" { +// Functions concerning instrumented global variables: +void __asan_abi_register_image_globals(void) {} +void __asan_abi_unregister_image_globals(void) {} + +// Functions concerning dynamic library initialization +void __asan_abi_before_dynamic_init(const char *module_name) {} +void __asan_abi_after_dynamic_init(void) {} + +// Functions concerning block memory destinations +void *__asan_abi_memcpy(void *d, const void *s, size_t n) { return NULL; } +void *__asan_abi_memmove(void *d, const void *s, size_t n) { return NULL; } +void *__asan_abi_memset(void *p, int c, size_t n) { return NULL; } + +// Functions concerning RTL startup and initialization +void __asan_abi_init(void) {} +void __asan_abi_handle_no_return(void) {} + +// Functions concerning memory load and store reporting +void __asan_abi_report_load_n(void *p, size_t n, bool abort) {} +void __asan_abi_report_exp_load_n(void *p, size_t n, int exp, bool abort) {} +void __asan_abi_report_store_n(void *p, size_t n, bool abort) {} +void __asan_abi_report_exp_store_n(void *p, size_t n, int exp, bool abort) {} + +// Functions concerning memory load and store +void __asan_abi_load_n(void *p, size_t n, bool abort) {} +void __asan_abi_exp_load_n(void *p, size_t n, int exp, bool abort) {} +void __asan_abi_store_n(void *p, size_t n, bool abort) {} +void __asan_abi_exp_store_n(void *p, size_t n, int exp, bool abort) {} + +// Functions concerning query about whether memory is poisoned +int __asan_abi_address_is_poisoned(void const volatile *p) { return 0; } +void *__asan_abi_region_is_poisoned(void const volatile *p, size_t size) { + return NULL; +} + +// Functions concerning the poisoning of memory +void __asan_abi_poison_memory_region(void const volatile *p, size_t n) {} +void __asan_abi_unpoison_memory_region(void const volatile *p, size_t n) {} + +// Functions concerning the partial poisoning of memory +void __asan_abi_set_shadow_xx_n(void *p, unsigned char xx, size_t n) {} + +// Functions concerning stack poisoning +void __asan_abi_poison_stack_memory(void *p, size_t n) {} +void __asan_abi_unpoison_stack_memory(void *p, size_t n) {} + +// Functions concerning redzone poisoning +void __asan_abi_poison_intra_object_redzone(void *p, size_t size) {} +void __asan_abi_unpoison_intra_object_redzone(void *p, size_t size) {} + +// Functions concerning array cookie poisoning +void __asan_abi_poison_cxx_array_cookie(void *p) {} +void *__asan_abi_load_cxx_array_cookie(void **p) { return NULL; } + +// Functions concerning fake stacks +void *__asan_abi_get_current_fake_stack(void) { return NULL; } +void *__asan_abi_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, + void **end) { + return NULL; +} + +// Functions concerning poisoning and unpoisoning fake stack alloca +void __asan_abi_alloca_poison(void *addr, size_t size) {} +void __asan_abi_allocas_unpoison(void *top, void *bottom) {} + +// Functions concerning fake stack malloc +void *__asan_abi_stack_malloc_n(size_t scale, size_t size) { return NULL; } +void *__asan_abi_stack_malloc_always_n(size_t scale, size_t size) { + return NULL; +} + +// Functions concerning fake stack free +void __asan_abi_stack_free_n(int scale, void *p, size_t n) {} +} diff --git a/compiler-rt/lib/asan_abi/asan_abi_shim.cpp b/compiler-rt/lib/asan_abi/asan_abi_shim.cpp new file mode 100644 --- /dev/null +++ b/compiler-rt/lib/asan_abi/asan_abi_shim.cpp @@ -0,0 +1,485 @@ +//===-asan_abi_shim.cpp - ASan Stable ABI Shim-----------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "../asan/asan_interface_internal.h" +#include "asan_abi.h" +#include + +extern "C" { +// Functions concerning instrumented global variables +void __asan_register_image_globals(uptr *flag) { + __asan_abi_register_image_globals(); +} + +void __asan_unregister_image_globals(uptr *flag) { + __asan_abi_unregister_image_globals(); +} +void __asan_register_elf_globals(uptr *flag, void *start, void *stop) {} +void __asan_unregister_elf_globals(uptr *flag, void *start, void *stop) {} +void __asan_register_globals(__asan_global *globals, uptr n) {} +void __asan_unregister_globals(__asan_global *globals, uptr n) {} + +// Functions concerning dynamic library initialization +void __asan_before_dynamic_init(const char *module_name) { + __asan_abi_before_dynamic_init(module_name); +} +void __asan_after_dynamic_init(void) { __asan_abi_after_dynamic_init(); } + +// Functions concerning block memory destinations +void *__asan_memcpy(void *dst, const void *src, uptr size) { + return __asan_abi_memcpy(dst, src, size); +} +void *__asan_memset(void *s, int c, uptr n) { + return __asan_abi_memset(s, c, n); +} +void *__asan_memmove(void *dest, const void *src, uptr n) { + return __asan_abi_memmove(dest, src, n); +} + +// Functions concerning RTL startup and initialization +void __asan_init(void) { + static_assert(sizeof(uptr) == 8); + static_assert(sizeof(u64) == 8); + static_assert(sizeof(u32) == 4); + + __asan_abi_init(); +} +void __asan_version_mismatch_check_v8(void) {} +void __asan_handle_no_return(void) { __asan_abi_handle_no_return(); } + +// Variables concerning RTL state. These provisionally exist for completeness +// but will likely move into the Stable ABI implementation and not in the shim. +uptr __asan_shadow_memory_dynamic_address = (uptr)0xdeaddeaddeadbeaf; +int __asan_option_detect_stack_use_after_return = 0; + +// Functions concerning memory load and store reporting +void __asan_report_load1(uptr addr) { + __asan_abi_report_load_n((void *)addr, 1, true); +} +void __asan_report_load2(uptr addr) { + __asan_abi_report_load_n((void *)addr, 2, true); +} +void __asan_report_load4(uptr addr) { + __asan_abi_report_load_n((void *)addr, 4, true); +} +void __asan_report_load8(uptr addr) { + __asan_abi_report_load_n((void *)addr, 8, true); +} +void __asan_report_load16(uptr addr) { + __asan_abi_report_load_n((void *)addr, 16, true); +} +void __asan_report_load_n(uptr addr, uptr size) { + __asan_abi_report_load_n((void *)addr, size, true); +} +void __asan_report_store1(uptr addr) { + __asan_abi_report_store_n((void *)addr, 1, true); +} +void __asan_report_store2(uptr addr) { + __asan_abi_report_store_n((void *)addr, 2, true); +} +void __asan_report_store4(uptr addr) { + __asan_abi_report_store_n((void *)addr, 4, true); +} +void __asan_report_store8(uptr addr) { + __asan_abi_report_store_n((void *)addr, 8, true); +} +void __asan_report_store16(uptr addr) { + __asan_abi_report_store_n((void *)addr, 16, true); +} +void __asan_report_store_n(uptr addr, uptr size) { + __asan_abi_report_store_n((void *)addr, size, true); +} + +// Functions concerning memory load and store reporting (experimental variants) +void __asan_report_exp_load1(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *)addr, exp, 1, true); +} +void __asan_report_exp_load2(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *)addr, exp, 2, true); +} +void __asan_report_exp_load4(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *)addr, exp, 4, true); +} +void __asan_report_exp_load8(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *)addr, exp, 8, true); +} +void __asan_report_exp_load16(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *)addr, exp, 16, true); +} +void __asan_report_exp_load_n(uptr addr, uptr size, u32 exp) { + __asan_abi_report_exp_load_n((void *)addr, size, exp, true); +} +void __asan_report_exp_store1(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *)addr, exp, 1, true); +} +void __asan_report_exp_store2(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *)addr, exp, 2, true); +} +void __asan_report_exp_store4(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *)addr, exp, 4, true); +} +void __asan_report_exp_store8(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *)addr, exp, 8, true); +} +void __asan_report_exp_store16(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *)addr, exp, 16, true); +} +void __asan_report_exp_store_n(uptr addr, uptr size, u32 exp) { + __asan_abi_report_exp_store_n((void *)addr, size, exp, true); +} + +// Functions concerning memory load and store reporting (noabort variants) +void __asan_report_load1_noabort(uptr addr) { + __asan_abi_report_load_n((void *)addr, 1, false); +} +void __asan_report_load2_noabort(uptr addr) { + __asan_abi_report_load_n((void *)addr, 2, false); +} +void __asan_report_load4_noabort(uptr addr) { + __asan_abi_report_load_n((void *)addr, 4, false); +} +void __asan_report_load8_noabort(uptr addr) { + __asan_abi_report_load_n((void *)addr, 8, false); +} +void __asan_report_load16_noabort(uptr addr) { + __asan_abi_report_load_n((void *)addr, 16, false); +} +void __asan_report_load_n_noabort(uptr addr, uptr size) { + __asan_abi_report_load_n((void *)addr, size, false); +} +void __asan_report_store1_noabort(uptr addr) { + __asan_abi_report_store_n((void *)addr, 1, false); +} +void __asan_report_store2_noabort(uptr addr) { + __asan_abi_report_store_n((void *)addr, 2, false); +} +void __asan_report_store4_noabort(uptr addr) { + __asan_abi_report_store_n((void *)addr, 4, false); +} +void __asan_report_store8_noabort(uptr addr) { + __asan_abi_report_store_n((void *)addr, 8, false); +} +void __asan_report_store16_noabort(uptr addr) { + __asan_abi_report_store_n((void *)addr, 16, false); +} +void __asan_report_store_n_noabort(uptr addr, uptr size) { + __asan_abi_report_store_n((void *)addr, size, false); +} + +// Functions concerning memory load and store +void __asan_load1(uptr addr) { __asan_abi_load_n((void *)addr, 1, true); } +void __asan_load2(uptr addr) { __asan_abi_load_n((void *)addr, 2, true); } +void __asan_load4(uptr addr) { __asan_abi_load_n((void *)addr, 4, true); } +void __asan_load8(uptr addr) { __asan_abi_load_n((void *)addr, 8, true); } +void __asan_load16(uptr addr) { __asan_abi_load_n((void *)addr, 16, true); } +void __asan_loadN(uptr addr, uptr size) { + __asan_abi_load_n((void *)addr, size, true); +} +void __asan_store1(uptr addr) { __asan_abi_store_n((void *)addr, 1, true); } +void __asan_store2(uptr addr) { __asan_abi_store_n((void *)addr, 2, true); } +void __asan_store4(uptr addr) { __asan_abi_store_n((void *)addr, 4, true); } +void __asan_store8(uptr addr) { __asan_abi_store_n((void *)addr, 8, true); } +void __asan_store16(uptr addr) { __asan_abi_store_n((void *)addr, 16, true); } +void __asan_storeN(uptr addr, uptr size) { + __asan_abi_store_n((void *)addr, size, true); +} + +// Functions concerning memory load and store (experimental variants) +void __asan_exp_load1(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *)addr, 1, exp, true); +} +void __asan_exp_load2(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *)addr, 2, exp, true); +} +void __asan_exp_load4(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *)addr, 4, exp, true); +} +void __asan_exp_load8(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *)addr, 8, exp, true); +} +void __asan_exp_load16(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *)addr, 16, exp, true); +} +void __asan_exp_loadN(uptr addr, uptr size, u32 exp) { + __asan_abi_exp_load_n((void *)addr, size, exp, true); +} +void __asan_exp_store1(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *)addr, 1, exp, true); +} +void __asan_exp_store2(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *)addr, 2, exp, true); +} +void __asan_exp_store4(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *)addr, 4, exp, true); +} +void __asan_exp_store8(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *)addr, 8, exp, true); +} +void __asan_exp_store16(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *)addr, 16, exp, true); +} +void __asan_exp_storeN(uptr addr, uptr size, u32 exp) { + __asan_abi_exp_store_n((void *)addr, size, exp, true); +} + +// Functions concerning memory load and store (noabort variants) +void __asan_load1_noabort(uptr addr) { + __asan_abi_load_n((void *)addr, 1, false); +} +void __asan_load2_noabort(uptr addr) { + __asan_abi_load_n((void *)addr, 2, false); +} +void __asan_load4_noabort(uptr addr) { + __asan_abi_load_n((void *)addr, 4, false); +} +void __asan_load8_noabort(uptr addr) { + __asan_abi_load_n((void *)addr, 8, false); +} +void __asan_load16_noabort(uptr addr) { + __asan_abi_load_n((void *)addr, 16, false); +} +void __asan_loadN_noabort(uptr addr, uptr size) { + __asan_abi_load_n((void *)addr, size, false); +} +void __asan_store1_noabort(uptr addr) { + __asan_abi_store_n((void *)addr, 1, false); +} +void __asan_store2_noabort(uptr addr) { + __asan_abi_store_n((void *)addr, 2, false); +} +void __asan_store4_noabort(uptr addr) { + __asan_abi_store_n((void *)addr, 4, false); +} +void __asan_store8_noabort(uptr addr) { + __asan_abi_store_n((void *)addr, 8, false); +} +void __asan_store16_noabort(uptr addr) { + __asan_abi_store_n((void *)addr, 16, false); +} +void __asan_storeN_noabort(uptr addr, uptr size) { + __asan_abi_store_n((void *)addr, size, false); +} + +// Functions concerning query about whether memory is poisoned +int __asan_address_is_poisoned(void const volatile *addr) { + return __asan_abi_address_is_poisoned(addr); +} +uptr __asan_region_is_poisoned(uptr beg, uptr size) { + return (uptr)__asan_abi_region_is_poisoned((void *)beg, size); +} + +// Functions concerning the poisoning of memory +void __asan_poison_memory_region(void const volatile *addr, uptr size) { + __asan_abi_poison_memory_region(addr, size); +} +void __asan_unpoison_memory_region(void const volatile *addr, uptr size) { + __asan_abi_unpoison_memory_region(addr, size); +} + +// Functions concerning the partial poisoning of memory +void __asan_set_shadow_00(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x00, size); +} +void __asan_set_shadow_01(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x01, size); +} +void __asan_set_shadow_02(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x02, size); +} +void __asan_set_shadow_03(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x03, size); +} +void __asan_set_shadow_04(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x04, size); +} +void __asan_set_shadow_05(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x05, size); +} +void __asan_set_shadow_06(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x06, size); +} +void __asan_set_shadow_07(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0x07, size); +} +void __asan_set_shadow_f1(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0xf1, size); +} +void __asan_set_shadow_f2(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0xf2, size); +} +void __asan_set_shadow_f3(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0xf3, size); +} +void __asan_set_shadow_f5(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0xf5, size); +} +void __asan_set_shadow_f8(uptr addr, uptr size) { + __asan_abi_set_shadow_xx_n((void *)addr, 0xf8, size); +} + +// Functions concerning stack poisoning +void __asan_poison_stack_memory(uptr addr, uptr size) { + __asan_abi_poison_stack_memory((void *)addr, size); +} +void __asan_unpoison_stack_memory(uptr addr, uptr size) { + __asan_abi_unpoison_stack_memory((void *)addr, size); +} + +// Functions concerning redzone poisoning +void __asan_poison_intra_object_redzone(uptr p, uptr size) {} +void __asan_unpoison_intra_object_redzone(uptr p, uptr size) {} + +// Functions concerning array cookie poisoning +void __asan_poison_cxx_array_cookie(uptr p) {} +uptr __asan_load_cxx_array_cookie(uptr *p) { + // TBD: Fail here + return (uptr)0; +} + +// Functions concerning fake stacks +void *__asan_get_current_fake_stack(void) { + // TBD: Fail here + return (void *)0; +} +void *__asan_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, + void **end) { + // TBD: Fail here + return (void *)0; +} + +// Functions concerning poisoning and unpoisoning fake stack alloca +void __asan_alloca_poison(uptr addr, uptr size) { + __asan_abi_alloca_poison((void *)addr, size); +} +void __asan_allocas_unpoison(uptr top, uptr bottom) { + __asan_abi_allocas_unpoison((void *)top, (void *)bottom); +} + +// Functions concerning fake stack malloc +uptr __asan_stack_malloc_0(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(0, size); +} +uptr __asan_stack_malloc_1(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(1, size); +} +uptr __asan_stack_malloc_2(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(2, size); +} +uptr __asan_stack_malloc_3(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(3, size); +} +uptr __asan_stack_malloc_4(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(4, size); +} +uptr __asan_stack_malloc_5(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(5, size); +} +uptr __asan_stack_malloc_6(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(6, size); +} +uptr __asan_stack_malloc_7(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(7, size); +} +uptr __asan_stack_malloc_8(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(8, size); +} +uptr __asan_stack_malloc_9(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(9, size); +} +uptr __asan_stack_malloc_10(uptr size) { + return (uptr)__asan_abi_stack_malloc_n(10, size); +} + +// Functions concerning fake stack malloc (always variants) +uptr __asan_stack_malloc_always_0(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(0, size); +} +uptr __asan_stack_malloc_always_1(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(1, size); +} +uptr __asan_stack_malloc_always_2(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(2, size); +} +uptr __asan_stack_malloc_always_3(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(3, size); +} +uptr __asan_stack_malloc_always_4(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(4, size); +} +uptr __asan_stack_malloc_always_5(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(5, size); +} +uptr __asan_stack_malloc_always_6(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(6, size); +} +uptr __asan_stack_malloc_always_7(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(7, size); +} +uptr __asan_stack_malloc_always_8(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(8, size); +} +uptr __asan_stack_malloc_always_9(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(9, size); +} +uptr __asan_stack_malloc_always_10(uptr size) { + return (uptr)__asan_abi_stack_malloc_always_n(10, size); +} + +// Functions concerning fake stack free +void __asan_stack_free_0(uptr ptr, uptr size) { + __asan_abi_stack_free_n(0, (void *)ptr, size); +} +void __asan_stack_free_1(uptr ptr, uptr size) { + __asan_abi_stack_free_n(1, (void *)ptr, size); +} +void __asan_stack_free_2(uptr ptr, uptr size) { + __asan_abi_stack_free_n(2, (void *)ptr, size); +} +void __asan_stack_free_3(uptr ptr, uptr size) { + __asan_abi_stack_free_n(3, (void *)ptr, size); +} +void __asan_stack_free_4(uptr ptr, uptr size) { + __asan_abi_stack_free_n(4, (void *)ptr, size); +} +void __asan_stack_free_5(uptr ptr, uptr size) { + __asan_abi_stack_free_n(5, (void *)ptr, size); +} +void __asan_stack_free_6(uptr ptr, uptr size) { + __asan_abi_stack_free_n(6, (void *)ptr, size); +} +void __asan_stack_free_7(uptr ptr, uptr size) { + __asan_abi_stack_free_n(7, (void *)ptr, size); +} +void __asan_stack_free_8(uptr ptr, uptr size) { + __asan_abi_stack_free_n(8, (void *)ptr, size); +} +void __asan_stack_free_9(uptr ptr, uptr size) { + __asan_abi_stack_free_n(9, (void *)ptr, size); +} +void __asan_stack_free_10(uptr ptr, uptr size) { + __asan_abi_stack_free_n(10, (void *)ptr, size); +} + +// Functions concerning introspection (including lldb support) +uptr __asan_get_alloc_stack(uptr addr, uptr *trace, uptr size, u32 *thread_id) { + // TBD: Fail here + return (uptr)0; +} +void __asan_report_error(uptr pc, uptr bp, uptr sp, uptr addr, int is_write, + uptr access_size, u32 exp) {} +void __asan_set_error_report_callback(void (*callback)(const char *)) {} +void __asan_describe_address(uptr addr) {} +int __asan_report_present(void) { return (int)0; } +uptr __asan_get_report_pc(void) { return (uptr)0; } +uptr __asan_get_report_bp(void) { return (uptr)0; } +uptr __asan_get_report_sp(void) { return (uptr)0; } +uptr __asan_get_report_address(void) { return (uptr)0; } +int __asan_get_report_access_type(void) { return (int)0; } +uptr __asan_get_report_access_size(void) { return (uptr)0; } +const char *__asan_get_report_description(void) { return (const char *)0; } +} diff --git a/compiler-rt/lib/asan_abi/asan_abi_tbd.txt b/compiler-rt/lib/asan_abi/asan_abi_tbd.txt new file mode 100644 --- /dev/null +++ b/compiler-rt/lib/asan_abi/asan_abi_tbd.txt @@ -0,0 +1,10 @@ +__asan_default_options +__asan_default_suppressions +__asan_get_free_stack +__asan_get_shadow_mapping +__asan_handle_vfork +__asan_locate_address +__asan_on_error +__asan_print_accumulated_stats +__asan_set_death_callback +__asan_update_allocation_context diff --git a/compiler-rt/test/asan_abi/CMakeLists.txt b/compiler-rt/test/asan_abi/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/compiler-rt/test/asan_abi/CMakeLists.txt @@ -0,0 +1,47 @@ +set(ASAN_ABI_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +set(ASAN_ABI_TESTSUITES) + +macro(get_bits_for_arch arch bits) + if (${arch} MATCHES "arm64") + set(${bits} 64) + else() + message(FATAL_ERROR "Unknown target architecture: ${arch}") + endif() +endmacro() + +set(ASAN_ABI_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) +if(NOT COMPILER_RT_STANDALONE_BUILD) + list(APPEND ASAN_ABI_TEST_DEPS asan_abi) +endif() +set(ASAN_ABI_DYNAMIC_TEST_DEPS ${ASAN_ABI_TEST_DEPS}) + +set(ASAN_ABI_TEST_ARCH arm64) + +foreach(arch ${ASAN_ABI_TEST_ARCH}) + set(ASAN_ABI_TEST_TARGET_ARCH ${arch}) + set(ASAN_ABI_TEST_APPLE_PLATFORM "osx") + set(ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_osx_MIN_VER_FLAG}") + string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX) + get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS) + get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC ASAN_ABI_TEST_TARGET_CFLAGS) + if(ANDROID OR APPLE) + set(ASAN_ABI_TEST_DYNAMIC True) + else() + set(ASAN_ABI_TEST_DYNAMIC False) + endif() + string(TOUPPER ${arch} ARCH_UPPER_CASE) + set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config) + + list(APPEND ASAN_ABI_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) + configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py + ) +endforeach() + +add_lit_testsuite(check-asan-abi "Running the AddressSanitizerABI tests" + ${ASAN_ABI_TESTSUITES} + ${exclude_from_check_all} + DEPENDS ${ASAN_ABI_TEST_DEPS}) +set_target_properties(check-asan-abi PROPERTIES FOLDER "Compiler-RT Misc") diff --git a/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp b/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp new file mode 100644 --- /dev/null +++ b/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_asan_abi -O0 -c -fsanitize-stable-abi -fsanitize=address %s -o %t.o +// RUN: %clangxx -c %p/../../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o +// RUN: %clangxx -dead_strip -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1 +// RUN: %clangxx -x c++-header -o - -E %p/../../../../lib/asan/asan_interface.inc \ +// RUN: | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" > %t.asan_interface.inc +// RUN: llvm-nm -g %libasan_abi \ +// RUN: | grep " [TU] " \ +// RUN: | grep -o "\(__asan\)[^ ]*" \ +// RUN: | grep -v "\(__asan_abi\)[^ ]*" \ +// RUN: | sed -e "s/__asan_version_mismatch_check_v[0-9]+/__asan_version_mismatch_check/" \ +// RUN: > %t.exports +// RUN: sed -e ':a' -e 'N' -e '$!ba' \ +// RUN: -e 's/ //g' \ +// RUN: -e ':b' -e 's/\n\n/\n/g' -e 'tb' \ +// RUN: -e 's/(\n/(/g' \ +// RUN: %t.asan_interface.inc \ +// RUN: | grep -v -f %p/../../../../lib/asan_abi/asan_abi_tbd.txt \ +// RUN: | grep -e "INTERFACE_\(WEAK_\)\?FUNCTION" \ +// RUN: | grep -v "__sanitizer[^ ]*" \ +// RUN: | sed -e "s/.*(//" -e "s/).*//" > %t.imports +// RUN: sort %t.imports | uniq > %t.imports-sorted +// RUN: sort %t.exports | uniq > %t.exports-sorted +// RUN: diff %t.imports-sorted %t.exports-sorted + +// UNSUPPORTED: ios + +int main() { return 0; } diff --git a/compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp b/compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp new file mode 100644 --- /dev/null +++ b/compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_asan_abi -O2 -c -fsanitize-stable-abi -fsanitize=address -O0 %s -o %t.o +// RUN: %clangxx -c %p/../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o +// RUN: %clangxx -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1 + +int main() { return 0; } diff --git a/compiler-rt/test/asan_abi/lit.cfg.py b/compiler-rt/test/asan_abi/lit.cfg.py new file mode 100644 --- /dev/null +++ b/compiler-rt/test/asan_abi/lit.cfg.py @@ -0,0 +1,74 @@ +# -*- Python -*- + +import os +import platform +import re + +import lit.formats + +def get_required_attr(config, attr_name): + attr_value = getattr(config, attr_name, None) + if attr_value is None: + lit_config.fatal( + 'No attribute %r in test configuration! You may need to run ' + 'tests from your build directory or add this attribute ' + 'to lit.site.cfg.py ' % attr_name) + return attr_value + +# Setup config name. +config.name = 'AddressSanitizerABI' + config.name_suffix + +# Platform-specific default ASAN_ABI_OPTIONS for lit tests. +default_asan_abi_opts = list(config.default_sanitizer_opts) + +default_asan_abi_opts_str = ':'.join(default_asan_abi_opts) +if default_asan_abi_opts_str: + config.environment['ASAN_ABI_OPTIONS'] = default_asan_abi_opts_str + default_asan_abi_opts_str += ':' +config.substitutions.append(('%env_asan_abi_opts=', + 'env ASAN_ABI_OPTIONS=' + default_asan_abi_opts_str)) + +# Setup source root. +config.test_source_root = os.path.dirname(__file__) + +# GCC-ASan doesn't link in all the necessary libraries automatically, so +# we have to do it ourselves. +extra_link_flags = [] + +# Setup default compiler flags used with -fsanitize=address option. +# FIXME: Review the set of required flags and check if it can be reduced. +target_cflags = [get_required_attr(config, 'target_cflags')] + extra_link_flags +target_cxxflags = config.cxx_mode_flags + target_cflags +clang_asan_abi_static_cflags = (['-fsanitize=address', + '-fsanitize-stable-abi', + '-mno-omit-leaf-frame-pointer', + '-fno-omit-frame-pointer', + '-fno-optimize-sibling-calls'] + + config.debug_info_flags + target_cflags) +clang_asan_abi_static_cxxflags = config.cxx_mode_flags + clang_asan_abi_static_cflags + +config.available_features.add('asan_abi-static-runtime') +clang_asan_abi_cflags = clang_asan_abi_static_cflags +clang_asan_abi_cxxflags = clang_asan_abi_static_cxxflags + +def build_invocation(compile_flags): + return ' ' + ' '.join([config.clang] + compile_flags) + ' ' + +config.substitutions.append( ('%clang ', build_invocation(target_cflags)) ) +config.substitutions.append( ('%clangxx ', build_invocation(target_cxxflags)) ) +config.substitutions.append( ('%clang_asan_abi ', build_invocation(clang_asan_abi_cflags)) ) +config.substitutions.append( ('%clangxx_asan_abi ', build_invocation(clang_asan_abi_cxxflags)) ) + +libasan_abi_path = os.path.join(config.compiler_rt_libdir, 'libclang_rt.asan_abi_osx.a'.format(config.apple_platform)) + +if libasan_abi_path is not None: + config.substitutions.append( ('%libasan_abi', libasan_abi_path) ) + config.substitutions.append( ('%clang_asan_abi_static ', build_invocation(clang_asan_abi_static_cflags)) ) + config.substitutions.append( ('%clangxx_asan_abi_static ', build_invocation(clang_asan_abi_static_cxxflags)) ) + +config.suffixes = ['.c', '.cpp'] + +if config.host_os == 'Darwin': + config.suffixes.append('.mm') +else: + config.unsupported = True diff --git a/compiler-rt/test/asan_abi/lit.site.cfg.py.in b/compiler-rt/test/asan_abi/lit.site.cfg.py.in new file mode 100644 --- /dev/null +++ b/compiler-rt/test/asan_abi/lit.site.cfg.py.in @@ -0,0 +1,18 @@ +@LIT_SITE_CFG_IN_HEADER@ + +# Tool-specific config options. +config.name_suffix = "@ASAN_ABI_TEST_CONFIG_SUFFIX@" +config.target_cflags = "@ASAN_ABI_TEST_TARGET_CFLAGS@" +config.clang = "@ASAN_ABI_TEST_TARGET_CC@" +config.bits = "@ASAN_ABI_TEST_BITS@" +config.arm_thumb = "@COMPILER_RT_ARM_THUMB@" +config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@" +config.apple_platform_min_deployment_target_flag = "@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@" +config.asan_abi_dynamic = @ASAN_ABI_TEST_DYNAMIC@ +config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@" + +# Load common config for all compiler-rt lit tests. +lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured") + +# Load tool-specific config that would do the real work. +lit_config.load_config(config, "@ASAN_ABI_LIT_SOURCE_DIR@/lit.cfg.py")