1 /*
2 * Load, and verify ClamAV bytecode.
3 *
4 * Copyright (C) 2013-2022 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
5 * Copyright (C) 2009-2013 Sourcefire, Inc.
6 *
7 * Authors: Török Edvin
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 */
23
24 #include <stdio.h>
25 #include <stdlib.h>
26
27 #include "bytecode.h"
28 #include "bytecode_priv.h"
29 #include "clamav.h"
30 #include "others.h"
31
cli_bytecode_prepare_jit(struct cli_all_bc * bcs)32 int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
33 {
34 unsigned i;
35 for (i = 0; i < bcs->count; i++) {
36 if (bcs->all_bcs[i].state == bc_skip)
37 continue;
38 if (bcs->all_bcs[i].state != bc_loaded &&
39 bcs->all_bcs[i].kind != BC_STARTUP) {
40 cli_warnmsg("Cannot prepare for JIT, because it has already been converted to interpreter\n");
41 return CL_EBYTECODE;
42 }
43 }
44 cli_dbgmsg("Cannot prepare for JIT, LLVM is not compiled or not linked\n");
45 return CL_EBYTECODE;
46 }
47
cli_vm_execute_jit(const struct cli_all_bc * bcs,struct cli_bc_ctx * ctx,const struct cli_bc_func * func)48 int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx, const struct cli_bc_func *func)
49 {
50 UNUSEDPARAM(bcs);
51 UNUSEDPARAM(ctx);
52 UNUSEDPARAM(func);
53 return CL_EBYTECODE;
54 }
55
cli_bytecode_init_jit(struct cli_all_bc * allbc,unsigned dconfmask)56 int cli_bytecode_init_jit(struct cli_all_bc *allbc, unsigned dconfmask)
57 {
58 UNUSEDPARAM(allbc);
59 UNUSEDPARAM(dconfmask);
60 return CL_SUCCESS;
61 }
62
cli_bytecode_done_jit(struct cli_all_bc * allbc,int partial)63 int cli_bytecode_done_jit(struct cli_all_bc *allbc, int partial)
64 {
65 UNUSEDPARAM(allbc);
66 UNUSEDPARAM(partial);
67 return CL_SUCCESS;
68 }
69
cli_bytecode_debug(int argc,char ** argv)70 void cli_bytecode_debug(int argc, char **argv)
71 {
72 /* Empty */
73 UNUSEDPARAM(argc);
74 UNUSEDPARAM(argv);
75 }
76
bytecode_init(void)77 int bytecode_init(void)
78 {
79 return 0;
80 }
81
cli_bytecode_debug_printsrc(const struct cli_bc_ctx * ctx)82 void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx)
83 {
84 /* Empty */
85 UNUSEDPARAM(ctx);
86 }
cli_bytecode_printversion(void)87 void cli_bytecode_printversion(void)
88 {
89 printf("LLVM is not compiled or not linked\n");
90 }
91 int have_clamjit = 0;
cli_printcxxver()92 void cli_printcxxver()
93 {
94 /* Empty */
95 }
cli_detect_env_jit(struct cli_environment * env)96 void cli_detect_env_jit(struct cli_environment *env)
97 {
98 /* Empty */
99 UNUSEDPARAM(env);
100 }
101