Abstract
We present CompCertELF, the first extension to CompCert that supports verified compilation from C programs all the way to a standard binary file format, i.e., the ELF object format. Previous work on Stack-Aware CompCert provides a verified compilation chain from C programs to assembly programs with a realistic machine memory model. We build CompCertELF by modifying and extending this compilation chain with a verified assembler which further transforms assembly programs into ELF object files.
CompCert supports large-scale verification via verified separate compilation: C modules can be written and compiled separately, and then linked together to get a target program that refines the semantics of the program linked from the source modules. However, verified separate compilation in CompCert only works for compilation to assembly programs, not to object files. For the latter, the main difficulty is to bridge the two different views of linking: one for CompCert's programs that allows arbitrary shuffling of global definitions by linking and the other for object files that treats blocks of encoded definitions as indivisible units.
We propose a lightweight approach that solves the above problem without any modification to CompCert's framework for verified separate compilation: by introducing a notion of syntactical equivalence between programs and proving the commutativity between syntactical equivalence and the two different kinds of linking, we are able to transit from the more abstract linking operation in CompCert to the more concrete one for ELF object files. By applying this approach to CompCertELF, we obtain the first compiler that supports verified separate compilation of C programs into ELF object files.
Supplemental Material
- Roberto M. Amadio, Nicolas Ayache, Francois Bobot, Jaap P. Boender, Brian Campbell, Ilias Garnier, Antoine Madet, James McKinna, Dominic P. Mulligan, Mauro Piccolo, Randy Pollack, Yann Régis-Gianas, Claudio Sacerdoti Coen, Ian Stark, and Paolo Tranquilli. 2014. Certified Complexity (CerCo). In Foundational and Practical Aspects of Resource Analysis, Ugo Dal Lago and Ricardo Peña (Eds.). Springer International Publishing, Cham, 1-18. https://doi.org/10.1007/978-3-319-12466-7_1 Google Scholar
Cross Ref
- Andrew Appel. 2011. Verified Software Toolchain. In Proc. 20th European Symposium on Programming (ESOP'11), Gilles Barthe (Ed.). LNCS, Vol. 6602. Springer, Saarbrucken, Germany, 1-17. https://doi.org/10.1007/978-3-642-19718-5_1 Google Scholar
Cross Ref
- Andrew W Appel, Lennart Beringer, Adam Chlipala, Benjamin C Pierce, Zhong Shao, Stephanie Weirich, and Steve Zdancewic. 2017. Position Paper: the Science of Deep Specification. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences 375, 2104 ( 2017 ), 20160331. https://doi.org/10.1098/rsta. 2016.0331 Google Scholar
Cross Ref
- Frédéric Besson, Sandrine Blazy, and Pierre Wilke. 2017. CompCertS: A Memory-Aware Verified C Compiler Using Pointer as Integer Semantics. In Interactive Theorem Proving (ITP'17), Mauricio Ayala-Rincón and César A. Muñoz (Eds.). Springer International Publishing, Cham, 81-97. https://doi.org/10.1007/978-3-319-66107-0_6 Google Scholar
Cross Ref
- Ronghui Gu, Jeremie Koenig, Tahina Ramananandro, Zhong Shao, Xiongnan(Newman) Wu, Shu-Chun Weng, Haozhong Zhang, and Yu Guo. 2015. Deep Specifications and Certified Abstraction Layers. In Proc. 42nd ACM Symposium on Principles of Programming Languages (POPL'15). ACM, New York, 595-608. https://doi.org/10.1145/2775051.2676975 Google Scholar
Digital Library
- Ronghui Gu, Zhong Shao, Hao Chen, Xiongnan (Newman) Wu, Jieung Kim, Vilhelm Sjöberg, and David Costanzo. 2016. CertiKOS: An Extensible Architecture for Building Certified Concurrent OS Kernels. In Proc. 12th USENIX Symposium on Operating Systems Design and Implementation (OSDI'16). USENIX Association, GA, 653-669.Google Scholar
Digital Library
- Ronghui Gu, Zhong Shao, Jieung Kim, Xiongnan (Newman) Wu, Jeremie Koenig, Vilhelm Sjober, Hao Chen, David Costanzo, and Tahnia Ramananandro. 2018. Certified Concurrent Abstraction Layers. In Proc. 2018 ACM Conference on Programming Language Design and Implementation (PLDI'18). ACM, New York, 646-661. https://doi.org/10.1145/3192366.3192381 Google Scholar
Digital Library
- Hanru Jiang, Hongjin Liang, Siyang Xiao, Junpeng Zha, and Xinyu Feng. 2019. Towards Certified Separate Compilation for Concurrent Programs. In Proc. 40th ACM Conference on Programming Language Design and Implementation (PLDI'19). ACM, New York, NY, USA, 111-125. https://doi.org/10.1145/3314221.3314595 Google Scholar
Digital Library
- Jeehoon Kang, Yoonseung Kim, Chung-Kil Hur, Derek Dreyer, and Viktor Vafeiadis. 2016. Lightweight Verification of Separate Compilation. In Proc. 43rd ACM Symposium on Principles of Programming Languages (POPL'16). ACM, New York, 178-190. https://doi.org/10.1145/2837614.2837642 Google Scholar
Digital Library
- Stephen Kell, Dominic P. Mulligan, and Peter Sewell. 2016. The Missing Link: Explaining ELF Static Linking, Semantically. In Proc. 2016 ACM International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'16). ACM, New York, NY, USA, 607-623. https://doi.org/10.1145/3022671.2983996 Google Scholar
Digital Library
- Ramana Kumar, Magnus O. Myreen, Michael Norrish, and Scott Owens. 2014. CakeML: A Verified Implementation of ML. In Proc. 41st ACM Symposium on Principles of Programming Languages (POPL'14). ACM, New York, NY, USA, 179-191. https://doi.org/10.1145/2535838.2535841 Google Scholar
Digital Library
- Xavier Leroy. 2005-2020. The CompCert Verified Compiler. http://compcert.inria.fr/.Google Scholar
- Xavier Leroy. 2009a. Formal Verification of a Realistic Compiler. Commun. ACM 52, 7 ( 2009 ), 107-115. https://doi.org/10. 1145/1538788.1538814 Google Scholar
Digital Library
- Xavier Leroy. 2009b. A Formally Verified Compiler Back-end. Journal of Automated Reasoning 43, 4 ( 2009 ), 363-446. https://doi.org/10.1007/s10817-009-9155-4 Google Scholar
Digital Library
- Xavier Leroy, Andrew W. Appel, Sandrine Blazy, and Gordon Stewart. 2012. The CompCert Memory Model, Version 2. Research Report RR-7987. INRIA. 26 pages. https://hal.inria.fr/hal-00703441Google Scholar
- Xavier Leroy and Sandrine Blazy. 2008. Formal Verification of a C-like Memory Model and Its Uses for Verifying Program Transformation. Journal of Automated Reasoning 41, 1 ( 2008 ), 1-31. https://doi.org/10.1007/s10817-008-9099-0 Google Scholar
Digital Library
- Andreas Lööw, Ramana Kumar, Yong Kiam Tan, Magnus O. Myreen, Michael Norrish, Oskar Abrahamsson, and Anthony Fox. 2019. Verified Compilation on a Verified Processor. In Proc. the 40th ACM Conference on Programming Language Design and Implementation (PLDI'19). ACM, New York, NY, USA, 1041-1053. https://doi.org/10.1145/3314221.3314622 Google Scholar
Digital Library
- Greg Morrisett, Gang Tan, Joseph Tassarotti, Jean-Baptiste Tristan, and Edward Gan. 2012. RockSalt: Better, Faster, Stronger SFI for the x86. In Proc. 2012 ACM Conference on Programming Language Design and Implementation (PLDI'12). ACM, New York, NY, USA, 395-404. https://doi.org/10.1145/2254064.2254111 Google Scholar
Digital Library
- Eric Mullen, Daryl Zuniga, Zachary Tatlock, and Dan Grossman. 2016. Verified Peephole Optimizations for CompCert. In Proc. 37th ACM Conference on Programming Language Design and Implementation (PLDI'16). ACM, New York, NY, USA, 448-461. https://doi.org/10.1145/2980983.2908109 Google Scholar
Digital Library
- Jaroslav Sevcík, Viktor Vafeiadis, Francesco Zappa Nardelli, Suresh Jagannathan, and Peter Sewell. 2011. Relaxed-Memory Concurrency and Verified Compilation. In Proc. 38th ACM Symposium on Principles of Programming Languages (POPL'11). ACM, New York, 43-54. https://doi.org/10.1145/1926385.1926393 Google Scholar
Digital Library
- Jaroslav Sevcík, Viktor Vafeiadis, Francesco Zappa Nardelli, Suresh Jagannathan, and Peter Sewell. 2013. CompCertTSO: A Verified Compiler for Relaxed-Memory Concurrency. J. ACM 60, 3 ( 2013 ), 22 : 1-22 : 50. https://doi.org/10.1145/2487241. 2487248 Google Scholar
Digital Library
- Youngju Song, Minki Cho, Dongjoo Kim, Yonghyun Kim, Jeehoon Kang, and Chung-Kil Hur. 2020. CompCertM: CompCert with C-Assembly Linking and Lightweight Modular Verification. Proc. ACM Program. Lang. 4, POPL, Article 23 ( Jan. 2020 ), 31 pages. https://doi.org/10.1145/3371091 Google Scholar
Digital Library
- Gordon Stewart. 2015. Verified Separate Compilation for C. Ph. D. Dissertation. Princeton University.Google Scholar
- Gordon Stewart, Lennart Beringer, Santiago Cuellar, and Andrew W. Appel. 2015. Compositional CompCert. In Proc. 42nd ACM Symposium on Principles of Programming Languages (POPL'15). ACM, New York, 275-287. https://doi.org/10.1145/ 2676726.2676985 Google Scholar
Digital Library
- Gang Tan and Greg Morrisett. 2018. Bidirectional Grammars for Machine-Code Decoding and Encoding. Journal of Automated Reasoning 60, 3 ( 2018 ), 257-277. https://doi.org/10.1007/s10817-017-9429-1 Google Scholar
Digital Library
- Yong Kiam Tan, Magnus O. Myreen, Ramana Kumar, Anthony Fox, Scott Owens, and Michael Norrish. 2019. The Verified CakeML Compiler Backend. Journal of Functional Programming 29 ( 2019 ), e2. https://doi.org/10.1017/S0956796818000229 Google Scholar
Cross Ref
- Yuting Wang, Pierre Wilke, and Zhong Shao. 2019. An Abstract Stack Based Approach to Verified Compositional Compilation to Machine Code. Proc. ACM Program. Lang. 3, POPL, Article 62 ( Jan. 2019 ), 30 pages. https://doi.org/10.1145/3290375 Google Scholar
Digital Library
Index Terms
CompCertELF: verified separate compilation of C programs into ELF object files
Recommendations
Lightweight verification of separate compilation
POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesMajor compiler verification efforts, such as the CompCert project, have traditionally simplified the verification problem by restricting attention to the correctness of whole-program compilation, leaving open the question of how to verify the ...
Lightweight verification of separate compilation
POPL '16Major compiler verification efforts, such as the CompCert project, have traditionally simplified the verification problem by restricting attention to the correctness of whole-program compilation, leaving open the question of how to verify the ...
Verified compilation on a verified processor
PLDI 2019: Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and ImplementationDeveloping technology for building verified stacks, i.e., computer systems with comprehensive proofs of correctness, is one way the science of programming languages furthers the computing discipline. While there have been successful projects verifying ...






Comments