Line | Count | Source |
1 | | /* conf.h -- primary configuration |
2 | | |
3 | | This file is part of the UPX executable compressor. |
4 | | |
5 | | Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer |
6 | | Copyright (C) 1996-2025 Laszlo Molnar |
7 | | All Rights Reserved. |
8 | | |
9 | | UPX and the UCL library are free software; you can redistribute them |
10 | | and/or modify them under the terms of the GNU General Public License as |
11 | | published by the Free Software Foundation; either version 2 of |
12 | | the License, or (at your option) any later version. |
13 | | |
14 | | This program is distributed in the hope that it will be useful, |
15 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | GNU General Public License for more details. |
18 | | |
19 | | You should have received a copy of the GNU General Public License |
20 | | along with this program; see the file COPYING. |
21 | | If not, write to the Free Software Foundation, Inc., |
22 | | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
23 | | |
24 | | Markus F.X.J. Oberhumer Laszlo Molnar |
25 | | <markus@oberhumer.com> <ezerotven+github@gmail.com> |
26 | | */ |
27 | | |
28 | | #pragma once |
29 | | |
30 | | /************************************************************************* |
31 | | // init |
32 | | **************************************************************************/ |
33 | | |
34 | | #include "util/system_headers.h" |
35 | | #include "util/system_undefs.h" |
36 | | #include "version.h" |
37 | | |
38 | | #if !defined(__has_attribute) |
39 | | #define __has_attribute(x) 0 |
40 | | #endif |
41 | | #if !defined(__has_builtin) |
42 | | #define __has_builtin(x) 0 |
43 | | #endif |
44 | | #if !defined(__has_declspec_attribute) |
45 | | #define __has_declspec_attribute(x) 0 |
46 | | #endif |
47 | | #if !defined(__has_feature) |
48 | | #define __has_feature(x) 0 |
49 | | #endif |
50 | | #if !defined(__has_include) |
51 | | #define __has_include(x) 0 |
52 | | #endif |
53 | | #if !defined(__has_warning) |
54 | | #define __has_warning(x) 0 |
55 | | #endif |
56 | | |
57 | | // reserve name "upx" for namespace |
58 | | namespace upx {} |
59 | | |
60 | | // check compiler core |
61 | | static_assert(CHAR_BIT == 8); |
62 | | static_assert(sizeof(short) == 2); |
63 | | static_assert(sizeof(int) == 4); |
64 | | static_assert(sizeof(long long) == 8); |
65 | | // check sane compiler mandatory flags |
66 | | static_assert(-1 == ~0); // two's complement - see https://wg21.link/P0907R4 |
67 | | static_assert(0u - 1 == ~0u); // two's complement - see https://wg21.link/P0907R4 |
68 | | static_assert((1u << 31) << 1 == 0); |
69 | | static_assert(((int) (1u << 31)) >> 31 == -1); // arithmetic right shift |
70 | | static_assert((-1) >> 31 == -1); // arithmetic right shift |
71 | | static_assert(CHAR_MAX == 255); // -funsigned-char |
72 | | static_assert((char) (-1) == 255); // -funsigned-char |
73 | | |
74 | | // disable some more strict warnings |
75 | | #if defined(__clang__) && __has_warning("-Wunnecessary-virtual-specifier") |
76 | | #pragma clang diagnostic ignored "-Wunnecessary-virtual-specifier" |
77 | | #endif |
78 | | // enable some more strict warnings for Git developer builds |
79 | | #if defined(UPX_CONFIG_DISABLE_WSTRICT) && (UPX_CONFIG_DISABLE_WSTRICT + 0 == 0) |
80 | | #if defined(UPX_CONFIG_DISABLE_WERROR) && (UPX_CONFIG_DISABLE_WERROR + 0 == 0) |
81 | | #if (ACC_CC_MSC) |
82 | | #pragma warning(error : 4714) // W4: function marked as __forceinline not inlined |
83 | | #endif |
84 | | #if (ACC_CC_CLANG >= 0x0b0000) |
85 | | #pragma clang diagnostic error "-Wsuggest-override" |
86 | | #elif (ACC_CC_GNUC >= 0x0a0000) |
87 | | // don't enable before gcc-10 because of gcc bug #78010 |
88 | | #pragma GCC diagnostic error "-Wsuggest-override" |
89 | | #endif |
90 | | #if (ACC_CC_CLANG >= 0x080000) |
91 | | // don't enable before clang-8 because of <stddef.h> issues |
92 | | #pragma clang diagnostic error "-Wzero-as-null-pointer-constant" |
93 | | #elif (ACC_CC_GNUC >= 0x040700) && defined(__GLIBC__) |
94 | | // Some non-GLIBC toolchains do not use 'nullptr' everywhere when C++: |
95 | | // openwrt-sdk-x86-64_gcc-11.2.0_musl.Linux-x86_64/staging_dir/ |
96 | | // toolchain-x86_64_gcc-11.2.0_musl/include/fortify/stdlib.h: |
97 | | // 51:32: error: zero as null pointer constant |
98 | | #pragma GCC diagnostic error "-Wzero-as-null-pointer-constant" |
99 | | #endif |
100 | | #endif // UPX_CONFIG_DISABLE_WERROR |
101 | | #endif // UPX_CONFIG_DISABLE_WSTRICT |
102 | | |
103 | | // upx_is_constant_evaluated |
104 | | #if __cplusplus >= 202002L // C++20 |
105 | | #define upx_is_constant_evaluated std::is_constant_evaluated |
106 | | #elif __has_builtin(__builtin_is_constant_evaluated) // clang-9, gcc-10 |
107 | 33.4M | #define upx_is_constant_evaluated __builtin_is_constant_evaluated |
108 | | #elif (ACC_CC_GNUC >= 0x090000) && 1 // gcc-9 |
109 | | #define upx_is_constant_evaluated __builtin_is_constant_evaluated |
110 | | #endif |
111 | | |
112 | | // multithreading (UPX currently does not use multithreading) |
113 | | #if (WITH_THREADS) |
114 | | #define upx_thread_local thread_local |
115 | | #define upx_std_atomic(Type) std::atomic<Type> |
116 | | #define upx_std_once_flag std::once_flag |
117 | | #define upx_std_call_once std::call_once |
118 | | #else |
119 | | #define upx_thread_local /*empty*/ |
120 | | #define upx_std_atomic(Type) Type |
121 | | #define upx_std_once_flag upx_std_atomic(size_t) |
122 | | template <class NoexceptCallable> |
123 | 2.68M | inline void upx_std_call_once(upx_std_once_flag &flag, NoexceptCallable &&f) noexcept { |
124 | 2.68M | if (__acc_unlikely(!flag)) { |
125 | 3 | flag = 1; |
126 | 3 | f(); |
127 | 3 | } |
128 | 2.68M | } filter.cpp:void upx_std_call_once<FilterImpl::getFilter(int)::$_0>(unsigned long&, FilterImpl::getFilter(int)::$_0&&) Line | Count | Source | 123 | 943 | inline void upx_std_call_once(upx_std_once_flag &flag, NoexceptCallable &&f) noexcept { | 124 | 943 | if (__acc_unlikely(!flag)) { | 125 | 1 | flag = 1; | 126 | 1 | f(); | 127 | 1 | } | 128 | 943 | } |
Unexecuted instantiation: packer.cpp:void upx_std_call_once<getIdentstr(unsigned int*, int)::$_0>(unsigned long&, getIdentstr(unsigned int*, int)::$_0&&) void upx_std_call_once<void (&)() noexcept>(unsigned long&, void (&)() noexcept) Line | Count | Source | 123 | 2.68M | inline void upx_std_call_once(upx_std_once_flag &flag, NoexceptCallable &&f) noexcept { | 124 | 2.68M | if (__acc_unlikely(!flag)) { | 125 | 2 | flag = 1; | 126 | 2 | f(); | 127 | 2 | } | 128 | 2.68M | } |
|
129 | | #endif // WITH_THREADS |
130 | | |
131 | | // <type_traits> upx_is_integral is overloaded for BE16 & friends; see bele.h |
132 | | template <class T> |
133 | | struct upx_is_integral : public std::is_integral<T> {}; |
134 | | template <class T> |
135 | | inline constexpr bool upx_is_integral_v = upx_is_integral<T>::value; |
136 | | |
137 | | #if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__) |
138 | | // horrible hack for broken compiler / ABI |
139 | | #define upx_fake_alignas_1 __attribute__((__aligned__(1), __packed__)) |
140 | | #define upx_fake_alignas_2 __attribute__((__aligned__(2))) |
141 | | #define upx_fake_alignas_4 __attribute__((__aligned__(2))) // object file maximum 2 ??? |
142 | | #define upx_fake_alignas_16 __attribute__((__aligned__(2))) // object file maximum 2 ??? |
143 | | #define upx_fake_alignas__(x) upx_fake_alignas_##x |
144 | | #define alignas(x) upx_fake_alignas__(x) |
145 | | #define upx_alignas_max upx_fake_alignas_2 |
146 | | #endif |
147 | | #ifndef upx_alignas_max |
148 | 11.8k | #define upx_alignas_max alignas(std::max_align_t) |
149 | | #endif |
150 | | |
151 | | /************************************************************************* |
152 | | // core |
153 | | **************************************************************************/ |
154 | | |
155 | | // protect against integer overflows and malicious header fields |
156 | | // see C 11 standard, Annex K |
157 | | // |
158 | | // this limits uncompressed_size to about 682 MiB (715_128_832 bytes) |
159 | | typedef size_t upx_rsize_t; |
160 | 384k | #define UPX_RSIZE_MAX UPX_RSIZE_MAX_MEM |
161 | 384k | #define UPX_RSIZE_MAX_MEM (768 * 1024 * 1024) // DO NOT CHANGE !!! |
162 | | #define UPX_RSIZE_MAX_STR (256 * 1024) |
163 | | |
164 | | // integral types |
165 | | typedef acc_int8_t upx_int8_t; |
166 | | typedef acc_uint8_t upx_uint8_t; |
167 | | typedef acc_int16_t upx_int16_t; |
168 | | typedef acc_uint16_t upx_uint16_t; |
169 | | typedef acc_int32_t upx_int32_t; |
170 | | typedef acc_uint32_t upx_uint32_t; |
171 | | typedef acc_int64_t upx_int64_t; |
172 | | typedef acc_uint64_t upx_uint64_t; |
173 | | #if (__SIZEOF_INT128__ == 16) |
174 | | typedef __int128 upx_int128_t; |
175 | | typedef unsigned __int128 upx_uint128_t; |
176 | | #endif |
177 | | typedef acc_uintptr_t upx_uintptr_t; |
178 | | #if defined(__PTRADDR_TYPE__) // CHERI |
179 | | typedef __PTRADDR_TYPE__ upx_ptraddr_t; |
180 | | #else |
181 | | typedef upx_uintptr_t upx_ptraddr_t; |
182 | | #endif |
183 | | typedef std::make_signed_t<upx_ptraddr_t> upx_sptraddr_t; // signed ptraddr_t |
184 | | typedef std::make_unsigned_t<ptrdiff_t> upx_uptrdiff_t; // unsigned ptrdiff_t |
185 | | typedef std::make_signed_t<size_t> upx_ssize_t; // signed size_t |
186 | | |
187 | | // UPX convention: use "byte" when dealing with data; use "char/uchar" when dealing |
188 | | // with strings; use "upx_uint8_t" when dealing with small integers |
189 | | typedef unsigned char byte; |
190 | 0 | #define upx_byte byte |
191 | 0 | #define upx_bytep byte * |
192 | | typedef unsigned char uchar; |
193 | | // UPX convention: use "charptr" when dealing with abstract pointer arithmetics |
194 | | #define charptr upx_charptr_unit_type * |
195 | | // upx_charptr_unit_type is some opaque type with sizeof(type) == 1 |
196 | | //// typedef char upx_charptr_unit_type; // also works |
197 | | struct alignas(1) upx_charptr_unit_type final { char hidden__; }; |
198 | | static_assert(sizeof(upx_charptr_unit_type) == 1); |
199 | | |
200 | | // using the system off_t was a bad idea even back in 199x... |
201 | | typedef long long upx_off_t; |
202 | | #undef off_t |
203 | | #if 0 |
204 | | // TODO later cleanup: at some future point we can do this: |
205 | | #define off_t DO_NOT_USE_off_t |
206 | | #else |
207 | 852 | #define off_t upx_off_t |
208 | | #endif |
209 | | |
210 | | // shortcuts |
211 | | #define forceinline __acc_forceinline |
212 | | #if (ACC_CC_MSC) |
213 | | #define noinline __declspec(noinline) |
214 | | #undef __acc_noinline |
215 | | #define __acc_noinline noinline |
216 | | #else |
217 | | #define noinline __acc_noinline |
218 | | #endif |
219 | | #if defined(__clang__) || defined(__GNUC__) |
220 | | #define noreturn noinline __attribute__((__noreturn__)) |
221 | | #elif (ACC_CC_MSC) |
222 | | // do not use, triggers annoying "warning C4702: unreachable code" |
223 | | ////#define noreturn noinline __declspec(noreturn) |
224 | | #define noreturn noinline |
225 | | #else |
226 | | #define noreturn noinline |
227 | | #endif |
228 | | #define forceinline_constexpr forceinline constexpr |
229 | 166k | #define likely __acc_likely |
230 | | #define unlikely __acc_unlikely |
231 | | #define very_likely __acc_very_likely |
232 | 28.8M | #define very_unlikely __acc_very_unlikely |
233 | | |
234 | | // cosmetic: explicitly annotate some functions which may throw exceptions; |
235 | | // note that noexcept(false) is the default for all C++ functions anyway |
236 | | #define may_throw noexcept(false) |
237 | | |
238 | 3.66M | #define COMPILE_TIME_ASSERT(e) ACC_COMPILE_TIME_ASSERT(e) |
239 | | #define DELETED_FUNCTION = delete |
240 | 356k | #define UNUSED(var) ACC_UNUSED(var) |
241 | | |
242 | | /************************************************************************* |
243 | | // portab |
244 | | **************************************************************************/ |
245 | | |
246 | | #if (ACC_OS_POSIX) && !defined(__unix__) |
247 | | #define __unix__ 1 |
248 | | #endif |
249 | | #if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || \ |
250 | | ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) |
251 | | #undef __unix |
252 | | #undef __unix__ |
253 | | #endif |
254 | | #if (ACC_OS_DOS32) && defined(__DJGPP__) |
255 | | #undef sopen |
256 | | #endif |
257 | | |
258 | | #ifndef STDIN_FILENO |
259 | | #define STDIN_FILENO (fileno(stdin)) |
260 | | #endif |
261 | | #ifndef STDOUT_FILENO |
262 | | #define STDOUT_FILENO (fileno(stdout)) |
263 | | #endif |
264 | | #ifndef STDERR_FILENO |
265 | | #define STDERR_FILENO (fileno(stderr)) |
266 | | #endif |
267 | | |
268 | | #if !(HAVE_STRCASECMP) && (HAVE_STRICMP) && !defined(strcasecmp) |
269 | | #define strcasecmp stricmp |
270 | | #endif |
271 | | #if !(HAVE_STRNCASECMP) && (HAVE_STRNICMP) && !defined(strncasecmp) |
272 | | #define strncasecmp strnicmp |
273 | | #endif |
274 | | |
275 | | #if !defined(S_IWUSR) && defined(_S_IWUSR) |
276 | | #define S_IWUSR _S_IWUSR |
277 | | #elif !defined(S_IWUSR) && defined(_S_IWRITE) |
278 | | #define S_IWUSR _S_IWRITE |
279 | | #endif |
280 | | |
281 | | #if !defined(S_IFMT) && defined(_S_IFMT) |
282 | | #define S_IFMT _S_IFMT |
283 | | #endif |
284 | | #if !defined(S_IFREG) && defined(_S_IFREG) |
285 | | #define S_IFREG _S_IFREG |
286 | | #endif |
287 | | #if !defined(S_IFDIR) && defined(_S_IFDIR) |
288 | | #define S_IFDIR _S_IFDIR |
289 | | #endif |
290 | | #if !defined(S_IFCHR) && defined(_S_IFCHR) |
291 | | #define S_IFCHR _S_IFCHR |
292 | | #endif |
293 | | |
294 | | #if !defined(S_ISREG) |
295 | | #if defined(S_IFMT) && defined(S_IFREG) |
296 | | #define S_ISREG(m) (((m) &S_IFMT) == S_IFREG) |
297 | | #else |
298 | | #error "S_ISREG" |
299 | | #endif |
300 | | #endif |
301 | | #if !defined(S_ISDIR) |
302 | | #if defined(S_IFMT) && defined(S_IFDIR) |
303 | | #define S_ISDIR(m) (((m) &S_IFMT) == S_IFDIR) |
304 | | #else |
305 | | #error "S_ISDIR" |
306 | | #endif |
307 | | #endif |
308 | | #if !defined(S_ISCHR) |
309 | | #if defined(S_IFMT) && defined(S_IFCHR) |
310 | | #define S_ISCHR(m) (((m) &S_IFMT) == S_IFCHR) |
311 | | #endif |
312 | | #endif |
313 | | |
314 | | // some platforms may provide their own system bswapXX() functions, so rename to avoid conflicts |
315 | | #undef bswap16 |
316 | | #undef bswap32 |
317 | | #undef bswap64 |
318 | 3.04M | #define bswap16 upx_bswap16 |
319 | 5.54M | #define bswap32 upx_bswap32 |
320 | 2.97M | #define bswap64 upx_bswap64 |
321 | | |
322 | | // avoid warnings about shadowing global symbols |
323 | | #undef _base |
324 | | #undef basename |
325 | | #undef index |
326 | | #undef outp |
327 | 0 | #define _base upx_renamed__base |
328 | | #define basename upx_renamed_basename |
329 | 128k | #define index upx_renamed_index |
330 | 0 | #define outp upx_renamed_outp |
331 | | |
332 | | #if !defined(O_BINARY) || (O_BINARY + 0 == 0) |
333 | | #if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || \ |
334 | | ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64) |
335 | | #error "missing O_BINARY" |
336 | | #endif |
337 | | #endif |
338 | | #if !defined(O_BINARY) |
339 | 7.89k | #define O_BINARY 0 |
340 | | #endif |
341 | | |
342 | | /************************************************************************* |
343 | | // util |
344 | | **************************************************************************/ |
345 | | |
346 | | #define CLANG_FORMAT_DUMMY_STATEMENT /*empty*/ |
347 | | |
348 | | // malloc debuggers |
349 | | #if !defined(VALGRIND_CHECK_MEM_IS_ADDRESSABLE) |
350 | | #define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, len) 0 |
351 | | #endif |
352 | | #if !defined(VALGRIND_CHECK_MEM_IS_DEFINED) |
353 | | #define VALGRIND_CHECK_MEM_IS_DEFINED(addr, len) 0 |
354 | | #endif |
355 | | #if !defined(VALGRIND_MAKE_MEM_DEFINED) |
356 | | #define VALGRIND_MAKE_MEM_DEFINED(addr, len) 0 |
357 | | #endif |
358 | | #if !defined(VALGRIND_MAKE_MEM_NOACCESS) |
359 | | #define VALGRIND_MAKE_MEM_NOACCESS(addr, len) 0 |
360 | | #endif |
361 | | #if !defined(VALGRIND_MAKE_MEM_UNDEFINED) |
362 | | #define VALGRIND_MAKE_MEM_UNDEFINED(addr, len) 0 |
363 | | #endif |
364 | | |
365 | | // TODO later: check __MINGW_PRINTF_FORMAT |
366 | | #if defined(_WIN32) && defined(__MINGW32__) && defined(__GNUC__) && !defined(__clang__) |
367 | | #define attribute_format(a, b) __attribute__((__format__(__gnu_printf__, a, b))) |
368 | | #elif defined(__clang__) || defined(__GNUC__) |
369 | | #define attribute_format(a, b) __attribute__((__format__(__printf__, a, b))) |
370 | | #else |
371 | | #define attribute_format(a, b) /*empty*/ |
372 | | #endif |
373 | | |
374 | | // for no-op debug output |
375 | | inline void NO_printf(const char *, ...) noexcept attribute_format(1, 2); |
376 | 100k | inline void NO_printf(const char *, ...) noexcept {} |
377 | | inline void NO_fprintf(FILE *, const char *, ...) noexcept attribute_format(2, 3); |
378 | 4.63M | inline void NO_fprintf(FILE *, const char *, ...) noexcept {} |
379 | | |
380 | | // upx_memcmp_inline |
381 | | #if __has_builtin(__builtin_memcmp) |
382 | 1.14M | #define upx_memcmp_inline __builtin_memcmp |
383 | | #elif defined(__clang__) || defined(__GNUC__) |
384 | | #define upx_memcmp_inline __builtin_memcmp |
385 | | #else |
386 | | #define upx_memcmp_inline memcmp |
387 | | #endif |
388 | | |
389 | | // upx_memcpy_inline |
390 | | #if __has_builtin(__builtin_memcpy_inline) && 0 // TODO later: clang constexpr limitation? |
391 | | #define upx_memcpy_inline __builtin_memcpy_inline |
392 | | #elif __has_builtin(__builtin_memcpy) |
393 | 32.2M | #define upx_memcpy_inline __builtin_memcpy |
394 | | #elif defined(__clang__) || defined(__GNUC__) |
395 | | #define upx_memcpy_inline __builtin_memcpy |
396 | | #else |
397 | | #define upx_memcpy_inline memcpy |
398 | | #endif |
399 | | |
400 | | // upx_return_address() |
401 | | #if defined(__wasi__) |
402 | | #define upx_return_address() nullptr |
403 | | #elif __has_builtin(__builtin_return_address) |
404 | | #define upx_return_address() __builtin_return_address(0) |
405 | | #elif defined(__clang__) || defined(__GNUC__) |
406 | | #define upx_return_address() __builtin_return_address(0) |
407 | | #elif (ACC_CC_MSC) |
408 | | #define upx_return_address() _ReturnAddress() |
409 | | #else |
410 | | #define upx_return_address() nullptr |
411 | | #endif |
412 | | |
413 | | // TODO later cleanup: we now require C++17, so remove all packed_struct usage |
414 | 0 | #define packed_struct(s) struct alignas(1) s |
415 | | |
416 | | // TODO later cleanup: this was needed in the old days to catch compiler problems/bugs; |
417 | | // we now require C++17, so remove this |
418 | | #define COMPILE_TIME_ASSERT_ALIGNOF_USING_SIZEOF__(a, b) \ |
419 | 518k | { \ |
420 | 518k | typedef a acc_tmp_a_t; \ |
421 | 518k | typedef b acc_tmp_b_t; \ |
422 | 518k | struct alignas(1) acc_tmp_t { \ |
423 | 518k | acc_tmp_b_t x; \ |
424 | 518k | acc_tmp_a_t y; \ |
425 | 518k | acc_tmp_b_t z; \ |
426 | 518k | }; \ |
427 | 518k | COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 2 * sizeof(b) + sizeof(a)) \ |
428 | 518k | COMPILE_TIME_ASSERT(sizeof(((acc_tmp_t *) nullptr)->x) + \ |
429 | 518k | sizeof(((acc_tmp_t *) nullptr)->y) + \ |
430 | 518k | sizeof(((acc_tmp_t *) nullptr)->z) == \ |
431 | 518k | 2 * sizeof(b) + sizeof(a)) \ |
432 | 518k | } |
433 | | #define COMPILE_TIME_ASSERT_ALIGNOF__(a, b) \ |
434 | 518k | COMPILE_TIME_ASSERT_ALIGNOF_USING_SIZEOF__(a, b) \ |
435 | 518k | COMPILE_TIME_ASSERT(__acc_alignof(a) == sizeof(b)) \ |
436 | 518k | COMPILE_TIME_ASSERT(alignof(a) == sizeof(b)) |
437 | 518k | #define COMPILE_TIME_ASSERT_ALIGNED1(a) COMPILE_TIME_ASSERT_ALIGNOF__(a, char) |
438 | | |
439 | 1.02M | #define TABLESIZE(table) ((sizeof(table) / sizeof((table)[0]))) |
440 | | |
441 | | template <class T> |
442 | 3.34M | inline void mem_clear(T *object) noexcept { |
443 | 3.34M | static_assert(std::is_class_v<T>); // UPX convention |
444 | 3.34M | static_assert(std::is_standard_layout_v<T>); |
445 | 3.34M | static_assert(std::is_trivially_copyable_v<T>); |
446 | 3.34M | constexpr size_t size = sizeof(*object); |
447 | 3.34M | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); |
448 | 3.34M | memset((void *) object, 0, size); |
449 | 3.34M | } void mem_clear<upx_callback_t>(upx_callback_t*) Line | Count | Source | 442 | 233k | inline void mem_clear(T *object) noexcept { | 443 | 233k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 233k | static_assert(std::is_standard_layout_v<T>); | 445 | 233k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 233k | constexpr size_t size = sizeof(*object); | 447 | 233k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 233k | memset((void *) object, 0, size); | 449 | 233k | } |
void mem_clear<bzip2_compress_result_t>(bzip2_compress_result_t*) Line | Count | Source | 442 | 349k | inline void mem_clear(T *object) noexcept { | 443 | 349k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 349k | static_assert(std::is_standard_layout_v<T>); | 445 | 349k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 349k | constexpr size_t size = sizeof(*object); | 447 | 349k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 349k | memset((void *) object, 0, size); | 449 | 349k | } |
void mem_clear<lzma_compress_result_t>(lzma_compress_result_t*) Line | Count | Source | 442 | 349k | inline void mem_clear(T *object) noexcept { | 443 | 349k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 349k | static_assert(std::is_standard_layout_v<T>); | 445 | 349k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 349k | constexpr size_t size = sizeof(*object); | 447 | 349k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 349k | memset((void *) object, 0, size); | 449 | 349k | } |
void mem_clear<ucl_compress_result_t>(ucl_compress_result_t*) Line | Count | Source | 442 | 349k | inline void mem_clear(T *object) noexcept { | 443 | 349k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 349k | static_assert(std::is_standard_layout_v<T>); | 445 | 349k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 349k | constexpr size_t size = sizeof(*object); | 447 | 349k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 349k | memset((void *) object, 0, size); | 449 | 349k | } |
void mem_clear<zlib_compress_result_t>(zlib_compress_result_t*) Line | Count | Source | 442 | 349k | inline void mem_clear(T *object) noexcept { | 443 | 349k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 349k | static_assert(std::is_standard_layout_v<T>); | 445 | 349k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 349k | constexpr size_t size = sizeof(*object); | 447 | 349k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 349k | memset((void *) object, 0, size); | 449 | 349k | } |
void mem_clear<zstd_compress_result_t>(zstd_compress_result_t*) Line | Count | Source | 442 | 349k | inline void mem_clear(T *object) noexcept { | 443 | 349k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 349k | static_assert(std::is_standard_layout_v<T>); | 445 | 349k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 349k | constexpr size_t size = sizeof(*object); | 447 | 349k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 349k | memset((void *) object, 0, size); | 449 | 349k | } |
void mem_clear<upx_compress_result_t::Debug>(upx_compress_result_t::Debug*) Line | Count | Source | 442 | 349k | inline void mem_clear(T *object) noexcept { | 443 | 349k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 349k | static_assert(std::is_standard_layout_v<T>); | 445 | 349k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 349k | constexpr size_t size = sizeof(*object); | 447 | 349k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 349k | memset((void *) object, 0, size); | 449 | 349k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<char>::TestT>((anonymous namespace)::CheckIntegral<char>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<signed char>::TestT>((anonymous namespace)::CheckIntegral<signed char>::TestT*) Line | Count | Source | 442 | 15.8k | inline void mem_clear(T *object) noexcept { | 443 | 15.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 15.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 15.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 15.8k | constexpr size_t size = sizeof(*object); | 447 | 15.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 15.8k | memset((void *) object, 0, size); | 449 | 15.8k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<unsigned char>::TestT>((anonymous namespace)::CheckIntegral<unsigned char>::TestT*) Line | Count | Source | 442 | 15.8k | inline void mem_clear(T *object) noexcept { | 443 | 15.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 15.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 15.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 15.8k | constexpr size_t size = sizeof(*object); | 447 | 15.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 15.8k | memset((void *) object, 0, size); | 449 | 15.8k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<short>::TestT>((anonymous namespace)::CheckIntegral<short>::TestT*) Line | Count | Source | 442 | 15.8k | inline void mem_clear(T *object) noexcept { | 443 | 15.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 15.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 15.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 15.8k | constexpr size_t size = sizeof(*object); | 447 | 15.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 15.8k | memset((void *) object, 0, size); | 449 | 15.8k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<unsigned short>::TestT>((anonymous namespace)::CheckIntegral<unsigned short>::TestT*) Line | Count | Source | 442 | 15.8k | inline void mem_clear(T *object) noexcept { | 443 | 15.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 15.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 15.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 15.8k | constexpr size_t size = sizeof(*object); | 447 | 15.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 15.8k | memset((void *) object, 0, size); | 449 | 15.8k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<int>::TestT>((anonymous namespace)::CheckIntegral<int>::TestT*) Line | Count | Source | 442 | 15.8k | inline void mem_clear(T *object) noexcept { | 443 | 15.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 15.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 15.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 15.8k | constexpr size_t size = sizeof(*object); | 447 | 15.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 15.8k | memset((void *) object, 0, size); | 449 | 15.8k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<unsigned int>::TestT>((anonymous namespace)::CheckIntegral<unsigned int>::TestT*) Line | Count | Source | 442 | 15.8k | inline void mem_clear(T *object) noexcept { | 443 | 15.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 15.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 15.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 15.8k | constexpr size_t size = sizeof(*object); | 447 | 15.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 15.8k | memset((void *) object, 0, size); | 449 | 15.8k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<long>::TestT>((anonymous namespace)::CheckIntegral<long>::TestT*) Line | Count | Source | 442 | 31.6k | inline void mem_clear(T *object) noexcept { | 443 | 31.6k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 31.6k | static_assert(std::is_standard_layout_v<T>); | 445 | 31.6k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 31.6k | constexpr size_t size = sizeof(*object); | 447 | 31.6k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 31.6k | memset((void *) object, 0, size); | 449 | 31.6k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<unsigned long>::TestT>((anonymous namespace)::CheckIntegral<unsigned long>::TestT*) Line | Count | Source | 442 | 47.5k | inline void mem_clear(T *object) noexcept { | 443 | 47.5k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 47.5k | static_assert(std::is_standard_layout_v<T>); | 445 | 47.5k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 47.5k | constexpr size_t size = sizeof(*object); | 447 | 47.5k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 47.5k | memset((void *) object, 0, size); | 449 | 47.5k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<long long>::TestT>((anonymous namespace)::CheckIntegral<long long>::TestT*) Line | Count | Source | 442 | 23.7k | inline void mem_clear(T *object) noexcept { | 443 | 23.7k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 23.7k | static_assert(std::is_standard_layout_v<T>); | 445 | 23.7k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 23.7k | constexpr size_t size = sizeof(*object); | 447 | 23.7k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 23.7k | memset((void *) object, 0, size); | 449 | 23.7k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<unsigned long long>::TestT>((anonymous namespace)::CheckIntegral<unsigned long long>::TestT*) Line | Count | Source | 442 | 15.8k | inline void mem_clear(T *object) noexcept { | 443 | 15.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 15.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 15.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 15.8k | constexpr size_t size = sizeof(*object); | 447 | 15.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 15.8k | memset((void *) object, 0, size); | 449 | 15.8k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<__int128>::TestT>((anonymous namespace)::CheckIntegral<__int128>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<unsigned __int128>::TestT>((anonymous namespace)::CheckIntegral<unsigned __int128>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<LE16>::TestT>((anonymous namespace)::CheckIntegral<LE16>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<LE32>::TestT>((anonymous namespace)::CheckIntegral<LE32>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<LE64>::TestT>((anonymous namespace)::CheckIntegral<LE64>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<BE16>::TestT>((anonymous namespace)::CheckIntegral<BE16>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<BE32>::TestT>((anonymous namespace)::CheckIntegral<BE32>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_check.cpp:void mem_clear<(anonymous namespace)::CheckIntegral<BE64>::TestT>((anonymous namespace)::CheckIntegral<BE64>::TestT*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
dt_cxxlib.cpp:void mem_clear<DOCTEST_ANON_FUNC_6()::Test>(DOCTEST_ANON_FUNC_6()::Test*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<int, false> >(upx::TriBool<int, false>*) Line | Count | Source | 442 | 7.92k | inline void mem_clear(T *object) noexcept { | 443 | 7.92k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.92k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.92k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.92k | constexpr size_t size = sizeof(*object); | 447 | 7.92k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.92k | memset((void *) object, 0, size); | 449 | 7.92k | } |
void mem_clear<upx::TriBool<signed char, false> >(upx::TriBool<signed char, false>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned char, false> >(upx::TriBool<unsigned char, false>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<short, false> >(upx::TriBool<short, false>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned short, false> >(upx::TriBool<unsigned short, false>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned int, false> >(upx::TriBool<unsigned int, false>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<long long, false> >(upx::TriBool<long long, false>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned long long, false> >(upx::TriBool<unsigned long long, false>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<signed char, true> >(upx::TriBool<signed char, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned char, true> >(upx::TriBool<unsigned char, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<short, true> >(upx::TriBool<short, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned short, true> >(upx::TriBool<unsigned short, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<int, true> >(upx::TriBool<int, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned int, true> >(upx::TriBool<unsigned int, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<long long, true> >(upx::TriBool<long long, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<upx::TriBool<unsigned long long, true> >(upx::TriBool<unsigned long long, true>*) Line | Count | Source | 442 | 3.96k | inline void mem_clear(T *object) noexcept { | 443 | 3.96k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 3.96k | static_assert(std::is_standard_layout_v<T>); | 445 | 3.96k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 3.96k | constexpr size_t size = sizeof(*object); | 447 | 3.96k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 3.96k | memset((void *) object, 0, size); | 449 | 3.96k | } |
void mem_clear<bzip2_compress_config_t>(bzip2_compress_config_t*) Line | Count | Source | 442 | 43.5k | inline void mem_clear(T *object) noexcept { | 443 | 43.5k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 43.5k | static_assert(std::is_standard_layout_v<T>); | 445 | 43.5k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 43.5k | constexpr size_t size = sizeof(*object); | 447 | 43.5k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 43.5k | memset((void *) object, 0, size); | 449 | 43.5k | } |
void mem_clear<_CLzmaDecoderState>(_CLzmaDecoderState*) Line | Count | Source | 442 | 13.8k | inline void mem_clear(T *object) noexcept { | 443 | 13.8k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 13.8k | static_assert(std::is_standard_layout_v<T>); | 445 | 13.8k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 13.8k | constexpr size_t size = sizeof(*object); | 447 | 13.8k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 13.8k | memset((void *) object, 0, size); | 449 | 13.8k | } |
void mem_clear<zlib_compress_config_t>(zlib_compress_config_t*) Line | Count | Source | 442 | 43.5k | inline void mem_clear(T *object) noexcept { | 443 | 43.5k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 43.5k | static_assert(std::is_standard_layout_v<T>); | 445 | 43.5k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 43.5k | constexpr size_t size = sizeof(*object); | 447 | 43.5k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 43.5k | memset((void *) object, 0, size); | 449 | 43.5k | } |
void mem_clear<zstd_compress_config_t>(zstd_compress_config_t*) Line | Count | Source | 442 | 43.5k | inline void mem_clear(T *object) noexcept { | 443 | 43.5k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 43.5k | static_assert(std::is_standard_layout_v<T>); | 445 | 43.5k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 43.5k | constexpr size_t size = sizeof(*object); | 447 | 43.5k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 43.5k | memset((void *) object, 0, size); | 449 | 43.5k | } |
void mem_clear<LeFile::le_header_t>(LeFile::le_header_t*) Line | Count | Source | 442 | 7.77k | inline void mem_clear(T *object) noexcept { | 443 | 7.77k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 7.77k | static_assert(std::is_standard_layout_v<T>); | 445 | 7.77k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 7.77k | constexpr size_t size = sizeof(*object); | 447 | 7.77k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 7.77k | memset((void *) object, 0, size); | 449 | 7.77k | } |
void mem_clear<Options>(Options*) Line | Count | Source | 442 | 39.6k | inline void mem_clear(T *object) noexcept { | 443 | 39.6k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 39.6k | static_assert(std::is_standard_layout_v<T>); | 445 | 39.6k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 39.6k | constexpr size_t size = sizeof(*object); | 447 | 39.6k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 39.6k | memset((void *) object, 0, size); | 449 | 39.6k | } |
Unexecuted instantiation: void mem_clear<PackExe::exe_header_t>(PackExe::exe_header_t*) Unexecuted instantiation: void mem_clear<PackTos::LinkerSymbols>(PackTos::LinkerSymbols*) void mem_clear<PackHeader>(PackHeader*) Line | Count | Source | 442 | 349k | inline void mem_clear(T *object) noexcept { | 443 | 349k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 349k | static_assert(std::is_standard_layout_v<T>); | 445 | 349k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 349k | constexpr size_t size = sizeof(*object); | 447 | 349k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 349k | memset((void *) object, 0, size); | 449 | 349k | } |
Unexecuted instantiation: void mem_clear<PeFile::Export::export_dir_t>(PeFile::Export::export_dir_t*) Unexecuted instantiation: void mem_clear<PeFile::pe_section_t>(PeFile::pe_section_t*) void mem_clear<UiPacker::State>(UiPacker::State*) Line | Count | Source | 442 | 116k | inline void mem_clear(T *object) noexcept { | 443 | 116k | static_assert(std::is_class_v<T>); // UPX convention | 444 | 116k | static_assert(std::is_standard_layout_v<T>); | 445 | 116k | static_assert(std::is_trivially_copyable_v<T>); | 446 | 116k | constexpr size_t size = sizeof(*object); | 447 | 116k | static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM); | 448 | 116k | memset((void *) object, 0, size); | 449 | 116k | } |
|
450 | | // disable some overloads |
451 | | #if defined(__clang__) || __GNUC__ != 7 |
452 | | template <class T> |
453 | | inline void mem_clear(T (&array)[]) noexcept DELETED_FUNCTION; |
454 | | #endif |
455 | | template <class T, size_t N> |
456 | | inline void mem_clear(T (&array)[N]) noexcept DELETED_FUNCTION; |
457 | | |
458 | | // An Array allocates memory on the heap, and automatically |
459 | | // gets destructed when leaving scope or on exceptions. |
460 | | #define Array(type, var, n) \ |
461 | 37 | MemBuffer var##_membuf(mem_size(sizeof(type), (n))); \ |
462 | 38 | type *const var = ACC_STATIC_CAST(type *, var##_membuf.getVoidPtr()) |
463 | | |
464 | 0 | #define ByteArray(var, n) Array(byte, var, (n)) |
465 | | |
466 | | // assert_noexcept() |
467 | | noreturn void assertFailed(const char *expr, const char *file, int line, const char *func) noexcept; |
468 | | noreturn void throwAssertFailed(const char *expr, const char *file, int line, const char *func); |
469 | | #if defined(__clang__) || defined(__GNUC__) |
470 | | #undef assert |
471 | | #if DEBUG || 0 |
472 | | // trigger a warning if assert() is used inside a "noexcept" context |
473 | | #define assert(e) \ |
474 | | ((void) (__acc_cte(e) || (assertFailed(#e, __FILE__, __LINE__, __func__), throw 1, 0))) |
475 | | #else |
476 | | // turn assertion failures into exceptions |
477 | | #define assert(e) \ |
478 | 25.1M | ((void) (__acc_cte(e) || (throwAssertFailed(#e, __FILE__, __LINE__, __func__), throw 1, 0))) |
479 | | #endif |
480 | | #define assert_noexcept(e) \ |
481 | 32.3M | ((void) (__acc_cte(e) || (assertFailed(#e, __FILE__, __LINE__, __func__), 0))) |
482 | | #else |
483 | | #define assert_noexcept assert |
484 | | #endif |
485 | | |
486 | | // C++ support library |
487 | | #include "util/cxxlib.h" |
488 | | using upx::tribool; |
489 | 6.83k | #define usizeof(expr) (upx::UnsignedSizeOf<sizeof(expr)>::value) |
490 | 0 | #define ALIGN_DOWN(a, b) (upx::align_down((a), (b))) |
491 | 3.08k | #define ALIGN_UP(a, b) (upx::align_up((a), (b))) |
492 | 0 | #define ALIGN_UP_GAP(a, b) (upx::align_up_gap((a), (b))) |
493 | 0 | #define UPX_MAX(a, b) (upx::max((a), (b))) |
494 | 176 | #define UPX_MIN(a, b) (upx::min((a), (b))) |
495 | | |
496 | | /************************************************************************* |
497 | | // constants |
498 | | **************************************************************************/ |
499 | | |
500 | | /* exit codes of this program: 0 ok, 1 error, 2 warning */ |
501 | 4.95k | #define EXIT_OK 0 |
502 | 9.75k | #define EXIT_ERROR 1 |
503 | 1.99k | #define EXIT_WARN 2 |
504 | | // |
505 | 0 | #define EXIT_USAGE 1 |
506 | | #define EXIT_FILE_READ 1 |
507 | | #define EXIT_FILE_WRITE 1 |
508 | | #define EXIT_MEMORY 1 |
509 | | #define EXIT_CHECKSUM 1 |
510 | 0 | #define EXIT_INIT 1 |
511 | | #define EXIT_INTERNAL 1 |
512 | | |
513 | | // magic constants for patching |
514 | 10.9k | #define UPX_MAGIC_LE32 0x21585055 /* "UPX!" */ |
515 | 0 | #define UPX_MAGIC2_LE32 0xD5D0D8A1 |
516 | | |
517 | | // upx_compress() error codes |
518 | 45.8k | #define UPX_E_OK (0) |
519 | 27.9k | #define UPX_E_ERROR (-1) |
520 | 2.12k | #define UPX_E_OUT_OF_MEMORY (-2) |
521 | 0 | #define UPX_E_NOT_COMPRESSIBLE (-3) |
522 | 19.8k | #define UPX_E_INPUT_OVERRUN (-4) |
523 | 19.8k | #define UPX_E_OUTPUT_OVERRUN (-5) |
524 | 72 | #define UPX_E_LOOKBEHIND_OVERRUN (-6) |
525 | 0 | #define UPX_E_EOF_NOT_FOUND (-7) |
526 | 6 | #define UPX_E_INPUT_NOT_CONSUMED (-8) |
527 | | #define UPX_E_NOT_YET_IMPLEMENTED (-9) |
528 | 0 | #define UPX_E_INVALID_ARGUMENT (-10) |
529 | | |
530 | | // Executable formats (info: big endian types are >= 128); DO NOT CHANGE |
531 | 13.5k | #define UPX_F_DOS_COM 1 |
532 | 7.30k | #define UPX_F_DOS_SYS 2 |
533 | 15.8k | #define UPX_F_DOS_EXE 3 |
534 | 7.22k | #define UPX_F_DJGPP2_COFF 4 |
535 | 3.90k | #define UPX_F_WATCOM_LE 5 |
536 | | // #define UPX_F_VXD_LE 6 // NOT IMPLEMENTED |
537 | 6.05k | #define UPX_F_DOS_EXEH 7 // OBSOLETE |
538 | 3.95k | #define UPX_F_TMT_ADAM 8 |
539 | 4.09k | #define UPX_F_W32PE_I386 9 |
540 | 2.21k | #define UPX_F_LINUX_i386 10 |
541 | | // #define UPX_F_WIN16_NE 11 // NOT IMPLEMENTED |
542 | 3.61k | #define UPX_F_LINUX_ELF_i386 12 |
543 | | // #define UPX_F_LINUX_SEP_i386 13 // NOT IMPLEMENTED |
544 | 2.31k | #define UPX_F_LINUX_SH_i386 14 |
545 | 8.55k | #define UPX_F_VMLINUZ_i386 15 |
546 | 5.60k | #define UPX_F_BVMLINUZ_i386 16 |
547 | 0 | #define UPX_F_ELKS_8086 17 // NOT IMPLEMENTED |
548 | 1.05k | #define UPX_F_PS1_EXE 18 |
549 | 3.52k | #define UPX_F_VMLINUX_i386 19 |
550 | 0 | #define UPX_F_LINUX_ELFI_i386 20 |
551 | 3.96k | #define UPX_F_WINCE_ARM 21 // Windows CE |
552 | 2.97k | #define UPX_F_LINUX_ELF64_AMD64 22 |
553 | 2.66k | #define UPX_F_LINUX_ELF32_ARM 23 |
554 | 2.25k | #define UPX_F_BSD_i386 24 |
555 | 10.8k | #define UPX_F_BSD_ELF_i386 25 |
556 | | #define UPX_F_BSD_SH_i386 26 |
557 | 3.52k | #define UPX_F_VMLINUX_AMD64 27 |
558 | 3.52k | #define UPX_F_VMLINUX_ARM 28 |
559 | 1.62k | #define UPX_F_MACH_i386 29 |
560 | 2.07k | #define UPX_F_LINUX_ELF32_MIPSEL 30 |
561 | 7.04k | #define UPX_F_VMLINUZ_ARM 31 |
562 | 1.32k | #define UPX_F_MACH_ARM 32 |
563 | 0 | #define UPX_F_DYLIB_i386 33 |
564 | 1.58k | #define UPX_F_MACH_AMD64 34 |
565 | 1.70k | #define UPX_F_DYLIB_AMD64 35 |
566 | 4.01k | #define UPX_F_W64PE_AMD64 36 |
567 | 1.35k | #define UPX_F_MACH_ARM64 37 |
568 | | // #define UPX_F_MACH_PPC64LE 38 // DOES NOT EXIST |
569 | 2.10k | #define UPX_F_LINUX_ELF64_PPC64LE 39 |
570 | 3.52k | #define UPX_F_VMLINUX_PPC64LE 40 |
571 | | // #define UPX_F_DYLIB_PPC64LE 41 // DOES NOT EXIST |
572 | 2.39k | #define UPX_F_LINUX_ELF64_ARM64 42 |
573 | 0 | #define UPX_F_W64PE_ARM64 43 // NOT YET IMPLEMENTED |
574 | 0 | #define UPX_F_W64PE_ARM64EC 44 // NOT YET IMPLEMENTED |
575 | 5.01k | #define UPX_F_LINUX_ELF64_RISCV64 45 |
576 | | |
577 | 1.08k | #define UPX_F_ATARI_TOS 129 |
578 | | // #define UPX_F_SOLARIS_SPARC 130 // NOT IMPLEMENTED |
579 | 1.70k | #define UPX_F_MACH_PPC32 131 |
580 | 2.33k | #define UPX_F_LINUX_ELF32_PPC32 132 |
581 | 2.45k | #define UPX_F_LINUX_ELF32_ARMEB 133 |
582 | 1.94k | #define UPX_F_MACH_FAT 134 |
583 | 3.52k | #define UPX_F_VMLINUX_ARMEB 135 |
584 | 3.52k | #define UPX_F_VMLINUX_PPC32 136 |
585 | 2.03k | #define UPX_F_LINUX_ELF32_MIPS 137 |
586 | 0 | #define UPX_F_DYLIB_PPC32 138 |
587 | 0 | #define UPX_F_MACH_PPC64 139 |
588 | 2.09k | #define UPX_F_LINUX_ELF64_PPC64 140 |
589 | | #define UPX_F_VMLINUX_PPC64 141 |
590 | 161 | #define UPX_F_DYLIB_PPC64 142 |
591 | | |
592 | | // compression methods; DO NOT CHANGE |
593 | 6.89k | #define M_NRV2B_LE32 2 |
594 | 23.7k | #define M_NRV2B_8 3 |
595 | 1.34k | #define M_NRV2B_LE16 4 |
596 | 627 | #define M_NRV2D_LE32 5 |
597 | 23.7k | #define M_NRV2D_8 6 |
598 | 310 | #define M_NRV2D_LE16 7 |
599 | 515 | #define M_NRV2E_LE32 8 |
600 | 23.7k | #define M_NRV2E_8 9 |
601 | 262 | #define M_NRV2E_LE16 10 |
602 | | // #define M_CL1B_LE32 11 |
603 | | // #define M_CL1B_8 12 |
604 | | // #define M_CL1B_LE16 13 |
605 | 93.1k | #define M_LZMA 14 |
606 | 11.9k | #define M_DEFLATE 15 // NOT YET USED |
607 | 0 | #define M_ZSTD 16 // NOT YET USED |
608 | 113 | #define M_BZIP2 17 // NOT YET USED |
609 | | // compression methods internal usage |
610 | 0 | #define M_ALL (-1) |
611 | 0 | #define M_END (-2) |
612 | 155k | #define M_NONE (-3) |
613 | 0 | #define M_SKIP (-4) |
614 | 0 | #define M_ULTRA_BRUTE (-5) |
615 | | |
616 | 27.8k | #define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16) |
617 | 26.8k | #define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16) |
618 | 254 | #define M_IS_NRV2E(x) ((x) >= M_NRV2E_LE32 && (x) <= M_NRV2E_LE16) |
619 | | // #define M_IS_CL1B(x) ((x) >= M_CL1B_LE32 && (x) <= M_CL1B_LE16) |
620 | 78.5k | #define M_IS_LZMA(x) (((x) &255) == M_LZMA) |
621 | 73 | #define M_IS_DEFLATE(x) ((x) == M_DEFLATE) |
622 | | #define M_IS_ZSTD(x) ((x) == M_ZSTD) |
623 | | #define M_IS_BZIP2(x) ((x) == M_BZIP2) |
624 | | |
625 | | // filters internal usage |
626 | 0 | #define FT_END (-1) |
627 | 39.6k | #define FT_NONE (-2) |
628 | 0 | #define FT_SKIP (-3) |
629 | 0 | #define FT_ULTRA_BRUTE (-4) |
630 | | |
631 | | /************************************************************************* |
632 | | // compression - setup and callback_t |
633 | | **************************************************************************/ |
634 | | |
635 | | #define WITH_LZMA 1 |
636 | | #define WITH_UCL 1 |
637 | | #ifndef WITH_ZLIB |
638 | | #define WITH_ZLIB 1 |
639 | | #endif |
640 | | #if (WITH_UCL) |
641 | | #define ucl_compress_config_t REAL_ucl_compress_config_t |
642 | | #include <ucl/include/ucl/uclconf.h> |
643 | | #include <ucl/include/ucl/ucl.h> |
644 | | #undef ucl_compress_config_t |
645 | | #undef ucl_compress_config_p |
646 | | #endif |
647 | | |
648 | | struct upx_callback_t; |
649 | | typedef void(__acc_cdecl *upx_progress_func_t)(upx_callback_t *, unsigned, unsigned); |
650 | | |
651 | | struct upx_callback_t final { |
652 | | upx_progress_func_t nprogress; |
653 | | void *user; |
654 | | |
655 | 233k | void reset() noexcept { mem_clear(this); } |
656 | | }; |
657 | | |
658 | | /************************************************************************* |
659 | | // compression - config_t |
660 | | **************************************************************************/ |
661 | | |
662 | | struct bzip2_compress_config_t final { |
663 | | unsigned dummy; |
664 | | |
665 | | void reset() noexcept; |
666 | | }; |
667 | | |
668 | | struct lzma_compress_config_t final { |
669 | | typedef upx::OptVar<unsigned, 2u, 0u, 4u> pos_bits_t; // pb |
670 | | typedef upx::OptVar<unsigned, 0u, 0u, 4u> lit_pos_bits_t; // lp |
671 | | typedef upx::OptVar<unsigned, 3u, 0u, 8u> lit_context_bits_t; // lc |
672 | | typedef upx::OptVar<unsigned, (1u << 22), 1u, (1u << 30)> dict_size_t; |
673 | | typedef upx::OptVar<unsigned, 64u, 5u, 273u> num_fast_bytes_t; |
674 | | |
675 | | pos_bits_t pos_bits; // pb |
676 | | lit_pos_bits_t lit_pos_bits; // lp |
677 | | lit_context_bits_t lit_context_bits; // lc |
678 | | dict_size_t dict_size; |
679 | | unsigned fast_mode; |
680 | | num_fast_bytes_t num_fast_bytes; |
681 | | unsigned match_finder_cycles; |
682 | | |
683 | | unsigned max_num_probs; |
684 | | |
685 | | void reset() noexcept; |
686 | | }; |
687 | | |
688 | | struct ucl_compress_config_t final : public REAL_ucl_compress_config_t { |
689 | 43.5k | void reset() noexcept { memset(this, 0xff, sizeof(*this)); } |
690 | | }; |
691 | | |
692 | | struct zlib_compress_config_t final { |
693 | | typedef upx::OptVar<unsigned, 8u, 1u, 9u> mem_level_t; // ml |
694 | | typedef upx::OptVar<unsigned, 15u, 9u, 15u> window_bits_t; // wb |
695 | | typedef upx::OptVar<unsigned, 0u, 0u, 4u> strategy_t; // st |
696 | | |
697 | | mem_level_t mem_level; // ml |
698 | | window_bits_t window_bits; // wb |
699 | | strategy_t strategy; // st |
700 | | |
701 | | void reset() noexcept; |
702 | | }; |
703 | | |
704 | | struct zstd_compress_config_t final { |
705 | | unsigned dummy; |
706 | | |
707 | | void reset() noexcept; |
708 | | }; |
709 | | |
710 | | struct upx_compress_config_t final { |
711 | | bzip2_compress_config_t conf_bzip2; |
712 | | lzma_compress_config_t conf_lzma; |
713 | | ucl_compress_config_t conf_ucl; |
714 | | zlib_compress_config_t conf_zlib; |
715 | | zstd_compress_config_t conf_zstd; |
716 | | |
717 | 0 | void reset() noexcept { |
718 | 0 | conf_bzip2.reset(); |
719 | 0 | conf_lzma.reset(); |
720 | 0 | conf_ucl.reset(); |
721 | 0 | conf_zlib.reset(); |
722 | 0 | conf_zstd.reset(); |
723 | 0 | } |
724 | | }; |
725 | | |
726 | 0 | #define NULL_cconf ((const upx_compress_config_t *) nullptr) |
727 | | |
728 | | /************************************************************************* |
729 | | // compression - result_t |
730 | | **************************************************************************/ |
731 | | |
732 | | struct bzip2_compress_result_t final { |
733 | | unsigned dummy; |
734 | | |
735 | 349k | void reset() noexcept { mem_clear(this); } |
736 | | }; |
737 | | |
738 | | struct lzma_compress_result_t final { |
739 | | unsigned pos_bits; // pb |
740 | | unsigned lit_pos_bits; // lp |
741 | | unsigned lit_context_bits; // lc |
742 | | unsigned dict_size; |
743 | | unsigned fast_mode; |
744 | | unsigned num_fast_bytes; |
745 | | unsigned match_finder_cycles; |
746 | | unsigned num_probs; // (computed result) |
747 | | |
748 | 349k | void reset() noexcept { mem_clear(this); } |
749 | | }; |
750 | | |
751 | | struct ucl_compress_result_t final { |
752 | | ucl_uint result[16]; |
753 | | |
754 | 349k | void reset() noexcept { mem_clear(this); } |
755 | | }; |
756 | | |
757 | | struct zlib_compress_result_t final { |
758 | | unsigned dummy; |
759 | | |
760 | 349k | void reset() noexcept { mem_clear(this); } |
761 | | }; |
762 | | |
763 | | struct zstd_compress_result_t final { |
764 | | unsigned dummy; |
765 | | |
766 | 349k | void reset() noexcept { mem_clear(this); } |
767 | | }; |
768 | | |
769 | | struct upx_compress_result_t final { |
770 | | // debugging aid |
771 | | struct Debug { |
772 | | int method, level; |
773 | | unsigned u_len, c_len; |
774 | 349k | void reset() noexcept { mem_clear(this); } |
775 | | }; |
776 | | Debug debug; |
777 | | |
778 | | bzip2_compress_result_t result_bzip2; |
779 | | lzma_compress_result_t result_lzma; |
780 | | ucl_compress_result_t result_ucl; |
781 | | zlib_compress_result_t result_zlib; |
782 | | zstd_compress_result_t result_zstd; |
783 | | |
784 | 349k | void reset() noexcept { |
785 | 349k | debug.reset(); |
786 | 349k | result_bzip2.reset(); |
787 | 349k | result_lzma.reset(); |
788 | 349k | result_ucl.reset(); |
789 | 349k | result_zlib.reset(); |
790 | 349k | result_zstd.reset(); |
791 | 349k | } |
792 | | }; |
793 | | |
794 | | /************************************************************************* |
795 | | // globals |
796 | | **************************************************************************/ |
797 | | |
798 | | // classes |
799 | | class ElfLinker; |
800 | | typedef ElfLinker Linker; // shortcut |
801 | | class Throwable; |
802 | | |
803 | | // check/dt_check.cpp |
804 | | noinline void upx_compiler_sanity_check() noexcept; |
805 | | noinline int upx_doctest_check(int argc, char **argv); |
806 | | int upx_doctest_check(); |
807 | | |
808 | | // util/membuffer.h |
809 | | class MemBuffer; |
810 | | void *membuffer_get_void_ptr(MemBuffer &mb) noexcept; |
811 | | const void *membuffer_get_void_ptr(const MemBuffer &mb) noexcept; |
812 | | unsigned membuffer_get_size_in_bytes(const MemBuffer &mb) noexcept; |
813 | | |
814 | | // main.cpp |
815 | | extern const char *progname; |
816 | | bool main_set_exit_code(int ec); |
817 | | int main_get_options(int argc, char **argv); |
818 | | void main_get_envoptions(); |
819 | | noinline int upx_main(int argc, char *argv[]) may_throw; |
820 | | |
821 | | // msg.cpp |
822 | | void printSetNl(int need_nl) noexcept; |
823 | | void printClearLine(FILE *f = nullptr) noexcept; |
824 | | void printErr(const char *iname, const Throwable &e) noexcept; |
825 | | void printUnhandledException(const char *iname, const std::exception *e) noexcept; |
826 | | void printErr(const char *iname, const char *format, ...) noexcept attribute_format(2, 3); |
827 | | void printWarn(const char *iname, const char *format, ...) noexcept attribute_format(2, 3); |
828 | | |
829 | | void infoWarning(const char *format, ...) attribute_format(1, 2); |
830 | | void infoHeader(const char *format, ...) attribute_format(1, 2); |
831 | | void info(const char *format, ...) attribute_format(1, 2); |
832 | | void infoHeader(); |
833 | | void infoWriting(const char *what, upx_int64_t size); |
834 | | |
835 | | // work.cpp |
836 | | noinline void do_one_file(const char *iname, char *oname) may_throw; |
837 | | noinline int do_files(int i, int argc, char *argv[]) may_throw; |
838 | | |
839 | | // help.cpp |
840 | | extern const char gitrev[]; |
841 | | void show_header(); |
842 | | void show_help(int verbose); |
843 | | void show_license(); |
844 | | void show_sysinfo(const char *options_var); |
845 | | void show_usage(); |
846 | | void show_version(bool one_line = false); |
847 | | |
848 | | // compress/compress.cpp |
849 | | // clang-format off |
850 | | unsigned upx_adler32(const void *buf, unsigned len, unsigned adler = 1); |
851 | | unsigned upx_crc32 (const void *buf, unsigned len, unsigned crc = 0); |
852 | | |
853 | | int upx_compress ( const upx_bytep src, unsigned src_len, |
854 | | upx_bytep dst, unsigned *dst_len, |
855 | | upx_callback_t *cb, |
856 | | int method, int level, |
857 | | const upx_compress_config_t *cconf, |
858 | | upx_compress_result_t *cresult ); |
859 | | int upx_decompress ( const upx_bytep src, unsigned src_len, |
860 | | upx_bytep dst, unsigned *dst_len, |
861 | | int method, |
862 | | const upx_compress_result_t *cresult ); |
863 | | int upx_test_overlap ( const upx_bytep buf, |
864 | | const upx_bytep tbuf, |
865 | | unsigned src_off, unsigned src_len, |
866 | | unsigned *dst_len, |
867 | | int method, |
868 | | const upx_compress_result_t *cresult ); |
869 | | // clang-format on |
870 | | |
871 | | #include "util/snprintf.h" // must get included first! |
872 | | #include "util/util.h" |
873 | | #include "options.h" |
874 | | #include "except.h" |
875 | | #include "bele.h" |
876 | | #include "console/console.h" |
877 | | // xspan |
878 | | #include "util/raw_bytes.h" |
879 | | #include "util/xspan.h" |
880 | | // |
881 | | #include "util/system_check_predefs.h" |
882 | | |
883 | | /* vim:set ts=4 sw=4 et: */ |