From ebe9e87ccf7ef063fe907d92b833b1eac41bb099 Mon Sep 17 00:00:00 2001 From: bellard Date: Sat, 5 Jan 2002 19:50:17 +0000 Subject: update --- tcc-doc.texi | 209 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 177 insertions(+), 32 deletions(-) (limited to 'tcc-doc.texi') diff --git a/tcc-doc.texi b/tcc-doc.texi index 4347fb1..ee1a9cf 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -14,49 +14,51 @@ Tiny C Compiler Reference Documentation

Introduction

-TinyCC (aka TCC) is a small but very fast C compiler. Unlike other C +TinyCC (aka TCC) is a small but hyper fast C compiler. Unlike other C compilers, it is meant to be self-suffisant: you do not need an external assembler or linker because TCC does that for you.

- -TCC compiles so fast that even for big projects Makefiles may +TCC compiles so fast that even for big projects Makefiles may not be necessary.

+TCC not only supports ANSI C, but also most of the new ISO C99 +standard and many GNUC extensions. +

TCC can also be used to make C scripts, i.e. pieces of C source that you run as a Perl or Python script. Compilation is so fast that your script will be as fast as if it was an executable. +

+TCC can also automatically generate memory and bound +checks while allowing all C pointers operations. TCC can do these +checks even if non patched libraries are used. +

-

Exact differences with ANSI C

+

Full ANSI C support

-TCC implements almost all the ANSI C standard, except floating points -numbers. +TCC implements all the ANSI C standard, including structure bit fields +and floating point numbers (long double, double, and +float fully supported). The following limitations are known:

ISOC99 extensions

TCC implements many features of the new C standard: ISO C99. Currently -missing items are: complex and imaginary numbers (will come with ANSI -C floating point numbers), long longs and variable length +missing items are: complex and imaginary numbers and variable length arrays. Currently implemented ISOC99 features:

GNU C extensions

-TCC implements some GNU C extensions which are found in many C sources: +TCC implements some GNU C extensions:

TinyCC extensions

@@ -138,35 +178,140 @@ indicate that you use TCC.
  • Binary digits can be entered ('0b101' instead of '5'). +
  • __BOUNDS_CHECKING_ON is defined if bound checking is activated. + -

    Command line invokation

    +

    TinyCC Memory and Bound checks

    + + +This feature is activated with the '-b' +option. +

    +Note that pointer size is unchanged and that code generated +with bound checks is fully compatible with unchecked +code. When a pointer comes from unchecked code, it is assumed to be +valid. Even very obscure C code with casts should work correctly. +

    +

    To have more information about the ideas behind this method, check +here. +

    +

    +Here are some examples of catched errors: +

    + + + + + + + + + + + + + + + + +
    +
    +{
    +    char tab[10];
    +    memset(tab, 0, 11);
    +}
    +
    +
    Invalid range with standard string function
    +
    +{
    +    int tab[10];
    +    for(i=0;i<11;i++) {
    +        sum += tab[i];
    +    }
    +}
    +
    +
    Bound error in global or local arrays
    +
    +{
    +    int *tab;
    +    tab = malloc(20 * sizeof(int));
    +    for(i=0;i<21;i++) {
    +        sum += tab4[i];
    +    }
    +    free(tab);
    +}
    +
    +
    Bound error in allocated data
    +
    +{
    +    int *tab;
    +    tab = malloc(20 * sizeof(int));
    +    free(tab);
    +    for(i=0;i<20;i++) {
    +        sum += tab4[i];
    +    }
    +}
    +
    +
    Access to a freed region
    +
    +{
    +    int *tab;
    +    tab = malloc(20 * sizeof(int));
    +    free(tab);
    +    free(tab);
    +}
    +
    +
    Freeing an already freed region
    + +

    Command line invocation

    +
    -usage: tcc [-Idir] [-Dsym] [-llib] [-i infile] infile [infile_args...]
    +usage: tcc [-Idir] [-Dsym[=val]] [-Usym] [-llib] [-g] [-b]
    +           [-i infile] infile [infile_args...]
     
    - - - + + + - +specified with LD_LIBRARY_PATH. + + + + + -
    '-Idir'specify an additionnal include path. The default ones are: +Specify an additionnal include path. The default ones are: /usr/include, /usr/lib/tcc, /usr/local/lib/tcc.
    '-Dsym'define preprocessor symbol 'sym' to 1.
    '-Dsym[=val]' Define preprocessor symbol 'sym' to +val. If val is not present, its value is '1'. NOTE: currently, only +integer and strings are supported as values
    '-Usym' Undefine preprocessor symbol 'sym'.
    '-lxxx'dynamically link your program with library +Dynamically link your program with library libxxx.so. Standard library paths are checked, including those -specificed with LD_LIBRARY_PATH.
    '-g'Generate run time debug information so that you get clear run time +error messages: test.c:68: in function 'test5()': dereferencing +invalid pointer instead of the laconic Segmentation +fault. +
    '-b' Generate additionnal support code to check +memory allocations and array/pointer bounds. '-g' is implied. Note +that the generated code is slower and bigger in this case. +
    '-i file'compile C source 'file' before main C source. With this +Compile C source 'file' before main C source. With this command, multiple C files can be compiled and linked together.
    +
    +Note: the '-o file' option to generate an ELF executable is +currently unsupported.
    -Copyright (c) 2001 Fabrice Bellard
    -Fabrice Bellard - fabrice.bellard at free.fr - http://fabrice.bellard.free.fr/ - http://www.tinycc.org/ +Copyright (c) 2001, 2002 Fabrice Bellard
    +Fabrice Bellard - fabrice.bellard at free.fr - http://bellard.org/ - http://www.tinycc.org/ -- cgit v1.3.1