Added support for LZMA SDK 4.49. Compiles, but pretty much untested.

This commit is contained in:
Markus F.X.J. Oberhumer 2007-07-08 13:58:08 +02:00
parent abc71baaa6
commit 3635c00143
13 changed files with 126 additions and 49 deletions

View File

@ -55,9 +55,15 @@ INCLUDES += -I$(UPX_UCLDIR)/include
LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
endif
LIBS += -lucl -lz
# you should set envvar UPX_LZMADIR to point to your unpacked lzma443.tar.bz2
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
DEFS += -DWITH_LZMA=1
# you should set envvar UPX_LZMADIR to point to your unpacked LZMA SDK lzma443.tar.bz2
# NOTE: only version 4.43 is currently sufficiently tested !
ifneq ($(wildcard $(UPX_LZMADIR)/CPP/7zip/.),)
UPX_LZMA_VERSION = 0x449
else ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
UPX_LZMA_VERSION = 0x443
endif
ifneq ($(UPX_LZMA_VERSION),)
DEFS += -DWITH_LZMA=$(UPX_LZMA_VERSION)
INCLUDES += -I$(UPX_LZMADIR)
endif
@ -86,9 +92,11 @@ endif
ifeq ($(USE_GNUC),1)
##compress_lzma$(objext) : CXXFLAGS += -O3 -fomit-frame-pointer
compress_lzma$(objext) : CXXFLAGS += -Wno-cast-qual
ifeq ($(UPX_LZMA_VERSION),0x443)
compress_lzma$(objext) : CXXFLAGS += -Wno-non-virtual-dtor
compress_lzma$(objext) : CXXFLAGS += -Wno-shadow
compress_lzma$(objext) : CXXFLAGS += -Wno-unused
endif
# needed for gcc-4.3:
compress_lzma$(objext) : CXXFLAGS += -Wno-error
endif

View File

