Commit graph

136 commits

Author SHA1 Message Date
Kevin Lin
2c859ec754 bb#11414 - integrate patch for LLVM 3.6 support 2015-10-29 17:48:45 -04:00
Mickey Sola
46a35abe56 mass update of copyright headers 2015-09-17 13:41:26 -04:00
Kevin Lin
99aeada848 bb#11147 - reverted change overwritten with branch merging
ref commit "rolled back changes from bb#8352 - fixes ppc unit tests"
2014-10-17 11:06:30 -04:00
Kevin Lin
4a40b53a1c bb#11146 - applied patch for system LLVM 3.5.0 support 2014-10-17 10:49:06 -04:00
Kevin Lin
deafd8fa94 bb#11112 - fixed custom pass initialization when using LLVM 2.9 2014-09-29 17:32:00 -04:00
Kevin Lin
ccc94d9003 added kfreebsd* to target OS
hardcoded embedded llvm version to 2.8
changed supported system-llvm 2.9 -> 3.4.1
minor compilation changes
2014-07-25 14:19:40 -04:00
Kevin Lin
b331b610bf added bytecode2llvm conversion for OP_BC_ICMP_SLE instruction 2014-07-25 12:55:01 -04:00
Kevin Lin
9f8df4ae4b unified bytecode version macros into LLVM_VERSION macro 2014-07-25 12:47:18 -04:00
Kevin Lin
fb2b05cb4a bytecode: merged in changes since 0.98.1 2014-07-25 12:29:08 -04:00
Kevin Lin
34d8b8cfc7 bb#10981 - applied LLVM 3.1-3.4 patch for testing
Conflicts:

	libclamav/c++/Makefile.am
	libclamav/c++/bytecode2llvm.cpp
