all: cosmetic cleanups

This commit is contained in:
Markus F.X.J. Oberhumer 2023-09-18 15:19:37 +02:00
parent 57ad6bc37d
commit 06675acc67
21 changed files with 174 additions and 70 deletions

View File

@ -12,8 +12,8 @@ env:
CMAKE_REQUIRED_QUIET: OFF
DEBIAN_FRONTEND: noninteractive
UPX_CMAKE_BUILD_FLAGS: --verbose
# 2023-09-10
ZIG_DIST_VERSION: 0.12.0-dev.294+4d1432299
# 2023-09-18
ZIG_DIST_VERSION: 0.12.0-dev.409+48e2ba3b3
jobs:
job-rebuild-and-verify-stubs:

View File

@ -1,5 +1,5 @@
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
# CC CompilationCheck: test various gcc+mingw versions
# CC CompilationCheck: compile with various mingw-gcc versions and run tests under Wine
name: 'Weekly CI CC - Alpine Linux MinGW'
on:

View File

@ -10,8 +10,8 @@ on:
env:
CMAKE_REQUIRED_QUIET: OFF
DEBIAN_FRONTEND: noninteractive
# 2023-09-10
ZIG_DIST_VERSION: 0.12.0-dev.294+4d1432299
# 2023-09-18
ZIG_DIST_VERSION: 0.12.0-dev.409+48e2ba3b3
jobs:
job-linux-zigcc: # uses cmake + make

View File

@ -20,6 +20,28 @@ endif
# enable this if you prefer Ninja for the actual builds:
#UPX_CMAKE_CONFIG_FLAGS += -G Ninja
# CMake honors CC and CXX; explicitly pass optional CMAKE_AR and CMAKE_RANLIB
is_set = $(and $($1),$(or $(findstring command line,$(origin $1)),$(findstring environment,$(origin $1))))
ifneq ($(call is_set,CMAKE_AR),)
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_AR="$(CMAKE_AR)"
endif
ifneq ($(call is_set,CMAKE_RANLIB),)
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_RANLIB="$(CMAKE_RANLIB)"
endif
# undocumented: CMAKE_NM, CMAKE_OBJCOPY, CMAKE_OBJDUMP and CMAKE_STRIP
ifneq ($(call is_set,CMAKE_NM),)
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_NM="$(CMAKE_NM)"
endif
ifneq ($(call is_set,CMAKE_OBJCOPY),)
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_OBJCOPY="$(CMAKE_OBJCOPY)"
endif
ifneq ($(call is_set,CMAKE_OBJDUMP),)
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_OBJDUMP="$(CMAKE_OBJDUMP)"
endif
ifneq ($(call is_set,CMAKE_STRIP),)
UPX_CMAKE_CONFIG_FLAGS += -DCMAKE_STRIP="$(CMAKE_STRIP)"
endif
#***********************************************************************
# default
#***********************************************************************

2
NEWS
View File

@ -3,9 +3,9 @@ User visible changes for UPX
==================================================================
Changes in 4.2.0 (XX XXX 2023):
* bug fixes - see https://github.com/upx/upx/milestone/13
* new option '--link' to preserve hard-links (Unix only; use with care)
* add support for NO_COLOR env var; see https://no-color.org/
* bug fixes - see https://github.com/upx/upx/milestone/13
Changes in 4.1.0 (08 Aug 2023):
* ELF: handle shared libraries with more than 2 PT_LOAD segments

2
doc/upx.1 generated
View File

@ -133,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "UPX 1"
.TH UPX 1 "2023-08-25" "upx 4.2.0" " "
.TH UPX 1 "2023-09-12" "upx 4.2.0" " "
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l

View File

