public override IVerbWorker getWorker() { if (verificationRequest.isComplete()) { VerificationResult vr = VerificationResult.fromXmlFile(batchSummaryVerb.getOutputFile().getRelativePath()); if (!vr.pass) { Util.Assert(false); //- Should never get here, since Ironclad app should fail before producing a verified exe return(new VerbSyncWorker(new Failed())); } } //- Copy the AppLoader binary and the bootloader into the same directory as the app's binary, so the pxe-loader can find them File.Copy(loaderVerb.getExe().getFilesystemPath(), loaderCopy.getFilesystemPath(), true); File.Copy(appVerb.getExe().getFilesystemPath(), appExecutableCopy.getFilesystemPath(), true); File.Copy(bootloader.getFilesystemPath(), bootloaderCopy.getFilesystemPath(), true); writeBootFile(); return(new VerbSyncWorker(new Fresh())); }
public override IVerbWorker getWorker() { if (verificationRequest.isComplete()) { //- If the verification succeeded, then we convert the untrusted exe into a trusted exe (via a copy) VerificationResult vr = VerificationResult.fromXmlFile(verifyResultsVerb.getOutputFile().getFilesystemPath()); if (!vr.pass) { return(new VerbSyncWorker(new Failed())); } File.Copy(srcObject.getFilesystemPath(), outputObject.getFilesystemPath(), true); //- True => Overwrite } else { UnverifiedSentinelVirtualContents contents = new UnverifiedSentinelVirtualContents(); BuildEngine.theEngine.getNuObjContents().storeVirtual(outputObject, new Fresh(), contents); } return(new VerbSyncWorker(new Fresh())); }
public IroncladAppVerb(SourcePath dfyroot, TARGET target, DafnyCCVerb.FramePointerMode framePointerMode, VerificationRequest verificationRequest) { this.dfyroot = dfyroot; // TODO this is the only #define we support just yet, so I'm stuffing it in here. // We'll need to plumb more carefully when we want to add x64. if (dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last().Equals("AppLoader")) { this.poundDefines = new PoundDefines(new string[] { "AppLoader" }); } else { this.poundDefines = PoundDefines.empty(); } this.verificationRequest = verificationRequest; this.abstractId = new AbstractId( this.GetType().Name, version, dfyroot.ToString(), this.poundDefines, concrete: string.Format( "{0},{1},{2}", target, framePointerMode.ToString(), verificationRequest.ToString())); this.appLabel = dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last(); this.dafnyspecVerb = new DafnySpecVerb(dfyroot, this.appLabel); this.dafnyccVerb = new DafnyCCVerb(dfyroot, this.appLabel, framePointerMode); bool isLoader = dfyroot.getRelativePath().Equals(BootableAppVerb.LOADER_DFY); // NB we keep dafnyccVerb as the lowest-priority context, so that our hand-written // beat impls will override its output. IContextGeneratingVerb contextWithDafny = new ConcatContextVerb( BuildEngine.theEngine.getVerveContextVerb(this.poundDefines), new VerbOutputsContextVerb(this.dafnyspecVerb, false), new VerbOutputsContextVerb(this.dafnyccVerb, true), this.poundDefines); this.stitcherVerb = new EntryStitcherVerb(contextWithDafny, this.appLabel); IContextGeneratingVerb contextWithDafnyAndEntry = new ConcatContextVerb( new VerbOutputsContextVerb(this.stitcherVerb, false), contextWithDafny, this.poundDefines); BuildObject entryImpObj = this.stitcherVerb.getEntryImpOutput(); BoogieAsmLinkVerb entryVerb = new BoogieAsmLinkVerb(contextWithDafnyAndEntry, entryImpObj); if (target == TARGET.BARE_METAL) { MasmVerb masmVerb = new MasmVerb(entryVerb); this.linkerVerb = new LinkerVerb(masmVerb, isLoader); } else if (target == TARGET.WINDOWS) { // Rewrite the asm that comes out of entryVerb before linking it AsmRewriterVerb rewriter = new AsmRewriterVerb(entryVerb); MasmVerb masmVerb = new MasmVerb(rewriter); this.linkerVerb = new WinLinkerVerb(masmVerb, isLoader); } BoogieAsmVerificationObligationListVerb bavolVerb = new BoogieAsmVerificationObligationListVerb(contextWithDafnyAndEntry, entryImpObj, verificationRequest); this.verifyResultsVerb = new VerificationResultSummaryVerb(bavolVerb); this.srcObject = this.linkerVerb.getUntrustedExe(); if (verificationRequest.isComplete()) { this.exeObject = dfyroot.makeOutputObject(TRUSTED_EXE_EXTN); this.outputObject = this.exeObject; } else { this.exeObject = this.srcObject; this.outputObject = dfyroot.makeVirtualObject(UNVERIFIED_SENTINEL_EXTENSION); } }
public IroncladAppVerb(SourcePath dfyroot, TARGET target, DafnyCCVerb.FramePointerMode framePointerMode, VerificationRequest verificationRequest) { this.dfyroot = dfyroot; // TODO this is the only #define we support just yet, so I'm stuffing it in here. // We'll need to plumb more carefully when we want to add x64. if (dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last().Equals("AppLoader")) { this.poundDefines = new PoundDefines(new string[] { "AppLoader" }); } else { this.poundDefines = PoundDefines.empty(); } this.verificationRequest = verificationRequest; this.abstractId = new AbstractId( this.GetType().Name, version, dfyroot.ToString(), this.poundDefines, concrete: string.Format( "{0},{1},{2}", target, framePointerMode.ToString(), verificationRequest.ToString())); this.appLabel = dfyroot.getDirPath().Split(Path.DirectorySeparatorChar).Last(); this.dafnyspecVerb = new DafnySpecVerb(dfyroot, this.appLabel); this.dafnyccVerb = new DafnyCCVerb(dfyroot, this.appLabel, framePointerMode); bool isLoader = dfyroot.getRelativePath().Equals(BootableAppVerb.LOADER_DFY); // NB we keep dafnyccVerb as the lowest-priority context, so that our hand-written // beat impls will override its output. IContextGeneratingVerb contextWithDafny = new ConcatContextVerb( BuildEngine.theEngine.getVerveContextVerb(this.poundDefines), new VerbOutputsContextVerb(this.dafnyspecVerb, false), new VerbOutputsContextVerb(this.dafnyccVerb, true), this.poundDefines); this.stitcherVerb = new EntryStitcherVerb(contextWithDafny, this.appLabel); IContextGeneratingVerb contextWithDafnyAndEntry = new ConcatContextVerb( new VerbOutputsContextVerb(this.stitcherVerb, false), contextWithDafny, this.poundDefines); BuildObject entryImpObj = this.stitcherVerb.getEntryImpOutput(); BoogieAsmLinkVerb entryVerb = new BoogieAsmLinkVerb(contextWithDafnyAndEntry, entryImpObj); if (target == TARGET.BARE_METAL) { MasmVerb masmVerb = new MasmVerb(entryVerb); this.linkerVerb = new LinkerVerb(masmVerb, isLoader); } else if (target == TARGET.WINDOWS) { // Rewrite the asm that comes out of entryVerb before linking it AsmRewriterVerb rewriter = new AsmRewriterVerb(entryVerb); MasmVerb masmVerb = new MasmVerb(rewriter); this.linkerVerb = new WinLinkerVerb(masmVerb, isLoader); } BoogieAsmVerificationObligationListVerb bavolVerb = new BoogieAsmVerificationObligationListVerb(contextWithDafnyAndEntry, entryImpObj, verificationRequest); this.verifyResultsVerb = new VerificationResultSummaryVerb(bavolVerb); this.srcObject = this.linkerVerb.getUntrustedExe(); if (verificationRequest.isComplete()) { this.exeObject = dfyroot.makeOutputObject(TRUSTED_EXE_EXTN); this.outputObject = this.exeObject; } else { this.exeObject = this.srcObject; this.outputObject = dfyroot.makeVirtualObject(UNVERIFIED_SENTINEL_EXTENSION); } }