skip to main content

CompCertELF: verified separate compilation of C programs into ELF object files

Published:13 November 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

This is a presentation video of my talk at OOPSLA 2020 on our paper titled "CompCertELF: Verified Separate Compilation of C Programs into ELF Object Files". The main contributions include the following: 1. 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. 2. A general and lightweight approach for bridging the two different views of linking in verified separate compilation: one for C programs that allows arbitrary shuffling of definitions by linking and the other for object files that treats blocks of encoded definitions as indivisible units. 3. Applying the above idea to CompCertELF, making it the first verified compiler that supports separate compilation from C programs all the way to object files.

References

  1. 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 ScholarGoogle ScholarCross RefCross Ref
  2. 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 ScholarGoogle ScholarCross RefCross Ref
  3. 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 ScholarGoogle ScholarCross RefCross Ref
  4. 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 ScholarGoogle ScholarCross RefCross Ref
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. Xavier Leroy. 2005-2020. The CompCert Verified Compiler. http://compcert.inria.fr/.Google ScholarGoogle Scholar
  13. Xavier Leroy. 2009a. Formal Verification of a Realistic Compiler. Commun. ACM 52, 7 ( 2009 ), 107-115. https://doi.org/10. 1145/1538788.1538814 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle Scholar
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. Gordon Stewart. 2015. Verified Separate Compilation for C. Ph. D. Dissertation. Princeton University.Google ScholarGoogle Scholar
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarCross RefCross Ref
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. CompCertELF: verified separate compilation of C programs into ELF object files

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!