src: move compress files into a subdir; clang-format some more files; NFC

This commit is contained in:
Markus F.X.J. Oberhumer 2023-01-18 09:28:12 +01:00
parent 334be287fc
commit 6c41a4c9c8
17 changed files with 183 additions and 212 deletions

View File

@ -293,7 +293,8 @@ jobs:
set s=%H%\src set s=%H%\src
cat .GITREV.txt cat .GITREV.txt
set /p GITREV=<.GITREV.txt set /p GITREV=<.GITREV.txt
cl -std:c++17 -Zc:__cplusplus -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" -DWITH_ZSTD %DEFS% -I%H%\vendor -I%H%\vendor\boost-pfr\include -Feupx.exe %s%\*.cpp %s%\check\*.cpp %s%\util\*.cpp %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib /link setargv.obj set sources=%s%\*.cpp %s%\check\*.cpp %s%\compress\*.cpp %s%\filter\*.cpp %s%\util\*.cpp
cl -std:c++17 -Zc:__cplusplus -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" -DWITH_ZSTD %DEFS% -I%H%\vendor -I%H%\vendor\boost-pfr\include -Feupx.exe %sources% %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib /link setargv.obj
- name: 'Make artifact' - name: 'Make artifact'
shell: bash shell: bash
run: | run: |

View File

@ -121,7 +121,7 @@ add_library(upx_vendor_zstd STATIC ${zstd_SOURCES})
set_property(TARGET upx_vendor_zstd PROPERTY C_STANDARD 11) set_property(TARGET upx_vendor_zstd PROPERTY C_STANDARD 11)
endif() endif()
file(GLOB upx_SOURCES "src/*.cpp" "src/check/*.cpp" "src/util/*.cpp") file(GLOB upx_SOURCES "src/*.cpp" "src/[cfu]*/*.cpp")
list(SORT upx_SOURCES) list(SORT upx_SOURCES)
add_executable(upx ${upx_SOURCES}) add_executable(upx ${upx_SOURCES})
#target_compile_features(upx PRIVATE cxx_std_17) #target_compile_features(upx PRIVATE cxx_std_17)
@ -250,6 +250,8 @@ endif()
# "ninja test" # "ninja test"
#*********************************************************************** #***********************************************************************
if(NOT UPX_CONFIG_CMAKE_DISABLE_TEST)
include(CTest) include(CTest)
if(NOT CMAKE_CROSSCOMPILING) if(NOT CMAKE_CROSSCOMPILING)
add_test(NAME upx-version COMMAND upx --version) add_test(NAME upx-version COMMAND upx --version)
@ -279,12 +281,16 @@ if(NOT CMAKE_CROSSCOMPILING AND NOT UPX_CONFIG_DISABLE_SELF_PACK_TEST)
upx_add_test(upx-run-packed ./upx-packed${exe} --version-short) upx_add_test(upx-run-packed ./upx-packed${exe} --version-short)
endif() endif()
endif() # UPX_CONFIG_CMAKE_DISABLE_TEST
#*********************************************************************** #***********************************************************************
# "cmake --install ." # "cmake --install ."
# "make install" # "make install"
# "ninja install" # "ninja install"
#*********************************************************************** #***********************************************************************
if(NOT UPX_CONFIG_CMAKE_DISABLE_INSTALL)
# installation prefix and directories # installation prefix and directories
if(NOT CMAKE_INSTALL_PREFIX) if(NOT CMAKE_INSTALL_PREFIX)
#message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined.") #message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined.")
@ -302,6 +308,8 @@ if(CMAKE_INSTALL_PREFIX AND DEFINED CMAKE_INSTALL_FULL_BINDIR)
install(FILES doc/upx.1 DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1") install(FILES doc/upx.1 DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1")
endif() endif()
endif() # UPX_CONFIG_CMAKE_DISABLE_INSTALL
#*********************************************************************** #***********************************************************************
# finally print some info about the build configuration # finally print some info about the build configuration
#*********************************************************************** #***********************************************************************
@ -317,11 +325,13 @@ function(print_var)
endif() endif()
endforeach() endforeach()
endfunction() endfunction()
if(NOT UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO)
print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION) print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION)
print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_CROSSCOMPILING) print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_CROSSCOMPILING)
print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI) print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI)
print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI) print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI)
print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_BUILD_TYPE) print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_BUILD_TYPE)
endif() # UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO
if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$") if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$")
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"") message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
endif() endif()

View File

@ -136,5 +136,5 @@ build/extra/cross-windows-mingw64/%: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISA
SUBMODULES = boost-pfr doctest lzma-sdk rangeless ucl valgrind zlib zstd SUBMODULES = boost-pfr doctest lzma-sdk rangeless ucl valgrind zlib zstd
dummy := $(foreach m,$(SUBMODULES),$(if $(wildcard vendor/$(m)/[CL]*),,\ dummy := $(foreach m,$(SUBMODULES),$(if $(wildcard vendor/$m/[CL]*),$m,\
$(error ERROR: missing git submodule $m; run 'git submodule update --init'))) $(error ERROR: missing git submodule $m; run 'git submodule update --init')))

View File

