File tree 12 files changed +142
-0
lines changed
goto-cc-cbmc-shared-options
12 files changed +142
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,9 @@ most important architectural parameters are:
112
112
` sizeof(long int) ` on various machines.
113
113
- The width of pointers; for example, compare the value of ` sizeof(int *) ` on
114
114
various machines.
115
+ - The number of bits in a pointer which are used to differentiate between
116
+ different objects. The remaining bits of a pointer are used for offsets
117
+ within objects.
115
118
- The [ endianness] ( http://en.wikipedia.org/wiki/Endianness ) of
116
119
the architecture.
117
120
@@ -129,6 +132,8 @@ following command-line arguments can be passed to the CPROVER tools:
129
132
- The word-width can be set with ` --16 ` , ` --32 ` , ` --64 ` .
130
133
- The endianness can be defined with ` --little-endian ` and
131
134
` --big-endian ` .
135
+ - The number of bits in a pointer used to differentiate between different
136
+ objects can be set using ` --object-bits x ` . Where ` x ` is the number of bits.
132
137
133
138
When using a goto binary, CBMC and the other tools read the
134
139
configuration from the binary. The setting when running goto-cc is
Original file line number Diff line number Diff line change 47
47
add_subdirectory (goto-cl)
48
48
endif ()
49
49
add_subdirectory (goto-cc-cbmc)
50
+ add_subdirectory (goto-cc-cbmc-shared-options )
50
51
add_subdirectory (cbmc-cpp)
51
52
add_subdirectory (goto-cc-goto-analyzer)
52
53
add_subdirectory (statement-list)
Original file line number Diff line number Diff line change
1
+ if (WIN32 )
2
+ set (is_windows true )
3
+ else ()
4
+ set (is_windows false )
5
+ endif ()
6
+
7
+ add_test_pl_tests(
8
+ "${CMAKE_CURRENT_SOURCE_DIR} /chain.sh $<TARGET_FILE:goto-cc> $<TARGET_FILE:cbmc> ${is_windows} "
9
+ )
Original file line number Diff line number Diff line change
1
+ default : tests.log
2
+
3
+ include ../../src/config.inc
4
+ include ../../src/common
5
+
6
+ ifeq ($(BUILD_ENV_ ) ,MSVC)
7
+ exe=../../../src/goto-cc/goto-cl
8
+ is_windows=true
9
+ else
10
+ exe=../../../src/goto-cc/goto-cc
11
+ is_windows=false
12
+ endif
13
+
14
+ test :
15
+ @../test.pl -e -p -c ' ../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)'
16
+
17
+ tests.log :
18
+ @../test.pl -e -p -c ' ../chain.sh $(exe) ../../../src/cbmc/cbmc $(is_windows)'
19
+
20
+ show :
21
+ @for dir in * ; do \
22
+ if [ -d " $$ dir" ]; then \
23
+ vim -o " $$ dir/*.c" " $$ dir/*.out" ; \
24
+ fi ; \
25
+ done ;
26
+
27
+ clean :
28
+ @for dir in * ; do \
29
+ $(RM ) tests.log; \
30
+ if [ -d " $$ dir" ]; then \
31
+ cd " $$ dir" ; \
32
+ $(RM ) * .out * .gb; \
33
+ cd ..; \
34
+ fi \
35
+ done
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ goto_cc=$1
4
+ cbmc=$2
5
+ is_windows=$3
6
+
7
+ options=${*: 4: $# -4}
8
+ name=${*: $# }
9
+ base_name=${name% .c}
10
+ base_name=${base_name% .cpp}
11
+
12
+ if [[ " ${is_windows} " == " true" ]]; then
13
+ " ${goto_cc} " " ${name} " ${options}
14
+ mv " ${base_name} .exe" " ${base_name} .gb"
15
+ else
16
+ " ${goto_cc} " " ${name} " -o " ${base_name} .gb" ${options}
17
+ fi
18
+
19
+ " ${cbmc} " " ${base_name} .gb" ${options}
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+ --function main
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ assertion object_bits != 6: SUCCESS
8
+ assertion object_bits != 8: FAILURE
9
+ assertion object_bits != 10: SUCCESS
10
+ --
11
+ ^warning: ignoring
12
+ --
13
+ Test that the default value for object-bits is 8.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+ --function main --object-bits 6
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ assertion object_bits != 6: FAILURE
8
+ assertion object_bits != 8: SUCCESS
9
+ assertion object_bits != 10: SUCCESS
10
+ --
11
+ ^warning: ignoring
12
+ --
13
+ Test test running with fewer bits than usual results in correct setup of
14
+ intrinsic constants.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ test.c
3
+ --function main --object-bits 10
4
+ ^EXIT=10$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION FAILED$
7
+ assertion object_bits != 6: SUCCESS
8
+ assertion object_bits != 8: SUCCESS
9
+ assertion object_bits != 10: FAILURE
10
+ --
11
+ ^warning: ignoring
12
+ --
13
+ Test test running with more bits than usual results in correct setup of
14
+ intrinsic constants.
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ size_t
5
+ find_first_set (const size_t max_malloc_size , const size_t bits_accumulator )
6
+ {
7
+ if (max_malloc_size & 1 )
8
+ return bits_accumulator ;
9
+ return find_first_set (max_malloc_size >> 1 , bits_accumulator + 1 );
10
+ }
11
+
12
+ size_t calculate_object_bits ()
13
+ {
14
+ const size_t ptr_size = sizeof (void * ) * 8 ;
15
+ return ptr_size - find_first_set (__CPROVER_max_malloc_size , 1 );
16
+ }
17
+
18
+ int main ()
19
+ {
20
+ void * temp = malloc (2 );
21
+ size_t object_bits = calculate_object_bits ();
22
+ assert (object_bits != 6 );
23
+ assert (object_bits != 8 );
24
+ assert (object_bits != 10 );
25
+ __CPROVER_assume ("end of main." );
26
+ }
Original file line number Diff line number Diff line change
1
+ This directory is for tests where we -
2
+ 1 ) Run ` goto-cc ` on the specified input file, with the specified options.
3
+ 2 ) Run ` cbmc ` on the goto binary produced in step 1. Using the same options
4
+ from the ` .desc ` file as were specified in step 1.
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ const char *goto_cc_options_with_separated_argument[]=
28
28
" --native-linker" ,
29
29
" --print-rejected-preprocessed-source" ,
30
30
" --mangle-suffix" ,
31
+ " --object-bits" ,
31
32
nullptr
32
33
};
33
34
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ void goto_cc_modet::help()
66
66
" --native-assembler cmd command to invoke as assembler (goto-as only)\n "
67
67
" --print-rejected-preprocessed-source file\n "
68
68
" copy failing (preprocessed) source to file\n "
69
+ " --object-bits number of bits used for object addresses\n "
69
70
" \n " ;
70
71
// clang-format on
71
72
}
You can’t perform that action at this time.
0 commit comments