diff --git a/src/main/scala/bap/BAPStatement.scala b/src/main/scala/bap/BAPStatement.scala index 9a102e4ef..24f7541fe 100644 --- a/src/main/scala/bap/BAPStatement.scala +++ b/src/main/scala/bap/BAPStatement.scala @@ -32,7 +32,7 @@ trait BAPAssign(lhs: BAPVariable, rhs: BAPExpr, line: String, instruction: Strin /** Memory store */ -case class BAPMemAssign(lhs: BAPMemory, rhs: BAPStore, line: String, instruction: String) +case class BAPMemAssign(lhs: BAPMemory, rhs: BAPStore, line: String, instruction: String, address: Option[Int] = None) extends BAPAssign(lhs, rhs, line, instruction) /* @@ -47,5 +47,5 @@ case object BAPMemAssign { } */ -case class BAPLocalAssign(lhs: BAPVar, rhs: BAPExpr, line: String, instruction: String) +case class BAPLocalAssign(lhs: BAPVar, rhs: BAPExpr, line: String, instruction: String, address: Option[Int] = None) extends BAPAssign(lhs, rhs, line, instruction) diff --git a/src/main/scala/boogie/BAttribute.scala b/src/main/scala/boogie/BAttribute.scala new file mode 100644 index 000000000..feb1c3243 --- /dev/null +++ b/src/main/scala/boogie/BAttribute.scala @@ -0,0 +1,16 @@ +package boogie + +trait HasAttributes { + def attributes: List[BAttribute] + + val attrString: String = if attributes.nonEmpty then { + attributes.mkString(" ") + " " + } else { + "" + } +} + +case class BAttribute(name: String, value: Option[String] = None) { + private val valueStr = if value.nonEmpty then s" ${value.get}" else "" + override def toString: String = s"{:$name$valueStr}" +} \ No newline at end of file diff --git a/src/main/scala/boogie/BCmd.scala b/src/main/scala/boogie/BCmd.scala index 4c48fe30a..fdd088303 100644 --- a/src/main/scala/boogie/BCmd.scala +++ b/src/main/scala/boogie/BCmd.scala @@ -17,23 +17,25 @@ case class BBlock(label: String, body: List[BCmd]) extends BCmdOrBlock { override def globals: Set[BVar] = body.flatMap(c => c.globals).toSet } -sealed trait BCmd extends BCmdOrBlock { +sealed trait BCmd() extends BCmdOrBlock with HasAttributes { + override def attributes: List[BAttribute] = List() def comment: Option[String] + override def toBoogie: List[String] = { val commentOut = comment.map(" //" + _).getOrElse("") List(toString + commentOut) } } -case class BAssert(body: BExpr, comment: Option[String] = None) extends BCmd { - override def toString: String = s"assert $body;" +case class BAssert(body: BExpr, comment: Option[String] = None, override val attributes: List[BAttribute] = List.empty) extends BCmd { + override def toString: String = s"assert $attrString$body;" override def functionOps: Set[FunctionOp] = body.functionOps override def locals: Set[BVar] = body.locals override def globals: Set[BVar] = body.globals } -case class BAssume(body: BExpr, comment: Option[String] = None) extends BCmd { - override def toString: String = s"assume $body;" +case class BAssume(body: BExpr, comment: Option[String] = None, override val attributes: List[BAttribute] = List.empty) extends BCmd { + override def toString: String = s"assume $attrString$body;" override def functionOps: Set[FunctionOp] = body.functionOps override def locals: Set[BVar] = body.locals override def globals: Set[BVar] = body.globals @@ -42,9 +44,9 @@ case class BAssume(body: BExpr, comment: Option[String] = None) extends BCmd { case class BProcedureCall(name: String, lhss: Seq[BVar], params: Seq[BExpr], comment: Option[String] = None) extends BCmd { override def toString: String = { if (lhss.isEmpty) { - s"call $name();" + s"call $attrString$name();" } else { - s"call ${lhss.mkString(", ")} := $name(${params.mkString(", ")});" + s"call $attrString${lhss.mkString(", ")} := $name(${params.mkString(", ")});" } } override def functionOps: Set[FunctionOp] = params.flatMap(p => p.functionOps).toSet diff --git a/src/main/scala/boogie/BExpr.scala b/src/main/scala/boogie/BExpr.scala index 1962ea3b3..804081926 100644 --- a/src/main/scala/boogie/BExpr.scala +++ b/src/main/scala/boogie/BExpr.scala @@ -443,7 +443,10 @@ case class MapUpdate(map: BExpr, index: BExpr, value: BExpr) extends BExpr { sealed trait FunctionOp -case class BVFunctionOp(name: String, bvbuiltin: String, in: List[BVar], out: BVar) extends FunctionOp +case class BVFunctionOp(name: String, bvbuiltin: String, in: List[BVar], out: BVar) extends FunctionOp { + def attribute: BAttribute = BAttribute("bvbuiltin", Some(s"\"$bvbuiltin\"")) +} + case class MemoryLoadOp(addressSize: Int, valueSize: Int, endian: Endian, bits: Int) extends FunctionOp { val accesses: Int = bits / valueSize diff --git a/src/main/scala/boogie/BProgram.scala b/src/main/scala/boogie/BProgram.scala index 98312ff32..1c5974488 100644 --- a/src/main/scala/boogie/BProgram.scala +++ b/src/main/scala/boogie/BProgram.scala @@ -4,7 +4,8 @@ case class BProgram(declarations: List[BDeclaration]) { override def toString: String = declarations.flatMap(x => x.toBoogie).mkString("\n") } -trait BDeclaration { +trait BDeclaration extends HasAttributes { + override def attributes: List[BAttribute] = List() def toBoogie: List[String] = List(toString) } @@ -19,12 +20,13 @@ case class BProcedure( freeEnsures: List[BExpr], freeRequires: List[BExpr], modifies: Set[BVar], - body: List[BCmdOrBlock] -) extends BDeclaration + body: List[BCmdOrBlock], + override val attributes: List[BAttribute] +) extends BDeclaration() with Ordered[BProcedure] { override def compare(that: BProcedure): Int = name.compare(that.name) override def toBoogie: List[String] = { - val header = s"procedure $name(${in.map(_.withType).mkString(", ")})" + val header = s"procedure $attrString$name(${in.map(_.withType).mkString(", ")})" val returns = if (out.nonEmpty) { s" returns (${out.map(_.withType).mkString(", ")})" } else { @@ -41,7 +43,7 @@ case class BProcedure( val freeRequiresStrs = freeRequires.map(r => s" free requires $r;") val freeEnsuresStrs = freeEnsures.map(e => s" free ensures $e;") val locals = body.flatMap(l => l.locals).distinct.sorted - val localDefs = locals.map(l => " " + BVarDecl(l).toString) + val localDefs = locals.map(l => " " + BVarDecl(l, List.empty).toString) val bodyStr = if (body.nonEmpty) { List("{") ++ localDefs ++ body.flatMap(x => x.toBoogie).map(s => " " + s) ++ List("}") } else { @@ -60,22 +62,19 @@ case class BProcedure( def globals: Set[BVar] = body.flatMap(c => c.globals).toSet ++ modifies } -case class BAxiom(body: BExpr) extends BDeclaration { - override def toString: String = s"axiom $body;" +case class BAxiom(body: BExpr, override val attributes: List[BAttribute]) extends BDeclaration() { + override def toString: String = s"axiom $attrString$body;" } -case class BFunction(name: String, bvbuiltin: String, in: List[BVar], out: BVar, body: Option[BExpr]) - extends BDeclaration +case class BFunction(name: String, in: List[BVar], out: BVar, body: Option[BExpr], + override val attributes: List[BAttribute]) + extends BDeclaration() with Ordered[BFunction] { + override def compare(that: BFunction): Int = name.compare(that.name) override def toBoogie: List[String] = { - val bvbuiltinString = if (bvbuiltin.isEmpty) { - "" - } else { - s" {:bvbuiltin \"$bvbuiltin\"}" - } val inString = in.map(_.withType).mkString(", ") - val declString = s"function$bvbuiltinString $name($inString) returns (${out.withType})" + val declString = s"function $attrString$name($inString) returns (${out.withType})" body match { case Some(b) => List(declString + " {", " " + b.toString, "}", "") case None => List(declString + ";") @@ -88,16 +87,16 @@ case class BFunction(name: String, bvbuiltin: String, in: List[BVar], out: BVar, } } -case class BVarDecl(variable: BVar) extends BDeclaration with Ordered[BVarDecl] { +case class BVarDecl(variable: BVar, override val attributes: List[BAttribute]) extends BDeclaration() with Ordered[BVarDecl] { def compare(that: BVarDecl): Int = variable.compare(that.variable) override def toString: String = if (variable.scope == Scope.Const) { - s"const $variable: ${variable.getType};" + s"const $attrString$variable: ${variable.getType};" } else { - s"var $variable: ${variable.getType};" + s"var $attrString$variable: ${variable.getType};" } } -case class BConstAxiomPair(const: BVarDecl, axiom: BAxiom) extends BDeclaration with Ordered[BConstAxiomPair] { +case class BConstAxiomPair(const: BVarDecl, axiom: BAxiom) extends BDeclaration() with Ordered[BConstAxiomPair] { override def compare(that: BConstAxiomPair): Int = const.compare(that.const) override def toString: String = const.toString + "\n" + axiom.toString } diff --git a/src/main/scala/ir/Statement.scala b/src/main/scala/ir/Statement.scala index 907c4324a..ff614c89e 100644 --- a/src/main/scala/ir/Statement.scala +++ b/src/main/scala/ir/Statement.scala @@ -1,6 +1,8 @@ package ir -trait Command +trait Command { + def label: Option[String] +} trait Statement extends Command { def modifies: Set[Global] = Set() @@ -10,7 +12,7 @@ trait Statement extends Command { ) } -class LocalAssign(var lhs: Variable, var rhs: Expr) extends Statement { +class LocalAssign(var lhs: Variable, var rhs: Expr, override val label: Option[String] = None) extends Statement { //override def locals: Set[Variable] = rhs.locals + lhs override def modifies: Set[Global] = lhs match { case r: Register => Set(r) @@ -20,31 +22,48 @@ class LocalAssign(var lhs: Variable, var rhs: Expr) extends Statement { override def acceptVisit(visitor: Visitor): Statement = visitor.visitLocalAssign(this) } -class MemoryAssign(var lhs: Memory, var rhs: MemoryStore) extends Statement { +object LocalAssign: + def unapply(l: LocalAssign): Option[(Variable, Expr, Option[String])] = Some(l.lhs, l.rhs, l.label) + +class MemoryAssign(var lhs: Memory, var rhs: MemoryStore, override val label: Option[String] = None) extends Statement { override def modifies: Set[Global] = Set(lhs) //override def locals: Set[Variable] = rhs.locals override def toString: String = s"$lhs := $rhs" override def acceptVisit(visitor: Visitor): Statement = visitor.visitMemoryAssign(this) } +object MemoryAssign: + def unapply(m: MemoryAssign): Option[(Memory, MemoryStore, Option[String])] = Some(m.lhs, m.rhs, m.label) + case object NOP extends Statement { + override def label: Option[String] = None override def toString: String = "" override def acceptVisit(visitor: Visitor): Statement = this } -class Assert(var body: Expr, var comment: Option[String]) extends Statement { +class Assume(var body: Expr, var comment: Option[String], override val label: Option[String] = None) extends Statement { + override def toString: String = s"assume $body" + comment.map(" //" + _) + override def acceptVisit(visitor: Visitor): Statement = visitor.visitAssume(this) +} + +object Assume: + def unapply(a: Assume): Option[(Expr, Option[String], Option[String])] = Some(a.body, a.comment, a.label) + +class Assert(var body: Expr, var comment: Option[String], override val label: Option[String] = None) extends Statement { override def toString: String = s"assert $body" + comment.map(" //" + _) override def acceptVisit(visitor: Visitor): Statement = visitor.visitAssert(this) } +object Assert: + def unapply(a: Assert): Option[(Expr, Option[String], Option[String])] = Some(a.body, a.comment, a.label) + trait Jump extends Command { def modifies: Set[Global] = Set() //def locals: Set[Variable] = Set() def calls: Set[Procedure] = Set() def acceptVisit(visitor: Visitor): Jump = throw new Exception("visitor " + visitor + " unimplemented for: " + this) } - -class GoTo(var target: Block, var condition: Option[Expr]) extends Jump { +class GoTo(var target: Block, var condition: Option[Expr], override val label: Option[String] = None) extends Jump { /* override def locals: Set[Variable] = condition match { case Some(c) => c.locals case None => Set() @@ -54,7 +73,10 @@ class GoTo(var target: Block, var condition: Option[Expr]) extends Jump { override def acceptVisit(visitor: Visitor): Jump = visitor.visitGoTo(this) } -class DirectCall(var target: Procedure, var condition: Option[Expr], var returnTarget: Option[Block]) extends Jump { +object GoTo: + def unapply(g: GoTo): Option[(Block, Option[Expr], Option[String])] = Some(g.target, g.condition, g.label) + +class DirectCall(var target: Procedure, var condition: Option[Expr], var returnTarget: Option[Block], override val label: Option[String] = None) extends Jump { /* override def locals: Set[Variable] = condition match { case Some(c) => c.locals case None => Set() @@ -64,7 +86,11 @@ class DirectCall(var target: Procedure, var condition: Option[Expr], var returnT override def acceptVisit(visitor: Visitor): Jump = visitor.visitDirectCall(this) } -class IndirectCall(var target: Variable, var condition: Option[Expr], var returnTarget: Option[Block]) extends Jump { +object DirectCall: + def unapply(i: DirectCall): Option[(Procedure, Option[Expr], Option[Block], Option[String])] = Some(i.target, i.condition, i.returnTarget, i.label) + +class IndirectCall(var target: Variable, var condition: Option[Expr], var returnTarget: Option[Block], + override val label: Option[String] = None) extends Jump { /* override def locals: Set[Variable] = condition match { case Some(c) => c.locals + target case None => Set(target) @@ -72,3 +98,6 @@ class IndirectCall(var target: Variable, var condition: Option[Expr], var return override def toString: String = s"IndirectCall($target, $condition, ${returnTarget.map(_.label)})" override def acceptVisit(visitor: Visitor): Jump = visitor.visitIndirectCall(this) } + +object IndirectCall: + def unapply(i: IndirectCall): Option[(Variable, Option[Expr], Option[Block], Option[String])] = Some(i.target, i.condition, i.returnTarget, i.label) \ No newline at end of file diff --git a/src/main/scala/ir/Visitor.scala b/src/main/scala/ir/Visitor.scala index 6fd3a2339..fa88da27f 100644 --- a/src/main/scala/ir/Visitor.scala +++ b/src/main/scala/ir/Visitor.scala @@ -21,6 +21,11 @@ abstract class Visitor { node } + def visitAssume(node: Assume): Statement = { + node.body = visitExpr(node.body) + node + } + def visitAssert(node: Assert): Statement = { node.body = visitExpr(node.body) node @@ -197,6 +202,11 @@ abstract class ReadOnlyVisitor extends Visitor { node } + override def visitAssume(node: Assume): Statement = { + visitExpr(node.body) + node + } + override def visitAssert(node: Assert): Statement = { visitExpr(node.body) node diff --git a/src/main/scala/specification/Specification.scala b/src/main/scala/specification/Specification.scala index 3c3ffd7ff..754d0e43b 100644 --- a/src/main/scala/specification/Specification.scala +++ b/src/main/scala/specification/Specification.scala @@ -23,7 +23,7 @@ case class SpecGlobal(name: String, override val size: Int, arraySize: Option[In override val toAddrVar: BVar = BVariable("$" + s"${name}_addr", BitVecBType(64), Scope.Const) override val toOldVar: BVar = BVariable(s"${name}_old", BitVecBType(size), Scope.Local) override val toOldGamma: BVar = BVariable(s"Gamma_${name}_old", BoolBType, Scope.Local) - val toAxiom: BAxiom = BAxiom(BinaryBExpr(BoolEQ, toAddrVar, BitVecBLiteral(address, 64))) + val toAxiom: BAxiom = BAxiom(BinaryBExpr(BoolEQ, toAddrVar, BitVecBLiteral(address, 64)), List.empty) override def resolveSpec: BMemoryLoad = BMemoryLoad( BMapVar("mem", MapBType(BitVecBType(64), BitVecBType(8)), Scope.Global), toAddrVar, diff --git a/src/main/scala/translating/BAPLoader.scala b/src/main/scala/translating/BAPLoader.scala index bf5b96ac2..979fdafb8 100644 --- a/src/main/scala/translating/BAPLoader.scala +++ b/src/main/scala/translating/BAPLoader.scala @@ -231,13 +231,15 @@ object BAPLoader { def visitImmDef(ctx: ImmDefContext): BAPLocalAssign = { val line = visitQuoteString(ctx.tid.name) val insn = parseFromAttrs(ctx.attrs, "insn").getOrElse("") - BAPLocalAssign(visitImmVar(ctx.lhs), visitExp(ctx.rhs), line, insn) + val addr = parseFromAttrs(ctx.attrs, "address").map(x => Integer.parseInt(x.stripPrefix("0x"), 16)); + BAPLocalAssign(visitImmVar(ctx.lhs), visitExp(ctx.rhs), line, insn, addr) } def visitMemDef(ctx: MemDefContext): BAPMemAssign = { val line = visitQuoteString(ctx.tid.name) val insn = parseFromAttrs(ctx.attrs, "insn").getOrElse("") - BAPMemAssign(visitMemVar(ctx.lhs), visitStore(ctx.rhs), line, insn) + val addr = parseFromAttrs(ctx.attrs, "address").map(x => Integer.parseInt(x.stripPrefix("0x"), 16)); + BAPMemAssign(visitMemVar(ctx.lhs), visitStore(ctx.rhs), line, insn, addr) } def visitQuoteString(ctx: QuoteStringContext): String = ctx.getText.stripPrefix("\"").stripSuffix("\"") diff --git a/src/main/scala/translating/BAPToIR.scala b/src/main/scala/translating/BAPToIR.scala index 943e1b600..0243400d1 100644 --- a/src/main/scala/translating/BAPToIR.scala +++ b/src/main/scala/translating/BAPToIR.scala @@ -60,8 +60,8 @@ class BAPToIR(var program: BAPProgram, mainAddress: Int) { } private def translate(s: BAPStatement) = s match { - case b: BAPMemAssign => MemoryAssign(b.lhs.toIR, b.rhs.toIR) - case b: BAPLocalAssign => LocalAssign(b.lhs.toIR, b.rhs.toIR) + case b: BAPMemAssign => MemoryAssign(b.lhs.toIR, b.rhs.toIR, Some(b.line)) + case b: BAPLocalAssign => LocalAssign(b.lhs.toIR, b.rhs.toIR, Some(b.line)) case _ => throw new Exception("unsupported statement: " + s) } @@ -70,12 +70,13 @@ class BAPToIR(var program: BAPProgram, mainAddress: Int) { DirectCall( nameToProcedure(b.target), coerceToBool(b.condition), - b.returnTarget.map { (t: String) => labelToBlock(t) } + b.returnTarget.map { (t: String) => labelToBlock(t) }, + Some(b.line) ) case b: BAPIndirectCall => - IndirectCall(b.target.toIR, coerceToBool(b.condition), b.returnTarget.map { (t: String) => labelToBlock(t) }) + IndirectCall(b.target.toIR, coerceToBool(b.condition), b.returnTarget.map { (t: String) => labelToBlock(t) }, Some(b.line)) case b: BAPGoTo => - GoTo(labelToBlock(b.target), coerceToBool(b.condition)) + GoTo(labelToBlock(b.target), coerceToBool(b.condition), Some(b.line)) case _ => throw new Exception("unsupported jump: " + j) } diff --git a/src/main/scala/translating/IRToBoogie.scala b/src/main/scala/translating/IRToBoogie.scala index bc6d6addb..ff6001397 100644 --- a/src/main/scala/translating/IRToBoogie.scala +++ b/src/main/scala/translating/IRToBoogie.scala @@ -6,6 +6,7 @@ import specification._ import scala.collection.mutable.ArrayBuffer class IRToBoogie(var program: Program, var spec: Specification) { + private val externAttr = BAttribute("extern") private val globals = spec.globals private val controls = spec.controls private val controlled = spec.controlled @@ -35,12 +36,12 @@ class IRToBoogie(var program: Program, var spec: Specification) { def translate: BProgram = { val readOnlyMemory = memoryToCondition(program.readOnlyMemory) val procedures = program.procedures.map(f => translateProcedure(f, readOnlyMemory)) - val defaultGlobals = List(BVarDecl(mem), BVarDecl(Gamma_mem)) + val defaultGlobals = List(BVarDecl(mem, List(externAttr)), BVarDecl(Gamma_mem, List(externAttr))) val globalVars = procedures.flatMap(p => p.globals ++ p.freeRequires.flatMap(_.globals) ++ p.freeEnsures.flatMap(_.globals) ++ p.ensures.flatMap(_.globals) ++ p.requires.flatMap(_.globals)) - val globalDecls = (globalVars.map(b => BVarDecl(b)) ++ defaultGlobals).distinct.sorted.toList + val globalDecls = (globalVars.map(b => BVarDecl(b, List(externAttr))) ++ defaultGlobals).distinct.sorted.toList val globalConsts: List[BConstAxiomPair] = - globals.map(g => BConstAxiomPair(BVarDecl(g.toAddrVar), g.toAxiom)).toList.sorted + globals.map(g => BConstAxiomPair(BVarDecl(g.toAddrVar, List(externAttr)), g.toAxiom)).toList.sorted val guaranteeReflexive = BProcedure( "guarantee_reflexive", @@ -53,7 +54,8 @@ class IRToBoogie(var program: Program, var spec: Specification) { List(), List(), Set(mem, Gamma_mem), - guaranteesReflexive.map(g => BAssert(g)) + guaranteesReflexive.map(g => BAssert(g)), + List(externAttr) ) val rgProcs = genRely(relies, readOnlyMemory) :+ guaranteeReflexive @@ -82,15 +84,19 @@ class IRToBoogie(var program: Program, var spec: Specification) { } else { reliesUsed } - val relyProc = BProcedure("rely", List(), List(), relyEnsures, List(), List(), List(), readOnlyMemory, List(), Set(mem, Gamma_mem), List()) - val relyTransitive = BProcedure("rely_transitive", List(), List(), reliesUsed, List(), List(), List(), List(), List(), Set(mem, Gamma_mem), List(BProcedureCall("rely", List(), List()), BProcedureCall("rely", List(), List()))) - val relyReflexive = BProcedure("rely_reflexive", List(), List(), List(), List(), List(), List(), List(), List(), Set(), reliesReflexive.map(r => BAssert(r))) + val relyProc = BProcedure("rely", List(), List(), relyEnsures, List(), List(), List(), readOnlyMemory, List(), + Set(mem, Gamma_mem), List(), List(externAttr)) + val relyTransitive = BProcedure("rely_transitive", List(), List(), reliesUsed, List(), List(), List(), List(), List(), + Set(mem, Gamma_mem), List(BProcedureCall("rely", List(), List()), BProcedureCall("rely", List(), List())), + List(externAttr)) + val relyReflexive = BProcedure("rely_reflexive", List(), List(), List(), List(), List(), List(), List(), List(), + Set(), reliesReflexive.map(r => BAssert(r)), List(externAttr)) List(relyProc, relyTransitive, relyReflexive) } def functionOpToDefinition(f: FunctionOp): BFunction = { f match { - case b: BVFunctionOp => BFunction(b.name, b.bvbuiltin, b.in, b.out, None) + case b: BVFunctionOp => BFunction(b.name, b.in, b.out, None, List(externAttr, b.attribute)) case m: MemoryLoadOp => val memVar = BMapVar("memory", MapBType(BitVecBType(m.addressSize), BitVecBType(m.valueSize)), Scope.Parameter) val indexVar = BParam("index", BitVecBType(m.addressSize)) @@ -112,7 +118,7 @@ class IRToBoogie(var program: Program, var spec: Specification) { BinaryBExpr(BVCONCAT, next, concat) } - BFunction(m.fnName, "", in, out, Some(body)) + BFunction(m.fnName, in, out, Some(body), List(externAttr)) case g: GammaLoadOp => val gammaMapVar = BMapVar("gammaMap", MapBType(BitVecBType(g.addressSize), BoolBType), Scope.Parameter) val indexVar = BParam("index", BitVecBType(g.addressSize)) @@ -130,7 +136,7 @@ class IRToBoogie(var program: Program, var spec: Specification) { BinaryBExpr(BoolAND, next, and) } - BFunction(g.fnName, "", in, out, Some(body)) + BFunction(g.fnName, in, out, Some(body), List(externAttr)) case m: MemoryStoreOp => val memType = MapBType(BitVecBType(m.addressSize), BitVecBType(m.valueSize)) val memVar = BMapVar("memory", memType, Scope.Parameter) @@ -160,7 +166,7 @@ class IRToBoogie(var program: Program, var spec: Specification) { (update: MapUpdate, next: (BExpr, BExpr)) => MapUpdate(update, next._1, next._2) } - BFunction(m.fnName, "", in, out, Some(body)) + BFunction(m.fnName, in, out, Some(body), List(externAttr)) case g: GammaStoreOp => val gammaMapType = MapBType(BitVecBType(g.addressSize), BoolBType) val gammaMapVar = BMapVar("gammaMap", gammaMapType, Scope.Parameter) @@ -187,7 +193,7 @@ class IRToBoogie(var program: Program, var spec: Specification) { (update: MapUpdate, next: (BExpr, BExpr)) => MapUpdate(update, next._1, next._2) } - BFunction(g.fnName, "", in, out, Some(body)) + BFunction(g.fnName, in, out, Some(body), List(externAttr)) case l: LOp => val memoryVar = BParam("memory", l.memoryType) val indexVar = BParam("index", l.indexType) @@ -213,7 +219,7 @@ class IRToBoogie(var program: Program, var spec: Specification) { IfThenElse(guard, LPred, ite) } } - BFunction("L", "", List(memoryVar, indexVar), BParam(BoolBType), Some(body)) + BFunction("L", List(memoryVar, indexVar), BParam(BoolBType), Some(body), List(externAttr)) } } @@ -288,7 +294,8 @@ class IRToBoogie(var program: Program, var spec: Specification) { freeEnsures, freeRequires, modifies.toSet, - body.toList + body.toList, + List.empty ) } @@ -305,9 +312,17 @@ class IRToBoogie(var program: Program, var spec: Specification) { sections.toList } + + def captureStateStatement(stateName: String): BAssume = { + BAssume(TrueBLiteral, None, List(BAttribute("captureState", Some(s"\"$stateName\"")))) + } + def translateBlock(b: Block): BBlock = { - val cmds = b.statements.flatMap(s => translate(s)) ++ b.jumps.flatMap(j => translate(j)) - BBlock(b.label, cmds.toList) + val captureState = captureStateStatement(s"${b.label}") + val cmds = List(captureState) + ++ (b.statements.flatMap(s => translate(s)) ++ b.jumps.flatMap(j => translate(j))) + + BBlock(b.label, cmds) } def translate(j: Jump): List[BCmd] = j match { @@ -362,8 +377,13 @@ class IRToBoogie(var program: Program, var spec: Specification) { val lhsGamma = m.lhs.toGamma val rhsGamma = m.rhs.toGamma val store = AssignCmd(List(lhs, lhsGamma), List(rhs, rhsGamma)) + val stateSplit = s match { + case MemoryAssign(_,_, Some(label)) => List(captureStateStatement(s"$label")) + case LocalAssign(_,_, Some(label)) => List(captureStateStatement(s"$label")) + case _ => List.empty + } if (lhs == stack) { - List(store) + List(store) ++ stateSplit } else { val rely = BProcedureCall("rely", List(), List()) val gammaValueCheck = BAssert(BinaryBExpr(BoolIMPLIES, L(lhs, rhs.index), m.rhs.value.toGamma)) @@ -386,7 +406,7 @@ class IRToBoogie(var program: Program, var spec: Specification) { BAssert(BinaryBExpr(BoolIMPLIES, addrCheck, checksAnd)) } val guaranteeChecks = guarantees.map(v => BAssert(v)) - (List(rely, gammaValueCheck) ++ oldAssigns ++ oldGammaAssigns :+ store) ++ secureUpdate ++ guaranteeChecks + (List(rely, gammaValueCheck) ++ oldAssigns ++ oldGammaAssigns :+ store) ++ secureUpdate ++ guaranteeChecks ++ stateSplit } case l: LocalAssign => val lhs = l.lhs.toBoogie diff --git a/src/test/correct/arrays_simple/clang/arrays_simple.expected b/src/test/correct/arrays_simple/clang/arrays_simple.expected index b326ff7ab..ca54b2d0a 100644 --- a/src/test/correct/arrays_simple/clang/arrays_simple.expected +++ b/src/test/correct/arrays_simple/clang/arrays_simple.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1872bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -82,9 +82,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -181,13 +181,17 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%0000089b"} true; R8, Gamma_R8 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%000008a8"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000008b7"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/arrays_simple/clang_O2/arrays_simple.expected b/src/test/correct/arrays_simple/clang_O2/arrays_simple.expected index 1e9764f80..b904c03a5 100644 --- a/src/test/correct/arrays_simple/clang_O2/arrays_simple.expected +++ b/src/test/correct/arrays_simple/clang_O2/arrays_simple.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1840bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/arrays_simple/clang_no_plt_no_pic/arrays_simple.expected b/src/test/correct/arrays_simple/clang_no_plt_no_pic/arrays_simple.expected index b326ff7ab..ca54b2d0a 100644 --- a/src/test/correct/arrays_simple/clang_no_plt_no_pic/arrays_simple.expected +++ b/src/test/correct/arrays_simple/clang_no_plt_no_pic/arrays_simple.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1872bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -82,9 +82,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -181,13 +181,17 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%0000089b"} true; R8, Gamma_R8 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%000008a8"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000008b7"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/arrays_simple/clang_pic/arrays_simple.expected b/src/test/correct/arrays_simple/clang_pic/arrays_simple.expected index b326ff7ab..ca54b2d0a 100644 --- a/src/test/correct/arrays_simple/clang_pic/arrays_simple.expected +++ b/src/test/correct/arrays_simple/clang_pic/arrays_simple.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1872bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -82,9 +82,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -181,13 +181,17 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%0000089b"} true; R8, Gamma_R8 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%000008a8"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000008b7"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/arrays_simple/gcc_O2/arrays_simple.expected b/src/test/correct/arrays_simple/gcc_O2/arrays_simple.expected index ab48890b6..306991d20 100644 --- a/src/test/correct/arrays_simple/gcc_O2/arrays_simple.expected +++ b/src/test/correct/arrays_simple/gcc_O2/arrays_simple.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected index f523388ae..4bdf41446 100644 --- a/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -190,13 +190,16 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002d1"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> true); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); assert true; + assume {:captureState "%000002dd"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/basic_arrays_read/clang_O2/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/clang_O2/basic_arrays_read.expected index 3fc4ae2e9..053a779de 100644 --- a/src/test/correct/basic_arrays_read/clang_O2/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/clang_O2/basic_arrays_read.expected @@ -1,33 +1,33 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var mem: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -68,7 +68,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -76,12 +76,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -179,11 +179,13 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> true); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); assert true; + assume {:captureState "%000002c9"} true; return; } diff --git a/src/test/correct/basic_arrays_read/clang_no_plt_no_pic/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/clang_no_plt_no_pic/basic_arrays_read.expected index f523388ae..8fa9643f0 100644 --- a/src/test/correct/basic_arrays_read/clang_no_plt_no_pic/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/clang_no_plt_no_pic/basic_arrays_read.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -190,13 +190,16 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000863"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> true); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); assert true; + assume {:captureState "%0000086f"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected index bcd1f7a82..fe469ac3d 100644 --- a/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -93,7 +93,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -101,12 +101,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -222,8 +222,10 @@ procedure main() free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002d5"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4056bv64)) || L(mem, bvadd64(R8, 4056bv64))); @@ -231,6 +233,7 @@ procedure main() assert (L(mem, R8) ==> true); mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert true; + assume {:captureState "%000002e8"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected index d8e31fe22..39f86e8f0 100644 --- a/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected @@ -1,36 +1,36 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -71,7 +71,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -79,12 +79,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -182,12 +182,14 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> true); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert true; + assume {:captureState "%000002d6"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); diff --git a/src/test/correct/basic_arrays_read/gcc_O2/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/gcc_O2/basic_arrays_read.expected index 6667be099..897f29d0a 100644 --- a/src/test/correct/basic_arrays_read/gcc_O2/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/gcc_O2/basic_arrays_read.expected @@ -1,33 +1,33 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -68,7 +68,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -76,12 +76,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -179,11 +179,13 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R1, 24bv64)) ==> true); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 24bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 24bv64), true); assert true; + assume {:captureState "%000001b7"} true; return; } diff --git a/src/test/correct/basic_arrays_read/gcc_no_plt_no_pic/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/gcc_no_plt_no_pic/basic_arrays_read.expected index d8e31fe22..fe51c2369 100644 --- a/src/test/correct/basic_arrays_read/gcc_no_plt_no_pic/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/gcc_no_plt_no_pic/basic_arrays_read.expected @@ -1,36 +1,36 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -71,7 +71,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -79,12 +79,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -182,12 +182,14 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> true); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert true; + assume {:captureState "%00000866"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); diff --git a/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected b/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected index c12d5f8d6..b8d3ae1b0 100644 --- a/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected +++ b/src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, bvadd64($arr_addr, 0bv64))) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert true; @@ -214,6 +214,7 @@ procedure main() free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); @@ -221,6 +222,7 @@ procedure main() assert (L(mem, R0) ==> true); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert true; + assume {:captureState "%000002d7"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); diff --git a/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected index 3e572c0c8..802dd2fd8 100644 --- a/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -87,12 +87,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -194,16 +194,19 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R9, Gamma_R9 := 69632bv64, true; R9, Gamma_R9 := bvadd64(R9, 52bv64), Gamma_R9; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002e5"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f4"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected index 1715c0443..0b0f67500 100644 --- a/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected @@ -1,36 +1,36 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -71,7 +71,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -79,12 +79,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -184,6 +184,7 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; R9, Gamma_R9 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -192,5 +193,6 @@ procedure main() arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002d4"} true; return; } diff --git a/src/test/correct/basic_arrays_write/clang_no_plt_no_pic/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/clang_no_plt_no_pic/basic_arrays_write.expected index 3e572c0c8..451345fbe 100644 --- a/src/test/correct/basic_arrays_write/clang_no_plt_no_pic/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/clang_no_plt_no_pic/basic_arrays_write.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -87,12 +87,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -194,16 +194,19 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R9, Gamma_R9 := 69632bv64, true; R9, Gamma_R9 := bvadd64(R9, 52bv64), Gamma_R9; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000890"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%0000089f"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected index b3f87be66..d97347e01 100644 --- a/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -95,7 +95,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -103,12 +103,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -226,17 +226,20 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4056bv64)) || L(mem, bvadd64(R9, 4056bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002e6"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f5"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected index 92f0905a8..633928146 100644 --- a/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/gcc/basic_arrays_write.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -192,8 +192,10 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002da"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); @@ -202,6 +204,7 @@ procedure main() arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f4"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected index d623aa766..72ddd2b51 100644 --- a/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/gcc_O2/basic_arrays_write.expected @@ -1,36 +1,36 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -71,7 +71,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -79,12 +79,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -184,6 +184,7 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 0bv64, true; @@ -192,5 +193,6 @@ procedure main() arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 28bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 28bv64), Gamma_R2); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000001be"} true; return; } diff --git a/src/test/correct/basic_arrays_write/gcc_no_plt_no_pic/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/gcc_no_plt_no_pic/basic_arrays_write.expected index 92f0905a8..acde06d29 100644 --- a/src/test/correct/basic_arrays_write/gcc_no_plt_no_pic/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/gcc_no_plt_no_pic/basic_arrays_write.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -192,8 +192,10 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000885"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); @@ -202,6 +204,7 @@ procedure main() arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%0000089f"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected b/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected index 646f49745..f49966fbc 100644 --- a/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected +++ b/src/test/correct/basic_arrays_write/gcc_pic/basic_arrays_write.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $arr_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $arr_addr: bv64; axiom ($arr_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if ((index == bvadd64($arr_addr, 4bv64)) || (index == bvadd64($arr_addr, 0bv64))) then false else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures true; @@ -93,7 +93,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures true; { @@ -101,12 +101,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert true; } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, bvadd64($arr_addr, 0bv64)) == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); @@ -224,8 +224,10 @@ procedure main() { var arr$0_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002da"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4080bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4080bv64)) || L(mem, bvadd64(R0, 4080bv64))); @@ -235,6 +237,7 @@ procedure main() arr$0_old := memory_load32_le(mem, bvadd64($arr_addr, 0bv64)); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); assert (arr$0_old == memory_load32_le(mem, bvadd64($arr_addr, 0bv64))); + assume {:captureState "%000002f5"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected index a64e855b7..45d3ed040 100644 --- a/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -184,6 +184,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 5bv64, true; call rely(); @@ -191,6 +192,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002ce"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_assign/clang_O2/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/clang_O2/basic_assign_assign.expected index ce931bc4a..00e811d26 100644 --- a/src/test/correct/basic_assign_assign/clang_O2/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/clang_O2/basic_assign_assign.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -184,6 +184,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 5bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -192,5 +193,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002d3"} true; return; } diff --git a/src/test/correct/basic_assign_assign/clang_no_plt_no_pic/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/clang_no_plt_no_pic/basic_assign_assign.expected index a64e855b7..1d38b377b 100644 --- a/src/test/correct/basic_assign_assign/clang_no_plt_no_pic/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/clang_no_plt_no_pic/basic_assign_assign.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -184,6 +184,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 5bv64, true; call rely(); @@ -191,6 +192,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%00000845"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected index cee149132..17aef59a5 100644 --- a/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -86,7 +86,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -94,12 +94,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -216,6 +216,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); @@ -225,6 +226,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected index 08e4296f3..238102d1a 100644 --- a/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/gcc/basic_assign_assign.expected @@ -1,33 +1,33 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -68,7 +68,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -76,12 +76,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -182,6 +182,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 5bv64, true; @@ -190,6 +191,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002d8"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected index cc8b3eeb2..81d8fdece 100644 --- a/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/gcc_O2/basic_assign_assign.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -184,6 +184,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := 5bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -192,5 +193,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000001bd"} true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc_no_plt_no_pic/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/gcc_no_plt_no_pic/basic_assign_assign.expected index 08e4296f3..1b1ef4f87 100644 --- a/src/test/correct/basic_assign_assign/gcc_no_plt_no_pic/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/gcc_no_plt_no_pic/basic_assign_assign.expected @@ -1,33 +1,33 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -68,7 +68,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -76,12 +76,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -182,6 +182,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 5bv64, true; @@ -190,6 +191,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%0000085b"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected b/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected index 85246be43..ffd291153 100644 --- a/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected +++ b/src/test/correct/basic_assign_assign/gcc_pic/basic_assign_assign.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -84,7 +84,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); { @@ -92,12 +92,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -214,6 +214,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -223,6 +224,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 5bv32)); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected index 36312a51e..528931a0f 100644 --- a/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -190,6 +190,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); @@ -199,6 +200,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002da"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_increment/clang_O2/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/clang_O2/basic_assign_increment.expected index 86b1b096d..68697865d 100644 --- a/src/test/correct/basic_assign_increment/clang_O2/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/clang_O2/basic_assign_increment.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -190,6 +190,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); @@ -200,5 +201,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002df"} true; return; } diff --git a/src/test/correct/basic_assign_increment/clang_no_plt_no_pic/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/clang_no_plt_no_pic/basic_assign_increment.expected index 36312a51e..fcde38982 100644 --- a/src/test/correct/basic_assign_increment/clang_no_plt_no_pic/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/clang_no_plt_no_pic/basic_assign_increment.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -190,6 +190,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); @@ -199,6 +200,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%0000085f"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected index 4cd66a8c8..86e9d68ec 100644 --- a/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected @@ -1,49 +1,49 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -100,12 +100,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -222,6 +222,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); @@ -233,6 +234,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002e5"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected index 3d153e01b..1c13cd862 100644 --- a/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/gcc/basic_assign_increment.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -82,12 +82,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -188,6 +188,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -200,6 +201,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002f7"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected index 9c5f79584..07a2894d0 100644 --- a/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/gcc_O2/basic_assign_increment.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -190,6 +190,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R2, Gamma_R2 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); @@ -200,5 +201,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 20bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 20bv64), Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000001c5"} true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc_no_plt_no_pic/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/gcc_no_plt_no_pic/basic_assign_increment.expected index 3d153e01b..01ec2e5fb 100644 --- a/src/test/correct/basic_assign_increment/gcc_no_plt_no_pic/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/gcc_no_plt_no_pic/basic_assign_increment.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -82,12 +82,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -188,6 +188,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -200,6 +201,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%0000089f"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected b/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected index bcb6297df..0f73e2bfe 100644 --- a/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected +++ b/src/test/correct/basic_assign_increment/gcc_pic/basic_assign_increment.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); @@ -90,7 +90,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (memory_load32_le(mem, $x_addr) == 5bv32)); { @@ -98,12 +98,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 5bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); @@ -220,6 +220,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -234,6 +235,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || (memory_load32_le(mem, $x_addr) == 1bv32)) || (memory_load32_le(mem, $x_addr) == 6bv32)); + assume {:captureState "%000002f9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected index 60a7c6f30..6c8610d8c 100644 --- a/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected @@ -1,66 +1,66 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -102,7 +102,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -111,13 +111,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -227,16 +227,21 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000304"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000030a"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%00000318"} true; R30, Gamma_R30 := 1840bv64, true; call zero(); goto l00000321; l00000321: + assume {:captureState "l00000321"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R0); @@ -246,6 +251,7 @@ procedure main() assert ((bvadd64(R8, 52bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%0000032c"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); @@ -256,6 +262,7 @@ procedure main() assert ((bvadd64(R9, 56bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%00000340"} true; R0, Gamma_R0 := 0bv64, true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); @@ -341,6 +348,7 @@ procedure zero() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lzero: + assume {:captureState "lzero"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected index 8f23c33b3..74d7abc58 100644 --- a/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -80,7 +80,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -89,13 +89,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -197,6 +197,7 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 0bv64, true; R9, Gamma_R9 := 69632bv64, true; @@ -209,6 +210,7 @@ procedure main() assert ((bvadd64(R9, 52bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000002f2"} true; call rely(); assert (L(mem, bvadd64(R10, 56bv64)) ==> Gamma_R8); x_old := memory_load32_le(mem, $x_addr); @@ -217,5 +219,6 @@ procedure main() assert ((bvadd64(R10, 56bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000002fa"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang_no_plt_no_pic/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/clang_no_plt_no_pic/basic_function_call_caller.expected index 2da604ae7..04a6a5d25 100644 --- a/src/test/correct/basic_function_call_caller/clang_no_plt_no_pic/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/clang_no_plt_no_pic/basic_function_call_caller.expected @@ -1,66 +1,66 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -102,7 +102,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -111,13 +111,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -227,16 +227,21 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000091b"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000921"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%0000092f"} true; R30, Gamma_R30 := 1840bv64, true; call zero(); goto l00000938; l00000938: + assume {:captureState "l00000938"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R0); @@ -246,6 +251,7 @@ procedure main() assert ((bvadd64(R8, 52bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%00000943"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); @@ -256,6 +262,7 @@ procedure main() assert ((bvadd64(R9, 56bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%00000957"} true; R0, Gamma_R0 := 0bv64, true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); @@ -341,6 +348,7 @@ procedure zero() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lzero: + assume {:captureState "lzero"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected index 85ae403cc..861158d4a 100644 --- a/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected @@ -1,66 +1,66 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -118,7 +118,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -127,13 +127,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -275,16 +275,21 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000030c"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000312"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%00000320"} true; R30, Gamma_R30 := 1904bv64, true; call zero(); goto l00000329; l00000329: + assume {:captureState "l00000329"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -296,6 +301,7 @@ procedure main() assert ((R8 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%0000033b"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); R9, Gamma_R9 := 65536bv64, true; call rely(); @@ -308,6 +314,7 @@ procedure main() assert ((R9 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%00000356"} true; R0, Gamma_R0 := 0bv64, true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); @@ -425,6 +432,7 @@ procedure zero() free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); { lzero: + assume {:captureState "lzero"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected index a129dc430..d350182f1 100644 --- a/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/gcc/basic_function_call_caller.expected @@ -1,64 +1,64 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -100,7 +100,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -109,13 +109,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -223,16 +223,21 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000302"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000308"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000031a"} true; R30, Gamma_R30 := 1836bv64, true; call zero(); goto l00000323; l00000323: + assume {:captureState "l00000323"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; @@ -244,6 +249,7 @@ procedure main() assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%0000033a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); @@ -255,6 +261,7 @@ procedure main() assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%00000354"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -339,6 +346,7 @@ procedure zero() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lzero: + assume {:captureState "lzero"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected index 338a6d32c..0d135f9f8 100644 --- a/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/gcc_O2/basic_function_call_caller.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R3: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R3: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -80,7 +80,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -89,13 +89,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -197,6 +197,7 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R3, Gamma_R3 := zero_extend32_32(R0[32:0]), Gamma_R0; @@ -209,6 +210,7 @@ procedure main() assert ((bvadd64(R1, 20bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000001d7"} true; call rely(); assert (L(mem, bvadd64(R2, 4bv64)) ==> Gamma_R3); x_old := memory_load32_le(mem, $x_addr); @@ -217,5 +219,6 @@ procedure main() assert ((bvadd64(R2, 4bv64) == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%000001df"} true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc_no_plt_no_pic/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/gcc_no_plt_no_pic/basic_function_call_caller.expected index 86bac1f17..39a811b3e 100644 --- a/src/test/correct/basic_function_call_caller/gcc_no_plt_no_pic/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/gcc_no_plt_no_pic/basic_function_call_caller.expected @@ -1,64 +1,64 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -100,7 +100,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -109,13 +109,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -223,16 +223,21 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000929"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000092f"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000941"} true; R30, Gamma_R30 := 1836bv64, true; call zero(); goto l0000094a; l0000094a: + assume {:captureState "l0000094a"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; @@ -244,6 +249,7 @@ procedure main() assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%00000961"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); @@ -255,6 +261,7 @@ procedure main() assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%0000097b"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -339,6 +346,7 @@ procedure zero() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lzero: + assume {:captureState "lzero"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected b/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected index 062aa71c0..75e7e00b2 100644 --- a/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected +++ b/src/test/correct/basic_function_call_caller/gcc_pic/basic_function_call_caller.expected @@ -1,64 +1,64 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -116,7 +116,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -125,13 +125,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -271,16 +271,21 @@ procedure main() var Gamma_y_old: bool; var x_old: bv32; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000302"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000308"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000031a"} true; R30, Gamma_R30 := 1900bv64, true; call zero(); goto l00000323; l00000323: + assume {:captureState "l00000323"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -293,6 +298,7 @@ procedure main() assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%0000033b"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -305,6 +311,7 @@ procedure main() assert ((R0 == $x_addr) ==> (L(mem, $y_addr) ==> Gamma_y_old)); assert ((x_old == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (Gamma_y_old ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); + assume {:captureState "%00000356"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -421,6 +428,7 @@ procedure zero() free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); { lzero: + assume {:captureState "lzero"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected index 23ab29004..74f5ae7ad 100644 --- a/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -88,7 +88,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -97,13 +97,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -214,12 +214,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000301"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000315"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); @@ -235,27 +238,36 @@ procedure main() } goto l00000345; l00000345: + assume {:captureState "l00000345"} true; R8, Gamma_R8 := 1bv64, true; goto l00000348; l00000342: + assume {:captureState "l00000342"} true; R8, Gamma_R8 := 0bv64, true; goto l00000348; l00000348: + assume {:captureState "l00000348"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000350; } goto l0000037a; l00000350: + assume {:captureState "l00000350"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000362"} true; goto l00000365; l0000037a: + assume {:captureState "l0000037a"} true; goto l0000037b; l0000037b: + assume {:captureState "l0000037b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000383"} true; goto l00000365; l00000365: + assume {:captureState "l00000365"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected index 7987ac443..83a41ea67 100644 --- a/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -78,7 +78,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -87,13 +87,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -202,6 +202,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; call rely(); @@ -219,11 +220,14 @@ procedure main() } goto l000002fd; l000002fd: + assume {:captureState "l000002fd"} true; R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; goto l00000300; l000002f9: + assume {:captureState "l000002f9"} true; R0, Gamma_R0 := 0bv64, true; goto l00000300; l00000300: + assume {:captureState "l00000300"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/clang_no_plt_no_pic/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/clang_no_plt_no_pic/basic_function_call_reader.expected index 66a7c15e5..a14b648f6 100644 --- a/src/test/correct/basic_function_call_reader/clang_no_plt_no_pic/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/clang_no_plt_no_pic/basic_function_call_reader.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -88,7 +88,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -97,13 +97,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -214,12 +214,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000944"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000958"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); @@ -235,27 +238,36 @@ procedure main() } goto l00000988; l00000988: + assume {:captureState "l00000988"} true; R8, Gamma_R8 := 1bv64, true; goto l0000098b; l00000985: + assume {:captureState "l00000985"} true; R8, Gamma_R8 := 0bv64, true; goto l0000098b; l0000098b: + assume {:captureState "l0000098b"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000993; } goto l000009bd; l00000993: + assume {:captureState "l00000993"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000009a5"} true; goto l000009a8; l000009bd: + assume {:captureState "l000009bd"} true; goto l000009be; l000009be: + assume {:captureState "l000009be"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000009c6"} true; goto l000009a8; l000009a8: + assume {:captureState "l000009a8"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected index f0f9dd71e..ec772c91a 100644 --- a/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -112,7 +112,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -121,13 +121,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -270,14 +270,17 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000309"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000324"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -295,27 +298,36 @@ procedure main() } goto l0000035b; l0000035b: + assume {:captureState "l0000035b"} true; R8, Gamma_R8 := 1bv64, true; goto l0000035e; l00000358: + assume {:captureState "l00000358"} true; R8, Gamma_R8 := 0bv64, true; goto l0000035e; l0000035e: + assume {:captureState "l0000035e"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000366; } goto l00000390; l00000366: + assume {:captureState "l00000366"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000378"} true; goto l0000037b; l00000390: + assume {:captureState "l00000390"} true; goto l00000391; l00000391: + assume {:captureState "l00000391"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000399"} true; goto l0000037b; l0000037b: + assume {:captureState "l0000037b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected index 6082bfc1b..b2e35d098 100644 --- a/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/gcc/basic_function_call_reader.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -86,7 +86,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -95,13 +95,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -212,12 +212,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000304"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -233,12 +235,15 @@ procedure main() } goto l00000349; l00000332: + assume {:captureState "l00000332"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); goto l0000033e; l00000349: + assume {:captureState "l00000349"} true; R0, Gamma_R0 := 0bv64, true; goto l0000033e; l0000033e: + assume {:captureState "l0000033e"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected index 5d09ae024..19620ad7e 100644 --- a/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/gcc_O2/basic_function_call_reader.expected @@ -1,33 +1,33 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -69,7 +69,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -78,13 +78,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -183,6 +183,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -193,9 +194,11 @@ procedure main() } goto l00000398; l00000398: + assume {:captureState "l00000398"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 4bv64)) || L(mem, bvadd64(R1, 4bv64))); goto l000001bc; l000001bc: + assume {:captureState "l000001bc"} true; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc_no_plt_no_pic/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/gcc_no_plt_no_pic/basic_function_call_reader.expected index 1fb48bb01..af2fdf5d3 100644 --- a/src/test/correct/basic_function_call_reader/gcc_no_plt_no_pic/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/gcc_no_plt_no_pic/basic_function_call_reader.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -86,7 +86,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -95,13 +95,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -212,12 +212,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000909"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -233,12 +235,15 @@ procedure main() } goto l0000094e; l00000937: + assume {:captureState "l00000937"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); goto l00000943; l0000094e: + assume {:captureState "l0000094e"} true; R0, Gamma_R0 := 0bv64, true; goto l00000943; l00000943: + assume {:captureState "l00000943"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected b/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected index 581270f2d..fd8a35964 100644 --- a/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected +++ b/src/test/correct/basic_function_call_reader/gcc_pic/basic_function_call_reader.expected @@ -1,58 +1,58 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then (memory_load32_le(memory, $x_addr) == 1bv32) else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); @@ -110,7 +110,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); ensures (old(gamma_load32(Gamma_mem, $y_addr)) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); @@ -119,13 +119,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == 0bv32) ==> (memory_load32_le(mem, $x_addr) == 0bv32)); assert (gamma_load32(Gamma_mem, $y_addr) ==> ((memory_load32_le(mem, $x_addr) == 0bv32) || gamma_load32(Gamma_mem, $y_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -268,6 +268,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -275,6 +276,7 @@ procedure main() call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000305"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -291,12 +293,15 @@ procedure main() } goto l0000034b; l00000334: + assume {:captureState "l00000334"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); goto l00000340; l0000034b: + assume {:captureState "l0000034b"} true; R0, Gamma_R0 := 0bv64, true; goto l00000340; l00000340: + assume {:captureState "l00000340"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_lock_read/clang/basic_lock_read.expected b/src/test/correct/basic_lock_read/clang/basic_lock_read.expected index 48587af8a..3fe582cff 100644 --- a/src/test/correct/basic_lock_read/clang/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/clang/basic_lock_read.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -212,9 +212,12 @@ procedure main() var ZF: bv1; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000300"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -230,31 +233,39 @@ procedure main() } goto l00000330; l00000330: + assume {:captureState "l00000330"} true; R8, Gamma_R8 := 1bv64, true; goto l00000333; l0000032d: + assume {:captureState "l0000032d"} true; R8, Gamma_R8 := 0bv64, true; goto l00000333; l00000333: + assume {:captureState "l00000333"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000033b; } goto l00000352; l00000352: + assume {:captureState "l00000352"} true; goto l00000353; l00000353: + assume {:captureState "l00000353"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%00000360"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000036f"} true; goto l0000033b; l0000033b: + assume {:captureState "l0000033b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected b/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected index ec5eb6ff0..1a13cddb4 100644 --- a/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -189,6 +189,7 @@ procedure main() { var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -198,15 +199,18 @@ procedure main() } goto l000002f7; l000002dc: + assume {:captureState "l000002dc"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%000002eb"} true; R0, Gamma_R0 := 0bv64, true; return; l000002f7: + assume {:captureState "l000002f7"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_lock_read/clang_no_plt_no_pic/basic_lock_read.expected b/src/test/correct/basic_lock_read/clang_no_plt_no_pic/basic_lock_read.expected index 4de731f00..ad72f3b57 100644 --- a/src/test/correct/basic_lock_read/clang_no_plt_no_pic/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/clang_no_plt_no_pic/basic_lock_read.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -212,9 +212,12 @@ procedure main() var ZF: bv1; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000924"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%0000092b"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -230,31 +233,39 @@ procedure main() } goto l0000095b; l0000095b: + assume {:captureState "l0000095b"} true; R8, Gamma_R8 := 1bv64, true; goto l0000095e; l00000958: + assume {:captureState "l00000958"} true; R8, Gamma_R8 := 0bv64, true; goto l0000095e; l0000095e: + assume {:captureState "l0000095e"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000966; } goto l0000097d; l0000097d: + assume {:captureState "l0000097d"} true; goto l0000097e; l0000097e: + assume {:captureState "l0000097e"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%0000098b"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000099a"} true; goto l00000966; l00000966: + assume {:captureState "l00000966"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected b/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected index 9e4cd6a60..0655b008a 100644 --- a/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -111,7 +111,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -119,12 +119,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -268,9 +268,12 @@ procedure main() var ZF: bv1; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000301"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000308"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -288,20 +291,25 @@ procedure main() } goto l0000033f; l0000033f: + assume {:captureState "l0000033f"} true; R8, Gamma_R8 := 1bv64, true; goto l00000342; l0000033c: + assume {:captureState "l0000033c"} true; R8, Gamma_R8 := 0bv64, true; goto l00000342; l00000342: + assume {:captureState "l00000342"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000034a; } goto l00000361; l00000361: + assume {:captureState "l00000361"} true; goto l00000362; l00000362: + assume {:captureState "l00000362"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); @@ -310,11 +318,14 @@ procedure main() z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%00000376"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000385"} true; goto l0000034a; l0000034a: + assume {:captureState "l0000034a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected b/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected index 40b7ea84d..b5874be65 100644 --- a/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/gcc/basic_lock_read.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -93,12 +93,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -210,8 +210,10 @@ procedure main() var ZF: bv1; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -227,6 +229,7 @@ procedure main() } goto l0000033e; l0000033e: + assume {:captureState "l0000033e"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -234,13 +237,16 @@ procedure main() z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%0000034e"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000368"} true; goto l00000327; l00000327: + assume {:captureState "l00000327"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected b/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected index 783f51ff4..72aeca101 100644 --- a/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/gcc_O2/basic_lock_read.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -190,6 +190,7 @@ procedure main() { var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -200,13 +201,16 @@ procedure main() } goto l0000039c; l0000039c: + assume {:captureState "l0000039c"} true; call rely(); assert (L(mem, bvadd64(R1, 4bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 4bv64), true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%000003a1"} true; goto l000001bd; l000001bd: + assume {:captureState "l000001bd"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_lock_read/gcc_no_plt_no_pic/basic_lock_read.expected b/src/test/correct/basic_lock_read/gcc_no_plt_no_pic/basic_lock_read.expected index c5bb36bf7..4af98550b 100644 --- a/src/test/correct/basic_lock_read/gcc_no_plt_no_pic/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/gcc_no_plt_no_pic/basic_lock_read.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -93,12 +93,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -210,8 +210,10 @@ procedure main() var ZF: bv1; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000091a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -227,6 +229,7 @@ procedure main() } goto l0000095f; l0000095f: + assume {:captureState "l0000095f"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -234,13 +237,16 @@ procedure main() z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%0000096f"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000989"} true; goto l00000948; l00000948: + assume {:captureState "l00000948"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected b/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected index d1281a25c..4b06ef422 100644 --- a/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected +++ b/src/test/correct/basic_lock_read/gcc_pic/basic_lock_read.expected @@ -1,58 +1,58 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -117,12 +117,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -266,8 +266,10 @@ procedure main() var ZF: bv1; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -284,6 +286,7 @@ procedure main() } goto l0000033f; l0000033f: + assume {:captureState "l0000033f"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -292,14 +295,17 @@ procedure main() z_old := memory_load32_le(mem, $z_addr); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert (memory_load32_le(mem, $z_addr) == z_old); + assume {:captureState "%00000350"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000036b"} true; goto l00000328; l00000328: + assume {:captureState "l00000328"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected index 054ff067d..2aba48461 100644 --- a/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -210,9 +210,12 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%000002fc"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -228,26 +231,33 @@ procedure main() } goto l0000032c; l0000032c: + assume {:captureState "l0000032c"} true; R8, Gamma_R8 := 1bv64, true; goto l0000032f; l00000329: + assume {:captureState "l00000329"} true; R8, Gamma_R8 := 0bv64, true; goto l0000032f; l0000032f: + assume {:captureState "l0000032f"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000337; } goto l0000034e; l0000034e: + assume {:captureState "l0000034e"} true; goto l0000034f; l0000034f: + assume {:captureState "l0000034f"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000364"} true; goto l00000337; l00000337: + assume {:captureState "l00000337"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected index 4b2120254..ac7bd7571 100644 --- a/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -198,6 +198,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; call rely(); @@ -215,11 +216,14 @@ procedure main() } goto l000002fd; l000002fd: + assume {:captureState "l000002fd"} true; R0, Gamma_R0 := 0bv64, true; goto l00000300; l000002fa: + assume {:captureState "l000002fa"} true; R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; goto l00000300; l00000300: + assume {:captureState "l00000300"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/clang_no_plt_no_pic/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/clang_no_plt_no_pic/basic_lock_security_read.expected index 2c9690283..3fc858b76 100644 --- a/src/test/correct/basic_lock_security_read/clang_no_plt_no_pic/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/clang_no_plt_no_pic/basic_lock_security_read.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -210,9 +210,12 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000913"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%0000091a"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -228,26 +231,33 @@ procedure main() } goto l0000094a; l0000094a: + assume {:captureState "l0000094a"} true; R8, Gamma_R8 := 1bv64, true; goto l0000094d; l00000947: + assume {:captureState "l00000947"} true; R8, Gamma_R8 := 0bv64, true; goto l0000094d; l0000094d: + assume {:captureState "l0000094d"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000955; } goto l0000096c; l0000096c: + assume {:captureState "l0000096c"} true; goto l0000096d; l0000096d: + assume {:captureState "l0000096d"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000982"} true; goto l00000955; l00000955: + assume {:captureState "l00000955"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected index 7f918a986..695fc0d48 100644 --- a/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -111,7 +111,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -119,12 +119,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -266,9 +266,12 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002fd"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000304"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -286,28 +289,35 @@ procedure main() } goto l0000033b; l0000033b: + assume {:captureState "l0000033b"} true; R8, Gamma_R8 := 1bv64, true; goto l0000033e; l00000338: + assume {:captureState "l00000338"} true; R8, Gamma_R8 := 0bv64, true; goto l0000033e; l0000033e: + assume {:captureState "l0000033e"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000346; } goto l0000035d; l0000035d: + assume {:captureState "l0000035d"} true; goto l0000035e; l0000035e: + assume {:captureState "l0000035e"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000037a"} true; goto l00000346; l00000346: + assume {:captureState "l00000346"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected index 6c4e2abf7..9006b9cff 100644 --- a/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/gcc/basic_lock_security_read.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -93,12 +93,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -208,8 +208,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002ed"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -225,13 +227,16 @@ procedure main() } goto l00000332; l00000332: + assume {:captureState "l00000332"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000034a"} true; goto l0000031b; l0000031b: + assume {:captureState "l0000031b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected index c9e168021..e446b0b58 100644 --- a/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/gcc_O2/basic_lock_security_read.expected @@ -1,36 +1,36 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -71,7 +71,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -79,12 +79,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -182,6 +182,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R0, Gamma_R0 := 0bv64, true; @@ -193,9 +194,11 @@ procedure main() } goto l0000039c; l0000039c: + assume {:captureState "l0000039c"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); goto l000001c2; l000001c2: + assume {:captureState "l000001c2"} true; return; } diff --git a/src/test/correct/basic_lock_security_read/gcc_no_plt_no_pic/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/gcc_no_plt_no_pic/basic_lock_security_read.expected index df22d1f47..69a940ab5 100644 --- a/src/test/correct/basic_lock_security_read/gcc_no_plt_no_pic/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/gcc_no_plt_no_pic/basic_lock_security_read.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -93,12 +93,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -208,8 +208,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000008ea"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -225,13 +227,16 @@ procedure main() } goto l0000092f; l0000092f: + assume {:captureState "l0000092f"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000947"} true; goto l00000918; l00000918: + assume {:captureState "l00000918"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected b/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected index 15c247916..ad3910528 100644 --- a/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected +++ b/src/test/correct/basic_lock_security_read/gcc_pic/basic_lock_security_read.expected @@ -1,58 +1,58 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) && (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))))); { @@ -117,12 +117,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); @@ -264,8 +264,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002ed"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -282,14 +284,17 @@ procedure main() } goto l00000333; l00000333: + assume {:captureState "l00000333"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000034c"} true; goto l0000031c; l0000031c: + assume {:captureState "l0000031c"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected index 01ba754fc..f2f05a0b1 100644 --- a/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -91,12 +91,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -201,8 +201,10 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002ea"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; call rely(); @@ -213,6 +215,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002fc"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); @@ -223,6 +226,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000310"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> true); @@ -232,6 +236,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), true); assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000031c"} true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -240,6 +245,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000323"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected index 9fa7b521a..dd56def9f 100644 --- a/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -192,6 +192,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; @@ -203,6 +204,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002d6"} true; call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -211,5 +213,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), true); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002dd"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/clang_no_plt_no_pic/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/clang_no_plt_no_pic/basic_lock_security_write.expected index 01ba754fc..f38c4c74d 100644 --- a/src/test/correct/basic_lock_security_write/clang_no_plt_no_pic/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/clang_no_plt_no_pic/basic_lock_security_write.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -91,12 +91,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -201,8 +201,10 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000008c7"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; call rely(); @@ -213,6 +215,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000008d9"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); @@ -223,6 +226,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000008ed"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> true); @@ -232,6 +236,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), true); assert ((bvadd64(R9, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000008f9"} true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -240,6 +245,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), true); assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000900"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected index 3e954daf5..f99743610 100644 --- a/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -107,7 +107,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -115,12 +115,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -257,8 +257,10 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002f2"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -271,6 +273,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000030b"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := 65536bv64, true; call rely(); @@ -283,6 +286,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, R10[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R10); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000326"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, R9) ==> true); @@ -292,6 +296,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, 0bv32), gamma_store32(Gamma_mem, R9, true); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000332"} true; call rely(); assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -300,6 +305,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000339"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected index 7de8b70b1..ba5c4d59d 100644 --- a/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/gcc/basic_lock_security_write.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -87,12 +87,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -197,8 +197,10 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000302"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -210,6 +212,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000031a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); @@ -221,6 +224,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000334"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -231,6 +235,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000346"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -241,6 +246,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000358"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected index bd0c54c4c..4bbaa34c0 100644 --- a/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/gcc_O2/basic_lock_security_write.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -192,6 +192,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R0, Gamma_R0 := 0bv64, true; @@ -203,6 +204,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000001bd"} true; call rely(); assert (L(mem, bvadd64(R2, 4bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -211,5 +213,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), true); assert ((bvadd64(R2, 4bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000001c4"} true; return; } diff --git a/src/test/correct/basic_lock_security_write/gcc_no_plt_no_pic/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/gcc_no_plt_no_pic/basic_lock_security_write.expected index 7de8b70b1..b374205cf 100644 --- a/src/test/correct/basic_lock_security_write/gcc_no_plt_no_pic/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/gcc_no_plt_no_pic/basic_lock_security_write.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -87,12 +87,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -197,8 +197,10 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000925"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -210,6 +212,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000093d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); @@ -221,6 +224,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000957"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -231,6 +235,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000969"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -241,6 +246,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000097b"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected b/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected index 059e8c88a..cb4b9c8ca 100644 --- a/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected +++ b/src/test/correct/basic_lock_security_write/gcc_pic/basic_lock_security_write.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); @@ -103,7 +103,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))) && (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr)))); { @@ -111,12 +111,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)) && (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -253,8 +253,10 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000302"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -267,6 +269,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000031b"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -279,6 +282,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000336"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -290,6 +294,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000349"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -301,6 +306,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000035c"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected index aec6e1318..52936b563 100644 --- a/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -186,6 +186,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -194,6 +195,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002d6"} true; R8, Gamma_R8 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); @@ -202,5 +204,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e7"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/clang_O2/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/clang_O2/basic_lock_unlock.expected index 06cb29ce9..d052faebb 100644 --- a/src/test/correct/basic_lock_unlock/clang_O2/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/clang_O2/basic_lock_unlock.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -82,12 +82,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -188,6 +188,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; @@ -198,11 +199,13 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e0"} true; call rely(); assert (L(mem, bvadd64(R10, 56bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R10, 56bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e7"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/clang_no_plt_no_pic/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/clang_no_plt_no_pic/basic_lock_unlock.expected index aec6e1318..934a892e7 100644 --- a/src/test/correct/basic_lock_unlock/clang_no_plt_no_pic/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/clang_no_plt_no_pic/basic_lock_unlock.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -186,6 +186,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -194,6 +195,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000865"} true; R8, Gamma_R8 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); @@ -202,5 +204,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%00000876"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected index f065d4569..1b825317d 100644 --- a/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -96,7 +96,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -104,12 +104,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -242,6 +242,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); @@ -252,6 +253,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e5"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -262,5 +264,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002fd"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected index 0c3be857c..45c3f0f16 100644 --- a/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/gcc/basic_lock_unlock.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -184,6 +184,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -193,6 +194,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e4"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -201,6 +203,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002f6"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected index 1d13517fe..4bb063905 100644 --- a/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/gcc_O2/basic_lock_unlock.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R3: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R3: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -82,12 +82,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -188,6 +188,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R3, Gamma_R3 := 1bv64, true; @@ -198,11 +199,13 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R3); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000001c3"} true; call rely(); assert (L(mem, bvadd64(R2, 4bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000001ca"} true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc_no_plt_no_pic/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/gcc_no_plt_no_pic/basic_lock_unlock.expected index 0c3be857c..7de6a308f 100644 --- a/src/test/correct/basic_lock_unlock/gcc_no_plt_no_pic/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/gcc_no_plt_no_pic/basic_lock_unlock.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -184,6 +184,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -193,6 +194,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000088b"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -201,6 +203,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%0000089d"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected b/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected index d5fdbac2c..e7f59e5d7 100644 --- a/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected +++ b/src/test/correct/basic_lock_unlock/gcc_pic/basic_lock_unlock.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); { @@ -102,12 +102,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)))); @@ -240,6 +240,7 @@ procedure main() var x_old: bv32; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -250,6 +251,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002e5"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -259,6 +261,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((z_old == 0bv32) ==> ((memory_load32_le(mem, $x_addr) == x_old) && (memory_load32_le(mem, $z_addr) == z_old))); + assume {:captureState "%000002f8"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected index 509e77e86..1702ab871 100644 --- a/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -186,6 +186,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 20bv64, true; call rely(); @@ -193,6 +194,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002ce"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_loop_assign/clang_O2/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/clang_O2/basic_loop_assign.expected index 1321cd22f..8031b1142 100644 --- a/src/test/correct/basic_loop_assign/clang_O2/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/clang_O2/basic_loop_assign.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -186,6 +186,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 20bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -194,5 +195,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002d3"} true; return; } diff --git a/src/test/correct/basic_loop_assign/clang_no_plt_no_pic/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/clang_no_plt_no_pic/basic_loop_assign.expected index 509e77e86..45a841343 100644 --- a/src/test/correct/basic_loop_assign/clang_no_plt_no_pic/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/clang_no_plt_no_pic/basic_loop_assign.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -186,6 +186,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 20bv64, true; call rely(); @@ -193,6 +194,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%00000845"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected index d0fa27046..9c2937fd7 100644 --- a/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -88,7 +88,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -96,12 +96,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -218,6 +218,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); @@ -227,6 +228,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected index d2e9ce4b6..55d86092d 100644 --- a/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/gcc/basic_loop_assign.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -184,6 +184,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 20bv64, true; @@ -192,6 +193,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002d8"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected index 3b9101b12..8a5abed56 100644 --- a/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/gcc_O2/basic_loop_assign.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -186,6 +186,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := 20bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -194,5 +195,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000001bd"} true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc_no_plt_no_pic/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/gcc_no_plt_no_pic/basic_loop_assign.expected index d2e9ce4b6..406846cdd 100644 --- a/src/test/correct/basic_loop_assign/gcc_no_plt_no_pic/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/gcc_no_plt_no_pic/basic_loop_assign.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -184,6 +184,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 20bv64, true; @@ -192,6 +193,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%0000085b"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected b/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected index de1c11056..4296b2ef3 100644 --- a/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected +++ b/src/test/correct/basic_loop_assign/gcc_pic/basic_loop_assign.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsle"} bvsle32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvslt"} bvslt32(bv32, bv32) returns (bool); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); @@ -86,7 +86,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (((memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(old(memory_load32_le(mem, $x_addr)), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (old(memory_load32_le(mem, $x_addr)) == 20bv32))); { @@ -94,12 +94,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || (bvsle32(memory_load32_le(mem, $x_addr), 10bv32) && bvslt32(memory_load32_le(mem, $x_addr), 10bv32))) || ((memory_load32_le(mem, $x_addr) == 21bv32) && (memory_load32_le(mem, $x_addr) == 20bv32))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (memory_load32_le(mem, $x_addr) == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(memory_load32_le(mem, $x_addr), 10bv32))); @@ -216,6 +216,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -225,6 +226,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (((memory_load32_le(mem, $x_addr) == x_old) || ((memory_load32_le(mem, $x_addr) == 20bv32) && (x_old == 0bv32))) || ((memory_load32_le(mem, $x_addr) == 20bv32) && bvsle32(x_old, 10bv32))); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected index 68b3adfae..ae3f7c2f7 100644 --- a/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected @@ -1,64 +1,64 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1952bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); -function {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -99,7 +99,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -108,9 +108,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -219,28 +219,38 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000338"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R8); + assume {:captureState "%00000340"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000348"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000355"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000362"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := zero_extend32_32(bvxor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000037f"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); R8, Gamma_R8 := zero_extend32_32(bvor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000039c"} true; R8, Gamma_R8 := 30bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000003a9"} true; R8, Gamma_R8 := 17bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000003b6"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); assert Gamma_R10; @@ -249,12 +259,15 @@ procedure main() } goto l000003ce; l000003ce: + assume {:captureState "l000003ce"} true; R9, Gamma_R9 := zero_extend32_32(bvsdiv33(sign_extend1_32(R8[32:0]), sign_extend1_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R8); goto l000003d1; l000003c9: + assume {:captureState "l000003c9"} true; R9, Gamma_R9 := 0bv64, true; goto l000003d1; l000003d1: + assume {:captureState "l000003d1"} true; R9, Gamma_R9 := zero_extend32_32(bvmul64(zero_extend32_32(R9[32:0]), zero_extend32_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R9); #4, Gamma_#4 := bvnot32(R9[32:0]), Gamma_R9; #5, Gamma_#5 := bvadd32(R8[32:0], bvnot32(R9[32:0])), (Gamma_R9 && Gamma_R8); @@ -264,6 +277,7 @@ procedure main() NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; R8, Gamma_R8 := zero_extend32_32(bvadd32(#5, 1bv32)), Gamma_#5; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000407"} true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_operation_evaluation/clang_O2/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/clang_O2/basic_operation_evaluation.expected index 1e9764f80..b904c03a5 100644 --- a/src/test/correct/basic_operation_evaluation/clang_O2/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/clang_O2/basic_operation_evaluation.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1840bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_operation_evaluation/clang_no_plt_no_pic/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/clang_no_plt_no_pic/basic_operation_evaluation.expected index 30009c38c..c41cd5c12 100644 --- a/src/test/correct/basic_operation_evaluation/clang_no_plt_no_pic/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/clang_no_plt_no_pic/basic_operation_evaluation.expected @@ -1,64 +1,64 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1952bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); -function {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -99,7 +99,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -108,9 +108,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -219,28 +219,38 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000a1b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R8); + assume {:captureState "%00000a23"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000a2b"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000a38"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a45"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := zero_extend32_32(bvxor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000a62"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); R8, Gamma_R8 := zero_extend32_32(bvor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a7f"} true; R8, Gamma_R8 := 30bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000a8c"} true; R8, Gamma_R8 := 17bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a99"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); assert Gamma_R10; @@ -249,12 +259,15 @@ procedure main() } goto l00000ab1; l00000ab1: + assume {:captureState "l00000ab1"} true; R9, Gamma_R9 := zero_extend32_32(bvsdiv33(sign_extend1_32(R8[32:0]), sign_extend1_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R8); goto l00000ab4; l00000aac: + assume {:captureState "l00000aac"} true; R9, Gamma_R9 := 0bv64, true; goto l00000ab4; l00000ab4: + assume {:captureState "l00000ab4"} true; R9, Gamma_R9 := zero_extend32_32(bvmul64(zero_extend32_32(R9[32:0]), zero_extend32_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R9); #4, Gamma_#4 := bvnot32(R9[32:0]), Gamma_R9; #5, Gamma_#5 := bvadd32(R8[32:0], bvnot32(R9[32:0])), (Gamma_R9 && Gamma_R8); @@ -264,6 +277,7 @@ procedure main() NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; R8, Gamma_R8 := zero_extend32_32(bvadd32(#5, 1bv32)), Gamma_#5; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000aea"} true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_operation_evaluation/clang_pic/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/clang_pic/basic_operation_evaluation.expected index 30009c38c..c41cd5c12 100644 --- a/src/test/correct/basic_operation_evaluation/clang_pic/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/clang_pic/basic_operation_evaluation.expected @@ -1,64 +1,64 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1952bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); -function {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -99,7 +99,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -108,9 +108,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -219,28 +219,38 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; R8, Gamma_R8 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000a1b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R8); + assume {:captureState "%00000a23"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000a2b"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000a38"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a45"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := zero_extend32_32(bvxor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000a62"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); R8, Gamma_R8 := zero_extend32_32(bvor32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a7f"} true; R8, Gamma_R8 := 30bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000a8c"} true; R8, Gamma_R8 := 17bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a99"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); assert Gamma_R10; @@ -249,12 +259,15 @@ procedure main() } goto l00000ab1; l00000ab1: + assume {:captureState "l00000ab1"} true; R9, Gamma_R9 := zero_extend32_32(bvsdiv33(sign_extend1_32(R8[32:0]), sign_extend1_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R8); goto l00000ab4; l00000aac: + assume {:captureState "l00000aac"} true; R9, Gamma_R9 := 0bv64, true; goto l00000ab4; l00000ab4: + assume {:captureState "l00000ab4"} true; R9, Gamma_R9 := zero_extend32_32(bvmul64(zero_extend32_32(R9[32:0]), zero_extend32_32(R10[32:0]))[32:0]), (Gamma_R10 && Gamma_R9); #4, Gamma_#4 := bvnot32(R9[32:0]), Gamma_R9; #5, Gamma_#5 := bvadd32(R8[32:0], bvnot32(R9[32:0])), (Gamma_R9 && Gamma_R8); @@ -264,6 +277,7 @@ procedure main() NF, Gamma_NF := bvadd32(#5, 1bv32)[32:31], Gamma_#5; R8, Gamma_R8 := zero_extend32_32(bvadd32(#5, 1bv32)), Gamma_#5; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000aea"} true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected index 3d0958349..2689978a8 100644 --- a/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1948bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); -function {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -91,7 +91,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -100,9 +100,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,25 +199,34 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000032a"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%00000332"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%0000033f"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%0000034c"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R0, Gamma_R0 := zero_extend32_32(bvxor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000369"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := zero_extend32_32(bvor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000386"} true; R0, Gamma_R0 := 30bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%00000393"} true; R0, Gamma_R0 := 17bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%000003a0"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); assert Gamma_R1; @@ -226,16 +235,20 @@ procedure main() } goto l000003b8; l000003b8: + assume {:captureState "l000003b8"} true; R2, Gamma_R2 := zero_extend32_32(bvsdiv33(sign_extend1_32(R0[32:0]), sign_extend1_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R0); goto l000003bb; l000003b3: + assume {:captureState "l000003b3"} true; R2, Gamma_R2 := 0bv64, true; goto l000003bb; l000003bb: + assume {:captureState "l000003bb"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := zero_extend32_32(bvmul64(zero_extend32_32(R2[32:0]), zero_extend32_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R2); R0, Gamma_R0 := zero_extend32_32(bvadd32(bvadd32(R0[32:0], bvnot32(R1[32:0])), 1bv32)), (Gamma_R1 && Gamma_R0); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000003dc"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_operation_evaluation/gcc_O2/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/gcc_O2/basic_operation_evaluation.expected index ab48890b6..306991d20 100644 --- a/src/test/correct/basic_operation_evaluation/gcc_O2/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/gcc_O2/basic_operation_evaluation.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basic_operation_evaluation/gcc_no_plt_no_pic/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/gcc_no_plt_no_pic/basic_operation_evaluation.expected index 9612d9db9..dad30a297 100644 --- a/src/test/correct/basic_operation_evaluation/gcc_no_plt_no_pic/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/gcc_no_plt_no_pic/basic_operation_evaluation.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1948bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); -function {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -91,7 +91,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -100,9 +100,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,25 +199,34 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009e5"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%000009ed"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%000009fa"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a07"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R0, Gamma_R0 := zero_extend32_32(bvxor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000a24"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := zero_extend32_32(bvor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a41"} true; R0, Gamma_R0 := 30bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%00000a4e"} true; R0, Gamma_R0 := 17bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a5b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); assert Gamma_R1; @@ -226,16 +235,20 @@ procedure main() } goto l00000a73; l00000a73: + assume {:captureState "l00000a73"} true; R2, Gamma_R2 := zero_extend32_32(bvsdiv33(sign_extend1_32(R0[32:0]), sign_extend1_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R0); goto l00000a76; l00000a6e: + assume {:captureState "l00000a6e"} true; R2, Gamma_R2 := 0bv64, true; goto l00000a76; l00000a76: + assume {:captureState "l00000a76"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := zero_extend32_32(bvmul64(zero_extend32_32(R2[32:0]), zero_extend32_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R2); R0, Gamma_R0 := zero_extend32_32(bvadd32(bvadd32(R0[32:0], bvnot32(R1[32:0])), 1bv32)), (Gamma_R1 && Gamma_R0); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000a97"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_operation_evaluation/gcc_pic/basic_operation_evaluation.expected b/src/test/correct/basic_operation_evaluation/gcc_pic/basic_operation_evaluation.expected index 9612d9db9..dad30a297 100644 --- a/src/test/correct/basic_operation_evaluation/gcc_pic/basic_operation_evaluation.expected +++ b/src/test/correct/basic_operation_evaluation/gcc_pic/basic_operation_evaluation.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1948bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); -function {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvmul"} bvmul64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvnot"} bvnot32(bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvor"} bvor32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvsdiv"} bvsdiv33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvxor"} bvxor32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -91,7 +91,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -100,9 +100,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,25 +199,34 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009e5"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%000009ed"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%000009fa"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a07"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R0, Gamma_R0 := zero_extend32_32(bvxor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000a24"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := zero_extend32_32(bvor32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a41"} true; R0, Gamma_R0 := 30bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R0); + assume {:captureState "%00000a4e"} true; R0, Gamma_R0 := 17bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a5b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); assert Gamma_R1; @@ -226,16 +235,20 @@ procedure main() } goto l00000a73; l00000a73: + assume {:captureState "l00000a73"} true; R2, Gamma_R2 := zero_extend32_32(bvsdiv33(sign_extend1_32(R0[32:0]), sign_extend1_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R0); goto l00000a76; l00000a6e: + assume {:captureState "l00000a6e"} true; R2, Gamma_R2 := 0bv64, true; goto l00000a76; l00000a76: + assume {:captureState "l00000a76"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := zero_extend32_32(bvmul64(zero_extend32_32(R2[32:0]), zero_extend32_32(R1[32:0]))[32:0]), (Gamma_R1 && Gamma_R2); R0, Gamma_R0 := zero_extend32_32(bvadd32(bvadd32(R0[32:0], bvnot32(R1[32:0])), 1bv32)), (Gamma_R1 && Gamma_R0); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000a97"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected index 30140b76d..7a3d39208 100644 --- a/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -210,12 +210,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000309"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); @@ -231,23 +234,30 @@ procedure main() } goto l00000339; l00000339: + assume {:captureState "l00000339"} true; R8, Gamma_R8 := 1bv64, true; goto l0000033c; l00000336: + assume {:captureState "l00000336"} true; R8, Gamma_R8 := 0bv64, true; goto l0000033c; l0000033c: + assume {:captureState "l0000033c"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000344; } goto l0000035b; l0000035b: + assume {:captureState "l0000035b"} true; goto l0000035c; l0000035c: + assume {:captureState "l0000035c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000364"} true; goto l00000344; l00000344: + assume {:captureState "l00000344"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected index 999923f6d..60294d829 100644 --- a/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -198,6 +198,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; call rely(); @@ -215,11 +216,14 @@ procedure main() } goto l000002fd; l000002fd: + assume {:captureState "l000002fd"} true; R0, Gamma_R0 := 0bv64, true; goto l00000300; l000002fa: + assume {:captureState "l000002fa"} true; R0, Gamma_R0 := zero_extend32_32(R9[32:0]), Gamma_R9; goto l00000300; l00000300: + assume {:captureState "l00000300"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/clang_no_plt_no_pic/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/clang_no_plt_no_pic/basic_sec_policy_read.expected index 5f935e465..990413eb8 100644 --- a/src/test/correct/basic_sec_policy_read/clang_no_plt_no_pic/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/clang_no_plt_no_pic/basic_sec_policy_read.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -210,12 +210,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000913"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000927"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); @@ -231,23 +234,30 @@ procedure main() } goto l00000957; l00000957: + assume {:captureState "l00000957"} true; R8, Gamma_R8 := 1bv64, true; goto l0000095a; l00000954: + assume {:captureState "l00000954"} true; R8, Gamma_R8 := 0bv64, true; goto l0000095a; l0000095a: + assume {:captureState "l0000095a"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000962; } goto l00000979; l00000979: + assume {:captureState "l00000979"} true; goto l0000097a; l0000097a: + assume {:captureState "l0000097a"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000982"} true; goto l00000962; l00000962: + assume {:captureState "l00000962"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected index f2d986215..c9874d209 100644 --- a/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -111,7 +111,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -119,12 +119,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -266,14 +266,17 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002fd"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000318"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -291,23 +294,30 @@ procedure main() } goto l0000034f; l0000034f: + assume {:captureState "l0000034f"} true; R8, Gamma_R8 := 1bv64, true; goto l00000352; l0000034c: + assume {:captureState "l0000034c"} true; R8, Gamma_R8 := 0bv64, true; goto l00000352; l00000352: + assume {:captureState "l00000352"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000035a; } goto l00000371; l00000371: + assume {:captureState "l00000371"} true; goto l00000372; l00000372: + assume {:captureState "l00000372"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%0000037a"} true; goto l0000035a; l0000035a: + assume {:captureState "l0000035a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected index 6bbc9f13c..e2420795f 100644 --- a/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/gcc/basic_sec_policy_read.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -93,12 +93,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -208,12 +208,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000300"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -229,9 +231,12 @@ procedure main() } goto l00000345; l00000345: + assume {:captureState "l00000345"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000034a"} true; goto l0000032e; l0000032e: + assume {:captureState "l0000032e"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected index afd185b0e..ee799a4b7 100644 --- a/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/gcc_O2/basic_sec_policy_read.expected @@ -1,36 +1,36 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -71,7 +71,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -79,12 +79,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -182,6 +182,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R0, Gamma_R0 := 0bv64, true; @@ -193,9 +194,11 @@ procedure main() } goto l0000039c; l0000039c: + assume {:captureState "l0000039c"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R2, 4bv64))), (gamma_load32(Gamma_mem, bvadd64(R2, 4bv64)) || L(mem, bvadd64(R2, 4bv64))); goto l000001c2; l000001c2: + assume {:captureState "l000001c2"} true; return; } diff --git a/src/test/correct/basic_sec_policy_read/gcc_no_plt_no_pic/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/gcc_no_plt_no_pic/basic_sec_policy_read.expected index 9519b3247..440392f1e 100644 --- a/src/test/correct/basic_sec_policy_read/gcc_no_plt_no_pic/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/gcc_no_plt_no_pic/basic_sec_policy_read.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -93,12 +93,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -208,12 +208,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000008fd"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -229,9 +231,12 @@ procedure main() } goto l00000942; l00000942: + assume {:captureState "l00000942"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000947"} true; goto l0000092b; l0000092b: + assume {:captureState "l0000092b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected b/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected index cf41554ac..30ee05d48 100644 --- a/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected +++ b/src/test/correct/basic_sec_policy_read/gcc_pic/basic_sec_policy_read.expected @@ -1,58 +1,58 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $z_addr)) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); { @@ -117,12 +117,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); @@ -264,6 +264,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -271,6 +272,7 @@ procedure main() call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000301"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -287,9 +289,12 @@ procedure main() } goto l00000347; l00000347: + assume {:captureState "l00000347"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000034c"} true; goto l00000330; l00000330: + assume {:captureState "l00000330"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected index b76307c3e..201b37eeb 100644 --- a/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -91,12 +91,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -199,8 +199,10 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002ee"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -210,6 +212,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000300"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R8, Gamma_R8 := 69632bv64, true; call rely(); @@ -219,6 +222,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000314"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> true); @@ -227,6 +231,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000320"} true; R8, Gamma_R8 := 2bv64, true; call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); @@ -235,6 +240,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000032d"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected index e11ed4e91..9dac0c99a 100644 --- a/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -78,7 +78,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -86,12 +86,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -192,6 +192,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; @@ -203,6 +204,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%000002df"} true; call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); @@ -210,5 +212,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R10); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%000002e7"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/clang_no_plt_no_pic/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/clang_no_plt_no_pic/basic_sec_policy_write.expected index b76307c3e..bf97d9983 100644 --- a/src/test/correct/basic_sec_policy_write/clang_no_plt_no_pic/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/clang_no_plt_no_pic/basic_sec_policy_write.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -91,12 +91,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -199,8 +199,10 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000008d7"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -210,6 +212,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%000008e9"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R8, Gamma_R8 := 69632bv64, true; call rely(); @@ -219,6 +222,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%000008fd"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> true); @@ -227,6 +231,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); assert ((bvadd64(R8, 56bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000909"} true; R8, Gamma_R8 := 2bv64, true; call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); @@ -235,6 +240,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000916"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected index e890cce75..36ab6f168 100644 --- a/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -107,7 +107,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -115,12 +115,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -255,8 +255,10 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002f6"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4032bv64)) || L(mem, bvadd64(R9, 4032bv64))); @@ -268,6 +270,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000030f"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R8, Gamma_R8 := 65536bv64, true; call rely(); @@ -279,6 +282,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000032a"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, R8) ==> true); @@ -287,6 +291,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000336"} true; R8, Gamma_R8 := 2bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); @@ -295,6 +300,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000343"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected index 66696d8c5..e1602790f 100644 --- a/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/gcc/basic_sec_policy_write.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -87,12 +87,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -195,8 +195,10 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000306"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -207,6 +209,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000031e"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); @@ -217,6 +220,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000338"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -226,6 +230,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000034a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 2bv64, true; @@ -236,6 +241,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000362"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected index 10df92113..08c116932 100644 --- a/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/gcc_O2/basic_sec_policy_write.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R3: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R3: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -78,7 +78,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -86,12 +86,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -192,6 +192,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R3, Gamma_R3 := 2bv64, true; @@ -203,6 +204,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%000001c2"} true; call rely(); assert (L(mem, bvadd64(R2, 4bv64)) ==> Gamma_R3); z_old := memory_load32_le(mem, $z_addr); @@ -210,5 +212,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), Gamma_R3); assert ((bvadd64(R2, 4bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%000001ca"} true; return; } diff --git a/src/test/correct/basic_sec_policy_write/gcc_no_plt_no_pic/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/gcc_no_plt_no_pic/basic_sec_policy_write.expected index 66696d8c5..959c60219 100644 --- a/src/test/correct/basic_sec_policy_write/gcc_no_plt_no_pic/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/gcc_no_plt_no_pic/basic_sec_policy_write.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -87,12 +87,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -195,8 +195,10 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000935"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -207,6 +209,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000094d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); @@ -217,6 +220,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000967"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -226,6 +230,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000979"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 2bv64, true; @@ -236,6 +241,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000991"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected b/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected index 09c819a7c..1fd3aca8c 100644 --- a/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected +++ b/src/test/correct/basic_sec_policy_write/gcc_pic/basic_sec_policy_write.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); @@ -103,7 +103,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr)); { @@ -111,12 +111,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $z_addr) != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); @@ -251,8 +251,10 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000306"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -264,6 +266,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000031f"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -275,6 +278,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000033a"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -285,6 +289,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%0000034d"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -296,6 +301,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert ((z_old != 0bv32) ==> (memory_load32_le(mem, $z_addr) != 0bv32)); + assume {:captureState "%00000366"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected index baee5b809..4fd51f050 100644 --- a/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -186,6 +186,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -193,6 +194,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basicassign_gamma0/clang_O2/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/clang_O2/basicassign_gamma0.expected index 6d0a174ca..0a66841bf 100644 --- a/src/test/correct/basicassign_gamma0/clang_O2/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/clang_O2/basicassign_gamma0.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -186,6 +186,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -194,5 +195,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002de"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/clang_no_plt_no_pic/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/clang_no_plt_no_pic/basicassign_gamma0.expected index baee5b809..2a980ae8e 100644 --- a/src/test/correct/basicassign_gamma0/clang_no_plt_no_pic/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/clang_no_plt_no_pic/basicassign_gamma0.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -186,6 +186,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -193,6 +194,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%0000085d"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected index 491b1c61f..49233a65d 100644 --- a/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -101,7 +101,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -109,12 +109,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -242,6 +242,7 @@ procedure main() free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); @@ -253,6 +254,7 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000002ef"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected index fe708ccc7..61c06314d 100644 --- a/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/gcc/basicassign_gamma0.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -83,12 +83,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -184,6 +184,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -193,6 +194,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000002ed"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected index d6b06580d..80ca6e118 100644 --- a/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/gcc_O2/basicassign_gamma0.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -186,6 +186,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R0, Gamma_R0 := 0bv64, true; @@ -194,5 +195,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc_no_plt_no_pic/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/gcc_no_plt_no_pic/basicassign_gamma0.expected index fe708ccc7..f64a19b05 100644 --- a/src/test/correct/basicassign_gamma0/gcc_no_plt_no_pic/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/gcc_no_plt_no_pic/basicassign_gamma0.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -83,12 +83,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -184,6 +184,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -193,6 +194,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000889"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected b/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected index 705b6a46c..640aca070 100644 --- a/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected +++ b/src/test/correct/basicassign_gamma0/gcc_pic/basicassign_gamma0.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69656bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); @@ -99,7 +99,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $secret_addr) == old(memory_load32_le(mem, $secret_addr))); { @@ -107,12 +107,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $secret_addr) == memory_load32_le(mem, $secret_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -240,6 +240,7 @@ procedure main() free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -251,6 +252,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000002ef"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/basicfree/clang/basicfree.expected b/src/test/correct/basicfree/clang/basicfree.expected index 12202cbfb..726176432 100644 --- a/src/test/correct/basicfree/clang/basicfree.expected +++ b/src/test/correct/basicfree/clang/basicfree.expected @@ -1,59 +1,59 @@ -var Gamma_R0: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2080bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69694bv64) == 0bv8); free ensures (memory_load8_le(mem, 69695bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,9 +103,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -283,27 +283,34 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f2"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002f8"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2024bv64, true; call malloc(); goto l0000030d; l0000030d: + assume {:captureState "l0000030d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000313"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 1bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000327"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2048bv64, true; call #free(); goto l00000338; l00000338: + assume {:captureState "l00000338"} true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); diff --git a/src/test/correct/basicfree/clang_O2/basicfree.expected b/src/test/correct/basicfree/clang_O2/basicfree.expected index 8637d2c74..ae43ad872 100644 --- a/src/test/correct/basicfree/clang_O2/basicfree.expected +++ b/src/test/correct/basicfree/clang_O2/basicfree.expected @@ -1,12 +1,12 @@ -var Gamma_mem: [bv64]bool; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1836bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -47,7 +47,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -56,9 +56,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -152,5 +152,6 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; return; } diff --git a/src/test/correct/basicfree/clang_no_plt_no_pic/basicfree.expected b/src/test/correct/basicfree/clang_no_plt_no_pic/basicfree.expected index f78216dd1..76c2aa03f 100644 --- a/src/test/correct/basicfree/clang_no_plt_no_pic/basicfree.expected +++ b/src/test/correct/basicfree/clang_no_plt_no_pic/basicfree.expected @@ -1,59 +1,59 @@ -var Gamma_R0: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2080bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69694bv64) == 0bv8); free ensures (memory_load8_le(mem, 69695bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,9 +103,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -283,27 +283,34 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008d2"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008d8"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2024bv64, true; call malloc(); goto l000008ed; l000008ed: + assume {:captureState "l000008ed"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000008f3"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 1bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000907"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2048bv64, true; call #free(); goto l00000918; l00000918: + assume {:captureState "l00000918"} true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); diff --git a/src/test/correct/basicfree/clang_pic/basicfree.expected b/src/test/correct/basicfree/clang_pic/basicfree.expected index f78216dd1..76c2aa03f 100644 --- a/src/test/correct/basicfree/clang_pic/basicfree.expected +++ b/src/test/correct/basicfree/clang_pic/basicfree.expected @@ -1,59 +1,59 @@ -var Gamma_R0: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2080bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69694bv64) == 0bv8); free ensures (memory_load8_le(mem, 69695bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,9 +103,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -283,27 +283,34 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008d2"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008d8"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2024bv64, true; call malloc(); goto l000008ed; l000008ed: + assume {:captureState "l000008ed"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000008f3"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 1bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000907"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2048bv64, true; call #free(); goto l00000918; l00000918: + assume {:captureState "l00000918"} true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#5, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#5, 8bv64)); diff --git a/src/test/correct/basicfree/gcc/basicfree.expected b/src/test/correct/basicfree/gcc/basicfree.expected index 200f0b0ab..0abdad17b 100644 --- a/src/test/correct/basicfree/gcc/basicfree.expected +++ b/src/test/correct/basicfree/gcc/basicfree.expected @@ -1,57 +1,57 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2076bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -101,9 +101,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -279,9 +279,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002e8"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002ee"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 4bv64, true; @@ -289,17 +292,21 @@ procedure main() call malloc(); goto l00000307; l00000307: + assume {:captureState "l00000307"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%0000030d"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000321"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 2044bv64, true; call #free(); goto l00000332; l00000332: + assume {:captureState "l00000332"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; diff --git a/src/test/correct/basicfree/gcc_O2/basicfree.expected b/src/test/correct/basicfree/gcc_O2/basicfree.expected index a86190f67..f96261171 100644 --- a/src/test/correct/basicfree/gcc_O2/basicfree.expected +++ b/src/test/correct/basicfree/gcc_O2/basicfree.expected @@ -1,12 +1,12 @@ -var Gamma_mem: [bv64]bool; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -47,7 +47,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -56,9 +56,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -152,5 +152,6 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; return; } diff --git a/src/test/correct/basicfree/gcc_no_plt_no_pic/basicfree.expected b/src/test/correct/basicfree/gcc_no_plt_no_pic/basicfree.expected index d248004cb..07b9f0233 100644 --- a/src/test/correct/basicfree/gcc_no_plt_no_pic/basicfree.expected +++ b/src/test/correct/basicfree/gcc_no_plt_no_pic/basicfree.expected @@ -1,57 +1,57 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2076bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -101,9 +101,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -279,9 +279,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008bd"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008c3"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 4bv64, true; @@ -289,17 +292,21 @@ procedure main() call malloc(); goto l000008dc; l000008dc: + assume {:captureState "l000008dc"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%000008e2"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000008f6"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 2044bv64, true; call #free(); goto l00000907; l00000907: + assume {:captureState "l00000907"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; diff --git a/src/test/correct/basicfree/gcc_pic/basicfree.expected b/src/test/correct/basicfree/gcc_pic/basicfree.expected index d248004cb..07b9f0233 100644 --- a/src/test/correct/basicfree/gcc_pic/basicfree.expected +++ b/src/test/correct/basicfree/gcc_pic/basicfree.expected @@ -1,57 +1,57 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2076bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -101,9 +101,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -279,9 +279,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008bd"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008c3"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 4bv64, true; @@ -289,17 +292,21 @@ procedure main() call malloc(); goto l000008dc; l000008dc: + assume {:captureState "l000008dc"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%000008e2"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000008f6"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 2044bv64, true; call #free(); goto l00000907; l00000907: + assume {:captureState "l00000907"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; diff --git a/src/test/correct/cjump/clang/cjump.expected b/src/test/correct/cjump/clang/cjump.expected index a17542801..fabe193c7 100644 --- a/src/test/correct/cjump/clang/cjump.expected +++ b/src/test/correct/cjump/clang/cjump.expected @@ -1,54 +1,54 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -89,7 +89,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -98,9 +98,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -209,13 +209,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000309"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%0000031b"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; @@ -230,34 +233,43 @@ procedure main() } goto l00000346; l00000346: + assume {:captureState "l00000346"} true; R8, Gamma_R8 := 1bv64, true; goto l00000349; l00000343: + assume {:captureState "l00000343"} true; R8, Gamma_R8 := 0bv64, true; goto l00000349; l00000349: + assume {:captureState "l00000349"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000351; } goto l0000037e; l00000351: + assume {:captureState "l00000351"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 2bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%00000366"} true; goto l00000369; l0000037e: + assume {:captureState "l0000037e"} true; goto l0000037f; l0000037f: + assume {:captureState "l0000037f"} true; R8, Gamma_R8 := 3bv64, true; R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%00000392"} true; goto l00000369; l00000369: + assume {:captureState "l00000369"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/cjump/clang_O2/cjump.expected b/src/test/correct/cjump/clang_O2/cjump.expected index 170c6ac8d..d3e291679 100644 --- a/src/test/correct/cjump/clang_O2/cjump.expected +++ b/src/test/correct/cjump/clang_O2/cjump.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -85,9 +85,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -184,6 +184,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; @@ -192,8 +193,10 @@ procedure main() call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%000002e9"} true; call rely(); assert (L(mem, bvadd64(R10, 56bv64)) ==> Gamma_R11); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 56bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 56bv64), Gamma_R11); + assume {:captureState "%000002f1"} true; return; } diff --git a/src/test/correct/cjump/clang_no_plt_no_pic/cjump.expected b/src/test/correct/cjump/clang_no_plt_no_pic/cjump.expected index f0d4e8e44..55f0aa5e5 100644 --- a/src/test/correct/cjump/clang_no_plt_no_pic/cjump.expected +++ b/src/test/correct/cjump/clang_no_plt_no_pic/cjump.expected @@ -1,54 +1,54 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -89,7 +89,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -98,9 +98,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -209,13 +209,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000095f"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%00000971"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; @@ -230,34 +233,43 @@ procedure main() } goto l0000099c; l0000099c: + assume {:captureState "l0000099c"} true; R8, Gamma_R8 := 1bv64, true; goto l0000099f; l00000999: + assume {:captureState "l00000999"} true; R8, Gamma_R8 := 0bv64, true; goto l0000099f; l0000099f: + assume {:captureState "l0000099f"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000009a7; } goto l000009d4; l000009a7: + assume {:captureState "l000009a7"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 2bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000009bc"} true; goto l000009bf; l000009d4: + assume {:captureState "l000009d4"} true; goto l000009d5; l000009d5: + assume {:captureState "l000009d5"} true; R8, Gamma_R8 := 3bv64, true; R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000009e8"} true; goto l000009bf; l000009bf: + assume {:captureState "l000009bf"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/cjump/clang_pic/cjump.expected b/src/test/correct/cjump/clang_pic/cjump.expected index f7afa4a8a..cf22bf2b8 100644 --- a/src/test/correct/cjump/clang_pic/cjump.expected +++ b/src/test/correct/cjump/clang_pic/cjump.expected @@ -1,62 +1,62 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -113,7 +113,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -122,9 +122,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -265,8 +265,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000315"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -274,6 +276,7 @@ procedure main() call rely(); assert (L(mem, R8) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "%0000032e"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; @@ -288,18 +291,22 @@ procedure main() } goto l00000359; l00000359: + assume {:captureState "l00000359"} true; R8, Gamma_R8 := 1bv64, true; goto l0000035c; l00000356: + assume {:captureState "l00000356"} true; R8, Gamma_R8 := 0bv64, true; goto l0000035c; l0000035c: + assume {:captureState "l0000035c"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000364; } goto l00000398; l00000364: + assume {:captureState "l00000364"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); @@ -307,10 +314,13 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000380"} true; goto l00000383; l00000398: + assume {:captureState "l00000398"} true; goto l00000399; l00000399: + assume {:captureState "l00000399"} true; R8, Gamma_R8 := 3bv64, true; R9, Gamma_R9 := 65536bv64, true; call rely(); @@ -318,8 +328,10 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003b3"} true; goto l00000383; l00000383: + assume {:captureState "l00000383"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/cjump/gcc/cjump.expected b/src/test/correct/cjump/gcc/cjump.expected index 3cade154e..8c4250ee0 100644 --- a/src/test/correct/cjump/gcc/cjump.expected +++ b/src/test/correct/cjump/gcc/cjump.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,9 +92,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -201,12 +201,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000310"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -222,22 +224,27 @@ procedure main() } goto l00000365; l0000033e: + assume {:captureState "l0000033e"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 2bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000359"} true; goto l0000035b; l00000365: + assume {:captureState "l00000365"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 3bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037b"} true; goto l0000035b; l0000035b: + assume {:captureState "l0000035b"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/cjump/gcc_O2/cjump.expected b/src/test/correct/cjump/gcc_O2/cjump.expected index 5fb2db688..a280e9d8a 100644 --- a/src/test/correct/cjump/gcc_O2/cjump.expected +++ b/src/test/correct/cjump/gcc_O2/cjump.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R3: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R3: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -83,9 +83,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -182,6 +182,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; R3, Gamma_R3 := 1bv64, true; @@ -189,9 +190,11 @@ procedure main() call rely(); assert (L(mem, bvadd64(R0, 20bv64)) ==> Gamma_R3); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 20bv64), Gamma_R3); + assume {:captureState "%000001c3"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R1, 4bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 4bv64), Gamma_R2); + assume {:captureState "%000001d0"} true; return; } diff --git a/src/test/correct/cjump/gcc_no_plt_no_pic/cjump.expected b/src/test/correct/cjump/gcc_no_plt_no_pic/cjump.expected index 9cb62b9bb..6bac2205c 100644 --- a/src/test/correct/cjump/gcc_no_plt_no_pic/cjump.expected +++ b/src/test/correct/cjump/gcc_no_plt_no_pic/cjump.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,9 +92,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -201,12 +201,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000094e"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -222,22 +224,27 @@ procedure main() } goto l000009a3; l0000097c: + assume {:captureState "l0000097c"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 2bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000997"} true; goto l00000999; l000009a3: + assume {:captureState "l000009a3"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 3bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000009b9"} true; goto l00000999; l00000999: + assume {:captureState "l00000999"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/cjump/gcc_pic/cjump.expected b/src/test/correct/cjump/gcc_pic/cjump.expected index 54c34667c..5b1dca745 100644 --- a/src/test/correct/cjump/gcc_pic/cjump.expected +++ b/src/test/correct/cjump/gcc_pic/cjump.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -107,7 +107,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -116,9 +116,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -257,6 +257,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -264,6 +265,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000311"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -280,6 +282,7 @@ procedure main() } goto l00000368; l00000340: + assume {:captureState "l00000340"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -287,8 +290,10 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000035c"} true; goto l0000035e; l00000368: + assume {:captureState "l00000368"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -296,8 +301,10 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037f"} true; goto l0000035e; l0000035e: + assume {:captureState "l0000035e"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/function/clang/function.expected b/src/test/correct/function/clang/function.expected index c61514f51..5f0453715 100644 --- a/src/test/correct/function/clang/function.expected +++ b/src/test/correct/function/clang/function.expected @@ -1,61 +1,61 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -96,7 +96,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -105,9 +105,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -187,6 +187,7 @@ procedure get_two() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R0, Gamma_R0 := 2bv64, true; return; } @@ -291,9 +292,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008db"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008e1"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R9, Gamma_R9 := 69632bv64, true; @@ -301,14 +305,17 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%000008fd"} true; R30, Gamma_R30 := 1836bv64, true; call get_two(); goto l00000910; l00000910: + assume {:captureState "l00000910"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R0); + assume {:captureState "%0000091b"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function/clang_O2/function.expected b/src/test/correct/function/clang_O2/function.expected index 9303fc01f..fd677be34 100644 --- a/src/test/correct/function/clang_O2/function.expected +++ b/src/test/correct/function/clang_O2/function.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -85,9 +85,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -184,6 +184,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; @@ -192,8 +193,10 @@ procedure main() call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%000002f1"} true; call rely(); assert (L(mem, bvadd64(R10, 56bv64)) ==> Gamma_R11); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 56bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 56bv64), Gamma_R11); + assume {:captureState "%000002f9"} true; return; } diff --git a/src/test/correct/function/clang_no_plt_no_pic/function.expected b/src/test/correct/function/clang_no_plt_no_pic/function.expected index c61514f51..5f0453715 100644 --- a/src/test/correct/function/clang_no_plt_no_pic/function.expected +++ b/src/test/correct/function/clang_no_plt_no_pic/function.expected @@ -1,61 +1,61 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -96,7 +96,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -105,9 +105,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -187,6 +187,7 @@ procedure get_two() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R0, Gamma_R0 := 2bv64, true; return; } @@ -291,9 +292,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008db"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008e1"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R9, Gamma_R9 := 69632bv64, true; @@ -301,14 +305,17 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%000008fd"} true; R30, Gamma_R30 := 1836bv64, true; call get_two(); goto l00000910; l00000910: + assume {:captureState "l00000910"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R0); + assume {:captureState "%0000091b"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function/clang_pic/function.expected b/src/test/correct/function/clang_pic/function.expected index bcd55e2bb..3937a0029 100644 --- a/src/test/correct/function/clang_pic/function.expected +++ b/src/test/correct/function/clang_pic/function.expected @@ -1,61 +1,61 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -112,7 +112,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -121,9 +121,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -235,6 +235,7 @@ procedure get_two() free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R0, Gamma_R0 := 2bv64, true; return; } @@ -371,9 +372,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f0"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002f6"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R9, Gamma_R9 := 65536bv64, true; @@ -383,16 +387,19 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000319"} true; R30, Gamma_R30 := 1904bv64, true; call get_two(); goto l0000032c; l0000032c: + assume {:captureState "l0000032c"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); assert (L(mem, R8) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, R8, R0[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R0); + assume {:captureState "%0000033e"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function/gcc/function.expected b/src/test/correct/function/gcc/function.expected index a475b42d0..81e902be8 100644 --- a/src/test/correct/function/gcc/function.expected +++ b/src/test/correct/function/gcc/function.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -95,7 +95,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -104,9 +104,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -186,6 +186,7 @@ procedure get_two() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R0, Gamma_R0 := 2bv64, true; return; } @@ -290,9 +291,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000090b"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000911"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 69632bv64, true; @@ -301,16 +305,19 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000933"} true; R30, Gamma_R30 := 1840bv64, true; call get_two(); goto l00000946; l00000946: + assume {:captureState "l00000946"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000095d"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function/gcc_O2/function.expected b/src/test/correct/function/gcc_O2/function.expected index 0131820aa..d1f3a9437 100644 --- a/src/test/correct/function/gcc_O2/function.expected +++ b/src/test/correct/function/gcc_O2/function.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R3: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R3: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -83,9 +83,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -182,6 +182,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R1, Gamma_R1 := bvadd64(R0, 20bv64), Gamma_R0; R3, Gamma_R3 := 1bv64, true; @@ -189,9 +190,11 @@ procedure main() call rely(); assert (L(mem, bvadd64(R0, 20bv64)) ==> Gamma_R3); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 20bv64), Gamma_R3); + assume {:captureState "%000001d7"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R1, 4bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 4bv64), Gamma_R2); + assume {:captureState "%000001e4"} true; return; } diff --git a/src/test/correct/function/gcc_no_plt_no_pic/function.expected b/src/test/correct/function/gcc_no_plt_no_pic/function.expected index a475b42d0..81e902be8 100644 --- a/src/test/correct/function/gcc_no_plt_no_pic/function.expected +++ b/src/test/correct/function/gcc_no_plt_no_pic/function.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -95,7 +95,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -104,9 +104,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -186,6 +186,7 @@ procedure get_two() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R0, Gamma_R0 := 2bv64, true; return; } @@ -290,9 +291,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000090b"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000911"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 69632bv64, true; @@ -301,16 +305,19 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000933"} true; R30, Gamma_R30 := 1840bv64, true; call get_two(); goto l00000946; l00000946: + assume {:captureState "l00000946"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000095d"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function/gcc_pic/function.expected b/src/test/correct/function/gcc_pic/function.expected index 20ca626e6..ecdb2f43c 100644 --- a/src/test/correct/function/gcc_pic/function.expected +++ b/src/test/correct/function/gcc_pic/function.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -111,7 +111,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -120,9 +120,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -234,6 +234,7 @@ procedure get_two() free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R0, Gamma_R0 := 2bv64, true; return; } @@ -370,9 +371,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002fa"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 65536bv64, true; @@ -382,10 +386,12 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000031d"} true; R30, Gamma_R30 := 1904bv64, true; call get_two(); goto l00000330; l00000330: + assume {:captureState "l00000330"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -393,6 +399,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000348"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/clang/function1.expected b/src/test/correct/function1/clang/function1.expected index 209b36c74..22620843f 100644 --- a/src/test/correct/function1/clang/function1.expected +++ b/src/test/correct/function1/clang/function1.expected @@ -1,91 +1,91 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2024bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -130,7 +130,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -139,9 +139,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -230,10 +230,14 @@ procedure get_two() free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%00000336"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%0000033e"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%00000346"} true; R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R9, Gamma_R9 := zero_extend32_32(bvadd32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); @@ -350,9 +354,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000386"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000038c"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R9, Gamma_R9 := 69632bv64, true; @@ -360,6 +367,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "%000003a8"} true; R0, Gamma_R0 := 97bv64, true; R1, Gamma_R1 := 10bv64, true; R2, Gamma_R2 := 58368bv64, true; @@ -369,10 +377,12 @@ procedure main() call get_two(); goto l000003ce; l000003ce: + assume {:captureState "l000003ce"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 64bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 64bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 64bv64), Gamma_R0); + assume {:captureState "%000003d9"} true; call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); R0, Gamma_R0 := 0bv64, true; @@ -381,6 +391,7 @@ procedure main() call printf(); goto l000003f5; l000003f5: + assume {:captureState "l000003f5"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/clang_O2/function1.expected b/src/test/correct/function1/clang_O2/function1.expected index b5fb16057..bddeefebb 100644 --- a/src/test/correct/function1/clang_O2/function1.expected +++ b/src/test/correct/function1/clang_O2/function1.expected @@ -1,70 +1,70 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R10: bv64; -var R11: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1976bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -118,9 +118,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -229,9 +229,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000317"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000031d"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R11, Gamma_R11 := 58475bv64, true; @@ -246,13 +249,16 @@ procedure main() call rely(); assert (L(mem, bvadd64(R8, 60bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), Gamma_R9); + assume {:captureState "%0000035f"} true; call rely(); assert (L(mem, bvadd64(R10, 64bv64)) ==> Gamma_R11); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 64bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 64bv64), Gamma_R11); + assume {:captureState "%00000367"} true; R30, Gamma_R30 := 1944bv64, true; call printf(); goto l00000371; l00000371: + assume {:captureState "l00000371"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/clang_no_plt_no_pic/function1.expected b/src/test/correct/function1/clang_no_plt_no_pic/function1.expected index a2b338593..aa6caaf17 100644 --- a/src/test/correct/function1/clang_no_plt_no_pic/function1.expected +++ b/src/test/correct/function1/clang_no_plt_no_pic/function1.expected @@ -1,91 +1,91 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2024bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -130,7 +130,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -139,9 +139,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -230,10 +230,14 @@ procedure get_two() free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%00000a47"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%00000a4f"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%00000a57"} true; R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R9, Gamma_R9 := zero_extend32_32(bvadd32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); @@ -350,9 +354,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000a97"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000a9d"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R9, Gamma_R9 := 69632bv64, true; @@ -360,6 +367,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "%00000ab9"} true; R0, Gamma_R0 := 97bv64, true; R1, Gamma_R1 := 10bv64, true; R2, Gamma_R2 := 58368bv64, true; @@ -369,10 +377,12 @@ procedure main() call get_two(); goto l00000adf; l00000adf: + assume {:captureState "l00000adf"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 64bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 64bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 64bv64), Gamma_R0); + assume {:captureState "%00000aea"} true; call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); R0, Gamma_R0 := 0bv64, true; @@ -381,6 +391,7 @@ procedure main() call printf(); goto l00000b06; l00000b06: + assume {:captureState "l00000b06"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/clang_pic/function1.expected b/src/test/correct/function1/clang_pic/function1.expected index e0f10770f..2c77c2294 100644 --- a/src/test/correct/function1/clang_pic/function1.expected +++ b/src/test/correct/function1/clang_pic/function1.expected @@ -1,91 +1,91 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2096bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 32"} sign_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -146,7 +146,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69590bv64) == 0bv8); free ensures (memory_load8_le(mem, 69591bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -155,9 +155,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -278,10 +278,14 @@ procedure get_two() free ensures (memory_load8_le(mem, 69591bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000033e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%00000346"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%0000034e"} true; R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R9, Gamma_R9 := zero_extend32_32(bvadd32(R8[32:0], R9[32:0])), (Gamma_R9 && Gamma_R8); @@ -430,9 +434,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000038e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000394"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R9, Gamma_R9 := 65536bv64, true; @@ -442,6 +449,7 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003b7"} true; R0, Gamma_R0 := 97bv64, true; R1, Gamma_R1 := 10bv64, true; R2, Gamma_R2 := 58368bv64, true; @@ -451,12 +459,14 @@ procedure main() call get_two(); goto l000003dd; l000003dd: + assume {:captureState "l000003dd"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); call rely(); assert (L(mem, R8) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, R8, R0[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R0); + assume {:captureState "%000003ef"} true; call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); R0, Gamma_R0 := 0bv64, true; @@ -465,6 +475,7 @@ procedure main() call printf(); goto l0000040b; l0000040b: + assume {:captureState "l0000040b"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/gcc/function1.expected b/src/test/correct/function1/gcc/function1.expected index 2e0921299..a95a503aa 100644 --- a/src/test/correct/function1/gcc/function1.expected +++ b/src/test/correct/function1/gcc/function1.expected @@ -1,86 +1,86 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2048bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -129,7 +129,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -138,9 +138,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -237,10 +237,14 @@ procedure get_two() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000034e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%00000356"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%0000035e"} true; R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); @@ -365,9 +369,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000039e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000003a4"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 69632bv64, true; @@ -376,6 +383,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003c6"} true; R2, Gamma_R2 := 58368bv64, true; R2, Gamma_R2 := (R2[64:32] ++ (21515bv16 ++ R2[16:0])), Gamma_R2; R2, Gamma_R2 := (R2[64:48] ++ (2bv16 ++ R2[32:0])), Gamma_R2; @@ -385,12 +393,14 @@ procedure main() call get_two(); goto l000003ec; l000003ec: + assume {:captureState "l000003ec"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000403"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -402,6 +412,7 @@ procedure main() call printf(); goto l00000430; l00000430: + assume {:captureState "l00000430"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/gcc_O2/function1.expected b/src/test/correct/function1/gcc_O2/function1.expected index b201a791e..8296db663 100644 --- a/src/test/correct/function1/gcc_O2/function1.expected +++ b/src/test/correct/function1/gcc_O2/function1.expected @@ -1,66 +1,66 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R3: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R3: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R3: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2048bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -118,9 +118,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure __printf_chk(); @@ -328,9 +328,12 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%000001ca"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%000001d0"} true; R31, Gamma_R31 := #1, Gamma_#1; R1, Gamma_R1 := 69632bv64, true; R3, Gamma_R3 := bvadd64(R1, 20bv64), Gamma_R1; @@ -341,15 +344,18 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R0); + assume {:captureState "%000001fd"} true; R1, Gamma_R1 := 0bv64, true; R1, Gamma_R1 := bvadd64(R1, 2056bv64), Gamma_R1; call rely(); assert (L(mem, bvadd64(R3, 4bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R3, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R3, 4bv64), Gamma_R2); + assume {:captureState "%00000210"} true; R30, Gamma_R30 := 1712bv64, true; call __printf_chk(); goto l0000021a; l0000021a: + assume {:captureState "l0000021a"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/gcc_no_plt_no_pic/function1.expected b/src/test/correct/function1/gcc_no_plt_no_pic/function1.expected index 75b3a0aad..711e70cf1 100644 --- a/src/test/correct/function1/gcc_no_plt_no_pic/function1.expected +++ b/src/test/correct/function1/gcc_no_plt_no_pic/function1.expected @@ -1,86 +1,86 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2048bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -129,7 +129,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -138,9 +138,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -237,10 +237,14 @@ procedure get_two() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%00000aa6"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%00000aae"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%00000ab6"} true; R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); @@ -365,9 +369,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000af6"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000afc"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 69632bv64, true; @@ -376,6 +383,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000b1e"} true; R2, Gamma_R2 := 58368bv64, true; R2, Gamma_R2 := (R2[64:32] ++ (21515bv16 ++ R2[16:0])), Gamma_R2; R2, Gamma_R2 := (R2[64:48] ++ (2bv16 ++ R2[32:0])), Gamma_R2; @@ -385,12 +393,14 @@ procedure main() call get_two(); goto l00000b44; l00000b44: + assume {:captureState "l00000b44"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000b5b"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -402,6 +412,7 @@ procedure main() call printf(); goto l00000b88; l00000b88: + assume {:captureState "l00000b88"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/function1/gcc_pic/function1.expected b/src/test/correct/function1/gcc_pic/function1.expected index b33c27c06..313d20eac 100644 --- a/src/test/correct/function1/gcc_pic/function1.expected +++ b/src/test/correct/function1/gcc_pic/function1.expected @@ -1,86 +1,86 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2112bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -145,7 +145,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 68998bv64) == 0bv8); free ensures (memory_load8_le(mem, 68999bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -154,9 +154,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure get_two() @@ -285,10 +285,14 @@ procedure get_two() free ensures (memory_load8_le(mem, 68999bv64) == 0bv8); { lget_two: + assume {:captureState "lget_two"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000034e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R1[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R1); + assume {:captureState "%00000356"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R2), gamma_store64(Gamma_stack, R31, Gamma_R2); + assume {:captureState "%0000035e"} true; R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R1[32:0], R0[32:0])), (Gamma_R0 && Gamma_R1); @@ -445,9 +449,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000039e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000003a4"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 65536bv64, true; @@ -457,6 +464,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003c7"} true; R2, Gamma_R2 := 58368bv64, true; R2, Gamma_R2 := (R2[64:32] ++ (21515bv16 ++ R2[16:0])), Gamma_R2; R2, Gamma_R2 := (R2[64:48] ++ (2bv16 ++ R2[32:0])), Gamma_R2; @@ -466,6 +474,7 @@ procedure main() call get_two(); goto l000003ed; l000003ed: + assume {:captureState "l000003ed"} true; R1, Gamma_R1 := zero_extend32_32(R0[32:0]), Gamma_R0; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -473,6 +482,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000405"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -485,6 +495,7 @@ procedure main() call printf(); goto l00000433; l00000433: + assume {:captureState "l00000433"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/functions_with_params/clang/functions_with_params.expected b/src/test/correct/functions_with_params/clang/functions_with_params.expected index 6fdd643ea..dfe4dc6cb 100644 --- a/src/test/correct/functions_with_params/clang/functions_with_params.expected +++ b/src/test/correct/functions_with_params/clang/functions_with_params.expected @@ -1,59 +1,59 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1912bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,9 +103,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -208,21 +208,28 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000030a"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000310"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R8); + assume {:captureState "%00000323"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000330"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); R30, Gamma_R30 := 1848bv64, true; call plus_one(); goto l00000366; l00000366: + assume {:captureState "l00000366"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%0000036c"} true; R0, Gamma_R0 := 0bv64, true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); @@ -309,8 +316,10 @@ procedure plus_one() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lplus_one: + assume {:captureState "lplus_one"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000034c"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/functions_with_params/clang_O2/functions_with_params.expected b/src/test/correct/functions_with_params/clang_O2/functions_with_params.expected index fd922f548..c92fd296f 100644 --- a/src/test/correct/functions_with_params/clang_O2/functions_with_params.expected +++ b/src/test/correct/functions_with_params/clang_O2/functions_with_params.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1848bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/functions_with_params/clang_no_plt_no_pic/functions_with_params.expected b/src/test/correct/functions_with_params/clang_no_plt_no_pic/functions_with_params.expected index f17db6c35..1136a902b 100644 --- a/src/test/correct/functions_with_params/clang_no_plt_no_pic/functions_with_params.expected +++ b/src/test/correct/functions_with_params/clang_no_plt_no_pic/functions_with_params.expected @@ -1,59 +1,59 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1912bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,9 +103,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -208,21 +208,28 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000955"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000095b"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R8); + assume {:captureState "%0000096e"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000097b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); R30, Gamma_R30 := 1848bv64, true; call plus_one(); goto l000009b1; l000009b1: + assume {:captureState "l000009b1"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%000009b7"} true; R0, Gamma_R0 := 0bv64, true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); @@ -309,8 +316,10 @@ procedure plus_one() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lplus_one: + assume {:captureState "lplus_one"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000997"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/functions_with_params/clang_pic/functions_with_params.expected b/src/test/correct/functions_with_params/clang_pic/functions_with_params.expected index f17db6c35..1136a902b 100644 --- a/src/test/correct/functions_with_params/clang_pic/functions_with_params.expected +++ b/src/test/correct/functions_with_params/clang_pic/functions_with_params.expected @@ -1,59 +1,59 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1912bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,9 +103,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -208,21 +208,28 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000955"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000095b"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R8); + assume {:captureState "%0000096e"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000097b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R29, 18446744073709551612bv64))), gamma_load32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64)); R30, Gamma_R30 := 1848bv64, true; call plus_one(); goto l000009b1; l000009b1: + assume {:captureState "l000009b1"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), Gamma_R0); + assume {:captureState "%000009b7"} true; R0, Gamma_R0 := 0bv64, true; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); @@ -309,8 +316,10 @@ procedure plus_one() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lplus_one: + assume {:captureState "lplus_one"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000997"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/functions_with_params/gcc/functions_with_params.expected b/src/test/correct/functions_with_params/gcc/functions_with_params.expected index be5bbf199..284845f2f 100644 --- a/src/test/correct/functions_with_params/gcc/functions_with_params.expected +++ b/src/test/correct/functions_with_params/gcc/functions_with_params.expected @@ -1,57 +1,57 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1904bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -101,9 +101,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -204,21 +204,28 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002fc"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000302"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000319"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000326"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 1844bv64, true; call plus_one(); goto l0000035c; l0000035c: + assume {:captureState "l0000035c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000362"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -304,8 +311,10 @@ procedure plus_one() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lplus_one: + assume {:captureState "lplus_one"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000342"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/functions_with_params/gcc_O2/functions_with_params.expected b/src/test/correct/functions_with_params/gcc_O2/functions_with_params.expected index 81f3e344b..031602cf6 100644 --- a/src/test/correct/functions_with_params/gcc_O2/functions_with_params.expected +++ b/src/test/correct/functions_with_params/gcc_O2/functions_with_params.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1916bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/functions_with_params/gcc_no_plt_no_pic/functions_with_params.expected b/src/test/correct/functions_with_params/gcc_no_plt_no_pic/functions_with_params.expected index 72cfd1a2e..03251913e 100644 --- a/src/test/correct/functions_with_params/gcc_no_plt_no_pic/functions_with_params.expected +++ b/src/test/correct/functions_with_params/gcc_no_plt_no_pic/functions_with_params.expected @@ -1,57 +1,57 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1904bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -101,9 +101,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -204,21 +204,28 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000933"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000939"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000950"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000095d"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 1844bv64, true; call plus_one(); goto l00000993; l00000993: + assume {:captureState "l00000993"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000999"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -304,8 +311,10 @@ procedure plus_one() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lplus_one: + assume {:captureState "lplus_one"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000979"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/functions_with_params/gcc_pic/functions_with_params.expected b/src/test/correct/functions_with_params/gcc_pic/functions_with_params.expected index 72cfd1a2e..03251913e 100644 --- a/src/test/correct/functions_with_params/gcc_pic/functions_with_params.expected +++ b/src/test/correct/functions_with_params/gcc_pic/functions_with_params.expected @@ -1,57 +1,57 @@ -var Gamma_R0: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1904bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -101,9 +101,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -204,21 +204,28 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000933"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000939"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000950"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000095d"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 1844bv64, true; call plus_one(); goto l00000993; l00000993: + assume {:captureState "l00000993"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000999"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -304,8 +311,10 @@ procedure plus_one() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lplus_one: + assume {:captureState "lplus_one"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000979"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; diff --git a/src/test/correct/ifbranches/clang/ifbranches.expected b/src/test/correct/ifbranches/clang/ifbranches.expected index 9e3d4da3f..5718d9457 100644 --- a/src/test/correct/ifbranches/clang/ifbranches.expected +++ b/src/test/correct/ifbranches/clang/ifbranches.expected @@ -1,54 +1,54 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -89,7 +89,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -98,9 +98,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -208,11 +208,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%0000030d"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000315"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%0000031d"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000324"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -226,31 +231,41 @@ procedure main() } goto l0000034f; l0000034f: + assume {:captureState "l0000034f"} true; R8, Gamma_R8 := 1bv64, true; goto l00000352; l0000034c: + assume {:captureState "l0000034c"} true; R8, Gamma_R8 := 0bv64, true; goto l00000352; l00000352: + assume {:captureState "l00000352"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000035a; } goto l00000397; l0000035a: + assume {:captureState "l0000035a"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000036a"} true; goto l0000036d; l00000397: + assume {:captureState "l00000397"} true; goto l00000398; l00000398: + assume {:captureState "l00000398"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000003a6"} true; goto l0000036d; l0000036d: + assume {:captureState "l0000036d"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000383"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/ifbranches/clang_O2/ifbranches.expected b/src/test/correct/ifbranches/clang_O2/ifbranches.expected index 4a3d010fb..e7d47e243 100644 --- a/src/test/correct/ifbranches/clang_O2/ifbranches.expected +++ b/src/test/correct/ifbranches/clang_O2/ifbranches.expected @@ -1,23 +1,23 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var mem: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,7 +58,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -67,9 +67,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -175,6 +175,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 2bv64, true; #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -187,11 +188,14 @@ procedure main() } goto l000002df; l000002df: + assume {:captureState "l000002df"} true; R0, Gamma_R0 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; goto l000002e2; l000002db: + assume {:captureState "l000002db"} true; R0, Gamma_R0 := zero_extend32_32(R8[32:0]), Gamma_R8; goto l000002e2; l000002e2: + assume {:captureState "l000002e2"} true; return; } diff --git a/src/test/correct/ifbranches/clang_no_plt_no_pic/ifbranches.expected b/src/test/correct/ifbranches/clang_no_plt_no_pic/ifbranches.expected index 76136db7d..ed65fc303 100644 --- a/src/test/correct/ifbranches/clang_no_plt_no_pic/ifbranches.expected +++ b/src/test/correct/ifbranches/clang_no_plt_no_pic/ifbranches.expected @@ -1,54 +1,54 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -89,7 +89,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -98,9 +98,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -208,11 +208,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000979"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000981"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000989"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000990"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -226,31 +231,41 @@ procedure main() } goto l000009bb; l000009bb: + assume {:captureState "l000009bb"} true; R8, Gamma_R8 := 1bv64, true; goto l000009be; l000009b8: + assume {:captureState "l000009b8"} true; R8, Gamma_R8 := 0bv64, true; goto l000009be; l000009be: + assume {:captureState "l000009be"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000009c6; } goto l00000a03; l000009c6: + assume {:captureState "l000009c6"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000009d6"} true; goto l000009d9; l00000a03: + assume {:captureState "l00000a03"} true; goto l00000a04; l00000a04: + assume {:captureState "l00000a04"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000a12"} true; goto l000009d9; l000009d9: + assume {:captureState "l000009d9"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000009ef"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/ifbranches/clang_pic/ifbranches.expected b/src/test/correct/ifbranches/clang_pic/ifbranches.expected index 76136db7d..ed65fc303 100644 --- a/src/test/correct/ifbranches/clang_pic/ifbranches.expected +++ b/src/test/correct/ifbranches/clang_pic/ifbranches.expected @@ -1,54 +1,54 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -89,7 +89,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -98,9 +98,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -208,11 +208,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000979"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000981"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000989"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000990"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -226,31 +231,41 @@ procedure main() } goto l000009bb; l000009bb: + assume {:captureState "l000009bb"} true; R8, Gamma_R8 := 1bv64, true; goto l000009be; l000009b8: + assume {:captureState "l000009b8"} true; R8, Gamma_R8 := 0bv64, true; goto l000009be; l000009be: + assume {:captureState "l000009be"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000009c6; } goto l00000a03; l000009c6: + assume {:captureState "l000009c6"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000009d6"} true; goto l000009d9; l00000a03: + assume {:captureState "l00000a03"} true; goto l00000a04; l00000a04: + assume {:captureState "l00000a04"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000a12"} true; goto l000009d9; l000009d9: + assume {:captureState "l000009d9"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000009ef"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/ifbranches/gcc/ifbranches.expected b/src/test/correct/ifbranches/gcc/ifbranches.expected index 956bbeeb6..5208e2068 100644 --- a/src/test/correct/ifbranches/gcc/ifbranches.expected +++ b/src/test/correct/ifbranches/gcc/ifbranches.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -96,9 +96,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -206,10 +206,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002fe"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%00000306"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), true); + assume {:captureState "%0000030d"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -222,17 +226,23 @@ procedure main() } goto l00000369; l00000330: + assume {:captureState "l00000330"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000340"} true; goto l00000342; l00000369: + assume {:captureState "l00000369"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000374"} true; goto l00000342; l00000342: + assume {:captureState "l00000342"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000355"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/ifbranches/gcc_O2/ifbranches.expected b/src/test/correct/ifbranches/gcc_O2/ifbranches.expected index f90c20326..f67aba3a9 100644 --- a/src/test/correct/ifbranches/gcc_O2/ifbranches.expected +++ b/src/test/correct/ifbranches/gcc_O2/ifbranches.expected @@ -1,21 +1,21 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -56,7 +56,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -65,9 +65,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -173,6 +173,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#1, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#1); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#1, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967296bv33))), (Gamma_R0 && Gamma_#1); @@ -184,12 +185,15 @@ procedure main() } goto l000001c6; l000001c6: + assume {:captureState "l000001c6"} true; R0, Gamma_R0 := 1bv64, true; goto l000001c9; l000001c3: + assume {:captureState "l000001c3"} true; R0, Gamma_R0 := 0bv64, true; goto l000001c9; l000001c9: + assume {:captureState "l000001c9"} true; R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 2bv32)), Gamma_R0; return; } diff --git a/src/test/correct/ifbranches/gcc_no_plt_no_pic/ifbranches.expected b/src/test/correct/ifbranches/gcc_no_plt_no_pic/ifbranches.expected index 6dde1f98e..9902018f0 100644 --- a/src/test/correct/ifbranches/gcc_no_plt_no_pic/ifbranches.expected +++ b/src/test/correct/ifbranches/gcc_no_plt_no_pic/ifbranches.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -96,9 +96,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -206,10 +206,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000931"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%00000939"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), true); + assume {:captureState "%00000940"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -222,17 +226,23 @@ procedure main() } goto l0000099c; l00000963: + assume {:captureState "l00000963"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000973"} true; goto l00000975; l0000099c: + assume {:captureState "l0000099c"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%000009a7"} true; goto l00000975; l00000975: + assume {:captureState "l00000975"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000988"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/ifbranches/gcc_pic/ifbranches.expected b/src/test/correct/ifbranches/gcc_pic/ifbranches.expected index 6dde1f98e..9902018f0 100644 --- a/src/test/correct/ifbranches/gcc_pic/ifbranches.expected +++ b/src/test/correct/ifbranches/gcc_pic/ifbranches.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -96,9 +96,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -206,10 +206,14 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000931"} true; stack, Gamma_stack := memory_store64_le(stack, R31, R1), gamma_store64(Gamma_stack, R31, Gamma_R1); + assume {:captureState "%00000939"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), true); + assume {:captureState "%00000940"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -222,17 +226,23 @@ procedure main() } goto l0000099c; l00000963: + assume {:captureState "l00000963"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000973"} true; goto l00000975; l0000099c: + assume {:captureState "l0000099c"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%000009a7"} true; goto l00000975; l00000975: + assume {:captureState "l00000975"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000988"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/correct/ifglobal/clang/ifglobal.expected b/src/test/correct/ifglobal/clang/ifglobal.expected index c96637259..f6cda1c81 100644 --- a/src/test/correct/ifglobal/clang/ifglobal.expected +++ b/src/test/correct/ifglobal/clang/ifglobal.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -96,9 +96,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -205,8 +205,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f1"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -222,27 +224,34 @@ procedure main() } goto l00000321; l00000321: + assume {:captureState "l00000321"} true; R8, Gamma_R8 := 1bv64, true; goto l00000324; l0000031e: + assume {:captureState "l0000031e"} true; R8, Gamma_R8 := 0bv64, true; goto l00000324; l00000324: + assume {:captureState "l00000324"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000032c; } goto l00000343; l00000343: + assume {:captureState "l00000343"} true; goto l00000344; l00000344: + assume {:captureState "l00000344"} true; R8, Gamma_R8 := 1bv64, true; R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%00000357"} true; goto l0000032c; l0000032c: + assume {:captureState "l0000032c"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/ifglobal/clang_O2/ifglobal.expected b/src/test/correct/ifglobal/clang_O2/ifglobal.expected index 70f0c3d41..afe71ccd1 100644 --- a/src/test/correct/ifglobal/clang_O2/ifglobal.expected +++ b/src/test/correct/ifglobal/clang_O2/ifglobal.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -85,9 +85,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -182,6 +182,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -191,13 +192,16 @@ procedure main() } goto l000002f8; l000002dc: + assume {:captureState "l000002dc"} true; R9, Gamma_R9 := 1bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%000002ec"} true; R0, Gamma_R0 := 0bv64, true; return; l000002f8: + assume {:captureState "l000002f8"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/ifglobal/clang_no_plt_no_pic/ifglobal.expected b/src/test/correct/ifglobal/clang_no_plt_no_pic/ifglobal.expected index ecd732cd7..b07e23d00 100644 --- a/src/test/correct/ifglobal/clang_no_plt_no_pic/ifglobal.expected +++ b/src/test/correct/ifglobal/clang_no_plt_no_pic/ifglobal.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -96,9 +96,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -205,8 +205,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000900"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -222,27 +224,34 @@ procedure main() } goto l00000930; l00000930: + assume {:captureState "l00000930"} true; R8, Gamma_R8 := 1bv64, true; goto l00000933; l0000092d: + assume {:captureState "l0000092d"} true; R8, Gamma_R8 := 0bv64, true; goto l00000933; l00000933: + assume {:captureState "l00000933"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000093b; } goto l00000952; l00000952: + assume {:captureState "l00000952"} true; goto l00000953; l00000953: + assume {:captureState "l00000953"} true; R8, Gamma_R8 := 1bv64, true; R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%00000966"} true; goto l0000093b; l0000093b: + assume {:captureState "l0000093b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/ifglobal/clang_pic/ifglobal.expected b/src/test/correct/ifglobal/clang_pic/ifglobal.expected index 327f31f41..dfb965c3c 100644 --- a/src/test/correct/ifglobal/clang_pic/ifglobal.expected +++ b/src/test/correct/ifglobal/clang_pic/ifglobal.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,7 +103,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -112,9 +112,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -237,8 +237,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); @@ -256,20 +258,25 @@ procedure main() } goto l00000330; l00000330: + assume {:captureState "l00000330"} true; R8, Gamma_R8 := 1bv64, true; goto l00000333; l0000032d: + assume {:captureState "l0000032d"} true; R8, Gamma_R8 := 0bv64, true; goto l00000333; l00000333: + assume {:captureState "l00000333"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000033b; } goto l00000352; l00000352: + assume {:captureState "l00000352"} true; goto l00000353; l00000353: + assume {:captureState "l00000353"} true; R8, Gamma_R8 := 1bv64, true; R9, Gamma_R9 := 65536bv64, true; call rely(); @@ -277,8 +284,10 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000036d"} true; goto l0000033b; l0000033b: + assume {:captureState "l0000033b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/ifglobal/gcc/ifglobal.expected b/src/test/correct/ifglobal/gcc/ifglobal.expected index fa3fd522b..d23d1d5bf 100644 --- a/src/test/correct/ifglobal/gcc/ifglobal.expected +++ b/src/test/correct/ifglobal/gcc/ifglobal.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,6 +197,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -212,14 +213,17 @@ procedure main() } goto l00000311; l00000311: + assume {:captureState "l00000311"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000327"} true; goto l00000302; l00000302: + assume {:captureState "l00000302"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/ifglobal/gcc_O2/ifglobal.expected b/src/test/correct/ifglobal/gcc_O2/ifglobal.expected index 2b5fc6a39..7c637d172 100644 --- a/src/test/correct/ifglobal/gcc_O2/ifglobal.expected +++ b/src/test/correct/ifglobal/gcc_O2/ifglobal.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -84,9 +84,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -181,6 +181,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); @@ -190,12 +191,15 @@ procedure main() } goto l00000396; l00000396: + assume {:captureState "l00000396"} true; R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, bvadd64(R0, 20bv64)) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 20bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 20bv64), Gamma_R1); + assume {:captureState "%000003a1"} true; goto l000001b7; l000001b7: + assume {:captureState "l000001b7"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/ifglobal/gcc_no_plt_no_pic/ifglobal.expected b/src/test/correct/ifglobal/gcc_no_plt_no_pic/ifglobal.expected index b74831af7..77b0fdc9a 100644 --- a/src/test/correct/ifglobal/gcc_no_plt_no_pic/ifglobal.expected +++ b/src/test/correct/ifglobal/gcc_no_plt_no_pic/ifglobal.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,6 +197,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -212,14 +213,17 @@ procedure main() } goto l000008e5; l000008e5: + assume {:captureState "l000008e5"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000008fb"} true; goto l000008d6; l000008d6: + assume {:captureState "l000008d6"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/ifglobal/gcc_pic/ifglobal.expected b/src/test/correct/ifglobal/gcc_pic/ifglobal.expected index 8e6c99707..a9559c8a6 100644 --- a/src/test/correct/ifglobal/gcc_pic/ifglobal.expected +++ b/src/test/correct/ifglobal/gcc_pic/ifglobal.expected @@ -1,54 +1,54 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $x_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -97,7 +97,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -106,9 +106,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -229,6 +229,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -245,6 +246,7 @@ procedure main() } goto l00000312; l00000312: + assume {:captureState "l00000312"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -252,8 +254,10 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000329"} true; goto l00000303; l00000303: + assume {:captureState "l00000303"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/indirect_call/clang_O2/indirect_call.expected b/src/test/correct/indirect_call/clang_O2/indirect_call.expected index 526771429..d04773ed9 100644 --- a/src/test/correct/indirect_call/clang_O2/indirect_call.expected +++ b/src/test/correct/indirect_call/clang_O2/indirect_call.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1952bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -120,7 +120,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -129,9 +129,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -316,9 +316,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002fc"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000302"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 0bv64, true; @@ -327,12 +330,14 @@ procedure main() call puts(); goto l00000320; l00000320: + assume {:captureState "l00000320"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 1956bv64), Gamma_R0; R30, Gamma_R30 := 1920bv64, true; call puts(); goto l00000332; l00000332: + assume {:captureState "l00000332"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/indirect_call/gcc_O2/indirect_call.expected b/src/test/correct/indirect_call/gcc_O2/indirect_call.expected index 46742d3c1..992bdfc81 100644 --- a/src/test/correct/indirect_call/gcc_O2/indirect_call.expected +++ b/src/test/correct/indirect_call/gcc_O2/indirect_call.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1984bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -126,7 +126,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -135,9 +135,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure greet() @@ -312,6 +312,7 @@ procedure greet() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lgreet: + assume {:captureState "lgreet"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 1992bv64), Gamma_R0; call puts(); @@ -513,9 +514,12 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%000001ca"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%000001d0"} true; R31, Gamma_R31 := #1, Gamma_#1; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2008bv64), Gamma_R0; @@ -524,10 +528,12 @@ procedure main() call puts(); goto l000001ef; l000001ef: + assume {:captureState "l000001ef"} true; R30, Gamma_R30 := 1624bv64, true; call greet(); goto l00000205; l00000205: + assume {:captureState "l00000205"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/initialisation/clang/initialisation.expected b/src/test/correct/initialisation/clang/initialisation.expected index a129d4d89..4a8b8a7ad 100644 --- a/src/test/correct/initialisation/clang/initialisation.expected +++ b/src/test/correct/initialisation/clang/initialisation.expected @@ -1,86 +1,86 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); -function {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); -function {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -121,7 +121,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -130,9 +130,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -264,6 +264,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; R9, Gamma_R9 := bvadd64(R9, 64bv64), Gamma_R9; @@ -274,6 +275,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R11, 48bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R11, 48bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R11, 48bv64), Gamma_R10); + assume {:captureState "%00000322"} true; R11, Gamma_R11 := 69632bv64, true; call rely(); R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R11, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R11, 56bv64)) || L(mem, bvadd64(R11, 56bv64))); @@ -286,12 +288,14 @@ procedure main() call rely(); assert (L(mem, bvadd64(R11, 56bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R11, 56bv64), R10), gamma_store64(Gamma_mem, bvadd64(R11, 56bv64), Gamma_R10); + assume {:captureState "%00000352"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 3bv32)), Gamma_R8; call rely(); assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); + assume {:captureState "%00000367"} true; R9, Gamma_R9 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, bvadd64(R9, 52bv64))), (gamma_load8(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); @@ -299,6 +303,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 52bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%00000381"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/initialisation/clang_O2/initialisation.expected b/src/test/correct/initialisation/clang_O2/initialisation.expected index adf848ee9..5bbd94028 100644 --- a/src/test/correct/initialisation/clang_O2/initialisation.expected +++ b/src/test/correct/initialisation/clang_O2/initialisation.expected @@ -1,88 +1,88 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R12: bool; -var Gamma_R13: bool; -var Gamma_R14: bool; -var Gamma_R15: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R12: bv64; -var R13: bv64; -var R14: bv64; -var R15: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R12: bool; +var {:extern} Gamma_R13: bool; +var {:extern} Gamma_R14: bool; +var {:extern} Gamma_R15: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R12: bv64; +var {:extern} R13: bv64; +var {:extern} R14: bv64; +var {:extern} R15: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -123,7 +123,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -132,9 +132,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -256,6 +256,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R10, Gamma_R10 := 69632bv64, true; R10, Gamma_R10 := bvadd64(R10, 64bv64), Gamma_R10; R8, Gamma_R8 := 69632bv64, true; @@ -276,15 +277,19 @@ procedure main() call rely(); assert (L(mem, bvadd64(R10, 4bv64)) ==> Gamma_R11); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 4bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 4bv64), Gamma_R11); + assume {:captureState "%00000349"} true; R10, Gamma_R10 := zero_extend32_32(bvadd32(R15[32:0], 1bv32)), Gamma_R15; call rely(); assert (L(mem, bvadd64(R8, 48bv64)) ==> Gamma_R13); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 48bv64), R13[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 48bv64), Gamma_R13); + assume {:captureState "%00000357"} true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R14); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 56bv64), R14), gamma_store64(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R14); + assume {:captureState "%0000035f"} true; call rely(); assert (L(mem, bvadd64(R12, 52bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R12, 52bv64), R10[8:0]), gamma_store8(Gamma_mem, bvadd64(R12, 52bv64), Gamma_R10); + assume {:captureState "%00000367"} true; return; } diff --git a/src/test/correct/initialisation/clang_no_plt_no_pic/initialisation.expected b/src/test/correct/initialisation/clang_no_plt_no_pic/initialisation.expected index a129d4d89..2487e0171 100644 --- a/src/test/correct/initialisation/clang_no_plt_no_pic/initialisation.expected +++ b/src/test/correct/initialisation/clang_no_plt_no_pic/initialisation.expected @@ -1,86 +1,86 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); -function {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); -function {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -121,7 +121,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -130,9 +130,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -264,6 +264,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; R9, Gamma_R9 := bvadd64(R9, 64bv64), Gamma_R9; @@ -274,6 +275,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R11, 48bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R11, 48bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R11, 48bv64), Gamma_R10); + assume {:captureState "%0000096a"} true; R11, Gamma_R11 := 69632bv64, true; call rely(); R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R11, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R11, 56bv64)) || L(mem, bvadd64(R11, 56bv64))); @@ -286,12 +288,14 @@ procedure main() call rely(); assert (L(mem, bvadd64(R11, 56bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R11, 56bv64), R10), gamma_store64(Gamma_mem, bvadd64(R11, 56bv64), Gamma_R10); + assume {:captureState "%0000099a"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 64bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 64bv64)) || L(mem, bvadd64(R8, 64bv64))); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 3bv32)), Gamma_R8; call rely(); assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); + assume {:captureState "%000009af"} true; R9, Gamma_R9 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, bvadd64(R9, 52bv64))), (gamma_load8(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); @@ -299,6 +303,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 52bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); + assume {:captureState "%000009c9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/initialisation/clang_pic/initialisation.expected b/src/test/correct/initialisation/clang_pic/initialisation.expected index 02ec4561d..6fb983d9b 100644 --- a/src/test/correct/initialisation/clang_pic/initialisation.expected +++ b/src/test/correct/initialisation/clang_pic/initialisation.expected @@ -1,84 +1,84 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69696bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); -function {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvadd"} bvadd65(bv65, bv65) returns (bv65); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp64(bv64, bv64) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp65(bv65, bv65) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); -function {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_64(bv64) returns (bv65); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -151,7 +151,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69566bv64) == 0bv8); free ensures (memory_load8_le(mem, 69567bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -160,9 +160,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -358,6 +358,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); @@ -370,6 +371,7 @@ procedure main() call rely(); assert (L(mem, R10) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R10, R8[32:0]), gamma_store32(Gamma_mem, R10, Gamma_R8); + assume {:captureState "%0000032d"} true; R10, Gamma_R10 := 65536bv64, true; call rely(); R10, Gamma_R10 := memory_load64_le(mem, bvadd64(R10, 4016bv64)), (gamma_load64(Gamma_mem, bvadd64(R10, 4016bv64)) || L(mem, bvadd64(R10, 4016bv64))); @@ -384,12 +386,14 @@ procedure main() call rely(); assert (L(mem, R10) ==> Gamma_R8); mem, Gamma_mem := memory_store64_le(mem, R10, R8), gamma_store64(Gamma_mem, R10, Gamma_R8); + assume {:captureState "%00000364"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 3bv32)), Gamma_R8; call rely(); assert (L(mem, bvadd64(R9, 4bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 4bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 4bv64), Gamma_R8); + assume {:captureState "%00000379"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); @@ -399,6 +403,7 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000039a"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/initialisation/gcc/initialisation.expected b/src/test/correct/initialisation/gcc/initialisation.expected index e6ae1203b..cd8f95208 100644 --- a/src/test/correct/initialisation/gcc/initialisation.expected +++ b/src/test/correct/initialisation/gcc/initialisation.expected @@ -1,74 +1,74 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -118,9 +118,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -242,6 +242,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -252,6 +253,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000034f"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -262,6 +264,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); @@ -272,6 +275,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); + assume {:captureState "%000003a5"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -283,6 +287,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003d6"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/initialisation/gcc_O2/initialisation.expected b/src/test/correct/initialisation/gcc_O2/initialisation.expected index 5902dc0d3..0b0da4f5d 100644 --- a/src/test/correct/initialisation/gcc_O2/initialisation.expected +++ b/src/test/correct/initialisation/gcc_O2/initialisation.expected @@ -1,84 +1,84 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R3: bool; -var Gamma_R4: bool; -var Gamma_R5: bool; -var Gamma_R6: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R3: bv64; -var R4: bv64; -var R5: bv64; -var R6: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R4: bool; +var {:extern} Gamma_R5: bool; +var {:extern} Gamma_R6: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} R4: bv64; +var {:extern} R5: bv64; +var {:extern} R6: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69672bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -119,7 +119,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -128,9 +128,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -253,6 +253,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R5, Gamma_R5 := 69632bv64, true; R1, Gamma_R1 := bvadd64(R5, 16bv64), Gamma_R5; R0, Gamma_R0 := 0bv64, true; @@ -270,15 +271,19 @@ procedure main() call rely(); assert (L(mem, bvadd64(R5, 16bv64)) ==> Gamma_R6); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R5, 16bv64), R6[32:0]), gamma_store32(Gamma_mem, bvadd64(R5, 16bv64), Gamma_R6); + assume {:captureState "%000001ec"} true; R3, Gamma_R3 := zero_extend32_32(bvadd32(R3[32:0], 3bv32)), Gamma_R3; call rely(); assert (L(mem, bvadd64(R1, 8bv64)) ==> Gamma_R4); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R1, 8bv64), R4), gamma_store64(Gamma_mem, bvadd64(R1, 8bv64), Gamma_R4); + assume {:captureState "%000001fa"} true; call rely(); assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R3); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R3); + assume {:captureState "%00000202"} true; call rely(); assert (L(mem, bvadd64(R1, 24bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R1, 24bv64), R2[8:0]), gamma_store8(Gamma_mem, bvadd64(R1, 24bv64), Gamma_R2); + assume {:captureState "%0000020a"} true; return; } diff --git a/src/test/correct/initialisation/gcc_no_plt_no_pic/initialisation.expected b/src/test/correct/initialisation/gcc_no_plt_no_pic/initialisation.expected index e6ae1203b..418adaae6 100644 --- a/src/test/correct/initialisation/gcc_no_plt_no_pic/initialisation.expected +++ b/src/test/correct/initialisation/gcc_no_plt_no_pic/initialisation.expected @@ -1,74 +1,74 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -118,9 +118,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -242,6 +242,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -252,6 +253,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a02"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -262,6 +264,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a2d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); @@ -272,6 +275,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); + assume {:captureState "%00000a58"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -283,6 +287,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a89"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/initialisation/gcc_pic/initialisation.expected b/src/test/correct/initialisation/gcc_pic/initialisation.expected index fdef9652e..4f95961a3 100644 --- a/src/test/correct/initialisation/gcc_pic/initialisation.expected +++ b/src/test/correct/initialisation/gcc_pic/initialisation.expected @@ -1,74 +1,74 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $a_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $a_addr: bv64; axiom ($a_addr == 69664bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -141,7 +141,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 68998bv64) == 0bv8); free ensures (memory_load8_le(mem, 68999bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -150,9 +150,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -338,6 +338,7 @@ procedure main() free ensures (memory_load8_le(mem, 68999bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); @@ -350,6 +351,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000351"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4040bv64)) || L(mem, bvadd64(R0, 4040bv64))); @@ -362,6 +364,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037e"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -374,6 +377,7 @@ procedure main() call rely(); assert (L(mem, bvadd64(R0, 4bv64)) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R0, 4bv64), R1[32:0]), gamma_store32(Gamma_mem, bvadd64(R0, 4bv64), Gamma_R1); + assume {:captureState "%000003ab"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -387,6 +391,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003de"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/jumptable/clang_O2/jumptable.expected b/src/test/correct/jumptable/clang_O2/jumptable.expected index 508a59310..8de643ece 100644 --- a/src/test/correct/jumptable/clang_O2/jumptable.expected +++ b/src/test/correct/jumptable/clang_O2/jumptable.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1916bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69680bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -78,7 +78,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,9 +87,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -188,6 +188,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); @@ -196,5 +197,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R8, 48bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 48bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 48bv64), Gamma_R9); + assume {:captureState "%00000378"} true; return; } diff --git a/src/test/correct/jumptable/gcc_O2/jumptable.expected b/src/test/correct/jumptable/gcc_O2/jumptable.expected index 5db7e4907..0b02b32d3 100644 --- a/src/test/correct/jumptable/gcc_O2/jumptable.expected +++ b/src/test/correct/jumptable/gcc_O2/jumptable.expected @@ -1,65 +1,65 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1976bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69648bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -100,7 +100,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,9 +109,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_six() @@ -190,6 +190,7 @@ procedure add_six() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { ladd_six: + assume {:captureState "ladd_six"} true; R1, Gamma_R1 := 69632bv64, true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); @@ -197,6 +198,7 @@ procedure add_six() call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%00000252"} true; return; } @@ -276,6 +278,7 @@ procedure add_two() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { ladd_two: + assume {:captureState "ladd_two"} true; R1, Gamma_R1 := 69632bv64, true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); @@ -283,6 +286,7 @@ procedure add_two() call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%00000233"} true; return; } @@ -388,23 +392,29 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%00000202"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%00000208"} true; R31, Gamma_R31 := #1, Gamma_#1; R29, Gamma_R29 := R31, Gamma_R31; R30, Gamma_R30 := 1548bv64, true; call add_two(); goto l0000027c; l0000027c: + assume {:captureState "l0000027c"} true; R30, Gamma_R30 := 1552bv64, true; call add_six(); goto l00000283; l00000283: + assume {:captureState "l00000283"} true; R30, Gamma_R30 := 1556bv64, true; call sub_seven(); goto l0000028a; l0000028a: + assume {:captureState "l0000028a"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -488,6 +498,7 @@ procedure sub_seven() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lsub_seven: + assume {:captureState "lsub_seven"} true; R1, Gamma_R1 := 69632bv64, true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); @@ -495,5 +506,6 @@ procedure sub_seven() call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%00000275"} true; return; } diff --git a/src/test/correct/jumptable3/gcc/jumptable3.expected b/src/test/correct/jumptable3/gcc/jumptable3.expected index b8e5b1154..d5441c22d 100644 --- a/src/test/correct/jumptable3/gcc/jumptable3.expected +++ b/src/test/correct/jumptable3/gcc/jumptable3.expected @@ -1,69 +1,69 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -104,7 +104,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -113,9 +113,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_six() @@ -194,6 +194,7 @@ procedure add_six() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { ladd_six: + assume {:captureState "ladd_six"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -204,6 +205,7 @@ procedure add_six() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000511"} true; return; } @@ -283,6 +285,7 @@ procedure add_two() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { ladd_two: + assume {:captureState "ladd_two"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -293,6 +296,7 @@ procedure add_two() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000004df"} true; return; } @@ -451,13 +455,18 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000556"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000055c"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000056e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000576"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967284bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934581bv33))), (Gamma_R0 && Gamma_#5); @@ -470,6 +479,7 @@ procedure main() } goto l000005e0; l000005e0: + assume {:captureState "l000005e0"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967284bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934581bv33))), (Gamma_R0 && Gamma_#6); @@ -482,6 +492,7 @@ procedure main() } goto l00000608; l00000608: + assume {:captureState "l00000608"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #7, Gamma_#7 := bvadd32(R0[32:0], 4294967285bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#7, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934582bv33))), (Gamma_R0 && Gamma_#7); @@ -494,28 +505,35 @@ procedure main() } goto l00000643; l00000629: + assume {:captureState "l00000629"} true; R30, Gamma_R30 := 2288bv64, true; call sub_seven(); goto l00000635; l00000635: + assume {:captureState "l00000635"} true; R30, Gamma_R30 := 2292bv64, true; call add_two(); goto l0000063c; l0000063c: + assume {:captureState "l0000063c"} true; R30, Gamma_R30 := 2296bv64, true; call add_six(); goto l00000599; l00000599: + assume {:captureState "l00000599"} true; R30, Gamma_R30 := 2300bv64, true; call sub_seven(); goto l000005a5; l000005a5: + assume {:captureState "l000005a5"} true; R30, Gamma_R30 := 2304bv64, true; call add_two(); goto l000005ac; l000005ac: + assume {:captureState "l000005ac"} true; goto l000005ad; l00000643: + assume {:captureState "l00000643"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #8, Gamma_#8 := bvadd32(R0[32:0], 4294967285bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#8, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934582bv33))), (Gamma_R0 && Gamma_#8); @@ -528,6 +546,7 @@ procedure main() } goto l0000066b; l0000066b: + assume {:captureState "l0000066b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #9, Gamma_#9 := bvadd32(R0[32:0], 4294967286bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#9, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934583bv33))), (Gamma_R0 && Gamma_#9); @@ -540,16 +559,20 @@ procedure main() } goto l000006a3; l0000068c: + assume {:captureState "l0000068c"} true; R30, Gamma_R30 := 2276bv64, true; call add_two(); goto l00000698; l00000698: + assume {:captureState "l00000698"} true; R30, Gamma_R30 := 2280bv64, true; call add_six(); goto l0000069f; l0000069f: + assume {:captureState "l0000069f"} true; goto l000005ad; l000006a3: + assume {:captureState "l000006a3"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #10, Gamma_#10 := bvadd32(R0[32:0], 4294967286bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#10, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934583bv33))), (Gamma_R0 && Gamma_#10); @@ -562,6 +585,7 @@ procedure main() } goto l000006cb; l000006cb: + assume {:captureState "l000006cb"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #11, Gamma_#11 := bvadd32(R0[32:0], 4294967287bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#11, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934584bv33))), (Gamma_R0 && Gamma_#11); @@ -574,6 +598,7 @@ procedure main() } goto l00000703; l00000703: + assume {:captureState "l00000703"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #12, Gamma_#12 := bvadd32(R0[32:0], 4294967287bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#12, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934584bv33))), (Gamma_R0 && Gamma_#12); @@ -586,6 +611,7 @@ procedure main() } goto l0000072b; l0000072b: + assume {:captureState "l0000072b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #13, Gamma_#13 := bvadd32(R0[32:0], 4294967288bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#13, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934585bv33))), (Gamma_R0 && Gamma_#13); @@ -598,6 +624,7 @@ procedure main() } goto l00000758; l00000758: + assume {:captureState "l00000758"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #14, Gamma_#14 := bvadd32(R0[32:0], 4294967288bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#14, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934585bv33))), (Gamma_R0 && Gamma_#14); @@ -610,6 +637,7 @@ procedure main() } goto l00000780; l00000780: + assume {:captureState "l00000780"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #15, Gamma_#15 := bvadd32(R0[32:0], 4294967289bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#15, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934586bv33))), (Gamma_R0 && Gamma_#15); @@ -622,6 +650,7 @@ procedure main() } goto l000007ad; l000007ad: + assume {:captureState "l000007ad"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #16, Gamma_#16 := bvadd32(R0[32:0], 4294967289bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#16, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934586bv33))), (Gamma_R0 && Gamma_#16); @@ -634,6 +663,7 @@ procedure main() } goto l000007d5; l000007d5: + assume {:captureState "l000007d5"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #17, Gamma_#17 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#17, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#17); @@ -646,32 +676,40 @@ procedure main() } goto l00000809; l000007f6: + assume {:captureState "l000007f6"} true; R30, Gamma_R30 := 2248bv64, true; call add_six(); goto l00000802; l00000802: + assume {:captureState "l00000802"} true; R30, Gamma_R30 := 2252bv64, true; call add_two(); goto l000007a1; l000007a1: + assume {:captureState "l000007a1"} true; R30, Gamma_R30 := 2256bv64, true; call add_six(); goto l0000074c; l0000074c: + assume {:captureState "l0000074c"} true; R30, Gamma_R30 := 2260bv64, true; call sub_seven(); goto l000006ec; l000006ec: + assume {:captureState "l000006ec"} true; R30, Gamma_R30 := 2264bv64, true; call sub_seven(); goto l000006f8; l000006f8: + assume {:captureState "l000006f8"} true; R30, Gamma_R30 := 2268bv64, true; call add_six(); goto l000006ff; l000006ff: + assume {:captureState "l000006ff"} true; goto l000005ad; l00000809: + assume {:captureState "l00000809"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #18, Gamma_#18 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#18, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#18); @@ -684,6 +722,7 @@ procedure main() } goto l00000831; l00000831: + assume {:captureState "l00000831"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #19, Gamma_#19 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#19, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#19); @@ -696,12 +735,15 @@ procedure main() } goto l00000862; l00000852: + assume {:captureState "l00000852"} true; R30, Gamma_R30 := 2240bv64, true; call add_six(); goto l0000085e; l0000085e: + assume {:captureState "l0000085e"} true; goto l000005ad; l00000862: + assume {:captureState "l00000862"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #20, Gamma_#20 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#20, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#20); @@ -714,6 +756,7 @@ procedure main() } goto l0000088a; l0000088a: + assume {:captureState "l0000088a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #21, Gamma_#21 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#21, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#21); @@ -726,16 +769,20 @@ procedure main() } goto l000008c2; l000008ab: + assume {:captureState "l000008ab"} true; R30, Gamma_R30 := 2228bv64, true; call add_two(); goto l000008b7; l000008b7: + assume {:captureState "l000008b7"} true; R30, Gamma_R30 := 2232bv64, true; call sub_seven(); goto l000008be; l000008be: + assume {:captureState "l000008be"} true; goto l000005ad; l000008c2: + assume {:captureState "l000008c2"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #22, Gamma_#22 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#22, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#22); @@ -748,6 +795,7 @@ procedure main() } goto l000008ea; l000008ea: + assume {:captureState "l000008ea"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #23, Gamma_#23 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#23, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#23); @@ -760,6 +808,7 @@ procedure main() } goto l0000091b; l0000091b: + assume {:captureState "l0000091b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #24, Gamma_#24 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#24, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#24); @@ -772,6 +821,7 @@ procedure main() } goto l00000943; l00000943: + assume {:captureState "l00000943"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #25, Gamma_#25 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#25, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#25); @@ -784,12 +834,15 @@ procedure main() } goto l0000097b; l00000964: + assume {:captureState "l00000964"} true; R30, Gamma_R30 := 2208bv64, true; call add_two(); goto l00000970; l00000970: + assume {:captureState "l00000970"} true; goto l000005ad; l0000097b: + assume {:captureState "l0000097b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #26, Gamma_#26 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#26, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#26); @@ -802,27 +855,34 @@ procedure main() } goto l000009a1; l00000974: + assume {:captureState "l00000974"} true; R30, Gamma_R30 := 2216bv64, true; call add_six(); goto l0000090b; l0000090b: + assume {:captureState "l0000090b"} true; R30, Gamma_R30 := 2220bv64, true; call sub_seven(); goto l00000917; l00000917: + assume {:captureState "l00000917"} true; goto l000005ad; l000005ad: + assume {:captureState "l000005ad"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); goto l000005c2; l000009a1: + assume {:captureState "l000009a1"} true; goto l000005d7; l000005d7: + assume {:captureState "l000005d7"} true; R0, Gamma_R0 := 1bv64, true; goto l000005c2; l000005c2: + assume {:captureState "l000005c2"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; @@ -905,6 +965,7 @@ procedure sub_seven() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lsub_seven: + assume {:captureState "lsub_seven"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -915,5 +976,6 @@ procedure sub_seven() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000543"} true; return; } diff --git a/src/test/correct/jumptable3/gcc_O2/jumptable3.expected b/src/test/correct/jumptable3/gcc_O2/jumptable3.expected index bf0bc5c31..ba99b9e81 100644 --- a/src/test/correct/jumptable3/gcc_O2/jumptable3.expected +++ b/src/test/correct/jumptable3/gcc_O2/jumptable3.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -80,7 +80,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -89,9 +89,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -219,6 +219,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; #1, Gamma_#1 := bvadd32(R0[32:0], 4294967289bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#1, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934586bv33))), (Gamma_R0 && Gamma_#1); @@ -231,12 +232,14 @@ procedure main() } goto l00000753; l00000753: + assume {:captureState "l00000753"} true; assert (Gamma_ZF && (Gamma_VF && Gamma_NF)); if ((bvand1(bvcomp1(NF, VF), bvcomp1(ZF, 0bv1)) != 0bv1)) { goto l000006e8; } goto l0000075c; l000006e8: + assume {:captureState "l000006e8"} true; R1, Gamma_R1 := 69632bv64, true; #8, Gamma_#8 := bvadd32(R0[32:0], 4294967286bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#8, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934583bv33))), (Gamma_R0 && Gamma_#8); @@ -249,20 +252,24 @@ procedure main() } goto l0000070c; l000005f9: + assume {:captureState "l000005f9"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 8bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%0000060c"} true; goto l00000360; l0000070c: + assume {:captureState "l0000070c"} true; assert (Gamma_ZF && (Gamma_VF && Gamma_NF)); if ((bvnot1(bvand1(bvcomp1(NF, VF), bvcomp1(ZF, 0bv1))) != 0bv1)) { goto l00000644; } goto l00000715; l00000644: + assume {:captureState "l00000644"} true; #6, Gamma_#6 := bvadd32(R0[32:0], 4294967288bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934585bv33))), (Gamma_R0 && Gamma_#6); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#6, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967289bv33))), (Gamma_R0 && Gamma_#6); @@ -274,6 +281,7 @@ procedure main() } goto l00000663; l00000663: + assume {:captureState "l00000663"} true; #7, Gamma_#7 := bvadd32(R0[32:0], 4294967287bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#7, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934584bv33))), (Gamma_R0 && Gamma_#7); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#7, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967288bv33))), (Gamma_R0 && Gamma_#7); @@ -285,6 +293,7 @@ procedure main() } goto l00000347; l00000715: + assume {:captureState "l00000715"} true; #9, Gamma_#9 := bvadd32(R0[32:0], 4294967285bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#9, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934582bv33))), (Gamma_R0 && Gamma_#9); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#9, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967286bv33))), (Gamma_R0 && Gamma_#9); @@ -296,14 +305,17 @@ procedure main() } goto l00000734; l00000612: + assume {:captureState "l00000612"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 1bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%00000625"} true; goto l00000628; l00000734: + assume {:captureState "l00000734"} true; #10, Gamma_#10 := bvadd32(R0[32:0], 4294967284bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#10, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934581bv33))), (Gamma_R0 && Gamma_#10); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#10, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967285bv33))), (Gamma_R0 && Gamma_#10); @@ -315,14 +327,17 @@ procedure main() } goto l00000628; l00000628: + assume {:captureState "l00000628"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 4294967291bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%0000063e"} true; goto l00000360; l0000075c: + assume {:captureState "l0000075c"} true; #11, Gamma_#11 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#11, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#11); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#11, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967293bv33))), (Gamma_R0 && Gamma_#11); @@ -334,6 +349,7 @@ procedure main() } goto l0000077b; l0000069c: + assume {:captureState "l0000069c"} true; R1, Gamma_R1 := 69632bv64, true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); @@ -341,14 +357,17 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%000006b4"} true; goto l00000360; l0000077b: + assume {:captureState "l0000077b"} true; assert (Gamma_ZF && (Gamma_VF && Gamma_NF)); if ((bvand1(bvcomp1(NF, VF), bvcomp1(ZF, 0bv1)) != 0bv1)) { goto l000005bc; } goto l00000784; l000005bc: + assume {:captureState "l000005bc"} true; #5, Gamma_#5 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#5); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#5, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967292bv33))), (Gamma_R0 && Gamma_#5); @@ -360,6 +379,7 @@ procedure main() } goto l00000682; l000005d6: + assume {:captureState "l000005d6"} true; R1, Gamma_R1 := 69632bv64, true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); @@ -367,8 +387,10 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%000005f3"} true; goto l00000360; l00000682: + assume {:captureState "l00000682"} true; R1, Gamma_R1 := 69632bv64, true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); @@ -376,32 +398,40 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%0000069a"} true; goto l00000317; l00000317: + assume {:captureState "l00000317"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 6bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%0000032f"} true; goto l00000331; l00000331: + assume {:captureState "l00000331"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 4294967289bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%00000344"} true; goto l00000347; l00000347: + assume {:captureState "l00000347"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 4294967295bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%0000035d"} true; goto l00000360; l00000784: + assume {:captureState "l00000784"} true; R1, Gamma_R1 := 69632bv64, true; #12, Gamma_#12 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#12, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#12); @@ -414,14 +444,17 @@ procedure main() } goto l000007a8; l000006ba: + assume {:captureState "l000006ba"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 6bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%000006cd"} true; goto l000006d0; l000007a8: + assume {:captureState "l000007a8"} true; #13, Gamma_#13 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#13, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#13); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#13, 1bv32)), bvadd33(zero_extend1_32(R0[32:0]), 4294967294bv33))), (Gamma_R0 && Gamma_#13); @@ -433,30 +466,37 @@ procedure main() } goto l000006d0; l00000368: + assume {:captureState "l00000368"} true; assert Gamma_R0; if ((bvnot1(bvcomp32(R0[32:0], 0bv32)) != 0bv1)) { goto l0000036b; } goto l000005a3; l0000036b: + assume {:captureState "l0000036b"} true; R0, Gamma_R0 := 1bv64, true; return; l000005a3: + assume {:captureState "l000005a3"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 2bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%000005b6"} true; goto l00000360; l000006d0: + assume {:captureState "l000006d0"} true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R1, 16bv64))), (gamma_load32(Gamma_mem, bvadd64(R1, 16bv64)) || L(mem, bvadd64(R1, 16bv64))); R0, Gamma_R0 := zero_extend32_32(bvadd32(R0[32:0], 4294967289bv32)), Gamma_R0; call rely(); assert (L(mem, bvadd64(R1, 16bv64)) ==> Gamma_R0); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 16bv64), R0[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 16bv64), Gamma_R0); + assume {:captureState "%000006e6"} true; goto l00000360; l00000360: + assume {:captureState "l00000360"} true; return; } diff --git a/src/test/correct/jumptable3/gcc_no_plt_no_pic/jumptable3.expected b/src/test/correct/jumptable3/gcc_no_plt_no_pic/jumptable3.expected index a6cb75ea3..5a02b2247 100644 --- a/src/test/correct/jumptable3/gcc_no_plt_no_pic/jumptable3.expected +++ b/src/test/correct/jumptable3/gcc_no_plt_no_pic/jumptable3.expected @@ -1,69 +1,69 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -104,7 +104,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -113,9 +113,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_six() @@ -194,6 +194,7 @@ procedure add_six() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { ladd_six: + assume {:captureState "ladd_six"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -204,6 +205,7 @@ procedure add_six() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000126c"} true; return; } @@ -283,6 +285,7 @@ procedure add_two() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { ladd_two: + assume {:captureState "ladd_two"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -293,6 +296,7 @@ procedure add_two() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000123a"} true; return; } @@ -451,13 +455,18 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000012b1"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000012b7"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000012c9"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%000012d1"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967284bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934581bv33))), (Gamma_R0 && Gamma_#5); @@ -470,6 +479,7 @@ procedure main() } goto l0000133b; l0000133b: + assume {:captureState "l0000133b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967284bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934581bv33))), (Gamma_R0 && Gamma_#6); @@ -482,6 +492,7 @@ procedure main() } goto l00001363; l00001363: + assume {:captureState "l00001363"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #7, Gamma_#7 := bvadd32(R0[32:0], 4294967285bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#7, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934582bv33))), (Gamma_R0 && Gamma_#7); @@ -494,28 +505,35 @@ procedure main() } goto l0000139e; l00001384: + assume {:captureState "l00001384"} true; R30, Gamma_R30 := 2288bv64, true; call sub_seven(); goto l00001390; l00001390: + assume {:captureState "l00001390"} true; R30, Gamma_R30 := 2292bv64, true; call add_two(); goto l00001397; l00001397: + assume {:captureState "l00001397"} true; R30, Gamma_R30 := 2296bv64, true; call add_six(); goto l000012f4; l000012f4: + assume {:captureState "l000012f4"} true; R30, Gamma_R30 := 2300bv64, true; call sub_seven(); goto l00001300; l00001300: + assume {:captureState "l00001300"} true; R30, Gamma_R30 := 2304bv64, true; call add_two(); goto l00001307; l00001307: + assume {:captureState "l00001307"} true; goto l00001308; l0000139e: + assume {:captureState "l0000139e"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #8, Gamma_#8 := bvadd32(R0[32:0], 4294967285bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#8, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934582bv33))), (Gamma_R0 && Gamma_#8); @@ -528,6 +546,7 @@ procedure main() } goto l000013c6; l000013c6: + assume {:captureState "l000013c6"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #9, Gamma_#9 := bvadd32(R0[32:0], 4294967286bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#9, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934583bv33))), (Gamma_R0 && Gamma_#9); @@ -540,16 +559,20 @@ procedure main() } goto l000013fe; l000013e7: + assume {:captureState "l000013e7"} true; R30, Gamma_R30 := 2276bv64, true; call add_two(); goto l000013f3; l000013f3: + assume {:captureState "l000013f3"} true; R30, Gamma_R30 := 2280bv64, true; call add_six(); goto l000013fa; l000013fa: + assume {:captureState "l000013fa"} true; goto l00001308; l000013fe: + assume {:captureState "l000013fe"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #10, Gamma_#10 := bvadd32(R0[32:0], 4294967286bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#10, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934583bv33))), (Gamma_R0 && Gamma_#10); @@ -562,6 +585,7 @@ procedure main() } goto l00001426; l00001426: + assume {:captureState "l00001426"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #11, Gamma_#11 := bvadd32(R0[32:0], 4294967287bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#11, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934584bv33))), (Gamma_R0 && Gamma_#11); @@ -574,6 +598,7 @@ procedure main() } goto l0000145e; l0000145e: + assume {:captureState "l0000145e"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #12, Gamma_#12 := bvadd32(R0[32:0], 4294967287bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#12, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934584bv33))), (Gamma_R0 && Gamma_#12); @@ -586,6 +611,7 @@ procedure main() } goto l00001486; l00001486: + assume {:captureState "l00001486"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #13, Gamma_#13 := bvadd32(R0[32:0], 4294967288bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#13, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934585bv33))), (Gamma_R0 && Gamma_#13); @@ -598,6 +624,7 @@ procedure main() } goto l000014b3; l000014b3: + assume {:captureState "l000014b3"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #14, Gamma_#14 := bvadd32(R0[32:0], 4294967288bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#14, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934585bv33))), (Gamma_R0 && Gamma_#14); @@ -610,6 +637,7 @@ procedure main() } goto l000014db; l000014db: + assume {:captureState "l000014db"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #15, Gamma_#15 := bvadd32(R0[32:0], 4294967289bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#15, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934586bv33))), (Gamma_R0 && Gamma_#15); @@ -622,6 +650,7 @@ procedure main() } goto l00001508; l00001508: + assume {:captureState "l00001508"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #16, Gamma_#16 := bvadd32(R0[32:0], 4294967289bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#16, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934586bv33))), (Gamma_R0 && Gamma_#16); @@ -634,6 +663,7 @@ procedure main() } goto l00001530; l00001530: + assume {:captureState "l00001530"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #17, Gamma_#17 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#17, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#17); @@ -646,32 +676,40 @@ procedure main() } goto l00001564; l00001551: + assume {:captureState "l00001551"} true; R30, Gamma_R30 := 2248bv64, true; call add_six(); goto l0000155d; l0000155d: + assume {:captureState "l0000155d"} true; R30, Gamma_R30 := 2252bv64, true; call add_two(); goto l000014fc; l000014fc: + assume {:captureState "l000014fc"} true; R30, Gamma_R30 := 2256bv64, true; call add_six(); goto l000014a7; l000014a7: + assume {:captureState "l000014a7"} true; R30, Gamma_R30 := 2260bv64, true; call sub_seven(); goto l00001447; l00001447: + assume {:captureState "l00001447"} true; R30, Gamma_R30 := 2264bv64, true; call sub_seven(); goto l00001453; l00001453: + assume {:captureState "l00001453"} true; R30, Gamma_R30 := 2268bv64, true; call add_six(); goto l0000145a; l0000145a: + assume {:captureState "l0000145a"} true; goto l00001308; l00001564: + assume {:captureState "l00001564"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #18, Gamma_#18 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#18, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#18); @@ -684,6 +722,7 @@ procedure main() } goto l0000158c; l0000158c: + assume {:captureState "l0000158c"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #19, Gamma_#19 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#19, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#19); @@ -696,12 +735,15 @@ procedure main() } goto l000015bd; l000015ad: + assume {:captureState "l000015ad"} true; R30, Gamma_R30 := 2240bv64, true; call add_six(); goto l000015b9; l000015b9: + assume {:captureState "l000015b9"} true; goto l00001308; l000015bd: + assume {:captureState "l000015bd"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #20, Gamma_#20 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#20, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#20); @@ -714,6 +756,7 @@ procedure main() } goto l000015e5; l000015e5: + assume {:captureState "l000015e5"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #21, Gamma_#21 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#21, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#21); @@ -726,16 +769,20 @@ procedure main() } goto l0000161d; l00001606: + assume {:captureState "l00001606"} true; R30, Gamma_R30 := 2228bv64, true; call add_two(); goto l00001612; l00001612: + assume {:captureState "l00001612"} true; R30, Gamma_R30 := 2232bv64, true; call sub_seven(); goto l00001619; l00001619: + assume {:captureState "l00001619"} true; goto l00001308; l0000161d: + assume {:captureState "l0000161d"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #22, Gamma_#22 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#22, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#22); @@ -748,6 +795,7 @@ procedure main() } goto l00001645; l00001645: + assume {:captureState "l00001645"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #23, Gamma_#23 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#23, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#23); @@ -760,6 +808,7 @@ procedure main() } goto l00001676; l00001676: + assume {:captureState "l00001676"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #24, Gamma_#24 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#24, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#24); @@ -772,6 +821,7 @@ procedure main() } goto l0000169e; l0000169e: + assume {:captureState "l0000169e"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #25, Gamma_#25 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#25, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#25); @@ -784,12 +834,15 @@ procedure main() } goto l000016d6; l000016bf: + assume {:captureState "l000016bf"} true; R30, Gamma_R30 := 2208bv64, true; call add_two(); goto l000016cb; l000016cb: + assume {:captureState "l000016cb"} true; goto l00001308; l000016d6: + assume {:captureState "l000016d6"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #26, Gamma_#26 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#26, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#26); @@ -802,27 +855,34 @@ procedure main() } goto l000016fc; l000016cf: + assume {:captureState "l000016cf"} true; R30, Gamma_R30 := 2216bv64, true; call add_six(); goto l00001666; l00001666: + assume {:captureState "l00001666"} true; R30, Gamma_R30 := 2220bv64, true; call sub_seven(); goto l00001672; l00001672: + assume {:captureState "l00001672"} true; goto l00001308; l00001308: + assume {:captureState "l00001308"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); goto l0000131d; l000016fc: + assume {:captureState "l000016fc"} true; goto l00001332; l00001332: + assume {:captureState "l00001332"} true; R0, Gamma_R0 := 1bv64, true; goto l0000131d; l0000131d: + assume {:captureState "l0000131d"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; @@ -905,6 +965,7 @@ procedure sub_seven() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lsub_seven: + assume {:captureState "lsub_seven"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 16bv64), Gamma_R0; call rely(); @@ -915,5 +976,6 @@ procedure sub_seven() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000129e"} true; return; } diff --git a/src/test/correct/jumptable3/gcc_pic/jumptable3.expected b/src/test/correct/jumptable3/gcc_pic/jumptable3.expected index 848f8d9ad..e08035a08 100644 --- a/src/test/correct/jumptable3/gcc_pic/jumptable3.expected +++ b/src/test/correct/jumptable3/gcc_pic/jumptable3.expected @@ -1,69 +1,69 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -112,7 +112,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -121,9 +121,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure add_six() @@ -218,6 +218,7 @@ procedure add_six() free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); { ladd_six: + assume {:captureState "ladd_six"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -230,6 +231,7 @@ procedure add_six() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000515"} true; return; } @@ -325,6 +327,7 @@ procedure add_two() free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); { ladd_two: + assume {:captureState "ladd_two"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -337,6 +340,7 @@ procedure add_two() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000004e1"} true; return; } @@ -511,13 +515,18 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000055c"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000562"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000574"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%0000057c"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967284bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934581bv33))), (Gamma_R0 && Gamma_#5); @@ -530,6 +539,7 @@ procedure main() } goto l000005e7; l000005e7: + assume {:captureState "l000005e7"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967284bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934581bv33))), (Gamma_R0 && Gamma_#6); @@ -542,6 +552,7 @@ procedure main() } goto l0000060f; l0000060f: + assume {:captureState "l0000060f"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #7, Gamma_#7 := bvadd32(R0[32:0], 4294967285bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#7, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934582bv33))), (Gamma_R0 && Gamma_#7); @@ -554,28 +565,35 @@ procedure main() } goto l0000064a; l00000630: + assume {:captureState "l00000630"} true; R30, Gamma_R30 := 2352bv64, true; call sub_seven(); goto l0000063c; l0000063c: + assume {:captureState "l0000063c"} true; R30, Gamma_R30 := 2356bv64, true; call add_two(); goto l00000643; l00000643: + assume {:captureState "l00000643"} true; R30, Gamma_R30 := 2360bv64, true; call add_six(); goto l0000059f; l0000059f: + assume {:captureState "l0000059f"} true; R30, Gamma_R30 := 2364bv64, true; call sub_seven(); goto l000005ab; l000005ab: + assume {:captureState "l000005ab"} true; R30, Gamma_R30 := 2368bv64, true; call add_two(); goto l000005b2; l000005b2: + assume {:captureState "l000005b2"} true; goto l000005b3; l0000064a: + assume {:captureState "l0000064a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #8, Gamma_#8 := bvadd32(R0[32:0], 4294967285bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#8, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934582bv33))), (Gamma_R0 && Gamma_#8); @@ -588,6 +606,7 @@ procedure main() } goto l00000672; l00000672: + assume {:captureState "l00000672"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #9, Gamma_#9 := bvadd32(R0[32:0], 4294967286bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#9, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934583bv33))), (Gamma_R0 && Gamma_#9); @@ -600,16 +619,20 @@ procedure main() } goto l000006aa; l00000693: + assume {:captureState "l00000693"} true; R30, Gamma_R30 := 2340bv64, true; call add_two(); goto l0000069f; l0000069f: + assume {:captureState "l0000069f"} true; R30, Gamma_R30 := 2344bv64, true; call add_six(); goto l000006a6; l000006a6: + assume {:captureState "l000006a6"} true; goto l000005b3; l000006aa: + assume {:captureState "l000006aa"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #10, Gamma_#10 := bvadd32(R0[32:0], 4294967286bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#10, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934583bv33))), (Gamma_R0 && Gamma_#10); @@ -622,6 +645,7 @@ procedure main() } goto l000006d2; l000006d2: + assume {:captureState "l000006d2"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #11, Gamma_#11 := bvadd32(R0[32:0], 4294967287bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#11, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934584bv33))), (Gamma_R0 && Gamma_#11); @@ -634,6 +658,7 @@ procedure main() } goto l0000070a; l0000070a: + assume {:captureState "l0000070a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #12, Gamma_#12 := bvadd32(R0[32:0], 4294967287bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#12, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934584bv33))), (Gamma_R0 && Gamma_#12); @@ -646,6 +671,7 @@ procedure main() } goto l00000732; l00000732: + assume {:captureState "l00000732"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #13, Gamma_#13 := bvadd32(R0[32:0], 4294967288bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#13, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934585bv33))), (Gamma_R0 && Gamma_#13); @@ -658,6 +684,7 @@ procedure main() } goto l0000075f; l0000075f: + assume {:captureState "l0000075f"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #14, Gamma_#14 := bvadd32(R0[32:0], 4294967288bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#14, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934585bv33))), (Gamma_R0 && Gamma_#14); @@ -670,6 +697,7 @@ procedure main() } goto l00000787; l00000787: + assume {:captureState "l00000787"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #15, Gamma_#15 := bvadd32(R0[32:0], 4294967289bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#15, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934586bv33))), (Gamma_R0 && Gamma_#15); @@ -682,6 +710,7 @@ procedure main() } goto l000007b4; l000007b4: + assume {:captureState "l000007b4"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #16, Gamma_#16 := bvadd32(R0[32:0], 4294967289bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#16, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934586bv33))), (Gamma_R0 && Gamma_#16); @@ -694,6 +723,7 @@ procedure main() } goto l000007dc; l000007dc: + assume {:captureState "l000007dc"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #17, Gamma_#17 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#17, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#17); @@ -706,32 +736,40 @@ procedure main() } goto l00000810; l000007fd: + assume {:captureState "l000007fd"} true; R30, Gamma_R30 := 2312bv64, true; call add_six(); goto l00000809; l00000809: + assume {:captureState "l00000809"} true; R30, Gamma_R30 := 2316bv64, true; call add_two(); goto l000007a8; l000007a8: + assume {:captureState "l000007a8"} true; R30, Gamma_R30 := 2320bv64, true; call add_six(); goto l00000753; l00000753: + assume {:captureState "l00000753"} true; R30, Gamma_R30 := 2324bv64, true; call sub_seven(); goto l000006f3; l000006f3: + assume {:captureState "l000006f3"} true; R30, Gamma_R30 := 2328bv64, true; call sub_seven(); goto l000006ff; l000006ff: + assume {:captureState "l000006ff"} true; R30, Gamma_R30 := 2332bv64, true; call add_six(); goto l00000706; l00000706: + assume {:captureState "l00000706"} true; goto l000005b3; l00000810: + assume {:captureState "l00000810"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #18, Gamma_#18 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#18, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#18); @@ -744,6 +782,7 @@ procedure main() } goto l00000838; l00000838: + assume {:captureState "l00000838"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #19, Gamma_#19 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#19, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#19); @@ -756,12 +795,15 @@ procedure main() } goto l00000869; l00000859: + assume {:captureState "l00000859"} true; R30, Gamma_R30 := 2304bv64, true; call add_six(); goto l00000865; l00000865: + assume {:captureState "l00000865"} true; goto l000005b3; l00000869: + assume {:captureState "l00000869"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #20, Gamma_#20 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#20, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#20); @@ -774,6 +816,7 @@ procedure main() } goto l00000891; l00000891: + assume {:captureState "l00000891"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #21, Gamma_#21 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#21, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#21); @@ -786,16 +829,20 @@ procedure main() } goto l000008c9; l000008b2: + assume {:captureState "l000008b2"} true; R30, Gamma_R30 := 2292bv64, true; call add_two(); goto l000008be; l000008be: + assume {:captureState "l000008be"} true; R30, Gamma_R30 := 2296bv64, true; call sub_seven(); goto l000008c5; l000008c5: + assume {:captureState "l000008c5"} true; goto l000005b3; l000008c9: + assume {:captureState "l000008c9"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #22, Gamma_#22 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#22, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#22); @@ -808,6 +855,7 @@ procedure main() } goto l000008f1; l000008f1: + assume {:captureState "l000008f1"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #23, Gamma_#23 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#23, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#23); @@ -820,6 +868,7 @@ procedure main() } goto l00000922; l00000922: + assume {:captureState "l00000922"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #24, Gamma_#24 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#24, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#24); @@ -832,6 +881,7 @@ procedure main() } goto l0000094a; l0000094a: + assume {:captureState "l0000094a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #25, Gamma_#25 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#25, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#25); @@ -844,12 +894,15 @@ procedure main() } goto l00000982; l0000096b: + assume {:captureState "l0000096b"} true; R30, Gamma_R30 := 2272bv64, true; call add_two(); goto l00000977; l00000977: + assume {:captureState "l00000977"} true; goto l000005b3; l00000982: + assume {:captureState "l00000982"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #26, Gamma_#26 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#26, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#26); @@ -862,16 +915,20 @@ procedure main() } goto l000009a8; l0000097b: + assume {:captureState "l0000097b"} true; R30, Gamma_R30 := 2280bv64, true; call add_six(); goto l00000912; l00000912: + assume {:captureState "l00000912"} true; R30, Gamma_R30 := 2284bv64, true; call sub_seven(); goto l0000091e; l0000091e: + assume {:captureState "l0000091e"} true; goto l000005b3; l000005b3: + assume {:captureState "l000005b3"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -879,11 +936,14 @@ procedure main() R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); goto l000005c9; l000009a8: + assume {:captureState "l000009a8"} true; goto l000005de; l000005de: + assume {:captureState "l000005de"} true; R0, Gamma_R0 := 1bv64, true; goto l000005c9; l000005c9: + assume {:captureState "l000005c9"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; @@ -982,6 +1042,7 @@ procedure sub_seven() free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); { lsub_seven: + assume {:captureState "lsub_seven"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -994,5 +1055,6 @@ procedure sub_seven() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000549"} true; return; } diff --git a/src/test/correct/malloc_with_local/clang/malloc_with_local.expected b/src/test/correct/malloc_with_local/clang/malloc_with_local.expected index 152aff0da..ecaf1a185 100644 --- a/src/test/correct/malloc_with_local/clang/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/clang/malloc_with_local.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2256bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -178,7 +178,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -187,9 +187,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -607,38 +607,50 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000362"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000368"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, R31, R8[32:0]), gamma_store32(Gamma_stack, R31, Gamma_R8); + assume {:captureState "%0000037b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000382"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000391; l00000391: + assume {:captureState "l00000391"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000397"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2112bv64, true; call malloc(); goto l000003a5; l000003a5: + assume {:captureState "l000003a5"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000003ab"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%000003b8"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003cc"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003e0"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -648,6 +660,7 @@ procedure main() call printf(); goto l00000403; l00000403: + assume {:captureState "l00000403"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -657,6 +670,7 @@ procedure main() call printf(); goto l00000423; l00000423: + assume {:captureState "l00000423"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2293bv64), Gamma_R0; @@ -664,16 +678,19 @@ procedure main() call printf(); goto l0000043c; l0000043c: + assume {:captureState "l0000043c"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2212bv64, true; call #free(); goto l0000044b; l0000044b: + assume {:captureState "l0000044b"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2220bv64, true; call #free(); goto l00000459; l00000459: + assume {:captureState "l00000459"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, R31)), gamma_load32(Gamma_stack, R31); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected b/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected index 6ecb21b64..775c83e11 100644 --- a/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/clang_O2/malloc_with_local.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1964bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -140,7 +140,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -149,9 +149,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -372,9 +372,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f8"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002fe"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 0bv64, true; @@ -384,6 +387,7 @@ procedure main() call printf(); goto l00000322; l00000322: + assume {:captureState "l00000322"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 1985bv64), Gamma_R0; R1, Gamma_R1 := 42bv64, true; @@ -391,6 +395,7 @@ procedure main() call printf(); goto l00000339; l00000339: + assume {:captureState "l00000339"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2001bv64), Gamma_R0; R1, Gamma_R1 := 10bv64, true; @@ -398,6 +403,7 @@ procedure main() call printf(); goto l00000350; l00000350: + assume {:captureState "l00000350"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local/clang_no_plt_no_pic/malloc_with_local.expected b/src/test/correct/malloc_with_local/clang_no_plt_no_pic/malloc_with_local.expected index cd0687851..07ac928d3 100644 --- a/src/test/correct/malloc_with_local/clang_no_plt_no_pic/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/clang_no_plt_no_pic/malloc_with_local.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2256bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -178,7 +178,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -187,9 +187,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -607,38 +607,50 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000ad4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000ada"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, R31, R8[32:0]), gamma_store32(Gamma_stack, R31, Gamma_R8); + assume {:captureState "%00000aed"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000af4"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000b03; l00000b03: + assume {:captureState "l00000b03"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000b09"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2112bv64, true; call malloc(); goto l00000b17; l00000b17: + assume {:captureState "l00000b17"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000b1d"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b2a"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000b3e"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000b52"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -648,6 +660,7 @@ procedure main() call printf(); goto l00000b75; l00000b75: + assume {:captureState "l00000b75"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -657,6 +670,7 @@ procedure main() call printf(); goto l00000b95; l00000b95: + assume {:captureState "l00000b95"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2293bv64), Gamma_R0; @@ -664,16 +678,19 @@ procedure main() call printf(); goto l00000bae; l00000bae: + assume {:captureState "l00000bae"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2212bv64, true; call #free(); goto l00000bbd; l00000bbd: + assume {:captureState "l00000bbd"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2220bv64, true; call #free(); goto l00000bcb; l00000bcb: + assume {:captureState "l00000bcb"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, R31)), gamma_load32(Gamma_stack, R31); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/malloc_with_local/clang_pic/malloc_with_local.expected b/src/test/correct/malloc_with_local/clang_pic/malloc_with_local.expected index cd0687851..07ac928d3 100644 --- a/src/test/correct/malloc_with_local/clang_pic/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/clang_pic/malloc_with_local.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2256bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -178,7 +178,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -187,9 +187,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -607,38 +607,50 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000ad4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000ada"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, R31, R8[32:0]), gamma_store32(Gamma_stack, R31, Gamma_R8); + assume {:captureState "%00000aed"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000af4"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000b03; l00000b03: + assume {:captureState "l00000b03"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000b09"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2112bv64, true; call malloc(); goto l00000b17; l00000b17: + assume {:captureState "l00000b17"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000b1d"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b2a"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000b3e"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000b52"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -648,6 +660,7 @@ procedure main() call printf(); goto l00000b75; l00000b75: + assume {:captureState "l00000b75"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -657,6 +670,7 @@ procedure main() call printf(); goto l00000b95; l00000b95: + assume {:captureState "l00000b95"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2293bv64), Gamma_R0; @@ -664,16 +678,19 @@ procedure main() call printf(); goto l00000bae; l00000bae: + assume {:captureState "l00000bae"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2212bv64, true; call #free(); goto l00000bbd; l00000bbd: + assume {:captureState "l00000bbd"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2220bv64, true; call #free(); goto l00000bcb; l00000bcb: + assume {:captureState "l00000bcb"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, R31)), gamma_load32(Gamma_stack, R31); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected b/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected index 746e71b97..7853707b6 100644 --- a/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/gcc/malloc_with_local.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2248bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -656,9 +656,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000350"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000356"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -666,25 +669,32 @@ procedure main() call malloc(); goto l0000036f; l0000036f: + assume {:captureState "l0000036f"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000375"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2096bv64, true; call malloc(); goto l00000383; l00000383: + assume {:captureState "l00000383"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000389"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000396"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003aa"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003be"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -695,6 +705,7 @@ procedure main() call printf(); goto l000003e7; l000003e7: + assume {:captureState "l000003e7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -705,6 +716,7 @@ procedure main() call printf(); goto l0000040d; l0000040d: + assume {:captureState "l0000040d"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2296bv64), Gamma_R0; @@ -712,16 +724,19 @@ procedure main() call printf(); goto l00000426; l00000426: + assume {:captureState "l00000426"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2204bv64, true; call #free(); goto l00000435; l00000435: + assume {:captureState "l00000435"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2212bv64, true; call #free(); goto l00000443; l00000443: + assume {:captureState "l00000443"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected b/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected index 0226bf176..2f63e0068 100644 --- a/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2088bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -153,7 +153,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -162,9 +162,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure __printf_chk(); @@ -624,9 +624,12 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%000001f2"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%000001f8"} true; R31, Gamma_R31 := #1, Gamma_#1; R2, Gamma_R2 := 65bv64, true; R1, Gamma_R1 := 0bv64, true; @@ -637,6 +640,7 @@ procedure main() call __printf_chk(); goto l00000221; l00000221: + assume {:captureState "l00000221"} true; R2, Gamma_R2 := 42bv64, true; R1, Gamma_R1 := 0bv64, true; R0, Gamma_R0 := 1bv64, true; @@ -645,6 +649,7 @@ procedure main() call __printf_chk(); goto l0000023d; l0000023d: + assume {:captureState "l0000023d"} true; R2, Gamma_R2 := 10bv64, true; R1, Gamma_R1 := 0bv64, true; R0, Gamma_R0 := 1bv64, true; @@ -653,6 +658,7 @@ procedure main() call __printf_chk(); goto l00000259; l00000259: + assume {:captureState "l00000259"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local/gcc_no_plt_no_pic/malloc_with_local.expected b/src/test/correct/malloc_with_local/gcc_no_plt_no_pic/malloc_with_local.expected index 3a6f53042..91f3ea4d7 100644 --- a/src/test/correct/malloc_with_local/gcc_no_plt_no_pic/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/gcc_no_plt_no_pic/malloc_with_local.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2248bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -656,9 +656,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000aa1"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000aa7"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -666,25 +669,32 @@ procedure main() call malloc(); goto l00000ac0; l00000ac0: + assume {:captureState "l00000ac0"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000ac6"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2096bv64, true; call malloc(); goto l00000ad4; l00000ad4: + assume {:captureState "l00000ad4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000ada"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000ae7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000afb"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000b0f"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -695,6 +705,7 @@ procedure main() call printf(); goto l00000b38; l00000b38: + assume {:captureState "l00000b38"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -705,6 +716,7 @@ procedure main() call printf(); goto l00000b5e; l00000b5e: + assume {:captureState "l00000b5e"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2296bv64), Gamma_R0; @@ -712,16 +724,19 @@ procedure main() call printf(); goto l00000b77; l00000b77: + assume {:captureState "l00000b77"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2204bv64, true; call #free(); goto l00000b86; l00000b86: + assume {:captureState "l00000b86"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2212bv64, true; call #free(); goto l00000b94; l00000b94: + assume {:captureState "l00000b94"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local/gcc_pic/malloc_with_local.expected b/src/test/correct/malloc_with_local/gcc_pic/malloc_with_local.expected index 3a6f53042..91f3ea4d7 100644 --- a/src/test/correct/malloc_with_local/gcc_pic/malloc_with_local.expected +++ b/src/test/correct/malloc_with_local/gcc_pic/malloc_with_local.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2248bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -656,9 +656,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000aa1"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000aa7"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -666,25 +669,32 @@ procedure main() call malloc(); goto l00000ac0; l00000ac0: + assume {:captureState "l00000ac0"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000ac6"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2096bv64, true; call malloc(); goto l00000ad4; l00000ad4: + assume {:captureState "l00000ad4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000ada"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000ae7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000afb"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000b0f"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -695,6 +705,7 @@ procedure main() call printf(); goto l00000b38; l00000b38: + assume {:captureState "l00000b38"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -705,6 +716,7 @@ procedure main() call printf(); goto l00000b5e; l00000b5e: + assume {:captureState "l00000b5e"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2296bv64), Gamma_R0; @@ -712,16 +724,19 @@ procedure main() call printf(); goto l00000b77; l00000b77: + assume {:captureState "l00000b77"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2204bv64, true; call #free(); goto l00000b86; l00000b86: + assume {:captureState "l00000b86"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2212bv64, true; call #free(); goto l00000b94; l00000b94: + assume {:captureState "l00000b94"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected index 3f1de863a..6030ae003 100644 --- a/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/clang/malloc_with_local2.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2292bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -178,7 +178,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -187,9 +187,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -607,50 +607,67 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000386"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000038c"} true; R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000039f"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%000003a6"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l000003b5; l000003b5: + assume {:captureState "l000003b5"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%000003bb"} true; R8, Gamma_R8 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%000003c8"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%000003d5"} true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l000003de; l000003de: + assume {:captureState "l000003de"} true; R8, Gamma_R8 := R0, Gamma_R0; R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%000003f1"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%000003fe"} true; R30, Gamma_R30 := 2148bv64, true; call malloc(); goto l00000407; l00000407: + assume {:captureState "l00000407"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%0000040d"} true; R8, Gamma_R8 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000041a"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000042e"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000442"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -660,6 +677,7 @@ procedure main() call printf(); goto l00000465; l00000465: + assume {:captureState "l00000465"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -669,6 +687,7 @@ procedure main() call printf(); goto l00000485; l00000485: + assume {:captureState "l00000485"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2329bv64), Gamma_R0; @@ -676,16 +695,19 @@ procedure main() call printf(); goto l0000049e; l0000049e: + assume {:captureState "l0000049e"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2248bv64, true; call #free(); goto l000004ad; l000004ad: + assume {:captureState "l000004ad"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2256bv64, true; call #free(); goto l000004bb; l000004bb: + assume {:captureState "l000004bb"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd64(R31, 64bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/malloc_with_local2/clang_O2/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/clang_O2/malloc_with_local2.expected index 6ecb21b64..775c83e11 100644 --- a/src/test/correct/malloc_with_local2/clang_O2/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/clang_O2/malloc_with_local2.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1964bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -140,7 +140,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -149,9 +149,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -372,9 +372,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002f8"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002fe"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 0bv64, true; @@ -384,6 +387,7 @@ procedure main() call printf(); goto l00000322; l00000322: + assume {:captureState "l00000322"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 1985bv64), Gamma_R0; R1, Gamma_R1 := 42bv64, true; @@ -391,6 +395,7 @@ procedure main() call printf(); goto l00000339; l00000339: + assume {:captureState "l00000339"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2001bv64), Gamma_R0; R1, Gamma_R1 := 10bv64, true; @@ -398,6 +403,7 @@ procedure main() call printf(); goto l00000350; l00000350: + assume {:captureState "l00000350"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local2/clang_no_plt_no_pic/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/clang_no_plt_no_pic/malloc_with_local2.expected index 4552108bd..8645f53a7 100644 --- a/src/test/correct/malloc_with_local2/clang_no_plt_no_pic/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/clang_no_plt_no_pic/malloc_with_local2.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2292bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -178,7 +178,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -187,9 +187,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -607,50 +607,67 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000b63"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000b69"} true; R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000b7c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000b83"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000b92; l00000b92: + assume {:captureState "l00000b92"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%00000b98"} true; R8, Gamma_R8 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%00000ba5"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%00000bb2"} true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000bbb; l00000bbb: + assume {:captureState "l00000bbb"} true; R8, Gamma_R8 := R0, Gamma_R0; R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%00000bce"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%00000bdb"} true; R30, Gamma_R30 := 2148bv64, true; call malloc(); goto l00000be4; l00000be4: + assume {:captureState "l00000be4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000bea"} true; R8, Gamma_R8 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000bf7"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000c0b"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000c1f"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -660,6 +677,7 @@ procedure main() call printf(); goto l00000c42; l00000c42: + assume {:captureState "l00000c42"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -669,6 +687,7 @@ procedure main() call printf(); goto l00000c62; l00000c62: + assume {:captureState "l00000c62"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2329bv64), Gamma_R0; @@ -676,16 +695,19 @@ procedure main() call printf(); goto l00000c7b; l00000c7b: + assume {:captureState "l00000c7b"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2248bv64, true; call #free(); goto l00000c8a; l00000c8a: + assume {:captureState "l00000c8a"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2256bv64, true; call #free(); goto l00000c98; l00000c98: + assume {:captureState "l00000c98"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd64(R31, 64bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/malloc_with_local2/clang_pic/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/clang_pic/malloc_with_local2.expected index 4552108bd..8645f53a7 100644 --- a/src/test/correct/malloc_with_local2/clang_pic/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/clang_pic/malloc_with_local2.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2292bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -178,7 +178,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -187,9 +187,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -607,50 +607,67 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000b63"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000b69"} true; R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000b7c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000b83"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000b92; l00000b92: + assume {:captureState "l00000b92"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%00000b98"} true; R8, Gamma_R8 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%00000ba5"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%00000bb2"} true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000bbb; l00000bbb: + assume {:captureState "l00000bbb"} true; R8, Gamma_R8 := R0, Gamma_R0; R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%00000bce"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%00000bdb"} true; R30, Gamma_R30 := 2148bv64, true; call malloc(); goto l00000be4; l00000be4: + assume {:captureState "l00000be4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000bea"} true; R8, Gamma_R8 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000bf7"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000c0b"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000c1f"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -660,6 +677,7 @@ procedure main() call printf(); goto l00000c42; l00000c42: + assume {:captureState "l00000c42"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -669,6 +687,7 @@ procedure main() call printf(); goto l00000c62; l00000c62: + assume {:captureState "l00000c62"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2329bv64), Gamma_R0; @@ -676,16 +695,19 @@ procedure main() call printf(); goto l00000c7b; l00000c7b: + assume {:captureState "l00000c7b"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2248bv64, true; call #free(); goto l00000c8a; l00000c8a: + assume {:captureState "l00000c8a"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2256bv64, true; call #free(); goto l00000c98; l00000c98: + assume {:captureState "l00000c98"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd64(R31, 64bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected index 2b193e1e8..503331b2c 100644 --- a/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2272bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -656,9 +656,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000036c"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000372"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -666,35 +669,46 @@ procedure main() call malloc(); goto l0000038b; l0000038b: + assume {:captureState "l0000038b"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000391"} true; R0, Gamma_R0 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000039e"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2104bv64, true; call malloc(); goto l000003ac; l000003ac: + assume {:captureState "l000003ac"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%000003b2"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%000003bf"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l000003cd; l000003cd: + assume {:captureState "l000003cd"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%000003d3"} true; R0, Gamma_R0 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%000003e0"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003f4"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000408"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -705,6 +719,7 @@ procedure main() call printf(); goto l00000431; l00000431: + assume {:captureState "l00000431"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -715,6 +730,7 @@ procedure main() call printf(); goto l00000457; l00000457: + assume {:captureState "l00000457"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2320bv64), Gamma_R0; @@ -722,16 +738,19 @@ procedure main() call printf(); goto l00000470; l00000470: + assume {:captureState "l00000470"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2232bv64, true; call #free(); goto l0000047f; l0000047f: + assume {:captureState "l0000047f"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R30, Gamma_R30 := 2240bv64, true; call #free(); goto l0000048d; l0000048d: + assume {:captureState "l0000048d"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local2/gcc_O2/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/gcc_O2/malloc_with_local2.expected index 0226bf176..2f63e0068 100644 --- a/src/test/correct/malloc_with_local2/gcc_O2/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/gcc_O2/malloc_with_local2.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2088bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -153,7 +153,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -162,9 +162,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure __printf_chk(); @@ -624,9 +624,12 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%000001f2"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%000001f8"} true; R31, Gamma_R31 := #1, Gamma_#1; R2, Gamma_R2 := 65bv64, true; R1, Gamma_R1 := 0bv64, true; @@ -637,6 +640,7 @@ procedure main() call __printf_chk(); goto l00000221; l00000221: + assume {:captureState "l00000221"} true; R2, Gamma_R2 := 42bv64, true; R1, Gamma_R1 := 0bv64, true; R0, Gamma_R0 := 1bv64, true; @@ -645,6 +649,7 @@ procedure main() call __printf_chk(); goto l0000023d; l0000023d: + assume {:captureState "l0000023d"} true; R2, Gamma_R2 := 10bv64, true; R1, Gamma_R1 := 0bv64, true; R0, Gamma_R0 := 1bv64, true; @@ -653,6 +658,7 @@ procedure main() call __printf_chk(); goto l00000259; l00000259: + assume {:captureState "l00000259"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local2/gcc_no_plt_no_pic/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/gcc_no_plt_no_pic/malloc_with_local2.expected index def33f328..76eed4543 100644 --- a/src/test/correct/malloc_with_local2/gcc_no_plt_no_pic/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/gcc_no_plt_no_pic/malloc_with_local2.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2272bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -656,9 +656,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000b0e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000b14"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -666,35 +669,46 @@ procedure main() call malloc(); goto l00000b2d; l00000b2d: + assume {:captureState "l00000b2d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000b33"} true; R0, Gamma_R0 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000b40"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2104bv64, true; call malloc(); goto l00000b4e; l00000b4e: + assume {:captureState "l00000b4e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%00000b54"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000b61"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000b6f; l00000b6f: + assume {:captureState "l00000b6f"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%00000b75"} true; R0, Gamma_R0 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%00000b82"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000b96"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000baa"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -705,6 +719,7 @@ procedure main() call printf(); goto l00000bd3; l00000bd3: + assume {:captureState "l00000bd3"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -715,6 +730,7 @@ procedure main() call printf(); goto l00000bf9; l00000bf9: + assume {:captureState "l00000bf9"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2320bv64), Gamma_R0; @@ -722,16 +738,19 @@ procedure main() call printf(); goto l00000c12; l00000c12: + assume {:captureState "l00000c12"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2232bv64, true; call #free(); goto l00000c21; l00000c21: + assume {:captureState "l00000c21"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R30, Gamma_R30 := 2240bv64, true; call #free(); goto l00000c2f; l00000c2f: + assume {:captureState "l00000c2f"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local2/gcc_pic/malloc_with_local2.expected b/src/test/correct/malloc_with_local2/gcc_pic/malloc_with_local2.expected index def33f328..76eed4543 100644 --- a/src/test/correct/malloc_with_local2/gcc_pic/malloc_with_local2.expected +++ b/src/test/correct/malloc_with_local2/gcc_pic/malloc_with_local2.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2272bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -656,9 +656,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000b0e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000b14"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -666,35 +669,46 @@ procedure main() call malloc(); goto l00000b2d; l00000b2d: + assume {:captureState "l00000b2d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000b33"} true; R0, Gamma_R0 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000b40"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2104bv64, true; call malloc(); goto l00000b4e; l00000b4e: + assume {:captureState "l00000b4e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%00000b54"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000b61"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000b6f; l00000b6f: + assume {:captureState "l00000b6f"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%00000b75"} true; R0, Gamma_R0 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%00000b82"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000b96"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000baa"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -705,6 +719,7 @@ procedure main() call printf(); goto l00000bd3; l00000bd3: + assume {:captureState "l00000bd3"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -715,6 +730,7 @@ procedure main() call printf(); goto l00000bf9; l00000bf9: + assume {:captureState "l00000bf9"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2320bv64), Gamma_R0; @@ -722,16 +738,19 @@ procedure main() call printf(); goto l00000c12; l00000c12: + assume {:captureState "l00000c12"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2232bv64, true; call #free(); goto l00000c21; l00000c21: + assume {:captureState "l00000c21"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R30, Gamma_R30 := 2240bv64, true; call #free(); goto l00000c2f; l00000c2f: + assume {:captureState "l00000c2f"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected index 60ac9d4d2..f97fa4098 100644 --- a/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/clang/malloc_with_local3.expected @@ -1,84 +1,84 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2344bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -638,55 +638,73 @@ procedure main() var Gamma_#4: bool; var Gamma_#7: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000003ba"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000003c0"} true; R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000003d3"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%000003da"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l000003e9; l000003e9: + assume {:captureState "l000003e9"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%000003ef"} true; R8, Gamma_R8 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%000003fc"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%00000409"} true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000412; l00000412: + assume {:captureState "l00000412"} true; R8, Gamma_R8 := R0, Gamma_R0; R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%00000425"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%00000432"} true; R30, Gamma_R30 := 2148bv64, true; call malloc(); goto l0000043b; l0000043b: + assume {:captureState "l0000043b"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000441"} true; R8, Gamma_R8 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000044e"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000462"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000476"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2192bv64, true; call printCharValue(); goto l00000504; l00000504: + assume {:captureState "l00000504"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -696,6 +714,7 @@ procedure main() call printf(); goto l00000524; l00000524: + assume {:captureState "l00000524"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2364bv64), Gamma_R0; @@ -703,16 +722,19 @@ procedure main() call printf(); goto l0000053d; l0000053d: + assume {:captureState "l0000053d"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2236bv64, true; call #free(); goto l0000054c; l0000054c: + assume {:captureState "l0000054c"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2244bv64, true; call #free(); goto l0000055a; l0000055a: + assume {:captureState "l0000055a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #7, Gamma_#7 := bvadd64(R31, 64bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #7), gamma_load64(Gamma_stack, #7); @@ -1144,12 +1166,16 @@ procedure printCharValue() var Gamma_#5: bool; var Gamma_#6: bool; lprintCharValue: + assume {:captureState "lprintCharValue"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%00000496"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%0000049c"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000004aa"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, R9)), (gamma_load8(Gamma_mem, R9) || L(mem, R9)); @@ -1157,6 +1183,7 @@ procedure printCharValue() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000004c6"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -1166,6 +1193,7 @@ procedure printCharValue() call printf(); goto l000004e9; l000004e9: + assume {:captureState "l000004e9"} true; #6, Gamma_#6 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #6), gamma_load64(Gamma_stack, #6); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#6, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#6, 8bv64)); diff --git a/src/test/correct/malloc_with_local3/clang_O2/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/clang_O2/malloc_with_local3.expected index fcdb3676c..de0df8c0a 100644 --- a/src/test/correct/malloc_with_local3/clang_O2/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/clang_O2/malloc_with_local3.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1996bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -146,7 +146,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -155,9 +155,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -390,9 +390,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000318"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000031e"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 0bv64, true; @@ -402,6 +405,7 @@ procedure main() call printf(); goto l00000342; l00000342: + assume {:captureState "l00000342"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2000bv64), Gamma_R0; R1, Gamma_R1 := 42bv64, true; @@ -409,6 +413,7 @@ procedure main() call printf(); goto l00000359; l00000359: + assume {:captureState "l00000359"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2016bv64), Gamma_R0; R1, Gamma_R1 := 10bv64, true; @@ -416,6 +421,7 @@ procedure main() call printf(); goto l00000370; l00000370: + assume {:captureState "l00000370"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/malloc_with_local3/clang_no_plt_no_pic/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/clang_no_plt_no_pic/malloc_with_local3.expected index c837ae5b3..4e8f07b3e 100644 --- a/src/test/correct/malloc_with_local3/clang_no_plt_no_pic/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/clang_no_plt_no_pic/malloc_with_local3.expected @@ -1,84 +1,84 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2344bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -638,55 +638,73 @@ procedure main() var Gamma_#4: bool; var Gamma_#7: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000c45"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000c4b"} true; R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000c5e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000c65"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000c74; l00000c74: + assume {:captureState "l00000c74"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%00000c7a"} true; R8, Gamma_R8 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%00000c87"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%00000c94"} true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000c9d; l00000c9d: + assume {:captureState "l00000c9d"} true; R8, Gamma_R8 := R0, Gamma_R0; R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%00000cb0"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%00000cbd"} true; R30, Gamma_R30 := 2148bv64, true; call malloc(); goto l00000cc6; l00000cc6: + assume {:captureState "l00000cc6"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000ccc"} true; R8, Gamma_R8 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000cd9"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000ced"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000d01"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2192bv64, true; call printCharValue(); goto l00000d8f; l00000d8f: + assume {:captureState "l00000d8f"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -696,6 +714,7 @@ procedure main() call printf(); goto l00000daf; l00000daf: + assume {:captureState "l00000daf"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2364bv64), Gamma_R0; @@ -703,16 +722,19 @@ procedure main() call printf(); goto l00000dc8; l00000dc8: + assume {:captureState "l00000dc8"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2236bv64, true; call #free(); goto l00000dd7; l00000dd7: + assume {:captureState "l00000dd7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2244bv64, true; call #free(); goto l00000de5; l00000de5: + assume {:captureState "l00000de5"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #7, Gamma_#7 := bvadd64(R31, 64bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #7), gamma_load64(Gamma_stack, #7); @@ -1144,12 +1166,16 @@ procedure printCharValue() var Gamma_#5: bool; var Gamma_#6: bool; lprintCharValue: + assume {:captureState "lprintCharValue"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%00000d21"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%00000d27"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000d35"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, R9)), (gamma_load8(Gamma_mem, R9) || L(mem, R9)); @@ -1157,6 +1183,7 @@ procedure printCharValue() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000d51"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -1166,6 +1193,7 @@ procedure printCharValue() call printf(); goto l00000d74; l00000d74: + assume {:captureState "l00000d74"} true; #6, Gamma_#6 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #6), gamma_load64(Gamma_stack, #6); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#6, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#6, 8bv64)); diff --git a/src/test/correct/malloc_with_local3/clang_pic/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/clang_pic/malloc_with_local3.expected index c837ae5b3..4e8f07b3e 100644 --- a/src/test/correct/malloc_with_local3/clang_pic/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/clang_pic/malloc_with_local3.expected @@ -1,84 +1,84 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2344bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,7 +185,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -194,9 +194,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -638,55 +638,73 @@ procedure main() var Gamma_#4: bool; var Gamma_#7: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551536bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 64bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000c45"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000c4b"} true; R29, Gamma_R29 := bvadd64(R31, 64bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000c5e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000c65"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000c74; l00000c74: + assume {:captureState "l00000c74"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R29, 18446744073709551600bv64), R0), gamma_store64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64), Gamma_R0); + assume {:captureState "%00000c7a"} true; R8, Gamma_R8 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551596bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551596bv64), Gamma_R8); + assume {:captureState "%00000c87"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store64_le(stack, R31, R0), gamma_store64(Gamma_stack, R31, Gamma_R0); + assume {:captureState "%00000c94"} true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000c9d; l00000c9d: + assume {:captureState "l00000c9d"} true; R8, Gamma_R8 := R0, Gamma_R0; R0, Gamma_R0 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 32bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R8); + assume {:captureState "%00000cb0"} true; R8, Gamma_R8 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R8); + assume {:captureState "%00000cbd"} true; R30, Gamma_R30 := 2148bv64, true; call malloc(); goto l00000cc6; l00000cc6: + assume {:captureState "l00000cc6"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000ccc"} true; R8, Gamma_R8 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000cd9"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000ced"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000d01"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2192bv64, true; call printCharValue(); goto l00000d8f; l00000d8f: + assume {:captureState "l00000d8f"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -696,6 +714,7 @@ procedure main() call printf(); goto l00000daf; l00000daf: + assume {:captureState "l00000daf"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2364bv64), Gamma_R0; @@ -703,16 +722,19 @@ procedure main() call printf(); goto l00000dc8; l00000dc8: + assume {:captureState "l00000dc8"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R29, 18446744073709551600bv64)), gamma_load64(Gamma_stack, bvadd64(R29, 18446744073709551600bv64)); R30, Gamma_R30 := 2236bv64, true; call #free(); goto l00000dd7; l00000dd7: + assume {:captureState "l00000dd7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 32bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 32bv64)); R30, Gamma_R30 := 2244bv64, true; call #free(); goto l00000de5; l00000de5: + assume {:captureState "l00000de5"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #7, Gamma_#7 := bvadd64(R31, 64bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #7), gamma_load64(Gamma_stack, #7); @@ -1144,12 +1166,16 @@ procedure printCharValue() var Gamma_#5: bool; var Gamma_#6: bool; lprintCharValue: + assume {:captureState "lprintCharValue"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; #5, Gamma_#5 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%00000d21"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%00000d27"} true; R29, Gamma_R29 := bvadd64(R31, 16bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000d35"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, R9)), (gamma_load8(Gamma_mem, R9) || L(mem, R9)); @@ -1157,6 +1183,7 @@ procedure printCharValue() call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000d51"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -1166,6 +1193,7 @@ procedure printCharValue() call printf(); goto l00000d74; l00000d74: + assume {:captureState "l00000d74"} true; #6, Gamma_#6 := bvadd64(R31, 16bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #6), gamma_load64(Gamma_stack, #6); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(#6, 8bv64)), gamma_load64(Gamma_stack, bvadd64(#6, 8bv64)); diff --git a/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected index c96cea995..84eaf0dd9 100644 --- a/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected @@ -1,80 +1,80 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2328bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -190,7 +190,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -199,9 +199,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -677,9 +677,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000003a4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000003aa"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -687,40 +690,52 @@ procedure main() call malloc(); goto l000003c3; l000003c3: + assume {:captureState "l000003c3"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%000003c9"} true; R0, Gamma_R0 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000003d6"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2104bv64, true; call malloc(); goto l000003e4; l000003e4: + assume {:captureState "l000003e4"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%000003ea"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%000003f7"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000405; l00000405: + assume {:captureState "l00000405"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%0000040b"} true; R0, Gamma_R0 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%00000418"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000042c"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000440"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2168bv64, true; call printCharValue(); goto l000004db; l000004db: + assume {:captureState "l000004db"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -731,6 +746,7 @@ procedure main() call printf(); goto l00000501; l00000501: + assume {:captureState "l00000501"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2352bv64), Gamma_R0; @@ -738,16 +754,19 @@ procedure main() call printf(); goto l0000051a; l0000051a: + assume {:captureState "l0000051a"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2216bv64, true; call #free(); goto l00000529; l00000529: + assume {:captureState "l00000529"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R30, Gamma_R30 := 2224bv64, true; call #free(); goto l00000537; l00000537: + assume {:captureState "l00000537"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -1212,12 +1231,16 @@ procedure printCharValue() var #5: bv64; var Gamma_#5: bool; lprintCharValue: + assume {:captureState "lprintCharValue"} true; #5, Gamma_#5 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%0000045a"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%00000460"} true; R31, Gamma_R31 := #5, Gamma_#5; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000472"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -1227,6 +1250,7 @@ procedure printCharValue() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000049b"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -1237,6 +1261,7 @@ procedure printCharValue() call printf(); goto l000004c4; l000004c4: + assume {:captureState "l000004c4"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; diff --git a/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected index 590d1c18b..cb33d38b0 100644 --- a/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected @@ -1,70 +1,70 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R19: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R3: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R19: bv64; -var R2: bv64; -var R29: bv64; -var R3: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R19: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R19: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R3: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2264bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -176,7 +176,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -185,9 +185,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure __printf_chk(); @@ -866,26 +866,33 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%00000222"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%00000228"} true; R31, Gamma_R31 := #1, Gamma_#1; R0, Gamma_R0 := 1bv64, true; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R19), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R19); + assume {:captureState "%0000023f"} true; R30, Gamma_R30 := 1812bv64, true; call malloc(); goto l00000249; l00000249: + assume {:captureState "l00000249"} true; R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000254"} true; R19, Gamma_R19 := R0, Gamma_R0; R30, Gamma_R30 := 1828bv64, true; call printCharValue(); goto l0000029a; l0000029a: + assume {:captureState "l0000029a"} true; R2, Gamma_R2 := 42bv64, true; R1, Gamma_R1 := 0bv64, true; R0, Gamma_R0 := 1bv64, true; @@ -894,6 +901,7 @@ procedure main() call __printf_chk(); goto l000002b6; l000002b6: + assume {:captureState "l000002b6"} true; R1, Gamma_R1 := 0bv64, true; R1, Gamma_R1 := bvadd64(R1, 2312bv64), Gamma_R1; R2, Gamma_R2 := 10bv64, true; @@ -902,11 +910,13 @@ procedure main() call __printf_chk(); goto l000002d2; l000002d2: + assume {:captureState "l000002d2"} true; R0, Gamma_R0 := R19, Gamma_R19; R30, Gamma_R30 := 1876bv64, true; call #free(); goto l000002e0; l000002e0: + assume {:captureState "l000002e0"} true; R0, Gamma_R0 := 0bv64, true; R19, Gamma_R19 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); @@ -1350,6 +1360,7 @@ procedure printCharValue() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lprintCharValue: + assume {:captureState "lprintCharValue"} true; R3, Gamma_R3 := R0, Gamma_R0; R0, Gamma_R0 := 1bv64, true; R1, Gamma_R1 := 0bv64, true; @@ -1361,6 +1372,7 @@ procedure printCharValue() call rely(); assert (L(mem, R3) ==> Gamma_R2); mem, Gamma_mem := memory_store8_le(mem, R3, R2[8:0]), gamma_store8(Gamma_mem, R3, Gamma_R2); + assume {:captureState "%00000293"} true; call __printf_chk(); //no return target assume false; diff --git a/src/test/correct/malloc_with_local3/gcc_no_plt_no_pic/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/gcc_no_plt_no_pic/malloc_with_local3.expected index 743895881..5b5324742 100644 --- a/src/test/correct/malloc_with_local3/gcc_no_plt_no_pic/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/gcc_no_plt_no_pic/malloc_with_local3.expected @@ -1,80 +1,80 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2328bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -190,7 +190,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -199,9 +199,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -677,9 +677,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000c00"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000c06"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -687,40 +690,52 @@ procedure main() call malloc(); goto l00000c1f; l00000c1f: + assume {:captureState "l00000c1f"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000c25"} true; R0, Gamma_R0 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000c32"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2104bv64, true; call malloc(); goto l00000c40; l00000c40: + assume {:captureState "l00000c40"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%00000c46"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000c53"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000c61; l00000c61: + assume {:captureState "l00000c61"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%00000c67"} true; R0, Gamma_R0 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%00000c74"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000c88"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000c9c"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2168bv64, true; call printCharValue(); goto l00000d37; l00000d37: + assume {:captureState "l00000d37"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -731,6 +746,7 @@ procedure main() call printf(); goto l00000d5d; l00000d5d: + assume {:captureState "l00000d5d"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2352bv64), Gamma_R0; @@ -738,16 +754,19 @@ procedure main() call printf(); goto l00000d76; l00000d76: + assume {:captureState "l00000d76"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2216bv64, true; call #free(); goto l00000d85; l00000d85: + assume {:captureState "l00000d85"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R30, Gamma_R30 := 2224bv64, true; call #free(); goto l00000d93; l00000d93: + assume {:captureState "l00000d93"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -1212,12 +1231,16 @@ procedure printCharValue() var #5: bv64; var Gamma_#5: bool; lprintCharValue: + assume {:captureState "lprintCharValue"} true; #5, Gamma_#5 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%00000cb6"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%00000cbc"} true; R31, Gamma_R31 := #5, Gamma_#5; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000cce"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -1227,6 +1250,7 @@ procedure printCharValue() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000cf7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -1237,6 +1261,7 @@ procedure printCharValue() call printf(); goto l00000d20; l00000d20: + assume {:captureState "l00000d20"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; diff --git a/src/test/correct/malloc_with_local3/gcc_pic/malloc_with_local3.expected b/src/test/correct/malloc_with_local3/gcc_pic/malloc_with_local3.expected index 743895881..5b5324742 100644 --- a/src/test/correct/malloc_with_local3/gcc_pic/malloc_with_local3.expected +++ b/src/test/correct/malloc_with_local3/gcc_pic/malloc_with_local3.expected @@ -1,80 +1,80 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2328bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -190,7 +190,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -199,9 +199,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -677,9 +677,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551552bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000c00"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000c06"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -687,40 +690,52 @@ procedure main() call malloc(); goto l00000c1f; l00000c1f: + assume {:captureState "l00000c1f"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 40bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 40bv64), Gamma_R0); + assume {:captureState "%00000c25"} true; R0, Gamma_R0 := 11bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000c32"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2104bv64, true; call malloc(); goto l00000c40; l00000c40: + assume {:captureState "l00000c40"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 48bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 48bv64), Gamma_R0); + assume {:captureState "%00000c46"} true; R0, Gamma_R0 := 10bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 32bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 32bv64), Gamma_R0); + assume {:captureState "%00000c53"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2124bv64, true; call malloc(); goto l00000c61; l00000c61: + assume {:captureState "l00000c61"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 56bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 56bv64), Gamma_R0); + assume {:captureState "%00000c67"} true; R0, Gamma_R0 := 9bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 36bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 36bv64), Gamma_R0); + assume {:captureState "%00000c74"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000c88"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000c9c"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2168bv64, true; call printCharValue(); goto l00000d37; l00000d37: + assume {:captureState "l00000d37"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -731,6 +746,7 @@ procedure main() call printf(); goto l00000d5d; l00000d5d: + assume {:captureState "l00000d5d"} true; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 32bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 32bv64)); R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 2352bv64), Gamma_R0; @@ -738,16 +754,19 @@ procedure main() call printf(); goto l00000d76; l00000d76: + assume {:captureState "l00000d76"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 40bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 40bv64)); R30, Gamma_R30 := 2216bv64, true; call #free(); goto l00000d85; l00000d85: + assume {:captureState "l00000d85"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 48bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 48bv64)); R30, Gamma_R30 := 2224bv64, true; call #free(); goto l00000d93; l00000d93: + assume {:captureState "l00000d93"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); @@ -1212,12 +1231,16 @@ procedure printCharValue() var #5: bv64; var Gamma_#5: bool; lprintCharValue: + assume {:captureState "lprintCharValue"} true; #5, Gamma_#5 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #5, R29), gamma_store64(Gamma_stack, #5, Gamma_R29); + assume {:captureState "%00000cb6"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#5, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#5, 8bv64), Gamma_R30); + assume {:captureState "%00000cbc"} true; R31, Gamma_R31 := #5, Gamma_#5; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000cce"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -1227,6 +1250,7 @@ procedure printCharValue() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000cf7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -1237,6 +1261,7 @@ procedure printCharValue() call printf(); goto l00000d20; l00000d20: + assume {:captureState "l00000d20"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; diff --git a/src/test/correct/multi_malloc/clang/multi_malloc.expected b/src/test/correct/multi_malloc/clang/multi_malloc.expected index 5967285b6..829a6b1d3 100644 --- a/src/test/correct/multi_malloc/clang/multi_malloc.expected +++ b/src/test/correct/multi_malloc/clang/multi_malloc.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2232bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -151,7 +151,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -160,9 +160,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -472,36 +472,47 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%0000034a"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000350"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000363"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%0000036a"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000379; l00000379: + assume {:captureState "l00000379"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%0000037f"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2112bv64, true; call malloc(); goto l0000038d; l0000038d: + assume {:captureState "l0000038d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000393"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003a7"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%000003bb"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -511,6 +522,7 @@ procedure main() call printf(); goto l000003de; l000003de: + assume {:captureState "l000003de"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -520,16 +532,19 @@ procedure main() call printf(); goto l000003fe; l000003fe: + assume {:captureState "l000003fe"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2188bv64, true; call #free(); goto l0000040d; l0000040d: + assume {:captureState "l0000040d"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2196bv64, true; call #free(); goto l0000041b; l0000041b: + assume {:captureState "l0000041b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/multi_malloc/clang_O2/multi_malloc.expected b/src/test/correct/multi_malloc/clang_O2/multi_malloc.expected index 0b5e39a9b..d1762ce6b 100644 --- a/src/test/correct/multi_malloc/clang_O2/multi_malloc.expected +++ b/src/test/correct/multi_malloc/clang_O2/multi_malloc.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1948bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -113,7 +113,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -122,9 +122,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -291,9 +291,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002e8"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002ee"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 0bv64, true; @@ -303,6 +306,7 @@ procedure main() call printf(); goto l00000312; l00000312: + assume {:captureState "l00000312"} true; R0, Gamma_R0 := 0bv64, true; R0, Gamma_R0 := bvadd64(R0, 1969bv64), Gamma_R0; R1, Gamma_R1 := 42bv64, true; @@ -310,6 +314,7 @@ procedure main() call printf(); goto l00000329; l00000329: + assume {:captureState "l00000329"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/multi_malloc/clang_no_plt_no_pic/multi_malloc.expected b/src/test/correct/multi_malloc/clang_no_plt_no_pic/multi_malloc.expected index 7b6181dcc..002ba1344 100644 --- a/src/test/correct/multi_malloc/clang_no_plt_no_pic/multi_malloc.expected +++ b/src/test/correct/multi_malloc/clang_no_plt_no_pic/multi_malloc.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2232bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -151,7 +151,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -160,9 +160,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -472,36 +472,47 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000a78"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000a7e"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000a91"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000a98"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000aa7; l00000aa7: + assume {:captureState "l00000aa7"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000aad"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2112bv64, true; call malloc(); goto l00000abb; l00000abb: + assume {:captureState "l00000abb"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000ac1"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000ad5"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000ae9"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -511,6 +522,7 @@ procedure main() call printf(); goto l00000b0c; l00000b0c: + assume {:captureState "l00000b0c"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -520,16 +532,19 @@ procedure main() call printf(); goto l00000b2c; l00000b2c: + assume {:captureState "l00000b2c"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2188bv64, true; call #free(); goto l00000b3b; l00000b3b: + assume {:captureState "l00000b3b"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2196bv64, true; call #free(); goto l00000b49; l00000b49: + assume {:captureState "l00000b49"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/multi_malloc/clang_pic/multi_malloc.expected b/src/test/correct/multi_malloc/clang_pic/multi_malloc.expected index 7b6181dcc..002ba1344 100644 --- a/src/test/correct/multi_malloc/clang_pic/multi_malloc.expected +++ b/src/test/correct/multi_malloc/clang_pic/multi_malloc.expected @@ -1,83 +1,83 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2232bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -151,7 +151,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69702bv64) == 0bv8); free ensures (memory_load8_le(mem, 69703bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -160,9 +160,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -472,36 +472,47 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000a78"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000a7e"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; R8, Gamma_R8 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000a91"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000a98"} true; R0, Gamma_R0 := 1bv64, true; R30, Gamma_R30 := 2100bv64, true; call malloc(); goto l00000aa7; l00000aa7: + assume {:captureState "l00000aa7"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000aad"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2112bv64, true; call malloc(); goto l00000abb; l00000abb: + assume {:captureState "l00000abb"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000ac1"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R8, Gamma_R8 := 65bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000ad5"} true; R9, Gamma_R9 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 42bv64, true; call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000ae9"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R1, Gamma_R1 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); @@ -511,6 +522,7 @@ procedure main() call printf(); goto l00000b0c; l00000b0c: + assume {:captureState "l00000b0c"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R1, Gamma_R1 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -520,16 +532,19 @@ procedure main() call printf(); goto l00000b2c; l00000b2c: + assume {:captureState "l00000b2c"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2188bv64, true; call #free(); goto l00000b3b; l00000b3b: + assume {:captureState "l00000b3b"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R30, Gamma_R30 := 2196bv64, true; call #free(); goto l00000b49; l00000b49: + assume {:captureState "l00000b49"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/multi_malloc/gcc/multi_malloc.expected b/src/test/correct/multi_malloc/gcc/multi_malloc.expected index e50dfecd9..183a05c34 100644 --- a/src/test/correct/multi_malloc/gcc/multi_malloc.expected +++ b/src/test/correct/multi_malloc/gcc/multi_malloc.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2224bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -158,7 +158,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -167,9 +167,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -521,9 +521,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000338"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000033e"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -531,23 +534,29 @@ procedure main() call malloc(); goto l00000357; l00000357: + assume {:captureState "l00000357"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%0000035d"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2096bv64, true; call malloc(); goto l0000036b; l0000036b: + assume {:captureState "l0000036b"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000371"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000385"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000399"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -558,6 +567,7 @@ procedure main() call printf(); goto l000003c2; l000003c2: + assume {:captureState "l000003c2"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -568,16 +578,19 @@ procedure main() call printf(); goto l000003e8; l000003e8: + assume {:captureState "l000003e8"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2180bv64, true; call #free(); goto l000003f7; l000003f7: + assume {:captureState "l000003f7"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 2188bv64, true; call #free(); goto l00000405; l00000405: + assume {:captureState "l00000405"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/multi_malloc/gcc_O2/multi_malloc.expected b/src/test/correct/multi_malloc/gcc_O2/multi_malloc.expected index ddca94216..4fa5bf17f 100644 --- a/src/test/correct/multi_malloc/gcc_O2/multi_malloc.expected +++ b/src/test/correct/multi_malloc/gcc_O2/multi_malloc.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R2: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R2: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R2: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2024bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -126,7 +126,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -135,9 +135,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure __printf_chk(); @@ -489,9 +489,12 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; #1, Gamma_#1 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #1, R29), gamma_store64(Gamma_stack, #1, Gamma_R29); + assume {:captureState "%000001b2"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#1, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#1, 8bv64), Gamma_R30); + assume {:captureState "%000001b8"} true; R31, Gamma_R31 := #1, Gamma_#1; R2, Gamma_R2 := 65bv64, true; R1, Gamma_R1 := 0bv64, true; @@ -502,6 +505,7 @@ procedure main() call __printf_chk(); goto l000001e1; l000001e1: + assume {:captureState "l000001e1"} true; R2, Gamma_R2 := 42bv64, true; R1, Gamma_R1 := 0bv64, true; R0, Gamma_R0 := 1bv64, true; @@ -510,6 +514,7 @@ procedure main() call __printf_chk(); goto l000001fd; l000001fd: + assume {:captureState "l000001fd"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/multi_malloc/gcc_no_plt_no_pic/multi_malloc.expected b/src/test/correct/multi_malloc/gcc_no_plt_no_pic/multi_malloc.expected index fbdc65c40..417806157 100644 --- a/src/test/correct/multi_malloc/gcc_no_plt_no_pic/multi_malloc.expected +++ b/src/test/correct/multi_malloc/gcc_no_plt_no_pic/multi_malloc.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2224bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -158,7 +158,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -167,9 +167,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -521,9 +521,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000a45"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000a4b"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -531,23 +534,29 @@ procedure main() call malloc(); goto l00000a64; l00000a64: + assume {:captureState "l00000a64"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000a6a"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2096bv64, true; call malloc(); goto l00000a78; l00000a78: + assume {:captureState "l00000a78"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a7e"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a92"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000aa6"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -558,6 +567,7 @@ procedure main() call printf(); goto l00000acf; l00000acf: + assume {:captureState "l00000acf"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -568,16 +578,19 @@ procedure main() call printf(); goto l00000af5; l00000af5: + assume {:captureState "l00000af5"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2180bv64, true; call #free(); goto l00000b04; l00000b04: + assume {:captureState "l00000b04"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 2188bv64, true; call #free(); goto l00000b12; l00000b12: + assume {:captureState "l00000b12"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/multi_malloc/gcc_pic/multi_malloc.expected b/src/test/correct/multi_malloc/gcc_pic/multi_malloc.expected index fbdc65c40..417806157 100644 --- a/src/test/correct/multi_malloc/gcc_pic/multi_malloc.expected +++ b/src/test/correct/multi_malloc/gcc_pic/multi_malloc.expected @@ -1,79 +1,79 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 2224bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -158,7 +158,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -167,9 +167,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure #free(); @@ -521,9 +521,12 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000a45"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000a4b"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; R0, Gamma_R0 := 1bv64, true; @@ -531,23 +534,29 @@ procedure main() call malloc(); goto l00000a64; l00000a64: + assume {:captureState "l00000a64"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R0); + assume {:captureState "%00000a6a"} true; R0, Gamma_R0 := 4bv64, true; R30, Gamma_R30 := 2096bv64, true; call malloc(); goto l00000a78; l00000a78: + assume {:captureState "l00000a78"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 24bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%00000a7e"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R1, Gamma_R1 := 65bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a92"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R1, Gamma_R1 := 42bv64, true; call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000aa6"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); @@ -558,6 +567,7 @@ procedure main() call printf(); goto l00000acf; l00000acf: + assume {:captureState "l00000acf"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); @@ -568,16 +578,19 @@ procedure main() call printf(); goto l00000af5; l00000af5: + assume {:captureState "l00000af5"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 16bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 16bv64)); R30, Gamma_R30 := 2180bv64, true; call #free(); goto l00000b04; l00000b04: + assume {:captureState "l00000b04"} true; R0, Gamma_R0 := memory_load64_le(stack, bvadd64(R31, 24bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 24bv64)); R30, Gamma_R30 := 2188bv64, true; call #free(); goto l00000b12; l00000b12: + assume {:captureState "l00000b12"} true; R0, Gamma_R0 := 0bv64, true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/nestedif/clang/nestedif.expected b/src/test/correct/nestedif/clang/nestedif.expected index a37da1c4d..15c499b19 100644 --- a/src/test/correct/nestedif/clang/nestedif.expected +++ b/src/test/correct/nestedif/clang/nestedif.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1968bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -203,11 +203,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000033d"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000034a"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), true); + assume {:captureState "%00000351"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -221,18 +225,22 @@ procedure main() } goto l0000037c; l0000037c: + assume {:captureState "l0000037c"} true; R8, Gamma_R8 := 1bv64, true; goto l0000037f; l00000379: + assume {:captureState "l00000379"} true; R8, Gamma_R8 := 0bv64, true; goto l0000037f; l0000037f: + assume {:captureState "l0000037f"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000387; } goto l00000442; l00000387: + assume {:captureState "l00000387"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#5); @@ -246,18 +254,22 @@ procedure main() } goto l000003b5; l000003b5: + assume {:captureState "l000003b5"} true; R8, Gamma_R8 := 1bv64, true; goto l000003b8; l000003b2: + assume {:captureState "l000003b2"} true; R8, Gamma_R8 := 0bv64, true; goto l000003b8; l000003b8: + assume {:captureState "l000003b8"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000003c0; } goto l0000042d; l000003c0: + assume {:captureState "l000003c0"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #6, Gamma_#6 := bvadd32(R8[32:0], 4294967293bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934590bv33))), (Gamma_R8 && Gamma_#6); @@ -271,40 +283,55 @@ procedure main() } goto l000003ee; l000003ee: + assume {:captureState "l000003ee"} true; R8, Gamma_R8 := 1bv64, true; goto l000003f1; l000003eb: + assume {:captureState "l000003eb"} true; R8, Gamma_R8 := 0bv64, true; goto l000003f1; l000003f1: + assume {:captureState "l000003f1"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000003f9; } goto l00000418; l00000418: + assume {:captureState "l00000418"} true; goto l00000419; l00000419: + assume {:captureState "l00000419"} true; R8, Gamma_R8 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000427"} true; goto l000003f9; l000003f9: + assume {:captureState "l000003f9"} true; goto l000003ff; l0000042d: + assume {:captureState "l0000042d"} true; goto l0000042e; l0000042e: + assume {:captureState "l0000042e"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000043c"} true; goto l000003ff; l000003ff: + assume {:captureState "l000003ff"} true; goto l00000403; l00000442: + assume {:captureState "l00000442"} true; goto l00000443; l00000443: + assume {:captureState "l00000443"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000451"} true; goto l00000403; l00000403: + assume {:captureState "l00000403"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/nestedif/clang_O2/nestedif.expected b/src/test/correct/nestedif/clang_O2/nestedif.expected index 1e9764f80..b904c03a5 100644 --- a/src/test/correct/nestedif/clang_O2/nestedif.expected +++ b/src/test/correct/nestedif/clang_O2/nestedif.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1840bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/nestedif/clang_no_plt_no_pic/nestedif.expected b/src/test/correct/nestedif/clang_no_plt_no_pic/nestedif.expected index c3575bfb5..3ca99ae3f 100644 --- a/src/test/correct/nestedif/clang_no_plt_no_pic/nestedif.expected +++ b/src/test/correct/nestedif/clang_no_plt_no_pic/nestedif.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1968bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -203,11 +203,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000a6e"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a7b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), true); + assume {:captureState "%00000a82"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -221,18 +225,22 @@ procedure main() } goto l00000aad; l00000aad: + assume {:captureState "l00000aad"} true; R8, Gamma_R8 := 1bv64, true; goto l00000ab0; l00000aaa: + assume {:captureState "l00000aaa"} true; R8, Gamma_R8 := 0bv64, true; goto l00000ab0; l00000ab0: + assume {:captureState "l00000ab0"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000ab8; } goto l00000b73; l00000ab8: + assume {:captureState "l00000ab8"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#5); @@ -246,18 +254,22 @@ procedure main() } goto l00000ae6; l00000ae6: + assume {:captureState "l00000ae6"} true; R8, Gamma_R8 := 1bv64, true; goto l00000ae9; l00000ae3: + assume {:captureState "l00000ae3"} true; R8, Gamma_R8 := 0bv64, true; goto l00000ae9; l00000ae9: + assume {:captureState "l00000ae9"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000af1; } goto l00000b5e; l00000af1: + assume {:captureState "l00000af1"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #6, Gamma_#6 := bvadd32(R8[32:0], 4294967293bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934590bv33))), (Gamma_R8 && Gamma_#6); @@ -271,40 +283,55 @@ procedure main() } goto l00000b1f; l00000b1f: + assume {:captureState "l00000b1f"} true; R8, Gamma_R8 := 1bv64, true; goto l00000b22; l00000b1c: + assume {:captureState "l00000b1c"} true; R8, Gamma_R8 := 0bv64, true; goto l00000b22; l00000b22: + assume {:captureState "l00000b22"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000b2a; } goto l00000b49; l00000b49: + assume {:captureState "l00000b49"} true; goto l00000b4a; l00000b4a: + assume {:captureState "l00000b4a"} true; R8, Gamma_R8 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b58"} true; goto l00000b2a; l00000b2a: + assume {:captureState "l00000b2a"} true; goto l00000b30; l00000b5e: + assume {:captureState "l00000b5e"} true; goto l00000b5f; l00000b5f: + assume {:captureState "l00000b5f"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b6d"} true; goto l00000b30; l00000b30: + assume {:captureState "l00000b30"} true; goto l00000b34; l00000b73: + assume {:captureState "l00000b73"} true; goto l00000b74; l00000b74: + assume {:captureState "l00000b74"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b82"} true; goto l00000b34; l00000b34: + assume {:captureState "l00000b34"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/nestedif/clang_pic/nestedif.expected b/src/test/correct/nestedif/clang_pic/nestedif.expected index c3575bfb5..3ca99ae3f 100644 --- a/src/test/correct/nestedif/clang_pic/nestedif.expected +++ b/src/test/correct/nestedif/clang_pic/nestedif.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1968bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -203,11 +203,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000a6e"} true; R8, Gamma_R8 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a7b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), true); + assume {:captureState "%00000a82"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -221,18 +225,22 @@ procedure main() } goto l00000aad; l00000aad: + assume {:captureState "l00000aad"} true; R8, Gamma_R8 := 1bv64, true; goto l00000ab0; l00000aaa: + assume {:captureState "l00000aaa"} true; R8, Gamma_R8 := 0bv64, true; goto l00000ab0; l00000ab0: + assume {:captureState "l00000ab0"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000ab8; } goto l00000b73; l00000ab8: + assume {:captureState "l00000ab8"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#5); @@ -246,18 +254,22 @@ procedure main() } goto l00000ae6; l00000ae6: + assume {:captureState "l00000ae6"} true; R8, Gamma_R8 := 1bv64, true; goto l00000ae9; l00000ae3: + assume {:captureState "l00000ae3"} true; R8, Gamma_R8 := 0bv64, true; goto l00000ae9; l00000ae9: + assume {:captureState "l00000ae9"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000af1; } goto l00000b5e; l00000af1: + assume {:captureState "l00000af1"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #6, Gamma_#6 := bvadd32(R8[32:0], 4294967293bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934590bv33))), (Gamma_R8 && Gamma_#6); @@ -271,40 +283,55 @@ procedure main() } goto l00000b1f; l00000b1f: + assume {:captureState "l00000b1f"} true; R8, Gamma_R8 := 1bv64, true; goto l00000b22; l00000b1c: + assume {:captureState "l00000b1c"} true; R8, Gamma_R8 := 0bv64, true; goto l00000b22; l00000b22: + assume {:captureState "l00000b22"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000b2a; } goto l00000b49; l00000b49: + assume {:captureState "l00000b49"} true; goto l00000b4a; l00000b4a: + assume {:captureState "l00000b4a"} true; R8, Gamma_R8 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b58"} true; goto l00000b2a; l00000b2a: + assume {:captureState "l00000b2a"} true; goto l00000b30; l00000b5e: + assume {:captureState "l00000b5e"} true; goto l00000b5f; l00000b5f: + assume {:captureState "l00000b5f"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b6d"} true; goto l00000b30; l00000b30: + assume {:captureState "l00000b30"} true; goto l00000b34; l00000b73: + assume {:captureState "l00000b73"} true; goto l00000b74; l00000b74: + assume {:captureState "l00000b74"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b82"} true; goto l00000b34; l00000b34: + assume {:captureState "l00000b34"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/nestedif/gcc/nestedif.expected b/src/test/correct/nestedif/gcc/nestedif.expected index be46c82f4..a2b195685 100644 --- a/src/test/correct/nestedif/gcc/nestedif.expected +++ b/src/test/correct/nestedif/gcc/nestedif.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1928bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -201,10 +201,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000031b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000322"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -217,6 +220,7 @@ procedure main() } goto l000003c4; l00000345: + assume {:captureState "l00000345"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#5); @@ -229,6 +233,7 @@ procedure main() } goto l000003b3; l0000036b: + assume {:captureState "l0000036b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#6); @@ -241,18 +246,25 @@ procedure main() } goto l000003a6; l000003a6: + assume {:captureState "l000003a6"} true; R0, Gamma_R0 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000003b1"} true; goto l00000391; l000003b3: + assume {:captureState "l000003b3"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000003be"} true; goto l00000391; l000003c4: + assume {:captureState "l000003c4"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000003cf"} true; goto l00000391; l00000391: + assume {:captureState "l00000391"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/nestedif/gcc_O2/nestedif.expected b/src/test/correct/nestedif/gcc_O2/nestedif.expected index ab48890b6..306991d20 100644 --- a/src/test/correct/nestedif/gcc_O2/nestedif.expected +++ b/src/test/correct/nestedif/gcc_O2/nestedif.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/nestedif/gcc_no_plt_no_pic/nestedif.expected b/src/test/correct/nestedif/gcc_no_plt_no_pic/nestedif.expected index 55e5d1a3e..0f2d64903 100644 --- a/src/test/correct/nestedif/gcc_no_plt_no_pic/nestedif.expected +++ b/src/test/correct/nestedif/gcc_no_plt_no_pic/nestedif.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1928bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -201,10 +201,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000009b7"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000009be"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -217,6 +220,7 @@ procedure main() } goto l00000a60; l000009e1: + assume {:captureState "l000009e1"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#5); @@ -229,6 +233,7 @@ procedure main() } goto l00000a4f; l00000a07: + assume {:captureState "l00000a07"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#6); @@ -241,18 +246,25 @@ procedure main() } goto l00000a42; l00000a42: + assume {:captureState "l00000a42"} true; R0, Gamma_R0 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000a4d"} true; goto l00000a2d; l00000a4f: + assume {:captureState "l00000a4f"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000a5a"} true; goto l00000a2d; l00000a60: + assume {:captureState "l00000a60"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000a6b"} true; goto l00000a2d; l00000a2d: + assume {:captureState "l00000a2d"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/nestedif/gcc_pic/nestedif.expected b/src/test/correct/nestedif/gcc_pic/nestedif.expected index 55e5d1a3e..0f2d64903 100644 --- a/src/test/correct/nestedif/gcc_pic/nestedif.expected +++ b/src/test/correct/nestedif/gcc_pic/nestedif.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1928bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -201,10 +201,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000009b7"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000009be"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -217,6 +220,7 @@ procedure main() } goto l00000a60; l000009e1: + assume {:captureState "l000009e1"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#5); @@ -229,6 +233,7 @@ procedure main() } goto l00000a4f; l00000a07: + assume {:captureState "l00000a07"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#6); @@ -241,18 +246,25 @@ procedure main() } goto l00000a42; l00000a42: + assume {:captureState "l00000a42"} true; R0, Gamma_R0 := 7bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000a4d"} true; goto l00000a2d; l00000a4f: + assume {:captureState "l00000a4f"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000a5a"} true; goto l00000a2d; l00000a60: + assume {:captureState "l00000a60"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000a6b"} true; goto l00000a2d; l00000a2d: + assume {:captureState "l00000a2d"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected index a8845dbc3..7a6a27fd0 100644 --- a/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -185,6 +185,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -192,6 +193,7 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002ce"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_x/clang_O2/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/clang_O2/no_interference_update_x.expected index 70b301f71..740a585c8 100644 --- a/src/test/correct/no_interference_update_x/clang_O2/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/clang_O2/no_interference_update_x.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -185,6 +185,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -193,5 +194,6 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002d3"} true; return; } diff --git a/src/test/correct/no_interference_update_x/clang_no_plt_no_pic/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/clang_no_plt_no_pic/no_interference_update_x.expected index a8845dbc3..293d1dbc9 100644 --- a/src/test/correct/no_interference_update_x/clang_no_plt_no_pic/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/clang_no_plt_no_pic/no_interference_update_x.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -185,6 +185,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -192,6 +193,7 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%00000845"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected index f6cc2c2b8..a5a054cf9 100644 --- a/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -88,7 +88,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -96,12 +96,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -217,6 +217,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); @@ -226,6 +227,7 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected index 861d5ce98..48ecd68b7 100644 --- a/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/gcc/no_interference_update_x.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -183,6 +183,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -191,6 +192,7 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002d8"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected index 4e1467783..ef1344e1e 100644 --- a/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/gcc_O2/no_interference_update_x.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -185,6 +185,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := 1bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -193,5 +194,6 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000001bd"} true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc_no_plt_no_pic/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/gcc_no_plt_no_pic/no_interference_update_x.expected index 861d5ce98..09a38ab49 100644 --- a/src/test/correct/no_interference_update_x/gcc_no_plt_no_pic/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/gcc_no_plt_no_pic/no_interference_update_x.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -183,6 +183,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -191,6 +192,7 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%0000085b"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected b/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected index c9909b307..b07082212 100644 --- a/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected +++ b/src/test/correct/no_interference_update_x/gcc_pic/no_interference_update_x.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -86,7 +86,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -94,12 +94,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); @@ -215,6 +215,7 @@ procedure main() { var y_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -224,6 +225,7 @@ procedure main() y_old := memory_load32_le(mem, $y_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $y_addr) == y_old); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected index c8c4f47bc..2bb856649 100644 --- a/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -185,6 +185,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -192,6 +193,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002ce"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_y/clang_O2/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/clang_O2/no_interference_update_y.expected index 1f7087a27..81e2f7c66 100644 --- a/src/test/correct/no_interference_update_y/clang_O2/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/clang_O2/no_interference_update_y.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -185,6 +185,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -193,5 +194,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002d3"} true; return; } diff --git a/src/test/correct/no_interference_update_y/clang_no_plt_no_pic/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/clang_no_plt_no_pic/no_interference_update_y.expected index c8c4f47bc..ac0a8d545 100644 --- a/src/test/correct/no_interference_update_y/clang_no_plt_no_pic/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/clang_no_plt_no_pic/no_interference_update_y.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -185,6 +185,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -192,6 +193,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%00000845"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected index 0aafc34d3..963551bd0 100644 --- a/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -88,7 +88,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -96,12 +96,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -217,6 +217,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4048bv64)) || L(mem, bvadd64(R9, 4048bv64))); @@ -226,6 +227,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected index 7ea617f8d..20a7bf882 100644 --- a/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/gcc/no_interference_update_y.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -183,6 +183,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -191,6 +192,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002d8"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected index 25986a697..01c79156a 100644 --- a/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/gcc_O2/no_interference_update_y.expected @@ -1,37 +1,37 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -72,7 +72,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -80,12 +80,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -185,6 +185,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := 1bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -193,5 +194,6 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000001bd"} true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc_no_plt_no_pic/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/gcc_no_plt_no_pic/no_interference_update_y.expected index 7ea617f8d..658b4eb22 100644 --- a/src/test/correct/no_interference_update_y/gcc_no_plt_no_pic/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/gcc_no_plt_no_pic/no_interference_update_y.expected @@ -1,35 +1,35 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -70,7 +70,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -78,12 +78,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -183,6 +183,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -191,6 +192,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%0000085b"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected b/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected index 40c5f15c7..0cd4b1423 100644 --- a/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected +++ b/src/test/correct/no_interference_update_y/gcc_pic/no_interference_update_y.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $y_addr: bv64; +const {:extern} $y_addr: bv64; axiom ($y_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $y_addr) then true else (if (index == $x_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); @@ -86,7 +86,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $y_addr) == old(memory_load32_le(mem, $y_addr))); { @@ -94,12 +94,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $y_addr) == memory_load32_le(mem, $y_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); @@ -215,6 +215,7 @@ procedure main() { var x_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -224,6 +225,7 @@ procedure main() x_old := memory_load32_le(mem, $x_addr); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert (memory_load32_le(mem, $x_addr) == x_old); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/secret_write/clang/secret_write.expected b/src/test/correct/secret_write/clang/secret_write.expected index 429086b06..731e47319 100644 --- a/src/test/correct/secret_write/clang/secret_write.expected +++ b/src/test/correct/secret_write/clang/secret_write.expected @@ -1,49 +1,49 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -94,13 +94,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -204,6 +204,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); @@ -213,6 +214,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), true); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000002f5"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; @@ -223,6 +225,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000030a"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); @@ -234,6 +237,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), Gamma_R10); assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000323"} true; call rely(); assert (L(mem, bvadd64(R8, 60bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -241,6 +245,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), true); assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000032a"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; @@ -251,5 +256,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000033f"} true; return; } diff --git a/src/test/correct/secret_write/clang_O2/secret_write.expected b/src/test/correct/secret_write/clang_O2/secret_write.expected index 4d3b532df..0adc7d048 100644 --- a/src/test/correct/secret_write/clang_O2/secret_write.expected +++ b/src/test/correct/secret_write/clang_O2/secret_write.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -92,13 +92,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -202,6 +202,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; @@ -213,6 +214,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), true); assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000002df"} true; call rely(); assert (L(mem, bvadd64(R9, 52bv64)) ==> Gamma_R10); z_old := memory_load32_le(mem, $z_addr); @@ -220,5 +222,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R10); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000002e7"} true; return; } diff --git a/src/test/correct/secret_write/clang_no_plt_no_pic/secret_write.expected b/src/test/correct/secret_write/clang_no_plt_no_pic/secret_write.expected index 429086b06..2e4c0f4d2 100644 --- a/src/test/correct/secret_write/clang_no_plt_no_pic/secret_write.expected +++ b/src/test/correct/secret_write/clang_no_plt_no_pic/secret_write.expected @@ -1,49 +1,49 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -94,13 +94,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -204,6 +204,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; call rely(); @@ -213,6 +214,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), true); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000008ec"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; @@ -223,6 +225,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000901"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); @@ -234,6 +237,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), Gamma_R10); assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000091a"} true; call rely(); assert (L(mem, bvadd64(R8, 60bv64)) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -241,6 +245,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 60bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 60bv64), true); assert ((bvadd64(R8, 60bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000921"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R9, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R9, 52bv64)) || L(mem, bvadd64(R9, 52bv64))); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; @@ -251,5 +256,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000936"} true; return; } diff --git a/src/test/correct/secret_write/clang_pic/secret_write.expected b/src/test/correct/secret_write/clang_pic/secret_write.expected index 5d1a5fc2d..53c9b519b 100644 --- a/src/test/correct/secret_write/clang_pic/secret_write.expected +++ b/src/test/correct/secret_write/clang_pic/secret_write.expected @@ -1,57 +1,57 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69692bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -117,7 +117,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69566bv64) == 0bv8); free ensures (memory_load8_le(mem, 69567bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -126,13 +126,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -284,6 +284,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4024bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4024bv64)) || L(mem, bvadd64(R9, 4024bv64))); @@ -295,6 +296,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, 0bv32), gamma_store32(Gamma_mem, R9, true); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000308"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; @@ -305,6 +307,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000031d"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4048bv64)) || L(mem, bvadd64(R8, 4048bv64))); @@ -320,6 +323,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000344"} true; call rely(); assert (L(mem, R8) ==> true); z_old := memory_load32_le(mem, $z_addr); @@ -327,6 +331,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); assert ((R8 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000034b"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R9)), (gamma_load32(Gamma_mem, R9) || L(mem, R9)); R8, Gamma_R8 := zero_extend32_32(bvadd32(R8[32:0], 1bv32)), Gamma_R8; @@ -337,5 +342,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000360"} true; return; } diff --git a/src/test/correct/secret_write/gcc/secret_write.expected b/src/test/correct/secret_write/gcc/secret_write.expected index 162db427a..fbb8b7faf 100644 --- a/src/test/correct/secret_write/gcc/secret_write.expected +++ b/src/test/correct/secret_write/gcc/secret_write.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -90,13 +90,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -200,6 +200,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -209,6 +210,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000032a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -223,6 +225,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000355"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); @@ -236,6 +239,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000037a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -245,6 +249,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000038c"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -259,6 +264,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000003b7"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/secret_write/gcc_O2/secret_write.expected b/src/test/correct/secret_write/gcc_O2/secret_write.expected index 4e97fe80d..393a51bf6 100644 --- a/src/test/correct/secret_write/gcc_O2/secret_write.expected +++ b/src/test/correct/secret_write/gcc_O2/secret_write.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_R3: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var R3: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_R3: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} R3: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -92,13 +92,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -202,6 +202,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R3, Gamma_R3 := 2bv64, true; @@ -213,6 +214,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), true); assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000001c2"} true; call rely(); assert (L(mem, bvadd64(R2, 4bv64)) ==> Gamma_R3); z_old := memory_load32_le(mem, $z_addr); @@ -220,5 +222,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R2, 4bv64), R3[32:0]), gamma_store32(Gamma_mem, bvadd64(R2, 4bv64), Gamma_R3); assert ((bvadd64(R2, 4bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000001ca"} true; return; } diff --git a/src/test/correct/secret_write/gcc_no_plt_no_pic/secret_write.expected b/src/test/correct/secret_write/gcc_no_plt_no_pic/secret_write.expected index 162db427a..9d6a27f3f 100644 --- a/src/test/correct/secret_write/gcc_no_plt_no_pic/secret_write.expected +++ b/src/test/correct/secret_write/gcc_no_plt_no_pic/secret_write.expected @@ -1,45 +1,45 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -90,13 +90,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -200,6 +200,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -209,6 +210,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000009b8"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -223,6 +225,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000009e3"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); @@ -236,6 +239,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000a08"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); @@ -245,6 +249,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000a1a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -259,6 +264,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000a45"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/secret_write/gcc_pic/secret_write.expected b/src/test/correct/secret_write/gcc_pic/secret_write.expected index 332031ef7..2275cb362 100644 --- a/src/test/correct/secret_write/gcc_pic/secret_write.expected +++ b/src/test/correct/secret_write/gcc_pic/secret_write.expected @@ -1,53 +1,53 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $x_addr) then (bvsmod32(memory_load32_le(memory, $z_addr), 2bv32) == 0bv32) else (if (index == $z_addr) then true else false))) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); -function {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvsge"} bvsge32(bv32, bv32) returns (bool); +function {:extern} {:bvbuiltin "bvsmod"} bvsmod32(bv32, bv32) returns (bv32); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); @@ -113,7 +113,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 68998bv64) == 0bv8); free ensures (memory_load8_le(mem, 68999bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $z_addr) == old(memory_load32_le(mem, $z_addr))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -122,13 +122,13 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr)); assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert bvsge32(memory_load32_le(mem, $z_addr), memory_load32_le(mem, $z_addr)); @@ -280,6 +280,7 @@ procedure main() var Gamma_x_old: bool; var z_old: bv32; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); @@ -290,6 +291,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000032b"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); @@ -306,6 +308,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000358"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -321,6 +324,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%0000037f"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -331,6 +335,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%00000392"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4048bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4048bv64)) || L(mem, bvadd64(R0, 4048bv64))); @@ -347,6 +352,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert bvsge32(memory_load32_le(mem, $z_addr), z_old); + assume {:captureState "%000003bf"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/simple_jump/clang/simple_jump.expected b/src/test/correct/simple_jump/clang/simple_jump.expected index d410505a4..62a848c1f 100644 --- a/src/test/correct/simple_jump/clang/simple_jump.expected +++ b/src/test/correct/simple_jump/clang/simple_jump.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1892bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,10 +199,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f1"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000002fe"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967290bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934587bv33))), (Gamma_R8 && Gamma_#4); @@ -216,24 +219,31 @@ procedure main() } goto l00000329; l00000329: + assume {:captureState "l00000329"} true; R8, Gamma_R8 := 1bv64, true; goto l0000032c; l00000326: + assume {:captureState "l00000326"} true; R8, Gamma_R8 := 0bv64, true; goto l0000032c; l0000032c: + assume {:captureState "l0000032c"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000334; } goto l0000034b; l0000034b: + assume {:captureState "l0000034b"} true; goto l0000034c; l0000034c: + assume {:captureState "l0000034c"} true; R8, Gamma_R8 := 6bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000035a"} true; goto l00000334; l00000334: + assume {:captureState "l00000334"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/simple_jump/clang_O2/simple_jump.expected b/src/test/correct/simple_jump/clang_O2/simple_jump.expected index 1e9764f80..b904c03a5 100644 --- a/src/test/correct/simple_jump/clang_O2/simple_jump.expected +++ b/src/test/correct/simple_jump/clang_O2/simple_jump.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1840bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/simple_jump/clang_no_plt_no_pic/simple_jump.expected b/src/test/correct/simple_jump/clang_no_plt_no_pic/simple_jump.expected index 21593dc1c..0973d91cd 100644 --- a/src/test/correct/simple_jump/clang_no_plt_no_pic/simple_jump.expected +++ b/src/test/correct/simple_jump/clang_no_plt_no_pic/simple_jump.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1892bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,10 +199,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000903"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000910"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967290bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934587bv33))), (Gamma_R8 && Gamma_#4); @@ -216,24 +219,31 @@ procedure main() } goto l0000093b; l0000093b: + assume {:captureState "l0000093b"} true; R8, Gamma_R8 := 1bv64, true; goto l0000093e; l00000938: + assume {:captureState "l00000938"} true; R8, Gamma_R8 := 0bv64, true; goto l0000093e; l0000093e: + assume {:captureState "l0000093e"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000946; } goto l0000095d; l0000095d: + assume {:captureState "l0000095d"} true; goto l0000095e; l0000095e: + assume {:captureState "l0000095e"} true; R8, Gamma_R8 := 6bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000096c"} true; goto l00000946; l00000946: + assume {:captureState "l00000946"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/simple_jump/clang_pic/simple_jump.expected b/src/test/correct/simple_jump/clang_pic/simple_jump.expected index 21593dc1c..0973d91cd 100644 --- a/src/test/correct/simple_jump/clang_pic/simple_jump.expected +++ b/src/test/correct/simple_jump/clang_pic/simple_jump.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1892bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,10 +199,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000903"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000910"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967290bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934587bv33))), (Gamma_R8 && Gamma_#4); @@ -216,24 +219,31 @@ procedure main() } goto l0000093b; l0000093b: + assume {:captureState "l0000093b"} true; R8, Gamma_R8 := 1bv64, true; goto l0000093e; l00000938: + assume {:captureState "l00000938"} true; R8, Gamma_R8 := 0bv64, true; goto l0000093e; l0000093e: + assume {:captureState "l0000093e"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000946; } goto l0000095d; l0000095d: + assume {:captureState "l0000095d"} true; goto l0000095e; l0000095e: + assume {:captureState "l0000095e"} true; R8, Gamma_R8 := 6bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000096c"} true; goto l00000946; l00000946: + assume {:captureState "l00000946"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/simple_jump/gcc/simple_jump.expected b/src/test/correct/simple_jump/gcc/simple_jump.expected index 207f613d1..9523ac12f 100644 --- a/src/test/correct/simple_jump/gcc/simple_jump.expected +++ b/src/test/correct/simple_jump/gcc/simple_jump.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1876bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,9 +197,11 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002e7"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#4); @@ -212,10 +214,13 @@ procedure main() } goto l0000031f; l0000031f: + assume {:captureState "l0000031f"} true; R0, Gamma_R0 := 6bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000032a"} true; goto l0000030a; l0000030a: + assume {:captureState "l0000030a"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/simple_jump/gcc_O2/simple_jump.expected b/src/test/correct/simple_jump/gcc_O2/simple_jump.expected index ab48890b6..306991d20 100644 --- a/src/test/correct/simple_jump/gcc_O2/simple_jump.expected +++ b/src/test/correct/simple_jump/gcc_O2/simple_jump.expected @@ -1,14 +1,14 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -49,7 +49,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -58,9 +58,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -155,6 +155,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/simple_jump/gcc_no_plt_no_pic/simple_jump.expected b/src/test/correct/simple_jump/gcc_no_plt_no_pic/simple_jump.expected index a401fed9f..76f57dcef 100644 --- a/src/test/correct/simple_jump/gcc_no_plt_no_pic/simple_jump.expected +++ b/src/test/correct/simple_jump/gcc_no_plt_no_pic/simple_jump.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1876bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,9 +197,11 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000008be"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#4); @@ -212,10 +214,13 @@ procedure main() } goto l000008f6; l000008f6: + assume {:captureState "l000008f6"} true; R0, Gamma_R0 := 6bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000901"} true; goto l000008e1; l000008e1: + assume {:captureState "l000008e1"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/simple_jump/gcc_pic/simple_jump.expected b/src/test/correct/simple_jump/gcc_pic/simple_jump.expected index a401fed9f..76f57dcef 100644 --- a/src/test/correct/simple_jump/gcc_pic/simple_jump.expected +++ b/src/test/correct/simple_jump/gcc_pic/simple_jump.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1876bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,9 +197,11 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000008be"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#4); @@ -212,10 +214,13 @@ procedure main() } goto l000008f6; l000008f6: + assume {:captureState "l000008f6"} true; R0, Gamma_R0 := 6bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000901"} true; goto l000008e1; l000008e1: + assume {:captureState "l000008e1"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/switch/clang/switch.expected b/src/test/correct/switch/clang/switch.expected index 1ddf91658..75db57ac2 100644 --- a/src/test/correct/switch/clang/switch.expected +++ b/src/test/correct/switch/clang/switch.expected @@ -1,44 +1,44 @@ -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1936bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,12 +199,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000323"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%0000032a"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000339"} true; #4, Gamma_#4 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#4); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_#4); @@ -217,20 +221,25 @@ procedure main() } goto l0000035d; l0000035d: + assume {:captureState "l0000035d"} true; R8, Gamma_R8 := 1bv64, true; goto l00000360; l0000035a: + assume {:captureState "l0000035a"} true; R8, Gamma_R8 := 0bv64, true; goto l00000360; l00000360: + assume {:captureState "l00000360"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000368; } goto l0000039a; l0000039a: + assume {:captureState "l0000039a"} true; goto l0000039b; l0000039b: + assume {:captureState "l0000039b"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #5, Gamma_#5 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#5); @@ -244,32 +253,43 @@ procedure main() } goto l000003c7; l000003c7: + assume {:captureState "l000003c7"} true; R8, Gamma_R8 := 1bv64, true; goto l000003ca; l000003c4: + assume {:captureState "l000003c4"} true; R8, Gamma_R8 := 0bv64, true; goto l000003ca; l000003ca: + assume {:captureState "l000003ca"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000389; } goto l000003d7; l00000389: + assume {:captureState "l00000389"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000394"} true; goto l0000037b; l000003d7: + assume {:captureState "l000003d7"} true; goto l000003d8; l000003d8: + assume {:captureState "l000003d8"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%000003e6"} true; goto l00000368; l00000368: + assume {:captureState "l00000368"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000378"} true; goto l0000037b; l0000037b: + assume {:captureState "l0000037b"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/switch/clang_O2/switch.expected b/src/test/correct/switch/clang_O2/switch.expected index 8637d2c74..ae43ad872 100644 --- a/src/test/correct/switch/clang_O2/switch.expected +++ b/src/test/correct/switch/clang_O2/switch.expected @@ -1,12 +1,12 @@ -var Gamma_mem: [bv64]bool; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1836bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -47,7 +47,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -56,9 +56,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -152,5 +152,6 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; return; } diff --git a/src/test/correct/switch/clang_no_plt_no_pic/switch.expected b/src/test/correct/switch/clang_no_plt_no_pic/switch.expected index 71d069297..e904c4952 100644 --- a/src/test/correct/switch/clang_no_plt_no_pic/switch.expected +++ b/src/test/correct/switch/clang_no_plt_no_pic/switch.expected @@ -1,44 +1,44 @@ -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1936bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,12 +199,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000009d8"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%000009df"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%000009ee"} true; #4, Gamma_#4 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#4); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_#4); @@ -217,20 +221,25 @@ procedure main() } goto l00000a12; l00000a12: + assume {:captureState "l00000a12"} true; R8, Gamma_R8 := 1bv64, true; goto l00000a15; l00000a0f: + assume {:captureState "l00000a0f"} true; R8, Gamma_R8 := 0bv64, true; goto l00000a15; l00000a15: + assume {:captureState "l00000a15"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000a1d; } goto l00000a4f; l00000a4f: + assume {:captureState "l00000a4f"} true; goto l00000a50; l00000a50: + assume {:captureState "l00000a50"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #5, Gamma_#5 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#5); @@ -244,32 +253,43 @@ procedure main() } goto l00000a7c; l00000a7c: + assume {:captureState "l00000a7c"} true; R8, Gamma_R8 := 1bv64, true; goto l00000a7f; l00000a79: + assume {:captureState "l00000a79"} true; R8, Gamma_R8 := 0bv64, true; goto l00000a7f; l00000a7f: + assume {:captureState "l00000a7f"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000a3e; } goto l00000a8c; l00000a3e: + assume {:captureState "l00000a3e"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a49"} true; goto l00000a30; l00000a8c: + assume {:captureState "l00000a8c"} true; goto l00000a8d; l00000a8d: + assume {:captureState "l00000a8d"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a9b"} true; goto l00000a1d; l00000a1d: + assume {:captureState "l00000a1d"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a2d"} true; goto l00000a30; l00000a30: + assume {:captureState "l00000a30"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/switch/clang_pic/switch.expected b/src/test/correct/switch/clang_pic/switch.expected index 71d069297..e904c4952 100644 --- a/src/test/correct/switch/clang_pic/switch.expected +++ b/src/test/correct/switch/clang_pic/switch.expected @@ -1,44 +1,44 @@ -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1936bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,12 +199,16 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%000009d8"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%000009df"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%000009ee"} true; #4, Gamma_#4 := bvadd32(R8[32:0], 4294967294bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934591bv33))), (Gamma_R8 && Gamma_#4); CF, Gamma_CF := bvnot1(bvcomp33(zero_extend1_32(bvadd32(#4, 1bv32)), bvadd33(zero_extend1_32(R8[32:0]), 4294967295bv33))), (Gamma_R8 && Gamma_#4); @@ -217,20 +221,25 @@ procedure main() } goto l00000a12; l00000a12: + assume {:captureState "l00000a12"} true; R8, Gamma_R8 := 1bv64, true; goto l00000a15; l00000a0f: + assume {:captureState "l00000a0f"} true; R8, Gamma_R8 := 0bv64, true; goto l00000a15; l00000a15: + assume {:captureState "l00000a15"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000a1d; } goto l00000a4f; l00000a4f: + assume {:captureState "l00000a4f"} true; goto l00000a50; l00000a50: + assume {:captureState "l00000a50"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #5, Gamma_#5 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#5); @@ -244,32 +253,43 @@ procedure main() } goto l00000a7c; l00000a7c: + assume {:captureState "l00000a7c"} true; R8, Gamma_R8 := 1bv64, true; goto l00000a7f; l00000a79: + assume {:captureState "l00000a79"} true; R8, Gamma_R8 := 0bv64, true; goto l00000a7f; l00000a7f: + assume {:captureState "l00000a7f"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000a3e; } goto l00000a8c; l00000a3e: + assume {:captureState "l00000a3e"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a49"} true; goto l00000a30; l00000a8c: + assume {:captureState "l00000a8c"} true; goto l00000a8d; l00000a8d: + assume {:captureState "l00000a8d"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a9b"} true; goto l00000a1d; l00000a1d: + assume {:captureState "l00000a1d"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000a2d"} true; goto l00000a30; l00000a30: + assume {:captureState "l00000a30"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/switch/gcc/switch.expected b/src/test/correct/switch/gcc/switch.expected index 4953b28c9..de46b7181 100644 --- a/src/test/correct/switch/gcc/switch.expected +++ b/src/test/correct/switch/gcc/switch.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1916bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,10 +199,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000030f"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000316"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#4); @@ -215,6 +218,7 @@ procedure main() } goto l0000036b; l0000036b: + assume {:captureState "l0000036b"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#5); @@ -227,18 +231,25 @@ procedure main() } goto l00000391; l0000035c: + assume {:captureState "l0000035c"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000367"} true; goto l0000034c; l00000391: + assume {:captureState "l00000391"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000039c"} true; goto l00000339; l00000339: + assume {:captureState "l00000339"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000349"} true; goto l0000034c; l0000034c: + assume {:captureState "l0000034c"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/switch/gcc_O2/switch.expected b/src/test/correct/switch/gcc_O2/switch.expected index a86190f67..f96261171 100644 --- a/src/test/correct/switch/gcc_O2/switch.expected +++ b/src/test/correct/switch/gcc_O2/switch.expected @@ -1,12 +1,12 @@ -var Gamma_mem: [bv64]bool; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1896bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -47,7 +47,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -56,9 +56,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -152,5 +152,6 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; return; } diff --git a/src/test/correct/switch/gcc_no_plt_no_pic/switch.expected b/src/test/correct/switch/gcc_no_plt_no_pic/switch.expected index c648c415f..ef08dc502 100644 --- a/src/test/correct/switch/gcc_no_plt_no_pic/switch.expected +++ b/src/test/correct/switch/gcc_no_plt_no_pic/switch.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1916bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,10 +199,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000096e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000975"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#4); @@ -215,6 +218,7 @@ procedure main() } goto l000009ca; l000009ca: + assume {:captureState "l000009ca"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#5); @@ -227,18 +231,25 @@ procedure main() } goto l000009f0; l000009bb: + assume {:captureState "l000009bb"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009c6"} true; goto l000009ab; l000009f0: + assume {:captureState "l000009f0"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009fb"} true; goto l00000998; l00000998: + assume {:captureState "l00000998"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009a8"} true; goto l000009ab; l000009ab: + assume {:captureState "l000009ab"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/switch/gcc_pic/switch.expected b/src/test/correct/switch/gcc_pic/switch.expected index c648c415f..ef08dc502 100644 --- a/src/test/correct/switch/gcc_pic/switch.expected +++ b/src/test/correct/switch/gcc_pic/switch.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1916bv64); -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -199,10 +199,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000096e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000975"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#4); @@ -215,6 +218,7 @@ procedure main() } goto l000009ca; l000009ca: + assume {:captureState "l000009ca"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#5); @@ -227,18 +231,25 @@ procedure main() } goto l000009f0; l000009bb: + assume {:captureState "l000009bb"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009c6"} true; goto l000009ab; l000009f0: + assume {:captureState "l000009f0"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009fb"} true; goto l00000998; l00000998: + assume {:captureState "l00000998"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000009a8"} true; goto l000009ab; l000009ab: + assume {:captureState "l000009ab"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/correct/switch2/clang_O2/switch2.expected b/src/test/correct/switch2/clang_O2/switch2.expected index bdb8ef7ef..9083f1e41 100644 --- a/src/test/correct/switch2/clang_O2/switch2.expected +++ b/src/test/correct/switch2/clang_O2/switch2.expected @@ -1,11 +1,11 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var mem: [bv64]bv8; -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} mem: [bv64]bv8; +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -46,7 +46,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -55,9 +55,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -152,5 +152,6 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; return; } diff --git a/src/test/correct/switch2/gcc/switch2.expected b/src/test/correct/switch2/gcc/switch2.expected index afd6b963a..e577cd799 100644 --- a/src/test/correct/switch2/gcc/switch2.expected +++ b/src/test/correct/switch2/gcc/switch2.expected @@ -1,65 +1,65 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -100,7 +100,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,9 +109,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -237,14 +237,20 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000386"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%0000038c"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000039e"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%000003a6"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), true); + assume {:captureState "%000003ad"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#5); @@ -257,10 +263,13 @@ procedure main() } goto l00000408; l000003d0: + assume {:captureState "l000003d0"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%000003e0"} true; goto l000003e2; l00000408: + assume {:captureState "l00000408"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#6); @@ -273,6 +282,7 @@ procedure main() } goto l00000430; l00000430: + assume {:captureState "l00000430"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #7, Gamma_#7 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#7, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#7); @@ -285,6 +295,7 @@ procedure main() } goto l00000467; l00000467: + assume {:captureState "l00000467"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #8, Gamma_#8 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#8, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#8); @@ -297,6 +308,7 @@ procedure main() } goto l0000048f; l0000048f: + assume {:captureState "l0000048f"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #9, Gamma_#9 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#9, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#9); @@ -309,13 +321,17 @@ procedure main() } goto l000004e2; l000004b0: + assume {:captureState "l000004b0"} true; R30, Gamma_R30 := 1944bv64, true; call r(); goto l000004bc; l000004bc: + assume {:captureState "l000004bc"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%000004c2"} true; goto l000004c4; l000004e2: + assume {:captureState "l000004e2"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #10, Gamma_#10 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#10, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#10); @@ -328,6 +344,7 @@ procedure main() } goto l0000050a; l0000050a: + assume {:captureState "l0000050a"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #11, Gamma_#11 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#11, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#11); @@ -340,10 +357,13 @@ procedure main() } goto l00000530; l000004c4: + assume {:captureState "l000004c4"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%000004cf"} true; goto l000003f1; l00000530: + assume {:captureState "l00000530"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #12, Gamma_#12 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#12, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#12); @@ -356,20 +376,28 @@ procedure main() } goto l00000556; l000004d5: + assume {:captureState "l000004d5"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%000004e0"} true; goto l00000451; l00000451: + assume {:captureState "l00000451"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000461"} true; goto l000003f1; l00000556: + assume {:captureState "l00000556"} true; goto l000003e2; l000003e2: + assume {:captureState "l000003e2"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%000003ed"} true; goto l000003f1; l000003f1: + assume {:captureState "l000003f1"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; @@ -452,6 +480,7 @@ procedure r() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lr: + assume {:captureState "lr"} true; R0, Gamma_R0 := 1bv64, true; return; } diff --git a/src/test/correct/switch2/gcc_O2/switch2.expected b/src/test/correct/switch2/gcc_O2/switch2.expected index 1ab56febd..8dd64e5d7 100644 --- a/src/test/correct/switch2/gcc_O2/switch2.expected +++ b/src/test/correct/switch2/gcc_O2/switch2.expected @@ -1,11 +1,11 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var mem: [bv64]bv8; -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} mem: [bv64]bv8; +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -46,7 +46,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -55,9 +55,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -152,5 +152,6 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; return; } diff --git a/src/test/correct/switch2/gcc_no_plt_no_pic/switch2.expected b/src/test/correct/switch2/gcc_no_plt_no_pic/switch2.expected index 34fe6e456..d39a1164a 100644 --- a/src/test/correct/switch2/gcc_no_plt_no_pic/switch2.expected +++ b/src/test/correct/switch2/gcc_no_plt_no_pic/switch2.expected @@ -1,65 +1,65 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -100,7 +100,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,9 +109,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -237,14 +237,20 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000be5"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000beb"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000bfd"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000c05"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), true); + assume {:captureState "%00000c0c"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#5); @@ -257,10 +263,13 @@ procedure main() } goto l00000c67; l00000c2f: + assume {:captureState "l00000c2f"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000c3f"} true; goto l00000c41; l00000c67: + assume {:captureState "l00000c67"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#6); @@ -273,6 +282,7 @@ procedure main() } goto l00000c8f; l00000c8f: + assume {:captureState "l00000c8f"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #7, Gamma_#7 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#7, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#7); @@ -285,6 +295,7 @@ procedure main() } goto l00000cc6; l00000cc6: + assume {:captureState "l00000cc6"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #8, Gamma_#8 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#8, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#8); @@ -297,6 +308,7 @@ procedure main() } goto l00000cee; l00000cee: + assume {:captureState "l00000cee"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #9, Gamma_#9 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#9, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#9); @@ -309,13 +321,17 @@ procedure main() } goto l00000d41; l00000d0f: + assume {:captureState "l00000d0f"} true; R30, Gamma_R30 := 1944bv64, true; call r(); goto l00000d1b; l00000d1b: + assume {:captureState "l00000d1b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000d21"} true; goto l00000d23; l00000d41: + assume {:captureState "l00000d41"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #10, Gamma_#10 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#10, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#10); @@ -328,6 +344,7 @@ procedure main() } goto l00000d69; l00000d69: + assume {:captureState "l00000d69"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #11, Gamma_#11 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#11, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#11); @@ -340,10 +357,13 @@ procedure main() } goto l00000d8f; l00000d23: + assume {:captureState "l00000d23"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000d2e"} true; goto l00000c50; l00000d8f: + assume {:captureState "l00000d8f"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #12, Gamma_#12 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#12, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#12); @@ -356,20 +376,28 @@ procedure main() } goto l00000db5; l00000d34: + assume {:captureState "l00000d34"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000d3f"} true; goto l00000cb0; l00000cb0: + assume {:captureState "l00000cb0"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000cc0"} true; goto l00000c50; l00000db5: + assume {:captureState "l00000db5"} true; goto l00000c41; l00000c41: + assume {:captureState "l00000c41"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000c4c"} true; goto l00000c50; l00000c50: + assume {:captureState "l00000c50"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; @@ -452,6 +480,7 @@ procedure r() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lr: + assume {:captureState "lr"} true; R0, Gamma_R0 := 1bv64, true; return; } diff --git a/src/test/correct/switch2/gcc_pic/switch2.expected b/src/test/correct/switch2/gcc_pic/switch2.expected index 34fe6e456..d39a1164a 100644 --- a/src/test/correct/switch2/gcc_pic/switch2.expected +++ b/src/test/correct/switch2/gcc_pic/switch2.expected @@ -1,65 +1,65 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvand"} bvand1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -100,7 +100,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -109,9 +109,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -237,14 +237,20 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000be5"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000beb"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000bfd"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000c05"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), true); + assume {:captureState "%00000c0c"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #5, Gamma_#5 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#5, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#5); @@ -257,10 +263,13 @@ procedure main() } goto l00000c67; l00000c2f: + assume {:captureState "l00000c2f"} true; R0, Gamma_R0 := 4bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000c3f"} true; goto l00000c41; l00000c67: + assume {:captureState "l00000c67"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967290bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934587bv33))), (Gamma_R0 && Gamma_#6); @@ -273,6 +282,7 @@ procedure main() } goto l00000c8f; l00000c8f: + assume {:captureState "l00000c8f"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #7, Gamma_#7 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#7, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#7); @@ -285,6 +295,7 @@ procedure main() } goto l00000cc6; l00000cc6: + assume {:captureState "l00000cc6"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #8, Gamma_#8 := bvadd32(R0[32:0], 4294967291bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#8, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934588bv33))), (Gamma_R0 && Gamma_#8); @@ -297,6 +308,7 @@ procedure main() } goto l00000cee; l00000cee: + assume {:captureState "l00000cee"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #9, Gamma_#9 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#9, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#9); @@ -309,13 +321,17 @@ procedure main() } goto l00000d41; l00000d0f: + assume {:captureState "l00000d0f"} true; R30, Gamma_R30 := 1944bv64, true; call r(); goto l00000d1b; l00000d1b: + assume {:captureState "l00000d1b"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000d21"} true; goto l00000d23; l00000d41: + assume {:captureState "l00000d41"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #10, Gamma_#10 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#10, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#10); @@ -328,6 +344,7 @@ procedure main() } goto l00000d69; l00000d69: + assume {:captureState "l00000d69"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #11, Gamma_#11 := bvadd32(R0[32:0], 4294967294bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#11, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934591bv33))), (Gamma_R0 && Gamma_#11); @@ -340,10 +357,13 @@ procedure main() } goto l00000d8f; l00000d23: + assume {:captureState "l00000d23"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000d2e"} true; goto l00000c50; l00000d8f: + assume {:captureState "l00000d8f"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #12, Gamma_#12 := bvadd32(R0[32:0], 4294967293bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#12, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934590bv33))), (Gamma_R0 && Gamma_#12); @@ -356,20 +376,28 @@ procedure main() } goto l00000db5; l00000d34: + assume {:captureState "l00000d34"} true; R0, Gamma_R0 := 2bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000d3f"} true; goto l00000cb0; l00000cb0: + assume {:captureState "l00000cb0"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000cc0"} true; goto l00000c50; l00000db5: + assume {:captureState "l00000db5"} true; goto l00000c41; l00000c41: + assume {:captureState "l00000c41"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000c4c"} true; goto l00000c50; l00000c50: + assume {:captureState "l00000c50"} true; R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R31, Gamma_R31 := bvadd64(R31, 48bv64), Gamma_R31; @@ -452,6 +480,7 @@ procedure r() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lr: + assume {:captureState "lr"} true; R0, Gamma_R0 := 1bv64, true; return; } diff --git a/src/test/correct/syscall/clang/syscall.expected b/src/test/correct/syscall/clang/syscall.expected index de88ed4c3..5c23cb30f 100644 --- a/src/test/correct/syscall/clang/syscall.expected +++ b/src/test/correct/syscall/clang/syscall.expected @@ -1,62 +1,62 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1944bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -97,7 +97,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -106,9 +106,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure fork(); @@ -286,19 +286,27 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002ea"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002f0"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%000002fd"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "%00000305"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%0000030d"} true; R30, Gamma_R30 := 1904bv64, true; call fork(); goto l00000317; l00000317: + assume {:captureState "l00000317"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/syscall/clang_no_plt_no_pic/syscall.expected b/src/test/correct/syscall/clang_no_plt_no_pic/syscall.expected index dc9bcaa16..d0efb46c8 100644 --- a/src/test/correct/syscall/clang_no_plt_no_pic/syscall.expected +++ b/src/test/correct/syscall/clang_no_plt_no_pic/syscall.expected @@ -1,62 +1,62 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1944bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -97,7 +97,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -106,9 +106,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure fork(); @@ -286,19 +286,27 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000902"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000908"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000915"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "%0000091d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000925"} true; R30, Gamma_R30 := 1904bv64, true; call fork(); goto l0000092f; l0000092f: + assume {:captureState "l0000092f"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000935"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/syscall/clang_pic/syscall.expected b/src/test/correct/syscall/clang_pic/syscall.expected index dc9bcaa16..d0efb46c8 100644 --- a/src/test/correct/syscall/clang_pic/syscall.expected +++ b/src/test/correct/syscall/clang_pic/syscall.expected @@ -1,62 +1,62 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1944bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -97,7 +97,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69686bv64) == 0bv8); free ensures (memory_load8_le(mem, 69687bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -106,9 +106,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure fork(); @@ -286,19 +286,27 @@ procedure main() var Gamma_#4: bool; var Gamma_#5: bool; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; #4, Gamma_#4 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%00000902"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%00000908"} true; R29, Gamma_R29 := bvadd64(R31, 32bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551612bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551612bv64), true); + assume {:captureState "%00000915"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R29, 18446744073709551608bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R29, 18446744073709551608bv64), Gamma_R0); + assume {:captureState "%0000091d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%00000925"} true; R30, Gamma_R30 := 1904bv64, true; call fork(); goto l0000092f; l0000092f: + assume {:captureState "l0000092f"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000935"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); #5, Gamma_#5 := bvadd64(R31, 32bv64), Gamma_R31; R29, Gamma_R29 := memory_load64_le(stack, #5), gamma_load64(Gamma_stack, #5); diff --git a/src/test/correct/syscall/gcc/syscall.expected b/src/test/correct/syscall/gcc/syscall.expected index f12cfc259..d10405962 100644 --- a/src/test/correct/syscall/gcc/syscall.expected +++ b/src/test/correct/syscall/gcc/syscall.expected @@ -1,62 +1,62 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1932bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -97,7 +97,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -106,9 +106,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure fork(); @@ -284,18 +284,25 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000002d8"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000002de"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000002f0"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%000002f8"} true; R30, Gamma_R30 := 1896bv64, true; call fork(); goto l00000302; l00000302: + assume {:captureState "l00000302"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%00000308"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/syscall/gcc_O2/syscall.expected b/src/test/correct/syscall/gcc_O2/syscall.expected index 04b6a3257..757903692 100644 --- a/src/test/correct/syscall/gcc_O2/syscall.expected +++ b/src/test/correct/syscall/gcc_O2/syscall.expected @@ -1,16 +1,16 @@ -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_mem: [bv64]bool; -var R16: bv64; -var R17: bv64; -var mem: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1960bv64); -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -51,7 +51,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -60,9 +60,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure fork(); diff --git a/src/test/correct/syscall/gcc_no_plt_no_pic/syscall.expected b/src/test/correct/syscall/gcc_no_plt_no_pic/syscall.expected index 7052244b3..712177c54 100644 --- a/src/test/correct/syscall/gcc_no_plt_no_pic/syscall.expected +++ b/src/test/correct/syscall/gcc_no_plt_no_pic/syscall.expected @@ -1,62 +1,62 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1932bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -97,7 +97,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -106,9 +106,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure fork(); @@ -284,18 +284,25 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008cf"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008d5"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000008e7"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%000008ef"} true; R30, Gamma_R30 := 1896bv64, true; call fork(); goto l000008f9; l000008f9: + assume {:captureState "l000008f9"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%000008ff"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/syscall/gcc_pic/syscall.expected b/src/test/correct/syscall/gcc_pic/syscall.expected index 7052244b3..712177c54 100644 --- a/src/test/correct/syscall/gcc_pic/syscall.expected +++ b/src/test/correct/syscall/gcc_pic/syscall.expected @@ -1,62 +1,62 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R16: bool; -var Gamma_R17: bool; -var Gamma_R29: bool; -var Gamma_R30: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R16: bv64; -var R17: bv64; -var R29: bv64; -var R30: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $_IO_stdin_used_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R16: bool; +var {:extern} Gamma_R17: bool; +var {:extern} Gamma_R29: bool; +var {:extern} Gamma_R30: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R16: bv64; +var {:extern} R17: bv64; +var {:extern} R29: bv64; +var {:extern} R30: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $_IO_stdin_used_addr: bv64; axiom ($_IO_stdin_used_addr == 1932bv64); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -97,7 +97,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -106,9 +106,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure fork(); @@ -284,18 +284,25 @@ procedure main() var #4: bv64; var Gamma_#4: bool; lmain: + assume {:captureState "lmain"} true; #4, Gamma_#4 := bvadd64(R31, 18446744073709551568bv64), Gamma_R31; stack, Gamma_stack := memory_store64_le(stack, #4, R29), gamma_store64(Gamma_stack, #4, Gamma_R29); + assume {:captureState "%000008cf"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(#4, 8bv64), R30), gamma_store64(Gamma_stack, bvadd64(#4, 8bv64), Gamma_R30); + assume {:captureState "%000008d5"} true; R31, Gamma_R31 := #4, Gamma_#4; R29, Gamma_R29 := R31, Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000008e7"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 16bv64), R1), gamma_store64(Gamma_stack, bvadd64(R31, 16bv64), Gamma_R1); + assume {:captureState "%000008ef"} true; R30, Gamma_R30 := 1896bv64, true; call fork(); goto l000008f9; l000008f9: + assume {:captureState "l000008f9"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 44bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 44bv64), Gamma_R0); + assume {:captureState "%000008ff"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 44bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 44bv64)); R29, Gamma_R29 := memory_load64_le(stack, R31), gamma_load64(Gamma_stack, R31); R30, Gamma_R30 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); diff --git a/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected index f4d0f8017..08d8da05a 100644 --- a/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -211,8 +211,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -228,27 +230,36 @@ procedure main() } goto l00000325; l00000325: + assume {:captureState "l00000325"} true; R8, Gamma_R8 := 1bv64, true; goto l00000328; l00000322: + assume {:captureState "l00000322"} true; R8, Gamma_R8 := 0bv64, true; goto l00000328; l00000328: + assume {:captureState "l00000328"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000330; } goto l00000358; l00000330: + assume {:captureState "l00000330"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000340"} true; goto l00000343; l00000358: + assume {:captureState "l00000358"} true; goto l00000359; l00000359: + assume {:captureState "l00000359"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000361"} true; goto l00000343; l00000343: + assume {:captureState "l00000343"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected index f162af5da..60b84aa63 100644 --- a/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -83,12 +83,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -197,6 +197,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -211,11 +212,14 @@ procedure main() } goto l000002e8; l000002e8: + assume {:captureState "l000002e8"} true; R0, Gamma_R0 := 1bv64, true; goto l000002eb; l000002e5: + assume {:captureState "l000002e5"} true; R0, Gamma_R0 := 0bv64, true; goto l000002eb; l000002eb: + assume {:captureState "l000002eb"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/clang_no_plt_no_pic/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/clang_no_plt_no_pic/using_gamma_conditional.expected index 0bb52e57a..1dd67fe4c 100644 --- a/src/test/correct/using_gamma_conditional/clang_no_plt_no_pic/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/clang_no_plt_no_pic/using_gamma_conditional.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -87,7 +87,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -95,12 +95,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -211,8 +211,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000910"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -228,27 +230,36 @@ procedure main() } goto l00000940; l00000940: + assume {:captureState "l00000940"} true; R8, Gamma_R8 := 1bv64, true; goto l00000943; l0000093d: + assume {:captureState "l0000093d"} true; R8, Gamma_R8 := 0bv64, true; goto l00000943; l00000943: + assume {:captureState "l00000943"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000094b; } goto l00000973; l0000094b: + assume {:captureState "l0000094b"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000095b"} true; goto l0000095e; l00000973: + assume {:captureState "l00000973"} true; goto l00000974; l00000974: + assume {:captureState "l00000974"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000097c"} true; goto l0000095e; l0000095e: + assume {:captureState "l0000095e"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected index c741aa67b..72ef22ce4 100644 --- a/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected @@ -1,60 +1,60 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -103,7 +103,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -111,12 +111,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -243,8 +243,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f9"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); @@ -262,27 +264,36 @@ procedure main() } goto l00000330; l00000330: + assume {:captureState "l00000330"} true; R8, Gamma_R8 := 1bv64, true; goto l00000333; l0000032d: + assume {:captureState "l0000032d"} true; R8, Gamma_R8 := 0bv64, true; goto l00000333; l00000333: + assume {:captureState "l00000333"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000033b; } goto l00000363; l0000033b: + assume {:captureState "l0000033b"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000034b"} true; goto l0000034e; l00000363: + assume {:captureState "l00000363"} true; goto l00000364; l00000364: + assume {:captureState "l00000364"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000036c"} true; goto l0000034e; l0000034e: + assume {:captureState "l0000034e"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected index df1a346eb..4ec9b160b 100644 --- a/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/gcc/using_gamma_conditional.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -81,12 +81,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -195,6 +195,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -210,11 +211,14 @@ procedure main() } goto l00000309; l000002fa: + assume {:captureState "l000002fa"} true; R0, Gamma_R0 := 1bv64, true; goto l00000304; l00000309: + assume {:captureState "l00000309"} true; R0, Gamma_R0 := 0bv64, true; goto l00000304; l00000304: + assume {:captureState "l00000304"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/gcc_O2/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/gcc_O2/using_gamma_conditional.expected index 1991c20a8..10df26406 100644 --- a/src/test/correct/using_gamma_conditional/gcc_O2/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/gcc_O2/using_gamma_conditional.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -81,12 +81,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -195,6 +195,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, bvadd64(R0, 20bv64))), (gamma_load32(Gamma_mem, bvadd64(R0, 20bv64)) || L(mem, bvadd64(R0, 20bv64))); @@ -209,11 +210,14 @@ procedure main() } goto l000001d2; l000001d2: + assume {:captureState "l000001d2"} true; R0, Gamma_R0 := 1bv64, true; goto l000001d5; l000001cf: + assume {:captureState "l000001cf"} true; R0, Gamma_R0 := 0bv64, true; goto l000001d5; l000001d5: + assume {:captureState "l000001d5"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/gcc_no_plt_no_pic/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/gcc_no_plt_no_pic/using_gamma_conditional.expected index 8d6ed7a5a..44703edf4 100644 --- a/src/test/correct/using_gamma_conditional/gcc_no_plt_no_pic/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/gcc_no_plt_no_pic/using_gamma_conditional.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -81,12 +81,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -195,6 +195,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -210,11 +211,14 @@ procedure main() } goto l000008c2; l000008b3: + assume {:captureState "l000008b3"} true; R0, Gamma_R0 := 1bv64, true; goto l000008bd; l000008c2: + assume {:captureState "l000008c2"} true; R0, Gamma_R0 := 0bv64, true; goto l000008bd; l000008bd: + assume {:captureState "l000008bd"} true; return; } diff --git a/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected b/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected index cf6db78d2..04f503f58 100644 --- a/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected +++ b/src/test/correct/using_gamma_conditional/gcc_pic/using_gamma_conditional.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -89,7 +89,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (old(gamma_load32(Gamma_mem, $x_addr)) ==> gamma_load32(Gamma_mem, $x_addr)); { @@ -97,12 +97,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); @@ -227,6 +227,7 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -243,11 +244,14 @@ procedure main() } goto l0000030a; l000002fb: + assume {:captureState "l000002fb"} true; R0, Gamma_R0 := 1bv64, true; goto l00000305; l0000030a: + assume {:captureState "l0000030a"} true; R0, Gamma_R0 := 0bv64, true; goto l00000305; l00000305: + assume {:captureState "l00000305"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected index 9a38996b7..5ab807fea 100644 --- a/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -189,6 +189,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -197,6 +198,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%000002ce"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang_O2/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/clang_O2/using_gamma_write_z.expected index fddf32d04..ba7a07752 100644 --- a/src/test/correct/using_gamma_write_z/clang_O2/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/clang_O2/using_gamma_write_z.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -189,6 +189,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 1bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -198,5 +199,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); assert ((bvadd64(R8, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%000002d3"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang_no_plt_no_pic/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/clang_no_plt_no_pic/using_gamma_write_z.expected index 9a38996b7..121f49afb 100644 --- a/src/test/correct/using_gamma_write_z/clang_no_plt_no_pic/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/clang_no_plt_no_pic/using_gamma_write_z.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -189,6 +189,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 69632bv64, true; R8, Gamma_R8 := 1bv64, true; call rely(); @@ -197,6 +198,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 52bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 52bv64), Gamma_R8); assert ((bvadd64(R9, 52bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%00000845"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected index bf7fd1eb8..c05386840 100644 --- a/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected @@ -1,49 +1,49 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69684bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -92,7 +92,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69598bv64) == 0bv8); free ensures (memory_load8_le(mem, 69599bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -100,12 +100,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -221,6 +221,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R9, Gamma_R9 := 65536bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R9, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R9, 4040bv64)) || L(mem, bvadd64(R9, 4040bv64))); @@ -231,6 +232,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); assert ((R9 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected index d16cac0c0..195161608 100644 --- a/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -82,12 +82,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -187,6 +187,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -196,6 +197,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%000002d8"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected index c261dfc76..6e3d75bef 100644 --- a/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -84,12 +84,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -189,6 +189,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := 1bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -198,5 +199,6 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); assert ((bvadd64(R1, 20bv64) == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%000001bd"} true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc_no_plt_no_pic/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/gcc_no_plt_no_pic/using_gamma_write_z.expected index d16cac0c0..8bf981db5 100644 --- a/src/test/correct/using_gamma_write_z/gcc_no_plt_no_pic/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/gcc_no_plt_no_pic/using_gamma_write_z.expected @@ -1,39 +1,39 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -74,7 +74,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -82,12 +82,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -187,6 +187,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := 1bv64, true; @@ -196,6 +197,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%0000085b"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected b/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected index 0346aadea..3ffffbcfb 100644 --- a/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected +++ b/src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $x_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $x_addr) then (memory_load32_le(memory, $z_addr) == 0bv32) else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); @@ -90,7 +90,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69014bv64) == 0bv8); free ensures (memory_load8_le(mem, 69015bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures ((old(memory_load32_le(mem, $x_addr)) == memory_load32_le(mem, $x_addr)) && (old(memory_load32_le(mem, $z_addr)) == memory_load32_le(mem, $z_addr))); { @@ -98,12 +98,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert ((memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)) && (memory_load32_le(mem, $z_addr) == memory_load32_le(mem, $z_addr))); } -procedure guarantee_reflexive() +procedure {:extern} guarantee_reflexive() modifies Gamma_mem, mem; { assert (gamma_load32(Gamma_mem, $x_addr) ==> gamma_load32(Gamma_mem, $x_addr)); @@ -219,6 +219,7 @@ procedure main() { var Gamma_x_old: bool; lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -229,6 +230,7 @@ procedure main() mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); assert ((R0 == $z_addr) ==> (L(mem, $x_addr) ==> Gamma_x_old)); assert (Gamma_x_old ==> gamma_load32(Gamma_mem, $x_addr)); + assume {:captureState "%000002d9"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/incorrect/basicassign/clang/basicassign.expected b/src/test/incorrect/basicassign/clang/basicassign.expected index 3898c9ef8..122d69a08 100644 --- a/src/test/incorrect/basicassign/clang/basicassign.expected +++ b/src/test/incorrect/basicassign/clang/basicassign.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -91,12 +91,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -191,6 +191,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R10, Gamma_R10 := 69632bv64, true; call rely(); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); @@ -198,25 +199,30 @@ procedure main() call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R9); + assume {:captureState "%000002f9"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> true); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); + assume {:captureState "%00000305"} true; call rely(); R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R11); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R11); + assume {:captureState "%00000319"} true; call rely(); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); + assume {:captureState "%00000328"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "%00000337"} true; return; } diff --git a/src/test/incorrect/basicassign/clang_O2/basicassign.expected b/src/test/incorrect/basicassign/clang_O2/basicassign.expected index bb9e905d2..e3a318276 100644 --- a/src/test/incorrect/basicassign/clang_O2/basicassign.expected +++ b/src/test/incorrect/basicassign/clang_O2/basicassign.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -89,12 +89,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -189,6 +189,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; R9, Gamma_R9 := 69632bv64, true; @@ -198,8 +199,10 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002eb"} true; call rely(); assert (L(mem, bvadd64(R10, 60bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R10, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R10, 60bv64), Gamma_R8); + assume {:captureState "%000002f3"} true; return; } diff --git a/src/test/incorrect/basicassign/clang_no_plt_no_pic/basicassign.expected b/src/test/incorrect/basicassign/clang_no_plt_no_pic/basicassign.expected index 3898c9ef8..3250d4cce 100644 --- a/src/test/incorrect/basicassign/clang_no_plt_no_pic/basicassign.expected +++ b/src/test/incorrect/basicassign/clang_no_plt_no_pic/basicassign.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -91,12 +91,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -191,6 +191,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R10, Gamma_R10 := 69632bv64, true; call rely(); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); @@ -198,25 +199,30 @@ procedure main() call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R9); + assume {:captureState "%000008e6"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> true); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), 0bv32), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), true); + assume {:captureState "%000008f2"} true; call rely(); R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R11); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R11[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R11); + assume {:captureState "%00000906"} true; call rely(); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, bvadd64(R10, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R10, 52bv64)) || L(mem, bvadd64(R10, 52bv64))); call rely(); assert (L(mem, bvadd64(R8, 56bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 56bv64), Gamma_R10); + assume {:captureState "%00000915"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); call rely(); assert (L(mem, bvadd64(R9, 60bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 60bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 60bv64), Gamma_R8); + assume {:captureState "%00000924"} true; return; } diff --git a/src/test/incorrect/basicassign/clang_pic/basicassign.expected b/src/test/incorrect/basicassign/clang_pic/basicassign.expected index 5a362163e..ac86f966b 100644 --- a/src/test/incorrect/basicassign/clang_pic/basicassign.expected +++ b/src/test/incorrect/basicassign/clang_pic/basicassign.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R11: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R11: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R11: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R11: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69692bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -115,7 +115,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69566bv64) == 0bv8); free ensures (memory_load8_le(mem, 69567bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -123,12 +123,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -271,6 +271,7 @@ procedure main() free ensures (memory_load8_le(mem, 69567bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); @@ -282,10 +283,12 @@ procedure main() call rely(); assert (L(mem, R8) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "%00000313"} true; R0, Gamma_R0 := 0bv64, true; call rely(); assert (L(mem, R8) ==> true); mem, Gamma_mem := memory_store32_le(mem, R8, 0bv32), gamma_store32(Gamma_mem, R8, true); + assume {:captureState "%0000031f"} true; call rely(); R11, Gamma_R11 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); R9, Gamma_R9 := 65536bv64, true; @@ -294,15 +297,18 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R11); mem, Gamma_mem := memory_store32_le(mem, R9, R11[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R11); + assume {:captureState "%0000033a"} true; call rely(); R10, Gamma_R10 := zero_extend32_32(memory_load32_le(mem, R10)), (gamma_load32(Gamma_mem, R10) || L(mem, R10)); call rely(); assert (L(mem, R8) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, R8, R10[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R10); + assume {:captureState "%00000349"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000358"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc/basicassign.expected b/src/test/incorrect/basicassign/gcc/basicassign.expected index b184d930c..121167794 100644 --- a/src/test/incorrect/basicassign/gcc/basicassign.expected +++ b/src/test/incorrect/basicassign/gcc/basicassign.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -185,6 +185,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); @@ -194,11 +195,13 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000341"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> true); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "%00000353"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -208,6 +211,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000378"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); @@ -217,6 +221,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000039d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -226,6 +231,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003c2"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/incorrect/basicassign/gcc_O2/basicassign.expected b/src/test/incorrect/basicassign/gcc_O2/basicassign.expected index d19045adc..42773c210 100644 --- a/src/test/incorrect/basicassign/gcc_O2/basicassign.expected +++ b/src/test/incorrect/basicassign/gcc_O2/basicassign.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69652bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69656bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69660bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -87,12 +87,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -189,6 +189,7 @@ procedure main() var #1: bv64; var Gamma_#1: bool; lmain: + assume {:captureState "lmain"} true; R2, Gamma_R2 := 69632bv64, true; R1, Gamma_R1 := bvadd64(R2, 20bv64), Gamma_R2; R0, Gamma_R0 := 0bv64, true; @@ -198,8 +199,10 @@ procedure main() call rely(); assert (L(mem, #1) ==> Gamma_R2); mem, Gamma_mem := memory_store32_le(mem, #1, R2[32:0]), gamma_store32(Gamma_mem, #1, Gamma_R2); + assume {:captureState "%000001c9"} true; call rely(); assert (L(mem, bvadd64(#1, 4bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store32_le(mem, bvadd64(#1, 4bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(#1, 4bv64), Gamma_R2); + assume {:captureState "%000001cf"} true; return; } diff --git a/src/test/incorrect/basicassign/gcc_no_plt_no_pic/basicassign.expected b/src/test/incorrect/basicassign/gcc_no_plt_no_pic/basicassign.expected index b184d930c..499b391fd 100644 --- a/src/test/incorrect/basicassign/gcc_no_plt_no_pic/basicassign.expected +++ b/src/test/incorrect/basicassign/gcc_no_plt_no_pic/basicassign.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -85,12 +85,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -185,6 +185,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); @@ -194,11 +195,13 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000009dc"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); assert (L(mem, R0) ==> true); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "%000009ee"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -208,6 +211,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a13"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 28bv64), Gamma_R0; call rely(); @@ -217,6 +221,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a38"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -226,6 +231,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a5d"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/incorrect/basicassign/gcc_pic/basicassign.expected b/src/test/incorrect/basicassign/gcc_pic/basicassign.expected index 16ae5f224..e67a10bdf 100644 --- a/src/test/incorrect/basicassign/gcc_pic/basicassign.expected +++ b/src/test/incorrect/basicassign/gcc_pic/basicassign.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69660bv64); -const $x_addr: bv64; +const {:extern} $x_addr: bv64; axiom ($x_addr == 69652bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else (if (index == $x_addr) then false else false))) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (forall i: bv64 :: (((mem[i] == old(mem[i])) ==> (Gamma_mem[i] == old(Gamma_mem[i]))))); ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); @@ -109,7 +109,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 68998bv64) == 0bv8); free ensures (memory_load8_le(mem, 68999bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (memory_load32_le(mem, $x_addr) == old(memory_load32_le(mem, $x_addr))); { @@ -117,12 +117,12 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive() +procedure {:extern} rely_reflexive() { assert (memory_load32_le(mem, $x_addr) == memory_load32_le(mem, $x_addr)); } -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -265,6 +265,7 @@ procedure main() free ensures (memory_load8_le(mem, 68999bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -276,12 +277,14 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000343"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); assert (L(mem, R0) ==> true); mem, Gamma_mem := memory_store32_le(mem, R0, 0bv32), gamma_store32(Gamma_mem, R0, true); + assume {:captureState "%00000356"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -293,6 +296,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000037d"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); @@ -304,6 +308,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003a4"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -315,6 +320,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000003cb"} true; R0, Gamma_R0 := 0bv64, true; return; } diff --git a/src/test/incorrect/basicassign1/clang/basicassign1.expected b/src/test/incorrect/basicassign1/clang/basicassign1.expected index 49af47157..bd0fa29fe 100644 --- a/src/test/incorrect/basicassign1/clang/basicassign1.expected +++ b/src/test/incorrect/basicassign1/clang/basicassign1.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -189,25 +189,31 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 69632bv64, true; call rely(); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "%000002fe"} true; R0, Gamma_R0 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%0000030a"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); + assume {:captureState "%0000031e"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%0000032d"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%0000033c"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected b/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected index 246156a06..54cfefaed 100644 --- a/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected +++ b/src/test/incorrect/basicassign1/clang_O2/basicassign1.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -84,9 +84,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -181,6 +181,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -189,5 +190,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002de"} true; return; } diff --git a/src/test/incorrect/basicassign1/clang_no_plt_no_pic/basicassign1.expected b/src/test/incorrect/basicassign1/clang_no_plt_no_pic/basicassign1.expected index 49af47157..05e7e5e2f 100644 --- a/src/test/incorrect/basicassign1/clang_no_plt_no_pic/basicassign1.expected +++ b/src/test/incorrect/basicassign1/clang_no_plt_no_pic/basicassign1.expected @@ -1,46 +1,46 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -81,7 +81,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -90,9 +90,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -189,25 +189,31 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 69632bv64, true; call rely(); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "%000008f8"} true; R0, Gamma_R0 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000904"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R10[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R10); + assume {:captureState "%00000918"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000927"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R9, 56bv64), R8[32:0]), gamma_store32(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%00000936"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected b/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected index 2e0678777..dc205cce6 100644 --- a/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected +++ b/src/test/incorrect/basicassign1/clang_pic/basicassign1.expected @@ -1,54 +1,54 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -105,7 +105,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -114,9 +114,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -245,6 +245,7 @@ procedure main() free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 65536bv64, true; call rely(); @@ -252,8 +253,10 @@ procedure main() call rely(); R9, Gamma_R9 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R9[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R9); + assume {:captureState "%0000030d"} true; R0, Gamma_R0 := 0bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000319"} true; R10, Gamma_R10 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R9, Gamma_R9 := 65536bv64, true; call rely(); @@ -261,13 +264,16 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R10); mem, Gamma_mem := memory_store32_le(mem, R9, R10[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R10); + assume {:captureState "%00000334"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R8); + assume {:captureState "%00000343"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store32_le(mem, R9, R8[32:0]), gamma_store32(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%00000352"} true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; } diff --git a/src/test/incorrect/basicassign1/gcc/basicassign1.expected b/src/test/incorrect/basicassign1/gcc/basicassign1.expected index aeb65fedd..ea9681d89 100644 --- a/src/test/incorrect/basicassign1/gcc/basicassign1.expected +++ b/src/test/incorrect/basicassign1/gcc/basicassign1.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -86,9 +86,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -185,30 +185,36 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000031c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000323"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000357"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000371"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected b/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected index d3391fd0a..0414017cb 100644 --- a/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected +++ b/src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -84,9 +84,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -181,6 +181,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 20bv64), Gamma_R1; R0, Gamma_R0 := 0bv64, true; @@ -189,5 +190,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 20bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R1, 20bv64), R2[32:0]), gamma_store32(Gamma_mem, bvadd64(R1, 20bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; return; } diff --git a/src/test/incorrect/basicassign1/gcc_no_plt_no_pic/basicassign1.expected b/src/test/incorrect/basicassign1/gcc_no_plt_no_pic/basicassign1.expected index aeb65fedd..fdcbd7147 100644 --- a/src/test/incorrect/basicassign1/gcc_no_plt_no_pic/basicassign1.expected +++ b/src/test/incorrect/basicassign1/gcc_no_plt_no_pic/basicassign1.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -86,9 +86,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -185,30 +185,36 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000095c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000963"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000097d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000997"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000009b1"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected b/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected index d39d48df5..91a64b3f4 100644 --- a/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected +++ b/src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $z_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69652bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else false) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -101,7 +101,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -110,9 +110,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -241,6 +241,7 @@ procedure main() free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -248,7 +249,9 @@ procedure main() call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000324"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -256,12 +259,14 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033f"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%0000035a"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -269,6 +274,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000375"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign2/clang/basicassign2.expected b/src/test/incorrect/basicassign2/clang/basicassign2.expected index eac88ceeb..471ecc76c 100644 --- a/src/test/incorrect/basicassign2/clang/basicassign2.expected +++ b/src/test/incorrect/basicassign2/clang/basicassign2.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -82,7 +82,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -91,9 +91,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -190,24 +190,30 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 69632bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R9), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R9); + assume {:captureState "%000002fe"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000305"} true; R10, Gamma_R10 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R10), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R10); + assume {:captureState "%00000319"} true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000328"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R8), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R8); + assume {:captureState "%00000337"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected b/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected index 8cc16eaf9..1443e9789 100644 --- a/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected +++ b/src/test/incorrect/basicassign2/clang_O2/basicassign2.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -85,9 +85,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -182,6 +182,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -190,5 +191,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R8), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R8); + assume {:captureState "%000002de"} true; return; } diff --git a/src/test/incorrect/basicassign2/clang_no_plt_no_pic/basicassign2.expected b/src/test/incorrect/basicassign2/clang_no_plt_no_pic/basicassign2.expected index eac88ceeb..911ce67bd 100644 --- a/src/test/incorrect/basicassign2/clang_no_plt_no_pic/basicassign2.expected +++ b/src/test/incorrect/basicassign2/clang_no_plt_no_pic/basicassign2.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -82,7 +82,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -91,9 +91,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -190,24 +190,30 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 69632bv64, true; call rely(); R9, Gamma_R9 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R9), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R9); + assume {:captureState "%000008f8"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%000008ff"} true; R10, Gamma_R10 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R10), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R10); + assume {:captureState "%00000913"} true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 56bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%00000922"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); assert (L(mem, bvadd64(R9, 64bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R9, 64bv64), R8), gamma_store64(Gamma_mem, bvadd64(R9, 64bv64), Gamma_R8); + assume {:captureState "%00000931"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected b/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected index 1b5fddca4..bb901dc08 100644 --- a/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected +++ b/src/test/incorrect/basicassign2/clang_pic/basicassign2.expected @@ -1,47 +1,47 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69688bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69696bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -98,7 +98,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -107,9 +107,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -238,6 +238,7 @@ procedure main() free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 65536bv64, true; call rely(); @@ -245,7 +246,9 @@ procedure main() call rely(); R9, Gamma_R9 := memory_load64_le(mem, R8), (gamma_load64(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R9), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R9); + assume {:captureState "%0000030d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000314"} true; R10, Gamma_R10 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); R9, Gamma_R9 := 65536bv64, true; call rely(); @@ -253,13 +256,16 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R10); mem, Gamma_mem := memory_store64_le(mem, R9, R10), gamma_store64(Gamma_mem, R9, Gamma_R10); + assume {:captureState "%0000032f"} true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, R8), (gamma_load64(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000033e"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store64_le(mem, R9, R8), gamma_store64(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000034d"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign2/gcc/basicassign2.expected b/src/test/incorrect/basicassign2/gcc/basicassign2.expected index 1800cc14a..95f92fbdc 100644 --- a/src/test/incorrect/basicassign2/gcc/basicassign2.expected +++ b/src/test/incorrect/basicassign2/gcc/basicassign2.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -78,7 +78,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,9 +87,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -186,30 +186,36 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000031c"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000323"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000357"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000371"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected b/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected index 9162add37..2116e0774 100644 --- a/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected +++ b/src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected @@ -1,41 +1,41 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -76,7 +76,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -85,9 +85,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -182,6 +182,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 24bv64), Gamma_R1; R0, Gamma_R0 := 0bv64, true; @@ -190,5 +191,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 24bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store64_le(mem, bvadd64(R1, 24bv64), R2), gamma_store64(Gamma_mem, bvadd64(R1, 24bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; return; } diff --git a/src/test/incorrect/basicassign2/gcc_no_plt_no_pic/basicassign2.expected b/src/test/incorrect/basicassign2/gcc_no_plt_no_pic/basicassign2.expected index 1800cc14a..190af2f08 100644 --- a/src/test/incorrect/basicassign2/gcc_no_plt_no_pic/basicassign2.expected +++ b/src/test/incorrect/basicassign2/gcc_no_plt_no_pic/basicassign2.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -78,7 +78,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -87,9 +87,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -186,30 +186,36 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000095c"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000963"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000097d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 32bv64), Gamma_R0; call rely(); R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000997"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; R1, Gamma_R1 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000009b1"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected b/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected index d0af0ffe0..1c35793fc 100644 --- a/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected +++ b/src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected @@ -1,43 +1,43 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69664bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69656bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $z_addr) then true else (if (index == $secret_addr) then false else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -procedure rely(); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,7 +94,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,9 +103,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -234,6 +234,7 @@ procedure main() free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -241,7 +242,9 @@ procedure main() call rely(); R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), 0bv64), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), true); + assume {:captureState "%00000324"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -249,12 +252,14 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033f"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); R0, Gamma_R0 := memory_load64_le(mem, R0), (gamma_load64(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R0), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000035a"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -262,6 +267,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store64_le(mem, R0, R1), gamma_store64(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000375"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign3/clang/basicassign3.expected b/src/test/incorrect/basicassign3/clang/basicassign3.expected index 3fe3c6e69..75800d54a 100644 --- a/src/test/incorrect/basicassign3/clang/basicassign3.expected +++ b/src/test/incorrect/basicassign3/clang/basicassign3.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69681bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69682bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -187,24 +187,30 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 69632bv64, true; call rely(); R9, Gamma_R9 := zero_extend56_8(memory_load8_le(mem, bvadd64(R8, 49bv64))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R9[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R9); + assume {:captureState "%000002fe"} true; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000305"} true; R10, Gamma_R10 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R10[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R10); + assume {:captureState "%00000319"} true; call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, bvadd64(R8, 49bv64))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R8); + assume {:captureState "%00000328"} true; R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R8); + assume {:captureState "%00000337"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected b/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected index 0374fa6a8..96cc417da 100644 --- a/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected +++ b/src/test/incorrect/basicassign3/clang_O2/basicassign3.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69684bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69688bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -82,9 +82,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -179,6 +179,7 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R8, Gamma_R8 := 69632bv64, true; R9, Gamma_R9 := 69632bv64, true; R0, Gamma_R0 := 0bv64, true; @@ -187,5 +188,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R9, 56bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 56bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 56bv64), Gamma_R8); + assume {:captureState "%000002de"} true; return; } diff --git a/src/test/incorrect/basicassign3/clang_no_plt_no_pic/basicassign3.expected b/src/test/incorrect/basicassign3/clang_no_plt_no_pic/basicassign3.expected index 3fe3c6e69..75b959513 100644 --- a/src/test/incorrect/basicassign3/clang_no_plt_no_pic/basicassign3.expected +++ b/src/test/incorrect/basicassign3/clang_no_plt_no_pic/basicassign3.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69681bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69682bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -187,24 +187,30 @@ procedure main() free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 69632bv64, true; call rely(); R9, Gamma_R9 := zero_extend56_8(memory_load8_le(mem, bvadd64(R8, 49bv64))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R9[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R9); + assume {:captureState "%000008f8"} true; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%000008ff"} true; R10, Gamma_R10 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R9, Gamma_R9 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R10); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R10[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R10); + assume {:captureState "%00000913"} true; call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, bvadd64(R8, 49bv64))), (gamma_load8(Gamma_mem, bvadd64(R8, 49bv64)) || L(mem, bvadd64(R8, 49bv64))); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R8); + assume {:captureState "%00000922"} true; R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); assert (L(mem, bvadd64(R9, 50bv64)) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R9, 50bv64), R8[8:0]), gamma_store8(Gamma_mem, bvadd64(R9, 50bv64), Gamma_R8); + assume {:captureState "%00000931"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected b/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected index 44c4be020..7a4df88f4 100644 --- a/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected +++ b/src/test/incorrect/basicassign3/clang_pic/basicassign3.expected @@ -1,52 +1,52 @@ -var Gamma_R0: bool; -var Gamma_R10: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R10: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R10: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R10: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69681bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69682bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -103,7 +103,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -112,9 +112,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -243,6 +243,7 @@ procedure main() free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R8, Gamma_R8 := 65536bv64, true; call rely(); @@ -250,7 +251,9 @@ procedure main() call rely(); R9, Gamma_R9 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R9[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R9); + assume {:captureState "%0000030d"} true; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000314"} true; R10, Gamma_R10 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); R9, Gamma_R9 := 65536bv64, true; call rely(); @@ -258,13 +261,16 @@ procedure main() call rely(); assert (L(mem, R9) ==> Gamma_R10); mem, Gamma_mem := memory_store8_le(mem, R9, R10[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R10); + assume {:captureState "%0000032f"} true; call rely(); R8, Gamma_R8 := zero_extend56_8(memory_load8_le(mem, R8)), (gamma_load8(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R8[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R8); + assume {:captureState "%0000033e"} true; R8, Gamma_R8 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); assert (L(mem, R9) ==> Gamma_R8); mem, Gamma_mem := memory_store8_le(mem, R9, R8[8:0]), gamma_store8(Gamma_mem, R9, Gamma_R8); + assume {:captureState "%0000034d"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign3/gcc/basicassign3.expected b/src/test/incorrect/basicassign3/gcc/basicassign3.expected index 2f888eea0..a3c547bb3 100644 --- a/src/test/incorrect/basicassign3/gcc/basicassign3.expected +++ b/src/test/incorrect/basicassign3/gcc/basicassign3.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -84,9 +84,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -183,30 +183,36 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000031c"} true; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000323"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%00000357"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000371"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected b/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected index 0aca8c217..62c8377ad 100644 --- a/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected +++ b/src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected @@ -1,38 +1,38 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R2: bool; -var Gamma_mem: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R2: bv64; -var mem: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R2: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R2: bv64; +var {:extern} mem: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -73,7 +73,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -82,9 +82,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -179,6 +179,7 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R1, Gamma_R1 := 69632bv64, true; R2, Gamma_R2 := bvadd64(R1, 17bv64), Gamma_R1; R0, Gamma_R0 := 0bv64, true; @@ -187,5 +188,6 @@ procedure main() call rely(); assert (L(mem, bvadd64(R1, 17bv64)) ==> Gamma_R2); mem, Gamma_mem := memory_store8_le(mem, bvadd64(R1, 17bv64), R2[8:0]), gamma_store8(Gamma_mem, bvadd64(R1, 17bv64), Gamma_R2); + assume {:captureState "%000001c5"} true; return; } diff --git a/src/test/incorrect/basicassign3/gcc_no_plt_no_pic/basicassign3.expected b/src/test/incorrect/basicassign3/gcc_no_plt_no_pic/basicassign3.expected index 2f888eea0..ea6ea1a7b 100644 --- a/src/test/incorrect/basicassign3/gcc_no_plt_no_pic/basicassign3.expected +++ b/src/test/incorrect/basicassign3/gcc_no_plt_no_pic/basicassign3.expected @@ -1,40 +1,40 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -75,7 +75,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -84,9 +84,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -183,30 +183,36 @@ procedure main() free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000095c"} true; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000963"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000097d"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 18bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%00000997"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 17bv64), Gamma_R0; R1, Gamma_R1 := zero_extend56_8(memory_load8_le(stack, bvadd64(R31, 15bv64))), gamma_load8(Gamma_stack, bvadd64(R31, 15bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%000009b1"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected b/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected index bfac2a917..7e6204c20 100644 --- a/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected +++ b/src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -const $secret_addr: bv64; +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +const {:extern} $secret_addr: bv64; axiom ($secret_addr == 69650bv64); -const $z_addr: bv64; +const {:extern} $z_addr: bv64; axiom ($z_addr == 69649bv64); -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { (if (index == $secret_addr) then false else (if (index == $z_addr) then true else false)) } -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load8(gammaMap: [bv64]bool, index: bv64) returns (bool) { gammaMap[index] } -function gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store8(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value] } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { +function {:extern} memory_store8_le(memory: [bv64]bv8, index: bv64, value: bv8) returns ([bv64]bv8) { memory[index := value[8:0]] } -function {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "zero_extend 56"} zero_extend56_8(bv8) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -99,7 +99,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -108,9 +108,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -239,6 +239,7 @@ procedure main() free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); { lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; R0, Gamma_R0 := 65536bv64, true; call rely(); @@ -246,7 +247,9 @@ procedure main() call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000031d"} true; stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), 0bv8), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), true); + assume {:captureState "%00000324"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -254,12 +257,14 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000033f"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4072bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4072bv64)) || L(mem, bvadd64(R0, 4072bv64))); call rely(); R0, Gamma_R0 := zero_extend56_8(memory_load8_le(mem, R0)), (gamma_load8(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store8_le(stack, bvadd64(R31, 15bv64), R0[8:0]), gamma_store8(Gamma_stack, bvadd64(R31, 15bv64), Gamma_R0); + assume {:captureState "%0000035a"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); @@ -267,6 +272,7 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store8_le(mem, R0, R1[8:0]), gamma_store8(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000375"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/iflocal/clang/iflocal.expected b/src/test/incorrect/iflocal/clang/iflocal.expected index 14a976418..9be5ec85b 100644 --- a/src/test/incorrect/iflocal/clang/iflocal.expected +++ b/src/test/incorrect/iflocal/clang/iflocal.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,11 +197,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%000002f5"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%000002fd"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000030c"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -215,24 +219,31 @@ procedure main() } goto l00000337; l00000337: + assume {:captureState "l00000337"} true; R8, Gamma_R8 := 1bv64, true; goto l0000033a; l00000334: + assume {:captureState "l00000334"} true; R8, Gamma_R8 := 0bv64, true; goto l0000033a; l0000033a: + assume {:captureState "l0000033a"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000342; } goto l00000359; l00000359: + assume {:captureState "l00000359"} true; goto l0000035a; l0000035a: + assume {:captureState "l0000035a"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000368"} true; goto l00000342; l00000342: + assume {:captureState "l00000342"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/iflocal/clang_no_plt_no_pic/iflocal.expected b/src/test/incorrect/iflocal/clang_no_plt_no_pic/iflocal.expected index c1ec5bd48..8fa6934a5 100644 --- a/src/test/incorrect/iflocal/clang_no_plt_no_pic/iflocal.expected +++ b/src/test/incorrect/iflocal/clang_no_plt_no_pic/iflocal.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,11 +197,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000917"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000091f"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000092e"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -215,24 +219,31 @@ procedure main() } goto l00000959; l00000959: + assume {:captureState "l00000959"} true; R8, Gamma_R8 := 1bv64, true; goto l0000095c; l00000956: + assume {:captureState "l00000956"} true; R8, Gamma_R8 := 0bv64, true; goto l0000095c; l0000095c: + assume {:captureState "l0000095c"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000964; } goto l0000097b; l0000097b: + assume {:captureState "l0000097b"} true; goto l0000097c; l0000097c: + assume {:captureState "l0000097c"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000098a"} true; goto l00000964; l00000964: + assume {:captureState "l00000964"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/iflocal/clang_pic/iflocal.expected b/src/test/incorrect/iflocal/clang_pic/iflocal.expected index c1ec5bd48..8fa6934a5 100644 --- a/src/test/incorrect/iflocal/clang_pic/iflocal.expected +++ b/src/test/incorrect/iflocal/clang_pic/iflocal.expected @@ -1,44 +1,44 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -79,7 +79,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -88,9 +88,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -197,11 +197,15 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000917"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000091f"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000092e"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 0bv33))), (Gamma_R8 && Gamma_#4); @@ -215,24 +219,31 @@ procedure main() } goto l00000959; l00000959: + assume {:captureState "l00000959"} true; R8, Gamma_R8 := 1bv64, true; goto l0000095c; l00000956: + assume {:captureState "l00000956"} true; R8, Gamma_R8 := 0bv64, true; goto l0000095c; l0000095c: + assume {:captureState "l0000095c"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000964; } goto l0000097b; l0000097b: + assume {:captureState "l0000097b"} true; goto l0000097c; l0000097c: + assume {:captureState "l0000097c"} true; R8, Gamma_R8 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000098a"} true; goto l00000964; l00000964: + assume {:captureState "l00000964"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/iflocal/gcc/iflocal.expected b/src/test/incorrect/iflocal/gcc/iflocal.expected index 6571a03cf..a5b449c83 100644 --- a/src/test/incorrect/iflocal/gcc/iflocal.expected +++ b/src/test/incorrect/iflocal/gcc/iflocal.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -86,9 +86,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -195,10 +195,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000002e6"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000002f5"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -211,10 +214,13 @@ procedure main() } goto l0000032d; l0000032d: + assume {:captureState "l0000032d"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000338"} true; goto l00000318; l00000318: + assume {:captureState "l00000318"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/incorrect/iflocal/gcc_no_plt_no_pic/iflocal.expected b/src/test/incorrect/iflocal/gcc_no_plt_no_pic/iflocal.expected index 66efa5b8d..185882037 100644 --- a/src/test/incorrect/iflocal/gcc_no_plt_no_pic/iflocal.expected +++ b/src/test/incorrect/iflocal/gcc_no_plt_no_pic/iflocal.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -86,9 +86,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -195,10 +195,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000008cd"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000008dc"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -211,10 +214,13 @@ procedure main() } goto l00000914; l00000914: + assume {:captureState "l00000914"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000091f"} true; goto l000008ff; l000008ff: + assume {:captureState "l000008ff"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/incorrect/iflocal/gcc_pic/iflocal.expected b/src/test/incorrect/iflocal/gcc_pic/iflocal.expected index 66efa5b8d..185882037 100644 --- a/src/test/incorrect/iflocal/gcc_pic/iflocal.expected +++ b/src/test/incorrect/iflocal/gcc_pic/iflocal.expected @@ -1,42 +1,42 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -77,7 +77,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -86,9 +86,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -195,10 +195,13 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%000008cd"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%000008dc"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #4, Gamma_#4 := bvadd32(R0[32:0], 4294967295bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#4, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 0bv33))), (Gamma_R0 && Gamma_#4); @@ -211,10 +214,13 @@ procedure main() } goto l00000914; l00000914: + assume {:captureState "l00000914"} true; R0, Gamma_R0 := 1bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000091f"} true; goto l000008ff; l000008ff: + assume {:captureState "l000008ff"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected index 971a31859..a084acbaf 100644 --- a/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/clang/nestedifglobal.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,9 +94,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -207,15 +207,20 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000345"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%0000034d"} true; R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%00000361"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), true); + assume {:captureState "%00000368"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; @@ -230,24 +235,31 @@ procedure main() } goto l00000393; l00000393: + assume {:captureState "l00000393"} true; R8, Gamma_R8 := 1bv64, true; goto l00000396; l00000390: + assume {:captureState "l00000390"} true; R8, Gamma_R8 := 0bv64, true; goto l00000396; l00000396: + assume {:captureState "l00000396"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l0000039e; } goto l0000045d; l0000045d: + assume {:captureState "l0000045d"} true; goto l0000045e; l0000045e: + assume {:captureState "l0000045e"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%0000046c"} true; goto l0000039e; l0000039e: + assume {:captureState "l0000039e"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -263,24 +275,31 @@ procedure main() } goto l000003d1; l000003d1: + assume {:captureState "l000003d1"} true; R8, Gamma_R8 := 1bv64, true; goto l000003d4; l000003ce: + assume {:captureState "l000003ce"} true; R8, Gamma_R8 := 0bv64, true; goto l000003d4; l000003d4: + assume {:captureState "l000003d4"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000003dc; } goto l00000448; l00000448: + assume {:captureState "l00000448"} true; goto l00000449; l00000449: + assume {:captureState "l00000449"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000457"} true; goto l000003dc; l000003dc: + assume {:captureState "l000003dc"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #6, Gamma_#6 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#6); @@ -294,26 +313,33 @@ procedure main() } goto l0000040a; l0000040a: + assume {:captureState "l0000040a"} true; R8, Gamma_R8 := 1bv64, true; goto l0000040d; l00000407: + assume {:captureState "l00000407"} true; R8, Gamma_R8 := 0bv64, true; goto l0000040d; l0000040d: + assume {:captureState "l0000040d"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000415; } goto l0000042c; l0000042c: + assume {:captureState "l0000042c"} true; goto l0000042d; l0000042d: + assume {:captureState "l0000042d"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000442"} true; goto l00000415; l00000415: + assume {:captureState "l00000415"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/nestedifglobal/clang_no_plt_no_pic/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/clang_no_plt_no_pic/nestedifglobal.expected index 42fc63d91..ded3f676a 100644 --- a/src/test/incorrect/nestedifglobal/clang_no_plt_no_pic/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/clang_no_plt_no_pic/nestedifglobal.expected @@ -1,50 +1,50 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -85,7 +85,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69678bv64) == 0bv8); free ensures (memory_load8_le(mem, 69679bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -94,9 +94,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -207,15 +207,20 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551600bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), true); + assume {:captureState "%00000a95"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 8bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R0); + assume {:captureState "%00000a9d"} true; R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 8bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 8bv64)); R8, Gamma_R8 := 69632bv64, true; call rely(); assert (L(mem, bvadd64(R8, 52bv64)) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, bvadd64(R8, 52bv64), R9[32:0]), gamma_store32(Gamma_mem, bvadd64(R8, 52bv64), Gamma_R9); + assume {:captureState "%00000ab1"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), true); + assume {:captureState "%00000ab8"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; @@ -230,24 +235,31 @@ procedure main() } goto l00000ae3; l00000ae3: + assume {:captureState "l00000ae3"} true; R8, Gamma_R8 := 1bv64, true; goto l00000ae6; l00000ae0: + assume {:captureState "l00000ae0"} true; R8, Gamma_R8 := 0bv64, true; goto l00000ae6; l00000ae6: + assume {:captureState "l00000ae6"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000aee; } goto l00000bad; l00000bad: + assume {:captureState "l00000bad"} true; goto l00000bae; l00000bae: + assume {:captureState "l00000bae"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000bbc"} true; goto l00000aee; l00000aee: + assume {:captureState "l00000aee"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 52bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 52bv64)) || L(mem, bvadd64(R8, 52bv64))); @@ -263,24 +275,31 @@ procedure main() } goto l00000b21; l00000b21: + assume {:captureState "l00000b21"} true; R8, Gamma_R8 := 1bv64, true; goto l00000b24; l00000b1e: + assume {:captureState "l00000b1e"} true; R8, Gamma_R8 := 0bv64, true; goto l00000b24; l00000b24: + assume {:captureState "l00000b24"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000b2c; } goto l00000b98; l00000b98: + assume {:captureState "l00000b98"} true; goto l00000b99; l00000b99: + assume {:captureState "l00000b99"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000ba7"} true; goto l00000b2c; l00000b2c: + assume {:captureState "l00000b2c"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 4bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 4bv64)); #6, Gamma_#6 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#6); @@ -294,26 +313,33 @@ procedure main() } goto l00000b5a; l00000b5a: + assume {:captureState "l00000b5a"} true; R8, Gamma_R8 := 1bv64, true; goto l00000b5d; l00000b57: + assume {:captureState "l00000b57"} true; R8, Gamma_R8 := 0bv64, true; goto l00000b5d; l00000b5d: + assume {:captureState "l00000b5d"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000b65; } goto l00000b7c; l00000b7c: + assume {:captureState "l00000b7c"} true; goto l00000b7d; l00000b7d: + assume {:captureState "l00000b7d"} true; R8, Gamma_R8 := 69632bv64, true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, bvadd64(R8, 56bv64))), (gamma_load32(Gamma_mem, bvadd64(R8, 56bv64)) || L(mem, bvadd64(R8, 56bv64))); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 4bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 4bv64), Gamma_R8); + assume {:captureState "%00000b92"} true; goto l00000b65; l00000b65: + assume {:captureState "l00000b65"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); R31, Gamma_R31 := bvadd64(R31, 16bv64), Gamma_R31; return; diff --git a/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected index b789075b8..a333a5bcf 100644 --- a/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/clang_pic/nestedifglobal.expected @@ -1,66 +1,66 @@ -var Gamma_R0: bool; -var Gamma_R31: bool; -var Gamma_R8: bool; -var Gamma_R9: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R31: bv64; -var R8: bv64; -var R9: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_R8: bool; +var {:extern} Gamma_R9: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R31: bv64; +var {:extern} R8: bv64; +var {:extern} R9: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store64(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value][bvadd64(index, 4bv64) := value][bvadd64(index, 5bv64) := value][bvadd64(index, 6bv64) := value][bvadd64(index, 7bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { +function {:extern} memory_store64_le(memory: [bv64]bv8, index: bv64, value: bv64) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]][bvadd64(index, 4bv64) := value[40:32]][bvadd64(index, 5bv64) := value[48:40]][bvadd64(index, 6bv64) := value[56:48]][bvadd64(index, 7bv64) := value[64:56]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -117,7 +117,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69062bv64) == 0bv8); free ensures (memory_load8_le(mem, 69063bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -126,9 +126,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -271,18 +271,24 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4040bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4040bv64)) || L(mem, bvadd64(R8, 4040bv64))); stack, Gamma_stack := memory_store64_le(stack, bvadd64(R31, 8bv64), R8), gamma_store64(Gamma_stack, bvadd64(R31, 8bv64), Gamma_R8); + assume {:captureState "%0000035e"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000365"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 24bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 24bv64), Gamma_R0); + assume {:captureState "%0000036d"} true; R9, Gamma_R9 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 24bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 24bv64)); call rely(); assert (L(mem, R8) ==> Gamma_R9); mem, Gamma_mem := memory_store32_le(mem, R8, R9[32:0]), gamma_store32(Gamma_mem, R8, Gamma_R9); + assume {:captureState "%0000037c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), true); + assume {:captureState "%00000383"} true; call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); #4, Gamma_#4 := bvadd32(R8[32:0], 4294967295bv32), Gamma_R8; @@ -297,24 +303,31 @@ procedure main() } goto l000003ae; l000003ae: + assume {:captureState "l000003ae"} true; R8, Gamma_R8 := 1bv64, true; goto l000003b1; l000003ab: + assume {:captureState "l000003ab"} true; R8, Gamma_R8 := 0bv64, true; goto l000003b1; l000003b1: + assume {:captureState "l000003b1"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000003b9; } goto l00000481; l00000481: + assume {:captureState "l00000481"} true; goto l00000482; l00000482: + assume {:captureState "l00000482"} true; R8, Gamma_R8 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%00000490"} true; goto l000003b9; l000003b9: + assume {:captureState "l000003b9"} true; R8, Gamma_R8 := memory_load64_le(stack, bvadd64(R31, 8bv64)), gamma_load64(Gamma_stack, bvadd64(R31, 8bv64)); call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); @@ -330,24 +343,31 @@ procedure main() } goto l000003ee; l000003ee: + assume {:captureState "l000003ee"} true; R8, Gamma_R8 := 1bv64, true; goto l000003f1; l000003eb: + assume {:captureState "l000003eb"} true; R8, Gamma_R8 := 0bv64, true; goto l000003f1; l000003f1: + assume {:captureState "l000003f1"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l000003f9; } goto l0000046c; l0000046c: + assume {:captureState "l0000046c"} true; goto l0000046d; l0000046d: + assume {:captureState "l0000046d"} true; R8, Gamma_R8 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%0000047b"} true; goto l000003f9; l000003f9: + assume {:captureState "l000003f9"} true; R8, Gamma_R8 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 20bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 20bv64)); #6, Gamma_#6 := bvadd32(R8[32:0], 4294967292bv32), Gamma_R8; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R8[32:0]), 8589934589bv33))), (Gamma_R8 && Gamma_#6); @@ -361,28 +381,35 @@ procedure main() } goto l00000427; l00000427: + assume {:captureState "l00000427"} true; R8, Gamma_R8 := 1bv64, true; goto l0000042a; l00000424: + assume {:captureState "l00000424"} true; R8, Gamma_R8 := 0bv64, true; goto l0000042a; l0000042a: + assume {:captureState "l0000042a"} true; assert Gamma_R8; if ((bvcomp1(R8[1:0], 1bv1) != 0bv1)) { goto l00000432; } goto l00000449; l00000449: + assume {:captureState "l00000449"} true; goto l0000044a; l0000044a: + assume {:captureState "l0000044a"} true; R8, Gamma_R8 := 65536bv64, true; call rely(); R8, Gamma_R8 := memory_load64_le(mem, bvadd64(R8, 4032bv64)), (gamma_load64(Gamma_mem, bvadd64(R8, 4032bv64)) || L(mem, bvadd64(R8, 4032bv64))); call rely(); R8, Gamma_R8 := zero_extend32_32(memory_load32_le(mem, R8)), (gamma_load32(Gamma_mem, R8) || L(mem, R8)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 20bv64), R8[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 20bv64), Gamma_R8); + assume {:captureState "%00000466"} true; goto l00000432; l00000432: + assume {:captureState "l00000432"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected index 843c7dc3c..8fd6d9f25 100644 --- a/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/gcc/nestedifglobal.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,9 +92,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -205,15 +205,19 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000332"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000034c"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000353"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -229,10 +233,13 @@ procedure main() } goto l00000414; l00000414: + assume {:captureState "l00000414"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%0000041f"} true; goto l00000381; l00000381: + assume {:captureState "l00000381"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -248,10 +255,13 @@ procedure main() } goto l00000407; l00000407: + assume {:captureState "l00000407"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000412"} true; goto l000003b2; l000003b2: + assume {:captureState "l000003b2"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#6); @@ -264,13 +274,16 @@ procedure main() } goto l000003ed; l000003ed: + assume {:captureState "l000003ed"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000405"} true; goto l000003d8; l000003d8: + assume {:captureState "l000003d8"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/incorrect/nestedifglobal/gcc_no_plt_no_pic/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/gcc_no_plt_no_pic/nestedifglobal.expected index 4e681cfe8..f53463dad 100644 --- a/src/test/incorrect/nestedifglobal/gcc_no_plt_no_pic/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/gcc_no_plt_no_pic/nestedifglobal.expected @@ -1,48 +1,48 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -83,7 +83,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69646bv64) == 0bv8); free ensures (memory_load8_le(mem, 69647bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -92,9 +92,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -205,15 +205,19 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000a2a"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; R1, Gamma_R1 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 12bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 12bv64)); call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%00000a44"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000a4b"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -229,10 +233,13 @@ procedure main() } goto l00000b0c; l00000b0c: + assume {:captureState "l00000b0c"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000b17"} true; goto l00000a79; l00000a79: + assume {:captureState "l00000a79"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 20bv64), Gamma_R0; call rely(); @@ -248,10 +255,13 @@ procedure main() } goto l00000aff; l00000aff: + assume {:captureState "l00000aff"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000b0a"} true; goto l00000aaa; l00000aaa: + assume {:captureState "l00000aaa"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#6); @@ -264,13 +274,16 @@ procedure main() } goto l00000ae5; l00000ae5: + assume {:captureState "l00000ae5"} true; R0, Gamma_R0 := 69632bv64, true; R0, Gamma_R0 := bvadd64(R0, 24bv64), Gamma_R0; call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000afd"} true; goto l00000ad0; l00000ad0: + assume {:captureState "l00000ad0"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return; diff --git a/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected b/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected index 11d772e99..33b87b289 100644 --- a/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected +++ b/src/test/incorrect/nestedifglobal/gcc_pic/nestedifglobal.expected @@ -1,56 +1,56 @@ -var Gamma_R0: bool; -var Gamma_R1: bool; -var Gamma_R31: bool; -var Gamma_mem: [bv64]bool; -var Gamma_stack: [bv64]bool; -var R0: bv64; -var R1: bv64; -var R31: bv64; -var mem: [bv64]bv8; -var stack: [bv64]bv8; -function L(memory: [bv64]bv8, index: bv64) returns (bool) { +var {:extern} Gamma_R0: bool; +var {:extern} Gamma_R1: bool; +var {:extern} Gamma_R31: bool; +var {:extern} Gamma_mem: [bv64]bool; +var {:extern} Gamma_stack: [bv64]bool; +var {:extern} R0: bv64; +var {:extern} R1: bv64; +var {:extern} R31: bv64; +var {:extern} mem: [bv64]bv8; +var {:extern} stack: [bv64]bv8; +function {:extern} L(memory: [bv64]bv8, index: bv64) returns (bool) { false } -function {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); -function {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); -function {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); -function {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); -function {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); -function {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); -function gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} {:bvbuiltin "bvadd"} bvadd32(bv32, bv32) returns (bv32); +function {:extern} {:bvbuiltin "bvadd"} bvadd33(bv33, bv33) returns (bv33); +function {:extern} {:bvbuiltin "bvadd"} bvadd64(bv64, bv64) returns (bv64); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp1(bv1, bv1) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp32(bv32, bv32) returns (bv1); +function {:extern} {:bvbuiltin "bvcomp"} bvcomp33(bv33, bv33) returns (bv1); +function {:extern} {:bvbuiltin "bvnot"} bvnot1(bv1) returns (bv1); +function {:extern} gamma_load32(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))) } -function gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { +function {:extern} gamma_load64(gammaMap: [bv64]bool, index: bv64) returns (bool) { (gammaMap[bvadd64(index, 7bv64)] && (gammaMap[bvadd64(index, 6bv64)] && (gammaMap[bvadd64(index, 5bv64)] && (gammaMap[bvadd64(index, 4bv64)] && (gammaMap[bvadd64(index, 3bv64)] && (gammaMap[bvadd64(index, 2bv64)] && (gammaMap[bvadd64(index, 1bv64)] && gammaMap[index]))))))) } -function gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { +function {:extern} gamma_store32(gammaMap: [bv64]bool, index: bv64, value: bool) returns ([bv64]bool) { gammaMap[index := value][bvadd64(index, 1bv64) := value][bvadd64(index, 2bv64) := value][bvadd64(index, 3bv64) := value] } -function memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { +function {:extern} memory_load32_le(memory: [bv64]bv8, index: bv64) returns (bv32) { (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))) } -function memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { +function {:extern} memory_load64_le(memory: [bv64]bv8, index: bv64) returns (bv64) { (memory[bvadd64(index, 7bv64)] ++ (memory[bvadd64(index, 6bv64)] ++ (memory[bvadd64(index, 5bv64)] ++ (memory[bvadd64(index, 4bv64)] ++ (memory[bvadd64(index, 3bv64)] ++ (memory[bvadd64(index, 2bv64)] ++ (memory[bvadd64(index, 1bv64)] ++ memory[index]))))))) } -function memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { +function {:extern} memory_load8_le(memory: [bv64]bv8, index: bv64) returns (bv8) { memory[index] } -function memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { +function {:extern} memory_store32_le(memory: [bv64]bv8, index: bv64, value: bv32) returns ([bv64]bv8) { memory[index := value[8:0]][bvadd64(index, 1bv64) := value[16:8]][bvadd64(index, 2bv64) := value[24:16]][bvadd64(index, 3bv64) := value[32:24]] } -function {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); -function {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); -procedure rely(); +function {:extern} {:bvbuiltin "sign_extend 1"} sign_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 1"} zero_extend1_32(bv32) returns (bv33); +function {:extern} {:bvbuiltin "zero_extend 32"} zero_extend32_32(bv32) returns (bv64); +procedure {:extern} rely(); modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -107,7 +107,7 @@ procedure rely(); free ensures (memory_load8_le(mem, 69006bv64) == 0bv8); free ensures (memory_load8_le(mem, 69007bv64) == 0bv8); -procedure rely_transitive() +procedure {:extern} rely_transitive() modifies Gamma_mem, mem; ensures (mem == old(mem)); ensures (Gamma_mem == old(Gamma_mem)); @@ -116,9 +116,9 @@ procedure rely_transitive() call rely(); } -procedure rely_reflexive(); +procedure {:extern} rely_reflexive(); -procedure guarantee_reflexive(); +procedure {:extern} guarantee_reflexive(); modifies Gamma_mem, mem; procedure main() @@ -261,8 +261,10 @@ procedure main() var VF: bv1; var ZF: bv1; lmain: + assume {:captureState "lmain"} true; R31, Gamma_R31 := bvadd64(R31, 18446744073709551584bv64), Gamma_R31; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 12bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 12bv64), Gamma_R0); + assume {:captureState "%00000332"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -270,7 +272,9 @@ procedure main() call rely(); assert (L(mem, R0) ==> Gamma_R1); mem, Gamma_mem := memory_store32_le(mem, R0, R1[32:0]), gamma_store32(Gamma_mem, R0, Gamma_R1); + assume {:captureState "%0000034d"} true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), 0bv32), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), true); + assume {:captureState "%00000354"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -287,10 +291,13 @@ procedure main() } goto l00000418; l00000418: + assume {:captureState "l00000418"} true; R0, Gamma_R0 := 3bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000423"} true; goto l00000383; l00000383: + assume {:captureState "l00000383"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4064bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4064bv64)) || L(mem, bvadd64(R0, 4064bv64))); @@ -307,10 +314,13 @@ procedure main() } goto l0000040b; l0000040b: + assume {:captureState "l0000040b"} true; R0, Gamma_R0 := 5bv64, true; stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000416"} true; goto l000003b5; l000003b5: + assume {:captureState "l000003b5"} true; R0, Gamma_R0 := zero_extend32_32(memory_load32_le(stack, bvadd64(R31, 28bv64))), gamma_load32(Gamma_stack, bvadd64(R31, 28bv64)); #6, Gamma_#6 := bvadd32(R0[32:0], 4294967292bv32), Gamma_R0; VF, Gamma_VF := bvnot1(bvcomp33(sign_extend1_32(bvadd32(#6, 1bv32)), bvadd33(sign_extend1_32(R0[32:0]), 8589934589bv33))), (Gamma_R0 && Gamma_#6); @@ -323,14 +333,17 @@ procedure main() } goto l000003f0; l000003f0: + assume {:captureState "l000003f0"} true; R0, Gamma_R0 := 65536bv64, true; call rely(); R0, Gamma_R0 := memory_load64_le(mem, bvadd64(R0, 4056bv64)), (gamma_load64(Gamma_mem, bvadd64(R0, 4056bv64)) || L(mem, bvadd64(R0, 4056bv64))); call rely(); R0, Gamma_R0 := zero_extend32_32(memory_load32_le(mem, R0)), (gamma_load32(Gamma_mem, R0) || L(mem, R0)); stack, Gamma_stack := memory_store32_le(stack, bvadd64(R31, 28bv64), R0[32:0]), gamma_store32(Gamma_stack, bvadd64(R31, 28bv64), Gamma_R0); + assume {:captureState "%00000409"} true; goto l000003db; l000003db: + assume {:captureState "l000003db"} true; R0, Gamma_R0 := 0bv64, true; R31, Gamma_R31 := bvadd64(R31, 32bv64), Gamma_R31; return;