@ -75,11 +75,11 @@ endif
# automatically format some C++ source code files # automatically format some C++ source code files
ifeq ($(shell uname),Linux) ifeq ($(shell uname),Linux)
# Markus loves clang-format, but John hates it; find a compromise # Markus loves clang-format, but John hates it; find a compromise
CLANG_FORMAT_EXCLUDE_FILES += conf.h miniacc.h version.h CLANG_FORMAT_EXCLUDE_FILES += conf.h miniacc.h version.h help.cpp
CLANG_FORMAT_EXCLUDE_FILES += compress.cpp compress.h filter.cpp filter.h filteri.cpp help.cpp
CLANG_FORMAT_EXCLUDE_FILES += p_elf.h p_elf_enum.h p_lx_% p_mach% p_unix% p_vmli% CLANG_FORMAT_EXCLUDE_FILES += p_elf.h p_elf_enum.h p_lx_% p_mach% p_unix% p_vmli%
CLANG_FORMAT_EXCLUDE_FILES += p_w32pe.cpp p_w64pep.cpp packer_c.cpp packer_f.cpp pefile% CLANG_FORMAT_EXCLUDE_FILES += p_w32pe.cpp p_w64pep.cpp packer_c.cpp packer_f.cpp pefile%
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* check/*.[ch]* util/*.[ch]*)) CLANG_FORMAT_EXCLUDE_FILES += compress/compress.h filter/filter_impl.cpp
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* [cu]*/*.[ch]*))
CLANG_FORMAT_FILES := $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES)) CLANG_FORMAT_FILES := $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES))
clang-format: PHONY $(CLANG_FORMAT_FILES) clang-format: PHONY $(CLANG_FORMAT_FILES)
@echo "running upx-clang-format" @echo "running upx-clang-format"

View File

@ -3,7 +3,6 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2023 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@ -21,22 +20,19 @@
If not, write to the Free Software Foundation, Inc., If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com>
*/ */
#include "../conf.h"
#include "conf.h"
#include "compress.h" #include "compress.h"
#include "util/membuffer.h" #include "../util/membuffer.h"
/************************************************************************* /*************************************************************************
// //
**************************************************************************/ **************************************************************************/
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler) unsigned upx_adler32(const void *buf, unsigned len, unsigned adler) {
{
if (len == 0) if (len == 0)
return adler; return adler;
assert(buf != nullptr); assert(buf != nullptr);
@ -47,8 +43,7 @@ unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
#endif #endif
} }
#if 0 // UNUSED
#if 0 /* UNUSED */
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc) unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
{ {
if (len == 0) if (len == 0)
@ -60,24 +55,20 @@ unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
return upx_zlib_crc32(buf, len, crc); return upx_zlib_crc32(buf, len, crc);
#endif #endif
} }
#endif /* UNUSED */ #endif // UNUSED
/************************************************************************* /*************************************************************************
// //
**************************************************************************/ **************************************************************************/
int upx_compress( const upx_bytep src, unsigned src_len, int upx_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
upx_bytep dst, unsigned* dst_len, upx_callback_p cb, int method, int level, const upx_compress_config_t *cconf,
upx_callback_p cb, upx_compress_result_t *cresult) {
int method, int level,
const upx_compress_config_t *cconf,
upx_compress_result_t *cresult )
{
int r = UPX_E_ERROR; int r = UPX_E_ERROR;
upx_compress_result_t cresult_buffer; upx_compress_result_t cresult_buffer;
assert(method > 0); assert(level > 0); assert(method > 0);
assert(level > 0);
#if 1 #if 1
// set available bytes in dst // set available bytes in dst
@ -94,65 +85,57 @@ int upx_compress( const upx_bytep src, unsigned src_len,
cresult = &cresult_buffer; cresult = &cresult_buffer;
memset(cresult, 0, sizeof(*cresult)); memset(cresult, 0, sizeof(*cresult));
#if 1 #if 1
// debug // debugging aid
cresult->method = method; cresult->debug.method = method;
cresult->level = level; cresult->debug.level = level;
cresult->u_len = src_len; cresult->debug.u_len = src_len;
cresult->c_len = 0; cresult->debug.c_len = 0;
#endif #endif
if __acc_cte(0) { if (__acc_cte(false)) {
} }
#if (WITH_LZMA) #if (WITH_LZMA)
else if (M_IS_LZMA(method)) else if (M_IS_LZMA(method))
r = upx_lzma_compress(src, src_len, dst, dst_len, r = upx_lzma_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
cb, method, level, cconf, cresult);
#endif #endif
#if (WITH_NRV) #if (WITH_NRV)
else if ((M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method)) && !opt->prefer_ucl) else if ((M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method)) && !opt->prefer_ucl)
r = upx_nrv_compress(src, src_len, dst, dst_len, r = upx_nrv_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
cb, method, level, cconf, cresult);
#endif #endif
#if (WITH_UCL) #if (WITH_UCL)
else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method)) else if (M_IS_NRV2B(method) || M_IS_NRV2D(method) || M_IS_NRV2E(method))
r = upx_ucl_compress(src, src_len, dst, dst_len, r = upx_ucl_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
cb, method, level, cconf, cresult);
#endif #endif
#if (WITH_ZSTD) #if (WITH_ZSTD)
else if (M_IS_ZSTD(method)) else if (M_IS_ZSTD(method))
r = upx_zstd_compress(src, src_len, dst, dst_len, r = upx_zstd_compress(src, src_len, dst, dst_len, cb, method, level, cconf, cresult);
cb, method, level, cconf, cresult);
#endif #endif
else { else {
throwInternalError("unknown compression method"); throwInternalError("unknown compression method");
} }
#if 1 #if 1
// debug // debugging aid
cresult->c_len = *dst_len; cresult->debug.c_len = *dst_len;
#endif #endif
return r; return r;
} }
/************************************************************************* /*************************************************************************
// //
**************************************************************************/ **************************************************************************/
int upx_decompress(const upx_bytep src, unsigned src_len, int upx_decompress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
upx_bytep dst, unsigned* dst_len, int method, const upx_compress_result_t *cresult) {
int method,
const upx_compress_result_t *cresult )
{
int r = UPX_E_ERROR; int r = UPX_E_ERROR;
assert(*dst_len > 0); assert(*dst_len > 0);
assert(src_len < *dst_len); // must be compressed assert(src_len < *dst_len); // must be compressed
if (cresult && cresult->method == 0) if (cresult && cresult->debug.method == 0)
cresult = nullptr; cresult = nullptr;
if __acc_cte(0) { if (__acc_cte(false)) {
} }
#if (WITH_LZMA) #if (WITH_LZMA)
else if (M_IS_LZMA(method)) else if (M_IS_LZMA(method))
@ -181,29 +164,23 @@ int upx_decompress(const upx_bytep src, unsigned src_len,
return r; return r;
} }
/************************************************************************* /*************************************************************************
// //
**************************************************************************/ **************************************************************************/
int upx_test_overlap( const upx_bytep buf, int upx_test_overlap(const upx_bytep buf, const upx_bytep tbuf, unsigned src_off, unsigned src_len,
const upx_bytep tbuf, unsigned *dst_len, int method, const upx_compress_result_t *cresult) {
unsigned src_off, unsigned src_len,
unsigned* dst_len,
int method,
const upx_compress_result_t *cresult )
{
int r = UPX_E_ERROR; int r = UPX_E_ERROR;
if (cresult && cresult->method == 0) if (cresult && cresult->debug.method == 0)
cresult = nullptr; cresult = nullptr;
assert(*dst_len > 0); assert(*dst_len > 0);
assert(src_len < *dst_len); // must be compressed assert(src_len < *dst_len); // must be compressed
unsigned overlap_overhead = src_off + src_len - *dst_len; unsigned overlap_overhead = src_off + src_len - *dst_len;
assert((int)overlap_overhead > 0); assert((int) overlap_overhead > 0);
if __acc_cte(0) { if (__acc_cte(false)) {
} }
#if (WITH_LZMA) #if (WITH_LZMA)
else if (M_IS_LZMA(method)) else if (M_IS_LZMA(method))

View File

@ -3,7 +3,6 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2023 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@ -21,19 +20,40 @@
If not, write to the Free Software Foundation, Inc., If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com>
*/ */
#pragma once
#ifndef __UPX_COMPRESS_H #ifndef UPX_COMPRESS_H__
#define __UPX_COMPRESS_H 1 #define UPX_COMPRESS_H__ 1
/************************************************************************* /*************************************************************************
// //
**************************************************************************/ **************************************************************************/
#if (WITH_BZIP2)
int upx_bzip2_init(void);
const char *upx_bzip2_version_string(void);
int upx_bzip2_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
upx_callback_p cb,
int method, int level,
const upx_compress_config_t *cconf,
upx_compress_result_t *cresult );
int upx_bzip2_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
int method,
const upx_compress_result_t *cresult );
int upx_bzip2_test_overlap ( const upx_bytep buf,
const upx_bytep tbuf,
unsigned src_off, unsigned src_len,
unsigned* dst_len,
int method,
const upx_compress_result_t *cresult );
#endif
#if (WITH_LZMA) #if (WITH_LZMA)
int upx_lzma_init(void); int upx_lzma_init(void);
const char *upx_lzma_version_string(void); const char *upx_lzma_version_string(void);

