mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
fce986a506
As discussed in https://github.com/google/sanitizers/issues/398, with current implementation of poisoning globals we can have some CHECK failures or false positives in case of mixing instrumented and non-instrumented code due to ASan poisons innocent globals from non-sanitized binary/library. We can use private aliases to avoid such errors. In addition, to preserve ODR violation detection, we introduce new __odr_asan_gen_XXX symbol for each instrumented global that indicates if this global was already registered. To detect ODR violation in runtime, we should only check the value of indicator and report an error if it isn't equal to zero. Differential Revision: http://reviews.llvm.org/D15642 llvm-svn: 260075
24 lines
967 B
LLVM
24 lines
967 B
LLVM
; RUN: opt < %s -asan -asan-module -asan-use-private-alias=1 -S | FileCheck %s
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
@a = internal global [2 x i32] zeroinitializer, align 4
|
|
|
|
; Check that we generate internal alias and odr indicator symbols for global to be protected.
|
|
; CHECK: @__odr_asan_gen_a = internal global i8 0, align 1
|
|
; CHECK: @"a<stdin>" = internal alias { [2 x i32], [56 x i8] }, { [2 x i32], [56 x i8] }* @a
|
|
|
|
; Function Attrs: nounwind sanitize_address uwtable
|
|
define i32 @foo(i32 %M) #0 {
|
|
entry:
|
|
%M.addr = alloca i32, align 4
|
|
store i32 %M, i32* %M.addr, align 4
|
|
store volatile i32 6, i32* getelementptr inbounds ([2 x i32], [2 x i32]* @a, i64 2, i64 0), align 4
|
|
%0 = load i32, i32* %M.addr, align 4
|
|
%idxprom = sext i32 %0 to i64
|
|
%arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* @a, i64 0, i64 %idxprom
|
|
%1 = load volatile i32, i32* %arrayidx, align 4
|
|
ret i32 %1
|
|
}
|