2014-07-25 12:26:04 -04:00
Shawn Webb
60d8d2c352 Move all the crypto API to clamav.h 2014-07-01 19:38:01 -04:00
Kevin Lin
09317562d9 rolled back changes from bb#8352 - fixes ppc unit tests 2014-06-02 10:52:01 -04:00
Shawn Webb
b2e7c931d0 Use OpenSSL for hashing. 2014-02-08 00:31:12 -05:00
Kevin Lin
51abf545de bb#8352 - converted serveral llvm intrinsics functions to 64-bit from 32-bit to correct type mismatch with bytecode compiler 2013-10-21 14:05:31 -07:00
David Raynor
3609e2d7b8 bytecode: cid #10622 2013-08-15 16:42:19 -04:00
David Raynor
9e1f0d90ad bytecode: refactored cleanup on error exit paths, cid #10509 & #10510 2013-08-15 16:23:44 -04:00
David Raynor
3aca6c4afe JIT: some better cleanup on error returns (also cid #10509 & #10510 & #10512), though these paths should lead to exit anyway 2013-08-09 18:33:06 -04:00
David Raynor
bebd86a60b bb#5343 2012-06-22 16:55:29 -04:00
Török Edvin
872d0a90d6 more LLVM 3.0 API changes 2011-10-26 00:05:17 +03:00
Török Edvin
59f1b78b51 Support LLVM 3.0 API 2011-09-30 15:32:16 +03:00
Török Edvin
bb5572cbe1 bytecode_watchdog: fix use of unaddressable data
If the watchdog thread is sleeping on a watchdog_item and
vm_execute_jit calls watchdog_disarm and returns before the watchdog wakes up,
then the watchdog thread will wake up and try to use the now uninitialized
item->abs_timeout.

Fix this by adding an in_use flag, and another condition variable.
watchdog_disarm now wakes the watchdog thread,
and waits till it releases the item.

Thanks to Michael Scheidell for providing feedback on this bug.
2011-06-30 14:28:44 +03:00
Török Edvin
b6187b6330 attempt to fix win32 build 2011-05-06 21:26:55 +03:00
Török Edvin
0c79cc5529 Support building with external LLVM 2.9, and drop support for building with external 2.8
Internal version is an LLVM 2.8 with 2 patches backported from LLVM 2.9 to fix a
crash on AVX chips.
So drop support for building with external LLVM 2.8, and add support for
building with external LLVM 2.9 instead.

Caveat:
 stack smashing protection is broken on LLVM 2.9 so it is disabled

Example on Debian:
apt-get install llvm-2.9-dev
./configure --enable-llvm --with-system-llvm=/usr/bin/llvm-config-2.9
2011-05-06 16:16:33 +03:00
Török Edvin
e51fc0581e bytecode: reuse watchdog thread
Don't create a new watchdog thread everytime a bytecode is run.
Instead try to reuse a previously create watchdog thread.
Watchdog thread will idle for a max of 10s, and then exit, and new watchdog being
created as needed.
2011-04-15 15:06:11 +03:00
Török Edvin
ab402e6aae Speed up bytecode load.
Don't codegen bytecodes that have a functionality_level test in entrypoint
that would prevent them from running.
2011-01-20 16:10:30 +02:00
aCaB
26b86d8d8e add missing EOL 2011-01-20 15:04:51 +01:00
Török Edvin
ce2386732a Fix build with external LLVM28.
It declares those 2 initialize functions as C linkage, so make sure we match it
(in our version they are not declared at all).
2010-11-12 09:53:09 +02:00
Török Edvin
e92dda94ce chkstk: another try. 2010-11-10 16:21:48 +02:00
Török Edvin
3d8ca9f6aa chkstk 2010-11-10 16:19:59 +02:00
Török Edvin
ca3e6c5860 I'm told _chkstk needs to be called as __chkstk on Win64.
Same to the backend (added _), but if I want the linker to find it, I need to do
it like this. Hope it works.
2010-11-10 16:00:39 +02:00
Török Edvin
3a35520bf9 Fix recently introduced ScopedExceptionHandler.
can't use setjmp inside a function that is not the parent.
just write and use some macros.

Otherwise the "else" from handler.Set() was never reached, which caused a unit
test to fail.
2010-11-10 14:53:39 +02:00
Török Edvin
29553b8e26 bytecode2llvm: convert errs() to cli_{err,warn,dbg} so they are not lost. 2010-11-10 14:21:51 +02:00
Török Edvin
4955886036 Fix win32 bytecode: allow _chkstk.
Win32 needs this when stack >4k, this was the message that was logged to stderr
previously, causing the crash.
2010-11-10 14:21:51 +02:00
Török Edvin
f62d53980a bytecode2llvm: make sure we don't return from a NORETURN function. 2010-11-10 14:21:50 +02:00
Török Edvin
162c2e431b bytecode2llvm: don't crash when stderr is unavailable.
Writing to errs() when stderr is not open results in write Error getting flagged
in LLVM's raw_fd_ostream, which results in a call to llvm_report_error.
However since jmp_buf is not valid anymore we end up crashing on longjmp.

Fix:
 - reset the thread-local recovery (jmp_buf*) to NULL when exiting the block
 where it is valid
 - clear errors on errs() on shutdown to avoid the report_fatal_error
2010-11-10 14:21:47 +02:00
Török Edvin
dccafff069 define LLVM28, since we are using that now. 2010-11-06 15:50:31 +02:00
Török Edvin
a7cf187a0c Make cl_load thread safe (bb #2333).
Parallel cl_load() crash (bb #2333).
Reason is twofold:
 - cache.c had 2 'static' global variables, thus trying to initialize same cache
 from multiple threads
  - bytecode2llvm.cpp: something in LLVM 2.7 is crashing when loading in
  parallel

Fix is to drop the 'static' on the variable (cache is per engine already).
This also fixes a potential memory leak in clamd!

The other part of the fix is to turn on the mutex around bytecode compilation
always. We don't call cl_load in parallel, so this doesn't affect clamd, but
some may need to call cl_load in parallel.
2010-11-04 21:53:03 +02:00
Török Edvin
49eb01089a Make sure Functions[i] is initialized, and not used as NULL. 2010-10-22 12:31:53 +03:00
Török Edvin
34306523a1 Fix startup.cbc load (bb #2330).
BC_STARTUP is already prepared with JIT, so Functions[i] is garbage,
don't attempt to codegen it.
2010-10-18 13:45:20 +03:00
Török Edvin
dec93ea86f Fix bytecode and autoitea06 for Apple-style universal builds (bb #2030)
Bytecode needs to enable both PPC and X86, link in all targets,
and autoit needs fpu_endian == cpu_endian for universal builds.
2010-10-18 11:27:06 +03:00
Török Edvin
1755adf042 Fix build with internal LLVM. 2010-09-28 16:43:25 +03:00
Török Edvin
45ba739216 Fix constructors for LLVM 2.8. 2010-09-28 14:45:04 +03:00
Török Edvin
b22af13f7a Merge branch 'llvm2.8'
* llvm2.8:
  Regenerate configure and Makefile.
  LLVM 2.8 changed llvm.mem{cpy,move,set}.* to take 5 arguments.
  LLVM 2.8 API update.
  Don't cast the iterator directly.
  Use CallSite instead of CI->getOperand.
  Support building with external LLVM 2.8.

Conflicts:
	libclamav/c++/Makefile.in
	libclamav/c++/bytecode2llvm.cpp
	libclamav/c++/configure
2010-09-28 14:28:59 +03:00
Török Edvin
744c40d142 LLVM 2.8 changed llvm.mem{cpy,move,set}.* to take 5 arguments.
Use AutoUpgrade to upgrade these calls.
Intrinsic::getDeclaration can't be used because in 2.7 it needs 1 type,
in 2.8 it needs 2/3, and there is no function to query how many it needs.
2010-09-28 14:25:22 +03:00
Török Edvin
e3a5450335 LLVM 2.8 API update.
Some APIs got renamed, provide macro wrappers.
2010-09-28 14:25:22 +03:00
Török Edvin
1300b00244 Don't cast the iterator directly.
LLVM 2.8 doesn't allow this, first dereference, then cast.
This is compatible with 2.7.
2010-09-28 14:25:22 +03:00
Török Edvin
c0a306b291 Fix valgrind warning introduced in clamav-0.96.3-6-g6e52ce6.
It reports some possible lost memory in llvm::sys::Timer, since by default
timer is not used add a wrapper so it only constructs Timer as necessary.
2010-09-28 14:22:41 +03:00
Török Edvin
6e52ce67c7 Improve bytecode load time and optimization (bb #2278).
Avoid quadratic load times: run module passes at the end, and run
rtcheck inserter at the end also.

Also optimize away some simple situations that the compiler couldn't,
like result of __is_bigendian() which is a constant at load time (but not at
compile time).
If we would have run LLVM's -O1 optimizers these would have been
optimized already, but we don't do that for 2 reasons:
 - optimizations may introduce new bugs
 - may take a bit longer time
Just run some simple transforms, and some custom optimizations for the bigendian
case.
2010-09-21 20:24:06 +03:00
Török Edvin
3eef86ee9f Workaround crash due to gcc stack alignment requirements (bb #2270).
GCC (4.4 at least) requires and creates functions with 16-byte stack alignment
on 32-bit Linux too.
If they happen to use SSE instructions they will crash if incoming stack
alignment is not 16-byte.

LLVM claims that 4-byte stack alignment is the standard, and it only aligns to
4-byte, hence the crash. Apparently older versions of GCC/glibc would crash
if it set alignment to 16-byte.

But since the oldest GCC we support is 4.1.2, and disable LLVM on anything older
just set stack alignment to 16-byte for all functions. LLVM will realign stack
as needed. To be safe turn this on only on Linux.

This should really be fixed by either GCC or LLVM, but until that happens (see
LLVM PR8152) lets use this workaround.
2010-09-15 13:19:48 +03:00
Török Edvin
cb1260cc8e Fix __bzero on darwin 10.
LLVM calls __bzero directly which is not allowed by libclamav.
Provide wrapper.
2010-09-10 18:03:11 +03:00