1; Test that global pointers to allocation functions are replaced 2 3; REQUIRES: allow_dump 4 5; RUN: %p2i -i %s --args -verbose=global_init -threads=0 -fsanitize-address \ 6; RUN: -allow-externally-defined-symbols | FileCheck --check-prefix=DUMP %s 7 8declare external i32 @malloc(i32) 9declare external i32 @realloc(i32, i32) 10declare external i32 @calloc(i32, i32) 11declare external void @free(i32) 12declare external void @foo() 13 14@global_malloc = internal global i32 ptrtoint (i32 (i32)* @malloc to i32) 15@global_realloc = internal global i32 ptrtoint (i32 (i32, i32)* @realloc to i32) 16@global_calloc = internal global i32 ptrtoint (i32 (i32, i32)* @calloc to i32) 17@global_free = internal global i32 ptrtoint (void (i32)* @free to i32) 18@global_foo = internal global i32 ptrtoint (void ()* @foo to i32) 19 20@constant_malloc = internal constant i32 ptrtoint (i32 (i32)* @malloc to i32) 21@constant_realloc = internal constant i32 ptrtoint (i32 (i32, i32)* @realloc to i32) 22@constant_calloc = internal constant i32 ptrtoint (i32 (i32, i32)* @calloc to i32) 23@constant_free = internal constant i32 ptrtoint (void (i32)* @free to i32) 24@constant_foo = internal constant i32 ptrtoint (void ()* @foo to i32) 25 26@multiple_initializers = internal global <{i32, i32}> <{i32 ptrtoint (i32 (i32)* @malloc to i32), i32 ptrtoint (void (i32)* @free to i32)}> 27 28define void @func() { 29 ret void 30} 31 32; DUMP: Instrumented Globals 33; DUMP-NEXT: @__$rz_array 34; DUMP-NEXT: @__$rz_sizes 35; DUMP-NEXT: @__$rz0 36; DUMP-NEXT: @global_malloc = internal global i32 37; DUMP-SAME: ptrtoint (i32 (i32)* @__asan_malloc to i32) 38; DUMP-NEXT: @__$rz1 39; DUMP-NEXT: @__$rz2 40; DUMP-NEXT: @global_realloc = internal global i32 41; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_realloc to i32) 42; DUMP-NEXT: @__$rz3 43; DUMP-NEXT: @__$rz4 44; DUMP-NEXT: @global_calloc = internal global i32 45; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_calloc to i32) 46; DUMP-NEXT: @__$rz5 47; DUMP-NEXT: @__$rz6 48; DUMP-NEXT: @global_free = internal global i32 49; DUMP-SAME: ptrtoint (void (i32)* @__asan_free to i32) 50; DUMP-NEXT: @__$rz7 51; DUMP-NEXT: @__$rz8 52; DUMP-NEXT: @global_foo = internal global i32 53; DUMP-SAME: ptrtoint (void ()* @foo to i32) 54; DUMP-NEXT: @__$rz9 55; DUMP-NEXT: @__$rz10 56; DUMP-NEXT: @constant_malloc = internal constant i32 57; DUMP-SAME: ptrtoint (i32 (i32)* @__asan_malloc to i32) 58; DUMP-NEXT: @__$rz11 59; DUMP-NEXT: @__$rz12 60; DUMP-NEXT: @constant_realloc = internal constant i32 61; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_realloc to i32) 62; DUMP-NEXT: @__$rz13 63; DUMP-NEXT: @__$rz14 64; DUMP-NEXT: @constant_calloc = internal constant i32 65; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_calloc to i32) 66; DUMP-NEXT: @__$rz15 67; DUMP-NEXT: @__$rz16 68; DUMP-NEXT: @constant_free = internal constant i32 69; DUMP-SAME: ptrtoint (void (i32)* @__asan_free to i32) 70; DUMP-NEXT: @__$rz17 71; DUMP-NEXT: @__$rz18 72; DUMP-NEXT: @constant_foo = internal constant i32 73; DUMP-SAME: ptrtoint (void ()* @foo to i32) 74; DUMP-NEXT: @__$rz19 75; DUMP-NEXT: @__$rz20 76; DUMP-NEXT: @multiple_initializers = internal global <{ i32, i32 }> 77; DUMP-SAME: <{ i32 ptrtoint (i32 (i32)* @__asan_malloc to i32), 78; DUMP-SAME: i32 ptrtoint (void (i32)* @__asan_free to i32) }> 79; DUMP-NEXT: @__$rz21