From f962afe146c8b0204fc7061f5df90526cc214160 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Mon, 4 Jan 2021 17:20:57 +0100 Subject: [PATCH] Various cosmetic updates and refactors. NFCI. --- .github/workflows/ci.yml | 4 +- src/bele.h | 129 +++++++++++++++++---------------------- src/bele_policy.h | 7 ++- src/bptr.h | 2 +- src/compress_ucl.cpp | 30 --------- src/compress_zlib.cpp | 11 +--- src/conf.h | 37 ++++++----- src/except.h | 2 +- src/main.cpp | 4 +- src/mem.h | 2 +- src/packer.cpp | 2 +- src/packer.h | 2 +- src/packer_c.cpp | 7 +-- src/snprintf.cpp | 2 +- src/snprintf.h | 2 +- src/stdcxx.cpp | 46 -------------- src/stdcxx.h | 56 ----------------- src/ui.cpp | 2 +- src/ui.h | 3 +- src/util.cpp | 26 +------- 20 files changed, 92 insertions(+), 284 deletions(-) delete mode 100644 src/stdcxx.cpp delete mode 100644 src/stdcxx.h diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7d07654..b1a6ad29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,7 +122,7 @@ jobs: export BUILD_LOCAL_UCL=1 bash ./.github/travis_build.sh - - name: 'Run test suite' + - name: 'Run test suite using Wine' run: | export C=${{matrix.C}} B=${{matrix.B}} T=${{matrix.T}} X=${{matrix.X}} TRAVIS_OS_NAME=linux export CROSS=${{matrix.CROSS}} @@ -195,7 +195,7 @@ jobs: set s=%H%\upx\src cat .GITREV.txt set /p GITREV=<.GITREV.txt - cl -MT -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -DUCL_NO_ASM -I%s%\lzma-sdk -I%H%\deps\ucl-1.03\include -I%H%\deps\zlib-1.2.11 -Feupx.exe %s%\*.cpp %BDIR%\ucl-1.03\ucl.lib %BDIR%\zlib-1.2.11\zlib.lib + cl -MT -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -I%s%\lzma-sdk -I%H%\deps\ucl-1.03\include -I%H%\deps\zlib-1.2.11 -Feupx.exe %s%\*.cpp %BDIR%\ucl-1.03\ucl.lib %BDIR%\zlib-1.2.11\zlib.lib - name: 'Basic tests' shell: cmd diff --git a/src/bele.h b/src/bele.h index 83757082..ba78369b 100644 --- a/src/bele.h +++ b/src/bele.h @@ -31,8 +31,8 @@ // BE - Big Endian // LE - Little Endian -// NE - Native Endiannes (aka host endianness) -// TE - Target Endiannes +// NE - Native Endianness (aka host endianness) +// TE - Target Endianness (not used here, see various packers) /************************************************************************* // core - NE @@ -103,7 +103,7 @@ __acc_static_forceinline upx_uint64_t bswap64(upx_uint64_t v) __acc_static_forceinline constexpr unsigned bswap16(unsigned v) { - //return __builtin_bswap16((upx_uint16_t) v); + //return __builtin_bswap16((upx_uint16_t) (v & 0xffff)); //return (unsigned) __builtin_bswap64((upx_uint64_t) v << 48); return __builtin_bswap32(v << 16); } @@ -161,56 +161,56 @@ inline unsigned get_be16(const void *p) return ne16_to_be16(get_ne16(p)); } -inline void set_be16(void *p, unsigned v) -{ - set_ne16(p, ne16_to_be16(v)); -} - inline unsigned get_be32(const void *p) { return ne32_to_be32(get_ne32(p)); } -inline void set_be32(void *p, unsigned v) -{ - set_ne32(p, ne32_to_be32(v)); -} - inline upx_uint64_t get_be64(const void *p) { return ne64_to_be64(get_ne64(p)); } -inline void set_be64(void *p, upx_uint64_t v) -{ - set_ne64(p, ne64_to_be64(v)); -} - inline unsigned get_le16(const void *p) { return ne16_to_le16(get_ne16(p)); } -inline void set_le16(void *p, unsigned v) -{ - set_ne16(p, ne16_to_le16(v)); -} - inline unsigned get_le32(const void *p) { return ne32_to_le32(get_ne32(p)); } -inline void set_le32(void *p, unsigned v) -{ - set_ne32(p, ne32_to_le32(v)); -} - inline upx_uint64_t get_le64(const void *p) { return ne64_to_le64(get_ne64(p)); } +inline void set_be16(void *p, unsigned v) +{ + set_ne16(p, ne16_to_be16(v)); +} + +inline void set_be32(void *p, unsigned v) +{ + set_ne32(p, ne32_to_be32(v)); +} + +inline void set_be64(void *p, upx_uint64_t v) +{ + set_ne64(p, ne64_to_be64(v)); +} + +inline void set_le16(void *p, unsigned v) +{ + set_ne16(p, ne16_to_le16(v)); +} + +inline void set_le32(void *p, unsigned v) +{ + set_ne32(p, ne32_to_le32(v)); +} + inline void set_le64(void *p, upx_uint64_t v) { set_ne64(p, ne64_to_le64(v)); @@ -227,6 +227,12 @@ inline unsigned get_be24(const void *p) return (b[0] << 16) | (b[1] << 8) | (b[2] << 0); } +inline unsigned get_le24(const void *p) +{ + const unsigned char *b = ACC_CCAST(const unsigned char *, p); + return (b[0] << 0) | (b[1] << 8) | (b[2] << 16); +} + inline void set_be24(void *p, unsigned v) { unsigned char *b = ACC_PCAST(unsigned char *, p); @@ -235,12 +241,6 @@ inline void set_be24(void *p, unsigned v) b[2] = ACC_ICONV(unsigned char, (v >> 0) & 0xff); } -inline unsigned get_le24(const void *p) -{ - const unsigned char *b = ACC_CCAST(const unsigned char *, p); - return (b[0] << 0) | (b[1] << 8) | (b[2] << 16); -} - inline void set_le24(void *p, unsigned v) { unsigned char *b = ACC_PCAST(unsigned char *, p); @@ -258,20 +258,17 @@ inline unsigned get_le26(const void *p) inline void set_le26(void *p, unsigned v) { // preserve the top 6 bits -#if 0 - set_le32(p, (get_le32(p) & 0xfc000000) | (v & 0x03ffffff)); -#else - // optimized version, saving a bswap32 - set_ne32(p, (get_ne32(p) & ne32_to_le32(0xfc000000)) | ne32_to_le32(v & 0x03ffffff)); -#endif + //set_le32(p, (get_le32(p) & 0xfc000000) | (v & 0x03ffffff)); + // optimized version, saving a runtime bswap32 + set_ne32(p, (get_ne32(p) & ne32_to_le32(0xfc000000)) | (ne32_to_le32(v) & ne32_to_le32(0x03ffffff))); } /************************************************************************* -// get signed values, i.e. sign-extend +// get signed values **************************************************************************/ -inline int sign_extend(unsigned v, unsigned bits) +__acc_static_forceinline int sign_extend(unsigned v, unsigned bits) { const unsigned sign_bit = 1u << (bits - 1); v &= sign_bit | (sign_bit - 1); @@ -279,7 +276,7 @@ inline int sign_extend(unsigned v, unsigned bits) return ACC_ICAST(int, v); } -inline upx_int64_t sign_extend(upx_uint64_t v, unsigned bits) +__acc_static_forceinline upx_int64_t sign_extend(upx_uint64_t v, unsigned bits) { const upx_uint64_t sign_bit = UPX_UINT64_C(1) << (bits - 1); v &= sign_bit | (sign_bit - 1); @@ -455,6 +452,7 @@ __packed_struct(LE64) __packed_struct_end() +// native types #if (ACC_ABI_BIG_ENDIAN) typedef BE16 NE16; typedef BE32 NE32; @@ -467,45 +465,27 @@ typedef LE64 NE64; /************************************************************************* -// global operators +// global operators (pointer addition/subtraction) **************************************************************************/ -template -inline T* operator + (T* ptr, const BE16& v) { return ptr + (unsigned) v; } -template -inline T* operator + (const BE16& v, T* ptr) { return ptr + (unsigned) v; } -template -inline T* operator - (T* ptr, const BE16& v) { return ptr - (unsigned) v; } +template inline T* operator + (T* ptr, const BE16& v) { return ptr + (unsigned) v; } +template inline T* operator - (T* ptr, const BE16& v) { return ptr - (unsigned) v; } -template -inline T* operator + (T* ptr, const BE32& v) { return ptr + (unsigned) v; } -template -inline T* operator + (const BE32& v, T* ptr) { return ptr + (unsigned) v; } -template -inline T* operator - (T* ptr, const BE32& v) { return ptr - (unsigned) v; } +template inline T* operator + (T* ptr, const BE32& v) { return ptr + (unsigned) v; } +template inline T* operator - (T* ptr, const BE32& v) { return ptr - (unsigned) v; } // these are not implemented on purpose and will cause link-time errors template T* operator + (T* ptr, const BE64& v); -template T* operator + (const BE64& v, T* ptr); template T* operator - (T* ptr, const BE64& v); -template -inline T* operator + (T* ptr, const LE16& v) { return ptr + (unsigned) v; } -template -inline T* operator + (const LE16& v, T* ptr) { return ptr + (unsigned) v; } -template -inline T* operator - (T* ptr, const LE16& v) { return ptr - (unsigned) v; } +template inline T* operator + (T* ptr, const LE16& v) { return ptr + (unsigned) v; } +template inline T* operator - (T* ptr, const LE16& v) { return ptr - (unsigned) v; } -template -inline T* operator + (T* ptr, const LE32& v) { return ptr + (unsigned) v; } -template -inline T* operator + (const LE32& v, T* ptr) { return ptr + (unsigned) v; } -template -inline T* operator - (T* ptr, const LE32& v) { return ptr - (unsigned) v; } +template inline T* operator + (T* ptr, const LE32& v) { return ptr + (unsigned) v; } +template inline T* operator - (T* ptr, const LE32& v) { return ptr - (unsigned) v; } // these are not implemented on purpose and will cause link-time errors template T* operator + (T* ptr, const LE64& v); -template T* operator + (const LE64& v, T* ptr); template T* operator - (T* ptr, const LE64& v); @@ -545,7 +525,7 @@ inline unsigned UPX_MIN(const LE32& a, unsigned b) { return UPX_MIN((unsigned /************************************************************************* -// misc +// misc support **************************************************************************/ // for use with qsort() @@ -591,22 +571,23 @@ extern const BEPolicy be_policy; extern const LEPolicy le_policy; } +// implementation namespace N_BELE_CTP { #define BELE_CTP 1 #include "bele_policy.h" #undef BELE_CTP } - namespace N_BELE_RTP { #define BELE_RTP 1 #include "bele_policy.h" #undef BELE_RTP } +// util namespace N_BELE_CTP { -inline const N_BELE_RTP::AbstractPolicy* getRTP(const BEPolicy*) +inline const N_BELE_RTP::AbstractPolicy* getRTP(const BEPolicy * /*dummy*/) { return &N_BELE_RTP::be_policy; } -inline const N_BELE_RTP::AbstractPolicy* getRTP(const LEPolicy*) +inline const N_BELE_RTP::AbstractPolicy* getRTP(const LEPolicy * /*dummy*/) { return &N_BELE_RTP::le_policy; } } diff --git a/src/bele_policy.h b/src/bele_policy.h index 2d712e92..b0a6e5d6 100644 --- a/src/bele_policy.h +++ b/src/bele_policy.h @@ -84,7 +84,7 @@ struct AbstractPolicy S u64_compare_signed(const void *a, const void *b) C = 0; // disable dynamic allocation - DISABLE_NEW_DELETE + ACC_CXX_DISABLE_NEW_DELETE }; #endif @@ -162,7 +162,7 @@ struct BEPolicy } // disable dynamic allocation - DISABLE_NEW_DELETE + ACC_CXX_DISABLE_NEW_DELETE }; @@ -239,10 +239,11 @@ struct LEPolicy } // disable dynamic allocation - DISABLE_NEW_DELETE + ACC_CXX_DISABLE_NEW_DELETE }; +// native policy (aka host policy) #if (ACC_ABI_BIG_ENDIAN) typedef BEPolicy HostPolicy; #elif (ACC_ABI_LITTLE_ENDIAN) diff --git a/src/bptr.h b/src/bptr.h index e6a4cc61..c01af246 100644 --- a/src/bptr.h +++ b/src/bptr.h @@ -97,7 +97,7 @@ private: // disable copy BoundedPtr(const BoundedPtr&) = delete; // disable dynamic allocation - DISABLE_NEW_DELETE + ACC_CXX_DISABLE_NEW_DELETE }; diff --git a/src/compress_ucl.cpp b/src/compress_ucl.cpp index 6d235509..71d6e95f 100644 --- a/src/compress_ucl.cpp +++ b/src/compress_ucl.cpp @@ -28,34 +28,6 @@ #include "conf.h" #include "compress.h" -#if !(WITH_UCL) -extern int compress_ucl_dummy; -int compress_ucl_dummy = 0; -#else - -#if 1 && !(UCL_USE_ASM) && (ACC_ARCH_I386) -# if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_WATCOMC) -# define UCL_USE_ASM 1 -# endif -#endif -#if (UCL_NO_ASM) -# undef UCL_USE_ASM -#endif -#if (ACC_CFG_NO_UNALIGNED) -# undef UCL_USE_ASM -#endif -#if 1 && (UCL_USE_ASM) -# include -# define ucl_nrv2b_decompress_safe_8 ucl_nrv2b_decompress_asm_safe_8 -# define ucl_nrv2b_decompress_safe_le16 ucl_nrv2b_decompress_asm_safe_le16 -# define ucl_nrv2b_decompress_safe_le32 ucl_nrv2b_decompress_asm_safe_le32 -# define ucl_nrv2d_decompress_safe_8 ucl_nrv2d_decompress_asm_safe_8 -# define ucl_nrv2d_decompress_safe_le16 ucl_nrv2d_decompress_asm_safe_le16 -# define ucl_nrv2d_decompress_safe_le32 ucl_nrv2d_decompress_asm_safe_le32 -# define ucl_nrv2e_decompress_safe_8 ucl_nrv2e_decompress_asm_safe_8 -# define ucl_nrv2e_decompress_safe_le16 ucl_nrv2e_decompress_asm_safe_le16 -# define ucl_nrv2e_decompress_safe_le32 ucl_nrv2e_decompress_asm_safe_le32 -#endif /************************************************************************* @@ -315,6 +287,4 @@ unsigned upx_ucl_crc32(const void *buf, unsigned len, unsigned crc) } #endif -#endif /* WITH_UCL */ - /* vim:set ts=4 sw=4 et: */ diff --git a/src/compress_zlib.cpp b/src/compress_zlib.cpp index 323b5833..1d122a7f 100644 --- a/src/compress_zlib.cpp +++ b/src/compress_zlib.cpp @@ -29,6 +29,7 @@ #include "conf.h" #include "compress.h" #include "mem.h" +#include void zlib_compress_config_t::reset() @@ -41,14 +42,6 @@ void zlib_compress_config_t::reset() } -#if !(WITH_ZLIB) -extern int compress_zlib_dummy; -int compress_zlib_dummy = 0; -#else - -#include - - static int convert_errno_from_zlib(int zr) { switch (zr) @@ -251,6 +244,4 @@ unsigned upx_zlib_crc32(const void *buf, unsigned len, unsigned crc) #endif -#endif /* WITH_ZLIB */ - /* vim:set ts=4 sw=4 et: */ diff --git a/src/conf.h b/src/conf.h index e268b7b8..3e289cc4 100644 --- a/src/conf.h +++ b/src/conf.h @@ -76,6 +76,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER(((int)(1u << 31)) >> 31 == -1) // arithmetic righ ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char +// enable/disable some warnings #if (ACC_CC_GNUC >= 0x040700) # pragma GCC diagnostic error "-Wzero-as-null-pointer-constant" #endif @@ -89,14 +90,6 @@ ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char # pragma warning(disable: 4820) // padding added after data member #endif -// FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages) -#if 1 && (ACC_ARCH_ARM) && defined(__pe__) && !defined(__CEGCC__) && !defined(_WIN32) -# undef HAVE_CHMOD -# undef HAVE_CHOWN -# undef HAVE_LSTAT -# undef HAVE_UTIME -#endif - #define ACC_WANT_ACC_INCD_H 1 #define ACC_WANT_ACC_INCE_H 1 #define ACC_WANT_ACC_LIB_H 1 @@ -457,12 +450,6 @@ private: #define UPX_F_VMLINUX_PPC64 141 #define UPX_F_DYLIB_PPC64 142 -// compression methods -#define M_ALL (-1) -#define M_END (-2) -#define M_NONE (-3) -#define M_SKIP (-4) -#define M_ULTRA_BRUTE (-5) // compression methods - DO NOT CHANGE #define M_NRV2B_LE32 2 #define M_NRV2B_8 3 @@ -478,6 +465,12 @@ private: //#define M_CL1B_LE16 13 #define M_LZMA 14 #define M_DEFLATE 15 /* zlib */ +// compression methods internal usage +#define M_ALL (-1) +#define M_END (-2) +#define M_NONE (-3) +#define M_SKIP (-4) +#define M_ULTRA_BRUTE (-5) #define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16) #define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16) @@ -670,13 +663,11 @@ struct upx_compress_result_t **************************************************************************/ #include "snprintf.h" // must get included first! -#include "stdcxx.h" -#include "options.h" -#include "except.h" -#include "bele.h" -#include "util.h" -#include "console.h" +#include +#include +#include +#include ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same::value)) ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same::value)) ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same::value)) @@ -684,6 +675,12 @@ ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same::value)) ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same::value)) ACC_COMPILE_TIME_ASSERT_HEADER((std::is_same::value)) +#include "options.h" +#include "except.h" +#include "bele.h" +#include "util.h" +#include "console.h" + // classes class ElfLinker; diff --git a/src/except.h b/src/except.h index f2e07c0b..4ae25b1c 100644 --- a/src/except.h +++ b/src/except.h @@ -59,7 +59,7 @@ private: // disable assignment Throwable& operator= (const Throwable &); // disable dynamic allocation - DISABLE_NEW_DELETE + ACC_CXX_DISABLE_NEW_DELETE private: static unsigned long counter; // for debugging diff --git a/src/main.cpp b/src/main.cpp index 67ebdd56..0f7fa4c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1404,7 +1404,7 @@ void upx_compiler_sanity_check(void) } { unsigned dd; - void *d = ⅆ + void * const d = ⅆ dd = ne32_to_le32(0xf7f6f5f4); assert(get_le26(d) == 0x03f6f5f4); set_le26(d, 0); @@ -1423,7 +1423,7 @@ void upx_compiler_sanity_check(void) assert(testNoAliasing(&u.v_short, &u.l32)); assert(testNoAliasing(&u.v_int, &u.b64)); assert(testNoAliasing(&u.v_int, &u.l64)); -#if 0 +#if 1 // check working -fno-strict-aliasing assert(testNoAliasing(&u.v_short, &u.v_int)); assert(testNoAliasing(&u.v_int, &u.v_long)); diff --git a/src/mem.h b/src/mem.h index 6b14cdc4..fc4904df 100644 --- a/src/mem.h +++ b/src/mem.h @@ -80,7 +80,7 @@ private: MemBuffer& operator= (const MemBuffer &) = delete; // disable dynamic allocation - DISABLE_NEW_DELETE + ACC_CXX_DISABLE_NEW_DELETE }; #endif /* already included */ diff --git a/src/packer.cpp b/src/packer.cpp index b35d9244..5692bd77 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -753,7 +753,7 @@ bool Packer::getPackHeader(void *b, int blen, bool allow_incompressible) bool Packer::readPackHeader(int len, bool allow_incompressible) { - assert((int)len > 0); + assert(len > 0); MemBuffer buf(len); len = fi->read(buf, len); if (len <= 0) diff --git a/src/packer.h b/src/packer.h index b4cc432a..36011dc8 100644 --- a/src/packer.h +++ b/src/packer.h @@ -49,7 +49,7 @@ class PackHeader friend class Packer; private: - // these are strictly private to Packer and not accessible in subclasses: + // these are strictly private to Packer and not accessible in subclasses PackHeader(); void putPackHeader(upx_bytep p); diff --git a/src/packer_c.cpp b/src/packer_c.cpp index 4a0f70e5..8991eb34 100644 --- a/src/packer_c.cpp +++ b/src/packer_c.cpp @@ -38,13 +38,8 @@ bool Packer::isValidCompressionMethod(int method) { - if (M_IS_LZMA(method)) { -#if !(WITH_LZMA) - assert(0 && "Internal error - LZMA not compiled in"); -#else + if (M_IS_LZMA(method)) return true; -#endif - } return (method >= M_NRV2B_LE32 && method <= M_LZMA); } diff --git a/src/snprintf.cpp b/src/snprintf.cpp index 1f1c6c3f..75915269 100644 --- a/src/snprintf.cpp +++ b/src/snprintf.cpp @@ -900,7 +900,7 @@ int main(void) "%d", nullptr }; - const long int_nums[] = { -1, 134, 91340, 341, 0203, 0 }; + const int int_nums[] = { -1, 134, 91340, 341, 0203, 0 }; const char *str_fmt[] = { "10.5s", "5.10s", diff --git a/src/snprintf.h b/src/snprintf.h index d87fbfc0..35a9d6b8 100644 --- a/src/snprintf.h +++ b/src/snprintf.h @@ -70,7 +70,7 @@ inline int strcasecmp(const unsigned char *s1, const unsigned char *s2) { return strcasecmp((const char *) s1, (const char *) s2); } -inline size_t strlen(const unsigned char *s) { return strlen((const char *) s); } +inline upx_rsize_t upx_strlen(const unsigned char *s) { return upx_strlen((const char *) s); } #endif /* already included */ diff --git a/src/stdcxx.cpp b/src/stdcxx.cpp deleted file mode 100644 index 3feb99cb..00000000 --- a/src/stdcxx.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* stdcxx.cpp -- - - This file is part of the UPX executable compressor. - - Copyright (C) 1996-2021 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2021 Laszlo Molnar - All Rights Reserved. - - UPX and the UCL library are free software; you can redistribute them - and/or modify them under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer Laszlo Molnar - - */ - -#include "conf.h" -#include "stdcxx.h" - -#if 1 && defined(__linux__) && (ACC_CC_GNUC >= 0x030400) -/* this is used by __gnu_cxx::__verbose_terminate_handler() */ -extern "C" { -char *__attribute__((__weak__)) __cxa_demangle(const char *, char *, size_t *, int *); -char *__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status) { - UNUSED(mangled_name); - UNUSED(buf); - UNUSED(n); - if (status) - *status = -1; /* memory_allocation_failure */ - return nullptr; -} -} /* extern "C" */ -#endif - -/* vim:set ts=4 sw=4 et: */ diff --git a/src/stdcxx.h b/src/stdcxx.h deleted file mode 100644 index 9d76372f..00000000 --- a/src/stdcxx.h +++ /dev/null @@ -1,56 +0,0 @@ -/* stdcxx.h -- - - This file is part of the UPX executable compressor. - - Copyright (C) 1996-2021 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996-2021 Laszlo Molnar - All Rights Reserved. - - UPX and the UCL library are free software; you can redistribute them - and/or modify them under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Markus F.X.J. Oberhumer Laszlo Molnar - - */ - -#ifndef __UPX_STDCXX_H -#define __UPX_STDCXX_H 1 - -#ifdef __cplusplus - -#define DISABLE_NEW_DELETE ACC_CXX_DISABLE_NEW_DELETE - -/************************************************************************* -// exceptions & RTTI -**************************************************************************/ - -#include -#include -#include -#include - -/************************************************************************* -// STL -**************************************************************************/ - -#ifdef WANT_STL -#error "WANT_STL" -#endif /* WANT_STL */ - -#endif /* __cplusplus */ - -#endif /* already included */ - -/* vim:set ts=4 sw=4 et: */ diff --git a/src/ui.cpp b/src/ui.cpp index 23aeabf9..f6e300fa 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -1,4 +1,4 @@ -/* ui.cpp -- +/* ui.cpp -- User Interface This file is part of the UPX executable compressor. diff --git a/src/ui.h b/src/ui.h index 484a562c..8b68a6c9 100644 --- a/src/ui.h +++ b/src/ui.h @@ -1,4 +1,4 @@ -/* ui.h -- +/* ui.h -- User Interface This file is part of the UPX executable compressor. @@ -51,7 +51,6 @@ public: static void uiTestTotal(); static void uiFileInfoTotal(); -public: virtual void uiPackStart(const OutputFile *fo); virtual void uiPackEnd(const OutputFile *fo); virtual void uiUnpackStart(const OutputFile *fo); diff --git a/src/util.cpp b/src/util.cpp index 0367f06d..4d898ef3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -46,6 +46,7 @@ /************************************************************************* // assert sane memory buffer sizes to protect against integer overflows // and malicious header fields +// see C 11 standard, Annex K **************************************************************************/ ACC_COMPILE_TIME_ASSERT_HEADER(UPX_RSIZE_MAX_MEM == UPX_RSIZE_MAX) @@ -517,29 +518,4 @@ unsigned get_ratio(upx_uint64_t u_len, upx_uint64_t c_len) { return ACC_ICONV(unsigned, x); } -/************************************************************************* -// Don't link these functions from libc ==> save xxx bytes -**************************************************************************/ - -extern "C" { - -// FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages) -#if 1 && (ACC_ARCH_ARM) && defined(__pe__) && !defined(__CEGCC__) && !defined(_WIN32) -int dup(int fd) { - UNUSED(fd); - return -1; -} -#endif - -#if (ACC_OS_DOS32) && defined(__DJGPP__) -// int _is_executable(const char *, int, const char *) { return 0; } - -// FIXME: something wants to link in ctime.o -// time_t mktime(struct tm *) { return 0; } - -// time_t time(time_t *t) { if (t) *t = 0; return 0; } -#endif - -} // extern "C" - /* vim:set ts=4 sw=4 et: */