2
* Load, verify and execute ClamAV bytecode.
4
* Copyright (C) 2009-2010 Sourcefire, Inc.
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.
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.
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,
23
#ifndef BYTECODE_PRIV_H
24
#define BYTECODE_PRIV_H
27
#include "type_desc.h"
29
#include "bytecode_hooks.h"
33
typedef uint32_t operand_t;
34
typedef uint16_t bbid_t;
35
typedef uint16_t funcid_t;
37
struct cli_bc_callop {
53
uint8_t size;/* 0: 1-bit, 1: 8b, 2: 16b, 3: 32b, 4: 64b */
56
typedef uint8_t interp_op_t;
58
enum bc_opcode opcode;
60
interp_op_t interp_op;/* opcode for interpreter */
64
struct cli_bc_cast cast;
67
struct cli_bc_callop ops;
75
struct cli_bc_inst *insts;
82
uint32_t numValues;/* without constants */
83
uint32_t numConstants;
84
uint32_t numBytes;/* stack size */
90
struct cli_bc_inst *allinsts;
95
struct cli_bc_dbgnode_element {
102
struct cli_bc_dbgnode {
103
unsigned numelements;
104
struct cli_bc_dbgnode_element* elements;
119
/* id and params of toplevel function called */
120
const struct cli_bc *bc;
121
const struct cli_bc_func *func;
132
struct cli_bc_hooks hooks;
133
const struct cli_exe_section *sections;
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;
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);
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);