Two systems that were actually done
Verification is easy to discuss in the abstract and easy to dismiss as impractical. Two projects settle the question of feasibility, because both produced machine-checked proofs about code that runs.
CompCert is a formally verified optimising C compiler, described by Xavier Leroy in "Formal verification of a realistic compiler", Communications of the ACM, volume 52, issue 7, 2009, pages 107 to 115. Its theorem is a semantic preservation result: the generated assembly behaves as the source C program's semantics specify.
seL4 is a formally verified operating system microkernel, presented by Gerwin Klein and colleagues at SOSP in 2009. Its theorem is functional correctness: the C implementation refines an abstract specification.
Both are real. CompCert compiles real C and is used where compiler-introduced bugs are unacceptable. seL4 is a working microkernel.
So the question is not whether this is possible. It is what it costs, and both projects published enough to answer that precisely.

