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

symbolic: Deduplicate mkInitialRegVal across projects #432

Open
langston-barrett opened this issue Aug 30, 2024 · 2 comments
Open

symbolic: Deduplicate mkInitialRegVal across projects #432

langston-barrett opened this issue Aug 30, 2024 · 2 comments
Labels
symbolic-execution Issues relating to macaw-symbolic and symbolic execution

Comments

@langston-barrett
Copy link
Contributor

Apparently, it's common to make an initial struct of completely symbolic registers:

mkInitialRegVal :: (CB.IsSymInterface sym, MT.HasRepr (MC.ArchReg arch) MT.TypeRepr)

https://github.com/GaloisInc/pate/blob/c43542818be7780264d8a2552bfeba1cffba2902/src/Pate/Verification/InlineCallee.hs#L88

https://github.com/GaloisInc/ambient-verifier/blob/eab04abb9750825a25ec0cbe0379add63f05f6c6/src/Ambient/Verifier/SymbolicExecution.hs#L172

https://github.com/GaloisInc/saw-script/blob/47a7632c973df3fdb2d32268edc92948fc150f2d/src/SAWScript/X86Spec.hs#L453

We should probably export this kind of functionality from macaw-symbolic, to prevent reinventing the wheel. Ideally, this could have some sort of tie-in with the solution to #430, such that the initial register state is reasonably suitable for executing actual machine code.

This does kind of toe the line of what should be included in macaw-symbolic. Certainly, one can imagine clients that would not want to set all registers to fully symbolic values. However, it appears to be relatively common in practice. I think it's not unreasonable to include helpers for setting macaw-symbolic up "in the normal way", and allow clients with more specific needs to use lower-level APIs to achieve what they want. We could also consider collecting this sort of functionality in a separate library, so that not every dependency would have to pay the price of additional compile time.

@langston-barrett langston-barrett added the symbolic-execution Issues relating to macaw-symbolic and symbolic execution label Aug 30, 2024
@langston-barrett
Copy link
Contributor Author

See also freshValue in macaw-x86-symbolic:

@RyanGlScott
Copy link
Contributor

And for even more prior art, see freshCrucibleConstant in macaw-symbolic:

-- | Create a fresh Crucible constant based on the supplied Macaw 'M.TypeRepr'.
freshCrucibleConstant ::
forall sym tp.
IsSymInterface sym =>
sym ->
SolverSymbol ->
M.TypeRepr tp ->
IO (C.RegValue sym (ToCrucibleType tp))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
symbolic-execution Issues relating to macaw-symbolic and symbolic execution
Projects
None yet
Development

No branches or pull requests

2 participants