mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-11-01 08:30:53 +00:00
Print better error message when wrong function is called.
This commit is contained in:
parent
6bd858662e
commit
d2171abf39
1 changed files with 9 additions and 3 deletions
|
|
@ -45,6 +45,7 @@
|
||||||
#include "llvm/System/Threading.h"
|
#include "llvm/System/Threading.h"
|
||||||
#include "llvm/Target/TargetSelect.h"
|
#include "llvm/Target/TargetSelect.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
|
#include "llvm/Target/TargetOptions.h"
|
||||||
#include "llvm/Support/TargetFolder.h"
|
#include "llvm/Support/TargetFolder.h"
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
|
|
@ -978,6 +979,9 @@ int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx,
|
||||||
void *code = bcs->engine->compiledFunctions[func];
|
void *code = bcs->engine->compiledFunctions[func];
|
||||||
if (!code) {
|
if (!code) {
|
||||||
errs() << MODULE << "Unable to find compiled function\n";
|
errs() << MODULE << "Unable to find compiled function\n";
|
||||||
|
if (func->numArgs)
|
||||||
|
errs() << MODULE << "Function has "
|
||||||
|
<< (unsigned)func->numArgs << " arguments, it must have 0 to be called as entrypoint\n";
|
||||||
return CL_EBYTECODE;
|
return CL_EBYTECODE;
|
||||||
}
|
}
|
||||||
// execute;
|
// execute;
|
||||||
|
|
@ -989,20 +993,19 @@ int cli_vm_execute_jit(const struct cli_all_bc *bcs, struct cli_bc_ctx *ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
errs() << "\n";
|
errs() << "\n";
|
||||||
errs().changeColor(raw_ostream::RED, true) << MODULE
|
errs().changeColor(raw_ostream::RED, true) << MODULE
|
||||||
<< "*** JITed code intercepted runtime error!\n";
|
<< "*** JITed code intercepted runtime error!\n";
|
||||||
errs().resetColor();
|
errs().resetColor();
|
||||||
return CL_EBYTECODE;
|
return CL_EBYTECODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
|
int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
|
||||||
{
|
{
|
||||||
if (!bcs->engine)
|
if (!bcs->engine)
|
||||||
return CL_EBYTECODE;
|
return CL_EBYTECODE;
|
||||||
jmp_buf env;
|
jmp_buf env;
|
||||||
// setup exception handler to longjmp back here
|
// setup exception handler to longjmp back here
|
||||||
ExceptionReturn.set(&env);
|
ExceptionReturn.set(&env);
|
||||||
if (setjmp(env) != 0) {
|
if (setjmp(env) != 0) {
|
||||||
errs() << "\n";
|
errs() << "\n";
|
||||||
errs().changeColor(raw_ostream::RED, true) << MODULE
|
errs().changeColor(raw_ostream::RED, true) << MODULE
|
||||||
|
|
@ -1119,6 +1122,9 @@ int bytecode_init(void)
|
||||||
#endif
|
#endif
|
||||||
atexit(do_shutdown);
|
atexit(do_shutdown);
|
||||||
|
|
||||||
|
#ifdef CL_DEBUG
|
||||||
|
llvm::JITEmitDebugInfo = true;
|
||||||
|
#endif
|
||||||
llvm_start_multithreaded();
|
llvm_start_multithreaded();
|
||||||
|
|
||||||
// If we have a native target, initialize it to ensure it is linked in and
|
// If we have a native target, initialize it to ensure it is linked in and
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue