Skip to content

Commit 54d4857

Browse files
committed
Encode integer addresses together with pointer object/offset
Instead of encoding pointers with the same bit width a pointer on a given platform has, just widen the bit-blasted encoding to include both the previous object/offset encoding as well as an (integer) address. The encoding is thus also trivially be extended to handle larger numbers of objects and offsets of the same width as the address. Furthermore clean up the code to encapsulate encoding properly, and make in-code layout of pointer encoding more natural (it's now object, offset, integer-address). Fixes: diffblue#436 Fixes: diffblue#311 Fixes: diffblue#94
1 parent 43b1e3c commit 54d4857

File tree

13 files changed

+565
-141
lines changed

13 files changed

+565
-141
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
THOROUGH
22
main.c
33
--32 --little-endian
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
^warning: ignoring
9+
--
10+
Takes around 2 minutes to run.

regression/cbmc/Pointer_Arithmetic13/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#define MB 0x00100000
2+
#define BASE (15*MB)
3+
#define OFFSET ( 1*MB)
4+
5+
main() {
6+
char val[4];
7+
char *base = BASE;
8+
int offset = OFFSET;
9+
int n = 2;
10+
__CPROVER_assert(&((char*)base)[offset]!=0, "no wrap-around expected");
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--32
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdlib.h>
2+
3+
int main()
4+
{
5+
if(sizeof(void*)!=8)
6+
return 0;
7+
8+
char* p=malloc(1);
9+
if(p==0)
10+
return 0;
11+
12+
unsigned long x=0xFFFFFFFF;
13+
if((unsigned long)p > x) // unsoundly evaluates to true due to pointer encoding
14+
return 0;
15+
16+
__CPROVER_assert(0, "");
17+
18+
return 0;
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring

regression/cbmc/address_space_size_limit1/test.c

Lines changed: 0 additions & 16 deletions
This file was deleted.

regression/cbmc/address_space_size_limit1/test.desc

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/solvers/flattening/boolbv_width.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const
195195
}
196196
else if(type_id==ID_pointer)
197197
{
198-
entry.total_width=to_pointer_type(type).get_width();
198+
entry.total_width=3*to_pointer_type(type).get_width();
199199
DATA_INVARIANT(entry.total_width!=0, "pointer must have width");
200200
}
201201
else if(type_id==ID_symbol)

0 commit comments

Comments
 (0)