| OLD | NEW |
| (Empty) | |
| 1 ; Verify that ASan properly catches and reports bugs |
| 2 |
| 3 ; REQUIRES: no_minimal_build |
| 4 |
| 5 ; check with a one off the end local access |
| 6 ; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \ |
| 7 ; RUN: --fsanitize-address --sz="-allow-externally-defined-symbols" \ |
| 8 ; RUN: %t.pexe -o %t && %t 2>&1 | FileCheck %s |
| 9 |
| 10 ; check with a many off the end local access |
| 11 ; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \ |
| 12 ; RUN: --fsanitize-address --sz="-allow-externally-defined-symbols" \ |
| 13 ; RUN: %t.pexe -o %t && %t 1 2>&1 | FileCheck %s |
| 14 |
| 15 ; check with a one before the front local access |
| 16 ; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \ |
| 17 ; RUN: --fsanitize-address --sz="-allow-externally-defined-symbols" \ |
| 18 ; RUN: %t.pexe -o %t && %t 1 2 2>&1 | FileCheck %s |
| 19 |
| 20 ; check with a one off the end global access |
| 21 ; RUIN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \ |
| 22 ; RUIN: --fsanitize-address --sz="-allow-externally-defined-symbols" \ |
| 23 ; RUIN: %t.pexe -o %t && %t 1 2 3 2>&1 | FileCheck %s |
| 24 |
| 25 ; check with a many off the end global access |
| 26 ; RUIN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \ |
| 27 ; RUIN: --fsanitize-address --sz="-allow-externally-defined-symbols" \ |
| 28 ; RUIN: %t.pexe -o %t && %t 1 2 3 4 2>&1 | FileCheck %s |
| 29 |
| 30 ; check with a one before the front global access |
| 31 ; RUIN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \ |
| 32 ; RUIN: --fsanitize-address --sz="-allow-externally-defined-symbols" \ |
| 33 ; RUIN: %t.pexe -o %t && %t 1 2 3 4 5 2>&1 | FileCheck %s |
| 34 |
| 35 |
| 36 declare external void @exit(i32) |
| 37 |
| 38 ; A global array |
| 39 @array = internal constant [12 x i8] zeroinitializer |
| 40 |
| 41 define i32 @access(i32 %is_local_i, i32 %err) { |
| 42 ; get the base pointer to either the local or global array |
| 43 %local = alloca i8, i32 12, align 1 |
| 44 %global = bitcast [12 x i8]* @array to i8* |
| 45 %is_local = icmp ne i32 %is_local_i, 0 |
| 46 %arr = select i1 %is_local, i8* %local, i8* %global |
| 47 |
| 48 ; determine the offset to access |
| 49 %err_offset = mul i32 %err, 4 |
| 50 %pos_offset = add i32 %err_offset, 12 |
| 51 %pos = icmp sge i32 %err_offset, 0 |
| 52 %offset = select i1 %pos, i32 %pos_offset, i32 %err |
| 53 |
| 54 ; calculate the address to access |
| 55 %arraddr = ptrtoint i8* %arr to i32 |
| 56 %badaddr = add i32 %arraddr, %offset |
| 57 %badptr = inttoptr i32 %badaddr to i32* |
| 58 |
| 59 ; perform the bad access |
| 60 %result = load i32, i32* %badptr, align 1 |
| 61 ret i32 %result |
| 62 } |
| 63 |
| 64 ; use argc to determine which test routine to run |
| 65 define void @_start(i32 %arg) { |
| 66 %argcaddr = add i32 %arg, 8 |
| 67 %argcptr = inttoptr i32 %argcaddr to i32* |
| 68 %argc = load i32, i32* %argcptr, align 1 |
| 69 switch i32 %argc, label %error [i32 1, label %one_local |
| 70 i32 2, label %many_local |
| 71 i32 3, label %neg_local] |
| 72 one_local: |
| 73 ; Access one past the end |
| 74 %__0 = call i32 @access(i32 1, i32 0) |
| 75 br label %error |
| 76 many_local: |
| 77 ; Access five past the end |
| 78 %__1 = call i32 @access(i32 1, i32 4) |
| 79 br label %error |
| 80 neg_local: |
| 81 ; Access one before the beginning |
| 82 %__2 = call i32 @access(i32 1, i32 -1) |
| 83 br label %error |
| 84 error: |
| 85 call void @exit(i32 1) |
| 86 unreachable |
| 87 } |
| 88 |
| 89 ; CHECK: Illegal access of 4 bytes at |
| OLD | NEW |