@ -49,7 +49,7 @@ function run_config_and_build {
# run_config
if [[ ! -f $bdir/CMakeCache.txt ]]; then
export CMAKE_REQUIRED_QUIET=OFF
cmake -S . -B "$bdir" -DCMAKE_BUILD_TYPE=$build_type -DCMAKE_AR=$AR -DCMAKE_RANLIB=$RANLIB $cmake_config_flags
cmake -S . -B "$bdir" -DCMAKE_BUILD_TYPE=$build_type -DCMAKE_AR="$AR" -DCMAKE_RANLIB="$RANLIB" $cmake_config_flags
fi
# run_build
cmake --build "$bdir" --config $build_type --parallel
@ -93,7 +93,7 @@ do
export CC=/usr/bin/${toolchain}-gcc
export CXX=/usr/bin/${toolchain}-g++
export RANLIB=/usr/bin/${toolchain}-ranlib
ls -l $AR $CC $CXX $RANLIB
ls -l "$AR" "$CC" "$CXX" "$RANLIB"
run_config_and_build $toolchain
unset AR CC CXX RANLIB
done

View File

@ -3,7 +3,7 @@ Packages:
Desired=Unknown/Install/Remove/Purge/Hold
ii 7zip 21.07+dfsg-4 amd64 7-Zip file archiver with a high compression ratio
ii adduser 3.118ubuntu5 all add and remove users and groups
ii apt 2.4.9 amd64 commandline package manager
ii apt 2.4.10 amd64 commandline package manager
ii aria2 1.36.0-1 amd64 High speed download utility
ii base-files 12ubuntu4.4 amd64 Debian base system miscellaneous files
ii base-passwd 3.5.52build1 amd64 Debian base system master password and group files
@ -38,7 +38,7 @@ ii e2fsprogs 1.46.5-2ubuntu1.1 amd64
ii elfutils 0.186-1build1 amd64 collection of utilities to handle ELF objects
ii emacsen-common 3.0.4 all Common facilities for all emacsen
ii fd-find 8.3.1-1ubuntu0.1 amd64 Simple, fast and user-friendly alternative to find
ii file 1:5.41-3 amd64 Recognize the type of data in a file using "magic" numbers
ii file 1:5.41-3ubuntu0.1 amd64 Recognize the type of data in a file using "magic" numbers
ii findutils 4.8.0-1ubuntu3 amd64 utilities for finding files--find, xargs
ii fzf 0.29.0-1 amd64 general-purpose command-line fuzzy finder
ii g++ 4:11.2.0-1ubuntu1 amd64 GNU C++ compiler
@ -54,8 +54,8 @@ ii gcc-12-base:amd64 12.3.0-1ubuntu1~22.04 amd64
ii gcc-12-base:i386 12.3.0-1ubuntu1~22.04 i386 GCC, the GNU Compiler Collection (base package)
ii gcc-multilib 4:11.2.0-1ubuntu1 amd64 GNU C compiler (multilib files)
ii gdb 12.1-0ubuntu1~22.04 amd64 GNU Debugger
ii git 1:2.34.1-1ubuntu1.9 amd64 fast, scalable, distributed revision control system
ii git-man 1:2.34.1-1ubuntu1.9 all fast, scalable, distributed revision control system (manual pages)
ii git 1:2.34.1-1ubuntu1.10 amd64 fast, scalable, distributed revision control system
ii git-man 1:2.34.1-1ubuntu1.10 all fast, scalable, distributed revision control system (manual pages)
ii gojq 0.12.6-1 amd64 pure Go implementation of jq (program)
ii gpgv 2.2.27-3ubuntu2.1 amd64 GNU privacy guard - signature verification tool
ii grep 3.7-1build1 amd64 GNU grep, egrep and fgrep
@ -78,7 +78,7 @@ ii lib32stdc++-11-dev 11.4.0-1ubuntu1~22.04 amd64
ii lib32stdc++6 12.3.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (32 bit Version)
ii lib32ubsan1 12.3.0-1ubuntu1~22.04 amd64 UBSan -- undefined behaviour sanitizer (32bit)
ii libacl1:amd64 2.3.1-1 amd64 access control list - shared library
ii libapt-pkg6.0:amd64 2.4.9 amd64 package management runtime library
ii libapt-pkg6.0:amd64 2.4.10 amd64 package management runtime library
ii libarchive13:amd64 3.6.0-1ubuntu1 amd64 Multi-format archive and compression library (shared library)
ii libaria2-0:amd64 1.36.0-1 amd64 C++ library interface to aria2
ii libasan6:amd64 11.4.0-1ubuntu1~22.04 amd64 AddressSanitizer -- a fast memory error detector
@ -95,15 +95,15 @@ ii libbrotli1:amd64 1.0.9-2build6 amd64
ii libbsd0:amd64 0.11.5-1 amd64 utility functions from BSD systems - shared library
ii libbz2-1.0:amd64 1.0.8-5build1 amd64 high-quality block-sorting file compressor library - runtime
ii libc-ares2:amd64 1.18.1-1ubuntu0.22.04.2 amd64 asynchronous name resolver
ii libc-bin 2.35-0ubuntu3.1 amd64 GNU C Library: Binaries
ii libc-dev-bin 2.35-0ubuntu3.1 amd64 GNU C Library: Development binaries
ii libc6-dev-i386 2.35-0ubuntu3.1 amd64 GNU C Library: 32-bit development libraries for AMD64
ii libc6-dev-x32 2.35-0ubuntu3.1 amd64 GNU C Library: X32 ABI Development Libraries for AMD64
ii libc6-dev:amd64 2.35-0ubuntu3.1 amd64 GNU C Library: Development Libraries and Header Files
ii libc6-i386 2.35-0ubuntu3.1 amd64 GNU C Library: 32-bit shared libraries for AMD64
ii libc6-x32 2.35-0ubuntu3.1 amd64 GNU C Library: X32 ABI Shared libraries for AMD64
ii libc6:amd64 2.35-0ubuntu3.1 amd64 GNU C Library: Shared libraries
ii libc6:i386 2.35-0ubuntu3.1 i386 GNU C Library: Shared libraries
ii libc-bin 2.35-0ubuntu3.3 amd64 GNU C Library: Binaries
ii libc-dev-bin 2.35-0ubuntu3.3 amd64 GNU C Library: Development binaries
ii libc6-dev-i386 2.35-0ubuntu3.3 amd64 GNU C Library: 32-bit development libraries for AMD64
ii libc6-dev-x32 2.35-0ubuntu3.3 amd64 GNU C Library: X32 ABI Development Libraries for AMD64
ii libc6-dev:amd64 2.35-0ubuntu3.3 amd64 GNU C Library: Development Libraries and Header Files
ii libc6-i386 2.35-0ubuntu3.3 amd64 GNU C Library: 32-bit shared libraries for AMD64
ii libc6-x32 2.35-0ubuntu3.3 amd64 GNU C Library: X32 ABI Shared libraries for AMD64
ii libc6:amd64 2.35-0ubuntu3.3 amd64 GNU C Library: Shared libraries
ii libc6:i386 2.35-0ubuntu3.3 i386 GNU C Library: Shared libraries
ii libcap-ng0:amd64 0.7.9-2.2build3 amd64 An alternate POSIX capabilities library
ii libcap2:amd64 1:2.44-1ubuntu0.22.04.1 amd64 POSIX 1003.1e capabilities (library)
ii libcc1-0:amd64 12.3.0-1ubuntu1~22.04 amd64 GCC cc1 plugin for GDB
@ -154,13 +154,13 @@ ii libk5crypto3:amd64 1.19.2-2ubuntu0.2 amd64
ii libkeyutils1:amd64 1.6.1-2ubuntu3 amd64 Linux Key Management Utilities (library)
ii libkrb5-3:amd64 1.19.2-2ubuntu0.2 amd64 MIT Kerberos runtime libraries
ii libkrb5support0:amd64 1.19.2-2ubuntu0.2 amd64 MIT Kerberos runtime libraries - Support library
ii libldap-2.5-0:amd64 2.5.15+dfsg-0ubuntu0.22.04.1 amd64 OpenLDAP libraries
ii libldap-2.5-0:amd64 2.5.16+dfsg-0ubuntu0.22.04.1 amd64 OpenLDAP libraries
ii liblsan0:amd64 12.3.0-1ubuntu1~22.04 amd64 LeakSanitizer -- a memory leak detector (runtime)
ii liblz4-1:amd64 1.9.3-2build2 amd64 Fast LZ compression algorithm library - runtime
ii liblzma5:amd64 5.2.5-2ubuntu1 amd64 XZ-format compression library
ii liblzo2-2:amd64 2.10-2build3 amd64 data compression library
ii libmagic-mgc 1:5.41-3 amd64 File type determination library using "magic" numbers (compiled magic file)
ii libmagic1:amd64 1:5.41-3 amd64 Recognize the type of data in a file using "magic" numbers - library
ii libmagic-mgc 1:5.41-3ubuntu0.1 amd64 File type determination library using "magic" numbers (compiled magic file)
ii libmagic1:amd64 1:5.41-3ubuntu0.1 amd64 Recognize the type of data in a file using "magic" numbers - library
ii libmd0:amd64 1.0.4-1build1 amd64 message digest functions from BSD systems - shared library
ii libmount1:amd64 2.37.2-4ubuntu3 amd64 device mounting library
ii libmpc3:amd64 1.2.1-2build1 amd64 multiple precision complex floating-point library
@ -254,7 +254,7 @@ ii libxxhash0:amd64 0.8.1-1 amd64
ii libyaml-0-2:amd64 0.2.2-1build2 amd64 Fast YAML 1.1 parser and emitter library
ii libzstd-dev:amd64 1.4.8+dfsg-3build1 amd64 fast lossless compression algorithm -- development files
ii libzstd1:amd64 1.4.8+dfsg-3build1 amd64 fast lossless compression algorithm
ii linux-libc-dev:amd64 5.15.0-78.85 amd64 Linux Kernel Headers for development
ii linux-libc-dev:amd64 5.15.0-83.92 amd64 Linux Kernel Headers for development
ii login 1:4.8.1-2ubuntu2.1 amd64 system login tools
ii logsave 1.46.5-2ubuntu1.1 amd64 save the output of a command in a log file
ii lsb-base 11.1.0ubuntu4 all Linux Standard Base init script functionality
@ -308,11 +308,11 @@ ii universal-ctags 5.9.20210829.0-1 amd64
ii unzip 6.0-26ubuntu3.1 amd64 De-archiver for .zip files
ii usrmerge 25ubuntu2 all Convert the system to the merged /usr directories scheme
ii util-linux 2.37.2-4ubuntu3 amd64 miscellaneous system utilities
ii vim 2:8.2.3995-1ubuntu2.10 amd64 Vi IMproved - enhanced vi editor
ii vim-common 2:8.2.3995-1ubuntu2.10 all Vi IMproved - Common files
ii vim-runtime 2:8.2.3995-1ubuntu2.10 all Vi IMproved - Runtime files
ii vim 2:8.2.3995-1ubuntu2.11 amd64 Vi IMproved - enhanced vi editor
ii vim-common 2:8.2.3995-1ubuntu2.11 all Vi IMproved - Common files
ii vim-runtime 2:8.2.3995-1ubuntu2.11 all Vi IMproved - Runtime files
ii wget 1.21.2-2ubuntu1 amd64 retrieves files from the web
ii xxd 2:8.2.3995-1ubuntu2.10 amd64 tool to make (or reverse) a hex dump
ii xxd 2:8.2.3995-1ubuntu2.11 amd64 tool to make (or reverse) a hex dump
ii xz-utils 5.2.5-2ubuntu1 amd64 XZ-format compression utilities
ii yash 2.51-1 amd64 yet another shell
ii zip 3.0-12build2 amd64 Archiver for .zip files
@ -327,7 +327,7 @@ ii zstd 1.4.8+dfsg-3build1 amd64
||/ Name Version Architecture Description
Packages sorted by Installed-Size:
749329 ===== TOTAL (321 packages)
749379 ===== TOTAL (321 packages)
52747 gcc-11 amd64
34444 libicu70 amd64
32781 vim-runtime all
@ -357,10 +357,10 @@ Packages sorted by Installed-Size:
7518 libasan6 amd64
7261 libc6-dev-i386 amd64
7255 libtsan0 amd64
7127 libmagic-mgc amd64
7128 libmagic-mgc amd64
7112 coreutils amd64
6988 libx32gcc-11-dev amd64
6734 linux-libc-dev amd64
6780 linux-libc-dev amd64
6733 dpkg amd64
6667 lib32asan6 amd64
6570 libx32asan6 amd64
@ -372,7 +372,7 @@ Packages sorted by Installed-Size:
4156 apt amd64
4147 ripgrep amd64
4082 libglib2.0-0 amd64
3924 vim amd64
3925 vim amd64
3643 python2.7-minimal amd64
3506 re2c amd64
3487 gojq amd64
@ -404,7 +404,7 @@ Packages sorted by Installed-Size:
2097 libxml2 amd64
2053 openssl amd64
2009 universal-ctags amd64
1959 git-man all
1958 git-man all
1864 bash amd64
1854 aria2 amd64
1750 libdb5.3 amd64
@ -478,7 +478,7 @@ Packages sorted by Installed-Size:
390 ca-certificates all
389 mount amd64
382 libmount1 amd64
379 vim-common all
380 vim-common all
376 unzip amd64
372 xz-utils amd64
368 libssh2-1 amd64
@ -532,7 +532,7 @@ Packages sorted by Installed-Size:
230 lz4 amd64
229 patch amd64
229 mawk amd64
228 libmagic1 amd64
229 libmagic1 amd64
225 libcrypt1 amd64
221 bfs amd64
220 libidn2-0 amd64
@ -600,8 +600,8 @@ Packages sorted by Installed-Size:
92 libhiredis0.14 amd64
91 libjansson4 amd64
90 python3 amd64
84 file amd64
83 sysvinit-utils amd64
83 file amd64
82 cabextract amd64
80 readline-common all
79 libdebconfclient0 amd64

View File

@ -634,7 +634,7 @@ TEST_CASE("libc qsort") {
struct Elem {
upx_uint16_t id;
upx_uint16_t value;
static int compare(const void *aa, const void *bb) noexcept {
static int __acc_cdecl_qsort compare(const void *aa, const void *bb) noexcept {
const Elem *a = (const Elem *) aa;
const Elem *b = (const Elem *) bb;
assert_noexcept(a->id != b->id); // check not IDENTICAL
@ -657,11 +657,11 @@ TEST_CASE("libc qsort") {
constexpr size_t N = 4096;
Elem e[N];
for (size_t n = 0; n <= N; n = 2 * n + 1) {
CHECK(Elem::check_sort(qsort, e, n));
// CHECK(Elem::check_sort(qsort, e, n)); // libc qsort()
CHECK(Elem::check_sort(upx_gnomesort, e, n));
CHECK(Elem::check_sort(upx_shellsort_memswap, e, n));
CHECK(Elem::check_sort(upx_shellsort_memcpy, e, n));
#if UPX_QSORT_IS_STABLE_SORT
#if UPX_CONFIG_USE_STABLE_SORT
upx_sort_func_t wrap_stable_sort = [](void *aa, size_t nn, size_t, upx_compare_func_t cc) {
upx_std_stable_sort<sizeof(Elem)>(aa, nn, cc);
};

View File

@ -806,7 +806,7 @@ TEST_CASE("PtrOrSpan int") {
namespace {
template <class T>
__acc_static_noinline int foo(T p) {
static noinline int foo(T p) {
unsigned r = 0;
r += *p++;
r += *++p;
@ -849,4 +849,86 @@ TEST_CASE("Span codegen") {
#endif // WITH_XSPAN >= 2
/*************************************************************************
// misc
**************************************************************************/
namespace {
template <class T>
struct PointerTraits {
typedef typename std::add_lvalue_reference<T>::type reference;
typedef
typename std::add_lvalue_reference<typename std::add_const<T>::type>::type const_reference;
typedef typename std::add_pointer<T>::type pointer;
typedef typename std::add_pointer<typename std::add_const<T>::type>::type const_pointer;
};
} // namespace
#if __cplusplus >= 201103L
TEST_CASE("decltype integral constants") {
static_assert((std::is_same<decltype(0), int>::value), "");
static_assert((std::is_same<decltype(0u), unsigned>::value), "");
static_assert((std::is_same<decltype(0l), long>::value), "");
static_assert((std::is_same<decltype(0ul), unsigned long>::value), "");
static_assert((std::is_same<decltype(0ll), long long>::value), "");
static_assert((std::is_same<decltype(0ull), unsigned long long>::value), "");
static_assert((std::is_same<decltype((char) 0), char>::value), "");
static_assert((std::is_same<decltype((short) 0), short>::value), "");
static_assert((std::is_same<decltype((long) 0), long>::value), "");
static_assert((std::is_same<decltype((long long) 0), long long>::value), "");
static_assert((std::is_same<decltype(char(0)), char>::value), "");
static_assert((std::is_same<decltype(short(0)), short>::value), "");
static_assert((std::is_same<decltype(long(0)), long>::value), "");
}
TEST_CASE("decltype pointer") {
int dummy = 0;
int *p = &dummy;
const int *c = &dummy;
static_assert((std::is_same<decltype(p - p), std::ptrdiff_t>::value), "");
static_assert((std::is_same<decltype(c - c), std::ptrdiff_t>::value), "");
static_assert((std::is_same<decltype(p - c), std::ptrdiff_t>::value), "");
static_assert((std::is_same<decltype(c - p), std::ptrdiff_t>::value), "");
typedef PointerTraits<int> TInt;
typedef PointerTraits<const int> TConstInt;
static_assert((std::is_same<int *, TInt::pointer>::value), "");
static_assert((std::is_same<const int *, TInt::const_pointer>::value), "");
static_assert((std::is_same<const int *, TConstInt::pointer>::value), "");
static_assert((std::is_same<const int *, TConstInt::const_pointer>::value), "");
//
static_assert((std::is_same<decltype(p), TInt::pointer>::value), "");
static_assert((std::is_same<decltype(c), TInt::const_pointer>::value), "");
static_assert((std::is_same<decltype(c), TConstInt::pointer>::value), "");
static_assert((std::is_same<decltype(p + 1), TInt::pointer>::value), "");
static_assert((std::is_same<decltype(c + 1), TInt::const_pointer>::value), "");
static_assert((std::is_same<decltype(c + 1), TConstInt::pointer>::value), "");
static_assert((std::is_same<decltype(c + 1), TConstInt::const_pointer>::value), "");
static_assert((std::is_same<decltype(c + 1), const int *>::value), "");
// dereference
static_assert((std::is_same<decltype(*p), TInt::reference>::value), "");
static_assert((std::is_same<decltype(*c), TInt::const_reference>::value), "");
#if 0
// this works, but avoid clang warnings:
// "Expression with side effects has no effect in an unevaluated context"
static_assert((std::is_same<decltype(*p++), TInt::reference>::value), "");
static_assert((std::is_same<decltype(*++p), TInt::reference>::value), "");
static_assert((std::is_same<decltype(*c++), TInt::const_reference>::value), "");
static_assert((std::is_same<decltype(*c++), TConstInt::reference>::value), "");
static_assert((std::is_same<decltype(*c++), TConstInt::const_reference>::value), "");
static_assert((std::is_same<decltype(*++c), TInt::const_reference>::value), "");
static_assert((std::is_same<decltype(*++c), TConstInt::reference>::value), "");
static_assert((std::is_same<decltype(*++c), TConstInt::const_reference>::value), "");
#endif
// array access
static_assert((std::is_same<decltype(p[0]), TInt::reference>::value), "");
static_assert((std::is_same<decltype(c[0]), TInt::const_reference>::value), "");
static_assert((std::is_same<decltype(c[0]), TConstInt::reference>::value), "");
static_assert((std::is_same<decltype(c[0]), TConstInt::const_reference>::value), "");
UNUSED(p);
UNUSED(c);
}
#endif // __cplusplus >= 201103L
/* vim:set ts=4 sw=4 et: */

View File

@ -64,7 +64,7 @@ static void handle_opterr(acc_getopt_p g, const char *f, void *v) {
static int exit_code = EXIT_OK;
#if (WITH_GUI)
__acc_static_noinline void do_exit(void) { throw exit_code; }
static noinline void do_exit(void) { throw exit_code; }
#else
#if defined(__GNUC__)
static void do_exit(void) __attribute__((__noreturn__));
@ -105,14 +105,14 @@ static bool set_eec(int ec, int *eec) {
bool main_set_exit_code(int ec) { return set_eec(ec, &exit_code); }
__acc_static_noinline void e_exit(int ec) {
static noinline void e_exit(int ec) {
if (opt->debug.getopt_throw_instead_of_exit)
throw ec;
(void) main_set_exit_code(ec);
do_exit();
}
__acc_static_noinline void e_usage(void) {
static noinline void e_usage(void) {
if (opt->debug.getopt_throw_instead_of_exit)
throw EXIT_USAGE;
show_usage();
@ -220,7 +220,7 @@ static void e_help(void) {
}
static void set_term(FILE *f) {
if (f)
if (f != nullptr)
con_term = f;
else
con_term = acc_isatty(STDIN_FILENO) ? stderr : stdout;
@ -1327,7 +1327,7 @@ int _dowildcard = -1;
}
#endif
int __acc_cdecl_main main(int argc, char *argv[]) {
int __acc_cdecl_main main(int argc, char *argv[]) /*noexcept*/ {
#if 0 && (ACC_OS_DOS32) && defined(__DJGPP__)
// LFN=n may cause problems with 2.03's _rename and mkdir under WinME
putenv("LFN=y");

View File

@ -50,7 +50,7 @@ public:
// getVersion() enables detecting forward incompatibility of unpack()
// by old upx when newer upx changes the format of compressed output.
virtual int getVersion() const = 0;
// A unique integer ID for this executable format. See conf.h.
// A unique integer ID for this executable format; see UPX_F_xxx in conf.h.
virtual int getFormat() const = 0;
virtual const char *getName() const = 0;
virtual const char *getFullName(const Options *) const = 0;

View File

@ -137,7 +137,7 @@ unsigned Packer::unoptimizeReloc(SPAN_S(const byte) & in, MemBuffer &out, SPAN_P
if (pc + 4 > image_size)
throwCantUnpack("bad reloc[%#x] = %#x", i, pc);
*relocs++ = pc;
if (bswap && image != nullptr) {
if (bswap) {
if (bits == 32)
set_be32(image + pc, get_le32(image + pc));
else

View File

@ -95,7 +95,7 @@ int PackHeader::getPackHeaderSize() const {
}
/*************************************************************************
// see stub/header.ash
// see stub/src/include/header.S
**************************************************************************/
void PackHeader::putPackHeader(SPAN_S(byte) p) const {
@ -111,7 +111,7 @@ void PackHeader::putPackHeader(SPAN_S(byte) p) const {
int old_chksum = 0;
// the new variable length header
if (format < 128) {
if (format < 128) { // little endian
if (format == UPX_F_DOS_COM || format == UPX_F_DOS_SYS) {
size = 22;
old_chksum = get_packheader_checksum(p, size - 1);
@ -140,7 +140,7 @@ void PackHeader::putPackHeader(SPAN_S(byte) p) const {
}
set_le32(p + 8, u_adler);
set_le32(p + 12, c_adler);
} else {
} else { // big endian
size = 32;
old_chksum = get_packheader_checksum(p, size - 1);
set_be32(p + 8, u_len);

View File

@ -1,4 +1,4 @@
/* cxxlib.h --
/* cxxlib.h -- C++ support library
This file is part of the UPX executable compressor.
@ -35,7 +35,7 @@ namespace upx {
// type_traits
**************************************************************************/
// <type_traits> is_bounded_array: same as C++20 std::is_bounded_array
// is_bounded_array: identical to C++20 std::is_bounded_array
template <class T>
struct is_bounded_array : public std::false_type {};
template <class T, size_t N>
@ -43,7 +43,7 @@ struct is_bounded_array<T[N]> : public std::true_type {};
template <class T>
inline constexpr bool is_bounded_array_v = is_bounded_array<T>::value;
// <type_traits> util: is_same_all and is_same_any means std::is_same for multiple types
// is_same_all and is_same_any: std::is_same for multiple types
template <class T, class... Ts>
struct is_same_all : public std::conjunction<std::is_same<T, Ts>...> {};
template <class T, class... Ts>
@ -125,7 +125,7 @@ struct TriBool final {
return value == TriBool(other).value;
}
// "Third" can mean many things, depending on usage context, so provide some alternative names:
// "Third" can mean many things - depending on usage context, so provide some alternate names:
// constexpr bool isDefault() const noexcept { return isThird(); } // might be misleading
constexpr bool isIndeterminate() const noexcept { return isThird(); }
constexpr bool isOther() const noexcept { return isThird(); }

View File

@ -388,7 +388,7 @@ void upx_std_stable_sort(void *array, size_t n, upx_compare_func_t compare) {
#endif
}
#if UPX_QSORT_IS_STABLE_SORT
#if UPX_CONFIG_USE_STABLE_SORT
// instantiate function templates for all element sizes we need
// efficient, but code size bloat
template void upx_std_stable_sort<1>(void *, size_t, upx_compare_func_t);

View File

@ -138,13 +138,13 @@ void upx_shellsort_memcpy(void *array, size_t n, size_t element_size, upx_compar
template <size_t ElementSize>
void upx_std_stable_sort(void *array, size_t n, upx_compare_func_t compare);
#if 1
// #define UPX_CONFIG_USE_STABLE_SORT 1
#if UPX_CONFIG_USE_STABLE_SORT
// use std::stable_sort(); requires that "element_size" is constexpr!
#define upx_qsort(a, n, element_size, compare) upx_std_stable_sort<(element_size)>(a, n, compare)
#else
// use libc qsort()
#define upx_qsort qsort
#else
// use std::stable_sort()
#define upx_qsort(a, b, c, d) upx_std_stable_sort<(c)>(a, b, d)
#define UPX_QSORT_IS_STABLE_SORT 1
#endif
/*************************************************************************

View File

@ -51,7 +51,7 @@
#include "xspan_impl.h"
#ifdef XSPAN_NAMESPACE_NAME
// help constructor to distinguish between number of elements and bytes
// types to help the constructor to distinguish between number of elements and bytes
using XSPAN_NAMESPACE_NAME::XSpanCount;
using XSPAN_NAMESPACE_NAME::XSpanSizeInBytes;
// actual classes
@ -59,7 +59,7 @@ using XSPAN_NAMESPACE_NAME::Ptr;
using XSPAN_NAMESPACE_NAME::PtrOrSpan;
using XSPAN_NAMESPACE_NAME::PtrOrSpanOrNull;
using XSPAN_NAMESPACE_NAME::Span;
// util
// support functions
using XSPAN_NAMESPACE_NAME::raw_bytes; // overloaded for all classes
using XSPAN_NAMESPACE_NAME::raw_index_bytes; // overloaded for all classes
#endif

View File

@ -204,8 +204,6 @@ struct XSpanInternalDummyArg {
#define XSpanInternalDummyArgInit (XSPAN_NS(XSpanInternalDummyArg)(0, nullptr))
#endif
XSPAN_NAMESPACE_END
// poison a pointer: point to a non-null invalid address
// - resulting pointer should crash on dereference
// - this should be efficient (so no mmap() guard page etc.)
@ -216,6 +214,8 @@ static forceinline void *XSPAN_GET_POISON_VOID_PTR() {
return (void *) 251;
}
XSPAN_NAMESPACE_END
#ifndef XSPAN_DELETED_FUNCTION
#define XSPAN_DELETED_FUNCTION = delete
#endif

View File

@ -443,7 +443,7 @@ public: // raw access
return ptr;
}
// like C++ std::span
// like C++20 std::span
pointer data() const noexcept { return ptr; }
pointer data(size_t bytes) const { return raw_bytes(bytes); } // UPX extra
// size_type size() const { return size_bytes() / sizeof(element_type); } // NOT USED

View File

@ -1,6 +1,6 @@
#define UPX_VERSION_HEX 0x040200 /* 04.02.00 */
#define UPX_VERSION_STRING "4.2.0"
#define UPX_VERSION_STRING4 "4.20"
#define UPX_VERSION_DATE "Aug 25th 2023"
#define UPX_VERSION_DATE_ISO "2023-08-25"
#define UPX_VERSION_DATE "Sep 12th 2023"
#define UPX_VERSION_DATE_ISO "2023-09-12"
#define UPX_VERSION_YEAR "2023"