diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ba31b22..2d285eab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact @@ -203,7 +203,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact @@ -271,7 +271,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact @@ -373,7 +373,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact @@ -505,7 +505,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/test-alpine-linux.yml b/.github/workflows/test-alpine-linux.yml index da3fa9bb..dc481645 100644 --- a/.github/workflows/test-alpine-linux.yml +++ b/.github/workflows/test-alpine-linux.yml @@ -34,7 +34,7 @@ jobs: echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: 'upx*/build/*/upx' @@ -61,7 +61,7 @@ jobs: echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: 'upx*/build/*/upx' diff --git a/.github/workflows/weekly-ci-bs-cmake-macos-xcode.yml b/.github/workflows/weekly-ci-bs-cmake-macos-xcode.yml index ebf617eb..ee23383b 100644 --- a/.github/workflows/weekly-ci-bs-cmake-macos-xcode.yml +++ b/.github/workflows/weekly-ci-bs-cmake-macos-xcode.yml @@ -41,7 +41,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/weekly-ci-bs-cmake-windows-make.yml b/.github/workflows/weekly-ci-bs-cmake-windows-make.yml index 9d794d4c..dada70bb 100644 --- a/.github/workflows/weekly-ci-bs-cmake-windows-make.yml +++ b/.github/workflows/weekly-ci-bs-cmake-windows-make.yml @@ -82,7 +82,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/weekly-ci-bs-cmake-windows-ninja.yml b/.github/workflows/weekly-ci-bs-cmake-windows-ninja.yml index 00e978ef..0a5de7b1 100644 --- a/.github/workflows/weekly-ci-bs-cmake-windows-ninja.yml +++ b/.github/workflows/weekly-ci-bs-cmake-windows-ninja.yml @@ -81,7 +81,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/weekly-ci-bs-cmake-windows-nmake.yml b/.github/workflows/weekly-ci-bs-cmake-windows-nmake.yml index 976b2075..2a787c89 100644 --- a/.github/workflows/weekly-ci-bs-cmake-windows-nmake.yml +++ b/.github/workflows/weekly-ci-bs-cmake-windows-nmake.yml @@ -68,7 +68,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/weekly-ci-cc-alpine-linux.yml b/.github/workflows/weekly-ci-cc-alpine-linux.yml index 1c70bc67..6578a7e7 100644 --- a/.github/workflows/weekly-ci-cc-alpine-linux.yml +++ b/.github/workflows/weekly-ci-cc-alpine-linux.yml @@ -160,7 +160,7 @@ jobs: - name: ${{ format('Upload artifact {0}', env.artifact_name) }} if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: 'upx with space*/build/*/*/*/upx' diff --git a/.github/workflows/weekly-ci-cc-alpine-mingw.yml b/.github/workflows/weekly-ci-cc-alpine-mingw.yml index c7640c49..2224c0e2 100644 --- a/.github/workflows/weekly-ci-cc-alpine-mingw.yml +++ b/.github/workflows/weekly-ci-cc-alpine-mingw.yml @@ -86,7 +86,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/weekly-ci-cc-llvm-mingw.yml b/.github/workflows/weekly-ci-cc-llvm-mingw.yml index adefd6e9..52221fc2 100644 --- a/.github/workflows/weekly-ci-cc-llvm-mingw.yml +++ b/.github/workflows/weekly-ci-cc-llvm-mingw.yml @@ -85,7 +85,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/weekly-ci-cc-zigcc.yml b/.github/workflows/weekly-ci-cc-zigcc.yml index 26a30a53..087f2923 100644 --- a/.github/workflows/weekly-ci-cc-zigcc.yml +++ b/.github/workflows/weekly-ci-cc-zigcc.yml @@ -120,7 +120,7 @@ jobs: # GitHub Actions magic: set "artifact_name" environment value for use in next step echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/.github/workflows/weekly-ci-rt-checkers.yml b/.github/workflows/weekly-ci-rt-checkers.yml index 92155fce..99d3316c 100644 --- a/.github/workflows/weekly-ci-rt-checkers.yml +++ b/.github/workflows/weekly-ci-rt-checkers.yml @@ -72,7 +72,7 @@ jobs: echo "artifact_name=$N" >> $GITHUB_ENV - name: ${{ format('Upload artifact {0}', env.artifact_name) }} if: ${{ !startsWith(matrix.container, 'i386/') }} # i386: missing nodejs on host - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.artifact_name }} path: tmp/artifact diff --git a/misc/make/Makefile-extra.mk b/misc/make/Makefile-extra.mk index ce95cf1a..27bfbb3e 100644 --- a/misc/make/Makefile-extra.mk +++ b/misc/make/Makefile-extra.mk @@ -120,7 +120,7 @@ build/extra/gcc-std-cxx20/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON build/extra/gcc-std-cxx23/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/gcc-std-cxx23/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/gcc-std-cxx23/%: export CC = gcc -std=gnu2x -build/extra/gcc-std-cxx23/%: export CXX = g++ -std=gnu++23 +build/extra/gcc-std-cxx23/%: export CXX = g++ -std=gnu++2b build/extra/gcc-std-cxx23/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON build/extra/gcc-std-cxx23/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON @@ -221,8 +221,8 @@ 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 -build/xtarget/$(UPX_XTARGET)/%: export CXX +build/xtarget/$(UPX_XTARGET)/%: export CC := $(CC) +build/xtarget/$(UPX_XTARGET)/%: export CXX := $(CXX) # shortcuts xtarget/all: xtarget/debug xtarget/release xtarget/debug: build/xtarget/$(UPX_XTARGET)/debug @@ -246,12 +246,22 @@ __add_cmake_config = $(and $($1),-D$1="$($1)") # pass common CMake settings from environment/make to cmake build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_VERBOSE_MAKEFILE) # pass common CMake toolchain settings from environment/make to cmake +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_ADDR2LINE) build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_AR) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_DLLTOOL) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_LINKER) build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_NM) -build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_RANLIB) build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJCOPY) build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJDUMP) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_RANLIB) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_READELF) build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_STRIP) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_TAPI) +# pass common CMake LTO toolchain settings from environment/make to cmake (for use with "-flto") +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_C_COMPILER_AR) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_C_COMPILER_RANLIB) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CXX_COMPILER_AR) +build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CXX_COMPILER_RANLIB) # pass common CMake cross compilation settings from environment/make to cmake build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_SYSTEM_NAME) build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CROSSCOMPILING_EMULATOR) diff --git a/src/packmast.cpp b/src/packmast.cpp index a6a8573f..7cca3e15 100644 --- a/src/packmast.cpp +++ b/src/packmast.cpp @@ -136,7 +136,7 @@ static noinline tribool try_can_unpack(PackerBase *pb, void *user) may_throw { /*static*/ PackerBase *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const Options *o, void *user) may_throw { -#define D(Klass) \ +#define VISIT(Klass) \ do { \ static_assert(std::is_class_v); \ static_assert(std::is_nothrow_destructible_v); \ @@ -159,91 +159,91 @@ PackerBase *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const O // if (!o->dos_exe.force_stub) { // dos32 - D(PackDjgpp2); - D(PackTmt); - D(PackWcle); + VISIT(PackDjgpp2); + VISIT(PackTmt); + VISIT(PackWcle); // Windows - // D(PackW64PeArm64EC); // NOT YET IMPLEMENTED - // D(PackW64PeArm64); // NOT YET IMPLEMENTED - D(PackW64PeAmd64); - D(PackW32PeI386); - D(PackWinCeArm); + // VISIT(PackW64PeArm64EC); // NOT YET IMPLEMENTED + // VISIT(PackW64PeArm64); // NOT YET IMPLEMENTED + VISIT(PackW64PeAmd64); + VISIT(PackW32PeI386); + VISIT(PackWinCeArm); } - D(PackExe); // dos/exe + VISIT(PackExe); // dos/exe // // linux kernel // - D(PackVmlinuxARMEL); - D(PackVmlinuxARMEB); - D(PackVmlinuxPPC32); - D(PackVmlinuxPPC64LE); - D(PackVmlinuxAMD64); - D(PackVmlinuxI386); - D(PackVmlinuzI386); - D(PackBvmlinuzI386); - D(PackVmlinuzARMEL); + VISIT(PackVmlinuxARMEL); + VISIT(PackVmlinuxARMEB); + VISIT(PackVmlinuxPPC32); + VISIT(PackVmlinuxPPC64LE); + VISIT(PackVmlinuxAMD64); + VISIT(PackVmlinuxI386); + VISIT(PackVmlinuzI386); + VISIT(PackBvmlinuzI386); + VISIT(PackVmlinuzARMEL); // // linux // if (!o->o_unix.force_execve) { if (o->o_unix.use_ptinterp) { - D(PackLinuxElf32x86interp); + VISIT(PackLinuxElf32x86interp); } - D(PackFreeBSDElf32x86); - D(PackNetBSDElf32x86); - D(PackOpenBSDElf32x86); - D(PackLinuxElf32x86); - D(PackLinuxElf64amd); - D(PackLinuxElf32armLe); - D(PackLinuxElf32armBe); - D(PackLinuxElf64arm); - D(PackLinuxElf32ppc); - D(PackLinuxElf64ppc); - D(PackLinuxElf64ppcle); - D(PackLinuxElf32mipsel); - D(PackLinuxElf32mipseb); - D(PackLinuxI386sh); + VISIT(PackFreeBSDElf32x86); + VISIT(PackNetBSDElf32x86); + VISIT(PackOpenBSDElf32x86); + VISIT(PackLinuxElf32x86); + VISIT(PackLinuxElf64amd); + VISIT(PackLinuxElf32armLe); + VISIT(PackLinuxElf32armBe); + VISIT(PackLinuxElf64arm); + VISIT(PackLinuxElf32ppc); + VISIT(PackLinuxElf64ppc); + VISIT(PackLinuxElf64ppcle); + VISIT(PackLinuxElf32mipsel); + VISIT(PackLinuxElf32mipseb); + VISIT(PackLinuxI386sh); } - D(PackBSDI386); - D(PackMachFat); // cafebabe conflict - D(PackLinuxI386); // cafebabe conflict + VISIT(PackBSDI386); + VISIT(PackMachFat); // cafebabe conflict + VISIT(PackLinuxI386); // cafebabe conflict // Mach (Darwin / macOS) - D(PackDylibAMD64); - D(PackMachPPC32); // TODO: this works with upx 3.91..3.94 but got broken in 3.95; FIXME - D(PackMachI386); - D(PackMachAMD64); - D(PackMachARMEL); - D(PackMachARM64EL); + VISIT(PackDylibAMD64); + VISIT(PackMachPPC32); // TODO: this works with upx 3.91..3.94 but got broken in 3.95; FIXME + VISIT(PackMachI386); + VISIT(PackMachAMD64); + VISIT(PackMachARMEL); + VISIT(PackMachARM64EL); // 2010-03-12 omit these because PackMachBase::pack4dylib (p_mach.cpp) // does not understand what the Darwin (Apple Mac OS X) dynamic loader // assumes about .dylib file structure. - // D(PackDylibI386); - // D(PackDylibPPC32); + // VISIT(PackDylibI386); + // VISIT(PackDylibPPC32); // // misc // - D(PackTos); // atari/tos - D(PackPs1); // ps1/exe - D(PackSys); // dos/sys - D(PackCom); // dos/com + VISIT(PackTos); // atari/tos + VISIT(PackPs1); // ps1/exe + VISIT(PackSys); // dos/sys + VISIT(PackCom); // dos/com return nullptr; -#undef D +#undef VISIT } -/*static*/ PackerBase *PackMaster::getPacker(InputFile *f) { +/*static*/ PackerBase *PackMaster::getPacker(InputFile *f) may_throw { PackerBase *pb = visitAllPackers(try_can_pack, f, opt, f); if (!pb) throwUnknownExecutableFormat(); return pb; } -/*static*/ PackerBase *PackMaster::getUnpacker(InputFile *f) { +/*static*/ PackerBase *PackMaster::getUnpacker(InputFile *f) may_throw { PackerBase *pb = visitAllPackers(try_can_unpack, f, opt, f); if (!pb) throwNotPacked(); @@ -254,31 +254,31 @@ PackerBase *PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const O // delegation from work.cpp **************************************************************************/ -void PackMaster::pack(OutputFile *fo) { +void PackMaster::pack(OutputFile *fo) may_throw { assert(packer == nullptr); packer = getPacker(fi); packer->doPack(fo); } -void PackMaster::unpack(OutputFile *fo) { +void PackMaster::unpack(OutputFile *fo) may_throw { assert(packer == nullptr); packer = getUnpacker(fi); packer->doUnpack(fo); } -void PackMaster::test() { +void PackMaster::test() may_throw { assert(packer == nullptr); packer = getUnpacker(fi); packer->doTest(); } -void PackMaster::list() { +void PackMaster::list() may_throw { assert(packer == nullptr); packer = getUnpacker(fi); packer->doList(); } -void PackMaster::fileInfo() { +void PackMaster::fileInfo() may_throw { assert(packer == nullptr); packer = visitAllPackers(try_can_unpack, fi, opt, fi); if (!packer) diff --git a/src/packmast.h b/src/packmast.h index 36958227..df23edb6 100644 --- a/src/packmast.h +++ b/src/packmast.h @@ -47,16 +47,15 @@ public: void fileInfo() may_throw; typedef tribool (*visit_func_t)(PackerBase *pb, void *user); - static PackerBase *visitAllPackers(visit_func_t, InputFile *f, const Options *, void *user) - may_throw; + static noinline PackerBase *visitAllPackers(visit_func_t, InputFile *f, const Options *, + void *user) may_throw; private: - OwningPointer(PackerBase) packer = nullptr; // owner - InputFile *const fi; // reference, required - static PackerBase *getPacker(InputFile *f) may_throw; static PackerBase *getUnpacker(InputFile *f) may_throw; + OwningPointer(PackerBase) packer = nullptr; // owner + InputFile *const fi; // reference, required // setup local options for each file Options local_options; Options *saved_opt = nullptr;