mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
[asan] don't instrument linker-initialized globals even with external linkage in -asan-initialization-order mode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168367 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ca23d43084
commit
407790604b
@ -364,11 +364,9 @@ void AddressSanitizer::instrumentMop(Instruction *I) {
|
||||
if (!ClInitializers)
|
||||
return;
|
||||
// If a global variable does not have dynamic initialization we don't
|
||||
// have to instrument it. However, if a global has external linkage, we
|
||||
// assume it has dynamic initialization, as it may have an initializer
|
||||
// in a different TU.
|
||||
if (G->getLinkage() != GlobalVariable::ExternalLinkage &&
|
||||
!DynamicallyInitializedGlobals.Contains(G))
|
||||
// have to instrument it. However, if a global does not have initailizer
|
||||
// at all, we assume it has dynamic initializer (in other TU).
|
||||
if (G->hasInitializer() && !DynamicallyInitializedGlobals.Contains(G))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,14 @@
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
@xxx = internal global i32 0, align 4 ; With dynamic initializer.
|
||||
@XXX = global i32 0, align 4 ; With dynamic initializer.
|
||||
@yyy = internal global i32 0, align 4 ; W/o dynamic initializer.
|
||||
@YYY = global i32 0, align 4 ; W/o dynamic initializer.
|
||||
; Clang will emit the following metadata identifying @xxx as dynamically
|
||||
; initialized.
|
||||
!0 = metadata !{i32* @xxx}
|
||||
!llvm.asan.dynamically_initialized_globals = !{!0}
|
||||
!1 = metadata !{i32* @XXX}
|
||||
!llvm.asan.dynamically_initialized_globals = !{!0, !1}
|
||||
|
||||
define i32 @initializer() uwtable {
|
||||
entry:
|
||||
@ -45,6 +48,16 @@ define void @touch_xxx() address_safety {
|
||||
; CHECK: ret void
|
||||
}
|
||||
|
||||
; Check that XXX is instrumented.
|
||||
define void @touch_XXX() address_safety {
|
||||
store i32 0, i32 *@XXX, align 4
|
||||
ret void
|
||||
; CHECK: define void @touch_XXX
|
||||
; CHECK: call void @__asan_report_store4
|
||||
; CHECK: ret void
|
||||
}
|
||||
|
||||
|
||||
; Check that yyy is NOT instrumented (as it does not have dynamic initializer).
|
||||
define void @touch_yyy() address_safety {
|
||||
store i32 0, i32 *@yyy, align 4
|
||||
@ -53,3 +66,12 @@ define void @touch_yyy() address_safety {
|
||||
; CHECK-NOT: call void @__asan_report_store4
|
||||
; CHECK: ret void
|
||||
}
|
||||
|
||||
; Check that YYY is NOT instrumented (as it does not have dynamic initializer).
|
||||
define void @touch_YYY() address_safety {
|
||||
store i32 0, i32 *@YYY, align 4
|
||||
ret void
|
||||
; CHECK: define void @touch_YYY
|
||||
; CHECK-NOT: call void @__asan_report_store4
|
||||
; CHECK: ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user