Compositional Symbolic Execution Combinators for Low-level Languages
Constructing sound compositional symbolic execution (CSE) engines for low-level languages is challenging: features such as machine integer representation and undefined values must be handled with precision and efficiency, and all of this must be implemented soundly with respect to the semantics of the underlying low-level language. Moreover, compositional reasoning should also be supported, both in the overapproximate (OX) style, for specification verification, and the underapproximate (UX) style, for bug-finding via specification synthesis using bi-abduction.
We identify the Gillian-C memory model as a good starting point for symbolic memory models for low-level languages. Based on the CompCert C memory model, Gillian-C’s symbolic memory model uses a complex tree-based structure, the block-tree model, tailored towards optimising symbolic execution performance, and enables support for both OX and UX analyses. However, the gigantic, monolithic design makes extension and modification based on requirements for other low-level languages awkward. Furthermore, the model exists only as unverified OCaml code, so it cannot be formally linked to any mechanised language semantics.
For the first time, we provide a description of the block-tree model and justify its soundness by formalising the internal data structures in Rocq as a combinator library, allowing straightforward, proof-preserving instantiation of low-level memory models and adding or removing features as needed. Using this, we create two combinator stacks based on CompCert C, one supporting OX and the other UX, and we formally prove a two-way simulation relation between their shared concrete memory model and that of CompCert, giving the first formal link between Gillian-C’s Rocq-formalised OX and UX symbolic memory models and CompCert’s semantics. For ongoing work, we are extending the combinator library to support features beyond C; in particular, CHERI capabilities and poison values from LLVM.