A symbolic executor for the QBE intermediate language
git clone https://git.8pit.net/qsym.git
1## Symbolic execution for the QBE IL 2 3qsym is a [symbolic execution][symex wikipedia] tool for the [QBE][qbe web] intermediate language. 4The tool leverages [Z3][z3 web] to execute QBE IL based on [SMT bitvectors][smt wikipedia]. 5This enables qsym to reason about conditional jumps in the QBE IL, exploring both branches (if feasible under the current constraints). 6 7### Status 8 9qsym is in very early stages of development and presently mostly a proof-of-concept.10The underlying parser for the QBE IL ([qbe-reader][qbe-reader github]) is also not yet complete, hence it does not support every syntactically valid QBE IL input yet.11Furthermore, it is assumed that input programs are well typed, e.g. no type checks are performed for instruction arguments.12Simple programs generated using a QBE frontend (e.g. [cproc][cproc repo]) can already be explored.1314### Installation1516Clone the repository and run the following command:1718 $ cargo install --path .1920### Usage Example2122Presently, qsym treats the parameters of a selected function as unconstrained symbolic and executes this function.23Consider the following example:2425 $ cat input.qbe26 function w $main(w %a) {27 @start28 %a =w add 0, %a29 jnz %a, @end1, @end230 @end131 %exit =w add 0, 132 hlt33 @end234 %exit =w add 0, 235 hlt36 }37 $ qsym input.qbe main38 [jnz] Exploring path for label 'end1'39 Halting executing40 Local variables:41 a = |main:a|42 exit = #x0000000143 Symbolic variable values:44 main:a -> #x000000024546 [jnz] Exploring path for label 'end2'47 Halting executing48 Local variables:49 a = |main:a|50 exit = #x0000000251 Symbolic variable values:52 main:a -> #x000000005354For the provided example program, qsym discovers two possible execution paths through the function `main`.55In the first execution path the symbolic variable `%a` is zero, in the other it is non-zero.5657### License5859This program is free software: you can redistribute it and/or modify it60under the terms of the GNU Affero General Public License as published by61the Free Software Foundation, either version 3 of the License, or (at62your option) any later version.6364This program is distributed in the hope that it will be useful, but65WITHOUT ANY WARRANTY; without even the implied warranty of66MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero67General Public License for more details.6869You should have received a copy of the GNU Affero General Public License70along with this program. If not, see <https://www.gnu.org/licenses/>.7172[qbe web]: https://c9x.me/compile/73[symex wikipedia]: https://en.wikipedia.org/wiki/Symbolic_execution74[z3 web]: https://github.com/Z3Prover/z375[smt wikipedia]: https://en.wikipedia.org/wiki/Satisfiability_modulo_theories76[qbe-reader github]: https://github.com/nmeum/qbe-reader77[cproc repo]: https://sr.ht/~mcf/cproc