Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prove a static (file scope) function using the starter kit? #199

Open
rod-chapman opened this issue Jun 8, 2023 · 4 comments
Open
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@rod-chapman
Copy link

I have a translation unit in f.h and f.c, all set up for proof using contracts and the starter kit.

f.c contains a static (file scope) function that I want to prove. How do I get that to work with the starter kit, which seems to insist on putting my test harness function in a separate translation unit, so the function I want to prove is not visible from the point of view of the harness?

@feliperodri mentioned that static functions get name-mangled by CBMC... is there some trick here that I'm not aware of? Where is this documented?

@remi-delmas-3000 remi-delmas-3000 added the documentation Improvements or additions to documentation label Jun 14, 2023
@remi-delmas-3000
Copy link
Contributor

By default static symbols are exported with a prefix __CPROVER_file_local + filename + symbol_name:

For instance:

// in file bar.c
static int foo(int)
{
   ...
}

can be referred to as __CPROVER_file_local_bar_c_foo in the proof harness.

Another way is to activate the crangler rewriting pass in the proof Makefile as explained here in Makefile.common

@rod-chapman
Copy link
Author

Where is that name-mangling documented? I couldn't find it in the user manual...

@remi-delmas-3000
Copy link
Contributor

@rod-chapman
Copy link
Author

rod-chapman commented Jun 14, 2023

That info (and an example of how to do it) really needs to be in here somwhere: https://diffblue.github.io/cbmc/user_guide.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants