mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
Update and improve compiler-rt tests for -mllvm -asan_use_after_return=(never|[runtime]|always).
In addition: - optionally add global flag to capture compile intent for UAR: __asan_detect_use_after_return_always. The global is a SANITIZER_WEAK_ATTRIBUTE. for issue: https://github.com/google/sanitizers/issues/1394 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D103304
This commit is contained in:
parent
4962534c4a
commit
6bd5841410
@ -2645,6 +2645,18 @@ bool ModuleAddressSanitizer::instrumentModule(Module &M) {
|
||||
appendToGlobalDtors(M, AsanDtorFunction, Priority);
|
||||
}
|
||||
|
||||
#if !SANITIZER_WINDOWS
|
||||
assert(ClUseAfterReturn != AsanDetectStackUseAfterReturnMode::Invalid);
|
||||
if (ClUseAfterReturn == AsanDetectStackUseAfterReturnMode::Always) {
|
||||
Type *IntTy = Type::getInt32Ty(*C);
|
||||
M.getOrInsertGlobal("__asan_detect_use_after_return_always", IntTy, [&] {
|
||||
return new GlobalVariable(
|
||||
M, IntTy, /*isConstant=*/true, GlobalValue::WeakODRLinkage,
|
||||
ConstantInt::get(IntTy, 1), "__asan_detect_use_after_return_always");
|
||||
});
|
||||
}
|
||||
#endif // !SANITIZER_WINDOWS
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -passes='asan-pipeline' -asan-use-after-return=0 -S | FileCheck %s --check-prefixes=CHECK,NEVER
|
||||
; RUN: opt < %s -passes='asan-pipeline' -asan-use-after-return=1 -S | FileCheck %s --check-prefixes=CHECK,RUNTIME
|
||||
; RUN: opt < %s -passes='asan-pipeline' -asan-use-after-return=0 -S | FileCheck %s --check-prefixes=CHECK,NEVER --implicit-check-not=__asan_detect_use_after_return_always
|
||||
; RUN: opt < %s -passes='asan-pipeline' -asan-use-after-return=1 -S | FileCheck %s --check-prefixes=CHECK,RUNTIME --implicit-check-not=__asan_detect_use_after_return_always
|
||||
; RUN: opt < %s -passes='asan-pipeline' -asan-use-after-return=2 -S | FileCheck %s --check-prefixes=CHECK,ALWAYS
|
||||
target datalayout = "e-i64:64-f80:128-s:64-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; ALWAYS-LABEL: @__asan_detect_use_after_return_always =
|
||||
; ALWAYS-SAME: weak_odr constant i32 1
|
||||
|
||||
declare void @Foo(i8*)
|
||||
|
||||
define void @Empty() uwtable sanitize_address {
|
||||
|
@ -135,6 +135,7 @@ target(asan_target_type, "asan") {
|
||||
# asan
|
||||
"-Wl,-U,___asan_default_options",
|
||||
"-Wl,-U,___asan_default_suppressions",
|
||||
"-Wl,-U,___asan_detect_use_after_return_always",
|
||||
"-Wl,-U,___asan_on_error",
|
||||
"-Wl,-U,___asan_set_shadow_00",
|
||||
"-Wl,-U,___asan_set_shadow_f1",
|
||||
|
Loading…
Reference in New Issue
Block a user