Skip to content

Commit

Permalink
Merge pull request #712 from GaloisInc/x86-mutable-globals
Browse files Browse the repository at this point in the history
Support mutable globals during x86 verification
  • Loading branch information
chameco authored May 20, 2020
2 parents eeef9a1 + 0dc1246 commit 3f8566d
Show file tree
Hide file tree
Showing 5 changed files with 332 additions and 177 deletions.
15 changes: 15 additions & 0 deletions intTests/test_llvm_x86_04/test.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
section .bss
global var
var: resq 1
section .text
global addvar
addvar:
mov rax, [rdi]
mov rbx, var
add rax, 1
mov [rdi], rax
ret
global _start
_start:
mov rax, 60
syscall
12 changes: 12 additions & 0 deletions intTests/test_llvm_x86_04/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stdint.h>
#include <stdio.h>

extern uint64_t var;

extern void addvar(uint64_t *i);

void test() {
(void) var;
uint64_t i = 42;
addvar(&i);
};
19 changes: 19 additions & 0 deletions intTests/test_llvm_x86_04/test.saw
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
enable_experimental;

m <- llvm_load_module "test.bc";

let addvar_setup = do {
crucible_alloc_global "var";
var <- crucible_fresh_var "var" (llvm_int 64);
crucible_points_to (crucible_global "var") (crucible_term {{ 2 : [64] }});

ptr <- crucible_alloc (llvm_int 64);
val <- crucible_fresh_var "val" (llvm_int 64);
crucible_points_to ptr (crucible_term val);

crucible_execute_func [ptr];

valprime <- crucible_fresh_var "_val" (llvm_int 64);
crucible_points_to ptr (crucible_term valprime);
};
crucible_llvm_verify_x86 m "./test" "addvar" [] false addvar_setup;
6 changes: 6 additions & 0 deletions intTests/test_llvm_x86_04/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
set -e

yasm -felf64 test.S
ld test.o -o test
clang -c -emit-llvm test.c
$SAW test.saw
Loading

0 comments on commit 3f8566d

Please sign in to comment.