View File

@ -3,7 +3,6 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2023 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@ -21,13 +20,13 @@
If not, write to the Free Software Foundation, Inc., If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com>
*/ */
#include "conf.h" #include "../conf.h"
#include "compress.h" #include "compress.h"
#include "util/membuffer.h" #include "../util/membuffer.h"
#if (ACC_CC_CLANG) #if (ACC_CC_CLANG)
#pragma clang diagnostic ignored "-Wshadow" #pragma clang diagnostic ignored "-Wshadow"
@ -453,7 +452,7 @@ int upx_lzma_decompress(const upx_bytep src, unsigned src_len, upx_bytep dst, un
src_len -= 2; src_len -= 2;
if (cresult) { if (cresult) {
assert(cresult->method == method); assert(cresult->debug.method == method);
assert(cresult->result_lzma.pos_bits == (unsigned) s.Properties.pb); assert(cresult->result_lzma.pos_bits == (unsigned) s.Properties.pb);
assert(cresult->result_lzma.lit_pos_bits == (unsigned) s.Properties.lp); assert(cresult->result_lzma.lit_pos_bits == (unsigned) s.Properties.lp);
assert(cresult->result_lzma.lit_context_bits == (unsigned) s.Properties.lc); assert(cresult->result_lzma.lit_context_bits == (unsigned) s.Properties.lc);
@ -518,14 +517,7 @@ int upx_lzma_test_overlap(const upx_bytep buf, const upx_bytep tbuf, unsigned sr
int upx_lzma_init(void) { return 0; } int upx_lzma_init(void) { return 0; }
const char *upx_lzma_version_string(void) { const char *upx_lzma_version_string(void) { return "4.43"; }
#if (WITH_LZMA == 0x443)
return "4.43";
#else
#error "unknown WITH_LZMA version"
return nullptr;
#endif
}
/************************************************************************* /*************************************************************************
// doctest checks // doctest checks

View File

@ -3,7 +3,6 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2023 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@ -21,11 +20,11 @@
If not, write to the Free Software Foundation, Inc., If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com>
*/ */
#include "conf.h" #include "../conf.h"
#include "compress.h" #include "compress.h"
/************************************************************************* /*************************************************************************
@ -261,7 +260,7 @@ unsigned upx_ucl_adler32(const void *buf, unsigned len, unsigned adler) {
return ucl_adler32(adler, (const ucl_bytep) buf, len); return ucl_adler32(adler, (const ucl_bytep) buf, len);
} }
#if 0 /* UNUSED */ #if 0 // UNUSED
unsigned upx_ucl_crc32(const void *buf, unsigned len, unsigned crc) { unsigned upx_ucl_crc32(const void *buf, unsigned len, unsigned crc) {
return ucl_crc32(crc, (const ucl_bytep) buf, len); return ucl_crc32(crc, (const ucl_bytep) buf, len);
} }
@ -273,7 +272,7 @@ unsigned upx_ucl_crc32(const void *buf, unsigned len, unsigned crc) {
#if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1 #if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1
#include "util/membuffer.h" #include "../util/membuffer.h"
static bool check_ucl(const int method, const unsigned expected_c_len) { static bool check_ucl(const int method, const unsigned expected_c_len) {
const unsigned u_len = 16384; const unsigned u_len = 16384;

View File

@ -3,7 +3,6 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2023 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2023 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@ -21,13 +20,13 @@
If not, write to the Free Software Foundation, Inc., If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar Markus F.X.J. Oberhumer
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com>
*/ */
#include "conf.h" #include "../conf.h"
#include "compress.h" #include "compress.h"
#include "util/membuffer.h" #include "../util/membuffer.h"
#include <zlib/zlib.h> #include <zlib/zlib.h>
#include <zlib/deflate.h> #include <zlib/deflate.h>
@ -224,13 +223,13 @@ int upx_zlib_init(void) {
const char *upx_zlib_version_string(void) { return zlibVersion(); } const char *upx_zlib_version_string(void) { return zlibVersion(); }
#if 0 /* UNUSED */ #if 0 // UNUSED
unsigned upx_zlib_adler32(const void *buf, unsigned len, unsigned adler) { unsigned upx_zlib_adler32(const void *buf, unsigned len, unsigned adler) {
return adler32(adler, (const Bytef *) buf, len); return adler32(adler, (const Bytef *) buf, len);
} }
#endif #endif
#if 0 /* UNUSED */ #if 0 // UNUSED
unsigned upx_zlib_crc32(const void *buf, unsigned len, unsigned crc) { unsigned upx_zlib_crc32(const void *buf, unsigned len, unsigned crc) {
return crc32(crc, (const Bytef *) buf, len); return crc32(crc, (const Bytef *) buf, len);
} }
@ -242,8 +241,6 @@ unsigned upx_zlib_crc32(const void *buf, unsigned len, unsigned crc) {
#if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1 #if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1
#include "util/membuffer.h"
static bool check_zlib(const int method, const int level, const unsigned expected_c_len) { static bool check_zlib(const int method, const int level, const unsigned expected_c_len) {
const unsigned u_len = 16384; const unsigned u_len = 16384;
const unsigned c_extra = 4096; const unsigned c_extra = 4096;

View File

@ -24,13 +24,13 @@
<markus@oberhumer.com> <markus@oberhumer.com>
*/ */
#include "conf.h" #include "../conf.h"
void zstd_compress_config_t::reset() { mem_clear(this, sizeof(*this)); } void zstd_compress_config_t::reset() { mem_clear(this, sizeof(*this)); }
#if WITH_ZSTD #if WITH_ZSTD
#include "compress.h" #include "compress.h"
#include "util/membuffer.h" #include "../util/membuffer.h"
#include <zstd/lib/zstd.h> #include <zstd/lib/zstd.h>
#include <zstd/lib/zstd_errors.h> #include <zstd/lib/zstd_errors.h>
#include <zstd/lib/compress/hist.h> #include <zstd/lib/compress/hist.h>
@ -161,8 +161,6 @@ const char *upx_zstd_version_string(void) { return ZSTD_VERSION_STRING; }
#if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1 #if DEBUG && !defined(DOCTEST_CONFIG_DISABLE) && 1
#include "util/membuffer.h"
static bool check_zstd(const int method, const int level, const unsigned expected_c_len) { static bool check_zstd(const int method, const int level, const unsigned expected_c_len) {
const unsigned u_len = 16384; const unsigned u_len = 16384;
const unsigned c_extra = 4096; const unsigned c_extra = 4096;

View File

@ -583,7 +583,7 @@ constexpr bool string_ge(const char *a, const char *b) {
// compression - setup and callback_t // compression - setup and callback_t
**************************************************************************/ **************************************************************************/
#define WITH_LZMA 0x443 #define WITH_LZMA 1
#define WITH_UCL 1 #define WITH_UCL 1
#define WITH_ZLIB 1 #define WITH_ZLIB 1
#if (WITH_UCL) #if (WITH_UCL)
@ -755,9 +755,11 @@ struct zstd_compress_result_t
struct upx_compress_result_t struct upx_compress_result_t
{ {
// debug // debugging aid
int method, level; struct {
unsigned u_len, c_len; int method, level;
unsigned u_len, c_len;
} debug;
lzma_compress_result_t result_lzma; lzma_compress_result_t result_lzma;
ucl_compress_result_t result_ucl; ucl_compress_result_t result_ucl;
@ -765,7 +767,7 @@ struct upx_compress_result_t
zstd_compress_result_t result_zstd; zstd_compress_result_t result_zstd;
void reset() { void reset() {
memset(this, 0, sizeof(*this)); memset(&this->debug, 0, sizeof(this->debug));
result_lzma.reset(); result_ucl.reset(); result_zlib.reset(); result_zstd.reset(); result_lzma.reset(); result_ucl.reset(); result_zlib.reset(); result_zstd.reset();
} }
}; };
@ -831,9 +833,9 @@ void show_license();
void show_usage(); void show_usage();
void show_version(bool one_line=false); void show_version(bool one_line=false);
// compress.cpp // compress/compress.cpp
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1); unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1);
unsigned upx_crc32(const void *buf, unsigned len, unsigned crc=0); unsigned upx_crc32 (const void *buf, unsigned len, unsigned crc=0);
int upx_compress ( const upx_bytep src, unsigned src_len, int upx_compress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len, upx_bytep dst, unsigned* dst_len,

View File

@ -25,42 +25,34 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com> <ezerotven+github@gmail.com>
*/ */
#include "conf.h" #include "conf.h"
#include "filter.h" #include "filter.h"
#include "file.h" #include "file.h"
/************************************************************************* /*************************************************************************
// util // util
**************************************************************************/ **************************************************************************/
static //inline static void initFilter(Filter *f, upx_byte *buf, unsigned buf_len) {
void initFilter(Filter *f, upx_byte *buf, unsigned buf_len)
{
f->buf = buf; f->buf = buf;
f->buf_len = buf_len; f->buf_len = buf_len;
// clear output parameters // clear output parameters
f->calls = f->wrongcalls = f->noncalls = f->firstcall = f->lastcall = 0; f->calls = f->wrongcalls = f->noncalls = f->firstcall = f->lastcall = 0;
} }
/************************************************************************* /*************************************************************************
// get a FilterEntry // get a FilterEntry
**************************************************************************/ **************************************************************************/
const FilterImp::FilterEntry *FilterImp::getFilter(int id) const FilterImpl::FilterEntry *FilterImpl::getFilter(int id) {
{
static bool done = false; static bool done = false;
static unsigned char filter_map[256]; static unsigned char filter_map[256];
if (!done) if (!done) {
{
// init the filter_map[] // init the filter_map[]
assert(n_filters <= 254); // as 0xff means "empty slot" assert(n_filters <= 254); // as 0xff means "empty slot"
memset(filter_map, 0xff, sizeof(filter_map)); memset(filter_map, 0xff, sizeof(filter_map));
for (int i = 0; i < n_filters; i++) for (int i = 0; i < n_filters; i++) {
{
int filter_id = filters[i].id; int filter_id = filters[i].id;
assert(filter_id >= 0 && filter_id <= 255); assert(filter_id >= 0 && filter_id <= 255);
assert(filter_map[filter_id] == 0xff); assert(filter_map[filter_id] == 0xff);
@ -72,21 +64,18 @@ const FilterImp::FilterEntry *FilterImp::getFilter(int id)
if (id < 0 || id > 255) if (id < 0 || id > 255)
return nullptr; return nullptr;
unsigned index = filter_map[id]; unsigned index = filter_map[id];
if (index == 0xff) // empty slot if (index == 0xff) // empty slot
return nullptr; return nullptr;
assert(filters[index].id == id); assert(filters[index].id == id);
return &filters[index]; return &filters[index];
} }
bool Filter::isValidFilter(int filter_id) {
bool Filter::isValidFilter(int filter_id) const FilterImpl::FilterEntry *const fe = FilterImpl::getFilter(filter_id);
{
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(filter_id);
return fe != nullptr; return fe != nullptr;
} }
bool Filter::isValidFilter(int filter_id, const int *allowed_filters) bool Filter::isValidFilter(int filter_id, const int *allowed_filters) {
{
if (!isValidFilter(filter_id)) if (!isValidFilter(filter_id))
return false; return false;
if (filter_id == 0) if (filter_id == 0)
@ -99,13 +88,11 @@ bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
return false; return false;
} }
/************************************************************************* /*************************************************************************
// high level API // high level API
**************************************************************************/ **************************************************************************/
void Filter::init(int id_, unsigned addvalue_) void Filter::init(int id_, unsigned addvalue_) {
{
this->id = id_; this->id = id_;
initFilter(this, nullptr, 0); initFilter(this, nullptr, 0);
// clear input parameters // clear input parameters
@ -116,12 +103,10 @@ void Filter::init(int id_, unsigned addvalue_)
this->n_mru = 0; this->n_mru = 0;
} }
bool Filter::filter(upx_byte *buf_, unsigned buf_len_) {
bool Filter::filter(upx_byte *buf_, unsigned buf_len_)
{
initFilter(this, buf_, buf_len_); initFilter(this, buf_, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id); const FilterImpl::FilterEntry *const fe = FilterImpl::getFilter(id);
if (fe == nullptr) if (fe == nullptr)
throwInternalError("filter-1"); throwInternalError("filter-1");
if (fe->id == 0) if (fe->id == 0)
@ -138,10 +123,10 @@ bool Filter::filter(upx_byte *buf_, unsigned buf_len_)
if (clevel != 1) if (clevel != 1)
this->adler = upx_adler32(this->buf, this->buf_len); this->adler = upx_adler32(this->buf, this->buf_len);
//printf("filter: %02x %p %d\n", this->id, this->buf, this->buf_len); NO_printf("filter: %02x %p %d\n", this->id, this->buf, this->buf_len);
//OutputFile::dump("filter.dat", buf, buf_len); // OutputFile::dump("filter.dat", buf, buf_len);
int r = (*fe->do_filter)(this); int r = (*fe->do_filter)(this);
//printf("filter: %02x %d\n", fe->id, r); NO_printf("filter: %02x %d\n", fe->id, r);
if (r > 0) if (r > 0)
throwFilterException(); throwFilterException();
if (r == 0) if (r == 0)
@ -149,12 +134,10 @@ bool Filter::filter(upx_byte *buf_, unsigned buf_len_)
return false; return false;
} }
void Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum) {
void Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum)
{
initFilter(this, buf_, buf_len_); initFilter(this, buf_, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id); const FilterImpl::FilterEntry *const fe = FilterImpl::getFilter(id);
if (fe == nullptr) if (fe == nullptr)
throwInternalError("unfilter-1"); throwInternalError("unfilter-1");
if (fe->id == 0) if (fe->id == 0)
@ -166,24 +149,21 @@ void Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum)
if (!fe->do_unfilter) if (!fe->do_unfilter)
throwInternalError("unfilter-2"); throwInternalError("unfilter-2");
//printf("unfilter: %02x %p %d\n", this->id, this->buf, this->buf_len); NO_printf("unfilter: %02x %p %d\n", this->id, this->buf, this->buf_len);
int r = (*fe->do_unfilter)(this); int r = (*fe->do_unfilter)(this);
//printf("unfilter: %02x %d\n", fe->id, r); NO_printf("unfilter: %02x %d\n", fe->id, r);
if (r != 0) if (r != 0)
throwInternalError("unfilter-3"); throwInternalError("unfilter-3");
//OutputFile::dump("unfilter.dat", buf, buf_len); // OutputFile::dump("unfilter.dat", buf, buf_len);
// verify checksum // verify checksum
if (verify_checksum && clevel != 1) if (verify_checksum && clevel != 1) {
{
if (this->adler != upx_adler32(this->buf, this->buf_len)) if (this->adler != upx_adler32(this->buf, this->buf_len))
throwInternalError("unfilter-4"); throwInternalError("unfilter-4");
} }
} }
void Filter::verifyUnfilter() {
void Filter::verifyUnfilter()
{
// Note: // Note:
// This verify is just because of complete paranoia that there // This verify is just because of complete paranoia that there
// could be a hidden bug in the filter implementation, and // could be a hidden bug in the filter implementation, and
@ -193,20 +173,18 @@ void Filter::verifyUnfilter()
// See also: // See also:
// Packer::verifyOverlappingDecompression() // Packer::verifyOverlappingDecompression()
//printf("verifyUnfilter: %02x %p %d\n", this->id, this->buf, this->buf_len); NO_printf("verifyUnfilter: %02x %p %d\n", this->id, this->buf, this->buf_len);
if (clevel != 1) if (clevel != 1)
unfilter(this->buf, this->buf_len, true); unfilter(this->buf, this->buf_len, true);
} }
bool Filter::scan(const upx_byte *buf_, unsigned buf_len_) {
bool Filter::scan(const upx_byte *buf_, unsigned buf_len_)
{
// Note: must use const_cast here. This is fine as the scan // Note: must use const_cast here. This is fine as the scan
// implementations (fe->do_scan) actually don't change the buffer. // implementations (fe->do_scan) actually don't change the buffer.
upx_byte *b = const_cast<upx_byte *>(buf_); upx_byte *b = const_cast<upx_byte *>(buf_);
initFilter(this, b, buf_len_); initFilter(this, b, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id); const FilterImpl::FilterEntry *const fe = FilterImpl::getFilter(id);
if (fe == nullptr) if (fe == nullptr)
throwInternalError("scan-1"); throwInternalError("scan-1");
if (fe->id == 0) if (fe->id == 0)
@ -218,9 +196,9 @@ bool Filter::scan(const upx_byte *buf_, unsigned buf_len_)
if (!fe->do_scan) if (!fe->do_scan)
throwInternalError("scan-2"); throwInternalError("scan-2");
//printf("filter: %02x %p %d\n", this->id, this->buf, this->buf_len); NO_printf("filter: %02x %p %d\n", this->id, this->buf, this->buf_len);
int r = (*fe->do_scan)(this); int r = (*fe->do_scan)(this);
//printf("filter: %02x %d\n", fe->id, r); NO_printf("filter: %02x %d\n", fe->id, r);
if (r > 0) if (r > 0)
throwFilterException(); throwFilterException();
if (r == 0) if (r == 0)

View File

@ -25,13 +25,9 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com> <ezerotven+github@gmail.com>
*/ */
#pragma once
#ifndef __UPX_FILTER_H #ifndef UPX_FILTER_H__
#define __UPX_FILTER_H 1 #define UPX_FILTER_H__ 1
class Filter;
class FilterImp;
/************************************************************************* /*************************************************************************
// A filter is a reversible operation that modifies a given // A filter is a reversible operation that modifies a given
@ -50,14 +46,16 @@ class FilterImp;
// to absolute addresses so that the buffer compresses better. // to absolute addresses so that the buffer compresses better.
**************************************************************************/ **************************************************************************/
class Filter class Filter {
{
public: public:
Filter(int level) { clevel = level; init(); } Filter(int level) {
void init(int id=0, unsigned addvalue=0); clevel = level;
init();
}
void init(int id = 0, unsigned addvalue = 0);
bool filter(upx_byte *buf, unsigned buf_len); bool filter(upx_byte *buf, unsigned buf_len);
void unfilter(upx_byte *buf, unsigned buf_len, bool verify_checksum=false); void unfilter(upx_byte *buf, unsigned buf_len, bool verify_checksum = false);
void verifyUnfilter(); void verifyUnfilter();
bool scan(const upx_byte *buf, unsigned buf_len); bool scan(const upx_byte *buf, unsigned buf_len);
@ -79,7 +77,7 @@ public:
const int *preferred_ctos = nullptr; const int *preferred_ctos = nullptr;
// Input/output parameters used by various filters // Input/output parameters used by various filters
unsigned char cto; // call trick offset unsigned char cto; // call trick offset
// Output used by various filters. Read only. // Output used by various filters. Read only.
unsigned calls; unsigned calls;
@ -87,16 +85,15 @@ public:
unsigned wrongcalls; unsigned wrongcalls;
unsigned firstcall; unsigned firstcall;
unsigned lastcall; unsigned lastcall;
unsigned n_mru; // ctojr only unsigned n_mru; // ctojr only
// Read only. // Read only.
int id; int id;
private: private:
int clevel; // compression level int clevel; // compression level
}; };
/************************************************************************* /*************************************************************************
// We don't want a full OO interface here because of // We don't want a full OO interface here because of
// certain implementation speed reasons. // certain implementation speed reasons.
@ -104,19 +101,17 @@ private:
// This class is private to Filter - don't look. // This class is private to Filter - don't look.
**************************************************************************/ **************************************************************************/
class FilterImp class FilterImpl {
{
friend class Filter; friend class Filter;
private: private:
struct FilterEntry struct FilterEntry {
{ int id; // 0 .. 255
int id; // 0 .. 255
unsigned min_buf_len; unsigned min_buf_len;
unsigned max_buf_len; unsigned max_buf_len;
int (*do_filter)(Filter *); // filter a buffer int (*do_filter)(Filter *); // filter a buffer
int (*do_unfilter)(Filter *); // unfilter a buffer int (*do_unfilter)(Filter *); // unfilter a buffer
int (*do_scan)(Filter *); // scan a buffer int (*do_scan)(Filter *); // scan a buffer
}; };
// get a specific filter entry // get a specific filter entry
@ -125,10 +120,9 @@ private:
private: private:
// strictly private filter database // strictly private filter database
static const FilterEntry filters[]; static const FilterEntry filters[];
static const int n_filters; // number of filters[] static const int n_filters; // number of filters[]
}; };
#endif /* already included */ #endif /* already included */
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */

View File

@ -1,4 +1,4 @@
/* filteri.cpp -- filter implementation (low-level) /* filter_impl.cpp -- filter implementation (low-level)
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
@ -26,8 +26,8 @@
*/ */
#include "conf.h" #include "../conf.h"
#include "filter.h" #include "../filter.h"
static unsigned static unsigned
umin(unsigned const a, unsigned const b) umin(unsigned const a, unsigned const b)
@ -45,20 +45,20 @@ umin(unsigned const a, unsigned const b)
// util // util
**************************************************************************/ **************************************************************************/
#include "filter/getcto.h" #include "getcto.h"
/************************************************************************* /*************************************************************************
// simple filters: calltrick / swaptrick / delta / ... // simple filters: calltrick / swaptrick / delta / ...
**************************************************************************/ **************************************************************************/
#include "filter/ct.h" #include "ct.h"
#include "filter/sw.h" #include "sw.h"
#include "filter/ctsw.h" #include "ctsw.h"
#include "filter/sub8.h" #include "sub8.h"
#include "filter/sub16.h" #include "sub16.h"
#include "filter/sub32.h" #include "sub32.h"
/************************************************************************* /*************************************************************************
@ -68,25 +68,25 @@ umin(unsigned const a, unsigned const b)
#define COND(b,x) (b[x] == 0xe8) #define COND(b,x) (b[x] == 0xe8)
#define F f_cto32_e8_bswap_le #define F f_cto32_e8_bswap_le
#define U u_cto32_e8_bswap_le #define U u_cto32_e8_bswap_le
#include "filter/cto.h" #include "cto.h"
#define F s_cto32_e8_bswap_le #define F s_cto32_e8_bswap_le
#include "filter/cto.h" #include "cto.h"
#undef COND #undef COND
#define COND(b,x) (b[x] == 0xe9) #define COND(b,x) (b[x] == 0xe9)
#define F f_cto32_e9_bswap_le #define F f_cto32_e9_bswap_le
#define U u_cto32_e9_bswap_le #define U u_cto32_e9_bswap_le
#include "filter/cto.h" #include "cto.h"
#define F s_cto32_e9_bswap_le #define F s_cto32_e9_bswap_le
#include "filter/cto.h" #include "cto.h"
#undef COND #undef COND
#define COND(b,x) (b[x] == 0xe8 || b[x] == 0xe9) #define COND(b,x) (b[x] == 0xe8 || b[x] == 0xe9)
#define F f_cto32_e8e9_bswap_le #define F f_cto32_e8e9_bswap_le
#define U u_cto32_e8e9_bswap_le #define U u_cto32_e8e9_bswap_le
#include "filter/cto.h" #include "cto.h"
#define F s_cto32_e8e9_bswap_le #define F s_cto32_e8e9_bswap_le
#include "filter/cto.h" #include "cto.h"
#undef COND #undef COND
@ -97,9 +97,9 @@ umin(unsigned const a, unsigned const b)
#define COND(b,x,lastcall) (b[x] == 0xe8 || b[x] == 0xe9) #define COND(b,x,lastcall) (b[x] == 0xe8 || b[x] == 0xe9)
#define F f_ctoj32_e8e9_bswap_le #define F f_ctoj32_e8e9_bswap_le
#define U u_ctoj32_e8e9_bswap_le #define U u_ctoj32_e8e9_bswap_le
#include "filter/ctoj.h" #include "ctoj.h"
#define F s_ctoj32_e8e9_bswap_le #define F s_ctoj32_e8e9_bswap_le
#include "filter/ctoj.h" #include "ctoj.h"
#undef COND #undef COND
@ -112,9 +112,9 @@ umin(unsigned const a, unsigned const b)
#define COND(b,x,lc,id) (COND1(b,x) || ((9<=(0xf&(id))) && COND2(b,x,lc))) #define COND(b,x,lc,id) (COND1(b,x) || ((9<=(0xf&(id))) && COND2(b,x,lc)))
#define F f_ctok32_e8e9_bswap_le #define F f_ctok32_e8e9_bswap_le
#define U u_ctok32_e8e9_bswap_le #define U u_ctok32_e8e9_bswap_le
#include "filter/ctok.h" #include "ctok.h"
#define F s_ctok32_e8e9_bswap_le #define F s_ctok32_e8e9_bswap_le
#include "filter/ctok.h" #include "ctok.h"
#undef COND #undef COND
#undef COND2 #undef COND2
#undef COND1 #undef COND1
@ -138,9 +138,9 @@ umin(unsigned const a, unsigned const b)
#define F f_ctojr32_e8e9_bswap_le #define F f_ctojr32_e8e9_bswap_le
#define U u_ctojr32_e8e9_bswap_le #define U u_ctojr32_e8e9_bswap_le
#include "filter/ctojr.h" #include "ctojr.h"
#define F s_ctojr32_e8e9_bswap_le #define F s_ctojr32_e8e9_bswap_le
#include "filter/ctojr.h" #include "ctojr.h"
#undef CONDU #undef CONDU
#undef CONDF #undef CONDF
@ -158,9 +158,9 @@ umin(unsigned const a, unsigned const b)
#define COND(b,x) (18==(get_be32(b+x)>>26)) #define COND(b,x) (18==(get_be32(b+x)>>26))
#define F f_ppcbxx #define F f_ppcbxx
#define U u_ppcbxx #define U u_ppcbxx
#include "filter/ppcbxx.h" #include "ppcbxx.h"
#define F s_ppcbxx #define F s_ppcbxx
#include "filter/ppcbxx.h" #include "ppcbxx.h"
#undef COND #undef COND
@ -168,7 +168,7 @@ umin(unsigned const a, unsigned const b)
// database for use in class Filter // database for use in class Filter
**************************************************************************/ **************************************************************************/
const FilterImp::FilterEntry FilterImp::filters[] = { const FilterImpl::FilterEntry FilterImpl::filters[] = {
// no filter // no filter
{ 0x00, 0, 0, nullptr, nullptr, nullptr }, { 0x00, 0, 0, nullptr, nullptr, nullptr },
@ -261,6 +261,6 @@ const FilterImp::FilterEntry FilterImp::filters[] = {
{ 0xd0, 8, 0, f_ppcbxx, u_ppcbxx, s_ppcbxx }, { 0xd0, 8, 0, f_ppcbxx, u_ppcbxx, s_ppcbxx },
}; };
const int FilterImp::n_filters = TABLESIZE(filters); const int FilterImpl::n_filters = TABLESIZE(filters);
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */

View File

@ -27,9 +27,9 @@
#include "conf.h" #include "conf.h"
#include "compress.h"
#include "packmast.h" #include "packmast.h"
#include "packer.h" #include "packer.h"
#include "compress/compress.h" // upx_ucl_version_string()
/************************************************************************* /*************************************************************************

View File

@ -28,10 +28,10 @@
// main entry, mostly boring stuff; see work.cpp for actual action // main entry, mostly boring stuff; see work.cpp for actual action
#include "conf.h" #include "conf.h"
#include "compress.h"
#include "file.h" #include "file.h"
#include "packer.h" #include "packer.h"
#include "p_elf.h" #include "p_elf.h"
#include "compress/compress.h" // upx_ucl_init()
/************************************************************************* /*************************************************************************
// options // options
@ -1207,6 +1207,9 @@ int upx_main(int argc, char *argv[]) {
set_term(stderr); set_term(stderr);
#if (WITH_BZIP2)
assert(upx_bzip2_init() == 0);
#endif
assert(upx_lzma_init() == 0); assert(upx_lzma_init() == 0);
#if (WITH_NRV) #if (WITH_NRV)
assert(upx_nrv_init() == 0); assert(upx_nrv_init() == 0);