about summary refs log tree commit diff homepage
path: root/test/Feature
diff options
context:
space:
mode:
authorDan Liew <daniel.liew@imperial.ac.uk>2015-10-17 18:32:19 +0100
committerDan Liew <daniel.liew@imperial.ac.uk>2015-10-17 18:46:34 +0100
commit2a7c7f81a70f1266cf67471861bffc8f2192ce18 (patch)
tree10b1702040e82d859cde6fffa460244ea6b627df /test/Feature
parent50b9e95064a8a312c365fda57ed5729cd91706ba (diff)
downloadklee-2a7c7f81a70f1266cf67471861bffc8f2192ce18.tar.gz
Implement gross hack to make it possible to execute code compiled
with -m32 (i.e. for i386). Previously if this was attempt allocations
in the program being executed by KLEE would hit an assertion because
malloc() would return an address that doesn't fit in a 32-bit pointer.

The interface of MemoryManager has been changed so that it is necessary
to specify the pointer size on creation. The implementation has been
changed to use a MASSIVE HACK when the pointer width is less than
64-bits.
Diffstat (limited to 'test/Feature')
-rw-r--r--test/Feature/32BitAlloc.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Feature/32BitAlloc.c b/test/Feature/32BitAlloc.c
new file mode 100644
index 00000000..311dc239
--- /dev/null
+++ b/test/Feature/32BitAlloc.c
@@ -0,0 +1,15 @@
+// RUN: %llvmgcc %s -emit-llvm -m32 -O0 -c -o %t1.bc
+// RUN: rm -rf %t.klee-out
+// RUN: %klee --output-dir=%t.klee-out %t1.bc
+
+// This simply tests that allocation works when
+// running 32-bit code
+
+// FIXME: This test only needs to run on x86_64
+int main() {
+  int a[100000];
+  for (int i=0; i < 5000; ++i) {
+    a[i] = i;
+  }
+  return 0;
+}