Repository navigation
Expand file tree
/
Copy pathucode_cat.txt
More file actions
52 lines (47 loc) · 2.2 KB
/
Copy pathucode_cat.txt
File metadata and controls
52 lines (47 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ucode_cat.txt -- the pc set of iris/UCodeCat.v, for tools/gen_ucode.py.
#
# tools/ucode_manifest.json binds this spec to iris/UCodeCat.v; `make gen-ucode`
# rewrites that file from it, and `make check-ucode` fails if it moved.
#
# cat is the first verified program whose SYSCALLS WRITE ITS MEMORY. init,
# echo and sync issue only quiet syscalls and exec/fork/wait; cat's inner
# loop is `read(fd, buf, 512)` into a 512-byte global, and the theorem has
# to hold whatever the kernel puts there and however much of it it fills.
# It is also the first to reach vprintf's `%s` arm, through
# `fprintf(2, "cat: cannot open %s\n", argv[i])`.
#
# Unreachable branches INSIDE a listed function are kept, following
# ucode_init.txt: an unused [uinstr] fact costs only compile time, and
# pruning per branch would have to be re-audited whenever the reachable set
# moves. A whole function never entered is another matter -- its facts
# would be a claim about code no proof reads -- so those are left out and
# the reason recorded below.
note This catalog covers cat as it runs: main's walk over argv, the
note read/write loop in cat(), and the fprintf cone underneath its three
note diagnostics. Its coverage claim is the list of omitted functions
note below, not all of ulib.
# ---- the program ------------------------------------------------------
func start
func main
func cat
# ---- the fprintf cone (reached by all three diagnostics) --------------
func fprintf
func vprintf
func putc
# ---- the syscall stubs it issues --------------------------------------
func read
func write
func open
func close
func exit
# ---- and what is deliberately absent ---------------------------------
skipfunc printint unreachable: vprintf reaches it only from the %d/%u/%x arms, and cat's only conversion is %s
skipfunc printf unreachable: cat calls fprintf, never printf
skipfunc malloc unreachable: cat allocates nothing
skipfunc free unreachable: cat allocates nothing
skipfunc sbrk unreachable: only malloc calls it
skipfunc sbrklazy unreachable: only malloc calls it
skipfunc sys_sbrk unreachable: only malloc calls it
skipfunc gets unreachable: cat never reads a line
skipfunc stat unreachable: cat never stats
skipfunc fstat unreachable: only stat calls it