From 54d16a458a4e08e071b20d05b348abb858f2fdcc Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Sat, 16 Mar 2024 17:46:40 +0100 Subject: [PATCH] CI updates; cleanups --- .github/workflows/ci.yml | 111 ++++++++++++----------- doc/upx.1 | 2 +- misc/make/Makefile-extra.mk | 28 ++++-- misc/podman/rebuild-stubs/Dockerfile | 2 +- misc/podman/rebuild-stubs/packages.txt | 118 ++++++++++++------------- misc/testsuite/mimic_ctest.sh | 5 ++ src/check/dt_check.cpp | 32 +++---- src/main.cpp | 3 +- src/p_mach.cpp | 12 +-- src/p_vmlinx.cpp | 2 +- src/util/system_defs.h | 11 ++- src/util/system_headers.h | 61 ++++++++----- src/util/util.cpp | 13 +++ src/util/util.h | 2 + src/version.h | 2 +- 15 files changed, 227 insertions(+), 177 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 669ecfd0..ad3e2ba1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,8 +16,8 @@ env: UPX_CMAKE_BUILD_FLAGS: --verbose UPX_CMAKE_CONFIG_FLAGS: -Wdev --warn-uninitialized UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO: 1 - # 2024-01-25 - ZIG_DIST_VERSION: 0.12.0-dev.2341+92211135f + # 2024-03-16 + ZIG_DIST_VERSION: 0.12.0-dev.3322+a4508ad71 jobs: job-rebuild-and-verify-stubs: @@ -89,27 +89,27 @@ jobs: uses: actions/checkout@v4 with: { submodules: true } - name: 'Check out test suite' - run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' - - name: 'Build cmake extra/gcc/debug' - run: 'make build/extra/gcc/debug' - - name: 'Build cmake extra/gcc/release' - run: 'make build/extra/gcc/release' - - name: 'Build cmake extra/clang/debug' - run: 'make build/extra/clang/debug' - - name: 'Build cmake extra/clang/release' - run: 'make build/extra/clang/release' - - name: 'Build cmake extra/gcc-m32/debug' + run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' + - name: 'Build extra/gcc/debug' + run: 'make build/extra/gcc/debug' + - name: 'Build extra/gcc/release' + run: 'make build/extra/gcc/release' + - name: 'Build extra/clang/debug' + run: 'make build/extra/clang/debug' + - name: 'Build extra/clang/release' + run: 'make build/extra/clang/release' + - name: 'Build extra/gcc-m32/debug' if: ${{ matrix.use_m32 }} - run: 'make build/extra/gcc-m32/debug' - - name: 'Build cmake extra/gcc-m32/release' + run: 'make build/extra/gcc-m32/debug' + - name: 'Build extra/gcc-m32/release' if: ${{ matrix.use_m32 && (success() || failure()) }} # run this step even if the previous step failed - run: 'make build/extra/gcc-m32/release' - - name: 'Build cmake extra/cross-windows-mingw32/release' + run: 'make build/extra/gcc-m32/release' + - name: 'Build extra/cross-windows-mingw32/release' if: ${{ matrix.use_m32 && (success() || failure()) }} # run this step even if the previous step failed - run: 'make build/extra/cross-windows-mingw32/release' - - name: 'Build cmake extra/cross-windows-mingw64/release' + run: 'make build/extra/cross-windows-mingw32/release' + - name: 'Build extra/cross-windows-mingw64/release' if: ${{ matrix.use_m32 && (success() || failure()) }} # run this step even if the previous step failed - run: 'make build/extra/cross-windows-mingw64/release' + run: 'make build/extra/cross-windows-mingw64/release' - name: 'Make artifact' run: | N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g') @@ -192,8 +192,8 @@ jobs: include: # NOTE: macos does not have "env -C"; only with brew coreutils # NOTE: macos-11 does not have "readlink -f"; only on macos >= 12 or with brew coreutils - - { os: macos-11, gcc: gcc-10, gxx: 'g++-10', testsuite: true, ctest: true } - - { os: macos-12, gcc: gcc-11, gxx: 'g++-11', testsuite: true, ctest: true } + - { os: macos-11, gcc: gcc-10, gxx: 'g++-10', testsuite: true } + - { os: macos-12, gcc: gcc-11, gxx: 'g++-11', testsuite: true } - { os: macos-13, gcc: gcc-12, gxx: 'g++-12', testsuite: true, xcode_version: 14.3.1 } - { os: macos-13, testsuite: true } # use default Xcode-15 # { os: macos-14, gcc: gcc-13, gxx: 'g++-13', testsuite: true } # gcc-13: INTERNAL ERROR in ld64 @@ -207,7 +207,7 @@ jobs: with: xcode-version: ${{ matrix.xcode_version }} - name: 'Install brew packages' - if: ${{ matrix.testsuite || matrix.ctest }} + if: ${{ matrix.testsuite }} run: | test -z "$HOMEBREW_PREFIX" && HOMEBREW_PREFIX="$(brew --prefix)" echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX" >> $GITHUB_ENV @@ -217,30 +217,35 @@ jobs: # only run "brew update" if needed if ! brew install coreutils; then brew update && brew install coreutils; fi fi + case "${{ matrix.os }}" in + macos-11 | macos-12) echo "UPX_DEBUG_FORCE_PACK_MACOS=1" >> $GITHUB_ENV ;; + # FIXME: UPX on macos-13+ is broken => disable self-test for now + macos-13 | macos-14) echo "UPX_CONFIG_DISABLE_SELF_PACK_TEST=ON" >> $GITHUB_ENV ;; + esac - name: 'Check out code' uses: actions/checkout@v4 with: { submodules: true } - name: 'Check out test suite' if: ${{ matrix.testsuite }} - run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' - - name: 'Build cmake extra/clang/debug' - run: 'make build/extra/clang/debug' - - name: 'Build cmake extra/clang/release' - run: 'make build/extra/clang/release' - - name: 'Build cmake extra/gcc/debug' + run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' + - name: 'Build extra/clang/debug' + run: 'make build/extra/clang/debug' + - name: 'Build extra/clang/release' + run: 'make build/extra/clang/release' + - name: 'Build extra/gcc/debug' if: ${{ matrix.gcc != '' }} - run: 'make build/extra/gcc/debug CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"' - - name: 'Build cmake extra/gcc/release' + run: 'make build/extra/gcc/debug CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"' + - name: 'Build extra/gcc/release' if: ${{ matrix.gcc != '' }} - run: 'make build/extra/gcc/release CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"' - - name: 'Build cmake xtarget/cross-darwin-arm64/debug' + run: 'make build/extra/gcc/release CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"' + - name: 'Build xtarget/cross-darwin-arm64/debug' run: | - CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" \ - make UPX_XTARGET=cross-darwin-arm64 xtarget/debug - - name: 'Build cmake xtarget/cross-darwin-arm64/release' + make UPX_XTARGET=xtarget/cross-darwin-arm64 xtarget/debug \ + CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" + - name: 'Build xtarget/cross-darwin-arm64/release' run: | - CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" \ - make UPX_XTARGET=cross-darwin-arm64 xtarget/release + make UPX_XTARGET=xtarget/cross-darwin-arm64 xtarget/release \ + CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" - name: 'Make artifact' run: | X="${{ matrix.xcode_version }}"; test -n "$X" && X="-xcode-$X" @@ -260,17 +265,15 @@ jobs: (cd build/extra/clang/release && DESTDIR="$PWD/Install with cmake" cmake --install .) (cd build/extra/clang/release && DESTDIR="$PWD/Install with make" make install) - name: 'Run ctest tests' - if: matrix.ctest # FIXME: UPX on macos-13+ is broken => disable self-test for now run: | make -C build/extra/clang/debug test - #make -C build/extra/clang/release test + make -C build/extra/clang/release test for f in ./build/extra/*/*/upx; do echo "===== $f"; $f --sysinfo -v; done - name: 'Mimic ctest tests' - if: matrix.ctest # FIXME: UPX on macos-13+ is broken => disable self-test for now run: | export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" env -C build/extra/clang/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh - #env -C build/extra/clang/release bash "$PWD"/misc/testsuite/mimic_ctest.sh + env -C build/extra/clang/release bash "$PWD"/misc/testsuite/mimic_ctest.sh - name: 'Run file system test suite' if: ${{ matrix.testsuite }} # for coreutils readlink run: | @@ -302,16 +305,16 @@ jobs: uses: actions/checkout@v4 with: { submodules: true } - name: 'Check out test suite' - run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' + run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite' - name: 'Set up Developer Command Prompt' uses: ilammy/msvc-dev-cmd@v1 with: vsversion: ${{ matrix.vsversion }} arch: ${{ matrix.arch }} - - name: 'Build cmake debug' - run: 'make build/debug' - - name: 'Build cmake release' - run: 'make build/release' + - name: 'Build debug' + run: 'make build/debug' + - name: 'Build release' + run: 'make build/release' - name: 'Make artifact' shell: bash run: | @@ -534,18 +537,14 @@ jobs: ls -la; head zig-ar zig-cc zig-cxx zig-ranlib - name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} run: | - mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/release - cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release - cmake ../../../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_RELEASE - cmake --build . --config Release --parallel --verbose - file ./upx* + make UPX_XTARGET=zig/${ZIG_TARGET}${ZIG_PIC} xtarget/release \ + CC="zig-cc" CXX="zig-cxx" CMAKE_AR="$HOME/.local/bin/zig-ar" CMAKE_RANLIB="$HOME/.local/bin/zig-ranlib" + file build/zig/${ZIG_TARGET}${ZIG_PIC}/release/upx* - name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} run: | - mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/debug - cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug - cmake ../../../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_DEBUG - cmake --build . --config Debug --parallel --verbose - file ./upx* + make UPX_XTARGET=zig/${ZIG_TARGET}${ZIG_PIC} xtarget/debug \ + CC="zig-cc" CXX="zig-cxx" CMAKE_AR="$HOME/.local/bin/zig-ar" CMAKE_RANLIB="$HOME/.local/bin/zig-ranlib" + file build/zig/${ZIG_TARGET}${ZIG_PIC}/debug/upx* - name: ${{ format('Make artifact from upx-{0}-{1}', github.ref_name, env.UPX_GITREV_SHORT) }} shell: bash run: | diff --git a/doc/upx.1 b/doc/upx.1 index 1f9fbbac..45b1ac47 100644 --- a/doc/upx.1 +++ b/doc/upx.1 @@ -133,7 +133,7 @@ .\" ======================================================================== .\" .IX Title "UPX 1" -.TH UPX 1 "2024-03-12" "upx 4.2.3" " " +.TH UPX 1 "2024-03-16" "upx 4.2.3" " " .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l diff --git a/misc/make/Makefile-extra.mk b/misc/make/Makefile-extra.mk index 1e4ae959..4fe8814a 100644 --- a/misc/make/Makefile-extra.mk +++ b/misc/make/Makefile-extra.mk @@ -50,6 +50,12 @@ build/extra/clang-static/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/clang-static/%: export CC = clang -static build/extra/clang-static/%: export CXX = clang++ -static +# force building with clang/clang++ -static-pie +build/extra/clang-static-pie/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/clang-static-pie/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/clang-static-pie/%: export CC = clang -static-pie -fPIE -Wno-unused-command-line-argument +build/extra/clang-static-pie/%: export CXX = clang++ -static-pie -fPIE -Wno-unused-command-line-argument + # force building with clang/clang++ -static -flto build/extra/clang-static-lto/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/clang-static-lto/release: PHONY; $(call run_config_and_build,$@,Release) @@ -102,6 +108,12 @@ build/extra/gcc-static/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/gcc-static/%: export CC = gcc -static build/extra/gcc-static/%: export CXX = g++ -static +# force building with gcc/g++ -static-pie +build/extra/gcc-static-pie/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/gcc-static-pie/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/gcc-static-pie/%: export CC = gcc -static-pie -fPIE +build/extra/gcc-static-pie/%: export CXX = g++ -static-pie -fPIE + # force building with gcc/g++ -static -flto build/extra/gcc-static-lto/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/gcc-static-lto/release: PHONY; $(call run_config_and_build,$@,Release) @@ -223,16 +235,16 @@ ifneq ($(CC),) ifneq ($(CXX),) UPX_XTARGET := $(UPX_XTARGET) -build/xtarget/$(UPX_XTARGET)/debug: PHONY; $(call run_config_and_build,$@,Debug) -build/xtarget/$(UPX_XTARGET)/release: PHONY; $(call run_config_and_build,$@,Release) -build/xtarget/$(UPX_XTARGET)/%: export CC := $(CC) -build/xtarget/$(UPX_XTARGET)/%: export CXX := $(CXX) +build/$(UPX_XTARGET)/debug: PHONY; $(call run_config_and_build,$@,Debug) +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 -xtarget/debug: build/xtarget/$(UPX_XTARGET)/debug -xtarget/release: build/xtarget/$(UPX_XTARGET)/release +xtarget/all: xtarget/debug xtarget/release PHONY +xtarget/debug: build/$(UPX_XTARGET)/debug PHONY +xtarget/release: build/$(UPX_XTARGET)/release PHONY # set new default -.DEFAULT_GOAL = build/xtarget/$(UPX_XTARGET)/release +.DEFAULT_GOAL := build/$(UPX_XTARGET)/release endif endif diff --git a/misc/podman/rebuild-stubs/Dockerfile b/misc/podman/rebuild-stubs/Dockerfile index 4e05fd98..adab77f4 100644 --- a/misc/podman/rebuild-stubs/Dockerfile +++ b/misc/podman/rebuild-stubs/Dockerfile @@ -18,7 +18,7 @@ RUN dpkg --add-architecture i386 \ mksh moreutils ninja-build p7zip parallel patch patchelf patchutils pax-utils paxctl \ python3 python3-pyasn1 python3-pycryptodome python3-zstd \ re2c ripgrep rsync screen universal-ctags unzip vim yash zip zlib1g-dev zsh zstd \ - # extra packages for compiling with "gcc -m32" and and "gcc -mx32": + # extra packages for compiling with "gcc -m32" and "gcc -mx32": g++-multilib gcc-multilib \ && true diff --git a/misc/podman/rebuild-stubs/packages.txt b/misc/podman/rebuild-stubs/packages.txt index 270a4f05..23bb27e8 100644 --- a/misc/podman/rebuild-stubs/packages.txt +++ b/misc/podman/rebuild-stubs/packages.txt @@ -5,14 +5,14 @@ ii 7zip 21.07+dfsg-4 amd64 ii adduser 3.118ubuntu5 all add and remove users and groups ii apt 2.4.11 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-files 12ubuntu4.6 amd64 Debian base system miscellaneous files ii base-passwd 3.5.52build1 amd64 Debian base system master password and group files ii bash 5.1-6ubuntu1 amd64 GNU Bourne Again SHell ii bash-completion 1:2.11-5ubuntu1 all programmable completion for the bash shell ii bfs 2.3.1-1 amd64 Breadth-first version of find(1) -ii binutils 2.38-4ubuntu2.4 amd64 GNU assembler, linker and binary utilities -ii binutils-common:amd64 2.38-4ubuntu2.4 amd64 Common files for the GNU assembler, linker and binary utilities -ii binutils-x86-64-linux-gnu 2.38-4ubuntu2.4 amd64 GNU binary utilities, for x86-64-linux-gnu target +ii binutils 2.38-4ubuntu2.6 amd64 GNU assembler, linker and binary utilities +ii binutils-common:amd64 2.38-4ubuntu2.6 amd64 Common files for the GNU assembler, linker and binary utilities +ii binutils-x86-64-linux-gnu 2.38-4ubuntu2.6 amd64 GNU binary utilities, for x86-64-linux-gnu target ii bsdutils 1:2.37.2-4ubuntu3 amd64 basic utilities from 4.4BSD-Lite ii busybox 1:1.30.1-7ubuntu3 amd64 Tiny utilities for small and embedded systems ii bzip2 1.0.8-5build1 amd64 high-quality block-sorting file compressor - utilities @@ -20,9 +20,9 @@ ii ca-certificates 20230311ubuntu0.22.04.1 all ii cabextract 1.9-3 amd64 Microsoft Cabinet file unpacker ii ccache 4.5.1-1 amd64 Compiler cache for fast recompilation of C/C++ code ii chrpath 0.16-2 amd64 Tool to edit the rpath in ELF binaries -ii cmake 3.22.1-1ubuntu1.22.04.1 amd64 cross-platform, open-source make system -ii cmake-data 3.22.1-1ubuntu1.22.04.1 all CMake data files (modules, templates and documentation) -ii coreutils 8.32-4.1ubuntu1 amd64 GNU core utilities +ii cmake 3.22.1-1ubuntu1.22.04.2 amd64 cross-platform, open-source make system +ii cmake-data 3.22.1-1ubuntu1.22.04.2 all CMake data files (modules, templates and documentation) +ii coreutils 8.32-4.1ubuntu1.1 amd64 GNU core utilities ii cpio 2.13+dfsg-7 amd64 GNU cpio -- a program to manage archives of files ii cpp 4:11.2.0-1ubuntu1 amd64 GNU C preprocessor (cpp) ii cpp-11 11.4.0-1ubuntu1~22.04 amd64 GNU C preprocessor @@ -33,7 +33,7 @@ ii debianutils 5.5-1ubuntu2 amd64 ii dh-elpa-helper 2.0.9ubuntu1 all helper package for emacs lisp extensions ii diffutils 1:3.8-0ubuntu2 amd64 File comparison utilities ii distro-info-data 0.52ubuntu0.6 all information about the distributions' releases (data files) -ii dpkg 1.21.1ubuntu2.2 amd64 Debian package management system +ii dpkg 1.21.1ubuntu2.3 amd64 Debian package management system ii e2fsprogs 1.46.5-2ubuntu1.1 amd64 ext2/ext3/ext4 file system utilities 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 @@ -66,7 +66,7 @@ ii htop 3.0.5-7build2 amd64 ii hyperfine 1.12.0-3ubuntu0.1 amd64 Command-line benchmarking tool ii init-system-helpers 1.62 all helper tools for all init systems ii jq 1.6-2.1ubuntu3 amd64 lightweight and flexible command-line JSON processor -ii less 590-1ubuntu0.22.04.1 amd64 pager program similar to more +ii less 590-1ubuntu0.22.04.2 amd64 pager program similar to more ii lib32asan6 11.4.0-1ubuntu1~22.04 amd64 AddressSanitizer -- a fast memory error detector (32bit) ii lib32atomic1 12.3.0-1ubuntu1~22.04 amd64 support library providing __atomic built-in functions (32bit) ii lib32gcc-11-dev 11.4.0-1ubuntu1~22.04 amd64 GCC support library (32 bit development files) @@ -88,22 +88,22 @@ ii libattr1:amd64 1:2.5.1-1build1 amd64 ii libaudit-common 1:3.0.7-1build1 all Dynamic library for security auditing - common files ii libaudit1:amd64 1:3.0.7-1build1 amd64 Dynamic library for security auditing ii libbabeltrace1:amd64 1.5.8-2build1 amd64 Babeltrace conversion libraries -ii libbinutils:amd64 2.38-4ubuntu2.4 amd64 GNU binary utilities (private shared library) +ii libbinutils:amd64 2.38-4ubuntu2.6 amd64 GNU binary utilities (private shared library) ii libblkid1:amd64 2.37.2-4ubuntu3 amd64 block device ID library ii libboost-regex1.74.0:amd64 1.74.0-14ubuntu3 amd64 regular expression library for C++ ii libbrotli1:amd64 1.0.9-2build6 amd64 library implementing brotli encoder and decoder (shared libraries) 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.5 amd64 GNU C Library: Binaries -ii libc-dev-bin 2.35-0ubuntu3.5 amd64 GNU C Library: Development binaries -ii libc6-dev-i386 2.35-0ubuntu3.5 amd64 GNU C Library: 32-bit development libraries for AMD64 -ii libc6-dev-x32 2.35-0ubuntu3.5 amd64 GNU C Library: X32 ABI Development Libraries for AMD64 -ii libc6-dev:amd64 2.35-0ubuntu3.5 amd64 GNU C Library: Development Libraries and Header Files -ii libc6-i386 2.35-0ubuntu3.5 amd64 GNU C Library: 32-bit shared libraries for AMD64 -ii libc6-x32 2.35-0ubuntu3.5 amd64 GNU C Library: X32 ABI Shared libraries for AMD64 -ii libc6:amd64 2.35-0ubuntu3.5 amd64 GNU C Library: Shared libraries -ii libc6:i386 2.35-0ubuntu3.5 i386 GNU C Library: Shared libraries +ii libc-ares2:amd64 1.18.1-1ubuntu0.22.04.3 amd64 asynchronous name resolver +ii libc-bin 2.35-0ubuntu3.6 amd64 GNU C Library: Binaries +ii libc-dev-bin 2.35-0ubuntu3.6 amd64 GNU C Library: Development binaries +ii libc6-dev-i386 2.35-0ubuntu3.6 amd64 GNU C Library: 32-bit development libraries for AMD64 +ii libc6-dev-x32 2.35-0ubuntu3.6 amd64 GNU C Library: X32 ABI Development Libraries for AMD64 +ii libc6-dev:amd64 2.35-0ubuntu3.6 amd64 GNU C Library: Development Libraries and Header Files +ii libc6-i386 2.35-0ubuntu3.6 amd64 GNU C Library: 32-bit shared libraries for AMD64 +ii libc6-x32 2.35-0ubuntu3.6 amd64 GNU C Library: X32 ABI Shared libraries for AMD64 +ii libc6:amd64 2.35-0ubuntu3.6 amd64 GNU C Library: Shared libraries +ii libc6:i386 2.35-0ubuntu3.6 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 @@ -111,8 +111,8 @@ ii libcom-err2:amd64 1.46.5-2ubuntu1.1 amd64 ii libcrypt-dev:amd64 1:4.4.27-1 amd64 libcrypt development files ii libcrypt1:amd64 1:4.4.27-1 amd64 libcrypt shared library ii libcrypt1:i386 1:4.4.27-1 i386 libcrypt shared library -ii libctf-nobfd0:amd64 2.38-4ubuntu2.4 amd64 Compact C Type Format library (runtime, no BFD dependency) -ii libctf0:amd64 2.38-4ubuntu2.4 amd64 Compact C Type Format library (runtime, BFD dependency) +ii libctf-nobfd0:amd64 2.38-4ubuntu2.6 amd64 Compact C Type Format library (runtime, no BFD dependency) +ii libctf0:amd64 2.38-4ubuntu2.6 amd64 Compact C Type Format library (runtime, BFD dependency) ii libcurl3-gnutls:amd64 7.81.0-1ubuntu1.15 amd64 easy-to-use client-side URL transfer library (GnuTLS flavour) ii libcurl4:amd64 7.81.0-1ubuntu1.15 amd64 easy-to-use client-side URL transfer library (OpenSSL flavour) ii libdb5.3:amd64 5.3.28+dfsg1-0.8ubuntu3 amd64 Berkeley v5.3 Database Libraries [runtime] @@ -122,7 +122,7 @@ ii libdebuginfod1:amd64 0.186-1build1 amd64 ii libdw1:amd64 0.186-1build1 amd64 library that provides access to the DWARF debug information ii libelf1:amd64 0.186-1build1 amd64 library to read and write ELF files ii liberror-perl 0.17029-1 all Perl module for error/exception handling in an OO-ish way -ii libexpat1:amd64 2.4.7-1ubuntu0.2 amd64 XML parsing C library - runtime library +ii libexpat1:amd64 2.4.7-1ubuntu0.3 amd64 XML parsing C library - runtime library ii libext2fs2:amd64 1.46.5-2ubuntu1.1 amd64 ext2/ext3/ext4 file system libraries ii libffi8:amd64 3.4.2-4 amd64 Foreign Function Interface library runtime ii libgcc-11-dev:amd64 11.4.0-1ubuntu1~22.04 amd64 GCC support library (development files) @@ -133,7 +133,7 @@ ii libgdbm-compat4:amd64 1.23-1 amd64 ii libgdbm6:amd64 1.23-1 amd64 GNU dbm database routines (runtime version) ii libglib2.0-0:amd64 2.72.4-0ubuntu2.2 amd64 GLib library of C routines ii libgmp10:amd64 2:6.2.1+dfsg-3ubuntu1 amd64 Multiprecision arithmetic library -ii libgnutls30:amd64 3.7.3-4ubuntu1.3 amd64 GNU TLS library - main runtime library +ii libgnutls30:amd64 3.7.3-4ubuntu1.4 amd64 GNU TLS library - main runtime library ii libgomp1:amd64 12.3.0-1ubuntu1~22.04 amd64 GCC OpenMP (GOMP) support library ii libgpg-error0:amd64 1.43-3 amd64 GnuPG development runtime library ii libgpm2:amd64 1.20.7-10build1 amd64 General Purpose Mouse - shared library @@ -154,7 +154,7 @@ ii libk5crypto3:amd64 1.19.2-2ubuntu0.3 amd64 ii libkeyutils1:amd64 1.6.1-2ubuntu3 amd64 Linux Key Management Utilities (library) ii libkrb5-3:amd64 1.19.2-2ubuntu0.3 amd64 MIT Kerberos runtime libraries ii libkrb5support0:amd64 1.19.2-2ubuntu0.3 amd64 MIT Kerberos runtime libraries - Support library -ii libldap-2.5-0:amd64 2.5.16+dfsg-0ubuntu0.22.04.1 amd64 OpenLDAP libraries +ii libldap-2.5-0:amd64 2.5.17+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 @@ -178,17 +178,17 @@ ii libnsl-dev:amd64 1.3.0-2build2 amd64 ii libnsl2:amd64 1.3.0-2build2 amd64 Public client interface for NIS(YP) and NIS+ ii libonig5:amd64 6.9.7.1-2build1 amd64 regular expressions library ii libp11-kit0:amd64 0.24.0-6build1 amd64 library for loading and coordinating access to PKCS#11 modules - runtime -ii libpam-modules-bin 1.4.0-11ubuntu2.3 amd64 Pluggable Authentication Modules for PAM - helper binaries -ii libpam-modules:amd64 1.4.0-11ubuntu2.3 amd64 Pluggable Authentication Modules for PAM -ii libpam-runtime 1.4.0-11ubuntu2.3 all Runtime support for the PAM library -ii libpam0g:amd64 1.4.0-11ubuntu2.3 amd64 Pluggable Authentication Modules library +ii libpam-modules-bin 1.4.0-11ubuntu2.4 amd64 Pluggable Authentication Modules for PAM - helper binaries +ii libpam-modules:amd64 1.4.0-11ubuntu2.4 amd64 Pluggable Authentication Modules for PAM +ii libpam-runtime 1.4.0-11ubuntu2.4 all Runtime support for the PAM library +ii libpam0g:amd64 1.4.0-11ubuntu2.4 amd64 Pluggable Authentication Modules library ii libpcre2-8-0:amd64 10.39-3ubuntu0.1 amd64 New Perl Compatible Regular Expression Library- 8 bit runtime files ii libpcre3:amd64 2:8.39-13ubuntu0.22.04.1 amd64 Old Perl 5 Compatible Regular Expression Library - runtime files ii libperl5.34:amd64 5.34.0-3ubuntu1.3 amd64 shared Perl library ii libpopt0:amd64 1.18-3build1 amd64 lib for parsing cmdline parameters ii libprocps8:amd64 2:3.3.17-6ubuntu2.1 amd64 library for accessing process information from /proc ii libpsl5:amd64 0.21.0-1.2build2 amd64 Library for Public Suffix List (shared libraries) -ii libpython2.7-minimal:amd64 2.7.18-13ubuntu1.1 amd64 Minimal subset of the Python language (version 2.7) +ii libpython2.7-minimal:amd64 2.7.18-13ubuntu1.2 amd64 Minimal subset of the Python language (version 2.7) ii libpython3-stdlib:amd64 3.10.6-1~22.04 amd64 interactive high-level object-oriented language (default python3 version) ii libpython3.10-minimal:amd64 3.10.12-1~22.04.3 amd64 Minimal subset of the Python language (version 3.10) ii libpython3.10-stdlib:amd64 3.10.12-1~22.04.3 amd64 Interactive high-level object-oriented language (standard library, version 3.10) @@ -211,14 +211,14 @@ ii libsmartcols1:amd64 2.37.2-4ubuntu3 amd64 ii libsodium23:amd64 1.0.18-1build2 amd64 Network communication, cryptography and signaturing library ii libsource-highlight-common 3.1.9-4.1build2 all architecture-independent files for source highlighting library ii libsource-highlight4v5 3.1.9-4.1build2 amd64 source highlighting library -ii libsqlite3-0:amd64 3.37.2-2ubuntu0.1 amd64 SQLite 3 shared library +ii libsqlite3-0:amd64 3.37.2-2ubuntu0.3 amd64 SQLite 3 shared library ii libss2:amd64 1.46.5-2ubuntu1.1 amd64 command-line interface parsing library -ii libssh-4:amd64 0.9.6-2ubuntu0.22.04.2 amd64 tiny C SSH library (OpenSSL flavor) +ii libssh-4:amd64 0.9.6-2ubuntu0.22.04.3 amd64 tiny C SSH library (OpenSSL flavor) ii libssh2-1:amd64 1.10.0-3 amd64 SSH2 client-side library -ii libssl3:amd64 3.0.2-0ubuntu1.12 amd64 Secure Sockets Layer toolkit - shared libraries +ii libssl3:amd64 3.0.2-0ubuntu1.15 amd64 Secure Sockets Layer toolkit - shared libraries ii libstdc++-11-dev:amd64 11.4.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (development files) ii libstdc++6:amd64 12.3.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 -ii libsystemd0:amd64 249.11-0ubuntu3.11 amd64 systemd utility library +ii libsystemd0:amd64 249.11-0ubuntu3.12 amd64 systemd utility library ii libtasn1-6:amd64 4.18.0-4build1 amd64 Manage ASN.1 structures (runtime) ii libtime-duration-perl 1.21-1 all module for rounded or exact English expression of durations ii libtimedate-perl 2.3300-2 all collection of modules to manipulate date/time information @@ -229,11 +229,11 @@ ii libtirpc-dev:amd64 1.3.2-2ubuntu0.1 amd64 ii libtirpc3:amd64 1.3.2-2ubuntu0.1 amd64 transport-independent RPC library ii libtsan0:amd64 11.4.0-1ubuntu1~22.04 amd64 ThreadSanitizer -- a Valgrind-based detector of data races (runtime) ii libubsan1:amd64 12.3.0-1ubuntu1~22.04 amd64 UBSan -- undefined behaviour sanitizer (runtime) -ii libudev1:amd64 249.11-0ubuntu3.11 amd64 libudev shared library +ii libudev1:amd64 249.11-0ubuntu3.12 amd64 libudev shared library ii libunistring2:amd64 1.0-1 amd64 Unicode string library for C ii libutempter0:amd64 1.2.1-2build2 amd64 privileged helper for utmp/wtmp updates (runtime) ii libuuid1:amd64 2.37.2-4ubuntu3 amd64 Universally Unique ID library -ii libuv1:amd64 1.43.0-1 amd64 asynchronous event notification library - runtime library +ii libuv1:amd64 1.43.0-1ubuntu0.1 amd64 asynchronous event notification library - runtime library ii libx11-6:amd64 2:1.7.5-1ubuntu0.3 amd64 X11 client-side library ii libx11-data 2:1.7.5-1ubuntu0.3 all X11 client-side library ii libx32asan6 11.4.0-1ubuntu1~22.04 amd64 AddressSanitizer -- a fast memory error detector (x32) @@ -249,13 +249,13 @@ ii libx32ubsan1 12.3.0-1ubuntu1~22.04 amd64 ii libxau6:amd64 1:1.0.9-1build5 amd64 X11 authorisation library ii libxcb1:amd64 1.14-3ubuntu3 amd64 X C Binding ii libxdmcp6:amd64 1:1.1.3-0ubuntu5 amd64 X11 Display Manager Control Protocol library -ii libxml2:amd64 2.9.13+dfsg-1ubuntu0.3 amd64 GNOME XML library +ii libxml2:amd64 2.9.13+dfsg-1ubuntu0.4 amd64 GNOME XML library ii libxxhash0:amd64 0.8.1-1 amd64 shared library for xxhash 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-91.101 amd64 Linux Kernel Headers for development -ii login 1:4.8.1-2ubuntu2.1 amd64 system login tools +ii linux-libc-dev:amd64 5.15.0-100.110 amd64 Linux Kernel Headers for development +ii login 1:4.8.1-2ubuntu2.2 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 ii lsb-release 11.1.0ubuntu4 all Linux Standard Base version reporting utility @@ -272,10 +272,10 @@ ii ncurses-base 6.3-2ubuntu0.1 all ii ncurses-bin 6.3-2ubuntu0.1 amd64 terminal-related programs and man pages ii ncurses-term 6.3-2ubuntu0.1 all additional terminal type definitions ii ninja-build 1.10.1-1 amd64 small build system closest in spirit to Make -ii openssl 3.0.2-0ubuntu1.12 amd64 Secure Sockets Layer toolkit - cryptographic utility +ii openssl 3.0.2-0ubuntu1.15 amd64 Secure Sockets Layer toolkit - cryptographic utility ii p7zip 16.02+dfsg-8 amd64 7zr file archiver with high compression ratio ii parallel 20210822+ds-2 all build and execute command lines from standard input in parallel -ii passwd 1:4.8.1-2ubuntu2.1 amd64 change and administer password and group data +ii passwd 1:4.8.1-2ubuntu2.2 amd64 change and administer password and group data ii patch 2.7.6-7build2 amd64 Apply a diff file to an original ii patchelf 0.14.3-1 amd64 modify properties of ELF executables ii patchutils 0.4.2-1build2 amd64 Utilities to work with patches @@ -286,11 +286,11 @@ ii perl-base 5.34.0-3ubuntu1.3 amd64 ii perl-modules-5.34 5.34.0-3ubuntu1.3 all Core Perl modules ii procps 2:3.3.17-6ubuntu2.1 amd64 /proc file system utilities ii python2-minimal 2.7.18-3 amd64 minimal subset of the Python2 language -ii python2.7-minimal 2.7.18-13ubuntu1.1 amd64 Minimal subset of the Python language (version 2.7) +ii python2.7-minimal 2.7.18-13ubuntu1.2 amd64 Minimal subset of the Python language (version 2.7) ii python3 3.10.6-1~22.04 amd64 interactive high-level object-oriented language (default python3 version) ii python3-minimal 3.10.6-1~22.04 amd64 minimal subset of the Python language (default python3 version) ii python3-pyasn1 0.4.8-1 all ASN.1 library for Python (Python 3 module) -ii python3-pycryptodome 3.11.0+dfsg1-3build1 amd64 cryptographic Python library (Python 3) +ii python3-pycryptodome 3.11.0+dfsg1-3ubuntu0.1 amd64 cryptographic Python library (Python 3) ii python3-zstd 1.5.0.2-1build1 amd64 python bindings to Yann Collet ZSTD compression library ii python3.10 3.10.12-1~22.04.3 amd64 Interactive high-level object-oriented language (version 3.10) ii python3.10-minimal 3.10.12-1~22.04.3 amd64 Minimal subset of the Python language (version 3.10) @@ -309,7 +309,7 @@ ii time 1.9-0.1build2 amd64 ii ubuntu-keyring 2021.03.26 all GnuPG keys of the Ubuntu archive ii ucf 3.0043 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 -ii unzip 6.0-26ubuntu3.1 amd64 De-archiver for .zip files +ii unzip 6.0-26ubuntu3.2 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.15 amd64 Vi IMproved - enhanced vi editor @@ -331,7 +331,7 @@ ii zstd 1.4.8+dfsg-3build1 amd64 ||/ Name Version Architecture Description Packages sorted by Installed-Size: - 754338 ===== TOTAL (325 packages) + 754392 ===== TOTAL (325 packages) 52747 gcc-11 amd64 34444 libicu70 amd64 32783 vim-runtime all @@ -344,32 +344,32 @@ Packages sorted by Installed-Size: 17671 perl-modules-5.34 all 15293 zsh-common all 13895 libgcc-11-dev amd64 - 13593 libc6 amd64 - 13037 libc6-dev amd64 + 13597 libc6 amd64 + 13038 libc6-dev amd64 12562 libc6-x32 amd64 12480 libc6 i386 12201 libc6-i386 amd64 11311 gdb amd64 10877 lib32stdc++-11-dev amd64 - 10439 binutils-x86-64-linux-gnu amd64 + 10431 binutils-x86-64-linux-gnu amd64 10390 libx32stdc++-11-dev amd64 9866 cmake-data all - 8249 libc6-dev-x32 amd64 + 8250 libc6-dev-x32 amd64 8119 libpython3.10-stdlib amd64 7948 lib32gcc-11-dev amd64 7734 perl-base amd64 7518 libasan6 amd64 - 7262 libc6-dev-i386 amd64 + 7263 libc6-dev-i386 amd64 7255 libtsan0 amd64 7128 libmagic-mgc amd64 - 7112 coreutils amd64 + 7104 coreutils amd64 6988 libx32gcc-11-dev amd64 - 6810 linux-libc-dev amd64 + 6858 linux-libc-dev amd64 6733 dpkg amd64 6667 lib32asan6 amd64 6570 libx32asan6 amd64 5898 python3.10-minimal amd64 - 5828 libssl3 amd64 + 5833 libssl3 amd64 5768 libpython3.10 amd64 5106 libpython3.10-minimal amd64 4249 ncurses-term all @@ -377,8 +377,8 @@ Packages sorted by Installed-Size: 4141 apt amd64 4082 libglib2.0-0 amd64 3931 vim amd64 - 3643 python2.7-minimal amd64 - 3542 python3-pycryptodome amd64 + 3639 python2.7-minimal amd64 + 3552 python3-pycryptodome amd64 3506 re2c amd64 3487 gojq amd64 3405 libmpfr6 amd64 @@ -433,7 +433,7 @@ Packages sorted by Installed-Size: 1138 libpam-modules amd64 1052 libkrb5-3 amd64 1005 screen amd64 - 995 libsystemd0 amd64 + 996 libsystemd0 amd64 990 p7zip amd64 984 wget amd64 960 tar amd64 @@ -486,12 +486,12 @@ Packages sorted by Installed-Size: 389 mount amd64 382 vim-common all 382 libmount1 amd64 - 376 unzip amd64 + 377 unzip amd64 372 xz-utils amd64 368 libssh2-1 amd64 356 libnettle8 amd64 350 ninja-build amd64 - 347 libudev1 amd64 + 348 libudev1 amd64 347 libnsl-dev amd64 347 libjq1 amd64 336 libhogweed6 amd64 @@ -522,7 +522,7 @@ Packages sorted by Installed-Size: 273 gcc-11-base amd64 272 gcc-12-base i386 272 gcc-12-base amd64 - 252 libuv1 amd64 + 253 libuv1 amd64 252 libipc-run-perl all 252 libcrypt1 i386 250 libmpdec3 amd64 diff --git a/misc/testsuite/mimic_ctest.sh b/misc/testsuite/mimic_ctest.sh index 38663694..58144722 100755 --- a/misc/testsuite/mimic_ctest.sh +++ b/misc/testsuite/mimic_ctest.sh @@ -53,6 +53,11 @@ export UPX="--no-color --no-progress" "${upx_run[@]}" --help "${upx_run[@]}" --sysinfo -v +case "$UPX_CONFIG_DISABLE_SELF_PACK_TEST" in +"" | "0" | "FALSE" | "OFF") ;; +*) echo "Self-pack test disabled. All done."; exit 0 ;; +esac + exe=".out" upx_self_exe=$upx_exe fo="--force-overwrite" diff --git a/src/check/dt_check.cpp b/src/check/dt_check.cpp index 49b845d5..c7a13570 100644 --- a/src/check/dt_check.cpp +++ b/src/check/dt_check.cpp @@ -44,10 +44,7 @@ int upx_doctest_check(int argc, char **argv) { UNUSED(argv); return 0; #else - const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE"); - if (!e) - e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling - if (e && e[0] && strcmp(e, "0") != 0) + if (is_envvar_true("UPX_DEBUG_DOCTEST_DISABLE", "UPX_DEBUG_DISABLE_DOCTEST")) return 0; bool minimal = true; // don't show summary bool duration = false; // don't show timings @@ -56,7 +53,7 @@ int upx_doctest_check(int argc, char **argv) { // default for debug builds: do show the [doctest] summary minimal = false; #endif - e = getenv("UPX_DEBUG_DOCTEST_VERBOSE"); + const char *e = getenv("UPX_DEBUG_DOCTEST_VERBOSE"); if (e && e[0]) { if (strcmp(e, "0") == 0) { minimal = true; @@ -352,11 +349,6 @@ static noinline void check_basic_cxx_exception_handling(void (*func)(int)) noexc // basic floating point checks to early catch toolchain/qemu/wine/etc problems // -#if defined(__clang__) && defined(__FAST_MATH__) && defined(__INTEL_LLVM_COMPILER) -// warning: comparison with NaN always evaluates to false in fast floating point modes -#pragma clang diagnostic ignored "-Wtautological-constant-compare" -#endif - static noinline float i64_f32_add_div(upx_int64_t a, upx_int64_t b) { return (a + b) / 1000000.0f; } static noinline float u64_f32_add_div(upx_uint64_t a, upx_uint64_t b) { return (a + b) / 1000000.0f; @@ -388,11 +380,18 @@ struct TestFloat { assert_noexcept(add_div_x(X, X) == Float(2)); assert_noexcept(sub_div(3 * X, X, Float(X)) == Float(2)); assert_noexcept(sub_div_x(3 * X, X) == Float(2)); - // extra debugging hack - const char *e = getenv("UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO"); - if (e && e[0] && strcmp(e, "0") != 0) { + // extra debugging; floating point edge cases cause portability problems in practice + if (is_envvar_true("UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO")) { +#if defined(__clang__) && defined(__FAST_MATH__) && defined(__INTEL_LLVM_COMPILER) + // warning: comparison with NaN always evaluates to false in fast floating point modes + fprintf(stderr, "upx: WARNING: ignoring UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO\n"); +#elif defined(__clang__) && (__clang_major__ < 9) && defined(__SANITIZE_UNDEFINED_BEHAVIOR__) + // @COMPILER_BUG @CLANG_BUG + fprintf(stderr, "upx: WARNING: ignoring UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO\n"); +#else assert_noexcept(std::isnan(div(0, Float(0)))); - assert_noexcept(std::isinf(div(X, Float(0)))); + assert_noexcept(std::isinf(div(1, Float(0)))); +#endif } } }; @@ -423,10 +422,7 @@ static noinline void check_basic_floating_point(void) noexcept { #include "../util/miniacc.h" void upx_compiler_sanity_check(void) noexcept { - const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE"); - if (!e) - e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling - if (e && e[0] && strcmp(e, "0") != 0) { + if (is_envvar_true("UPX_DEBUG_DOCTEST_DISABLE", "UPX_DEBUG_DISABLE_DOCTEST")) { // If UPX_DEBUG_DOCTEST_DISABLE is set then we don't want to throw any // exceptions in order to improve debugging experience. } else { diff --git a/src/main.cpp b/src/main.cpp index b64a1e8d..9f99ba12 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1306,8 +1306,7 @@ int upx_main(int argc, char *argv[]) may_throw { if (gitrev[0]) { // also see UPX_CONFIG_DISABLE_GITREV in CMakeLists.txt bool warn_gitrev = true; - const char *ee = getenv("UPX_DEBUG_DISABLE_GITREV_WARNING"); - if (ee && ee[0] && strcmp(ee, "1") == 0) + if (is_envvar_true("UPX_DEBUG_DISABLE_GITREV_WARNING")) warn_gitrev = false; if (warn_gitrev) { FILE *f = stdout; diff --git a/src/p_mach.cpp b/src/p_mach.cpp index 34fbb43b..f640004f 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -2243,17 +2243,19 @@ tribool PackMachBase::canPack() break; } } -#if !defined(DEBUG) - // disable macOS packing in Release builds until we do support macOS 13+ + // disable macOS packing until we do support macOS 13+ // https://github.com/upx/upx/issues/612 - if (my_cputype == CPU_TYPE_X86_64 || my_cputype == CPU_TYPE_ARM64) - if (!opt->darwin_macho.force_macos) + if (my_cputype == CPU_TYPE_X86_64 || my_cputype == CPU_TYPE_ARM64) { + bool force = opt->darwin_macho.force_macos || is_envvar_true("UPX_DEBUG_FORCE_PACK_MACOS"); + if (!force) throwCantPack("macOS is currently not supported (try --force-macos)"); -#endif + } return true; } +// instantiate instances template class PackMachBase; +// template class PackMachBase; // currently not used template class PackMachBase; template class PackMachBase; diff --git a/src/p_vmlinx.cpp b/src/p_vmlinx.cpp index 40a7cb5d..25fcaa6a 100644 --- a/src/p_vmlinx.cpp +++ b/src/p_vmlinx.cpp @@ -1240,7 +1240,7 @@ Linker* PackVmlinuxAMD64::newLinker() const // instantiate instances template class PackVmlinuxBase; -// template class PackVmlinuxBase; // not used +// template class PackVmlinuxBase; // currently not used template class PackVmlinuxBase; template class PackVmlinuxBase; diff --git a/src/util/system_defs.h b/src/util/system_defs.h index 2b565d30..17cc48f0 100644 --- a/src/util/system_defs.h +++ b/src/util/system_defs.h @@ -30,9 +30,16 @@ #define _FILE_OFFSET_BITS 64 #endif -#if !defined(__STDC_FORMAT_MACROS) // this is needed for some older glibc/mingw versions +// these are needed for some older glibc/mingw versions +#if !defined(__STDC_CONSTANT_MACROS) +#define __STDC_CONSTANT_MACROS 1 +#endif +#if !defined(__STDC_FORMAT_MACROS) #define __STDC_FORMAT_MACROS 1 #endif +#if !defined(__STDC_LIMIT_MACROS) +#define __STDC_LIMIT_MACROS 1 +#endif #if !defined(__USE_MINGW_ANSI_STDIO) #if defined(_WIN32) && defined(__MINGW32__) && (defined(__clang__) || defined(__GNUC__)) @@ -40,7 +47,7 @@ #endif #endif -#if defined(_WIN32) +#if defined(_WIN32) || defined(__CYGWIN__) // disable silly warnings about using "deprecated" POSIX functions like fopen() #if !defined(_CRT_NONSTDC_NO_DEPRECATE) #define _CRT_NONSTDC_NO_DEPRECATE 1 diff --git a/src/util/system_headers.h b/src/util/system_headers.h index 99420b64..d6c60e6b 100644 --- a/src/util/system_headers.h +++ b/src/util/system_headers.h @@ -32,7 +32,36 @@ #error "C++17 is required" #endif -// sanity check +// check expected defines +#if defined(__CYGWIN32__) && !defined(__CYGWIN__) +#error "missing __CYGWIN__" +#endif +#if defined(__CYGWIN64__) && !defined(__CYGWIN__) +#error "missing __CYGWIN__" +#endif +#if defined(__clang__) || defined(__GNUC__) +// these are pre-defined since gcc-4.6 (2011) and clang-3.2 (2012) +#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 == 0) +#error "missing __ORDER_BIG_ENDIAN__" +#endif +#if !defined(__ORDER_LITTLE_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 == 0) +#error "missing __ORDER_LITTLE_ENDIAN__" +#endif +#if !defined(__BYTE_ORDER__) || (__BYTE_ORDER__ + 0 == 0) +#error "missing __BYTE_ORDER__" +#endif +#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 != 4321) +#error "unexpected __ORDER_BIG_ENDIAN__" +#endif +#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 != 1234) +#error "unexpected __ORDER_BIG_ENDIAN__" +#endif +#if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) +#error "unexpected __BYTE_ORDER__" +#endif +#endif + +// sanity checks #if defined(__ILP32) || defined(__ILP32__) static_assert(sizeof(int) == 4); static_assert(sizeof(long) == 4); @@ -55,28 +84,9 @@ static_assert(sizeof(int) == 4); static_assert(sizeof(long) == 4); static_assert(sizeof(void *) == 8); #endif - -// check expected defines -#if defined(__clang__) || defined(__GNUC__) -// these are pre-defined since gcc-4.6 (2011) and clang-3.2 (2012) -#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 == 0) -#error "missing __ORDER_BIG_ENDIAN__" -#endif -#if !defined(__ORDER_LITTLE_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 == 0) -#error "missing __ORDER_LITTLE_ENDIAN__" -#endif -#if !defined(__BYTE_ORDER__) || (__BYTE_ORDER__ + 0 == 0) -#error "missing __BYTE_ORDER__" -#endif -#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 != 4321) -#error "unexpected __ORDER_BIG_ENDIAN__" -#endif -#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 != 1234) -#error "unexpected __ORDER_BIG_ENDIAN__" -#endif -#if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) -#error "unexpected __BYTE_ORDER__" -#endif +#if defined(__CYGWIN__) +static_assert(sizeof(int) == 4); +static_assert(sizeof(void *) == sizeof(long)); #endif // ACC and C system headers @@ -135,6 +145,11 @@ static_assert(sizeof(void *) == 8); #define __SANITIZE_MEMORY__ 1 #endif #endif +#if !defined(__SANITIZE_UNDEFINED_BEHAVIOR__) && defined(__has_feature) +#if __has_feature(undefined_behavior_sanitizer) +#define __SANITIZE_UNDEFINED_BEHAVIOR__ 1 +#endif +#endif // UPX vendor git submodule headers #include diff --git a/src/util/util.cpp b/src/util/util.cpp index 0614f16b..43ae4d0e 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -768,6 +768,19 @@ int fn_strcmp(const char *n1, const char *n2) { // misc **************************************************************************/ +bool is_envvar_true(const char *envvar, const char *alternate_name) noexcept { + // UPX convention: any environment variable that is set and is not strictly equal to "0" is true + const char *e = getenv(envvar); + if (e != nullptr && e[0]) + return strcmp(e, "0") != 0; + if (alternate_name != nullptr) { + e = getenv(alternate_name); + if (e != nullptr && e[0]) + return strcmp(e, "0") != 0; + } + return false; +} + bool set_method_name(char *buf, size_t size, int method, int level) { bool r = true; const char *alg; diff --git a/src/util/util.h b/src/util/util.h index 31c6089a..26d8bc4b 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -192,6 +192,8 @@ bool maketempname(char *ofilename, size_t size, const char *ifilename, const cha bool force = true); bool makebakname(char *ofilename, size_t size, const char *ifilename, bool force = true); +bool is_envvar_true(const char *envvar, const char *alternate_name = nullptr) noexcept; + unsigned get_ratio(upx_uint64_t u_len, upx_uint64_t c_len); bool set_method_name(char *buf, size_t size, int method, int level); void center_string(char *buf, size_t size, const char *s); diff --git a/src/version.h b/src/version.h index 9f649846..9a34b921 100644 --- a/src/version.h +++ b/src/version.h @@ -3,5 +3,5 @@ #define UPX_VERSION_STRING "4.2.3" #define UPX_VERSION_STRING4 "4.23" #define UPX_VERSION_DATE "Mar 12th 2024" -#define UPX_VERSION_DATE_ISO "2024-03-12" +#define UPX_VERSION_DATE_ISO "2024-03-16" #define UPX_VERSION_YEAR "2024"