-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic memory tests and introspection external functions
- Loading branch information
Showing
17 changed files
with
219 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
;; Reuse memory address chunk with different size | ||
(module | ||
(import "summaries" "alloc" (func $malloc (param i32 i32) (result i32))) | ||
(import "summaries" "dealloc" (func $free (param i32))) | ||
(import "symbolic" "assert" (func $assert (param i32))) | ||
(memory $m 1) | ||
(global $__heap_base (mut i32) (i32.const 0x00000000)) | ||
(func $start (local i32) | ||
global.get $__heap_base | ||
i32.const 0x00000004 | ||
call $malloc | ||
local.tee 0 | ||
i32.const 0x0000002a | ||
i32.store | ||
local.get 0 | ||
i32.load | ||
i32.const 0x0000002a | ||
i32.eq | ||
call $assert | ||
local.get 0 | ||
call $free | ||
global.get $__heap_base | ||
i32.const 0x00000008 | ||
call $malloc | ||
local.tee 0 | ||
i32.const 0x00000054 | ||
i32.store | ||
local.get 0 | ||
i32.load | ||
i32.const 0x00000054 | ||
i32.eq | ||
call $assert | ||
local.get 0 | ||
call $free) | ||
(start $start)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
;; Allocate multiple chunks and check that they don't overlap | ||
(module | ||
(import "summaries" "alloc" (func $malloc (param i32 i32) (result i32))) | ||
(import "summaries" "dealloc" (func $free (param i32))) | ||
(import "symbolic" "assert" (func $assert (param i32))) | ||
(memory $m 1) | ||
(global $__heap_base (mut i32) (i32.const 0x00000000)) | ||
(func $start (local i32 i32) | ||
global.get $__heap_base | ||
i32.const 0x00000004 | ||
call $malloc | ||
local.tee 0 | ||
global.get $__heap_base | ||
i32.const 0x00000004 | ||
i32.add | ||
i32.const 0x00000008 | ||
call $malloc | ||
local.tee 1 | ||
i32.const 0x0000000a | ||
i32.store | ||
i32.const 0x0000000b | ||
i32.store | ||
local.get 0 | ||
i32.load | ||
i32.const 0x0000000b | ||
i32.eq | ||
call $assert | ||
local.get 1 | ||
i32.load | ||
i32.const 0x0000000a | ||
i32.eq | ||
call $assert | ||
local.get 1 | ||
call $free | ||
local.get 0 | ||
call $free) | ||
(start $start)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
;; Allocate a memory chunk, store and load same address | ||
(module | ||
(import "summaries" "alloc" (func $malloc (param i32 i32) (result i32))) | ||
(import "summaries" "dealloc" (func $free (param i32))) | ||
(import "symbolic" "assert" (func $assert (param i32))) | ||
(memory $m 1) | ||
(global $__heap_base (mut i32) (i32.const 0x00000000)) | ||
(func $start (local i32) | ||
global.get $__heap_base | ||
i32.const 0x00000004 | ||
call $malloc | ||
local.tee 0 | ||
i32.const 0xdeadbeef | ||
i32.store | ||
local.get 0 | ||
i32.load | ||
i32.const 0xdeadbeef | ||
i32.eq | ||
call $assert | ||
local.get 0 | ||
call $free) | ||
(start $start)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
;; Dereference of a free'd pointer should not be allowed | ||
(module | ||
(import "summaries" "alloc" (func $malloc (param i32 i32) (result i32))) | ||
(import "summaries" "dealloc" (func $free (param i32))) | ||
(import "symbolic" "assert" (func $assert (param i32))) | ||
(memory $m 1) | ||
(global $__heap_base (mut i32) (i32.const 0x00000000)) | ||
(func $start (local i32) | ||
global.get $__heap_base | ||
i32.const 0x00000004 | ||
call $malloc | ||
local.tee 0 | ||
i32.const 0x0000002a | ||
i32.store | ||
local.get 0 | ||
call $free | ||
local.get 0 | ||
i32.load | ||
i32.const 0x0000002a | ||
i32.eq | ||
call $assert) | ||
(start $start)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(module | ||
(import "symbolic" "assert" (func $assert (param i32))) | ||
(memory $m 1) | ||
(func $start | ||
i32.const 0x00000000 | ||
i32.load | ||
i32.const 0x00000000 | ||
i32.eq | ||
call $assert) | ||
(start $start)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(module | ||
(memory $m 1) | ||
(func $start | ||
i32.const 0x0000fffc | ||
i32.const 0xbeefbabe | ||
i32.store) | ||
(start $start)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(module | ||
(import "symbolic" "i32_symbol" (func $i32_symbol (result i32))) | ||
(import "symbolic" "assume" (func $assume (param i32))) | ||
(import "symbolic" "assert" (func $assert (param i32))) | ||
(import "introspection" "dump_memory" (func $dump_memory)) | ||
(import "introspection" "print_i32" (func $print_i32 (param i32) (result i32))) | ||
(memory $m 1) | ||
(func $start | ||
i32.const 0x00000000 | ||
i32.const 0x50ffc001 | ||
i32.store | ||
i32.const 0x00000000 | ||
i32.load | ||
i32.const 0x50ffc001 | ||
i32.eq | ||
call $assert) | ||
(start $start)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
(module | ||
(memory $m 1) | ||
(func $start | ||
i32.const 0x00010000 | ||
i32.const 0xbaaaaaad | ||
i32.store) | ||
(start $start)) |