@ -102,9 +102,15 @@ int compress_lzma_dummy = 0;
#undef _WIN32_WCE
#undef COMPRESS_MF_MT
#undef _NO_EXCEPTIONS
#include "C/Common/MyInitGuid.h"
//#include "C/7zip/Compress/LZMA/LZMADecoder.h"
#include "C/7zip/Compress/LZMA/LZMAEncoder.h"
#if (WITH_LZMA >= 0x449)
# define INITGUID 1
//# include "CPP/7zip/Compress/LZMA/LZMADecoder.h"
# include "CPP/7zip/Compress/LZMA/LZMAEncoder.h"
#else
# include "C/Common/MyInitGuid.h"
//# include "C/7zip/Compress/LZMA/LZMADecoder.h"
# include "C/7zip/Compress/LZMA/LZMAEncoder.h"
#endif
namespace MyLzma {
@ -174,16 +180,29 @@ STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outS
# pragma warning(disable: 424) // #424: extra ";" ignored
#endif
#include "C/Common/Alloc.cpp"
#include "C/Common/CRC.cpp"
//#include "C/7zip/Common/InBuffer.cpp"
#include "C/7zip/Common/OutBuffer.cpp"
#include "C/7zip/Common/StreamUtils.cpp"
#include "C/7zip/Compress/LZ/LZInWindow.cpp"
//#include "C/7zip/Compress/LZ/LZOutWindow.cpp"
//#include "C/7zip/Compress/LZMA/LZMADecoder.cpp"
#include "C/7zip/Compress/LZMA/LZMAEncoder.cpp"
#include "C/7zip/Compress/RangeCoder/RangeCoderBit.cpp"
#if (WITH_LZMA >= 0x449)
# include "C/Alloc.c"
# include "C/7zCrc.c"
# include "C/Compress/Lz/MatchFinder.c"
//# include "CPP/7zip/Common/InBuffer.cpp"
# include "CPP/7zip/Common/OutBuffer.cpp"
# include "CPP/7zip/Common/StreamUtils.cpp"
//# include "CPP/7zip/Compress/LZ/LZOutWindow.cpp"
//# include "CPP/7zip/Compress/LZMA/LZMADecoder.cpp"
# include "CPP/7zip/Compress/LZMA/LZMAEncoder.cpp"
# include "CPP/7zip/Compress/RangeCoder/RangeCoderBit.cpp"
#else
# include "C/Common/Alloc.cpp"
# include "C/Common/CRC.cpp"
//# include "C/7zip/Common/InBuffer.cpp"
# include "C/7zip/Common/OutBuffer.cpp"
# include "C/7zip/Common/StreamUtils.cpp"
# include "C/7zip/Compress/LZ/LZInWindow.cpp"
//# include "C/7zip/Compress/LZ/LZOutWindow.cpp"
//# include "C/7zip/Compress/LZMA/LZMADecoder.cpp"
# include "C/7zip/Compress/LZMA/LZMAEncoder.cpp"
# include "C/7zip/Compress/RangeCoder/RangeCoderBit.cpp"
#endif
#undef RC_NORMALIZE
@ -224,7 +243,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
PROPVARIANT pr[8];
pr[0].vt = pr[1].vt = pr[2].vt = pr[3].vt = VT_UI4;
pr[4].vt = pr[5].vt = pr[6].vt = VT_UI4;
pr[7].vt = VT_BSTR;
unsigned nprops = 7;
// setup defaults
pr[0].uintVal = 2; // 0 .. 4
@ -236,9 +255,11 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
pr[6].uintVal = 0;
#ifdef COMPRESS_MF_BT4
static wchar_t matchfinder[] = L"BT4";
#endif
assert(NCompress::NLZMA::FindMatchFinder(matchfinder) >= 0);
pr[7].bstrVal = matchfinder;
pr[nprops].vt = VT_BSTR;
pr[nprops].bstrVal = matchfinder;
nprops++;
#endif
#if 1
pr[0].uintVal = lzma_compress_config_t::pos_bits_t::default_value_c;
pr[1].uintVal = lzma_compress_config_t::lit_pos_bits_t::default_value_c;
@ -349,7 +370,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
# error
#endif
if (enc.SetCoderProperties(propIDs, pr, 8) != S_OK)
if (enc.SetCoderProperties(propIDs, pr, nprops) != S_OK)
goto error;
if (enc.WriteCoderProperties(&os) != S_OK)
goto error;
@ -407,8 +428,13 @@ error:
#undef _LZMA_OUT_READ
#undef _LZMA_PROB32
#undef _LZMA_LOC_OPT
#include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
#include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
#if (WITH_LZMA >= 0x449)
# include "C/Compress/Lzma/LzmaDecode.h"
# include "C/Compress/Lzma/LzmaDecode.c"
#else
# include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
# include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
#endif
int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
@ -519,9 +545,14 @@ int upx_lzma_test_overlap ( const upx_bytep buf,
const char *upx_lzma_version_string(void)
{
// FIXME
// return NULL;
#if (WITH_LZMA == 0x449)
return "4.49";
#elif (WITH_LZMA == 0x443)
return "4.43";
#else
# error "unknown version"
return NULL;
#endif
}

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -37,6 +38,7 @@ $c += -Os -fomit-frame-pointer
$c += -fno-unit-at-a-time
$c += -ffunction-sections
$c += -fwrapv
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -40,6 +41,7 @@ $c += -Os -fomit-frame-pointer
$c += -fno-unit-at-a-time
$c += -ffunction-sections
$c += -fwrapv
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -38,6 +39,7 @@ $c += -Os -fomit-frame-pointer
$c += -fno-unit-at-a-time
$c += -ffunction-sections
$c += -fwrapv
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src

View File

@ -1,9 +1,3 @@
#
# highly experimental support for i086 using Open Watcom C/C++
#
##export WATCOM ?= /opt/cc-i386-linux/watcom/open-watcom-1.6
#
MAKEFLAGS += -rR
.SUFFIXES:
.SECONDEXPANSION:
@ -18,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
ifneq ($(wildcard $(WATCOM)/binl/wcl),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -94,6 +89,7 @@ lzma_d_c% : tc_bfdname =
c := tc.arch-i086.gcc
$c += -MF /dev/null
$c += -Wall -W
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src
@ -105,7 +101,12 @@ $c += -ms
$c += -O1 -1
$c += -w
$c += -D__INT_MAX__=32767
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
ifeq ($(UPX_LZMA_VERSION),0x449)
$c += -I$(subst \,/,$(call winedir_w,$(UPX_LZMADIR)/C/Compress/Lzma))
else
$c += -I$(subst \,/,$(call winedir_w,$(UPX_LZMADIR)/C/7zip/Compress/LZMA_C))
endif
$c += -I$(top_srcdir)/src
endif
@ -113,14 +114,16 @@ endif
# http://www.digitalmars.com/download/freecompiler.html
ifneq ($(wildcard $(DM849DIR)/bin/dmc.exe),)
c := tc.method-lzma.dmc
$c = $(WINEENV) CFLAGS='$(DMC)' wine cmd.exe /c tmp/dmc.bat
$c = $(WINEENV) DMC1='$(DMC1)' DMC2='$(DMC2)' wine cmd.exe /c tmp/dmc.bat
$c += -ms -R
$c += -NS
$c += -w- -w7 -r
DMC := -o -0
DMC += -D__INT_MAX__=32767
DMC += -I$(call winedir_w,$(UPX_LZMADIR))
DMC += -I$(call winedir_w,$(top_srcdir)/src)
$c += @DMC1 @DMC2
DMC1 := -o -0
DMC1 += -D__INT_MAX__=32767
DMC1 += -DWITH_LZMA=$(UPX_LZMA_VERSION)
DMC2 := -I$(call winedir_w,$(UPX_LZMADIR))
DMC2 += -I$(call winedir_w,$(top_srcdir)/src)
endif
# Visual C/C++ 1.52 (8.00c)
@ -133,6 +136,7 @@ $c += -O2 -Gf -Gs -G0
$c += -W4
CL := -nologo
CL += -D__INT_MAX__=32767
CL += -DWITH_LZMA=$(UPX_LZMA_VERSION)
CL += -I$(call winedir_s,$(UPX_LZMADIR))
CL += -I$(call winedir_s,$(top_srcdir)/src)
endif
@ -147,12 +151,13 @@ $c += -zm -zc
$c += -os -s -0 -d0
$c += -w5 -we -fr=/dev/null
$c += -D__INT_MAX__=32767
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src
endif
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
ifneq ($(UPX_LZMA_VERSION),)
ifneq ($(wildcard $(WATCOM)/binl/wcl),)
lzma_d_c%.S : tmp/lzma_d_c%.i cleanasm.py $(MAKEFILE_LIST)

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -36,6 +37,7 @@ $c = $(tc.i386-linux.elf.gcc)
$c += -fno-unit-at-a-time
$c += -ffunction-sections
$c += -fwrapv
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -38,6 +39,7 @@ $c += -Os -fomit-frame-pointer
$c += -fno-unit-at-a-time
$c += -ffunction-sections
$c += -fwrapv
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -38,6 +39,7 @@ $c += -Os -fomit-frame-pointer
$c += -fno-unit-at-a-time
$c += -ffunction-sections
$c += -fwrapv
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -69,7 +70,8 @@ $c += -ffixed-30
else
$(error unknown gcc version: $(firstword $($c)))
endif
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
ifneq ($(UPX_LZMA_VERSION),)
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
endif
$c += -I$(top_srcdir)/src
@ -100,7 +102,7 @@ define __test_stub_compression
@ls -l $1.tmp.*
endef
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
ifneq ($(UPX_LZMA_VERSION),)
test-stub-compression: tc_list = mipsel.r3000-ps1 default
test-stub-compression: lzma_d_cf.S lzma_d_cs.S
$(call __test_stub_compression,tmp/lzma_d_cs.out,tmp/lzma_d_cs.o)

View File

@ -12,7 +12,8 @@ include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
vpath %.c $(top_srcdir)/src/stub/src/c
STUBS =
ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
include $(top_srcdir)/src/stub/src/c/Makedefs.lzma
ifneq ($(UPX_LZMA_VERSION),)
STUBS += lzma_d_cf.S lzma_d_cs.S
endif
@ -38,6 +39,7 @@ $c += -Os -fomit-frame-pointer
$c += -fno-unit-at-a-time
$c += -ffunction-sections
$c += -fwrapv
$c += -DWITH_LZMA=$(UPX_LZMA_VERSION)
$c += -I$(UPX_LZMADIR)
$c += -I$(top_srcdir)/src

View File

@ -0,0 +1,6 @@
# you should set envvar UPX_LZMADIR to point to your unpacked LZMA SDK
ifneq ($(wildcard $(UPX_LZMADIR)/CPP/7zip/.),)
UPX_LZMA_VERSION = 0x449
else ifneq ($(wildcard $(UPX_LZMADIR)/C/7zip/.),)
UPX_LZMA_VERSION = 0x443
endif

View File

@ -48,6 +48,9 @@
# define _LZMA_UINT32_IS_ULONG 1
# endif
#endif
#if !defined(_LZMA_NO_SYSTEM_SIZE_T)
# define _LZMA_NO_SYSTEM_SIZE_T 1
#endif
#if 0
@ -66,7 +69,11 @@ ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(CLzmaDecoderState) == 16)
#if (ACC_CC_BORLANDC)
#include "LzmaDecode.h"
#else
#include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
#if (WITH_LZMA >= 0x449)
# include "C/Compress/Lzma/LzmaDecode.h"
#else
# include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
#endif
#endif
#undef CLzmaDecoderState
#undef LzmaDecodeProperties
@ -93,7 +100,11 @@ int LzmaDecode(CLzmaDecoderState *, const unsigned char *, SizeT, SizeT *, unsig
#if (ACC_CC_BORLANDC)
#include "LzmaDecode.c"
#else
#include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
#if (WITH_LZMA >= 0x449)
# include "C/Compress/Lzma/LzmaDecode.c"
#else
# include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
#endif
#endif
#undef char
#undef CLzmaDecoderState