Skip to content
Snippets Groups Projects
Commit 599194b9 authored by Henrik Tjäder's avatar Henrik Tjäder
Browse files

Merge branch 'klee' of gitlab.henriktjader.com:KLEE/cortex-m-rtfm-klee into klee

parents 2791081e 28b88b09
Branches
Tags
No related merge requests found
...@@ -28,6 +28,7 @@ rustflags = [ ...@@ -28,6 +28,7 @@ rustflags = [
"-C", "link-arg=-Tlink.x", "-C", "link-arg=-Tlink.x",
"-C", "linker=arm-none-eabi-ld", "-C", "linker=arm-none-eabi-ld",
"-Z", "linker-flavor=ld", "-Z", "linker-flavor=ld",
"-Z", "thinlto=no",
] ]
# used when building for klee # used when building for klee
...@@ -35,7 +36,8 @@ rustflags = [ ...@@ -35,7 +36,8 @@ rustflags = [
[target.x86_64-unknown-linux-gnu] [target.x86_64-unknown-linux-gnu]
rustflags = [ rustflags = [
"--emit=llvm-bc,llvm-ir", "--emit=llvm-bc,llvm-ir",
"-C", "linker=true" "-C", "linker=true",
"-Z", "thinlto=no",
] ]
# default build target (for m3) # default build target (for m3)
......
...@@ -7,7 +7,7 @@ extern crate cstr_core; ...@@ -7,7 +7,7 @@ extern crate cstr_core;
extern crate cty; extern crate cty;
// mod lang_items; // mod lang_items;
mod ll; pub mod ll;
use core::mem; use core::mem;
...@@ -42,7 +42,7 @@ pub fn k_mk_symbol<T>(t: &mut T, name: &CStr) { ...@@ -42,7 +42,7 @@ pub fn k_mk_symbol<T>(t: &mut T, name: &CStr) {
} }
} }
#[inline(never)] #[inline(always)]
pub fn k_abort() -> ! { pub fn k_abort() -> ! {
unsafe { unsafe {
ll::abort(); ll::abort();
...@@ -50,7 +50,7 @@ pub fn k_abort() -> ! { ...@@ -50,7 +50,7 @@ pub fn k_abort() -> ! {
} }
/// assume a condition involving symbolic variables /// assume a condition involving symbolic variables
#[inline(never)] #[inline(always)]
pub fn k_assume(cond: bool) { pub fn k_assume(cond: bool) {
unsafe { unsafe {
ll::klee_assume(cond); ll::klee_assume(cond);
...@@ -58,10 +58,12 @@ pub fn k_assume(cond: bool) { ...@@ -58,10 +58,12 @@ pub fn k_assume(cond: bool) {
} }
/// assert a condition involving symbolic variables /// assert a condition involving symbolic variables
#[inline(never)] #[inline(always)]
pub fn k_assert(e: bool) { pub fn k_assert(e: bool) {
if !e { if !e {
k_abort(); unsafe {
ll::abort();
}
} }
} }
...@@ -80,6 +82,21 @@ macro_rules! k_symbol { ...@@ -80,6 +82,21 @@ macro_rules! k_symbol {
} }
} }
/// assertion
#[macro_export]
macro_rules! k_assert {
($e: expr) => {
{
use klee::ll;
if !$e {
unsafe {
ll::abort();
}
}
}
}
}
#[macro_export] #[macro_export]
macro_rules! k_visit { macro_rules! k_visit {
()=> { ()=> {
......
...@@ -8,12 +8,15 @@ extern "C" { ...@@ -8,12 +8,15 @@ extern "C" {
} }
#[cfg(not(feature = "klee_mode"))] #[cfg(not(feature = "klee_mode"))]
#[inline(always)]
pub unsafe fn abort() -> ! { pub unsafe fn abort() -> ! {
loop {} loop {}
} }
#[cfg(not(feature = "klee_mode"))] #[cfg(not(feature = "klee_mode"))]
#[inline(always)]
pub unsafe fn klee_assume(_cond: bool) {} pub unsafe fn klee_assume(_cond: bool) {}
#[cfg(not(feature = "klee_mode"))] #[cfg(not(feature = "klee_mode"))]
#[inline(always)]
pub unsafe fn klee_make_symbolic(_ptr: *mut c_void, _size: usize, _name: *const c_char) {} pub unsafe fn klee_make_symbolic(_ptr: *mut c_void, _size: usize, _name: *const c_char) {}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment