1 ; RUN: opt < %s -asan -asan-module -S | FileCheck %s 2 3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 4 target triple = "x86_64-unknown-linux-gnu" 5 6 ; Globals: 7 @global = global i32 0, align 4 8 @dyn_init_global = global i32 0, align 4 9 @blacklisted_global = global i32 0, align 4 10 @_ZZ4funcvE10static_var = internal global i32 0, align 4 11 @.str = private unnamed_addr constant [14 x i8] c"Hello, world!\00", align 1 12 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_asan_globals.cpp, i8* null }] 13 14 ; Sanitizer location descriptors: 15 @.str1 = private unnamed_addr constant [22 x i8] c"/tmp/asan-globals.cpp\00", align 1 16 @.asan_loc_descr = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 5, i32 5 } 17 @.asan_loc_descr1 = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 7, i32 5 } 18 @.asan_loc_descr2 = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 12, i32 14 } 19 @.asan_loc_descr4 = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 14, i32 25 } 20 21 ; Check that globals were instrumented, but sanitizer location descriptors weren't: 22 ; CHECK: @global = global { i32, [60 x i8] } zeroinitializer, align 32 23 ; CHECK: @.str = internal unnamed_addr constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }, align 32 24 ; CHECK: @.asan_loc_descr = private unnamed_addr constant { [22 x i8]*, i32, i32 } { [22 x i8]* @.str1, i32 5, i32 5 } 25 26 ; Check that location decriptors were passed into __asan_register_globals: 27 ; CHECK: i64 ptrtoint ({ [22 x i8]*, i32, i32 }* @.asan_loc_descr to i64) 28 29 ; Function Attrs: nounwind sanitize_address 30 define internal void @__cxx_global_var_init() #0 section ".text.startup" { 31 entry: 32 %0 = load i32* @global, align 4 33 store i32 %0, i32* @dyn_init_global, align 4 34 ret void 35 } 36 37 ; Function Attrs: nounwind sanitize_address 38 define void @_Z4funcv() #1 { 39 entry: 40 %literal = alloca i8*, align 8 41 store i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0), i8** %literal, align 8 42 ret void 43 } 44 45 ; Function Attrs: nounwind sanitize_address 46 define internal void @_GLOBAL__sub_I_asan_globals.cpp() #0 section ".text.startup" { 47 entry: 48 call void @__cxx_global_var_init() 49 ret void 50 } 51 52 attributes #0 = { nounwind sanitize_address } 53 attributes #1 = { nounwind sanitize_address "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 54 55 !llvm.asan.globals = !{!0, !1, !2, !3, !4} 56 !llvm.ident = !{!5} 57 58 !0 = metadata !{i32* @global, { [22 x i8]*, i32, i32 }* @.asan_loc_descr, i1 false, i1 false} 59 !1 = metadata !{i32* @dyn_init_global, { [22 x i8]*, i32, i32 }* @.asan_loc_descr1, i1 true, i1 false} 60 !2 = metadata !{i32* @blacklisted_global, null, i1 false, i1 true} 61 !3 = metadata !{i32* @_ZZ4funcvE10static_var, { [22 x i8]*, i32, i32 }* @.asan_loc_descr2, i1 false, i1 false} 62 !4 = metadata !{[14 x i8]* @.str, { [22 x i8]*, i32, i32 }* @.asan_loc_descr4, i1 false, i1 false} 63 !5 = metadata !{metadata !"clang version 3.5.0 (211282)"} 64