~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/bytecode_priv.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Load, verify and execute ClamAV bytecode.
 
3
 *
 
4
 *  Copyright (C) 2009-2010 Sourcefire, Inc.
 
5
 *
 
6
 *  Authors: Török Edvin
 
7
 *
 
8
 *  This program is free software; you can redistribute it and/or modify
 
9
 *  it under the terms of the GNU General Public License version 2 as
 
10
 *  published by the Free Software Foundation.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
20
 *  MA 02110-1301, USA.
 
21
 */
 
22
 
 
23
#ifndef BYTECODE_PRIV_H
 
24
#define BYTECODE_PRIV_H
 
25
 
 
26
#include "bytecode.h"
 
27
#include "type_desc.h"
 
28
#include "execs.h"
 
29
#include "bytecode_hooks.h"
 
30
#include "fmap.h"
 
31
#include "mpool.h"
 
32
 
 
33
typedef uint32_t operand_t;
 
34
typedef uint16_t bbid_t;
 
35
typedef uint16_t funcid_t;
 
36
 
 
37
struct cli_bc_callop {
 
38
    operand_t* ops;
 
39
    uint16_t* opsizes;
 
40
    uint8_t numOps;
 
41
    funcid_t funcid;
 
42
};
 
43
 
 
44
struct branch {
 
45
    operand_t condition;
 
46
    bbid_t br_true;
 
47
    bbid_t br_false;
 
48
};
 
49
 
 
50
struct cli_bc_cast {
 
51
    uint64_t mask;
 
52
    operand_t source;
 
53
    uint8_t size;/* 0: 1-bit, 1: 8b, 2: 16b, 3: 32b, 4: 64b */
 
54
};
 
55
 
 
56
typedef uint8_t interp_op_t;
 
57
struct cli_bc_inst {
 
58
    enum bc_opcode opcode;
 
59
    uint16_t type;
 
60
    interp_op_t interp_op;/* opcode for interpreter */
 
61
    operand_t dest;
 
62
    union {
 
63
        operand_t unaryop;
 
64
        struct cli_bc_cast cast;
 
65
        operand_t binop[2];
 
66
        operand_t three[3];
 
67
        struct cli_bc_callop ops;
 
68
        struct branch branch;
 
69
        bbid_t jump;
 
70
    } u;
 
71
};
 
72
 
 
73
struct cli_bc_bb {
 
74
    unsigned numInsts;
 
75
    struct cli_bc_inst *insts;
 
76
};
 
77
 
 
78
struct cli_bc_func {
 
79
    uint8_t numArgs;
 
80
    uint16_t numLocals;
 
81
    uint32_t numInsts;
 
82
    uint32_t numValues;/* without constants */
 
83
    uint32_t numConstants;
 
84
    uint32_t numBytes;/* stack size */
 
85
    uint16_t numBB;
 
86
    uint16_t returnType;
 
87
    uint16_t *types;
 
88
    uint32_t insn_idx;
 
89
    struct cli_bc_bb *BB;
 
90
    struct cli_bc_inst *allinsts;
 
91
    uint64_t *constants;
 
92
    unsigned *dbgnodes;
 
93
};
 
94
 
 
95
struct cli_bc_dbgnode_element {
 
96
    unsigned nodeid;
 
97
    char *string;
 
98
    unsigned len;
 
99
    uint64_t constant;
 
100
};
 
101
 
 
102
struct cli_bc_dbgnode {
 
103
    unsigned numelements;
 
104
    struct cli_bc_dbgnode_element* elements;
 
105
};
 
106
 
 
107
#define MAX_OP ~0u
 
108
enum trace_level {
 
109
    trace_none=0,
 
110
    trace_func,
 
111
    trace_param,
 
112
    trace_scope,
 
113
    trace_line,
 
114
    trace_col,
 
115
    trace_op,
 
116
    trace_val
 
117
};
 
118
struct cli_bc_ctx {
 
119
    /* id and params of toplevel function called */
 
120
    const struct cli_bc *bc;
 
121
    const struct cli_bc_func *func;
 
122
    unsigned bytes;
 
123
    uint16_t *opsizes;
 
124
    char *values;
 
125
    operand_t *operands;
 
126
    uint16_t funcid;
 
127
    unsigned numParams;
 
128
    uint32_t file_size;
 
129
    off_t off;
 
130
    fmap_t *fmap;
 
131
    const char *virname;
 
132
    struct cli_bc_hooks hooks;
 
133
    const struct cli_exe_section *sections;
 
134
    int outfd;
 
135
    char *tempfile;
 
136
    void *ctx;
 
137
    unsigned written;
 
138
    bc_dbg_callback_trace trace;
 
139
    bc_dbg_callback_trace_op trace_op;
 
140
    bc_dbg_callback_trace_val trace_val;
 
141
    bc_dbg_callback_trace_ptr trace_ptr;
 
142
    unsigned trace_level;
 
143
    const char *directory;
 
144
    const char *file;
 
145
    const char *scope;
 
146
    uint32_t scopeid;
 
147
    unsigned line;
 
148
    unsigned col;
 
149
    mpool_t *mpool;
 
150
    uint32_t numGlobals;
 
151
    uint8_t* globals;
 
152
};
 
153
struct cli_all_bc;
 
154
int cli_vm_execute(const struct cli_bc *bc, struct cli_bc_ctx *ctx, const struct cli_bc_func *func, const struct cli_bc_inst *inst);
 
155
 
 
156
#ifdef __cplusplus
 
157
extern "C" {
 
158
#endif
 
159
 
 
160
int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx, const struct cli_bc_func *func);
 
161
int cli_bytecode_prepare_jit(struct cli_all_bc *bc);
 
162
int cli_bytecode_init_jit(struct cli_all_bc *bc, unsigned dconfmask);
 
163
int cli_bytecode_done_jit(struct cli_all_bc *bc);
 
164
 
 
165
#ifdef __cplusplus
 
166
}
 
167
#endif
 
168
#endif