diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b11e75a7..c8a2a81f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ env: UPX_CMAKE_CONFIG_FLAGS: -Wdev --warn-uninitialized UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO: 1 UPX_DEBUG_TEST_LIBC_QSORT: 1 - # 2024-04-20 - ZIG_DIST_VERSION: 0.12.0 + # 2024-06-07 + ZIG_DIST_VERSION: 0.13.0 jobs: job-rebuild-and-verify-stubs: @@ -349,7 +349,9 @@ jobs: - { name: arm64ec-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64ec' } # { name: arm64x-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64x' } - { name: i386-win32-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64_x86 } - - { name: i386-win32-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_x86 } + # TODO later: as of 2024-06-07 i386-win32-vs2022 stopped working: "upx_ucl_init() failed"; + # examine why; flaky?? + # { name: i386-win32-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_x86 } steps: - run: git config --global core.autocrlf false - uses: actions/checkout@v4 diff --git a/misc/make/Makefile-extra.mk b/misc/make/Makefile-extra.mk index 41b5c131..958fc522 100644 --- a/misc/make/Makefile-extra.mk +++ b/misc/make/Makefile-extra.mk @@ -256,12 +256,12 @@ build/$(UPX_XTARGET)/release: PHONY; $(call run_config_and_build,$@,Release) build/$(UPX_XTARGET)/%: export CC := $(CC) build/$(UPX_XTARGET)/%: export CXX := $(CXX) # shortcuts -xtarget/all: xtarget/debug xtarget/release PHONY xtarget/debug: build/$(UPX_XTARGET)/debug PHONY xtarget/release: build/$(UPX_XTARGET)/release PHONY -xtarget/all+test: xtarget/debug+test xtarget/release+test PHONY +xtarget/all: xtarget/debug xtarget/release PHONY xtarget/debug+test: build/$(UPX_XTARGET)/debug+test PHONY xtarget/release+test: build/$(UPX_XTARGET)/release+test PHONY +xtarget/all+test: xtarget/debug+test xtarget/release+test PHONY # set new default .DEFAULT_GOAL := build/$(UPX_XTARGET)/release diff --git a/misc/podman/rebuild-stubs/Dockerfile b/misc/podman/rebuild-stubs/Dockerfile index 8fbc1e2b..b75d194e 100644 --- a/misc/podman/rebuild-stubs/Dockerfile +++ b/misc/podman/rebuild-stubs/Dockerfile @@ -14,11 +14,13 @@ RUN dpkg --add-architecture i386 \ # the following packages are not required for rebuilding the stubs, but # they do make the image *much* more convenient and also allow building # the full UPX binary inside the container via CMake: - 7zip bfs bubblewrap busybox bzip2 bzip3 cabextract ccache chrpath cmake cpio dash diffstat \ - elfutils execstack fd-find file fish fzf g++ gawk gdb gojq ht htop hyperfine jq ksh \ - libzstd-dev lsb-release lz4 lzip lzop minify mksh moreutils musl neovim ninja-build \ + 7zip bfs btop bubblewrap busybox bzip2 bzip3 cabextract ccache chrpath cmake cpio \ + dash diffstat direnv elfutils execstack fd-find file fish fzf \ + g++ gawk gdb gojq ht htop hyperfine jq ksh \ + libzstd-dev lsd lsb-release lz4 lzip lzop minify mksh moreutils musl neovim ninja-build \ p7zip parallel patch patchelf patchutils pax-utils proot \ - python3 python3-pyasn1 python3-pycryptodome python3-pycurl python3-toml python3-yaml python3-zstd \ + python3 python3-pyasn1 python3-pycryptodome python3-pycurl python3-tomli python3-tomli-w \ + python3-yaml python3-zstd \ re2c ripgrep rsync screen strace universal-ctags unzip valgrind yash yq \ zip zlib1g-dev zoxide zsh zstd \ # extra packages for compiling with "gcc -m32" and "gcc -mx32": diff --git a/misc/podman/rebuild-stubs/packages.txt b/misc/podman/rebuild-stubs/packages.txt index 45eb7a11..002e0f0e 100644 --- a/misc/podman/rebuild-stubs/packages.txt +++ b/misc/podman/rebuild-stubs/packages.txt @@ -14,6 +14,7 @@ ii binutils-common:amd64 2.42-4ubuntu2 amd64 ii binutils-x86-64-linux-gnu 2.42-4ubuntu2 amd64 GNU binary utilities, for x86-64-linux-gnu target ii bsdextrautils 2.39.3-9ubuntu6 amd64 extra utilities from 4.4BSD-Lite ii bsdutils 1:2.39.3-9ubuntu6 amd64 basic utilities from 4.4BSD-Lite +ii btop 1.3.0-1 amd64 Modern and colorful command line resource monitor that shows usage and stats ii bubblewrap 0.9.0-1build1 amd64 utility for unprivileged chroot and namespace manipulation ii busybox 1:1.36.1-6ubuntu3 amd64 Tiny utilities for small and embedded systems ii bzip2 1.0.8-5.1 amd64 high-quality block-sorting file compressor - utilities @@ -36,6 +37,7 @@ ii debconf 1.5.86ubuntu1 all ii debianutils 5.17build1 amd64 Miscellaneous utilities specific to Debian ii diffstat 1.66-1build1 amd64 produces graph of changes introduced by a diff file ii diffutils 1:3.10-1build1 amd64 File comparison utilities +ii direnv 2.32.1-2build1 amd64 Utility to set directory specific environment variables ii dpkg 1.22.6ubuntu6 amd64 Debian package management system ii e2fsprogs 1.47.0-2.4~exp1ubuntu4 amd64 ext2/ext3/ext4 file system utilities ii elfutils 0.190-1.1build4 amd64 collection of utilities to handle ELF objects @@ -63,8 +65,8 @@ ii gcc-14-base:i386 14-20240412-0ubuntu1 i386 ii gcc-multilib 4:13.2.0-7ubuntu1 amd64 GNU C compiler (multilib files) ii gcc-x86-64-linux-gnu 4:13.2.0-7ubuntu1 amd64 GNU C compiler for the amd64 architecture ii gdb 15.0.50.20240403-0ubuntu1 amd64 GNU Debugger -ii git 1:2.43.0-1ubuntu7 amd64 fast, scalable, distributed revision control system -ii git-man 1:2.43.0-1ubuntu7 all fast, scalable, distributed revision control system (manual pages) +ii git 1:2.43.0-1ubuntu7.1 amd64 fast, scalable, distributed revision control system +ii git-man 1:2.43.0-1ubuntu7.1 all fast, scalable, distributed revision control system (manual pages) ii gojq 0.12.13-1 amd64 pure Go implementation of jq (program) ii gpgv 2.4.4-2ubuntu17 amd64 GNU privacy guard - signature verification tool ii grep 3.11-4build1 amd64 GNU grep, egrep and fgrep @@ -91,7 +93,7 @@ ii lib32stdc++6 14-20240412-0ubuntu1 amd64 ii lib32ubsan1 14-20240412-0ubuntu1 amd64 UBSan -- undefined behaviour sanitizer (32bit) ii libacl1:amd64 2.3.2-1build1 amd64 access control list - shared library ii libapt-pkg6.0t64:amd64 2.7.14build2 amd64 package management runtime library -ii libarchive13t64:amd64 3.7.2-2 amd64 Multi-format archive and compression library (shared library) +ii libarchive13t64:amd64 3.7.2-2ubuntu0.1 amd64 Multi-format archive and compression library (shared library) ii libaria2-0:amd64 1.37.0+debian-1build3 amd64 C++ library interface to aria2 ii libasan8:amd64 14-20240412-0ubuntu1 amd64 AddressSanitizer -- a fast memory error detector ii libasm1t64:amd64 0.190-1.1build4 amd64 library with a programmable assembler interface @@ -107,16 +109,16 @@ ii libbrotli1:amd64 1.1.0-2build2 amd64 ii libbsd0:amd64 0.12.1-1build1 amd64 utility functions from BSD systems - shared library ii libbz2-1.0:amd64 1.0.8-5.1 amd64 high-quality block-sorting file compressor library - runtime ii libbzip3-0:amd64 1.4.0-1 amd64 better, faster and stronger spiritual successor to bzip2 - runtime -ii libc-bin 2.39-0ubuntu8.1 amd64 GNU C Library: Binaries -ii libc-dev-bin 2.39-0ubuntu8.1 amd64 GNU C Library: Development binaries -ii libc6-dbg:amd64 2.39-0ubuntu8.1 amd64 GNU C Library: detached debugging symbols -ii libc6-dev-i386 2.39-0ubuntu8.1 amd64 GNU C Library: 32-bit development libraries for AMD64 -ii libc6-dev-x32 2.39-0ubuntu8.1 amd64 GNU C Library: X32 ABI Development Libraries for AMD64 -ii libc6-dev:amd64 2.39-0ubuntu8.1 amd64 GNU C Library: Development Libraries and Header Files -ii libc6-i386 2.39-0ubuntu8.1 amd64 GNU C Library: 32-bit shared libraries for AMD64 -ii libc6-x32 2.39-0ubuntu8.1 amd64 GNU C Library: X32 ABI Shared libraries for AMD64 -ii libc6:amd64 2.39-0ubuntu8.1 amd64 GNU C Library: Shared libraries -ii libc6:i386 2.39-0ubuntu8.1 i386 GNU C Library: Shared libraries +ii libc-bin 2.39-0ubuntu8.2 amd64 GNU C Library: Binaries +ii libc-dev-bin 2.39-0ubuntu8.2 amd64 GNU C Library: Development binaries +ii libc6-dbg:amd64 2.39-0ubuntu8.2 amd64 GNU C Library: detached debugging symbols +ii libc6-dev-i386 2.39-0ubuntu8.2 amd64 GNU C Library: 32-bit development libraries for AMD64 +ii libc6-dev-x32 2.39-0ubuntu8.2 amd64 GNU C Library: X32 ABI Development Libraries for AMD64 +ii libc6-dev:amd64 2.39-0ubuntu8.2 amd64 GNU C Library: Development Libraries and Header Files +ii libc6-i386 2.39-0ubuntu8.2 amd64 GNU C Library: 32-bit shared libraries for AMD64 +ii libc6-x32 2.39-0ubuntu8.2 amd64 GNU C Library: X32 ABI Shared libraries for AMD64 +ii libc6:amd64 2.39-0ubuntu8.2 amd64 GNU C Library: Shared libraries +ii libc6:i386 2.39-0ubuntu8.2 i386 GNU C Library: Shared libraries ii libcap-ng0:amd64 0.8.4-2build2 amd64 alternate POSIX capabilities library ii libcap2:amd64 1:2.66-5ubuntu2 amd64 POSIX 1003.1e capabilities (library) ii libcares2:amd64 1.27.0-1.0ubuntu1 amd64 asynchronous name resolver @@ -144,6 +146,7 @@ ii libgcc-s1:i386 14-20240412-0ubuntu1 i386 ii libgcrypt20:amd64 1.10.3-2build1 amd64 LGPL Crypto library - runtime library ii libgdbm-compat4t64:amd64 1.23-5.1build1 amd64 GNU dbm database routines (legacy support runtime version) ii libgdbm6t64:amd64 1.23-5.1build1 amd64 GNU dbm database routines (runtime version) +ii libgit2-1.7:amd64 1.7.2+ds-1ubuntu3 amd64 low-level Git library ii libglib2.0-0t64:amd64 2.80.0-6ubuntu3.1 amd64 GLib library of C routines ii libgmp10:amd64 2:6.3.0+dfsg-2ubuntu6 amd64 Multiprecision arithmetic library ii libgnutls30t64:amd64 3.8.3-1.1ubuntu3.1 amd64 GNU TLS library - main runtime library @@ -153,6 +156,7 @@ ii libgprofng0:amd64 2.42-4ubuntu2 amd64 ii libgssapi-krb5-2:amd64 1.20.1-6ubuntu2 amd64 MIT Kerberos runtime libraries - krb5 GSS-API Mechanism ii libhiredis1.1.0:amd64 1.2.0-6ubuntu3 amd64 minimalistic C client library for Redis ii libhogweed6t64:amd64 3.9.1-2.2build1 amd64 low level cryptographic library (public-key cryptos) +ii libhttp-parser2.9:amd64 2.9.4-6build1 amd64 parser for HTTP messages written in C ii libhwasan0:amd64 14-20240412-0ubuntu1 amd64 AddressSanitizer -- a fast memory error detector ii libicu74:amd64 74.2-1ubuntu3 amd64 International Components for Unicode ii libidn2-0:amd64 2.3.7-2build1 amd64 Internationalized domain names (IDNA2008/TR46) library @@ -192,10 +196,10 @@ ii libnl-genl-3-200:amd64 3.7.0-0.3build1 amd64 ii libnpth0t64:amd64 1.6-3.1build1 amd64 replacement for GNU Pth using system threads ii libonig5:amd64 6.9.9-1build1 amd64 regular expressions library ii libp11-kit0:amd64 0.25.3-4ubuntu2 amd64 library for loading and coordinating access to PKCS#11 modules - runtime -ii libpam-modules-bin 1.5.3-5ubuntu5 amd64 Pluggable Authentication Modules for PAM - helper binaries -ii libpam-modules:amd64 1.5.3-5ubuntu5 amd64 Pluggable Authentication Modules for PAM -ii libpam-runtime 1.5.3-5ubuntu5 all Runtime support for the PAM library -ii libpam0g:amd64 1.5.3-5ubuntu5 amd64 Pluggable Authentication Modules library +ii libpam-modules-bin 1.5.3-5ubuntu5.1 amd64 Pluggable Authentication Modules for PAM - helper binaries +ii libpam-modules:amd64 1.5.3-5ubuntu5.1 amd64 Pluggable Authentication Modules for PAM +ii libpam-runtime 1.5.3-5ubuntu5.1 all Runtime support for the PAM library +ii libpam0g:amd64 1.5.3-5ubuntu5.1 amd64 Pluggable Authentication Modules library ii libpcre2-32-0:amd64 10.42-4ubuntu2 amd64 New Perl Compatible Regular Expression Library - 32 bit runtime files ii libpcre2-8-0:amd64 10.42-4ubuntu2 amd64 New Perl Compatible Regular Expression Library- 8 bit runtime files ii libperl5.38t64:amd64 5.38.2-3.2build2 amd64 shared Perl library @@ -233,7 +237,7 @@ ii libssh2-1t64:amd64 1.11.0-4.1build2 amd64 ii libssl3t64:amd64 3.0.13-0ubuntu3.1 amd64 Secure Sockets Layer toolkit - shared libraries ii libstdc++-13-dev:amd64 13.2.0-23ubuntu4 amd64 GNU Standard C++ Library v3 (development files) ii libstdc++6:amd64 14-20240412-0ubuntu1 amd64 GNU Standard C++ Library v3 -ii libsystemd0:amd64 255.4-1ubuntu8 amd64 systemd utility library +ii libsystemd0:amd64 255.4-1ubuntu8.1 amd64 systemd utility library ii libtalloc2:amd64 2.4.2-1build2 amd64 hierarchical pool based memory allocator ii libtasn1-6:amd64 4.19.0-3build1 amd64 Manage ASN.1 structures (runtime) ii libtermkey1:amd64 0.22-1 amd64 library for processing keyboard input @@ -244,7 +248,7 @@ ii libtree-sitter0:amd64 0.20.8-2 amd64 ii libtsan2:amd64 14-20240412-0ubuntu1 amd64 ThreadSanitizer -- a Valgrind-based detector of data races (runtime) ii libubsan1:amd64 14-20240412-0ubuntu1 amd64 UBSan -- undefined behaviour sanitizer (runtime) ii libuchardet0:amd64 0.0.8-1build1 amd64 universal charset detection library - shared library -ii libudev1:amd64 255.4-1ubuntu8 amd64 libudev shared library +ii libudev1:amd64 255.4-1ubuntu8.1 amd64 libudev shared library ii libunibilium4:amd64 2.1.0-3 amd64 simple, self-contained terminfo library ii libunistring5:amd64 1.1-2build1 amd64 Unicode string library for C ii libunwind8:amd64 1.6.2-3build1 amd64 library to determine the call-chain of a program - runtime @@ -273,10 +277,11 @@ ii libxxhash0:amd64 0.8.2-2build1 amd64 ii libyaml-0-2:amd64 0.2.5-1build1 amd64 Fast YAML 1.1 parser and emitter library ii libzstd-dev:amd64 1.5.5+dfsg2-2build1 amd64 fast lossless compression algorithm -- development files ii libzstd1:amd64 1.5.5+dfsg2-2build1 amd64 fast lossless compression algorithm -ii linux-libc-dev:amd64 6.8.0-31.31 amd64 Linux Kernel Headers for development +ii linux-libc-dev:amd64 6.8.0-35.35 amd64 Linux Kernel Headers for development ii login 1:4.13+dfsg1-4ubuntu3 amd64 system login tools ii logsave 1.47.0-2.4~exp1ubuntu4 amd64 save the output of a command in a log file ii lsb-release 12.0-2 all Linux Standard Base version reporting utility (minimal implementation) +ii lsd 1.0.0-2 amd64 ls command with a lot of pretty colors and some other stuff ii lua-luv:amd64 1.48.0-2-2build1 amd64 libuv bindings for Lua ii lz4 1.9.4-1build1 amd64 Fast LZ compression algorithm library - tool ii lzip 1.24.1-1build1 amd64 lossless data compressor based on the LZMA algorithm @@ -319,6 +324,8 @@ ii python3-pycryptodome 3.20.0+dfsg-1 amd64 ii python3-pycurl 7.45.3-1build2 amd64 Python bindings to libcurl (Python 3) ii python3-pyelftools 0.30-1 all pure-python3 library for parsing ELF and DWARF ii python3-toml 0.10.2-1 all library for Tom's Obvious, Minimal Language - Python 3.x +ii python3-tomli 2.0.1-2 all lil' TOML parser for Python +ii python3-tomli-w 1.0.0-2 all lil' TOML writer for Python ii python3-xmltodict 0.13.0-1 all Makes working with XML feel like you are working with JSON (Python 3) ii python3-yaml 6.0.1-2build2 amd64 YAML parser and emitter for Python3 ii python3-zstd 1.5.5.1-1build1 amd64 python bindings to Yann Collet ZSTD compression library @@ -337,7 +344,7 @@ ii sysstat 12.6.1-2 amd64 ii sysvinit-utils 3.08-6ubuntu3 amd64 System-V-like utilities ii tar 1.35+dfsg-3build1 amd64 GNU version of the tar archiving utility ii time 1.9-0.2build1 amd64 GNU time program for measuring CPU resource usage -ii tzdata 2024a-2ubuntu1 all time zone and daylight-saving time data +ii tzdata 2024a-3ubuntu1.1 all time zone and daylight-saving time data ii ubuntu-keyring 2023.11.28.1 all GnuPG keys of the Ubuntu archive ii ucf 3.0043+nmu1 all Update Configuration File(s): preserve user changes to config files ii universal-ctags 5.9.20210829.0-1 amd64 build tag file indexes of source code definitions @@ -361,7 +368,7 @@ ii zstd 1.5.5+dfsg2-2build1 amd64 ||/ Name Version Architecture Description Packages sorted by Installed-Size: - 964904 ===== TOTAL (355 packages) + 978188 ===== TOTAL (362 packages) 76943 valgrind amd64 72249 gcc-13-x86-64-linux-gnu amd64 37841 g++-13-x86-64-linux-gnu amd64 @@ -370,7 +377,7 @@ Packages sorted by Installed-Size: 35027 cpp-13-x86-64-linux-gnu amd64 29327 libperl5.38t64 amd64 21815 neovim-runtime all - 21684 git amd64 + 21692 git amd64 20518 libstdc++-13-dev amd64 19159 perl-modules-5.38 all 16248 zsh-common all @@ -383,7 +390,7 @@ Packages sorted by Installed-Size: 12003 libc6-x32 amd64 11992 libc6-i386 amd64 11569 binutils-x86-64-linux-gnu amd64 - 11174 libc6-dbg amd64 + 11183 libc6-dbg amd64 10984 cmake-data all 10764 libasan8 amd64 9665 libx32asan8 amd64 @@ -397,9 +404,10 @@ Packages sorted by Installed-Size: 7923 python3.12-minimal amd64 7913 perl-base amd64 7492 libx32gcc-13-dev amd64 - 7166 linux-libc-dev amd64 + 7193 linux-libc-dev amd64 6946 libc6-dev-i386 amd64 6944 coreutils amd64 + 6832 direnv amd64 6775 neovim amd64 6743 lib32stdc++-13-dev amd64 6607 libssl3t64 amd64 @@ -423,6 +431,7 @@ Packages sorted by Installed-Size: 3443 fish amd64 3441 re2c amd64 3438 util-linux amd64 + 3408 lsd amd64 3403 libaria2-0 amd64 3382 fd-find amd64 3349 libubsan1 amd64 @@ -459,6 +468,7 @@ Packages sorted by Installed-Size: 1730 libsqlite3-0 amd64 1712 libp11-kit0 amd64 1634 mksh amd64 + 1582 btop amd64 1579 ccache amd64 1504 e2fsprogs amd64 1454 bash-completion all @@ -471,9 +481,10 @@ Packages sorted by Installed-Size: 1321 zlib1g-dev amd64 1314 hyperfine amd64 1237 libzstd-dev amd64 + 1237 libgit2-1.7 amd64 1186 libmpfr6 amd64 + 1145 libpam-modules amd64 1136 zoxide amd64 - 1123 libpam-modules amd64 1025 libsystemd0 amd64 1014 libkrb5-3 amd64 996 screen amd64 @@ -559,7 +570,7 @@ Packages sorted by Installed-Size: 273 patchelf amd64 273 mawk amd64 270 pax-utils amd64 - 269 libpam-modules-bin amd64 + 270 libpam-modules-bin amd64 264 libuv1t64 amd64 257 libk5crypto3 amd64 255 libipc-run-perl all @@ -582,7 +593,7 @@ Packages sorted by Installed-Size: 215 patchutils amd64 214 ucf all 211 libmagic1t64 amd64 - 208 libpam0g amd64 + 209 libpam0g amd64 207 libuchardet0 amd64 206 proot amd64 202 python3-pycurl amd64 @@ -669,11 +680,13 @@ Packages sorted by Installed-Size: 69 liberror-perl all 69 libdebuginfod1t64 amd64 67 libpipeline1 amd64 + 66 libhttp-parser2.9 amd64 66 bzip3 amd64 63 sensible-utils all 63 libtermkey1 amd64 63 file amd64 61 ksh all + 60 python3-tomli all 60 libcap-ng0 amd64 60 libattr1 amd64 57 libcom-err2 amd64 @@ -700,6 +713,7 @@ Packages sorted by Installed-Size: 34 libtime-duration-perl all 34 libgdbm-compat4t64 amd64 33 libxau6 amd64 + 31 python3-tomli-w all 29 ubuntu-keyring all 28 g++-13 amd64 27 libpython3-stdlib amd64 diff --git a/src/conf.h b/src/conf.h index 77e43cd7..ce25ec3a 100644 --- a/src/conf.h +++ b/src/conf.h @@ -84,7 +84,9 @@ static_assert((char) (-1) == 255); #if __cplusplus >= 202002L // C++20 #define upx_is_constant_evaluated std::is_constant_evaluated -#elif __has_builtin(__builtin_is_constant_evaluated) // clang-9, gcc-9 +#elif __has_builtin(__builtin_is_constant_evaluated) // clang-9, gcc-10 +#define upx_is_constant_evaluated __builtin_is_constant_evaluated +#elif (ACC_CC_GNUC >= 0x090000) && 1 // gcc-9 #define upx_is_constant_evaluated __builtin_is_constant_evaluated #endif diff --git a/src/except.cpp b/src/except.cpp index 627cd417..683c9d04 100644 --- a/src/except.cpp +++ b/src/except.cpp @@ -152,7 +152,7 @@ void throwCantPack(const char *format, ...) { char msg[1024]; va_list ap; va_start(ap, format); - (void) upx_safe_vsnprintf_noexcept(msg, sizeof(msg), format, ap); + upx_safe_vsnprintf_noexcept(msg, sizeof(msg), format, ap); va_end(ap); throwCantPack(msg); } @@ -162,7 +162,7 @@ void throwCantUnpack(const char *format, ...) { char msg[1024]; va_list ap; va_start(ap, format); - (void) upx_safe_vsnprintf_noexcept(msg, sizeof(msg), format, ap); + upx_safe_vsnprintf_noexcept(msg, sizeof(msg), format, ap); va_end(ap); throwCantUnpack(msg); } @@ -172,9 +172,9 @@ void throwInternalError(const char *format, ...) { char msg[1024]; va_list ap; va_start(ap, format); - (void) upx_safe_vsnprintf_noexcept(msg, sizeof(msg), format, ap); + upx_safe_vsnprintf_noexcept(msg, sizeof(msg), format, ap); va_end(ap); - throwCantUnpack(msg); + throwInternalError(msg); } /************************************************************************* diff --git a/src/linker.h b/src/linker.h index c0b32de0..24f5ba3e 100644 --- a/src/linker.h +++ b/src/linker.h @@ -31,7 +31,7 @@ // ElfLinker **************************************************************************/ -class ElfLinker : private upx::noncopyable { +class ElfLinker /*not_final*/ : private upx::noncopyable { friend class Packer; public: @@ -114,7 +114,7 @@ protected: const char *type); }; -struct ElfLinker::Section : private upx::noncopyable { +struct ElfLinker::Section final : private upx::noncopyable { char *name = nullptr; void *input = nullptr; byte *output = nullptr; @@ -128,7 +128,7 @@ struct ElfLinker::Section : private upx::noncopyable { ~Section() noexcept; }; -struct ElfLinker::Symbol : private upx::noncopyable { +struct ElfLinker::Symbol final : private upx::noncopyable { char *name = nullptr; Section *section = nullptr; upx_uint64_t offset = 0; @@ -137,7 +137,7 @@ struct ElfLinker::Symbol : private upx::noncopyable { ~Symbol() noexcept; }; -struct ElfLinker::Relocation : private upx::noncopyable { +struct ElfLinker::Relocation final : private upx::noncopyable { const Section *section = nullptr; unsigned offset = 0; const char *type = nullptr; diff --git a/src/pefile.cpp b/src/pefile.cpp index 88da0274..decd0edf 100644 --- a/src/pefile.cpp +++ b/src/pefile.cpp @@ -884,8 +884,9 @@ public: ACC_COMPILE_TIME_ASSERT(sizeof(C1) == 1) // "char" or "byte" ACC_COMPILE_TIME_ASSERT(sizeof(C2) == 1) // "char" or "byte" const Section *s = getThunk((const char *) dll, (const char *) proc, thunk_separator_first); - if (s == nullptr && - (s = getThunk((const char *) dll, (const char *) proc, thunk_separator)) == nullptr) + if (s == nullptr) + s = getThunk((const char *) dll, (const char *) proc, thunk_separator); + if (s == nullptr) throwInternalError("entry not found"); return s->offset; } @@ -897,7 +898,9 @@ public: char ord[1 + 5 + 1]; upx_safe_snprintf(ord, sizeof(ord), "%c%05u", ordinal_id, ordinal); const Section *s = getThunk((const char *) dll, ord, thunk_separator_first); - if (s == nullptr && (s = getThunk((const char *) dll, ord, thunk_separator)) == nullptr) + if (s == nullptr) + s = getThunk((const char *) dll, ord, thunk_separator); + if (s == nullptr) throwInternalError("entry not found"); return s->offset; } @@ -910,12 +913,13 @@ public: } template - upx_uint64_t hasDll(const C *dll) const { + bool hasDll(const C *dll) const { ACC_COMPILE_TIME_ASSERT(sizeof(C) == 1) // "char" or "byte" TStr sdll(name_for_dll((const char *) dll, dll_name_id)); return findSection(sdll, false) != nullptr; } -}; +}; // class PeFile::ImportLinker + /*static*/ const char PeFile::ImportLinker::zeros[sizeof(import_desc)] = {0}; void PeFile::addKernelImport(const char *name) { ilinker->add_import(kernelDll(), name); } @@ -928,8 +932,7 @@ void PeFile::addStubImports() { addKernelImport("VirtualProtect"); } -void PeFile::processImports2(unsigned myimport, unsigned) // pass 2 -{ +void PeFile::processImports2(unsigned myimport, unsigned) { // pass 2 COMPILE_TIME_ASSERT(sizeof(import_desc) == 20) if (ilinker == nullptr) return; @@ -941,8 +944,7 @@ void PeFile::processImports2(unsigned myimport, unsigned) // pass 2 } template -unsigned PeFile::processImports0(ord_mask_t ord_mask) // pass 1 -{ +unsigned PeFile::processImports0(ord_mask_t ord_mask) { // pass 1 if (isefi) { if (IDSIZE(PEDIR_IMPORT)) throwCantPack("imports not supported on EFI"); @@ -1354,8 +1356,7 @@ struct PeFile::tls_traits final { template void PeFile::processTls1(Interval *iv, typename tls_traits::cb_value_t imagebase, - unsigned imagesize) // pass 1 -{ + unsigned imagesize) { // pass 1 typedef typename tls_traits::tls tls; typedef typename tls_traits::cb_value_t cb_value_t; constexpr unsigned cb_size = tls_traits::cb_size; @@ -1441,8 +1442,7 @@ void PeFile::processTls1(Interval *iv, typename tls_traits::cb_value_t ima template void PeFile::processTls2(Reloc *const rel, const Interval *const iv, unsigned newaddr, - typename tls_traits::cb_value_t imagebase) // pass 2 -{ + typename tls_traits::cb_value_t imagebase) { // pass 2 typedef typename tls_traits::tls tls; typedef typename tls_traits::cb_value_t cb_value_t; constexpr unsigned cb_size = tls_traits::cb_size; @@ -1501,8 +1501,7 @@ void PeFile::processTls2(Reloc *const rel, const Interval *const iv, unsigned ne // Load Configuration handling **************************************************************************/ -void PeFile::processLoadConf(Interval *iv) // pass 1 -{ +void PeFile::processLoadConf(Interval *iv) { // pass 1 if (IDSIZE(PEDIR_LOAD_CONFIG) == 0) return; @@ -2350,7 +2349,7 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask, unsigned newvsize = (isection[objs - 1].vaddr + isection[objs - 1].vsize + oam1) & ~oam1; NO_fprintf(stderr, "newvsize=%x objs=%d\n", newvsize, objs); - if (newvsize + soimport + sorelocs > ibuf.getSize()) + if ((upx_uint64_t) newvsize + soimport + sorelocs > ibuf.getSize()) throwInternalError("buffer too small 2"); memcpy(ibuf + newvsize, oimport, soimport); memcpy(ibuf + newvsize + soimport, orelocs, sorelocs); @@ -3144,8 +3143,7 @@ tribool PeFile32::canUnpack() { return canUnpack0(getFormat() == UPX_F_WINCE_ARM ? 4 : 3, ih.objects, ih.entry, sizeof(ih)); } -unsigned PeFile32::processImports() // pass 1 -{ +unsigned PeFile32::processImports() { // pass 1 return processImports0(1u << 31); } @@ -3195,8 +3193,7 @@ tribool PeFile64::canUnpack() { return canUnpack0(3, ih.objects, ih.entry, sizeof(ih)); } -unsigned PeFile64::processImports() // pass 1 -{ +unsigned PeFile64::processImports() { // pass 1 return processImports0(1ULL << 63); } diff --git a/src/util/cxxlib.h b/src/util/cxxlib.h index 109ba617..eea22ec0 100644 --- a/src/util/cxxlib.h +++ b/src/util/cxxlib.h @@ -743,7 +743,7 @@ inline void owner_delete(OwningPointer(T)(&object)) noexcept { static_assert(std::is_class_v); // UPX convention static_assert(std::is_nothrow_destructible_v); if (object != nullptr) { - delete (T *) object; + delete (T *) object; // single object delete object = nullptr; } assert_noexcept((T *) object == nullptr); @@ -754,7 +754,7 @@ template inline void owner_free(OwningPointer(T)(&object)) noexcept { static_assert(!std::is_class_v); // UPX convention if (object != nullptr) { - ::free((T *) object); + ::free((T *) object); // free memory from malloc() object = nullptr; } assert_noexcept((T *) object == nullptr); diff --git a/src/util/membuffer.cpp b/src/util/membuffer.cpp index 64fb144c..8eaa9315 100644 --- a/src/util/membuffer.cpp +++ b/src/util/membuffer.cpp @@ -146,7 +146,7 @@ void MemBuffer::fill(unsigned off, unsigned len, int value) { **************************************************************************/ // for use_simple_mcheck() -#define PTR_BITS32(p) ((unsigned) (ptr_get_address(p) & 0xffffffff)) +#define PTR_BITS32(p) ((upx_uint32_t) (ptr_get_address(p) & 0xffffffff)) #define MAGIC1(p) ((PTR_BITS32(p) ^ 0xfefdbeeb) | 1) #define MAGIC2(p) ((PTR_BITS32(p) ^ 0xfefdbeeb ^ 0x88224411) | 1) @@ -279,7 +279,7 @@ TEST_CASE("MemBuffer core") { CHECK_THROWS(mb.subref("", N, 1)); if (use_simple_mcheck()) { byte *p = raw_bytes(mb, 0); - unsigned magic1 = get_ne32(p - 4); + upx_uint32_t magic1 = get_ne32(p - 4); set_ne32(p - 4, magic1 ^ 1); CHECK_THROWS(mb.checkState()); set_ne32(p - 4, magic1);