IOCCC image by Matt Zucker

The International Obfuscated C Code Contest

2001/bellard - Best abuse of the rules

A C subset programming system for x86

Author:

To build:

    make

Bugs and (Mis)features:

The current status of this entry is:

STATUS: INABIAF - please DO NOT fix

For more detailed information see 2001/bellard in bugs.html.

To use:

    ./bellard file

Try:

    ./bellard bellard.otccex.c

Judges’ remarks:

<JUDGES_COMMENTS> :-)

Author’s remarks:

OTCC is an Obfuscated Tiny C Compiler for i386-linux. It generates FAST! i386 32 bit code (no bytecode) and it is powerful enough to compile itself. OTCC supports a strict subset of C. This subset is compilable by a standard ANSI C compiler. OTCC compiles, assembles, links and runs C code without the need of any other program.

You can use it by typing:

    ./bellard bellard.c [args]...

or by giving the C source to its standard input.

args are given to the main() function of bellard.c, argv[0] is bellard.c.

Examples:

    ./bellard bellard.otccex.c 10
    ./bellard bellard.c bellard.otccex.c 10
    ./bellard bellard.c bellard.c bellard.otccex.c 10

An alternate syntax is to use it as a script interpreter: you can put #!/usr/local/bin/otcc at the beginning of your C source if you installed otcc at this place.

Supported C language subset

Read joint example bellard.otccex.c to have an introduction to OTCC dialect.

Expressions:

Obfuscation:

No special effort was needed because obfuscation is almost unavoidable for such a program :-) #defines must be used to compress the code, and integrated i386 code generator leads to non obvious code.

Portability:

OTCC only works on i386 linux because it generates i386 code. OTCC also relies on little endianness, unaligned memory accesses and ASCII representation of characters. It also supposes that no valid pointers are less than 512. If all those constraints are met, then OTCC could be theoretically used to “cross compile”, although no such support is currently integrated.

It was successfully compiled with gcc version 2.95.2. You get some warnings because old K&R prototypes are used, some casts are implicit and some functions are used before being defined. OTCC uses the dynamic linker to resolve symbols with dlsym(3), so -ldl must be used when you compile and link it.

Inventory for 2001/bellard

Primary files

Secondary files


Jump to: top