brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · dd73c75 Raw
86 lines · plain
1; RUN: opt < %s -passes=asan -S | FileCheck %s2; RUN: opt < %s -passes=asan -asan-mapping-scale=5 -S | FileCheck %s3target 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"4target triple = "x86_64-unknown-linux-gnu"5@xxx = internal global i32 0, align 4, sanitize_address_dyninit  ; With dynamic initializer.6@XXX = global i32 0, align 4, sanitize_address_dyninit           ; With dynamic initializer.7@yyy = internal global i32 0, align 4  ; W/o dynamic initializer.8@YYY = global i32 0, align 4           ; W/o dynamic initializer.9 10define i32 @initializer() uwtable {11entry:12  ret i32 4213}14 15define internal void @__cxx_global_var_init() section ".text.startup" {16entry:17  %call = call i32 @initializer()18  store i32 %call, ptr @xxx, align 419  ret void20}21 22@llvm.global_ctors = appending global [2 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @__late_ctor, ptr null }, { i32, ptr, ptr } { i32 0, ptr @__early_ctor, ptr null }]23 24define internal void @__late_ctor() sanitize_address section ".text.startup" {25entry:26  call void @__cxx_global_var_init()27  ret void28}29 30; Clang indicated that @xxx was dynamically initailized.31; __asan_{before,after}_dynamic_init should be called from __late_ctor32 33; CHECK-LABEL: define internal void @__late_ctor34; CHECK-NOT: ret35; CHECK: call void @__asan_before_dynamic_init36; CHECK: call void @__cxx_global_var_init37; CHECK: call void @__asan_after_dynamic_init38; CHECK: ret39 40; CTOR with priority 0 should not be instrumented.41define internal void @__early_ctor() sanitize_address section ".text.startup" {42entry:43  call void @__cxx_global_var_init()44  ret void45}46; CHECK-LABEL: define internal void @__early_ctor47; CHECK-NOT: __asan48; CHECK: ret49 50; Check that xxx is instrumented.51define void @touch_xxx() sanitize_address {52  store i32 0, ptr @xxx, align 453  ret void54; CHECK-LABEL: touch_xxx55; CHECK: call void @__asan_report_store456; CHECK: ret void57}58 59; Check that XXX is instrumented.60define void @touch_XXX() sanitize_address {61  store i32 0, ptr @XXX, align 462  ret void63; CHECK: define void @touch_XXX64; CHECK: call void @__asan_report_store465; CHECK: ret void66}67 68 69; Check that yyy is NOT instrumented (as it does not have dynamic initializer).70define void @touch_yyy() sanitize_address {71  store i32 0, ptr @yyy, align 472  ret void73; CHECK: define void @touch_yyy74; CHECK-NOT: call void @__asan_report_store475; CHECK: ret void76}77 78; Check that YYY is NOT instrumented (as it does not have dynamic initializer).79define void @touch_YYY() sanitize_address {80  store i32 0, ptr @YYY, align 481  ret void82; CHECK: define void @touch_YYY83; CHECK-NOT: call void @__asan_report_store484; CHECK: ret void85}86