Commit graph

73 commits

Author SHA1 Message Date
Török Edvin
b2de4fd85f Minor optimization in JIT loader. 2010-03-30 11:07:05 +03:00
Török Edvin
cbec3f2446 Update SELinux message. 2010-03-30 00:34:49 +03:00
Török Edvin
44e134312c More fixes for pdf.cbc. 2010-03-30 00:04:38 +03:00
Török Edvin
c506c2c555 Fallback to interpreter mode when SELinux denies 'execmem' access. (bb #1901).
This also fixes a crash when run under SELinux: MemoryBlock() needs to
initialize its field to 0!
2010-03-28 13:52:29 +03:00
Török Edvin
11cee1b7de Disable JITDebugRegisterer, and fix unit_tests rule. 2010-03-24 17:22:34 +02:00
Török Edvin
6ea339aeab Fix bswap. 2010-03-24 15:27:15 +02:00
Török Edvin
bdd9aeaeeb Use a watchdog thread. Also make timeout be ms instead of us. 2010-03-23 16:33:41 +02:00
Török Edvin
99536a178c Insert timeout checks directly into the JITed code.
pthread_cancel is broken on Mac OS X (it only works if the thread
you want to kill calls pthread_testcancel, which is never the situation
when you need async cancelation).
Anyway async cancelation is risky, it may leave bc_ctx in an inconsistent state.
So rather than doing using pthread_cancel (or pthread_kill+siglongjmp)
just insert the timeout checks into the JITed code directly.

These are inserted in each loop, if the loop's tripcount is unknown, or
higher than a threshold. They are also inserted after a certain amount
of APIcalls are made (even in absence of loops).
Note that 'loop' in this sense is not LLVM's notion of a natural loop,
it is simply a BB which is reachable both directly and via a backedge.

For example this doesn't contain natural loops but contains backedges (and a
potential infinite loop):
int foo(int a)
{
    int x=4;
    if (a == 42)
        goto head2;
head:
    x++;
head2:
    if (a >= 2) {
        x += 3;
        goto head;
    } else if (a >= 0) {
        x += 9;
        goto head;
    }
    return x;
}
2010-03-23 15:54:41 +02:00
Török Edvin
b63681a52b Introduce BytecodeTimeout. 2010-03-22 17:16:07 +02:00
Török Edvin
884a0b8f8d Support for timeouts. 2010-03-22 16:57:27 +02:00
Török Edvin
84edf09bba Fix clambc -p. 2010-03-22 14:58:51 +02:00
Török Edvin
e2752b2cc8 Fix valgrind warning. 2010-03-22 13:05:20 +02:00
Török Edvin
52d0d8bc7e More fixes for global vars in the interpreter. 2010-03-22 11:18:28 +02:00
Török Edvin
09667cdd3b Print size and location of JITed code. 2010-03-22 11:18:28 +02:00
Török Edvin
6ad39a4099 zlib/buffer apis. 2010-03-22 11:18:28 +02:00
Török Edvin
75e18b29c2 minimalistic zlib api. 2010-03-22 11:18:28 +02:00
Török Edvin
b56bea54d3 New API for buffer fill. 2010-03-22 11:18:28 +02:00
Török Edvin
aa745db74d Add clamscan commandline to load bytecode in debug mode. 2010-03-12 13:13:08 +02:00
Török Edvin
f60c59a471 bb #1800. 2010-03-10 11:44:55 +02:00
Török Edvin
04d11afedb Update to new LLVM API.
ModuleProvider is gone!
2010-02-15 18:48:35 +02:00
Török Edvin
6eeadbfeda dconf for bytecode. 2010-02-15 17:32:41 +02:00
Török Edvin
1e30496d2a runtime checks verifier. 2010-02-15 17:32:41 +02:00
Török Edvin
236fb13647 New pointer handling rules. 2010-02-15 17:32:40 +02:00
Török Edvin
847d7fc1b8 2009->2010 2010-02-02 14:03:32 +02:00
Török Edvin
57bbb2eb14 Fix loading of multiple .cbc files.
Common function prototypes must be added only once per Module, otherwise LLVM autorenames
them, and we get llvm.bswap.i326 instead of llvm.bswap.i32, which is of course
not valid and the verifier rejects.
2010-02-02 14:01:38 +02:00
Török Edvin
bcb354a654 _GLIBCXX_PARALLEL is not supported: it creates threads before we fork() causing
deadlock.
2010-01-27 14:42:40 +02:00
Török Edvin
a7b7a64833 fix compiler warning. 2010-01-26 14:25:54 +02:00
Török Edvin
ee6ab4f8d3 Support building w/o atomic builtins for i386 (bb #1781).
Wrap all LLVM API calls with a single mutex when LLVM doesn't have multithreaded
mode.
Also fallback to interpreter mode on i386 and i486.
2010-01-26 12:44:49 +02:00
Török Edvin
be43f951c6 BytecodeSecurity setting. 2010-01-22 16:50:35 +02:00
Török Edvin
4395bb9acf bytecode ptrdiff32 opcode. 2010-01-21 16:49:22 +02:00
Török Edvin
2d45ef0616 Support for malloc in bytecode. Fix crash with mismatched api/flevel versions. 2010-01-20 20:04:01 +02:00
Török Edvin
8997b14725 bswap. 2009-12-30 15:08:35 +02:00
Török Edvin
b3571ea9ae Fix __*di3 libcalls on x86-32.
On 32-bit targets LLVM emits libcalls for 64-bit operations.
Make sure these libcalls actually map to our own functions, and not to 0.
Also reject any other libcall we don't know about instead of mapping to 0 and crashing.
2009-12-30 12:15:26 +02:00
Török Edvin
c52e92748e Fix some warnings from clang++ bytecode2llvm.cpp. 2009-12-28 20:18:59 +02:00
Török Edvin
8d18898743 add regalloc local for debug purposes. 2009-12-18 15:04:23 +02:00
Török Edvin
9463f9fd90 Stack protector support. 2009-12-18 14:17:50 +02:00
Török Edvin
688799d126 yc_bytecode is able to unpack a file now! 2009-12-17 17:40:35 +02:00
Török Edvin
3cd48316a3 Fix some compiler warnings. 2009-12-17 10:59:26 +02:00
Török Edvin
5b91dc3455 new deplibs. 2009-12-15 18:15:28 +02:00
Török Edvin
303c6ea016 Minimum required version for multithreaded LLVM is gcc 4.1.3.
gcc 3.4.6 doesn't support atomic builtins required by LLVM for multithreaded
mode.
So make the minimum version 4.1.3, since: 4.0 is buggy for ClamAV itself, and
4.1.1, 4.1.2 are buggy when compiling LLVM.
On gcc 3.4.6 clamav will use the interpreter now.
2009-12-14 16:23:22 +02:00
Török Edvin
853b6e5da1 Add LLVM win32 proj files generated by cmake.
Fix win32 build issues.
Enable CPU detection on win32 too.
Enable LLVM JIT on win32 too.
Define NDEBUG for libclamavc++ for release win32 builds.
2009-12-12 15:14:39 +02:00
Török Edvin
d0934caf99 Distcheck fixes. 2009-12-11 21:02:19 +02:00
Török Edvin
482e97dbb2 Support for bytecode lines >8k.
Size is specified on first line (which must be <8k).
2009-12-11 16:05:38 +02:00
Török Edvin
7945ff1e97 Fix global initializer bitcasts. 2009-12-11 12:08:32 +02:00
Török Edvin
0a11015bf5 Refactor trace API, so that trace printing happens in clambc.
This will allow clambc to implement breakpoints, and watchpoints.
2009-12-09 17:05:05 +02:00
Török Edvin
284ffd21f2 Add support for null constant. 2009-12-09 15:15:35 +02:00
Török Edvin
124af5e8a5 Trace formatting fixes. 2009-12-09 11:43:17 +02:00
Török Edvin
65c740d7d8 Add support for tracing (if bytecode compiled with support).
TODO: global id 0 is now a null pointer, need to adjust rest of conversion code
accordingly.
2009-12-08 23:02:49 +02:00
Török Edvin
53bd5bb14d read optional debug metadata. 2009-11-30 15:22:20 +02:00
Török Edvin
d2171abf39 Print better error message when wrong function is called. 2009-11-27 15:57:13 +02:00