1; Test that global metadata is placed in a separate section on Mach-O platforms,
2; allowing dead stripping to be performed, and that the appropriate runtime
3; routines are invoked.
4
5; RUN: opt < %s -asan -asan-module -asan-globals-live-support -S | FileCheck %s
6
7target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
8target triple = "x86_64-apple-macosx10.11.0"
9
10@global = global [1 x i32] zeroinitializer, align 4
11
12!llvm.asan.globals = !{!0}
13
14!0 = !{[1 x i32]* @global, !1, !"global", i1 false, i1 false}
15!1 = !{!"test-globals.c", i32 1, i32 5}
16
17
18; Test that there is the flag global variable:
19; CHECK: @__asan_globals_registered = common global i64 0
20
21; Find the metadata for @global:
22; CHECK: [[METADATA:@[0-9]+]] = internal global {{.*}} @global {{.*}} section "__DATA,__asan_globals,regular", align 1
23
24; Find the liveness binder for @global and its metadata:
25; CHECK: @{{[0-9]+}} = internal global {{.*}} @global {{.*}} [[METADATA]] {{.*}} section "__DATA,__asan_liveness,regular,live_support"
26
27; Test that __asan_register_image_globals is invoked from the constructor:
28; CHECK-LABEL: define internal void @asan.module_ctor
29; CHECK-NOT: ret
30; CHECK: call void @__asan_register_image_globals(i64 ptrtoint (i64* @__asan_globals_registered to i64))
31; CHECK: ret
32
33; Test that __asan_unregister_image_globals is invoked from the destructor:
34; CHECK-LABEL: define internal void @asan.module_dtor
35; CHECK-NOT: ret
36; CHECK: call void @__asan_unregister_image_globals(i64 ptrtoint (i64* @__asan_globals_registered to i64))
37; CHECK: ret
38