Skip to content

Commit 460c5b0

Browse files
committed
CHB: allow for address roll-over in simplification of preconditions
1 parent efb71d7 commit 460c5b0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

CodeHawk/CHB/bchlib/bCHCallSemanticsRecorder.ml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ object (self)
9999
| XPONotNull x ->
100100
(match x with
101101
| XConst (IntConst n) when n#gt numerical_zero ->
102+
let n = n#modulo numerical_e32 in
102103
Discharged
103104
("non-null constant address: "
104105
^ TR.tget_ok (numerical_to_hex_string n))
@@ -109,7 +110,7 @@ object (self)
109110
| XPONullTerminated x ->
110111
(match x with
111112
| XConst (IntConst n) ->
112-
let dw = TR.tget_ok (numerical_to_doubleword n) in
113+
let dw = numerical_mod_to_doubleword n in
113114
if string_table#has_string dw then
114115
Discharged ("constant string: " ^ (string_table#get_string dw))
115116
else
@@ -119,7 +120,7 @@ object (self)
119120
(match (ptr, size) with
120121
| (XConst (IntConst n1), XOp ((Xf "ntpos"), [XConst (IntConst n2)]))
121122
when n1#equal n2 ->
122-
let dw = TR.tget_ok (numerical_to_doubleword n1) in
123+
let dw = numerical_mod_to_doubleword n1 in
123124
if string_table#has_string dw then
124125
Discharged ("constant string: " ^ (string_table#get_string dw))
125126
else
@@ -129,7 +130,7 @@ object (self)
129130
(match (ptr, size) with
130131
| (XConst (IntConst n1), XOp ((Xf "ntpos"), [XConst (IntConst n2)]))
131132
when n1#equal n2 ->
132-
let dw = TR.tget_ok (numerical_to_doubleword n1) in
133+
let dw = numerical_mod_to_doubleword n1 in
133134
if string_table#has_string dw then
134135
Discharged ("constant string: " ^ (string_table#get_string dw))
135136
else
@@ -138,7 +139,7 @@ object (self)
138139
| XPOOutputFormatString x ->
139140
(match x with
140141
| XConst (IntConst n) ->
141-
let dw = TR.tget_ok (numerical_to_doubleword n) in
142+
let dw = numerical_mod_to_doubleword n in
142143
if string_table#has_string dw then
143144
Discharged ("constant string: " ^ (string_table#get_string dw))
144145
else
@@ -170,22 +171,22 @@ object (self)
170171
let x = simplify_xpr x in
171172
(match self#xprxt#xpr_to_bterm t_voidptr x with
172173
| Some (NumConstant n) when n#gt numerical_zero ->
173-
let dw = TR.tget_ok (numerical_to_doubleword n) in
174+
let dw = numerical_mod_to_doubleword n in
174175
DelegatedGlobal (dw, XXNotNull (NumConstant n))
175176
| Some t -> Delegated (XXNotNull t)
176177
| _ -> Open)
177178
| XPONullTerminated x ->
178179
let x = simplify_xpr x in
179180
(match self#xprxt#xpr_to_bterm t_voidptr x with
180181
| Some (NumConstant n) when n#gt numerical_zero ->
181-
let dw = TR.tget_ok (numerical_to_doubleword n) in
182+
let dw = numerical_mod_to_doubleword n in
182183
DelegatedGlobal (dw, XXNullTerminated (NumConstant n))
183184
| Some t -> Delegated (XXNullTerminated t)
184185
| _ -> Open)
185186
| XPOBlockWrite (ty, ptr, size) ->
186187
(match self#xprxt#xpr_to_bterm t_voidptr ptr with
187188
| Some (NumConstant n) when n#gt numerical_zero ->
188-
let dw = TR.tget_ok (numerical_to_doubleword n) in
189+
let dw = numerical_mod_to_doubleword n in
189190
(match self#xprxt#xpr_to_bterm t_int size with
190191
| Some (NumConstant ns) ->
191192
DelegatedGlobal
@@ -200,7 +201,7 @@ object (self)
200201
| XPOBuffer (ty, ptr, size) ->
201202
(match self#xprxt#xpr_to_bterm t_voidptr ptr with
202203
| Some (NumConstant n) when n#gt numerical_zero ->
203-
let dw = TR.tget_ok (numerical_to_doubleword n) in
204+
let dw = numerical_mod_to_doubleword n in
204205
(match self#xprxt#xpr_to_bterm t_int size with
205206
| Some (NumConstant ns) ->
206207
DelegatedGlobal
@@ -215,7 +216,7 @@ object (self)
215216
| XPOInitializedRange (ty, ptr, size) ->
216217
(match self#xprxt#xpr_to_bterm t_voidptr ptr with
217218
| Some (NumConstant n) when n#gt numerical_zero ->
218-
let dw = TR.tget_ok (numerical_to_doubleword n) in
219+
let dw = numerical_mod_to_doubleword n in
219220
(match self#xprxt#xpr_to_bterm t_int size with
220221
| Some (NumConstant ns) ->
221222
DelegatedGlobal

0 commit comments

Comments
 (0)