06.03.2014 Views

Book of Abstracts - IRIT

Book of Abstracts - IRIT

Book of Abstracts - IRIT

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Effective Types for C formalized in Coq<br />

Robbert Krebbers<br />

The main novelty <strong>of</strong> our model is that the memory, although being fairly abstract, still<br />

supports low level operations; in particular byte-wise copying <strong>of</strong> objects. The model includes<br />

three layers: (a.) values with machine integers and pointers as leafs, (b.) memory values with<br />

arrays <strong>of</strong> bytes as leafs, and (c.) arrays <strong>of</strong> bytes. As in CompCert [4], bytes corresponding<br />

to uninitialized memory and fragments <strong>of</strong> pointers are symbolic. The following figure displays<br />

these three layers for the object struct { short x, *p; } s = { 33; &s.x }.<br />

(a)<br />

33 •<br />

<strong>of</strong> val<br />

to val<br />

0x00 0x21 • • • •<br />

(b)<br />

to bytes <strong>of</strong> bytes<br />

(c)<br />

0x00 0x21 • • • •<br />

When copying an object by assignment, it is converted to an actual value when loaded (using<br />

to val) and converted back when stored (using <strong>of</strong> val). The conversion back yields a set <strong>of</strong><br />

possible representations. When copying an object byte-wise (using to bytes and <strong>of</strong> bytes),<br />

information about the variants <strong>of</strong> contained unions may be lost (as that cannot be stored in<br />

bytes). We define a partial order ⊆ to capture that information about the variants <strong>of</strong> unions<br />

may have gotten lost, and that uninitialized memory may have become initialized.<br />

Theorem 2.1. For each memory value v and type τ with v : τ, there exists a memory value w<br />

such that: (a.) w ∈ <strong>of</strong> val (to val v), and (b.) w ⊆ <strong>of</strong> bytes τ (to bytes v).<br />

A consequence <strong>of</strong> the previous theorem is that a copy by assignment can be transformed<br />

into a byte-wise copy. If a copy <strong>of</strong> v by assignment has defined behavior, then it does not go<br />

wrong for each representation obtained by conversion to a value and back. As for one <strong>of</strong> these<br />

representations w we have w ⊆ <strong>of</strong> bytes τ (to bytes v) by the theorem, and the fact that all<br />

operations on the memory respect ⊆, we obtain soundness <strong>of</strong> this transformation.<br />

3 Future work<br />

The eventual goal <strong>of</strong> this work is to develop a semantics for a large part <strong>of</strong> the C11 programming<br />

language. In previous work [3] we developed a concise operational and axiomatic semantics for<br />

non local control flow (goto and return statements). Recently, we have extended this operational<br />

and axiomatic semantics with sequence points and non-deterministic expressions with sideeffects.<br />

The next step is to create a fully fledged memory model on top <strong>of</strong> the abstract version<br />

introduced here, and to integrate it into our formalization [2]. Another direction for future<br />

research is to prove a correspondence with the CompCert memory model [4].<br />

References<br />

[1] Chucky Ellison and Grigore Rosu. An executable formal semantics <strong>of</strong> C with applications. In<br />

POPL, pages 533–544, 2012.<br />

[2] Robbert Krebbers. The CH 2O formalization, 2013. http://robbertkrebbers.nl/research/ch2o/.<br />

[3] Robbert Krebbers and Freek Wiedijk. Separation Logic for Non-local Control Flow and Block Scope<br />

Variables. In FoSSaCS, volume 7794 <strong>of</strong> LNCS, pages 257–272, 2013.<br />

[4] Xavier Leroy, Andrew W. Appel, Sandrine Blazy, and Gordon Stewart. The CompCert Memory<br />

Model, Version 2. Research report RR-7987, INRIA, 2012.<br />

55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!