Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 8 declare external i32 @malloc(i32) | |
| 9 declare external i32 @realloc(i32, i32) | |
| 10 declare external i32 @calloc(i32, i32) | |
| 11 declare external void @free(i32) | |
| 12 | |
| 13 @global_malloc = internal global i32 ptrtoint (i32 (i32)* @malloc to i32) | |
| 14 @global_realloc = internal global i32 ptrtoint (i32 (i32, i32)* @realloc to i32) | |
| 15 @global_calloc = internal global i32 ptrtoint (i32 (i32, i32)* @calloc to i32) | |
| 16 @global_free = internal global i32 ptrtoint (void (i32)* @free to i32) | |
|
Karl
2016/08/15 21:43:46
How about inserting a non-global pointer to show n
tlively
2016/08/15 22:24:59
My next task is to instrument non-global pointers,
| |
| 17 | |
| 18 @constant_malloc = internal constant i32 ptrtoint (i32 (i32)* @malloc to i32) | |
| 19 @constant_realloc = internal constant i32 ptrtoint (i32 (i32, i32)* @realloc to i32) | |
| 20 @constant_calloc = internal constant i32 ptrtoint (i32 (i32, i32)* @calloc to i3 2) | |
| 21 @constant_free = internal constant i32 ptrtoint (void (i32)* @free to i32) | |
| 22 | |
| 23 define void @func() { | |
| 24 ret void | |
| 25 } | |
| 26 | |
| 27 ; DUMP: Instrumented Globals | |
| 28 ; DUMP-NEXT: @__$rz_array | |
| 29 ; DUMP-NEXT: @__$rz_sizes | |
| 30 ; DUMP-NEXT: @__$rz0 | |
| 31 ; DUMP-NEXT: @global_malloc = internal global i32 | |
| 32 ; DUMP-SAME: ptrtoint (i32 (i32)* @__asan_malloc to i32) | |
| 33 ; DUMP-NEXT: @__$rz1 | |
| 34 ; DUMP-NEXT: @__$rz2 | |
| 35 ; DUMP-NEXT: @global_realloc = internal global i32 | |
| 36 ; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_realloc to i32) | |
| 37 ; DUMP-NEXT: @__$rz3 | |
| 38 ; DUMP-NEXT: @__$rz4 | |
| 39 ; DUMP-NEXT: @global_calloc = internal global i32 | |
| 40 ; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_calloc to i32) | |
| 41 ; DUMP-NEXT: @__$rz5 | |
| 42 ; DUMP-NEXT: @__$rz6 | |
| 43 ; DUMP-NEXT: @global_free = internal global i32 | |
| 44 ; DUMP-SAME: ptrtoint (void (i32)* @__asan_free to i32) | |
| 45 ; DUMP-NEXT: @__$rz7 | |
| 46 ; DUMP-NEXT: @__$rz8 | |
| 47 ; DUMP-NEXT: @constant_malloc = internal constant i32 | |
| 48 ; DUMP-SAME: ptrtoint (i32 (i32)* @__asan_malloc to i32) | |
| 49 ; DUMP-NEXT: @__$rz9 | |
| 50 ; DUMP-NEXT: @__$rz10 | |
| 51 ; DUMP-NEXT: @constant_realloc = internal constant i32 | |
| 52 ; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_realloc to i32) | |
| 53 ; DUMP-NEXT: @__$rz11 | |
| 54 ; DUMP-NEXT: @__$rz12 | |
| 55 ; DUMP-NEXT: @constant_calloc = internal constant i32 | |
| 56 ; DUMP-SAME: ptrtoint (i32 (i32, i32)* @__asan_calloc to i32) | |
| 57 ; DUMP-NEXT: @__$rz13 | |
| 58 ; DUMP-NEXT: @__$rz14 | |
| 59 ; DUMP-NEXT: @constant_free = internal constant i32 | |
| 60 ; DUMP-SAME: ptrtoint (void (i32)* @__asan_free to i32) | |
| 61 ; DUMP-NEXT: @__$rz15 | |
| OLD | NEW |