|
ABSTRACT
The C language definition leaves the sizes and layouts of types partially unspecified. When a C program makes assumptions about type layout, its semantics is defined only on platforms (C compilers and the underlying hardware) on which those assumptions hold. Previous work on formalizing C-like languages has ignored this issue, either by assuming that programs do not make such assumptions or by assuming that all valid programs target only one platform. In the latter case, the platform's choices are hard-wired in the language semantics. In this paper, we present a practically-motivated model for a C-like language in which the memory layouts of types are left largely unspecified. The dynamic semantics is parameterized by a platform's layout policy and makes manifest the consequence of platform-dependent (i.e., unspecified) steps. A type-and-effect system produces a layout constraint: a logic formula encoding layout conditions under which the program is memory-safe. We prove that if a program type-checks, it is memory-safe on all platforms satisfying its constraint. Based on our theory, we have implemented a tool that discovers unportable layout assumptions in C programs. Our approach should generalize to other kinds of platform-dependent assumptions.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
 |
1
|
|
| |
2
|
Aleph One Limited. The ARMLinux Book Online, Chapter 10. 2005. http://www.aleph1.co.uk/armlinux/book.
|
 |
3
|
|
| |
4
|
David F. Bacon. Kava: a Java dialect with a uniform object model for lightweight classes. Concurrency and Computation: Practice and Experience, 15 (3--5), 2003.
|
| |
5
|
Sandrine Blazy, Zaynah Dargaye, and Xavier Leroy. Formal verification of a C compiler front-end. In 14th International Symposium on Formal Methods, 2006.
|
| |
6
|
C Standard 1999. ISO/IEC 9899:1999, International Standard-Programming Languages-C. International Standards Organization, 1999.
|
 |
7
|
|
 |
8
|
Juan Chen , Dinghao Wu , Andrew W. Appel , Hai Fang, A provably sound TAL for back-end optimization, Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and implementation, June 09-11, 2003, San Diego, California, USA
|
 |
9
|
Jeremy Condit , Matthew Harren , Scott McPeak , George C. Necula , Westley Weimer, CCured in the real world, Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and implementation, June 09-11, 2003, San Diego, California, USA
|
| |
10
|
Jeremy Condit, Matthew Harren, Zachary Anderson, David Gay, and George Necula. Dependent types for low-level programming. In European Symposium on Programming, 2007.
|
 |
11
|
|
 |
12
|
|
 |
13
|
|
 |
14
|
|
 |
15
|
Dan Grossman , Greg Morrisett , Trevor Jim , Michael Hicks , Yanling Wang , James Cheney, Region-based memory management in cyclone, Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, June 17-19, 2002, Berlin, Germany
|
 |
16
|
|
| |
17
|
|
| |
18
|
IBM. Developing embedded software for the IBM PowerPC 970FX processor. Application Note 970, IBM, 2004. http://www.ibm.com/chips/techlib/.
|
| |
19
|
Trevor Jim , J. Greg Morrisett , Dan Grossman , Michael W. Hicks , James Cheney , Yanling Wang, Cyclone: A Safe Dialect of C, Proceedings of the General Track of the annual conference on USENIX Annual Technical Conference, p.275-288, June 10-15, 2002
|
 |
20
|
|
| |
21
|
|
| |
22
|
Brad Martin, Anita Rettinger, and Jasmit Singh. Multiplatform porting to 64 bits. Dr. Dobb's Journal, 2005.
|
 |
23
|
|
 |
24
|
|
 |
25
|
|
| |
26
|
|
 |
27
|
|
 |
28
|
|
| |
29
|
Marius Nita, Dan Grossman, and Craig Chambers. A theory of platform-dependent low-level software (extended version). 2007. Available at http://www.cs.washington.edu/homes/marius/papers/tpd/.
|
| |
30
|
Michael Norrish. C formalised in HOL. PhD thesis, University of Cambridge, 1998.
|
 |
31
|
Leaf Petersen , Robert Harper , Karl Crary , Frank Pfenning, A type theory for memory allocation and data layout, Proceedings of the 30th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, p.172-184, January 15-17, 2003, New Orleans, Louisiana, USA
|
| |
32
|
Norman Ramsey, Simon~Peyton Jones, and Christian Lindig. The C-language specification version 2.0, 2005. http://www.cminusminus.org/extern/man2.pdf.
|
 |
33
|
Michael Siff , Satish Chandra , Thomas Ball , Krishna Kunchithapadam , Thomas Reps, Coping with type casts in C, Proceedings of the 7th European software engineering conference held jointly with the 7th ACM SIGSOFT international symposium on Foundations of software engineering, p.180-198, September 06-10, 1999, Toulouse, France
|
 |
34
|
|
|