============ System Model ============ This page describes how czz-llvm :ref:`models various aspects of libc and the host operating system `. To maintain soundness, czz must *under-approximate* the behavior of the standard library and host OS. Every response that czz generates for a library call must be a *possible* response that the standard library and host OS might generate. The test suite compares the behavior of programs that make library calls when interpreted by czz-llvm to when they're compiled by Clang and executed on the host, to ensure fidelity of czz-llvm's models. The hope is to enrich the Scheme API to the point where many such models could be written in Scheme. Overrides ========= czz-llvm's models of library functions are called *overrides*. The following table provides a high-level view of these overrides. The "Impl." column is short for "implementation", for which there are several possible options: - "None": no override is available - "czz": the override is implemented as part of czz-llvm. - "cru.": the override is implemented as part of Crucible-LLVM. These overrides are generally suitable for program verification, so they are almost always sound. - "musl": the definition of this function is compiled by Clang from musl libc and linked into the LLVM module before execution by czz-llvm. This is sound up to bugs in musl, Clang, and ``llvm-link``. The "Sound" column is short for "soundness", for which there are several possible options: - "Yes?": AFAIK this is sound, but more research may be needed to verify this. - "Yes": This is very likely sound based on my reading of the docs. - "No": This is known to be unsound (see documentation for specific overrides). .. TODO(lb): What's up with the crucible-llvm math ones? Do they work for concrete values? .. https://github.com/GaloisInc/crucible/blob/master/crucible-llvm/src/Lang/Crucible/LLVM/Intrinsics.hs .. :ref:`Math ` ``ciel`` n/a cru. Yes n/a ================================== ================== ===== ===== ===== ============================ Category Name Tests Impl. Sound Docs or Issue ================================== ================== ===== ===== ===== ============================ :ref:`Env. vars. ` ``getenv`` 5 czz Yes? :ref:`Docs ` :ref:`Env. vars. ` ``setenv`` 2 None n/a `#29`_ :ref:`Env. vars. ` ``unsetenv`` 2 None No :ref:`Docs ` :ref:`Files ` ``fclose`` 0 None n/a `#43`_ :ref:`Files ` ``fopen`` 0 None n/a `#42`_ :ref:`Files ` ``fprintf`` czz n/a :ref:`Docs ` :ref:`Files ` ``fread`` 0 None n/a `#44`_ :ref:`Files ` ``fwrite`` 0 None n/a `#45`_ :ref:`Formatting ` ``__printf_chk`` n/a cru. No :ref:`Docs ` :ref:`Formatting ` ``printf`` n/a cru. No :ref:`Docs ` :ref:`Formatting ` ``sprintf`` czz No :ref:`Docs ` :ref:`Formatting ` ``snprintf`` czz No :ref:`Docs ` :ref:`Formatting ` ``__sprintf_chk`` czz No :ref:`Docs ` :ref:`Formatting ` ``__snprintf_chk`` czz No :ref:`Docs ` :ref:`Math ` ``abs`` n/a cru. Yes n/a :ref:`Math ` ``labs`` n/a cru. Yes n/a :ref:`Math ` ``llabs`` n/a cru. Yes n/a :ref:`Memory ` ``__memcpy_chk`` n/a cru. Yes n/a :ref:`Memory ` ``__memset_chk`` n/a cru. Yes n/a :ref:`Memory ` ``calloc`` n/a cru. Yes n/a :ref:`Memory ` ``free`` n/a cru. Yes n/a :ref:`Memory ` ``htonl`` n/a cru. Yes n/a :ref:`Memory ` ``htons`` n/a cru. Yes n/a :ref:`Memory ` ``malloc`` n/a cru. Yes n/a :ref:`Memory ` ``memcmp`` n/a musl Yes n/a :ref:`Memory ` ``memcpy`` n/a cru. Yes n/a :ref:`Memory ` ``memmove`` n/a cru. Yes n/a :ref:`Memory ` ``memrchr`` n/a musl Yes n/a :ref:`Memory ` ``memset`` n/a cru. Yes n/a :ref:`Memory ` ``ntohl`` n/a cru. Yes n/a :ref:`Memory ` ``ntohs`` n/a cru. Yes n/a :ref:`Memory ` ``posix_memalign`` n/a cru. Yes n/a :ref:`Memory ` ``realloc`` n/a cru. Yes n/a :ref:`Misc ` ``__lctrans_cur`` n/a musl Yes n/a :ref:`Misc ` ``__lctrans`` n/a musl Yes n/a :ref:`Misc ` ``atoi`` n/a musl Yes n/a :ref:`Misc ` ``getopt_long`` n/a musl Yes n/a :ref:`Misc ` ``mbtowc`` n/a musl Yes n/a :ref:`Misc ` ``rand`` n/a musl Yes n/a :ref:`Misc ` ``srand`` n/a musl Yes n/a :ref:`Misc ` ``signal`` czz Yes? :ref:`Docs ` :ref:`Network ` ``accept`` czz No :ref:`Docs ` :ref:`Network ` ``bind`` czz No :ref:`Docs ` :ref:`Network ` ``listen`` czz No :ref:`Docs ` :ref:`Network ` ``recv`` czz No :ref:`Docs ` :ref:`Network ` ``send`` czz No :ref:`Docs ` :ref:`Network ` ``setsockopt`` czz No :ref:`Docs ` :ref:`Network ` ``socket`` czz No :ref:`Docs ` :ref:`Standard I/O ` ``putchar`` n/a cru. No n/a :ref:`Standard I/O ` ``puts`` n/a cru. No n/a :ref:`Strings ` ``stpncpy`` n/a musl Yes n/a :ref:`Strings ` ``strcmp`` n/a musl Yes n/a :ref:`Strings ` ``strdup`` n/a musl Yes n/a :ref:`Strings ` ``strlen`` n/a cru. Yes n/a :ref:`Strings ` ``strcpy`` czz Yes None :ref:`Strings ` ``strncpy`` n/a musl Yes n/a :ref:`Strings ` ``strrchr`` n/a musl Yes n/a :ref:`Time ` ``gettimeofday`` 1 czz Yes :ref:`Docs ` :ref:`Time ` ``time`` 1 czz Yes? :ref:`Docs