Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
dd19f8fd
Commit
dd19f8fd
authored
3 years ago
by
Basile Desloges
Browse files
Options
Downloads
Patches
Plain Diff
[eacsl] Generate memory model updates for libc functions
Manually update E-ACSL memory model when calling certain libc functions.
parent
6f55c89b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/e-acsl/src/code_generator/injector.ml
+17
-2
17 additions, 2 deletions
src/plugins/e-acsl/src/code_generator/injector.ml
with
17 additions
and
2 deletions
src/plugins/e-acsl/src/code_generator/injector.ml
+
17
−
2
View file @
dd19f8fd
...
@@ -88,7 +88,7 @@ let rec inject_in_init env kf_opt vi off = function
...
@@ -88,7 +88,7 @@ let rec inject_in_init env kf_opt vi off = function
in
in
CompoundInit
(
typ
,
List
.
rev
l
)
,
env
CompoundInit
(
typ
,
List
.
rev
l
)
,
env
let
inject_in_local_init
loc
env
kf
vi
=
function
let
inject_in_local_init
~
loc
~
stmt
env
kf
vi
=
function
|
ConsInit
(
fvi
,
sz
::
_
,
_
)
as
init
|
ConsInit
(
fvi
,
sz
::
_
,
_
)
as
init
when
Functions
.
Libc
.
is_vla_alloc_name
fvi
.
vname
->
when
Functions
.
Libc
.
is_vla_alloc_name
fvi
.
vname
->
(* add a store statement when creating a variable length array *)
(* add a store statement when creating a variable length array *)
...
@@ -99,6 +99,13 @@ let inject_in_local_init loc env kf vi = function
...
@@ -99,6 +99,13 @@ let inject_in_local_init loc env kf vi = function
|
ConsInit
(
caller
,
args
,
kind
)
->
|
ConsInit
(
caller
,
args
,
kind
)
->
let
args
,
env
=
replace_literal_strings_in_args
env
(
Some
kf
)
args
in
let
args
,
env
=
replace_literal_strings_in_args
env
(
Some
kf
)
args
in
let
caller
,
args
=
rename_caller
~
loc
caller
args
in
let
caller
,
args
=
rename_caller
~
loc
caller
args
in
let
_
,
env
=
if
Libc
.
is_writing_memory
caller
then
begin
let
result
=
Var
vi
,
NoOffset
in
Libc
.
update_memory_model
~
loc
~
stmt
env
kf
~
result
caller
args
end
else
None
,
env
in
ConsInit
(
caller
,
args
,
kind
)
,
env
ConsInit
(
caller
,
args
,
kind
)
,
env
|
AssignInit
init
->
|
AssignInit
init
->
...
@@ -153,6 +160,14 @@ let inject_in_instr env kf stmt = function
...
@@ -153,6 +160,14 @@ let inject_in_instr env kf stmt = function
Cil
.
evar
fvi
,
args
Cil
.
evar
fvi
,
args
|
_
->
caller
,
args
|
_
->
caller
,
args
in
in
(* if this is a call to a libc function that writes into a memory block then
manually update the memory model *)
let
result
,
env
=
match
caller
.
enode
with
|
Lval
(
Var
cvi
,
_
)
when
Libc
.
is_writing_memory
cvi
->
Libc
.
update_memory_model
~
loc
~
stmt
env
kf
?
result
cvi
args
|
_
->
result
,
env
in
(* add statement tracking initialization of return values *)
(* add statement tracking initialization of return values *)
let
env
=
let
env
=
match
result
with
match
result
with
...
@@ -177,7 +192,7 @@ let inject_in_instr env kf stmt = function
...
@@ -177,7 +192,7 @@ let inject_in_instr env kf stmt = function
|
Local_init
(
vi
,
linit
,
loc
)
->
|
Local_init
(
vi
,
linit
,
loc
)
->
let
lv
=
Var
vi
,
NoOffset
in
let
lv
=
Var
vi
,
NoOffset
in
let
env
=
add_initializer
loc
~
vi
lv
~
post
:
true
stmt
env
kf
in
let
env
=
add_initializer
loc
~
vi
lv
~
post
:
true
stmt
env
kf
in
let
linit
,
env
=
inject_in_local_init
loc
env
kf
vi
linit
in
let
linit
,
env
=
inject_in_local_init
~
loc
~
stmt
env
kf
vi
linit
in
Local_init
(
vi
,
linit
,
loc
)
,
env
Local_init
(
vi
,
linit
,
loc
)
,
env
(* nothing to do: *)
(* nothing to do: *)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment