2009-08-25 18:54:14 +03:00
|
|
|
/*
|
|
|
|
* Load, and verify ClamAV bytecode.
|
|
|
|
*
|
2019-01-25 10:15:50 -05:00
|
|
|
* Copyright (C) 2013-2019 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
|
|
|
* Copyright (C) 2009-2013 Sourcefire, Inc.
|
2009-08-25 18:54:14 +03:00
|
|
|
*
|
|
|
|
* Authors: Török Edvin
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
* MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2009-12-11 20:43:58 +02:00
|
|
|
#include <stdio.h>
|
2009-09-07 18:01:43 +03:00
|
|
|
#include <stdlib.h>
|
2014-02-08 00:31:12 -05:00
|
|
|
|
2009-08-25 18:54:14 +03:00
|
|
|
#include "bytecode.h"
|
2009-09-07 18:01:43 +03:00
|
|
|
#include "bytecode_priv.h"
|
2009-08-28 16:57:18 +03:00
|
|
|
#include "clamav.h"
|
2009-09-07 18:01:43 +03:00
|
|
|
#include "others.h"
|
2009-08-25 18:54:14 +03:00
|
|
|
|
2009-09-07 18:01:43 +03:00
|
|
|
int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
|
2009-08-25 18:54:14 +03:00
|
|
|
{
|
2009-09-07 18:01:43 +03:00
|
|
|
unsigned i;
|
2018-12-03 12:40:13 -05:00
|
|
|
for (i = 0; i < bcs->count; i++) {
|
|
|
|
if (bcs->all_bcs[i].state == bc_skip)
|
|
|
|
continue;
|
|
|
|
if (bcs->all_bcs[i].state != bc_loaded &&
|
|
|
|
bcs->all_bcs[i].kind != BC_STARTUP) {
|
|
|
|
cli_warnmsg("Cannot prepare for JIT, because it has already been converted to interpreter\n");
|
|
|
|
return CL_EBYTECODE;
|
|
|
|
}
|
2009-08-25 18:54:14 +03:00
|
|
|
}
|
2014-09-22 16:02:14 -04:00
|
|
|
cli_dbgmsg("Cannot prepare for JIT, LLVM is not compiled or not linked\n");
|
2009-08-25 18:54:14 +03:00
|
|
|
return CL_EBYTECODE;
|
|
|
|
}
|
|
|
|
|
2009-09-07 18:01:43 +03:00
|
|
|
int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx, const struct cli_bc_func *func)
|
2009-08-25 18:54:14 +03:00
|
|
|
{
|
2014-07-10 18:11:49 -04:00
|
|
|
UNUSEDPARAM(bcs);
|
|
|
|
UNUSEDPARAM(ctx);
|
|
|
|
UNUSEDPARAM(func);
|
2009-08-25 18:54:14 +03:00
|
|
|
return CL_EBYTECODE;
|
|
|
|
}
|
|
|
|
|
2010-02-15 14:37:09 +02:00
|
|
|
int cli_bytecode_init_jit(struct cli_all_bc *allbc, unsigned dconfmask)
|
2009-08-25 18:54:14 +03:00
|
|
|
{
|
2014-07-10 18:11:49 -04:00
|
|
|
UNUSEDPARAM(allbc);
|
|
|
|
UNUSEDPARAM(dconfmask);
|
2009-08-25 18:54:14 +03:00
|
|
|
return CL_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-07-22 22:32:21 +03:00
|
|
|
int cli_bytecode_done_jit(struct cli_all_bc *allbc, int partial)
|
2009-08-25 18:54:14 +03:00
|
|
|
{
|
2014-07-10 18:11:49 -04:00
|
|
|
UNUSEDPARAM(allbc);
|
|
|
|
UNUSEDPARAM(partial);
|
2009-08-25 18:54:14 +03:00
|
|
|
return CL_SUCCESS;
|
|
|
|
}
|
2009-08-27 18:12:39 +03:00
|
|
|
|
2018-12-03 12:40:13 -05:00
|
|
|
void cli_bytecode_debug(int argc, char **argv)
|
|
|
|
{
|
|
|
|
/* Empty */
|
2014-07-10 18:11:49 -04:00
|
|
|
UNUSEDPARAM(argc);
|
|
|
|
UNUSEDPARAM(argv);
|
2009-08-27 18:12:39 +03:00
|
|
|
}
|
2009-08-28 16:57:18 +03:00
|
|
|
|
|
|
|
int bytecode_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2009-08-28 20:07:25 +03:00
|
|
|
|
2018-12-03 12:40:13 -05:00
|
|
|
void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx)
|
|
|
|
{
|
2010-01-27 12:07:08 +02:00
|
|
|
/* Empty */
|
2014-07-10 18:11:49 -04:00
|
|
|
UNUSEDPARAM(ctx);
|
2009-12-08 23:02:49 +02:00
|
|
|
}
|
2018-12-03 12:40:13 -05:00
|
|
|
void cli_bytecode_printversion(void)
|
|
|
|
{
|
|
|
|
printf("LLVM is not compiled or not linked\n");
|
2009-12-11 20:43:58 +02:00
|
|
|
}
|
2018-12-03 12:40:13 -05:00
|
|
|
int have_clamjit = 0;
|
2010-04-19 18:35:30 +03:00
|
|
|
void cli_printcxxver()
|
|
|
|
{
|
|
|
|
/* Empty */
|
|
|
|
}
|
2010-07-29 13:02:13 +03:00
|
|
|
void cli_detect_env_jit(struct cli_environment *env)
|
|
|
|
{
|
|
|
|
/* Empty */
|
2014-07-10 18:11:49 -04:00
|
|
|
UNUSEDPARAM(env);
|
2010-07-29 13:02:13 +03:00
|
|
|
}
|