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,12 @@ def fno_sanitize_address_outline_instrumentation : Flag<["-"], "fno-sanitize-address-outline-instrumentation">, Group, HelpText<"Use default code inlining logic for the address sanitizer">; +def fsanitize_stable_abi : Flag<["-"], "fsanitize-stable-abi">, + Group, + HelpText<"Always generate Stable ABI calls for sanitizer instrumentation">; +def fno_sanitize_stable_abi : Flag<["-"], "fno-sanitize-stable-abi">, + Group, + HelpText<"Disable generation of Stable ABI calls for sanitizer instrumentation">; 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,11 @@ } } + StableABI = Args.hasFlag( + options::OPT_fsanitize_stable_abi, + options::OPT_fno_sanitize_stable_abi, + StableABI); + AsanUseAfterScope = Args.hasFlag( options::OPT_fsanitize_address_use_after_scope, options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope); @@ -1282,6 +1287,13 @@ CmdArgs.push_back("-asan-instrumentation-with-call-threshold=0"); } + 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.c b/clang/test/Driver/fsanitize.c --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -263,6 +263,22 @@ // RUN: FileCheck %s --check-prefix=CHECK-NO-CHECK-ASAN-CALLBACK // CHECK-NO-CHECK-ASAN-CALLBACK-NOT: "-mllvm" "-asan-instrumentation-with-call-threshold=0" +// RUN: %clang --target=x86_64-linux-gnu -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=x86_64-linux-gnu -fsanitize=address -fsanitize-stable-abi %s -### 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CHECK-ASAN-STABLE-OK +// RUN: %clang --target=x86_64-linux-gnu -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=x86_64-linux-gnu -fsanitize=address -fno-sanitize-stable-abi %s -### 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CHECK-NO-ASAN-STABLE-OK +// RUN: %clang --target=x86_64-linux-gnu -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" + // RUN: %clang --target=x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-ODR-INDICATOR // RUN: %clang_cl --target=x86_64-windows -fsanitize=address -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-ODR-INDICATOR-OFF // CHECK-ASAN-ODR-INDICATOR-NOT: "-fsanitize-address-use-odr-indicator" 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/asan_abi.md b/compiler-rt/docs/asan_abi.md new file mode 100644 --- /dev/null +++ b/compiler-rt/docs/asan_abi.md @@ -0,0 +1,35 @@ +# Darwin Sanitizers Stable ABI + +We wish to make it possible to include the AddressSanitizer (ASan) runtime implementation in OSes and for this we need a stable ASan ABI. Based on previous discussions about this topic, our understanding is that freezing the present ABI would impose an excessive burden on other sanitizer developers and for unrelated platforms. Therefore, we propose adding a secondary stable ABI for our use and anyone else in the community seeking the same. We believe that we can define a stable ABI with minimal burden on the community, expecting only to keep existing tests running and implementing stubs when new features are added. We are okay with trading performance for stability with no impact for existing users of ASan while minimizing the maintenance burden for ASan maintainers. We wish to commit this functionality to the LLVM project to maintain it there. This new and stable ABI will abstract away the implementation details allowing new and novel approaches to ASan for developers, researchers and others. + +## Details + +Rather than adding a lot of conditional code to the LLVM instrumentation phase, which would incur excessive complexity and maintenance cost of adding conditional code into all places that emit a runtime call, we propose a “shim” layer which will map the unstable ABI to the stable ABI: + +* A static library (.a library) shim that maps the existing ASan ABI to a generalized, smaller and stable ABI. The library would implement the __asan functions and call into the new ABI. For example: + * `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); }` +* This “shim” library would only be used by people who opt in: A compilation flag in the Clang driver will be used to gate the use of the stable ABI workflow. +* Utilize the existing ability for the ASan instrumentation to prefer runtime calls instead of inlined direct shadow memory accesses. +* Pursue (under the new driver flag) a better separation of abstraction and implementation with: + * LLVM instrumentation: Calling out for all poisoning, checking and unpoisoning. + * Runtime: Implementing the stable ABI and being responsible of implementation details of the shadow memory. + +## Maintenance + +Our aim is that the maintenance burden on the sanitizer developer community be negligible. Stable ABI tests will always pass for non-Darwin platforms. Changes to the existing ABI which would require a change to the shim have been infrequent as the ASan ABI is already relatively stable. Rarely, a change that impacts the contract between LLVM and the shim will occur. 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 those changes: + +* Example: 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. + * `uptr __asan_load1(uptr p) { __asan_abi_loadn(p, 1, true); return p; }` +* Example: 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: + * `void __asan_load128(uptr p) { __asan_abi_loadn(p, 128, true); }` +* Example: 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. + * `void __asan_prefetch(uptr p) { }` +* Example: An entrypoint in the existing ABI is deprecated and/or deleted: + * (Delete the entrypoint from the shim.) + +We’re looking for buy-in for this level of support. + +(Note: Upon acceptance of the general concepts herein, we will add a controlling clang flag, cmake integration, contract for the stable ABI, and the appropriate test infrastructure.) 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,83 @@ +//===-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 + +void __asan_abi_register_image_globals(void); +void __asan_abi_unregister_image_globals(void); + +void __asan_abi_before_dynamic_init(const char *module_name); +void __asan_abi_after_dynamic_init(void); + +// Interceptors +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); + +// RTL (Interface) +void __asan_abi_init(void); +void __asan_abi_handle_no_return(void); + +// RTL (Report) +void __asan_abi_report_load_n(void *p, size_t n); +void __asan_abi_report_exp_load_n(void *p, size_t n, int exp); +void __asan_abi_report_load_n_noabort(void *p, size_t n); +void __asan_abi_report_store_n(void *p, size_t n); +void __asan_abi_report_exp_store_n(void *p, size_t n, int exp); +void __asan_abi_report_store_n_noabort(void *p, size_t n); + +// RTL (Access) +void __asan_abi_load_n(void *p, size_t n); +void __asan_abi_exp_load_n(void *p, size_t n, int exp); +void __asan_abi_load_n_noabort(void *p, size_t n); +void __asan_abi_store_n(void *p, size_t n); +void __asan_abi_exp_store_n(void *p, size_t n, int exp); +void __asan_abi_store_n_noabort(void *p, size_t n); + +// Poison +int __asan_abi_address_is_poisoned(void const volatile *p); +void *__asan_abi_region_is_poisoned(void const volatile *p, size_t size); + +// Poison (Region) +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); + +// Poison (Partial) +void __asan_abi_set_shadow_xx_n(void *p, unsigned char xx, size_t n); + +// Poison (Stack) +void __asan_abi_poison_stack_memory(void *p, size_t n); +void __asan_abi_unpoison_stack_memory(void *p, size_t n); + +// Poison (Redzone) +void __asan_abi_poison_intra_object_redzone(void *p, size_t size); +void __asan_abi_unpoison_intra_object_redzone(void *p, size_t size); + +// Poison (Array Cookie) +void __asan_abi_poison_cxx_array_cookie(void *p); +void *__asan_abi_load_cxx_array_cookie(void **p); + +// Fakestack +void *__asan_abi_get_current_fake_stack(void); +void *__asan_abi_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, void **end); + +// Fakestack (alloca) +void __asan_abi_alloca_poison(void *addr, size_t size); +void __asan_abi_allocas_unpoison(void *top, void *bottom); + +// Fakestack (malloc/free) +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); +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,151 @@ +//===-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" + +// Globals +void __asan_abi_register_image_globals(void) { +} + +void __asan_abi_unregister_image_globals(void) { +} + +void __asan_abi_before_dynamic_init(const char *module_name) { +} + +void __asan_abi_after_dynamic_init(void) { +} + +// Interceptors +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; +} + +// RTL (Interface) +void __asan_abi_init(void) { +} + +void __asan_abi_handle_no_return(void) { +} + +// RTL (Report) +void __asan_abi_report_load_n(void *p, size_t n) { +} + +void __asan_abi_report_exp_load_n(void *p, size_t n, int exp) { +} + +void __asan_abi_report_load_n_noabort(void *p, size_t n) { +} + +void __asan_abi_report_store_n(void *p, size_t n) { +} + +void __asan_abi_report_exp_store_n(void *p, size_t n, int exp) { +} + +void __asan_abi_report_store_n_noabort(void *p, size_t n) { +} + +// RTL (Access) +void __asan_abi_load_n(void *p, size_t n) { +} + +void __asan_abi_exp_load_n(void *p, size_t n, int exp) { +} + +void __asan_abi_load_n_noabort(void *p, size_t n) { +} + +void __asan_abi_store_n(void *p, size_t n) { +} + +void __asan_abi_exp_store_n(void *p, size_t n, int exp) { +} + +void __asan_abi_store_n_noabort(void *p, size_t n) { +} + +// Poison +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; +} + +// Poison (Region) +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) { +} + +// Poison (Partial) +void __asan_abi_set_shadow_xx_n(void *p, unsigned char xx, size_t n) { +} + +// Poison (Stack) +void __asan_abi_poison_stack_memory(void *p, size_t n) { +} + +void __asan_abi_unpoison_stack_memory(void *p, size_t n) { +} + +// Poison (Redzone) +void __asan_abi_poison_intra_object_redzone(void *p, size_t size) { +} + +void __asan_abi_unpoison_intra_object_redzone(void *p, size_t size) { +} + +// Poison (Array Cookie) +void __asan_abi_poison_cxx_array_cookie(void *p) { +} + +void *__asan_abi_load_cxx_array_cookie(void **p) { + return NULL; +} + +// Fakestack +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; +} + +// Fakestack (alloca) +void __asan_abi_alloca_poison(void *addr, size_t size) { +} + +void __asan_abi_allocas_unpoison(void *top, void *bottom) { +} + +// Fakestack (malloc/free) +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; +} + +// 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.h b/compiler-rt/lib/asan_abi/asan_abi_shim.h new file mode 100644 --- /dev/null +++ b/compiler-rt/lib/asan_abi/asan_abi_shim.h @@ -0,0 +1,224 @@ +//===-asan_abi_shim.h - ASan Stable ABI Shim Interfac----------------------===// +// +// 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_SHIM_H +#define ASAN_ABI_SHIM_H + +typedef unsigned long uptr; +typedef unsigned long u64; +typedef unsigned int u32; + +extern void __asan_register_image_globals(uptr *flag); +extern void __asan_unregister_image_globals(uptr *flag); + +extern void __asan_register_elf_globals(uptr *flag, void *start, void *stop); +extern void __asan_unregister_elf_globals(uptr *flag, void *start, void *stop); + +extern void __asan_register_globals(__asan_global *globals, uptr n); +extern void __asan_unregister_globals(__asan_global *globals, uptr n); + +extern void __asan_before_dynamic_init(const char *module_name); +extern void __asan_after_dynamic_init(void); + +// Interceptors +extern void *__asan_memcpy(void *dst, const void *src, uptr size); +extern void *__asan_memset(void *s, int c, uptr n); +extern void *__asan_memmove(void *dest, const void *src, uptr n); + +// RTL (Interface) +extern void __asan_init(void); +extern void __asan_version_mismatch_check(void); +extern void __asan_handle_no_return(void); + +// RTL (Variables) +extern uptr __asan_shadow_memory_dynamic_address; +extern int __asan_option_detect_stack_use_after_return; + +// RTL (Report) +extern void __asan_report_load1(uptr addr); +extern void __asan_report_load2(uptr addr); +extern void __asan_report_load4(uptr addr); +extern void __asan_report_load8(uptr addr); +extern void __asan_report_load16(uptr addr); +extern void __asan_report_load_n(uptr addr, uptr size); +extern void __asan_report_store1(uptr addr); +extern void __asan_report_store2(uptr addr); +extern void __asan_report_store4(uptr addr); +extern void __asan_report_store8(uptr addr); +extern void __asan_report_store16(uptr addr); +extern void __asan_report_store_n(uptr addr, uptr size); + +// RTL (Report-experimental) +extern void __asan_report_exp_load1(uptr addr, u32 exp); +extern void __asan_report_exp_load2(uptr addr, u32 exp); +extern void __asan_report_exp_load4(uptr addr, u32 exp); +extern void __asan_report_exp_load8(uptr addr, u32 exp); +extern void __asan_report_exp_load16(uptr addr, u32 exp); +extern void __asan_report_exp_load_n(uptr addr, uptr size, u32 exp); +extern void __asan_report_exp_store1(uptr addr, u32 exp); +extern void __asan_report_exp_store2(uptr addr, u32 exp); +extern void __asan_report_exp_store4(uptr addr, u32 exp); +extern void __asan_report_exp_store8(uptr addr, u32 exp); +extern void __asan_report_exp_store16(uptr addr, u32 exp); +extern void __asan_report_exp_store_n(uptr addr, uptr size, u32 exp); + +// RTL (Report-noabort) +extern void __asan_report_load1_noabort(uptr addr); +extern void __asan_report_load2_noabort(uptr addr); +extern void __asan_report_load4_noabort(uptr addr); +extern void __asan_report_load8_noabort(uptr addr); +extern void __asan_report_load16_noabort(uptr addr); +extern void __asan_report_load_n_noabort(uptr addr, uptr size); +extern void __asan_report_store1_noabort(uptr addr); +extern void __asan_report_store2_noabort(uptr addr); +extern void __asan_report_store4_noabort(uptr addr); +extern void __asan_report_store8_noabort(uptr addr); +extern void __asan_report_store16_noabort(uptr addr); +extern void __asan_report_store_n_noabort(uptr addr, uptr size); + +// RTL (Access) +extern void __asan_load1(uptr p); +extern void __asan_load2(uptr p); +extern void __asan_load4(uptr p); +extern void __asan_load8(uptr p); +extern void __asan_load16(uptr p); +extern void __asan_loadN(uptr p, uptr size); +extern void __asan_store1(uptr p); +extern void __asan_store2(uptr p); +extern void __asan_store4(uptr p); +extern void __asan_store8(uptr p); +extern void __asan_store16(uptr p); +extern void __asan_storeN(uptr p, uptr size); + +// RTL (Access-experimental) +extern void __asan_exp_load1(uptr p, u32 exp); +extern void __asan_exp_load2(uptr p, u32 exp); +extern void __asan_exp_load4(uptr p, u32 exp); +extern void __asan_exp_load8(uptr p, u32 exp); +extern void __asan_exp_load16(uptr p, u32 exp); +extern void __asan_exp_loadN(uptr p, uptr size, u32 exp); +extern void __asan_exp_store1(uptr p, u32 exp); +extern void __asan_exp_store2(uptr p, u32 exp); +extern void __asan_exp_store4(uptr p, u32 exp); +extern void __asan_exp_store8(uptr p, u32 exp); +extern void __asan_exp_store16(uptr p, u32 exp); +extern void __asan_exp_storeN(uptr p, uptr size, u32 exp); + +// RTL (Access-noabort) +extern void __asan_load1_noabort(uptr p); +extern void __asan_load2_noabort(uptr p); +extern void __asan_load4_noabort(uptr p); +extern void __asan_load8_noabort(uptr p); +extern void __asan_load16_noabort(uptr p); +extern void __asan_loadN_noabort(uptr p, uptr size); +extern void __asan_store1_noabort(uptr p); +extern void __asan_store2_noabort(uptr p); +extern void __asan_store4_noabort(uptr p); +extern void __asan_store8_noabort(uptr p); +extern void __asan_store16_noabort(uptr p); +extern void __asan_storeN_noabort(uptr p, uptr size); + +// Poison +extern int __asan_address_is_poisoned(void const volatile *addr); +extern uptr __asan_region_is_poisoned(uptr beg, uptr size); + +// Poison (Region) +extern void __asan_poison_memory_region(void const volatile *addr, uptr size); +extern void __asan_unpoison_memory_region(void const volatile *addr, uptr size); + +// Poison (Partial) +extern void __asan_set_shadow_00(uptr addr, uptr size); +extern void __asan_set_shadow_01(uptr addr, uptr size); +extern void __asan_set_shadow_02(uptr addr, uptr size); +extern void __asan_set_shadow_03(uptr addr, uptr size); +extern void __asan_set_shadow_04(uptr addr, uptr size); +extern void __asan_set_shadow_05(uptr addr, uptr size); +extern void __asan_set_shadow_06(uptr addr, uptr size); +extern void __asan_set_shadow_07(uptr addr, uptr size); +extern void __asan_set_shadow_f1(uptr addr, uptr size); +extern void __asan_set_shadow_f2(uptr addr, uptr size); +extern void __asan_set_shadow_f3(uptr addr, uptr size); +extern void __asan_set_shadow_f5(uptr addr, uptr size); +extern void __asan_set_shadow_f8(uptr addr, uptr size); + +// Poison (Stack) +extern void __asan_poison_stack_memory(uptr addr, uptr size); +extern void __asan_unpoison_stack_memory(uptr addr, uptr size); + +// Poison (Redzone) +extern void __asan_poison_intra_object_redzone(uptr p, uptr size); +extern void __asan_unpoison_intra_object_redzone(uptr p, uptr size); + +// Poison (Array Cookie) +extern void __asan_poison_cxx_array_cookie(uptr p); +extern uptr __asan_load_cxx_array_cookie(uptr *p); + +// Fakestack +extern void *__asan_get_current_fake_stack(void); +extern void *__asan_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, void **end); + +// Fakestack (alloca) +extern void __asan_alloca_poison(uptr addr, uptr size); +extern void __asan_allocas_unpoison(uptr top, uptr bottom); + +// Fakestack (malloc) +extern uptr __asan_stack_malloc_0(uptr size); +extern uptr __asan_stack_malloc_1(uptr size); +extern uptr __asan_stack_malloc_2(uptr size); +extern uptr __asan_stack_malloc_3(uptr size); +extern uptr __asan_stack_malloc_4(uptr size); +extern uptr __asan_stack_malloc_5(uptr size); +extern uptr __asan_stack_malloc_6(uptr size); +extern uptr __asan_stack_malloc_7(uptr size); +extern uptr __asan_stack_malloc_8(uptr size); +extern uptr __asan_stack_malloc_9(uptr size); +extern uptr __asan_stack_malloc_10(uptr size); + +// Fakestack (malloc always) +extern uptr __asan_stack_malloc_always_0(uptr size); +extern uptr __asan_stack_malloc_always_1(uptr size); +extern uptr __asan_stack_malloc_always_2(uptr size); +extern uptr __asan_stack_malloc_always_3(uptr size); +extern uptr __asan_stack_malloc_always_4(uptr size); +extern uptr __asan_stack_malloc_always_5(uptr size); +extern uptr __asan_stack_malloc_always_6(uptr size); +extern uptr __asan_stack_malloc_always_7(uptr size); +extern uptr __asan_stack_malloc_always_8(uptr size); +extern uptr __asan_stack_malloc_always_9(uptr size); +extern uptr __asan_stack_malloc_always_10(uptr size); + +// Fakestack (free) +extern void __asan_stack_free_0(uptr ptr, uptr size); +extern void __asan_stack_free_1(uptr ptr, uptr size); +extern void __asan_stack_free_2(uptr ptr, uptr size); +extern void __asan_stack_free_3(uptr ptr, uptr size); +extern void __asan_stack_free_4(uptr ptr, uptr size); +extern void __asan_stack_free_5(uptr ptr, uptr size); +extern void __asan_stack_free_6(uptr ptr, uptr size); +extern void __asan_stack_free_7(uptr ptr, uptr size); +extern void __asan_stack_free_8(uptr ptr, uptr size); +extern void __asan_stack_free_9(uptr ptr, uptr size); +extern void __asan_stack_free_10(uptr ptr, uptr size); + +// Debugging +extern uptr __asan_get_alloc_stack(uptr addr, uptr *trace, uptr size, u32 *thread_id); + +// Reporting (including LLDB plugin requisites) +extern void __asan_report_error(uptr pc, uptr bp, uptr sp, uptr addr, int is_write, uptr access_size, u32 exp); +extern void __asan_set_error_report_callback(void (*callback)(const char*)); +extern void __asan_describe_address(uptr addr); +extern int __asan_report_present(void); +extern uptr __asan_get_report_pc(void); +extern uptr __asan_get_report_bp(void); +extern uptr __asan_get_report_sp(void); +extern uptr __asan_get_report_address(void); +extern int __asan_get_report_access_type(void); +extern uptr __asan_get_report_access_size(void); +extern const char *__asan_get_report_description(void); + +#endif // ASAN_ABI_SHIM_H 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,689 @@ +//===-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_abi.h" +#include "../asan/asan_interface_internal.h" +#include + +// Globals +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) { +} + + +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(); +} + + +// Interceptors +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); +} + + +// RTL (Interface) +void __asan_init(void) { + assert(sizeof(uptr) == 8); + assert(sizeof(u64) == 8); + assert(sizeof(u32) == 4); + + __asan_abi_init(); +} + +void __asan_version_mismatch_check_apple_clang_1400(void) { +} + +void __asan_handle_no_return(void) { + __asan_abi_handle_no_return(); +} + + +// RTL (Variables) +uptr __asan_shadow_memory_dynamic_address = (uptr) 0xdeaddeaddeadbeaf; +int __asan_option_detect_stack_use_after_return = 0; + +// RTL (Report) +void __asan_report_load1(uptr addr) { + __asan_abi_report_load_n((void *)addr, 1); +} + +void __asan_report_load2(uptr addr) { + __asan_abi_report_load_n((void *) addr, 2); +} + +void __asan_report_load4(uptr addr) { + __asan_abi_report_load_n((void *) addr, 4); +} + +void __asan_report_load8(uptr addr) { + __asan_abi_report_load_n((void *) addr, 8); +} + +void __asan_report_load16(uptr addr) { + __asan_abi_report_load_n((void *) addr, 16); +} + +void __asan_report_loadN(uptr addr, uptr size) { + __asan_abi_report_load_n((void *) addr, size); +} + +void __asan_report_store1(uptr addr) { + __asan_abi_report_store_n((void *) addr, 1); +} + +void __asan_report_store2(uptr addr) { + __asan_abi_report_store_n((void *) addr, 2); +} + +void __asan_report_store4(uptr addr) { + __asan_abi_report_store_n((void *) addr, 4); +} + +void __asan_report_store8(uptr addr) { + __asan_abi_report_store_n((void *) addr, 8); +} + +void __asan_report_store16(uptr addr) { + __asan_abi_report_store_n((void *) addr, 16); +} + +void __asan_report_store_n(uptr addr, uptr size) { + __asan_abi_report_store_n((void *) addr, size); +} + + +// RTL (Report-experimental) +void __asan_report_exp_load1(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *) addr, exp, 1); +} + +void __asan_report_exp_load2(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *) addr, exp, 2); +} + +void __asan_report_exp_load4(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *) addr, exp, 4); +} + +void __asan_report_exp_load8(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *) addr, exp, 8); +} + +void __asan_report_exp_load16(uptr addr, u32 exp) { + __asan_abi_report_exp_load_n((void *) addr, exp, 16); +} + +void __asan_report_exp_load_n(uptr addr, uptr size, u32 exp) { + __asan_abi_report_exp_load_n((void *) addr, size, exp); +} + +void __asan_report_exp_store1(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *) addr, exp, 1); +} + +void __asan_report_exp_store2(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *) addr, exp, 2); +} + +void __asan_report_exp_store4(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *) addr, exp, 4); +} + +void __asan_report_exp_store8(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *) addr, exp, 8); +} + +void __asan_report_exp_store16(uptr addr, u32 exp) { + __asan_abi_report_exp_store_n((void *) addr, exp, 16); +} + +void __asan_report_exp_store_n(uptr addr, uptr size, u32 exp) { + __asan_abi_report_exp_store_n((void *) addr, size, exp); +} + + +// RTL (Report-noabort) +void __asan_report_load1_noabort(uptr addr) { + __asan_abi_report_load_n_noabort((void *) addr, 1); +} + +void __asan_report_load2_noabort(uptr addr) { + __asan_abi_report_load_n_noabort((void *) addr, 2); +} + +void __asan_report_load4_noabort(uptr addr) { + __asan_abi_report_load_n_noabort((void *) addr, 4); +} + +void __asan_report_load8_noabort(uptr addr) { + __asan_abi_report_load_n_noabort((void *) addr, 8); +} + +void __asan_report_load16_noabort(uptr addr) { + __asan_abi_report_load_n_noabort((void *) addr, 16); +} + +void __asan_report_load_n_noabort(uptr addr, uptr size) { + __asan_abi_report_load_n_noabort((void *) addr, size); +} + +void __asan_report_store1_noabort(uptr addr) { + __asan_abi_report_store_n_noabort((void *) addr, 1); +} + +void __asan_report_store2_noabort(uptr addr) { + __asan_abi_report_store_n_noabort((void *) addr, 2); +} + +void __asan_report_store4_noabort(uptr addr) { + __asan_abi_report_store_n_noabort((void *) addr, 4); +} + +void __asan_report_store8_noabort(uptr addr) { + __asan_abi_report_store_n_noabort((void *) addr, 8); +} + +void __asan_report_store16_noabort(uptr addr) { + __asan_abi_report_store_n_noabort((void *) addr, 16); +} + +void __asan_report_store_n_noabort(uptr addr, uptr size) { + __asan_abi_report_store_n_noabort((void *) addr, size); +} + + +// RTL (Access) +void __asan_load1(uptr addr) { + __asan_abi_load_n((void *) addr, 1); +} + +void __asan_load2(uptr addr) { + __asan_abi_load_n((void *) addr, 2); +} + +void __asan_load4(uptr addr) { + __asan_abi_load_n((void *) addr, 4); +} + +void __asan_load8(uptr addr) { + __asan_abi_load_n((void *) addr, 8); +} + +void __asan_load16(uptr addr) { + __asan_abi_load_n((void *) addr, 16); +} + +void __asan_loadN(uptr addr, uptr size) { + __asan_abi_load_n((void *) addr, size); +} + +void __asan_store1(uptr addr) { + __asan_abi_store_n((void *) addr, 1); +} + +void __asan_store2(uptr addr) { + __asan_abi_store_n((void *) addr, 2); +} + +void __asan_store4(uptr addr) { + __asan_abi_store_n((void *) addr, 4); +} + +void __asan_store8(uptr addr) { + __asan_abi_store_n((void *) addr, 8); +} + +void __asan_store16(uptr addr) { + __asan_abi_store_n((void *) addr, 16); +} + +void __asan_storeN(uptr addr, uptr size) { + __asan_abi_store_n((void *) addr, size); +} + + +// RTL (Access-experimental) +void __asan_exp_load1(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *) addr, 1, exp); +} + +void __asan_exp_load2(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *) addr, 2, exp); +} + +void __asan_exp_load4(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *) addr, 4, exp); +} + +void __asan_exp_load8(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *) addr, 8, exp); +} + +void __asan_exp_load16(uptr addr, u32 exp) { + __asan_abi_exp_load_n((void *) addr, 16, exp); +} + +void __asan_exp_loadN(uptr addr, uptr size, u32 exp) { + __asan_abi_exp_load_n((void *) addr, size, exp); +} + +void __asan_exp_store1(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *) addr, 1, exp); +} + +void __asan_exp_store2(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *) addr, 2, exp); +} + +void __asan_exp_store4(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *) addr, 4, exp); +} + +void __asan_exp_store8(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *) addr, 8, exp); +} + +void __asan_exp_store16(uptr addr, u32 exp) { + __asan_abi_exp_store_n((void *) addr, 16, exp); +} + +void __asan_exp_storeN(uptr addr, uptr size, u32 exp) { + __asan_abi_exp_store_n((void *) addr, size, exp); +} + + +// RTL (Access-noabort) +void __asan_load1_noabort(uptr addr) { + __asan_abi_load_n_noabort((void *) addr, 1); +} + +void __asan_load2_noabort(uptr addr) { + __asan_abi_load_n_noabort((void *) addr, 2); +} + +void __asan_load4_noabort(uptr addr) { + __asan_abi_load_n_noabort((void *) addr, 4); +} + +void __asan_load8_noabort(uptr addr) { + __asan_abi_load_n_noabort((void *) addr, 8); +} + +void __asan_load16_noabort(uptr addr) { + __asan_abi_load_n_noabort((void *) addr, 16); +} + +void __asan_loadN_noabort(uptr addr, uptr size) { + __asan_abi_load_n_noabort((void *) addr, size); +} + +void __asan_store1_noabort(uptr addr) { + __asan_abi_store_n_noabort((void *) addr, 1); +} + +void __asan_store2_noabort(uptr addr) { + __asan_abi_store_n_noabort((void *) addr, 2); +} + +void __asan_store4_noabort(uptr addr) { + __asan_abi_store_n_noabort((void *) addr, 4); +} + +void __asan_store8_noabort(uptr addr) { + __asan_abi_store_n_noabort((void *) addr, 8); +} + +void __asan_store16_noabort(uptr addr) { + __asan_abi_store_n_noabort((void *) addr, 16); +} + +void __asan_storeN_noabort(uptr addr, uptr size) { + __asan_abi_store_n_noabort((void *) addr, size); +} + + +// Poison +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); +} + + +// Poison (Region) +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); +} + + +// Poison (Partial) +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); +} + + +// Poison (Stack) +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); +} + + +// Poison (Redzone) +void __asan_poison_intra_object_redzone(uptr p, uptr size) { +} + +void __asan_unpoison_intra_object_redzone(uptr p, uptr size) { +} + + +// Poison (Array Cookie) +void __asan_poison_cxx_array_cookie(uptr p) { +} + +uptr __asan_load_cxx_array_cookie(uptr *p) { + // TBD: Fail here + return (uptr) 0; +} + + +// Fakestack +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; +} + + +// Fakestack (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); +} + + +// Fakestack (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); +} + + +// Fakestack (malloc always) +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); +} + + +// Fakestack (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); +} + + +// Debugging +uptr __asan_get_alloc_stack(uptr addr, uptr *trace, uptr size, u32 *thread_id) { + // TBD: Fail here + return (uptr) 0; +} + + +// Reporting (including LLDB plugin requisites) +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/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 @@ +#TODO: Setup asan_abi test suite.