Root/tools/upx/patches/100-lzmaonly.patch

1--- a/src/compress.cpp
2+++ b/src/compress.cpp
3@@ -41,7 +41,7 @@
4     if (len == 0)
5         return adler;
6     assert(buf != NULL);
7-#if 0
8+#if !(WITH_UCL)
9     return adler32(adler, (const Bytef *) buf, len); // zlib
10 #elif (WITH_UCL)
11     return ucl_adler32(adler, (const ucl_bytep) buf, len);
12--- a/src/conf.h
13+++ b/src/conf.h
14@@ -179,7 +179,7 @@
15 # undef __unix
16 #endif
17 
18-#if !defined(WITH_UCL)
19+#if defined(WITH_UCL)
20 # define WITH_UCL 1
21 #endif
22 #if 0 && !defined(WITH_LZMA)
23@@ -645,7 +645,11 @@
24 };
25 
26 
27+#if (WITH_UCL)
28 struct ucl_compress_config_t : public REAL_ucl_compress_config_t
29+#else
30+struct ucl_compress_config_t
31+#endif
32 {
33     void reset() { memset(this, 0xff, sizeof(*this)); }
34 };
35@@ -697,7 +701,9 @@
36 
37 struct ucl_compress_result_t
38 {
39+#if (WITH_UCL)
40     ucl_uint result[16];
41+#endif
42 
43     void reset() { memset(this, 0, sizeof(*this)); }
44 };
45--- a/src/main.cpp
46+++ b/src/main.cpp
47@@ -618,7 +618,9 @@
48         opt->method = -1;
49         opt->all_filters = true;
50         opt->filter = -1;
51+#if (WITH_UCL)
52         opt->crp.crp_ucl.m_size = 999999;
53+#endif
54         /* fallthrough */
55     case 900: // --best
56         if (!set_method(-1, 10))
57@@ -709,6 +711,7 @@
58         opt->exact = true;
59         break;
60     // compression runtime parameters
61+#if (WITH_UCL)
62     case 801:
63         getoptvar(&opt->crp.crp_ucl.c_flags, 0, 3, arg);
64         break;
65@@ -730,6 +733,7 @@
66     case 807:
67         getoptvar(&opt->crp.crp_ucl.m_size, 10000u, 999999u, arg);
68         break;
69+#endif
70     case 811:
71         getoptvar(&opt->crp.crp_lzma.pos_bits, arg);
72         break;
73--- a/src/Makefile
74+++ b/src/Makefile
75@@ -57,7 +57,10 @@
76 INCLUDES += -I$(UPX_UCLDIR)/include
77 LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
78 endif
79-LIBS += -lucl -lz
80+ifeq ($(WITH_UCL),1)
81+LIBS += -lucl
82+endif
83+LIBS += -lz
84 # you should set envvar UPX_LZMADIR to point to your unpacked LZMA SDK
85 include $(top_srcdir)/src/stub/src/c/Makevars.lzma
86 ifneq ($(UPX_LZMA_VERSION),)
87--- a/src/packer.cpp
88+++ b/src/packer.cpp
89@@ -199,6 +199,7 @@
90     if (cconf_parm)
91         cconf = *cconf_parm;
92     // cconf options
93+#if (WITH_UCL)
94     if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
95     {
96         if (opt->crp.crp_ucl.c_flags != -1)
97@@ -216,6 +217,7 @@
98             step = 0;
99 #endif
100     }
101+#endif
102     if (M_IS_LZMA(ph.method))
103     {
104         oassign(cconf.conf_lzma.pos_bits, opt->crp.crp_lzma.pos_bits);
105@@ -250,6 +252,7 @@
106     if (r != UPX_E_OK)
107         throwInternalError("compression failed");
108 
109+#if (WITH_UCL)
110     if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
111     {
112         const ucl_uint *res = ph.compress_result.result_ucl.result;
113@@ -267,6 +270,7 @@
114             assert(cconf.conf_ucl.max_match == 0 || cconf.conf_ucl.max_match >= ph.max_match_found);
115         }
116     }
117+#endif
118 
119     //printf("\nPacker::compress: %d/%d: %7d -> %7d\n", ph.method, ph.level, ph.u_len, ph.c_len);
120     if (!checkCompressionRatio(ph.u_len, ph.c_len))
121--- a/src/p_exe.cpp
122+++ b/src/p_exe.cpp
123@@ -506,7 +506,9 @@
124     Filter ft(ph.level);
125     // compress (max_match = 8192)
126     upx_compress_config_t cconf; cconf.reset();
127+#if (WITH_UCL)
128     cconf.conf_ucl.max_match = MAXMATCH;
129+#endif
130     cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
131     compressWithFilters(&ft, 32, &cconf);
132 
133--- a/src/p_ps1.cpp
134+++ b/src/p_ps1.cpp
135@@ -499,7 +499,9 @@
136 
137     // compress (max_match = 65535)
138     upx_compress_config_t cconf; cconf.reset();
139+#if (WITH_UCL)
140     cconf.conf_ucl.max_match = 65535;
141+#endif
142     cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
143     compressWithFilters(&ft, sa_cnt, &cconf);
144 
145--- a/src/p_tos.cpp
146+++ b/src/p_tos.cpp
147@@ -506,7 +506,9 @@
148     Filter ft(ph.level);
149     // compress (max_match = 65535)
150     upx_compress_config_t cconf; cconf.reset();
151+#if (WITH_UCL)
152     cconf.conf_ucl.max_match = 65535;
153+#endif
154     cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
155     compressWithFilters(&ft, 512, &cconf);
156 
157

Archive Download this file



interactive