Skip to content

Commit 3f8566d

Browse files
authored
Merge pull request #712 from GaloisInc/x86-mutable-globals
Support mutable globals during x86 verification
2 parents eeef9a1 + 0dc1246 commit 3f8566d

File tree

5 files changed

+332
-177
lines changed

5 files changed

+332
-177
lines changed

intTests/test_llvm_x86_04/test.S

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
section .bss
2+
global var
3+
var: resq 1
4+
section .text
5+
global addvar
6+
addvar:
7+
mov rax, [rdi]
8+
mov rbx, var
9+
add rax, 1
10+
mov [rdi], rax
11+
ret
12+
global _start
13+
_start:
14+
mov rax, 60
15+
syscall

intTests/test_llvm_x86_04/test.c

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <stdint.h>
2+
#include <stdio.h>
3+
4+
extern uint64_t var;
5+
6+
extern void addvar(uint64_t *i);
7+
8+
void test() {
9+
(void) var;
10+
uint64_t i = 42;
11+
addvar(&i);
12+
};

intTests/test_llvm_x86_04/test.saw

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
enable_experimental;
2+
3+
m <- llvm_load_module "test.bc";
4+
5+
let addvar_setup = do {
6+
crucible_alloc_global "var";
7+
var <- crucible_fresh_var "var" (llvm_int 64);
8+
crucible_points_to (crucible_global "var") (crucible_term {{ 2 : [64] }});
9+
10+
ptr <- crucible_alloc (llvm_int 64);
11+
val <- crucible_fresh_var "val" (llvm_int 64);
12+
crucible_points_to ptr (crucible_term val);
13+
14+
crucible_execute_func [ptr];
15+
16+
valprime <- crucible_fresh_var "_val" (llvm_int 64);
17+
crucible_points_to ptr (crucible_term valprime);
18+
};
19+
crucible_llvm_verify_x86 m "./test" "addvar" [] false addvar_setup;

intTests/test_llvm_x86_04/test.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
set -e
2+
3+
yasm -felf64 test.S
4+
ld test.o -o test
5+
clang -c -emit-llvm test.c
6+
$SAW test.saw

0 commit comments

Comments
 (0)