Compare commits

..

310 Commits

Author SHA1 Message Date
John Reiser 65b3dd7e52 risc-v 64-bit stubs build successfully in developer environment
This is the "bottom half" to add support for riscv64 to UPX.
Need update to stubtools for: gcc objcopy objdump ld
   Now using local cross tools /usr/bin/riscv64-linux-gnu-* on Ubuntu 24.04.
Need fix for riscv64-linux.elf-fold.h being 224 KB.
TODO: extend p_lx_elf.cpp  linker.cpp
TODO: implement nrv2d_d.S nrv2e_d.S lzma_d.S
TODO: testing  (using qemu-riscv64 and gdb-multiarch on Ubuntu 24.04)

        https://github.com/upx/upx/discussions/793

	modified:   src/stub/Makefile
	modified:   src/stub/scripts/xstrip.py
	modified:   src/stub/src/amd64-linux.elf-main2.c
	modified:   src/stub/src/arch/amd64/macros.S
	new file:   src/stub/src/arch/riscv/64/Makefile
	new file:   src/stub/src/arch/riscv/64/Makefile.extra
	new file:   src/stub/src/arch/riscv/64/macros.S
	new file:   src/stub/src/arch/riscv/64/nrv2b_d.S
	new file:   src/stub/src/arch/riscv/64/regs.h
	new file:   src/stub/src/riscv64-expand.S
	new file:   src/stub/src/riscv64-linux.elf-entry.S
	new file:   src/stub/src/riscv64-linux.elf-fold.S
	new file:   src/stub/src/riscv64-linux.elf-fold.lds
	new file:   src/stub/src/riscv64-linux.elf-help_umf.S
	new file:   src/stub/src/riscv64-linux.elf-main2.c
	modified:   src/stub/src/upxfd_linux.c
2025-11-01 08:59:05 -07:00
Markus F.X.J. Oberhumer b11f043d64 CI updates 2025-09-10 11:11:51 +02:00
John Reiser aef93548f9 Fix memfd_create in shared libraries on amd64 Linux < kernel 6.3
https://github.com/upx/upx/issues/929
	modified:   stub/src/amd64-linux.elf-so_fold.S
           plus generated .h .dump
2025-09-09 14:58:00 -07:00
John Reiser 26ca21f6cb arm.v4a: cancel_sigsegv
modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   src/stub/src/arm.v4a-linux.elf-entry.S
	modified:   src/stub/src/arm.v4a-linux.elf-fold.S
           plus generated .h .dump .map
2025-08-21 06:19:21 -07:00
Markus F.X.J. Oberhumer 404fb48668 CI updates 2025-08-21 00:21:15 +02:00
John Reiser e85e8bec5d New option --catch-sigsegv on amd64, arm64, arm.v4a
Catch SIGSEGV during de-compression, and print state info
("auto debug") using /proc/self/maps and gdb.
This was motivated by suspicion of unreliable hardware
which triggered "Heisenbugs": a crash which cannot be reproduced.
If SIGSGV occurs without the "auto debug" info, then that
implies an error user code after de-compression, often when
user code accesses /proc/self/exe, which is not the un-compressed file.
	modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   src/help.cpp
	modified:   src/main.cpp
	modified:   src/options.h
	modified:   src/p_lx_elf.cpp
	modified:   src/stub/Makefile
	modified:   src/stub/src/amd64-linux.elf-entry.S
	modified:   src/stub/src/amd64-linux.elf-fold.S
	modified:   src/stub/src/arm.v4a-linux.elf-entry.S
	modified:   src/stub/src/arm.v4a-linux.elf-fold.S
	modified:   src/stub/src/arm64-linux.elf-entry.S
	modified:   src/stub/src/arm64-linux.elf-fold.S
           plus generated .h .dump .map
2025-08-19 12:25:33 -07:00
John Reiser 4530e5c264 Fix upxfd_create for stubs on PowerPC64
https://github.com/upx/upx/issues/925
	modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   src/stub/src/powerpc64-linux.elf-fold.S
           plus generated .h
2025-08-16 16:00:11 -07:00
Markus F.X.J. Oberhumer 1188d2933b SIGSEGV: handle and pretty-print on arm64-linux 2025-08-10 09:55:12 +02:00
Markus F.X.J. Oberhumer 4e88556c94 SIGSEGV: handle and pretty-print on amd64-linux 2025-08-10 09:39:29 +02:00
Markus F.X.J. Oberhumer 1f0036a460 CI updates 2025-08-10 09:05:14 +02:00
Markus F.X.J. Oberhumer 5d30472ee2 CI updates 2025-08-04 16:05:44 +02:00
Markus F.X.J. Oberhumer 9866b9bca9 SIGSEGV: handle and pretty-print on amd64-linux 2025-08-01 00:49:27 +02:00
Markus F.X.J. Oberhumer bbf52cee67 CI updates 2025-07-30 23:09:28 +02:00
Markus F.X.J. Oberhumer b9b77965b7 CI updates 2025-07-30 01:40:30 +02:00
Markus F.X.J. Oberhumer 852666010e CI updates 2025-07-29 19:50:17 +02:00
John Reiser bbb886ae4d gcc 14.2.1-3 lax on signed-vs-unsigned compare
modified:   p_lx_elf.cpp
2025-07-25 07:14:33 -07:00
John Reiser b52d3e0772 Detect DT_HASH chain out-of-bounds
https://issues.oss-fuzz.com/u/1/issues/430110068
	modified:   p_lx_elf.cpp
2025-07-24 11:09:58 -07:00
Markus F.X.J. Oberhumer 27f8f4f62e CI updates 2025-07-25 18:20:14 +02:00
Markus F.X.J. Oberhumer 21ec7e7410 CI updates 2025-07-25 10:03:28 +02:00
Markus F.X.J. Oberhumer ae6d5303ba CI updates 2025-07-25 03:07:51 +02:00
Markus F.X.J. Oberhumer fbbc2bc874 CI updates 2025-07-23 14:33:29 +02:00
Markus F.X.J. Oberhumer 62f22d61e6 CI updates 2025-07-23 11:00:41 +02:00
Markus F.X.J. Oberhumer 3f1f76f8a3 CI updates 2025-07-21 15:57:03 +02:00
Markus F.X.J. Oberhumer 518712c613 CI updates 2025-07-21 12:26:30 +02:00
Markus F.X.J. Oberhumer c0c08c9f43 all: post-release version bump 2025-07-20 15:59:04 +02:00
Markus F.X.J. Oberhumer c4113b6bd6 all: prepare for release 2025-07-20 14:41:25 +02:00
Markus F.X.J. Oberhumer 4988868e61 CI updates 2025-07-20 13:58:38 +02:00
Markus F.X.J. Oberhumer 5a513ab16f CI updates 2025-07-20 12:21:56 +02:00
Markus F.X.J. Oberhumer f1a9d1bec9 CI updates 2025-07-20 00:38:43 +02:00
Markus F.X.J. Oberhumer 70a3acfded CI updates 2025-07-18 20:17:11 +02:00
Markus F.X.J. Oberhumer 3ec6a3cce0 CI updates 2025-07-18 12:42:37 +02:00
Markus F.X.J. Oberhumer dd0a8856cc CI updates 2025-07-18 11:44:36 +02:00
Markus F.X.J. Oberhumer c51a1130b8 CI updates 2025-07-17 20:47:19 +02:00
Markus F.X.J. Oberhumer 9851fba246 CI updates 2025-07-17 15:46:12 +02:00
Markus F.X.J. Oberhumer 8054543671 CI updates 2025-07-15 10:55:39 +02:00
Markus F.X.J. Oberhumer 17d0e897ba CI updates 2025-07-15 09:56:46 +02:00
Markus F.X.J. Oberhumer a7940fd19b CI updates 2025-07-07 18:01:00 +02:00
John Reiser 1fbd34035e shell trap on ERR to help locate failing commands
modified:   misc/testsuite/mimic_ctest.sh
2025-07-06 19:21:26 -07:00
John Reiser 945d9157fa PowerPC64 editing error affecting -fPIE
https://github.com/upx/upx/issues/918
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/powerpc64-linux.elf-fold.S
          plus generated powerpc64*-linux.elf-fold.h
2025-07-05 18:10:46 -07:00
Markus F.X.J. Oberhumer 915bfbd82e CI updates 2025-07-05 22:23:13 +02:00
Markus F.X.J. Oberhumer ef01a73e8f CI updates 2025-06-26 11:54:26 +02:00
Markus F.X.J. Oberhumer 7e4e6a3cb1 CI updates 2025-06-26 11:30:46 +02:00
Markus F.X.J. Oberhumer ca97430db2 CI updates 2025-06-06 12:25:13 +02:00
Markus F.X.J. Oberhumer 7530643d1d CI updates 2025-06-01 14:55:43 +02:00
Markus F.X.J. Oberhumer 073cdb0d58 CI updates 2025-06-01 14:11:05 +02:00
Markus F.X.J. Oberhumer 9a93b5d1c1 CI updates 2025-05-31 15:44:22 +02:00
Markus F.X.J. Oberhumer 44ce469b84 CI updates 2025-05-31 13:54:04 +02:00
Markus F.X.J. Oberhumer 4d8d330f21 CI updates 2025-05-30 18:31:56 +02:00
Markus F.X.J. Oberhumer 793e1622ea CI updates 2025-05-29 12:04:43 +02:00
Markus F.X.J. Oberhumer 92a33fa0cc CI updates 2025-05-25 10:12:35 +02:00
John Reiser e8c49a2c35 Prevent SIGSEGV on de-compress of modified PE file
https://github.com/upx/upx/issues/863
	modified:   pefile.cpp
2025-05-13 10:51:59 -07:00
Markus F.X.J. Oberhumer d2e9db7112 CI updates 2025-05-10 13:55:49 +02:00
John Reiser b728b0e021 buildLinuxLoader needs more space
for shlib + lzma + Android
https://github.com/upx/upx/issues/913
	modified:   p_lx_elf.cpp
2025-05-07 13:52:58 -07:00
John Reiser a1ef410509 ELF DT_DYNSYM: fix checking of symbol table
Particularly JNI_OnLoad
https://github.com/upx/upx/issues/914
	modified:   p_lx_elf.cpp
2025-05-07 17:02:56 -07:00
Markus F.X.J. Oberhumer 24b4ec42e7 CI updates 2025-05-07 19:11:57 +02:00
Markus F.X.J. Oberhumer 52dde5789e all: post-release version bump 2025-05-06 14:01:35 +02:00
Markus F.X.J. Oberhumer 730c6ce6c5 all: prepare for release 2025-05-06 12:19:16 +02:00
Markus F.X.J. Oberhumer 5ed1d5b2b3 src/stub: fix ET_DYN with non-zero PT_LOAD[0].p_vaddr 2025-05-01 20:42:39 +02:00
Markus F.X.J. Oberhumer 23c70ec447 src/stub: fix ET_DYN with non-zero PT_LOAD[0].p_vaddr 2025-05-01 20:37:36 +02:00
Markus F.X.J. Oberhumer e29e73a4e4 src/help.cpp: mention --fileinfo 2025-05-01 20:33:34 +02:00
Markus F.X.J. Oberhumer 27289a7589 src/stub: flush datacache before msync 2025-04-29 17:53:33 +02:00
Markus F.X.J. Oberhumer e509bb87e9 src/stub: flush datacache before msync 2025-04-29 17:44:47 +02:00
Markus F.X.J. Oberhumer 5cec09966e submodules: update for new versions 2025-04-22 15:44:29 +02:00
Markus F.X.J. Oberhumer b5789fb321 src: minor cleanups 2025-04-21 14:04:27 +02:00
Markus F.X.J. Oberhumer a1b0fd987f CI updates 2025-04-20 15:46:19 +02:00
Markus F.X.J. Oberhumer a468b92e3a PowerPC Psync flush datacache before msync 2025-04-20 15:06:58 +02:00
John Reiser ddf0b50c6d PowerPC Psync flush datacache before msync
https://github.com/upx/upx/issues/907
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
2025-04-20 14:55:06 +02:00
Markus F.X.J. Oberhumer 3af2b21869 CI updates 2025-04-11 09:41:08 +02:00
Markus F.X.J. Oberhumer c4bfebeceb CI updates 2025-04-10 20:04:34 +02:00
Markus F.X.J. Oberhumer d23484b9db CI updates 2025-04-09 11:32:13 +02:00
John Reiser 071579b5b6 Cleanup after broken tools
zig/powerpc64le/musl newly undefined openat64; adjacent literal strings
in C source were not concatenated; comment introduced by double slash
did not ignore backslash in rest of line
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64-linux.elf-entry.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
	modified:   stub/src/upxfd_linux.c
2025-03-21 13:25:02 -07:00
John Reiser ff9d577e46 O_DIRECTORY is architecture-dependent
https://github.com/upx/upx/issues/902
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
	modified:   stub/src/upxfd_android.c
	modified:   stub/src/upxfd_linux.c
           plus generated .h .map .dump
2025-03-21 10:54:27 -07:00
John Reiser a25c20ee0b M_LZMA with hi parameter bytes confused --ultra-brute
https://github.com/upx/upx/issues/900
	modified:   packhead.cpp
	modified:   p_lx_elf.cpp
2025-03-20 09:48:00 -07:00
John Reiser ff75a462a4 Fighting over .e_shentsize
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
2025-03-18 13:48:19 -07:00
John Reiser e0b6ff1924 More checking in unpack()
https://github.com/upx/upx/issues/898
	modified:   p_lx_elf.cpp
2025-03-18 08:40:08 -07:00
John Reiser 1c5fae74e0 Fix recovery of readlink() when /proc/self/exe is missing
https://github.com/upx/upx/issues/897
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/arm.v4a-linux.elf-fold.S
           plus generated .h
2025-03-16 12:37:57 -07:00
John Reiser 6f650ca16f mips memfd_create() and syscall error handling
https://github.com/upx/upx/issues/895
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
           plus generated .h .dump .map
2025-03-13 08:07:26 -07:00
Markus F.X.J. Oberhumer c2da21ba4e CI updates 2025-03-05 12:13:21 +01:00
John Reiser 903ca50391 Workaround valgrind-3.24.0 botch of 'notrack' on i386
https://github.com/upx/upx/issues/890
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
           plus generated .h .map
2025-03-02 14:30:50 -08:00
John Reiser 70f1ab8cb7 Nice message for ancient Linux lacking memfd_create
... or O_TMPFILE for recovery using /dev/shm
https://github.com/upx/upx/issues/889
	modified:   stub/src/upxfd_linux.c
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
           plus generated  .h  .map  .dump
2025-03-02 11:46:17 -08:00
John Reiser 6998449715 Remove inline syscalls from MIPS stubs
They were a maintenance headache, especially for error handling.
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/include/linux.h
	modified:   stub/src/mips.r3000-expand.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/upxfd_android.c
2025-03-02 11:32:49 -08:00
John Reiser fb0f6c6a00 Escape hatch needs 'notrack' to enter
modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-fold.S
2025-03-02 11:22:05 -08:00
John Reiser dbde75028c Avoid corrupted P_hdr
https://issues.oss-fuzz.com/u/1/issues/398127991
	modified:   p_lx_elf.cpp
2025-03-02 11:12:08 -08:00
John Reiser 90d86ea59e Prevent leak even if corrupted input
https://issues.oss-fuzz.com/u/1/issues/42531955
	modified:   pefile.cpp
2025-02-27 17:10:52 -08:00
John Reiser 64891286ba Unpack: better checking of bounds for DT_HASH
https://issues.oss-fuzz.com/u/1/issues/398075916
	modified:   p_lx_elf.cpp
2025-02-22 07:55:14 -08:00
John Reiser e52a3ceb48 Unpack: Entire ElfXX_Ehdr must be present in de-compressed Ehdr+Phdrs
https://issues.oss-fuzz.com/u/1/issues/397728078
(previous commit: https://issues.oss-fuzz.com/u/1/issues/397500915)
	modified:   p_lx_elf.cpp
2025-02-22 07:55:14 -08:00
John Reiser 8cce9cf641 Detect bad b_info.method
https://issues.oss-fuzz.com/u/1/issues?q=upx
	modified:   p_lx_elf.cpp
	modified:   p_unix.cpp
	modified:   packhead.cpp
	modified:   packhead.h
2025-02-22 07:55:14 -08:00
Markus F.X.J. Oberhumer 896dff9619 src/check: some toolchains are buggy 2025-02-22 06:43:28 +01:00
Markus F.X.J. Oberhumer 84a0347df1 testsuite: update checksums caused by version bump 2025-02-21 00:12:41 +01:00
Markus F.X.J. Oberhumer fc5e44f391 all: post-release version bump 2025-02-20 23:56:24 +01:00
Markus F.X.J. Oberhumer 8bf49aa4f2 all: prepare for release 2025-02-20 16:02:44 +01:00
Markus F.X.J. Oberhumer b8079bb6eb CI updates 2025-02-19 16:45:44 +01:00
John Reiser 5dcad7a387 Mention ELF work
modified:   NEWS
2025-02-18 08:26:30 -08:00
John Reiser 83e5f74b3d Compiler different type checking
modified:   p_lx_elf.cpp
2025-02-17 09:39:55 -08:00
John Reiser 3d402134f5 Better checking of DT_GNU_HASH during de-compression
https://issues.oss-fuzz.com/u/1/issues/396167884
	modified:   p_lx_elf.cpp
2025-02-17 09:14:19 -08:00
John Reiser b8b64a3e0f Fuzz nuisance: wild p_info for de-compression
https://issues.oss-fuzz.com/u/1/issues/383200048
	modified:   p_lx_elf.cpp
2025-02-17 08:26:17 -08:00
John Reiser c0bf7bf9ab Old powerpc* kernels lack MFD_EXEC
For example: Debian 3.16.43-2+deb8u5 (2017-09-19)
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/Makefile
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64-linux.elf-entry.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
           plus generated .h, .dump, .map
2025-02-16 15:33:58 -08:00
John Reiser 0144f81c28 Cleanup stub for arm64 shared library
modified:   stub/arm64-linux.elf-so_entry.h
	modified:   stub/src/arm64-linux.elf-so_entry.S
2025-02-16 08:41:50 -08:00
John Reiser 78f4959521 Fix de-compression of ELF shared libraries
Reset ph.method on each b_info.b_method.
Use file_image[] as ReadOnly, subsuming fi->seek()+read().
Use lowmem[0, +xct_off) for changing values.
Work on un_DT_INIT().
https://github.com/upx/upx/issues/882

	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2025-02-15 19:35:21 -08:00
John Reiser eff1ef2d70 Fix amd64 shared libraries
Inspired by https://github.com/upx/upx/issues/880
(https://github.com/microsoft/mimalloc.git on Linux)
but still need test case.
	modified:   p_lx_elf.cpp
	modified:   stub/amd64-linux.elf-so_entry.h
	modified:   stub/src/amd64-linux.elf-so_entry.S
2025-02-13 17:22:37 -08:00
John Reiser 782b07c752 PPC64 check ehdri.e_ident[EI_DATA], not elfout
modified:   p_lx_elf.cpp
2025-02-12 08:56:18 -08:00
John Reiser bd67677389 Honor dos_header_t.e_cparhdr for small header
... and cleanup PackDjgpp2::readFileHeader()
https://github.com/upx/upx/issues/881

	modified:   p_djgpp2.cpp
	modified:   p_djgpp2.h
2025-02-11 10:29:53 -08:00
John Reiser 8c9e04daaf Propagate .e_ident[EI_ABIVERSION]
Linux on bare metal (and explicit qemu) seems not to care,
but qemu-user-binfmt gives ENOEXEC (Exec format error)
        https://github.com/upx/upx/issues/876
2025-02-07 19:24:46 -08:00
John Reiser bddc05e787 Fix elf_lookup() defenses against fuzzed DT_HASH
modified:   p_lx_elf.cpp
2025-02-01 13:22:26 -08:00
John Reiser a49d023bd0 Detect too-short Mach_command, also be careful in recovery
fuzzing from leon.weiss AT @ruhr-uni-bochum.de
https://github.com/upx/upx/issues/875
https://github.com/upx/upx/issues/874
	modified:   p_mach.cpp
2025-01-31 11:34:48 -08:00
John Reiser 7b06ba0b78 Detect empty DT_STRTAB
https://github.com/upx/upx/issues/872
fuzzing from leon.weiss AT @ruhr-uni-bochum.de
	modified:   p_lx_elf.cpp
2025-01-31 11:32:48 -08:00
John Reiser 344b73dab0 invert_pt_dynamic defends against missing DT_STRTAB or DT_STRSIZ
https://github.com/upx/upx/issues/872
fuzzing from leon.weiss AT @ruhr-uni-bochum.de
	modified:   p_lx_elf.cpp
2025-01-30 11:42:09 -08:00
John Reiser 0870514194 elf_lookup must defend against bad chain in hash table
https://github.com/upx/upx/issues/871
fuzzing from leon.weiss AT @ruhr-uni-bochum.de
2025-01-30 10:56:45 -08:00
Markus F.X.J. Oberhumer 0a61ffea3a submodules: update for new versions 2025-01-30 00:05:15 +01:00
Markus F.X.J. Oberhumer fbc650791d CI updates 2025-01-29 22:19:21 +01:00
Markus F.X.J. Oberhumer 4b41aa1226 CI updates 2025-01-29 16:11:03 +01:00
Markus F.X.J. Oberhumer 3fd68d3ec6 CI updates 2025-01-27 18:11:44 +01:00
John Reiser d41ceb0d31 ARM64: move Psync closer to PAGE_MASK
and use 'bic' instead of 'and'
	modified:   stub/arm64-linux.elf-so_fold.h
	modified:   stub/src/arm64-linux.elf-so_fold.S
2025-01-26 18:43:14 -08:00
John Reiser aee970e80b Allow empty .rsrc Section in PE file
https://github.com/upx/upx/issues/869
	modified:   pefile.cpp
2025-01-24 07:45:05 -08:00
Markus F.X.J. Oberhumer ef8a24ba53 CI updates. Closes #862. 2025-01-21 21:16:01 +01:00
Markus F.X.J. Oberhumer 2edf91d315 testsuite: update checksums caused by version bump 2025-01-17 22:06:55 +01:00
Markus F.X.J. Oberhumer 9fe377b288 all: version bump 2025-01-17 21:50:38 +01:00
Markus F.X.J. Oberhumer 996ca8d17d all: welcome 2025 2025-01-17 21:18:55 +01:00
Markus F.X.J. Oberhumer b356595eb5 CI updates 2025-01-17 21:15:43 +01:00
Markus F.X.J. Oberhumer e4668e5328 CI updates 2025-01-08 12:57:52 +01:00
John Reiser a846e483be clang-format uglifies again
modified:   p_w64pe_amd64.cpp
2025-01-02 12:05:59 -08:00
John Reiser f6e3df69eb stub/amd64-win64.pe.h matches upx-v4.2.4
so that anti-virus checkers of apps for 64-bit Windows that are newly-
compressed by upx should not complain about new matches with malware.
This costs a few bytes and a small fraction of cycles in NRV2
de-compressors, but is considered to be a tolerable concession
to the cesspool environment of software for Microsoft Windows.
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_w64pe_amd64.cpp   see code comments
	modified:   stub/amd64-win64.pe.h
	modified:   stub/src/arch/amd64/lzma_d.S   see code comments
	modified:   stub/src/arch/amd64/nrv2b_d.S
	modified:   stub/src/arch/amd64/nrv2d_d.S
	modified:   stub/src/arch/amd64/nrv2e_d.S
	modified:   stub/tmp/amd64-win64.pe.bin.dump
2025-01-02 11:47:34 -08:00
John Reiser 1a6c1f0589 Fix unpackExtent() of non-compressible extent (PT_LOAD)
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/amd64-darwin.macho-upxmain.c
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/amd64-linux.elf-so_entry.S
	modified:   stub/src/amd64-linux.elf-so_main.c
	modified:   stub/src/i386-bsd.elf-main.c
	modified:   stub/src/i386-darwin.macho-main.c
	modified:   stub/src/i386-darwin.macho-upxmain.c
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/i386-linux.elf-so_main.c
	modified:   stub/src/i386-linux.elf.interp-main.c
	modified:   stub/src/i386-linux.elf.shell-main.c
	modified:   stub/src/i386-openbsd.elf-main.c
	modified:   stub/src/powerpc-darwin.macho-main.c
	modified:   stub/src/powerpc-darwin.macho-upxmain.c
	modified:   stub/src/powerpc64-darwin.macho-main.c
            plus generated *.h  *.map  *.dump
2024-12-30 16:49:31 -08:00
John Reiser e3e5d8a3a5 Try again for Android Elfxx_Shdr
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2024-12-23 11:20:26 -08:00
John Reiser 505f6b7373 Remove PROT_WRITE from de-compressed folded code.
Safer; required for SELinux Enforcing mode;
but inhibits breakpoint debugging.
	modified:   stub/amd64-linux.elf-entry.h
	modified:   stub/mips.r3000-linux.elf-entry.h
	modified:   stub/mipsel.r3000-linux.elf-entry.h
	modified:   stub/powerpc-linux.elf-entry.h
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-entry.S
2024-12-23 10:52:07 -08:00
John Reiser 7d907d9d65 is_asl handles per-file opt->o_unix.android_shlib
Also slide_sh_offset() handles so_slide.
TODO: if asl_delta, then relocate sh_offset that is above xct_off.
PT_DYNAMIC.p_offset and {.dynamic}.sh_offset must match; etc.

	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2024-12-17 17:17:24 -08:00
John Reiser d00ba4b465 Forgotten file
new file:   src/amd64-linux.elf-so_entry.lds
2024-12-12 11:13:12 -08:00
John Reiser d4deb2a100 Psync: msync demands page-aligned first argument
modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   src/stub/src/amd64-linux.elf-fold.S
	modified:   src/stub/src/amd64-linux.elf-main2.c
	modified:   src/stub/src/amd64-linux.elf-so_fold.S
	modified:   src/stub/src/amd64-linux.elf-so_main.c
	modified:   src/stub/src/arm.v4a-linux.elf-entry.S
	modified:   src/stub/src/arm.v4a-linux.elf-fold.S
	modified:   src/stub/src/arm.v4a-linux.elf-so_fold.S
	modified:   src/stub/src/arm64-linux.elf-fold.S
	modified:   src/stub/src/arm64-linux.elf-so_fold.S
	modified:   src/stub/src/i386-linux.elf-fold.S
	modified:   src/stub/src/i386-linux.elf-main2.c
	modified:   src/stub/src/i386-linux.elf-so_entry.S
	modified:   src/stub/src/i386-linux.elf-so_fold.S
	modified:   src/stub/src/i386-linux.elf-so_main.c
	modified:   src/stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   src/stub/src/powerpc-linux.elf-fold.S
	modified:   src/stub/src/powerpc64-linux.elf-fold.S
            plus stubs *.h *.dump *.map
2024-12-12 10:50:30 -08:00
John Reiser 5999b0a959 Unused get_page_mask but satisfies external for upxfd_*.c
modified:   stub/src/i386-linux.elf-entry.S
2024-12-10 17:10:27 -08:00
John Reiser e2f1e6697a Stubs for shared libraries on amd64-linux.elf and arm64-linux.elf
modified:   stub/Makefile
	modified:   stub/src/amd64-linux.elf-so_entry.S
	modified:   stub/src/amd64-linux.elf-so_fold.S
	modified:   stub/src/arm64-linux.elf-so_entry.S
	modified:   stub/src/arm64-linux.elf-so_fold.S
	modified:   stub/src/upxfd_linux.c
2024-12-10 16:49:35 -08:00
Markus F.X.J. Oberhumer baee96347d CI updates 2024-12-11 07:54:48 +01:00
John Reiser f60d8f6d18 Fix MIPS stubs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/Makefile
	modified:   stub/mips.r3000-linux.elf-entry.h
	modified:   stub/mipsel.r3000-linux.elf-entry.h
	modified:   stub/tmp/mips.r3000-linux.elf-entry.bin.dump
	modified:   stub/tmp/mips.r3000-linux.elf-fold.map
	modified:   stub/tmp/mipsel.r3000-linux.elf-entry.bin.dump
	modified:   stub/tmp/mipsel.r3000-linux.elf-fold.map
2024-12-09 14:26:00 -08:00
John Reiser d3300e9564 Sync stubs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/mips.r3000-linux.elf-entry.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-entry.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/tmp/arm.v4a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v5a-linux.elf-entry.bin.dump
	modified:   stub/tmp/armeb.v4a-linux.elf-entry.bin.dump
2024-12-09 13:33:21 -08:00
John Reiser 877390a2ba FIx MIPS stubs
modified:   stub/Makefile
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/upxfd_android.c
	modified:   stub/src/upxfd_linux.c
2024-12-09 13:26:22 -08:00
John Reiser 5afe2af365 EINVAL whitespace
modified:   src/stub/src/i386-linux.elf-so_main.c
2024-12-07 09:46:42 -08:00
John Reiser 5028d559c5 msync for *-so_fold.S
Android 14  returnes -EINVAL but can be ignored
	modified:   stub/arm64-linux.elf-so_fold.h
	modified:   stub/amd64-linux.elf-so_fold.h
	modified:   stub/arm.v4a-linux.elf-so_fold.h
	modified:   stub/arm.v5a-linux.elf-so_fold.h
	modified:   stub/i386-linux.elf-so_fold.h
	modified:   stub/src/amd64-linux.elf-so_main.c
	modified:   stub/src/i386-linux.elf-so_main.c
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/arm.v4a-linux.elf-so_fold.S
2024-12-07 09:39:45 -08:00
John Reiser deda4f1bae Sync stubs
modified:   stub/arm64-linux.elf-so_fold.h
	modified:   stub/amd64-linux.elf-so_fold.h
	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v4a-linux.elf-fold.h
	modified:   stub/arm.v4a-linux.elf-so_entry.h
	modified:   stub/arm.v4a-linux.elf-so_fold.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-fold.h
	modified:   stub/arm.v5a-linux.elf-so_entry.h
	modified:   stub/arm.v5a-linux.elf-so_fold.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-fold.h
	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/i386-linux.elf-so_entry.h
	modified:   stub/i386-linux.elf-so_fold.h
            plus *.dump *.map
2024-12-07 08:56:34 -08:00
John Reiser 927a9d10a7 zig -musleabihf default -mdouble-float conflicts -msoft-float
modified:   .github/workflows/ci.yml
2024-12-07 08:53:30 -08:00
John Reiser ad96cee14c Unify prep_SELinux and upx_so_main
Also va_top, not hi_offset
	modified:   stub/src/amd64-linux.elf-so_main.c
	modified:   stub/src/i386-linux.elf-so_main.c
	modified:   stub/src/upxfd_android.c
2024-12-07 08:43:04 -08:00
John Reiser f95bb4953f CI updates: target ".2.3.4" invalid; "*-linux-musl" appends "eabi"
modified:   ci.yml
2024-12-05 11:30:05 -08:00
John Reiser 8c594de432 Sync stubs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v4a-linux.elf-fold.h
	modified:   stub/arm.v4a-linux.elf-so_entry.h
	modified:   stub/arm.v4a-linux.elf-so_fold.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-fold.h
	modified:   stub/arm.v5a-linux.elf-so_entry.h
	modified:   stub/arm.v5a-linux.elf-so_fold.h
	modified:   stub/arm64-linux.elf-so_entry.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-fold.h
	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/i386-linux.elf-so_entry.h
	modified:   stub/i386-linux.elf-so_fold.h
	modified:   stub/mips.r3000-linux.elf-entry.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-entry.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/powerpc-linux.elf-fold.h
            plus *.dump *.map
2024-12-05 11:08:41 -08:00
John Reiser 330ac2443c help_umf.S for MIPS and PPC
modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/mips.r3000-linux.elf-help_umf.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-help_umf.S
	new file:   stub/src/powerpc-linux.elf-help_umf.S
2024-12-05 11:06:09 -08:00
John Reiser ebe6272ac7 whitespace
modified:   stub/src/arm.v4a-linux.elf-so_fold.S
2024-12-05 08:25:02 -08:00
John Reiser 982e732b74 Allow re-ordering of functions in upxfd_android.c and upxfd_linux.c
Compiler has a mind of its own.
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	new file:   stub/src/amd64-linux.elf-help_umf.S
	modified:   stub/src/arm.v4a-expand.S
	new file:   stub/src/arm.v4a-linux.elf-help_umf.S
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/arm.v4a-linux.elf-so_fold.S
	new file:   stub/src/arm.v5a-linux.elf-help_umf.S
	new file:   stub/src/arm64-linux.elf-help_umf.S
	modified:   stub/src/arm64-linux.elf-so_entry.S
	new file:   stub/src/armeb.v4a-linux.elf-help_umf.S
	new file:   stub/src/i386-linux.elf-help_umf.S
	modified:   stub/src/i386-linux.elf-so_main.c
	new file:   stub/src/mips.r3000-linux.elf-help_umf.S
	new file:   stub/src/mipsel.r3000-linux.elf-help_umf.S
	modified:   stub/src/upxfd_android.c
2024-12-04 17:00:37 -08:00
John Reiser 27de5f42bb Sync stubs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/amd64-linux.elf-entry.h
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/amd64-linux.elf-so_entry.h
	modified:   stub/amd64-linux.elf-so_fold.h
	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v4a-linux.elf-fold.h
	modified:   stub/arm.v4a-linux.elf-so_entry.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-fold.h
	modified:   stub/arm.v5a-linux.elf-so_entry.h
	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/arm64-linux.elf-so_fold.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-fold.h
	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/mips.r3000-linux.elf-entry.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-entry.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
            also *.dump, *.map
2024-12-03 11:52:13 -08:00
John Reiser 37dff58289 powerpc-linux.elf-entry.S does not need UMF_LINUX
... because it calls memfd_create directly, not via upx_mmap_and_fd.
Perhaps MIPS, foo?
	modified:   p_lx_elf.cpp
2024-12-03 11:50:21 -08:00
John Reiser fc9d90c231 Revamp building stubs for MIPS
modified:   stub/Makefile
2024-12-03 10:37:19 -08:00
John Reiser 68b31d31c3 msync() and UMF_LINUX fiddling
modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-so_fold.S
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-entry.lds
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/arm64-linux.elf-so_fold.S
	modified:   stub/src/mips.r3000-linux.elf-entry.lds
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.lds
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/upxfd_linux.c
2024-12-03 10:36:14 -08:00
John Reiser f7f08be312 get_te64_32() fetches 64 bits, checks and returns 32
modified:   packer.h
2024-12-03 10:28:01 -08:00
John Reiser d14901548a Unique label sysgo_incl; fix #define that might capture trailing '//'
modified:   stub/src/include/linux.h
2024-12-03 10:21:07 -08:00
John Reiser 6ebdf92d40 Update ZIG version; fix extra leading space
Thomas Legris spotted the syntax error of extra space.
	modified:   .github/workflows/ci.yml
2024-12-03 10:17:36 -08:00
John Reiser abced6720b clang-format {silly)
modified:   packer.h
2024-12-02 08:08:51 -08:00
John Reiser f4604db164 Stub msync() on PF_X before munmap()
modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/include/linux.h
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
	modified:   stub/src/upxfd_android.c
	modified:   stub/src/upxfd_linux.c
2024-11-30 13:58:40 -08:00
John Reiser 8327c390cf Stack 0x10 aligned at all times
modified:   stub/src/arm64-expand.S
2024-11-30 13:57:46 -08:00
John Reiser bd251c0dbd Stub for 64-bit shlib
modified:   stub/Makefile
	modified:   stub/src/amd64-expand.S
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-so_entry.S
	modified:   stub/src/amd64-linux.elf-so_fold.S
	modified:   stub/src/amd64-linux.elf-so_main.c
	modified:   stub/src/arm64-expand.S
	modified:   stub/src/upxfd_linux.c
2024-11-28 19:10:27 -08:00
John Reiser d04209d30f Unify 32-bit and 64-bit ::buildLinuxLoader
modified:   p_lx_elf.cpp
2024-11-28 19:09:46 -08:00
John Reiser 8782778eb3 stub *-linux.elf-entry.S often must define label upx_mmap_and_fd
modified:   p_lx_elf.cpp
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/i386-linux.elf-entry.S
2024-11-26 19:43:14 -08:00
John Reiser c8515ae862 Unify PackLinuxElf64::pack2_shlib* with 32-bit
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2024-11-26 16:44:35 -08:00
John Reiser a2fa417af9 Unify 64-bit upx_main() stub for shlib with 32-bit i386
modified:   stub/src/amd64-linux.elf-so_main.c
2024-11-26 16:43:02 -08:00
John Reiser 93f420939e ElfW()
modified:   src/i386-linux.elf-so_main.c
2024-11-25 11:52:43 -08:00
John Reiser 88cd02d750 get_te64_32() gets 4-bit value, then detects 32-bit overflow
modified:   packer.h
2024-11-25 10:45:54 -08:00
John Reiser a35e50c02a ZIG_DIST_VERSION: 0.14.0-dev.2271+f845fa04a
modified:   ci.yml
2024-11-21 13:06:06 -08:00
John Reiser 566c1eebd2 sync stubs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/arm.v4a-linux.elf-fold.h
	modified:   stub/arm.v5a-linux.elf-fold.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/armeb.v4a-linux.elf-fold.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
	modified:   stub/tmp/arm.v4a-linux.elf-fold.map
	modified:   stub/tmp/arm.v5a-linux.elf-fold.map
	modified:   stub/tmp/arm64-linux.elf-fold.map
	modified:   stub/tmp/armeb.v4a-linux.elf-fold.map
	modified:   stub/tmp/mips.r3000-linux.elf-fold.map
	modified:   stub/tmp/mipsel.r3000-linux.elf-fold.map
	modified:   stub/tmp/powerpc-linux.elf-fold.map
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2024-11-21 11:20:32 -08:00
John Reiser 65c3195b39 Cleanup stub for mips and powerpc
modified:   stub/Makefile
	modified:   stub/src/powerpc-expand.S
	modified:   stub/src/powerpc-linux.elf-fold.S
2024-11-20 15:28:41 -08:00
John Reiser 76b0b4ce9c Fix mips stub for ELF2 main program
modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/mips.r3000-expand.S
	modified:   stub/src/upxfd_linux.c
2024-11-20 15:02:32 -08:00
John Reiser 02b9ac9764 Name it upx_main2() for clarity
modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/powerpc64-linux.elf-fold.S
2024-11-20 15:00:11 -08:00
John Reiser 17b94cdfe5 Cleanup remaining *.lds linker scripts for stubs
modified:   stub/src/arm64-linux.elf-fold.lds
	modified:   stub/src/mips.r3000-linux.elf-fold.lds
	modified:   stub/src/mipsel.r3000-linux.elf-fold.lds
	modified:   stub/src/powerpc-linux.elf-fold.lds
	modified:   stub/src/powerpc64-linux.elf-fold.lds
	modified:   stub/src/powerpc64le-linux.elf-fold.lds
2024-11-20 14:52:22 -08:00
John Reiser 83166e21a5 PackLinuxElf64::unpack forgot some get_te*
Also use is_LOAD where ever possible.
	modified:   p_lx_elf.cpp

	modified:   ../NEWS
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2024-11-20 07:46:24 -08:00
John Reiser b4ea89f9d6 check-whitespace, clang-format
modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   stub/src/i386-linux.elf-so_entry.S
2024-11-19 09:13:44 -08:00
John Reiser 00706f0ccc Sync stubs ("make testsuite" passes)
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v4a-linux.elf-fold.h
	modified:   stub/arm.v4a-linux.elf-so_entry.h
	modified:   stub/arm.v4a-linux.elf-so_fold.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-fold.h
	modified:   stub/arm.v5a-linux.elf-so_entry.h
	modified:   stub/arm.v5a-linux.elf-so_fold.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-fold.h
	modified:   stub/i386-bsd.elf-fold.h
	modified:   stub/i386-bsd.elf.execve-fold.h
	modified:   stub/i386-darwin.macho-entry.h
	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/i386-linux.elf-so_entry.h
	modified:   stub/i386-linux.elf-so_fold.h
	modified:   stub/i386-linux.elf.execve-fold.h
	modified:   stub/i386-linux.elf.interp-fold.h
	modified:   stub/i386-linux.elf.shell-fold.h
	modified:   stub/i386-netbsd.elf-fold.h
	modified:   stub/i386-openbsd.elf-fold.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	deleted:    stub/src/upxfd_create.c
	modified:   stub/tmp/amd64-linux.elf-fold.map
	modified:   stub/tmp/arm.v4a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v4a-linux.elf-fold.map
	modified:   stub/tmp/arm.v5a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v5a-linux.elf-fold.map
	modified:   stub/tmp/arm64-linux.elf-fold.map
	modified:   stub/tmp/armeb.v4a-linux.elf-entry.bin.dump
	modified:   stub/tmp/armeb.v4a-linux.elf-fold.map
	modified:   stub/tmp/i386-bsd.elf-fold.map
	modified:   stub/tmp/i386-bsd.elf.execve-fold.map
	modified:   stub/tmp/i386-darwin.macho-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf-fold.map
	modified:   stub/tmp/i386-linux.elf.execve-fold.map
	modified:   stub/tmp/i386-linux.elf.interp-fold.map
	modified:   stub/tmp/i386-linux.elf.shell-fold.map
	modified:   stub/tmp/i386-netbsd.elf-fold.map
	modified:   stub/tmp/i386-openbsd.elf-fold.map
	modified:   stub/tmp/mips.r3000-linux.elf-fold.map
	modified:   stub/tmp/mipsel.r3000-linux.elf-fold.map
	modified:   stub/tmp/powerpc-linux.elf-fold.map
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2024-11-19 08:55:31 -08:00
John Reiser 3798dde3aa Fix stubs in arm,mips,powerpc for upx_mmap_and_fd
modified:   stub/Makefile
	modified:   stub/src/arm.v4a-expand.S
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/mips.r3000-expand.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/upxfd_linux.c
2024-11-19 08:44:48 -08:00
John Reiser 5bf2258505 filter strategy option to build no loader at all
modified:   packer.cpp
2024-11-18 16:17:37 -08:00
John Reiser 33b9c68677 upx_fd_android.c
modified:   stub/src/upxfd_android.c
2024-11-18 16:15:06 -08:00
John Reiser 58d9b00a0a Revamp 32-bit stub/src/*-linux.elf-so_main.c
... including better error checking of system calls
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-so_entry.S
	modified:   stub/src/i386-linux.elf-so_fold.S
	modified:   stub/src/i386-linux.elf-so_main.c
2024-11-18 16:12:44 -08:00
John Reiser 7ef018fed0 Option --android-oid for Android < 10
modified:   main.cpp
	modified:   options.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.h
2024-11-18 16:06:45 -08:00
John Reiser 3d9fc7ab53 Clarify call to upx_compress(); NFC
modified:   p_unix.cpp
2024-11-18 16:04:48 -08:00
John Reiser 3d6b2e4617 Cleanup stub/*.lds linker scripts
modified:   Makefile
	modified:   src/amd64-linux.elf-fold.lds
	modified:   src/amd64-linux.elf-so_fold.lds
	modified:   src/arm.v4a-linux.elf-entry.lds
	modified:   src/arm.v4a-linux.elf-fold.lds
	modified:   src/arm.v4a-linux.elf-so_entry.lds
	modified:   src/arm.v4a-linux.elf-so_fold.lds
	modified:   src/arm.v5a-linux.elf-entry.lds
	modified:   src/arm.v5a-linux.elf-fold.lds
	modified:   src/arm.v5a-linux.elf-so_entry.lds
	modified:   src/arm.v5a-linux.elf-so_fold.lds
	modified:   src/arm64-linux.elf-fold.lds
	modified:   src/arm64-linux.elf-so_fold.lds
	modified:   src/armeb.v4a-linux.elf-entry.lds
	modified:   src/armeb.v4a-linux.elf-fold.lds
	modified:   src/i386-bsd.elf-fold.lds
	modified:   src/i386-linux.elf-fold.lds
	modified:   src/i386-linux.elf-so_entry.lds
	modified:   src/i386-linux.elf-so_fold.lds
	modified:   src/i386-linux.elf.execve-fold.lds
	modified:   src/i386-linux.elf.interp-fold.lds
	modified:   src/i386-linux.elf.shell-fold.lds
	modified:   src/mips.r3000-linux.elf-fold.lds
	modified:   src/mipsel.r3000-linux.elf-fold.lds
	modified:   src/powerpc-linux.elf-fold.lds
	modified:   src/powerpc64-linux.elf-fold.lds
	modified:   src/powerpc64le-linux.elf-fold.lds
	new file:   src/upxfd_linux.c
2024-11-18 16:00:36 -08:00
John Reiser 886e325cbf EXP_TAIL goes after de-compressors, and before UMF_LINUX
modified:   p_lx_elf.cpp
	modified:   stub/src/i386-expand.S
2024-11-14 19:22:28 -08:00
John Reiser 60bdffee84 make_hatch() has uniform calling sequence
... so factor out the calls to make_hatch
	modified:   src/i386-linux.elf-so_main.c
2024-11-14 11:19:10 -08:00
John Reiser a9dc43f7fb PackLinuxElf32::generateElfHdr, PackLinuxElf64::buildLinuxLoader
modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
2024-10-26 10:53:28 -07:00
John Reiser 0cc0e51d5d PackLinuxElf64::canPack_Shdr
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2024-10-26 10:02:14 -07:00
John Reiser 14d75b222f -DWINDOWS_BACK=1 for PE
modified:   stub/Makefile
2024-10-26 09:52:12 -07:00
John Reiser b10d2b7365 lodsb is OK to use in branch filter
modified:   stub/src/arch/i386/bxx.S
2024-10-26 09:50:38 -07:00
John Reiser 8aa3679323 upx_mmap_and_fd
modified:   stub/src/upxfd_create.c
2024-10-26 09:49:26 -07:00
John Reiser 3403b87cb7 More Control Flow Integrity (Intel)
More ENDBRxx for CALL *%RDX for 'getbit'.
amd64: LEA xxx(%rip),%reg and STRCON section,
    instead of CALL; .asciz "..."; POP %reg
(Not for PE due to WINDOWS_BACK binary compatibility.)
i386 string constants still use call-.asciz-pop because no (%rip)
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/amd64-linux.elf-so_entry.S
	modified:   stub/src/amd64-linux.shlib-init.S
	modified:   stub/src/amd64-win64.pe.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-so_entry.S
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.map *.dump
2024-09-20 14:48:30 -07:00
John Reiser d55fdf2205 ZIG_DIST_VERSION of 2024-09-17
also https://github.com/upx/upx/issues/847

	modified:   ../.github/workflows/ci.yml
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/i386-darwin.macho-entry.S
           plus generated *.h *.map *.dump
2024-09-17 01:55:08 -07:00
John Reiser 7cb3f40dab WIP: variable page size for xfind_pages(); debug arm32 Android shlib
modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/i386-linux.elf-main2.c
           plus generated *.h *.dump *.map
2024-08-29 16:55:18 -07:00
John Reiser 65c362efce MSVC lacks stpcpy()
modified:   p_lx_elf.cpp
2024-08-26 18:59:55 -07:00
John Reiser 8065eebca3 --android-shlib for arm32 and i386
... including work-around if no memfd_create() on early Android 32-bit
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/arm.v4a-linux.elf-so_fold.S
	modified:   stub/src/i386-linux.elf-so_main.c
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.dump *.map
2024-08-25 15:16:29 -07:00
John Reiser 7f062c7ca5 Variable page size: spread the word by using 'page_' instead of 'PAGE_'
modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64-linux.elf-entry.S
           plus genereated *.h *.map
2024-08-25 15:16:29 -07:00
John Reiser 0adad4a053 ELF2 after successful ANDROID_TEST of upxfd_android.c on i386 and arm32
modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.dump *.map
2024-08-25 15:16:29 -07:00
John Reiser cb39e6e0b8 ELF2: stub for i386 shared library
WIP: stub is debugged, but compressed input needs work
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/i386-linux.elf-so_entry.S
	modified:   stub/src/i386-linux.elf-so_fold.S
	modified:   stub/src/i386-linux.elf-so_main.c
	modified:   stub/src/include/linux.h
           plus generated *.h *.dump
2024-08-25 15:16:29 -07:00
John Reiser 94eebc3ee5 ELF2: arm32 shared libraries; runs on Android 14 under TermUX
NYI: complex DT_INIT (R_RELR, etc.)
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   stub/src/arm.v4a-expand.S
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/arm.v4a-linux.elf-so_fold.S
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/i386-linux.elf-so_main.c
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser 5d5f4d1765 Elf2: Android on ARM 64-bit and 32-bit main program runs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser ed0665407a More: prefer movzbl over movb fetch to register
Avoids hardware failure of writing 0x00 instead of the fetched byte.
1 cycle faster, 1 byte larger (but often recouped later when OR of 32-bits).
Avoid changing win*pe.S for now.

	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/amd64-darwin.dylib-entry.S
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-expand.S
	modified:   stub/src/amd64-linux.shlib-init.S
	modified:   stub/src/arch/amd64/nrv2b_d.S
	modified:   stub/src/arch/amd64/nrv2d_d.S
	modified:   stub/src/arch/amd64/nrv2e_d.S
	modified:   stub/src/arch/i386/nrv2b_d32-easy.S
	modified:   stub/src/i386-darwin.macho-entry.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser 3869a67180 Intel CET (Control-flow Enforcement Technology)
{endbr64, endbr32} at target of computed jmp/call; 'notrack' at source
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arch/amd64/macros.S
	modified:   stub/src/arch/i386/macros.S
	modified:   stub/src/i386-expand.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main2.c
2024-08-25 15:16:29 -07:00
John Reiser 7e75491e88 Macho" begin catch-up to ELF by defining labels eof_n2*
modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/amd64-darwin.macho-entry.h
	modified:   stub/tmp/amd64-darwin.macho-entry.bin.dump
2024-08-25 15:16:29 -07:00
John Reiser ca33d66816 Sync stub checksums; and i386-linux and arm64-linux generated files
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
2024-08-25 15:16:29 -07:00
John Reiser 055e3db80a i386-linux stub: Use current __NR_uname; pacify memcheck
modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
2024-08-25 15:16:29 -07:00
John Reiser 620ddf1228 arm64: typo in daisy-chain when selecting de-compression method
modified:   stub/src/arm64-expand.S
2024-08-25 15:16:29 -07:00
John Reiser d71fe3eda0 Sync stub checksums (and generated files)
Many *.h, *.dump, *.map
2024-08-25 15:16:29 -07:00
John Reiser bff5049a98 developer documentation
modified:   p_lx_elf.cpp
2024-08-25 15:16:29 -07:00
John Reiser 536b2c2475 i386 LzmaDecode (lzma_d_c*.S) compiled code exited not at the end
... so the build recipe required acrobatics to make it "fall through"
	modified:   stub/src/arch/i386/Makefile.extra
	new file:   stub/src/arch/i386/fall-through.sed
	modified:   stub/src/arch/i386/lzma-multi_d.S
	modified:   stub/src/arch/i386/lzma_d_cf.S
	modified:   stub/src/arch/i386/lzma_d_cs.S
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/i386-expand.S
2024-08-25 15:16:29 -07:00
John Reiser 7a3033c150 MFD_EXEC is unknown in older Ubuntu linux
modified:   stub/src/include/linux.h
	modified:   stub/src/upxfd_android.c
2024-08-25 15:16:29 -07:00
John Reiser 05db054fb9 developer documentation
modified:   stub/src/i386-linux.elf-so_fold.S
2024-08-25 15:16:29 -07:00
John Reiser 8aa445e2fc i386 stub: prefer movzbl over movb fetch [stragglers]
modified:   stub/src/arch/i386/nrv2d_d32-easy.S
	modified:   stub/src/arch/i386/nrv2e_d32-easy.S
2024-08-25 15:16:29 -07:00
John Reiser 3658136b82 whitespace
modified:   stub/src/powerpc64-linux.elf-fold.S
2024-08-25 15:16:29 -07:00
John Reiser 64419ca4f4 Sync checksums from testsuite (i386 and powerpc64le)
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
2024-08-25 15:16:29 -07:00
John Reiser 913cddec61 Generated files
modified:   stub/i386-darwin.macho-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/i386-linux.elf-so_fold.h
	modified:   stub/tmp/i386-darwin.macho-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf-fold.map
2024-08-25 15:16:29 -07:00
John Reiser 25e6a31004 i386 stub: prefer movzbl over movb fetch
32-bit mode on x86_64 hardware can fail movb fetch to register
by writing 0x00 randomly instead of the fetched byte.
Note that most CPU can write only 32 or 64 bits to the register file,
so writing just 8 or 16 bits incurs a 1-cycle penalty in order to
form 32 bits by Read-Modify-Write of the destination register.
	modified:   stub/src/arch/i386/nrv2b_d32-easy.S
	modified:   stub/src/i386-expand.S
2024-08-25 15:16:29 -07:00
John Reiser 3d58035b41 i386 stub filters 0x49 and 0x46 really are different (but similar!)
modified:   filter/filter_impl.cpp
	modified:   p_lx_elf.cpp
	modified:   stub/src/arch/i386/bxx.S
2024-08-25 15:16:29 -07:00
John Reiser b94a150685 PowerPC64 stub: fix register assignments
modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/src/powerpc64-linux.elf-entry.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
2024-08-25 15:16:29 -07:00
John Reiser 22717c15af sync checksums after podman rebuild
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
2024-08-25 15:16:29 -07:00
John Reiser cb07fc2abc podman stubs rebuild
Looks like all differences are in generated *.h *.map *.dump .
	modified:   stub/amd64-linux.kernel.vmlinux.h
	modified:   stub/i386-bsd.elf-entry.h
	modified:   stub/i386-bsd.elf.execve-entry.h
	modified:   stub/i386-darwin.dylib-entry.h
	modified:   stub/i386-darwin.macho-entry.h
	modified:   stub/i386-dos32.djgpp2.h
	modified:   stub/i386-dos32.tmt.h
	modified:   stub/i386-dos32.watcom.le.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/i386-linux.elf-so_fold.h
	modified:   stub/i386-linux.elf.execve-entry.h
	modified:   stub/i386-linux.elf.interp-entry.h
	modified:   stub/i386-linux.elf.shell-entry.h
	modified:   stub/i386-linux.kernel.vmlinux.h
	modified:   stub/i386-linux.kernel.vmlinuz.h
	modified:   stub/i386-linux.shlib-init.h
	modified:   stub/i386-netbsd.elf-entry.h
	modified:   stub/i386-win32.pe.h
	modified:   stub/src/arch/i386/lzma_d_cf.S
	modified:   stub/src/arch/i386/lzma_d_cs.S
	modified:   stub/tmp/amd64-linux.kernel.vmlinux.bin.dump
	modified:   stub/tmp/i386-bsd.elf-entry.bin.dump
	modified:   stub/tmp/i386-bsd.elf.execve-entry.bin.dump
	modified:   stub/tmp/i386-darwin.dylib-entry.bin.dump
	modified:   stub/tmp/i386-darwin.macho-entry.bin.dump
	modified:   stub/tmp/i386-dos32.djgpp2.bin.dump
	modified:   stub/tmp/i386-dos32.tmt.bin.dump
	modified:   stub/tmp/i386-dos32.watcom.le.bin.dump
	modified:   stub/tmp/i386-linux.elf-fold.map
	modified:   stub/tmp/i386-linux.elf.execve-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf.interp-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf.shell-entry.bin.dump
	modified:   stub/tmp/i386-linux.kernel.vmlinux.bin.dump
	modified:   stub/tmp/i386-linux.kernel.vmlinuz.bin.dump
	modified:   stub/tmp/i386-linux.shlib-init.bin.dump
	modified:   stub/tmp/i386-netbsd.elf-entry.bin.dump
	modified:   stub/tmp/i386-win32.pe.bin.dump
2024-08-25 15:16:29 -07:00
John Reiser ea2a190bd1 ELF2 main programs pass src/testsuite and upx-testsuite-v2
Decompressing lzma required many adjustments.
Backwards compatibility probably is broken for
    stub/amd64-win64.pe.h
    stub/arm64-win64.pe.h
Also: shared libraries need memfd_create.
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/scripts/xstrip.py
	modified:   stub/src/amd64-expand.S
	modified:   stub/src/arch/amd64/lzma_d.S
	modified:   stub/src/arch/arm/v4a/lzma_d.S
	modified:   stub/src/arch/arm/v4t/macros.S
	modified:   stub/src/arch/arm64/v8/lzma_d.S
	modified:   stub/src/arch/powerpc/32/lzma_d.S
	modified:   stub/src/arch/powerpc/64le/lzma_d-common.S
	modified:   stub/src/arm.v4a-expand.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
	modified:   stub/src/arm64-expand.S
	modified:   stub/src/i386-expand.S
	modified:   stub/src/mips.r3000-expand.S
	modified:   stub/src/powerpc-expand.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64-expand.S
	modified:   stub/src/powerpc64-linux.elf-entry.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser e6f3c1b3da un-DEBUG
modified:   stub/src/arm.v4a-linux.elf-main2.c
2024-08-25 15:16:29 -07:00
John Reiser 22f732aa4e ARM 32-bit: centralize definition of bkpt, bkpt_th opcodes
modified:   stub/src/arch/arm/v4a/macros.S
	modified:   stub/src/arm.v4a-linux.elf-so_entry.S
	modified:   stub/src/arm.v4a-linux.elf-so_fold.S
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
2024-08-25 15:16:29 -07:00
John Reiser 5e531d7cca PowerPC register mixups
modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
2024-08-25 15:16:29 -07:00
John Reiser 0deae5f0b8 ARM_OLDABI is no longer handled by #define
modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/armeb.v4a-linux.elf-entry.S
	modified:   stub/src/armeb.v4a-linux.elf-fold.S
2024-08-25 15:16:29 -07:00
John Reiser 9ff4187fb3 filters 0x50, 0x51 use same code for unfilter
modified:   stub/src/arm.v4a-expand.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
2024-08-25 15:16:29 -07:00
John Reiser 6a1e70bf40 i386 filters 0x46 and 0x49 are the same
modified:   filter/filter_impl.cpp
	modified:   stub/src/arch/i386/bxx.S
2024-08-25 15:16:29 -07:00
John Reiser d097218a45 mips.r3000, a mips-1 cpu, still has load-delay slots
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/mips.r3000-expand.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
2024-08-25 15:16:29 -07:00
John Reiser cc87a2c867 ELF2 for mips 32-bit main programs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/include/linux.h
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/arch/mips/r3000/lzma_d.S
	modified:   stub/src/arch/mips/r3000/macros.ash
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm.v4a-linux.elf-main2.c
	modified:   stub/src/arm.v4a-linux.elf-so_fold.lds
	modified:   stub/src/arm.v5a-linux.elf-so_fold.lds
	modified:   stub/src/arm64-linux.elf-so_fold.lds
	modified:   stub/src/i386-expand.S
	modified:   stub/src/i386-linux.elf-entry.lds
	modified:   stub/src/i386-linux.elf-main2.c
	modified:   stub/src/i386-linux.elf-so_fold.lds
	new file:   stub/src/mips.r3000-expand.S
	new file:   stub/src/mips.r3000-linux.elf-entry.lds
	modified:   stub/src/mips.r3000-linux.elf-fold.S
	modified:   stub/src/mips.r3000-linux.elf-fold.lds
	new file:   stub/src/mips.r3000-linux.elf-main2.c
	new file:   stub/src/mipsel.r3000-expand.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	new file:   stub/src/mipsel.r3000-linux.elf-entry.lds
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.lds
	new file:   stub/src/mipsel.r3000-linux.elf-main2.c
	modified:   stub/src/mipsel.r3000-linux.shlib-init.S
	modified:   stub/src/powerpc-linux.elf-fold.lds
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser b26ba9c4d3 ELF2 stragglers from stub make
modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/tmp/powerpc-linux.elf-fold.map
2024-08-25 15:16:29 -07:00
John Reiser 88c94d1cc0 ELF2 for powerpc (32-bit) main programs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/arch/powerpc/32/macros.S
	modified:   stub/src/i386-linux.elf-main2.c
	new file:   stub/src/powerpc-expand.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-fold.lds
	new file:   stub/src/powerpc-linux.elf-main2.c
	modified:   stub/src/powerpc64-linux.elf-fold.S
           plus generated *.h *.map *.dump

 interactive rebase in progress; onto ac82d473
 Last commands done (17 commands done):
    pick 1b9ddea5 ELF2 arm32-linux unmap_all_pages
    pick 1f372e54 ELF2 for powerpc (32-bit) main programs
 Next commands to do (10 remaining commands):
    pick 5f5849a9 ELF2 stragglers from stub make
    pick 2ba8b5da ELF2 for mips 32-bit main programs
 You are currently rebasing branch 'jreiser-ELF2' on 'ac82d473'.

 Changes to be committed:
	modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   src/p_lx_elf.cpp
	modified:   src/stub/Makefile
	modified:   src/stub/powerpc-linux.elf-entry.h
	modified:   src/stub/powerpc-linux.elf-fold.h
	modified:   src/stub/powerpc64-linux.elf-fold.h
	modified:   src/stub/powerpc64le-linux.elf-fold.h
	modified:   src/stub/src/arch/powerpc/32/macros.S
	modified:   src/stub/src/i386-linux.elf-main2.c
	new file:   src/stub/src/powerpc-expand.S
	modified:   src/stub/src/powerpc-linux.elf-entry.S
	modified:   src/stub/src/powerpc-linux.elf-fold.S
	modified:   src/stub/src/powerpc-linux.elf-fold.lds
	new file:   src/stub/src/powerpc-linux.elf-main2.c
	modified:   src/stub/src/powerpc64-linux.elf-fold.S
	modified:   src/stub/tmp/powerpc-linux.elf-entry.bin.dump
	modified:   src/stub/tmp/powerpc-linux.elf-fold.map
	modified:   src/stub/tmp/powerpc64-linux.elf-fold.map
	modified:   src/stub/tmp/powerpc64le-linux.elf-fold.map
2024-08-25 15:16:29 -07:00
John Reiser 6cda0b6016 ELF2 arm32-linux unmap_all_pages
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser 66dc1d90d8 ELF2 for arm32
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	new file:   stub/src/arm.v4a-linux.elf-entry.lds
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm.v4a-linux.elf-fold.lds
	new file:   stub/src/arm.v4a-linux.elf-main2.c
	new file:   stub/src/arm.v4a-linux.elf-so_entry.lds
	new file:   stub/src/arm.v5a-linux.elf-entry.lds
	new file:   stub/src/arm.v5a-linux.elf-fold.lds
	new file:   stub/src/arm.v5a-linux.elf-main2.c
	new file:   stub/src/arm.v5a-linux.elf-so_entry.lds
	new file:   stub/src/armeb.v4a-expand.S
	new file:   stub/src/armeb.v4a-linux.elf-entry.lds
	modified:   stub/src/armeb.v4a-linux.elf-fold.lds
	new file:   stub/src/armeb.v4a-linux.elf-main2.c
	new file:   stub/src/armeb.v4a-linux.elf-so_main2.c
	modified:   stub/src/i386-linux.elf-main2.c
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser f7cab0cf71 ELF2 for i386-linux main programs
OpenBSD and NetBSD main programs probably need work.
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/i386-linux.elf-entry.S
	new file:   stub/src/i386-linux.elf-entry.lds
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-fold.lds
	new file:   stub/src/i386-linux.elf-main2.c
	new file:   stub/src/i386-linux.elf-so_entry.lds
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser 83e2df4c46 Fix pwerpc64 lzma stub
modified:   stub/src/arch/powerpc/64/lzma_d.S

 interactive rebase in progress; onto ac82d473
 Last commands done (13 commands done):
    pick 821c9dcc ELF2: FIx powerpc64* lzma
    pick ad3d6786 Fix pwerpc64 lzma stub
 Next commands to do (14 remaining commands):
    pick 8389340b ELF2 for i386-linux main programs
    pick 921d6ad3 ELF2 for arm32
 You are currently rebasing branch 'jreiser-ELF2' on 'ac82d473'.

 Changes to be committed:
	modified:   src/stub/powerpc64-linux.elf-fold.h
	modified:   src/stub/src/arch/powerpc/64/lzma_d.S
	modified:   src/stub/tmp/powerpc64-linux.elf-fold.map
2024-08-25 15:16:29 -07:00
John Reiser 31216ed1b2 ELF2: FIx powerpc64* lzma
also follow-ons for https://github.com/upx/upx/issues/834
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arch/powerpc/64le/lzma_d-common.S
	modified:   stub/src/arch/powerpc/64le/lzma_d.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/powerpc64-expand.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
           plus generated *.h *.map *.dump

 interactive rebase in progress; onto ac82d473
 Last commands done (12 commands done):
    pick d6a29e58 CI updates
    pick 821c9dcc ELF2: FIx powerpc64* lzma
 Next commands to do (15 remaining commands):
    pick ad3d6786 Fix pwerpc64 lzma stub
    pick 8389340b ELF2 for i386-linux main programs
 You are currently rebasing branch 'jreiser-ELF2' on 'ac82d473'.

 Changes to be committed:
	modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   src/stub/powerpc64-linux.elf-fold.h
	modified:   src/stub/powerpc64le-linux.elf-fold.h
2024-08-25 15:16:29 -07:00
John Reiser e9930bb2bc ELF2: Move section EXP_TAIL to catch case of no matching de-compressor
Also adjust blocksize for large gap (.p_align - .p_filesz)
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-expand.S
	modified:   stub/src/arm64-expand.S
	modified:   stub/src/powerpc64-expand.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser c8a0540fd2 ELF2: FIx powerpc64* lzma
also follow-ons for https://github.com/upx/upx/issues/834
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arch/powerpc/64le/lzma_d-common.S
	modified:   stub/src/arch/powerpc/64le/lzma_d.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/powerpc64-expand.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser a9b7a0cb27 ELF2: use "gcc -E" instead of /lib/cpp
modified:   Makefile
2024-08-25 15:16:29 -07:00
John Reiser c0ff491972 ELF2 for PowerPC64 forgot to add new files
new file:   src/powerpc64-expand.S
	new file:   src/powerpc64-linux.elf-main2.c
	new file:   src/powerpc64le-expand.S
	new file:   src/powerpc64le-linux.elf-main2.c
2024-08-25 15:16:29 -07:00
John Reiser 146c105961 ELF2 for PowerPC64
(MacOS temporarily disabled)
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/arch/powerpc/64/macros.S
	modified:   stub/src/arch/powerpc/64le/bxx.S
	modified:   stub/src/arch/powerpc/64le/macros.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	new file:   stub/src/dollar-dollar.sed
	modified:   stub/src/powerpc64-linux.elf-entry.S
	modified:   stub/src/powerpc64-linux.elf-fold.S
	modified:   stub/src/powerpc64-linux.elf-fold.lds
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-fold.lds
	modified:   stub/src/powerpc64le-linux.kernel.vmlinux.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser 35fca2062e ELF2 arm64: fix exit from lzma de-compressor
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   linker.cpp
	modified:   stub/src/arch/arm64/v8/lzma_d.S
	modified:   stub/src/arm64-expand.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:29 -07:00
John Reiser 2c4e5c7a47 arm64-expand code for nrv* EOF at de-compress is not quite uniform
WINDOWS_BACK requirement also interferes.
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/arch/arm64/v8/nrv2d_d32.S
	modified:   stub/src/arch/arm64/v8/nrv2e_d32.S
	modified:   stub/src/arm64-expand.S
           plus generated *.h, *.map
2024-08-25 15:16:29 -07:00
John Reiser e561da33bd ELF2 64-bits: Use /dev/shm (O_TMPFILE) if memfd_create fails
Such as Ubuntu-20.04, Linux kernel 5.15.0-67, #74-20.04.1, 2023-02-22
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/Makefile
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/upxfd_android.c
           plus generated *.h *.map *.dump
2024-08-25 15:16:28 -07:00
John Reiser 5f6bdb0a8f ELF2 for arm64 main programs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   stub/Makefile
	modified:   stub/src/amd64-expand.S
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arch/amd64/lzma_d.S
	modified:   stub/src/arch/amd64/nrv2b_d.S
	modified:   stub/src/arch/amd64/nrv2d_d.S
	modified:   stub/src/arch/amd64/nrv2e_d.S
	modified:   stub/src/arch/arm64/v8/lzma_d.S
	modified:   stub/src/arch/arm64/v8/macros.S
	modified:   stub/src/arch/arm64/v8/nrv2b_d32.S
	modified:   stub/src/arch/arm64/v8/nrv2d_d32.S
	modified:   stub/src/arch/arm64/v8/nrv2e_d32.S
	modified:   stub/src/arm64-expand.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
           plus generated *.h *.map *.dump
2024-08-25 15:16:28 -07:00
John Reiser 6276a4a7c4 ELF2 for arm64 main programs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main2.c
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-fold.lds
	new file:   stub/src/arm64-linux.elf-main2.c
           plus generated *.h *.dump *.map
2024-08-25 15:16:28 -07:00
John Reiser 4fa50b96ad Disable macos-12 from running upx-packed [temporary]
macOS-12.7.5 lldb complains "Bad executable" for any packed.
	modified:   .github/workflows/ci.yml
2024-08-25 15:16:28 -07:00
John Reiser 5aef158ff0 ELF2: Fix EINVAL when PT_LOAD does not start on page boundary
modified:   stub/src/amd64-linux.elf-main2.c
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
           plus generated .h .map
2024-08-25 15:16:28 -07:00
John Reiser 4054ac192a ELF2: memcheck avoids extra safety bytes
modified:   stub/src/amd64-linux.elf-entry.S
	modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
           plus generated .h and .dump
2024-08-25 15:16:28 -07:00
John Reiser febe8e4d9e whitespace
modified:   stub/src/arch/amd64/lzma_d.S
2024-08-25 15:16:28 -07:00
John Reiser c924c32d54 ELF2: fix lzma on amd64-linux.elf-*
New -DWINDOWS_BACK so that amd64-win64.pe.h does not change.
This hides a real bug (unchecked), but would change anti-virus status.
	modified:   src/stub/src/amd64-expand.S
	modified:   src/stub/src/amd64-linux.elf-entry.S
	modified:   src/stub/src/amd64-linux.elf-fold.S
	modified:   src/stub/src/arch/amd64/lzma_d.S
	modified:   src/stub/Makefile
	modified:   misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
           plus generated *.h, *.map, *.dump
2024-08-25 15:16:28 -07:00
John Reiser 743eb5cc26 whitespace
modified:   p_lx_elf.cpp
2024-08-25 15:16:28 -07:00
John Reiser f4585cdf77 Sync stubs
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
2024-08-25 15:16:28 -07:00
John Reiser c36977f0b1 ELF: amd64-linux main programs use 2-step de-compressor
The first $ARCH to move to 2-step de-compressor for ELF main programs.
De-compressor uses memfd_create to comply with strictest SELinux
settings (no PROT_WRITE on any PROT_EXEC page).
First step de-compressor always uses NRV2B to de-compress the second step,
and the second step can use a different de-compressor for each PT_LOAD.
	modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	modified:   stub/src/amd64-linux.elf-fold.lds
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	new file:   stub/src/amd64-linux.elf-main2.c

	modified:   stub/amd64-linux.elf-entry.h
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-entry.bin.dump
	modified:   stub/tmp/amd64-linux.elf-fold.map
2024-08-25 15:16:28 -07:00
Markus F.X.J. Oberhumer 44e4bd0b54 CI updates 2024-08-19 07:55:57 +02:00
Markus F.X.J. Oberhumer 1427b8137a CI updates 2024-08-13 11:32:29 +02:00
Markus F.X.J. Oberhumer a9cb354225 CI and cmake updates 2024-08-07 13:37:38 +02:00
Markus F.X.J. Oberhumer b4db17ab3c cmake update 2024-07-31 18:56:32 +02:00
Markus F.X.J. Oberhumer ba969fb9f2 CI updates 2024-07-31 09:24:33 +02:00
Markus F.X.J. Oberhumer 87ac252c8d CI updates 2024-07-30 17:22:52 +02:00
Markus F.X.J. Oberhumer ada9081ea2 CI updates 2024-07-28 18:01:54 +02:00
Markus F.X.J. Oberhumer d6a29e582f CI updates 2024-07-25 13:08:15 +02:00
Markus F.X.J. Oberhumer 03c4184067 all: misc cleanups 2024-07-23 12:24:09 +02:00
Markus F.X.J. Oberhumer 0a82280f20 cmake update 2024-07-19 11:13:04 +02:00
Markus F.X.J. Oberhumer a7fa2f87c5 cmake update 2024-07-17 12:06:41 +02:00
Markus F.X.J. Oberhumer 3a11a5a82e CI updates 2024-07-13 12:49:02 +02:00
John Reiser 08a38af553 Workaround bug in Alpine Linux
"empty" DT_GNU_HASH lacked hasharr[0] when n_bucket==1,
which upx correctly detected as malformed.
	modified:   p_lx_elf.cpp
2024-07-02 11:24:27 -07:00
Markus F.X.J. Oberhumer 043a54cf3e all: minor cleanups 2024-07-10 10:34:58 +02:00
Markus F.X.J. Oberhumer 16c8f6d160 src: portability updates 2024-07-07 14:50:27 +02:00
Markus F.X.J. Oberhumer 285472bc78 submodules: update for new versions 2024-07-07 14:16:49 +02:00
Markus F.X.J. Oberhumer a77adcd4c7 src: new ACC version 2024-07-01 18:25:54 +02:00
John Reiser cebd4392f2 Fix checksum error de-compressing ELF with large .p_align and small blocksize
https://github.com/upx/upx/issues/836
	modified:   p_unix.cpp
2024-07-05 19:06:14 -07:00
John Reiser 64a3de5a7a FIX PT_GNU_HASH when "empty"
... such as a main program with no exported globals
https://github.com/upx/upx/issues/834
	modified:   p_lx_elf.cpp
2024-06-28 09:04:05 -07:00
Markus F.X.J. Oberhumer 261609f706 CI updates 2024-06-26 11:45:35 +02:00
Markus F.X.J. Oberhumer 17cf73001c CI updates 2024-06-21 18:19:59 +02:00
Markus F.X.J. Oberhumer ad566d793a CI updates 2024-06-20 10:49:09 +02:00
Markus F.X.J. Oberhumer b499ed3d20 CI updates 2024-06-19 00:20:35 +02:00
John Reiser de8de9c0f0 Option --unmap-all-pages completely avoids /proc/self/exe
https://github.com/upx/upx/issues/749
2024-06-18 10:18:32 -07:00
John Reiser 3b36dce5c2 Mention PT_MIPS_ABIFLAGS forwarding
https://github.com/upx/upx/issues/788
	modified:   NEWS
2024-06-17 08:50:54 -07:00
Markus F.X.J. Oberhumer dcd8dfd5fc CI: add zigcc linux-mips soft-float targets 2024-06-17 10:28:53 +02:00
Markus F.X.J. Oberhumer 78f3b6297c src/pefile.cpp: default to strict reloc checks 2024-06-17 09:35:31 +02:00
Markus F.X.J. Oberhumer a49fe3b04a CI: remove zigcc linux-mips workaround 2024-06-17 08:55:21 +02:00
Markus F.X.J. Oberhumer f23cc7daa3 CI update: remove macos-11 runner 2024-06-15 18:16:58 +02:00
John Reiser cafd9d7ace Sync stub checksums
modified:   ../misc/testsuite/upx_testsuite_1-expected_sha256sums.sh
2024-06-14 14:49:54 -07:00
John Reiser 1b6c120864 64-bit phdrx[], PT_NOTE, PT_GNU_STACK
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2024-06-13 15:32:51 -07:00
John Reiser 99afc50ebf PT_MIPS_ABIFLAGS, PT_MIPS_REGINFO
Also re-org of PT_HOTE and other non-PT_LOAD Elf32_Phdrs
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2024-06-13 09:58:20 -07:00
John Reiser 3286f7c5ba De-compression of PT_MIPS_ABIFLAGS
modified:   p_lx_elf.cpp
2024-06-11 20:03:44 -07:00
John Reiser 72ccca9faf PT_MIPS_ABIFLAGS, compression side only, 32-bit only
modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2024-06-11 15:02:13 -07:00
Markus F.X.J. Oberhumer 3c294d9721 all: minor cleanups 2024-06-14 15:15:55 +02:00
Markus F.X.J. Oberhumer 1aff5f5bb7 all: misc cleanups 2024-06-07 22:29:57 +02:00
John Reiser 937ae4c5e0 Avoid crash on outrageous fuzzed input
https://github.com/upx/upx/issues/828
	modified:   p_lx_elf.cpp
2024-06-04 15:43:11 -07:00
John Reiser 056865f59a Detect bad placement of LINK segment
https://github.com/upx/upx/issues/827
	modified:   p_mach.cpp
2024-06-04 08:55:46 -07:00
John Reiser c58246b43c Detect compressed length too short
https://github.com/upx/upx/issues/827
	modified:   p_unix.cpp
2024-06-04 08:32:26 -07:00
Markus F.X.J. Oberhumer 3495d1affd all: minor cleanups 2024-05-28 10:26:39 +02:00
Markus F.X.J. Oberhumer b0ce072370 src: fix compilation on older compilers; update tests 2024-05-27 20:59:12 +02:00
Markus F.X.J. Oberhumer 9f4d18baac src: yet more constexpr updates 2024-05-27 07:03:03 +02:00
Markus F.X.J. Oberhumer f65c8f8c6f src: more work on constexpr 2024-05-26 18:22:29 +02:00
Markus F.X.J. Oberhumer e0633b89bb CI updates 2024-05-26 12:36:41 +02:00
Markus F.X.J. Oberhumer c3341ce4dc src: add support for constexpr bele.h 2024-05-26 02:27:51 +02:00
Markus F.X.J. Oberhumer 43f9b90c92 cmake update 2024-05-24 09:17:37 +02:00
Markus F.X.J. Oberhumer 6ee45dcdcd CI updates 2024-05-22 22:23:40 +02:00
Markus F.X.J. Oberhumer 344246725b src: more upx::max cleanups 2024-05-22 09:49:20 +02:00
John Reiser 57763ca1e2 ELF stubs: go_lang different placement of DT_STRTAB, DT_SYMTAB
https://github.com/upx/upx/issues/825
	modified:   p_lx_elf.cpp
2024-05-21 17:14:21 -07:00
Markus F.X.J. Oberhumer 40b7e24fcc src: introduce upx::max and friends; updates for clang-19 git snapshot 2024-05-15 14:06:05 +02:00
Markus F.X.J. Oberhumer 9e0f16a629 submodules: update for new versions 2024-05-15 12:32:36 +02:00
Markus F.X.J. Oberhumer 33f4f3a5a1 all: minor clang-tidy cleanups 2024-05-12 08:35:04 +02:00
Markus F.X.J. Oberhumer 07a3b75b3e submodules: update for new versions 2024-05-12 08:33:16 +02:00
Markus F.X.J. Oberhumer bdea2539d1 cmake: use recommended CMAKE install variables
The documentation of GNUInstallDirs explicitly recommends to
*NOT* use the CMAKE_INSTALL_FULL_<dir> variants.
2024-05-11 22:12:29 +02:00
Markus F.X.J. Oberhumer ed3d7b0c45 all: minor cleanups 2024-05-11 22:07:08 +02:00
Markus F.X.J. Oberhumer cba44c45fc src: introduce ptr_get_address() 2024-05-11 17:37:15 +02:00
Markus F.X.J. Oberhumer 07b533f95b submodules: update for new versions 2024-05-11 13:17:43 +02:00
Markus F.X.J. Oberhumer 7b0a79dec5 all: update LZMA SDK license information
The LZMA SDK was placed in the public domain as of
version 4.62 (December 2008).

  https://www.7-zip.org/sdk.html

And according to https://sourceforge.net/p/sevenzip/discussion/45797/thread/685169cf/

  "Are older LZMA versions in the public domain?"
  "Yes, you can use old versions of LZMA SDK as public domain."
    -- Igor Pavlov, 2011-06-21
2024-05-11 12:52:26 +02:00
Markus F.X.J. Oberhumer befd01aa96 CI updates 2024-05-10 10:30:59 +02:00
Markus F.X.J. Oberhumer 1cc263624d submodules: update for new versions 2024-05-10 10:04:13 +02:00
Markus F.X.J. Oberhumer 4daa2c1cde testsuite: update checksums caused by version bump 2024-05-09 12:50:03 +02:00
Markus F.X.J. Oberhumer 7081c57571 all: post-release version bump 2024-05-09 12:44:51 +02:00
613 changed files with 91293 additions and 67102 deletions
-1
View File
@@ -23,7 +23,6 @@ Checks: >
clang-analyzer-*, clang-analyzer-*,
-clang-analyzer-optin.performance.Padding, -clang-analyzer-optin.performance.Padding,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
-clang-analyzer-security.insecureAPI.rand,
-clang-analyzer-security.insecureAPI.strcpy, -clang-analyzer-security.insecureAPI.strcpy,
clang-diagnostic-*, clang-diagnostic-*,
performance-*, performance-*,
+322 -128
View File
@@ -8,33 +8,38 @@ name: CI
on: [push, workflow_dispatch] on: [push, workflow_dispatch]
defaults: { run: { shell: bash } }
env: env:
CMAKE_REQUIRED_QUIET: 'OFF' CMAKE_REQUIRED_QUIET: 'OFF'
CMAKE_VERBOSE_MAKEFILE: 'ON' CMAKE_VERBOSE_MAKEFILE: 'ON'
CTEST_OUTPUT_ON_FAILURE: 'ON' CTEST_OUTPUT_ON_FAILURE: 'ON'
DEBIAN_FRONTEND: noninteractive DEBIAN_FRONTEND: noninteractive
NO_COLOR: 1
UPX_CMAKE_BUILD_FLAGS: --verbose UPX_CMAKE_BUILD_FLAGS: --verbose
UPX_CMAKE_CONFIG_FLAGS: -Wdev --warn-uninitialized UPX_CMAKE_CONFIG_FLAGS: -Wdev --warn-uninitialized
UPX_CONFIG_HAVE_WORKING_BUILD_RPATH: 'ON'
UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO: 1 UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO: 1
UPX_DEBUG_TEST_LIBC_QSORT: 1 UPX_DEBUG_TEST_LIBC_QSORT: 1
# 2024-04-20 ZSTD_CLEVEL: 17
ZIG_DIST_VERSION: 0.12.0 # 2025-08-19
ZIG_DIST_VERSION: 0.15.1
jobs: jobs:
job-rebuild-and-verify-stubs: job-rebuild-and-verify-stubs:
name: Rebuild stubs name: Rebuild stubs
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ubuntu:24.04 # glibc-2.39 container: ubuntu:24.04 # provides glibc-2.39
#container: debian:12-slim # also works; glibc-2.36 #container: debian:12-slim # also works; provides glibc-2.36
#container: debian:testing-slim # also works #container: debian:testing-slim # also works; currently provides glibc-2.38
steps: steps:
- run: uname -a; pwd; id; umask
- name: Install packages - name: Install packages
run: | run: |
uname -a; pwd; id; umask
dpkg --add-architecture i386 dpkg --add-architecture i386
apt-get update && apt-get upgrade -y apt-get update && apt-get upgrade -y
# install system packages # install system packages
apt-get install -y --no-install-recommends bash ca-certificates curl git libmpc3 make perl-base xz-utils libc6:i386 zlib1g:i386 apt-get install -y --no-install-recommends bash ca-certificates curl git libmpc3 make perl-base tar time xz-utils libc6:i386 zlib1g:i386
# install python2-minimal packages from Debian-11 # install python2-minimal packages from Debian-11
mkdir ../deps; cd ../deps; mkdir packages mkdir ../deps; cd ../deps; mkdir packages
curl -sS -L -O https://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb curl -sS -L -O https://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb
@@ -53,41 +58,110 @@ jobs:
git config --global --add safe.directory '*' # needed when running in a container git config --global --add safe.directory '*' # needed when running in a container
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" . git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
git submodule update --init -- vendor/lzma-sdk git submodule update --init -- vendor/lzma-sdk
git fsck --strict --no-progress
- name: Rebuild and verify stubs - name: Rebuild and verify stubs
run: | run: |
export PATH="$(readlink -en ../deps/bin-upx-20221212):$PATH" export PATH="$(readlink -en ../deps/bin-upx-20221212):$PATH"
make -C src/stub maintainer-clean extra-clean make -C src/stub maintainer-clean extra-clean
git status || true git status || true # make sure the stub files got deleted
make -C src/stub extra-all all make -C src/stub extra-all all
if ! git diff --quiet; then git diff; exit 1; fi if ! git diff --quiet; then git diff; exit 1; fi
- run: bash ./misc/scripts/check_whitespace_git.sh - run: bash ./misc/scripts/check_whitespace_git.sh
- name: Check source code formatting - name: Check source code formatting
run: | run: |
export UPX_CLANG_FORMAT="$PWD/../deps/bin-upx-20221212/clang-format-15.0.6" export UPX_CLANG_FORMAT="$(readlink -en ../deps/bin-upx-20221212/clang-format-15.0.6)"
make -C src clang-format make -C src clang-format
if ! git diff --quiet; then git diff; exit 1; fi if ! git diff --quiet; then git diff; exit 1; fi
- name: Rebuild docs - name: Rebuild docs
run: | run: |
make -C doc clean all make -C doc clean all
if ! git diff --quiet; then git diff || true; fi # ignore diff error if ! git diff --quiet; then git diff || true; fi # ignore diff error
- name: Clean up
run: |
git ls-files -z --others --ignored --exclude-standard ./src/stub | xargs -0r rm -v --
find ./src/stub/src -type d -name tmp -print0 | xargs -0r rmdir -v --
- run: git status --ignored || true
job-linux-cmake: # uses cmake + make job-linux-cmake-0: # uses cmake + make
if: true if: true
needs: [ job-rebuild-and-verify-stubs ] needs: [ job-rebuild-and-verify-stubs ]
name: ${{ format('{0}', matrix.os) }}
runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- { os: ubuntu-22.04, use_extra: true, use_wine: true } - { os: ubuntu-22.04 }
- { os: ubuntu-20.04, use_extra: true } - { os: ubuntu-24.04 }
- { os: ubuntu-22.04-arm }
- { os: ubuntu-24.04-arm }
name: ${{ format('{0}', matrix.os) }}-0
runs-on: ${{ matrix.os }}
steps: steps:
- run: uname -a; pwd; id; umask
- run: sudo apt-get update
- run: sudo apt-get install -y dmidecode gdb parallel valgrind
- run: (sudo dmidecode | sed -n -e '/System Information/,/^$/p') || true
- run: sudo dmidecode -q || true
- run: sudo dmidecode || true
- uses: actions/checkout@v5
with: { submodules: true }
- run: make build/extra/gcc/all
- run: make build/extra/clang/all
- run: ls -l build/*/*/*/upx* || true
- run: file build/*/*/*/upx* || true
- name: Make artifact
run: |
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}-0" | sed 's/[^0-9a-zA-Z_.-]/-/g')
mkdir -p "tmp/artifact/$N"
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
if command -v hardlink >/dev/null; then (cd "tmp/artifact/$N" && hardlink .) fi
(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v4
with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
- name: Run install tests
run: |
jobs="gcc/debug gcc/release clang/debug clang/release"
echo "===== parallel jobs: $jobs"
DESTDIR="Install with make 2" parallel -kv --lb 'make build/extra/{}+install' ::: $jobs
- name: Mimic ctest tests SIGSEGV
run: |
jobs="gcc/debug gcc/release clang/debug clang/release"
echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest_sigsegv.sh' ::: $jobs
- name: Run ctest tests
run: |
jobs="gcc/debug gcc/release clang/debug clang/release"
echo "===== parallel jobs: $jobs"
CTEST_JOBS=2 parallel -kv --lb 'make build/extra/{}+test' ::: $jobs
- name: Mimic ctest tests with Valgrind
run: |
export UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS=ON # valgrind is SLOW
export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet --gen-suppressions=all"
# clang/debug does not work before valgrind-3.20, see https://bugs.kde.org/show_bug.cgi?id=452758
jobs="gcc/debug gcc/release clang/release"
echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
job-linux-cmake: # uses cmake + make
if: true
needs: [ job-rebuild-and-verify-stubs ]
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-22.04, use_extra: true }
- { os: ubuntu-24.04, use_extra: true, use_wine: true }
name: ${{ format('{0}', matrix.os) }}
runs-on: ${{ matrix.os }}
steps:
- run: uname -a; pwd; id; umask
- name: Install extra 32-bit and MinGW packages - name: Install extra 32-bit and MinGW packages
if: ${{ matrix.use_extra }} if: ${{ matrix.use_extra }}
run: | run: |
sudo dpkg --add-architecture i386 sudo dpkg --add-architecture i386
sudo apt-get update && sudo apt-get upgrade -y sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install -y dmidecode gdb libc6-dbg:i386 parallel valgrind
sudo apt-get install -y g++-multilib g++-mingw-w64-i686 g++-mingw-w64-x86-64 sudo apt-get install -y g++-multilib g++-mingw-w64-i686 g++-mingw-w64-x86-64
# make sure that we use posix-threads (pthread/winpthreads) and NOT win32-threads # make sure that we use posix-threads (pthread/winpthreads) and NOT win32-threads
for f in i686-w64-mingw32-g++ i686-w64-mingw32-gcc x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc; do for f in i686-w64-mingw32-g++ i686-w64-mingw32-gcc x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc; do
@@ -95,17 +169,28 @@ jobs:
ls -l /usr/bin/${f}* ls -l /usr/bin/${f}*
done done
ls -l /etc/alternatives/*mingw* || true ls -l /etc/alternatives/*mingw* || true
sudo apt-get install -y libc6-dbg:i386 valgrind - run: (sudo dmidecode | sed -n -e '/System Information/,/^$/p') || true
if: ${{ matrix.use_extra }}
- run: sudo dmidecode -q || true
if: ${{ matrix.use_extra }}
- run: sudo dmidecode || true
if: ${{ matrix.use_extra }}
- name: Install Wine - name: Install Wine
if: ${{ matrix.use_extra && matrix.use_wine }} if: ${{ matrix.use_extra && matrix.use_wine }}
run: | run: |
sudo apt-get install -y wine wine32:i386 wine64 sudo apt-get install -y wine wine32:i386 wine64
ls -l /usr/bin/wine* ls -l /usr/bin/wine*
mkdir -p -v ~/.wine && wineboot --init mkdir -p -v ~/.wine && wineboot --init
- uses: actions/checkout@v4 - uses: actions/checkout@v5
with: { submodules: true } with: { submodules: true }
- name: Check out test suite - 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
- run: set -x; clang --version; clang++ --version
- run: set -x; gcc --version; g++ --version
- run: clang -E -x c -dM /dev/null # list predefined macros for C
- run: clang++ -E -x c++ -dM /dev/null # list predefined macros for C++
- run: gcc -E -x c -dM /dev/null # list predefined macros for C
- run: g++ -E -x c++ -dM /dev/null # list predefined macros for C++
- run: make build/extra/gcc/all - run: make build/extra/gcc/all
- run: make build/extra/clang/all - run: make build/extra/clang/all
- run: make build/extra/gcc-m32/all - run: make build/extra/gcc-m32/all
@@ -116,12 +201,25 @@ jobs:
if: ${{ matrix.use_extra }} if: ${{ matrix.use_extra }}
- run: make build/extra/cross-windows-mingw64/all - run: make build/extra/cross-windows-mingw64/all
if: ${{ matrix.use_extra }} if: ${{ matrix.use_extra }}
- run: ls -l build/*/*/*/upx* || true
- run: file build/*/*/*/upx* || true
- name: Make artifact - name: Make artifact
run: | run: |
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g') N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
mkdir -p "tmp/artifact/$N" mkdir -p "tmp/artifact/$N"
dirs="gcc/debug gcc/release clang/debug clang/release"
if test "${{ matrix.use_extra }}" = "true"; then
dirs="$dirs gcc-m32/debug gcc-m32/release gcc-mx32/debug gcc-mx32/release"
dirs="$dirs cross-windows-mingw32/debug cross-windows-mingw32/release"
dirs="$dirs cross-windows-mingw64/debug cross-windows-mingw64/release"
fi
for d in $dirs; do DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdir/$d" cmake --install build/extra/$d; done
for d in $dirs; do DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdirAndStrip/$d" cmake --install build/extra/$d --strip; done
for d in $dirs; do cmake --install build/extra/$d --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefix/$d"; done
for d in $dirs; do cmake --install build/extra/$d --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefixAndStrip/$d" --strip; done
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N") (cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") if command -v hardlink >/dev/null; then (cd "tmp/artifact/$N" && hardlink .) fi
(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
echo "artifact_name=$N" >> $GITHUB_ENV echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }} - name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -130,6 +228,16 @@ jobs:
run: | run: |
(cd build/extra/gcc/release && DESTDIR="$PWD/Install with cmake" cmake --install .) (cd build/extra/gcc/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
(cd build/extra/gcc/release && DESTDIR="$PWD/Install with make" make install) (cd build/extra/gcc/release && DESTDIR="$PWD/Install with make" make install)
jobs="gcc/debug gcc/release clang/debug clang/release"
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
echo "===== parallel jobs: $jobs"
DESTDIR="Install with make 2" parallel -kv --lb 'make build/extra/{}+install' ::: $jobs
- name: Mimic ctest tests SIGSEGV
run: |
jobs="gcc/debug gcc/release clang/debug clang/release"
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest_sigsegv.sh' ::: $jobs
- name: Run ctest tests - name: Run ctest tests
run: | run: |
jobs="gcc/debug gcc/release clang/debug clang/release" jobs="gcc/debug gcc/release clang/debug clang/release"
@@ -138,12 +246,6 @@ jobs:
command -v wine >/dev/null && jobs="$jobs cross-windows-mingw64/debug cross-windows-mingw64/release" command -v wine >/dev/null && jobs="$jobs cross-windows-mingw64/debug cross-windows-mingw64/release"
echo "===== parallel jobs: $jobs" echo "===== parallel jobs: $jobs"
CTEST_JOBS=2 parallel -kv --lb 'make build/extra/{}+test' ::: $jobs CTEST_JOBS=2 parallel -kv --lb 'make build/extra/{}+test' ::: $jobs
- name: Mimic ctest tests
run: |
jobs="gcc/debug gcc/release clang/debug clang/release"
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
- name: Mimic ctest tests with Valgrind - name: Mimic ctest tests with Valgrind
if: true # note: valgrind is SLOW if: true # note: valgrind is SLOW
run: | run: |
@@ -156,13 +258,13 @@ jobs:
echo "===== parallel jobs: $jobs" echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
fi fi
- name: Run file system test suite - name: Run file system tests
run: | run: |
jobs="gcc/debug gcc/release clang/debug clang/release" jobs="gcc/debug gcc/release clang/debug clang/release"
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release" test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
echo "===== parallel jobs: $jobs" echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/test_symlinks.sh' ::: $jobs parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/test_symlinks.sh' ::: $jobs
- name: Run file system test suite with Valgrind - name: Run file system tests with Valgrind
if: false # note: valgrind is SLOW if: false # note: valgrind is SLOW
run: | run: |
if command -v valgrind >/dev/null; then if command -v valgrind >/dev/null; then
@@ -184,22 +286,20 @@ jobs:
job-macos-cmake: # uses cmake + make job-macos-cmake: # uses cmake + make
if: true if: true
needs: [ job-rebuild-and-verify-stubs ] needs: [ job-rebuild-and-verify-stubs ]
name: ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }}
runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
# NOTE: Xcode updates regularly tend to break Homebrew clang/gcc; often some ld64 issue; use "xcode_version" as needed; or try "-Wl,-ld_classic"
# NOTE: macos does not have "env -C"; only with brew coreutils # 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-13, gcc: gcc-12, gxx: g++-12, testsuite: true }
- { os: macos-11, gcc: gcc-10, gxx: g++-10, testsuite: true } - { os: macos-14, gcc: gcc-13, gxx: g++-13, testsuite: true }
- { os: macos-12, gcc: gcc-11, gxx: g++-11, testsuite: true } # { os: macos-15, gcc: gcc-14, gxx: g++-14, testsuite: true }
- { os: macos-13, testsuite: true } # use default Xcode-15; NOTE: gcc-12 on macos-13 does not work with Xcode-15 - { os: macos-15, testsuite: true }
- { os: macos-13, gcc: gcc-12, gxx: g++-12, testsuite: true, xcode_version: 14.3.1 } name: ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }}
# { os: macos-14, gcc: gcc-13, gxx: g++-13, testsuite: true } # gcc-13: INTERNAL ERROR in ld64 runs-on: ${{ matrix.os }}
# { os: macos-14, gcc: gcc-13, gxx: g++-13, testsuite: true, xcode_version: 14.3.1 } # gcc-13: MISSING HEADER FILES
- { os: macos-14, gcc: gcc-12, gxx: g++-12, testsuite: true } # => use gcc-12 for now
steps: steps:
- run: uname -a; pwd; id; umask
- uses: maxim-lobanov/setup-xcode@v1 - uses: maxim-lobanov/setup-xcode@v1
if: ${{ matrix.xcode_version }} if: ${{ matrix.xcode_version }}
with: { xcode-version: '${{ matrix.xcode_version }}' } with: { xcode-version: '${{ matrix.xcode_version }}' }
@@ -209,24 +309,34 @@ jobs:
test -z "$HOMEBREW_PREFIX" && HOMEBREW_PREFIX="$(brew --prefix)" test -z "$HOMEBREW_PREFIX" && HOMEBREW_PREFIX="$(brew --prefix)"
echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX" >> $GITHUB_ENV echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX" >> $GITHUB_ENV
# testsuite needs working "readlink -en" and "sha256sum -b" # testsuite needs working "readlink -en" and "sha256sum -b"
packages="ninja parallel" packages="parallel util-linux"
test -e "$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin/readlink" || packages="$packages coreutils" test -e "$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin/readlink" || packages="$packages coreutils"
if test -n "$packages"; then if test -n "$packages"; then
echo "===== brew leaves:"; brew leaves; echo "===== brew list:"; brew list --versions echo "===== brew leaves:"; brew leaves; echo "===== brew list:"; brew list --versions
# only run "brew update" if needed # only run "brew update" if needed
if ! brew install $packages; then brew update && brew install $packages; fi if ! brew install $packages; then echo "===== brew update" && brew update && brew install $packages; fi
fi fi
mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi) mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi)
echo "UPX_DEBUG_FORCE_PACK_MACOS=1" >> $GITHUB_ENV echo "UPX_DEBUG_FORCE_PACK_MACOS=1" >> $GITHUB_ENV
case "${{ matrix.os }}" in case "${{ matrix.os }}" in
# TODO FIXME: UPX on macos-13+ is broken => disable run-packed for now # TODO FIXME: UPX on macos-13+ is broken => disable run-packed for now
macos-13 | macos-14) echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV ;; macos-1[345]) echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV ;;
esac esac
- uses: actions/checkout@v4 - uses: actions/checkout@v5
with: { submodules: true } with: { submodules: true }
- name: Check out test suite - name: Check out test suite
if: ${{ matrix.testsuite }} if: ${{ matrix.testsuite }}
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
- run: set -x; xcode-select -p || true; xcodebuild -version || true
- run: set -x; clang --version; clang++ --version
- run: clang -E -x c -dM /dev/null # list predefined macros for C
- run: clang++ -E -x c++ -dM /dev/null # list predefined macros for C++
- run: set -x; ${{ matrix.gcc }} --version; ${{ matrix.gxx }} --version
if: ${{ matrix.gcc }}
- run: ${{ matrix.gcc }} -E -x c -dM /dev/null # list predefined macros for C
if: ${{ matrix.gcc }}
- run: ${{ matrix.gxx }} -E -x c++ -dM /dev/null # list predefined macros for C++
if: ${{ matrix.gcc }}
- run: make build/extra/clang/all - run: make build/extra/clang/all
- name: Build extra/gcc/all - name: Build extra/gcc/all
if: ${{ matrix.gcc }} if: ${{ matrix.gcc }}
@@ -235,13 +345,23 @@ jobs:
run: | run: |
make UPX_XTARGET=xtarget/cross-darwin-arm64 xtarget/all \ make UPX_XTARGET=xtarget/cross-darwin-arm64 xtarget/all \
CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin"
- run: ls -l build/*/*/*/upx* || true
- run: file build/*/*/*/upx* || true
- name: Make artifact - name: Make artifact
run: | run: |
X="${{ matrix.xcode_version }}"; test -n "$X" && X="-xcode-$X" X="${{ matrix.xcode_version }}"; test -n "$X" && X="-xcode-$X"
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}$X" | sed 's/[^0-9a-zA-Z_.-]/-/g') N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}$X" | sed 's/[^0-9a-zA-Z_.-]/-/g')
mkdir -p "tmp/artifact/$N" mkdir -p "tmp/artifact/$N"
dirs="clang/debug clang/release"
test -n "${{ matrix.gcc }}" && dirs="$dirs gcc/debug gcc/release"
for d in $dirs; do DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdir/$d" cmake --install build/extra/$d; done
for d in $dirs; do DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdirAndStrip/$d" cmake --install build/extra/$d --strip; done
for d in $dirs; do cmake --install build/extra/$d --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefix/$d"; done
for d in $dirs; do cmake --install build/extra/$d --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefixAndStrip/$d" --strip; done
(cd build && rsync -R -a */*/*/upx "../tmp/artifact/$N/") (cd build && rsync -R -a */*/*/upx "../tmp/artifact/$N/")
(cd tmp/artifact && gtar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") hardlink="$HOMEBREW_PREFIX/opt/util-linux/bin/hardlink"
if test -f "$hardlink"; then (cd "tmp/artifact/$N" && "$hardlink" .) fi
(cd tmp/artifact && gtar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
echo "artifact_name=$N" >> $GITHUB_ENV echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }} - name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -264,7 +384,7 @@ jobs:
test -n "${{ matrix.gcc }}" && jobs="$jobs gcc/debug gcc/release" test -n "${{ matrix.gcc }}" && jobs="$jobs gcc/debug gcc/release"
echo "===== parallel jobs: $jobs" echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
- name: Run file system test suite - name: Run file system tests
if: ${{ matrix.testsuite }} # for coreutils readlink if: ${{ matrix.testsuite }} # for coreutils readlink
run: | run: |
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
@@ -286,30 +406,60 @@ jobs:
job-windows-cmake: # uses cmake + msbuild job-windows-cmake: # uses cmake + msbuild
if: true if: true
needs: [ job-rebuild-and-verify-stubs ] needs: [ job-rebuild-and-verify-stubs ]
name: ${{ format('{0}', matrix.name) }}
runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- { name: windows-2019-amd64, os: windows-2019, vsversion: 2019, vsarch: amd64 } # { name: windows-2019-amd64, os: windows-2019, vsversion: 2019, vsarch: amd64 }
- { name: windows-2022-amd64, os: windows-2022, vsversion: 2022, vsarch: amd64 } - { name: windows-2022-amd64, os: windows-2022, vsversion: 2022, vsarch: amd64 }
- { name: windows-2022-arm64, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64 }
# { name: windows-2022-arm64ec, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64, use_arm64ec: true }
- { name: windows-2022-i386, os: windows-2022, vsversion: 2022, vsarch: amd64_x86 }
- { name: windows-2025-amd64, os: windows-2025, vsversion: 2022, vsarch: amd64 }
- { name: windows-2025-arm64, os: windows-2025, vsversion: 2022, vsarch: amd64_arm64 }
- { name: windows-2025-arm64ec, os: windows-2025, vsversion: 2022, vsarch: amd64_arm64, use_arm64ec: true }
- { name: windows-2025-i386, os: windows-2025, vsversion: 2022, vsarch: amd64_x86 }
name: ${{ format('{0}', matrix.name) }}
runs-on: ${{ matrix.os }}
steps: steps:
- run: git config --global core.autocrlf false - run: git config --global core.autocrlf false
- uses: actions/checkout@v4 - uses: actions/checkout@v5
with: { submodules: true } with: { submodules: true }
- name: Check out test suite - 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
- uses: ilammy/msvc-dev-cmd@v1 - uses: ilammy/msvc-dev-cmd@v1
with: { vsversion: '${{ matrix.vsversion }}', arch: '${{ matrix.vsarch }}' } with: { vsversion: '${{ matrix.vsversion }}', arch: '${{ matrix.vsarch }}' }
- name: Set platform
run: |
if [[ "${{ matrix.vsarch }}" == amd64 ]]; then true;
echo "UPX_CMAKE_CONFIG_FLAGS_PLATFORM=-A x64" >> $GITHUB_ENV
elif [[ "${{ matrix.use_arm64ec }}" == "true" ]]; then true;
echo "UPX_CMAKE_CONFIG_FLAGS_PLATFORM=-A ARM64EC" >> $GITHUB_ENV
echo "UPX_CONFIG_DISABLE_SELF_PACK_TEST=ON" >> $GITHUB_ENV
elif [[ "${{ matrix.vsarch }}" == amd64_arm64 ]]; then true;
echo "UPX_CMAKE_CONFIG_FLAGS_PLATFORM=-A ARM64" >> $GITHUB_ENV
echo "UPX_CONFIG_DISABLE_SELF_PACK_TEST=ON" >> $GITHUB_ENV
elif [[ "${{ matrix.vsarch }}" == amd64_x86 ]]; then true;
echo "UPX_CMAKE_CONFIG_FLAGS_PLATFORM=-A Win32" >> $GITHUB_ENV
fi
- run: make build/debug - run: make build/debug
- run: make build/release - run: make build/release
- run: shopt -s globstar; ls -ld build/**/upx* || true
- run: shopt -s globstar; file build/**/upx* || true
- name: Make artifact - name: Make artifact
shell: bash
run: | run: |
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g') N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.name }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
mkdir -p "tmp/artifact/$N" mkdir -p "tmp/artifact/$N"
DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdir/debug" cmake --install build/debug --config Debug
DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdir/release" cmake --install build/release --config Release
DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdirAndStrip/debug" cmake --install build/debug --config Debug --strip
DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdirAndStrip/release" cmake --install build/release --config Release --strip
cmake --install build/debug --config Debug --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefix/debug"
cmake --install build/release --config Release --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefix/release"
cmake --install build/debug --config Debug --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefixAndStrip/debug" --strip
cmake --install build/release --config Release --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefixAndStrip/release" --strip
(cd build && cp -ai --parents */*/upx.exe "../tmp/artifact/$N") (cd build && cp -ai --parents */*/upx.exe "../tmp/artifact/$N")
(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
echo "artifact_name=$N" >> $GITHUB_ENV echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }} - name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -319,39 +469,42 @@ jobs:
run: | run: |
ctest --test-dir build/debug --parallel 8 -C Debug ctest --test-dir build/debug --parallel 8 -C Debug
ctest --test-dir build/release --parallel 8 -C Release ctest --test-dir build/release --parallel 8 -C Release
- name: Mimic ctest tests
if: ${{ matrix.vsarch != 'amd64_arm64' }}
run: |
env -C build/debug/Debug upx_exe=./upx.exe bash "$PWD"/misc/testsuite/mimic_ctest.sh
env -C build/release/Release upx_exe=./upx.exe bash "$PWD"/misc/testsuite/mimic_ctest.sh
- name: Run test suite build/release - name: Run test suite build/release
if: ${{ matrix.vsarch != 'amd64_arm64' }} if: ${{ matrix.vsarch != 'amd64_arm64' }}
shell: bash
run: | run: |
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
env -C build/release/Release bash "$PWD"/misc/testsuite/upx_testsuite_1.sh env -C build/release/Release upx_exe=./upx.exe bash "$PWD"/misc/testsuite/upx_testsuite_1.sh
job-windows-toolchains: # build "by hand" using cmd.exe job-windows-toolchains: # build "by hand" using cmd.exe
if: github.repository_owner == 'upx' if: github.repository_owner == 'upx'
needs: [ job-rebuild-and-verify-stubs ] needs: [ job-rebuild-and-verify-stubs ]
strategy:
fail-fast: false
matrix:
include:
# { name: amd64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64 }
- { name: amd64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64 }
# { name: arm64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64_arm64 }
- { name: arm64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64 }
- { 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 }
name: ${{ format('windows {0}', matrix.name) }} name: ${{ format('windows {0}', matrix.name) }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
C: ${{ matrix.name }} C: ${{ matrix.name }}
B: release B: release
strategy:
fail-fast: false
matrix:
include:
- { name: amd64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64 }
- { name: amd64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64 }
- { name: arm64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64_arm64 }
- { name: arm64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64 }
- { 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 }
steps: steps:
- run: git config --global core.autocrlf false - run: git config --global core.autocrlf false
- uses: actions/checkout@v4 - uses: actions/checkout@v5
with: { submodules: true } with: { submodules: true }
- name: Prepare sources and Check out test suite - name: Prepare sources and Check out test suite
shell: bash
run: | run: |
git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite
mkdir -p -v build/$C/$B/{bzip2,ucl,upx,zlib,zstd} mkdir -p -v build/$C/$B/{bzip2,ucl,upx,zlib,zstd}
@@ -381,7 +534,8 @@ jobs:
%RUN_LIB% -out:ucl.lib *.obj %RUN_LIB% -out:ucl.lib *.obj
@REM ===== build zlib ===== @REM ===== build zlib =====
cd %BDIR%\zlib cd %BDIR%\zlib
%RUN_CL% -J -O2 -W3 -WX %DEFS% -DHAVE_VSNPRINTF -c %H%\vendor\zlib\*.c set s=%H%\vendor\zlib
%RUN_CL% -J -O2 -W3 -WX %DEFS% -I%s% -DHAVE_VSNPRINTF -c %H%\vendor\zlib\*.c
%RUN_LIB% -out:zlib.lib *.obj %RUN_LIB% -out:zlib.lib *.obj
@REM ===== build zstd ===== @REM ===== build zstd =====
cd %BDIR%\zstd cd %BDIR%\zstd
@@ -398,33 +552,24 @@ jobs:
@rem set UPX_LIBS=%BDIR%\bzip2\bzip2.lib %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib @rem set UPX_LIBS=%BDIR%\bzip2\bzip2.lib %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib
set sources=%s%\*.cpp %s%\check\*.cpp %s%\compress\*.cpp %s%\console\*.cpp %s%\filter\*.cpp %s%\util\*.cpp set sources=%s%\*.cpp %s%\check\*.cpp %s%\compress\*.cpp %s%\console\*.cpp %s%\filter\*.cpp %s%\util\*.cpp
%RUN_CL% -J -O2 -W4 -WX -std:c++17 -Zc:__cplusplus -EHsc -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% %UPX_DEFS% -I%H%\vendor -Feupx.exe %sources% %UPX_LIBS% /link ${{ matrix.link_machine_flags }} setargv.obj %RUN_CL% -J -O2 -W4 -WX -std:c++17 -Zc:__cplusplus -EHsc -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% %UPX_DEFS% -I%H%\vendor -Feupx.exe %sources% %UPX_LIBS% /link ${{ matrix.link_machine_flags }} setargv.obj
- run: shopt -s globstar; ls -ld build/**/upx* || true
- run: shopt -s globstar; file build/**/upx* || true
- name: Make artifact - name: Make artifact
shell: bash
run: | run: |
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-windows-${{ matrix.name }}" | sed 's/[^0-9a-zA-Z_.-]/-/g') N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-windows-${{ matrix.name }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
mkdir -p "tmp/artifact/$N/$B" mkdir -p "tmp/artifact/$N/$B"
cp -ai build/$C/$B/upx/upx*.exe "tmp/artifact/$N/$B" cp -ai build/$C/$B/upx/upx*.exe "tmp/artifact/$N/$B"
(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
echo "artifact_name=$N" >> $GITHUB_ENV echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }} - name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: { name: '${{ env.artifact_name }}', path: tmp/artifact } with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
- name: Run basic tests - name: Mimic ctest tests
if: ${{ matrix.vsarch != 'amd64_arm64' }} if: ${{ matrix.vsarch != 'amd64_arm64' }}
run: | run: |
$ErrorActionPreference = 'stop' env -C build/$C/$B/upx upx_exe=./upx.exe bash "$PWD"/misc/testsuite/mimic_ctest.sh
$ErrorView = 'NormalView'
cd $Env:H\build\$Env:C\$Env:B\upx
$Env:UPX = "--no-color --no-progress"
.\upx.exe --version
.\upx.exe --sysinfo -v
.\upx.exe upx.exe -o upx_packed.exe
dir *.exe
.\upx.exe -l upx_packed.exe
.\upx.exe -t upx_packed.exe
.\upx_packed.exe --version
- name: Run test suite - name: Run test suite
if: ${{ matrix.vsarch != 'amd64_arm64' }} if: ${{ matrix.vsarch != 'amd64_arm64' }}
shell: bash
run: | run: |
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)" export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
env -C build/$C/$B/upx upx_exe=./upx.exe bash "$PWD"/misc/testsuite/upx_testsuite_1.sh env -C build/$C/$B/upx upx_exe=./upx.exe bash "$PWD"/misc/testsuite/upx_testsuite_1.sh
@@ -432,110 +577,158 @@ jobs:
job-linux-zigcc: # uses cmake + make job-linux-zigcc: # uses cmake + make
if: github.repository_owner == 'upx' if: github.repository_owner == 'upx'
needs: [ job-rebuild-and-verify-stubs ] needs: [ job-rebuild-and-verify-stubs ]
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
runs-on: ubuntu-latest
container: alpine:3.19
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
# only build a few targets => more targets are tested in the Weekly CI # only build a few selected targets => more targets are tested in the Weekly CI
- { zig_target: aarch64-linux-musl, qemu: qemu-aarch64 } - { zig_target: aarch64-linux-musl, qemu: qemu-aarch64 }
# { zig_target: aarch64-linux-musl, qemu: qemu-aarch64, zig_pic: -fPIE } - { zig_target: aarch64-linux-musl, qemu: qemu-aarch64, zig_pic: -fPIE, container: 'alpine:3.18' }
# { zig_target: aarch64-macos-none } - { zig_target: aarch64-macos-none }
- { zig_target: aarch64-macos.11.0-none }
# { zig_target: aarch64-macos.12.0-none }
# { zig_target: aarch64-macos.13.0-none }
- { zig_target: aarch64-windows-gnu } - { zig_target: aarch64-windows-gnu }
- { zig_target: arm-linux-musleabihf, qemu: qemu-arm } - { zig_target: arm-linux-musleabihf, qemu: qemu-arm }
# { zig_target: arm-linux-musleabihf, qemu: qemu-arm, zig_pic: -fPIE } - { zig_target: armeb-linux-musleabihf, qemu: qemu-armeb }
- { zig_target: i386-linux-gnu.2.3.4, zig_flags: -march=i586 } - { zig_target: i386-linux-gnu.2.3.4, zig_flags: -march=i586 }
- { zig_target: i386-linux-gnu.2.17, zig_flags: -march=i586 }
- { zig_target: i386-linux-musl, zig_flags: -march=i586, qemu: qemu-i386 } - { zig_target: i386-linux-musl, zig_flags: -march=i586, qemu: qemu-i386 }
# { zig_target: i386-linux-musl, zig_flags: -march=i586, qemu: qemu-i386, zig_pic: -fPIE } - { zig_target: i386-linux-musl, zig_flags: -march=i586, qemu: qemu-i386, zig_pic: -fPIE }
- { zig_target: i386-windows-gnu } - { zig_target: i386-windows-gnu }
# mips and mipsel: bad hard-float code generation(??); or QEMU bug; or UPX bug; see https://github.com/upx/upx/issues/788 - { zig_target: mips-linux-musleabi, qemu: qemu-mips }
- { zig_target: mips-linux-musl, zig_flags: -msoft-float, qemu: qemu-mips } - { zig_target: mips-linux-musleabihf, qemu: qemu-mips }
- { zig_target: mipsel-linux-musl, zig_flags: -msoft-float, qemu: qemu-mipsel } - { zig_target: mipsel-linux-musleabi, qemu: qemu-mipsel }
- { zig_target: powerpc-linux-musl, qemu: qemu-ppc } - { zig_target: mipsel-linux-musleabihf, qemu: qemu-mipsel }
# powerpc64: obscure problem with C++ exceptions in UPX doctest checks; use -fPIC to work-around # { zig_target: mips-linux-musleabi-mips32r2, zig_flags: -march=mips32r2, qemu: qemu-mips }
- { zig_target: powerpc64-linux-musl, zig_flags: -fPIC, qemu: qemu-ppc64 } # { zig_target: mips-linux-musleabi-mips32r3, zig_flags: -march=mips32r3, qemu: qemu-mips }
# { zig_target: mips-linux-musleabi-mips32r5, zig_flags: -march=mips32r5, qemu: qemu-mips }
# { zig_target: mips-linux-musleabi-mips32r6, zig_flags: -march=mips32r6, qemu: qemu-mips }
- { zig_target: powerpc-linux-musleabihf, qemu: qemu-ppc }
- { zig_target: powerpc64-linux-musl, qemu: qemu-ppc64 }
- { zig_target: powerpc64-linux-musl, qemu: qemu-ppc64, zig_pic: -fPIE }
- { zig_target: powerpc64le-linux-musl, qemu: qemu-ppc64le } - { zig_target: powerpc64le-linux-musl, qemu: qemu-ppc64le }
- { zig_target: powerpc64le-linux-musl, qemu: qemu-ppc64le, zig_pic: -fPIE }
- { zig_target: x86_64-linux-gnu.2.3.4, qemu: qemu-x86_64 } # can use QEMU because of gcompat - { zig_target: x86_64-linux-gnu.2.3.4, qemu: qemu-x86_64 } # can use QEMU because of gcompat
- { zig_target: x86_64-linux-gnu.2.17, qemu: qemu-x86_64 } # can use QEMU because of gcompat
- { zig_target: x86_64-linux-musl, qemu: qemu-x86_64 } - { zig_target: x86_64-linux-musl, qemu: qemu-x86_64 }
# { zig_target: x86_64-linux-musl, qemu: qemu-x86_64, zig_pic: -fPIE } - { zig_target: x86_64-linux-musl, qemu: qemu-x86_64, zig_pic: -fPIE, container: 'alpine:3.18' }
# { zig_target: x86_64-macos-none } - { zig_target: x86_64-macos-none }
- { zig_target: x86_64-macos.11.0-none }
# { zig_target: x86_64-macos.12.0-none }
# { zig_target: x86_64-macos.13.0-none }
- { zig_target: x86_64-windows-gnu } - { zig_target: x86_64-windows-gnu }
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
runs-on: ubuntu-latest
container: ${{ matrix.container || 'alpine:3.22' }}
env: env:
# zig is currently missing winpthreads; see https://github.com/ziglang/zig/issues/10989 container: ${{ matrix.container || 'alpine:3.22' }}
UPX_CONFIG_EXPECT_THREADS: ${{ contains(matrix.zig_target, '-windows-') && 'OFF' || 'ON' }} UPX_CONFIG_HAVE_WORKING_BUILD_RPATH: ''
# for zig-cc wrapper scripts (see below): # for zig-cc wrapper scripts (see below):
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
ZIG_FLAGS: ${{ matrix.zig_flags }} ZIG_FLAGS: ${{ matrix.zig_flags }}
ZIG_PIC: ${{ matrix.zig_pic }} ZIG_PIC: ${{ matrix.zig_pic }}
ZIG_TARGET: ${{ matrix.zig_target }} ZIG_TARGET: ${{ matrix.zig_target }}
steps: steps:
- name: Install Alpine Linux container packages - run: uname -a; pwd; id; umask
if: ${{ job.container }} shell: sh
- name: ${{ format('Install packages {0}', env.container) }}
shell: sh shell: sh
run: | run: |
apk update && apk upgrade && apk add bash cmake curl file git make parallel tar xz apk update && apk upgrade && apk add bash cmake curl dmidecode file gdb git make parallel patch strace sudo tar util-linux xz zstd
mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi)
# set PATH like in Ubuntu # set PATH like in Ubuntu
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
git config --global --add safe.directory '*' # needed when running in a container git config --global --add safe.directory '*' # needed when running in a container
- uses: actions/checkout@v4 mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi)
- run: (sudo dmidecode | sed -n -e '/System Information/,/^$/p') || true
- uses: actions/checkout@v5
with: { submodules: true } with: { submodules: true }
- name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }} - name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }}
shell: bash
run: | run: |
rev=$(git rev-parse --short=7 HEAD) rev=$(git rev-parse --short=7 HEAD)
echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV
if [[ "${{ matrix.zig_target }}" == x86_64-linux-gnu.2.3.4 ]]; then if [[ "${{ matrix.zig_target }}" == i386-linux-gnu.2.3.* ]]; then true;
echo "UPX_CONFIG_DISABLE_SHARED_LIBS=ON" >> $GITHUB_ENV # zig problem when linking in Debug mode
fi
if [[ "${{ matrix.zig_target }}" == x86_64-linux-gnu.2* ]]; then true;
echo "NEED_GCOMPAT=1" >> $GITHUB_ENV echo "NEED_GCOMPAT=1" >> $GITHUB_ENV
# TODO FIXME: problem with self-packed upx and musl+gcompat: "Not a valid dynamic program" # TODO FIXME: problem with self-packed upx and musl+gcompat: "Not a valid dynamic program"
echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV
fi fi
# update ZIG_TARGET (i386 => x86)
ZIG_TARGET=${ZIG_TARGET/i386-/x86-}
echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV
# install zig; note that ~/.local/bin is included in the default $PATH on Ubuntu # install zig; note that ~/.local/bin is included in the default $PATH on Ubuntu
mkdir -p -v ~/.local/bin mkdir -p -v ~/.local/bin
cd ~/.local/bin cd ~/.local/bin
ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION} ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION}
curl -sS -L -O https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz ZIG_DIST_NAME=zig-x86_64-linux-${ZIG_DIST_VERSION}
#curl -sS -L -O https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz
#curl -sS -L -O https://ziglang.org/download/0.14.1/${ZIG_DIST_NAME}.tar.xz
curl -sS -L -O https://ziglang.org/download/0.15.1/${ZIG_DIST_NAME}.tar.xz
ls -l ${ZIG_DIST_NAME}.tar.xz ls -l ${ZIG_DIST_NAME}.tar.xz
file ${ZIG_DIST_NAME}.tar.xz || true
tar -xoJf ${ZIG_DIST_NAME}.tar.xz tar -xoJf ${ZIG_DIST_NAME}.tar.xz
rm ${ZIG_DIST_NAME}.tar.xz rm ${ZIG_DIST_NAME}.tar.xz
ln -s -v ${ZIG_DIST_NAME}/zig zig ln -s -v ${ZIG_DIST_NAME}/zig zig
#echo "PATH=$PATH" && which zig #echo "PATH=$PATH" && which zig
echo -n 'zig version: '; zig version echo -n 'zig version: '; zig version
# patch zig
ls -la "$HOME" "$GITHUB_WORKSPACE" || true
(cd ${ZIG_DIST_NAME} && patch --verbose -p1 -i "$GITHUB_WORKSPACE"/misc/patches/zig/0001-x.patch)
# create wrapper scripts (needed for CMake) # create wrapper scripts (needed for CMake)
echo -e '#!/bin/sh\nexec zig ar "$@"' > zig-ar log=
echo -e '#!/bin/sh\nexec zig cc -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CFLAGS "$@"' > zig-cc log='set -x\n'
echo -e '#!/bin/sh\nexec zig c++ -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CXXFLAGS "$@"' > zig-cxx echo -e '#!/bin/sh\n'$log'exec zig ar "$@"' > zig-ar
echo -e '#!/bin/sh\nexec zig ranlib "$@"' > zig-ranlib echo -e '#!/bin/sh\n'$log'exec zig cc -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CFLAGS "$@"' > zig-cc
echo -e '#!/bin/sh\n'$log'exec zig c++ -target $ZIG_TARGET $ZIG_PIC $ZIG_FLAGS $ZIG_CPPFLAGS $ZIG_CXXFLAGS "$@"' > zig-cxx
echo -e '#!/bin/sh\n'$log'exec zig ranlib "$@"' > zig-ranlib
chmod +x zig-ar zig-cc zig-cxx zig-ranlib chmod +x zig-ar zig-cc zig-cxx zig-ranlib
ls -la; head zig-ar zig-cc zig-cxx zig-ranlib ls -la; head zig-ar zig-cc zig-cxx zig-ranlib
# update ZIG_TARGET
[[ $ZIG_TARGET == mips-linux-musleabi-* ]] && ZIG_TARGET=mips-linux-musleabi
[[ $ZIG_TARGET == mips-linux-musleabihf-* ]] && ZIG_TARGET=mips-linux-musleabihf
[[ $ZIG_TARGET == mipsel-linux-musleabi-* ]] && ZIG_TARGET=mipsel-linux-musleabi
[[ $ZIG_TARGET == mipsel-linux-musleabihf-* ]] && ZIG_TARGET=mipsel-linux-musleabihf
ZIG_TARGET=${ZIG_TARGET/#i386-/x86-} # i386 => x86
echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV
# update ZIG_FLAGS
# -fPIE is for compilation only => also use the correct linker flag "-pie"
# INFO: it seems the zig driver does handle this automatically(??), so not really needed
if test "X$ZIG_PIC" = "X-fPIE"; then true;
ZIG_FLAGS="$ZIG_FLAGS --start-no-unused-arguments -pie --end-no-unused-arguments"
echo "UPX_CONFIG_DISABLE_SHARED_LIBS=ON" >> $GITHUB_ENV # conflicts with ZIG_PIC/ZIG_FLAGS
fi
if [[ $ZIG_TARGET == *-linux-gnu.2.3.* ]]; then true;
# glibc-2.3.3: undefined symbols in Debug build: __snprintf_chk __vsnprintf_chk
# glibc-2.3.4: ld.lld: error: undefined symbol: openat64
ZIG_FLAGS="$ZIG_FLAGS -fno-sanitize=all"
echo "UPX_CONFIG_DISABLE_SANITIZE=ON" >> $GITHUB_ENV
fi
if [[ $ZIG_TARGET == *-linux-gnu.2.[456789] ]]; then true;
# glibc-2.x: ld.lld: error: undefined symbol: pwritev64
ZIG_FLAGS="$ZIG_FLAGS -fno-sanitize=all"
echo "UPX_CONFIG_DISABLE_SANITIZE=ON" >> $GITHUB_ENV
fi
echo "ZIG_FLAGS=$ZIG_FLAGS" >> $GITHUB_ENV
- run: set -x; zig version; zig-cc --version || true; zig-cxx --version || true
- run: zig-cc -E -x c -dM /dev/null # list predefined macros for C
- run: zig-cxx -E -x c++ -dM /dev/null # list predefined macros for C++
- name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }} - name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
run: | run: |
make UPX_XTARGET=zig/${ZIG_TARGET}${ZIG_PIC} xtarget/release \ 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" 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) }} - name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
run: | run: |
make UPX_XTARGET=zig/${ZIG_TARGET}${ZIG_PIC} xtarget/debug \ 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" 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* - run: ls -l build/*/*/*/upx* || true
- run: file build/*/*/*/upx* || true
- name: ${{ format('Make artifact from upx-{0}-{1}', github.ref_name, env.UPX_GITREV_SHORT) }} - name: ${{ format('Make artifact from upx-{0}-{1}', github.ref_name, env.UPX_GITREV_SHORT) }}
shell: bash
run: | run: |
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-zigcc-${{ matrix.zig_target }}${ZIG_PIC}" | sed 's/[^0-9a-zA-Z_.-]/-/g') N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-zigcc-${{ matrix.zig_target }}${ZIG_PIC}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
mkdir -p "tmp/artifact/$N" mkdir -p "tmp/artifact/$N"
if [[ "${{ matrix.zig_target }}" == *-linux* ]]; then
dirs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
for d in $dirs; do DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdir/$d" cmake --install build/zig/$d; done
for d in $dirs; do DESTDIR="$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithDestdirAndStrip/$d" cmake --install build/zig/$d --strip; done
for d in $dirs; do cmake --install build/zig/$d --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefix/$d"; done
for d in $dirs; do cmake --install build/zig/$d --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefixAndStrip/$d" --strip; done
fi
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N") (cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N") if command -v hardlink >/dev/null; then (cd "tmp/artifact/$N" && hardlink .) fi
(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
echo "artifact_name=$N" >> $GITHUB_ENV echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }} - name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@@ -546,14 +739,14 @@ jobs:
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR="$PWD/Install with cmake" cmake --install .) (cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR="$PWD/Install with make" make install) (cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR="$PWD/Install with make" make install)
- name: Run ctest tests - name: Run ctest tests
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }} if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || contains(matrix.zig_target, 'x86_64-linux-gnu.2') }}
run: | run: |
test -n "$NEED_GCOMPAT" && apk add gcompat test -n "$NEED_GCOMPAT" && apk add gcompat
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release" jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
echo "===== parallel jobs: $jobs" echo "===== parallel jobs: $jobs"
parallel -kv --lb 'make build/zig/{}+test' ::: $jobs parallel -kv --lb 'make build/zig/{}+test' ::: $jobs
- name: Mimic ctest tests - name: Mimic ctest tests
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }} if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || contains(matrix.zig_target, 'x86_64-linux-gnu.2') }}
run: | run: |
test -n "$NEED_GCOMPAT" && apk add gcompat test -n "$NEED_GCOMPAT" && apk add gcompat
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release" jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
@@ -570,7 +763,8 @@ jobs:
echo "===== parallel jobs: $jobs" echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
- name: Mimic ctest tests with Valgrind - name: Mimic ctest tests with Valgrind
if: ${{ matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }} #if: ${{ matrix.zig_target == 'x86_64-linux-musl' || contains(matrix.zig_target, 'x86_64-linux-gnu.2') }}
if: false
run: | run: |
export UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS=ON # valgrind is SLOW export UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS=ON # valgrind is SLOW
apk add coreutils valgrind apk add coreutils valgrind
@@ -580,8 +774,8 @@ jobs:
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release" jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
echo "===== parallel jobs: $jobs" echo "===== parallel jobs: $jobs"
parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
- name: Run file system test suite - name: Run file system tests
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }} if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || contains(matrix.zig_target, 'x86_64-linux-gnu.2') }}
run: | run: |
apk add coreutils sudo apk add coreutils sudo
test -n "$NEED_GCOMPAT" && apk add gcompat test -n "$NEED_GCOMPAT" && apk add gcompat
@@ -25,7 +25,7 @@ jobs:
issues: write issues: write
pull-requests: write pull-requests: write
steps: steps:
- uses: actions/stale@v9 - uses: actions/stale@v10
with: with:
operations-per-run: 300 operations-per-run: 300
exempt-all-milestones: true exempt-all-milestones: true
+21 -14
View File
@@ -1,5 +1,11 @@
/.cache*
/.idea/
/.hg* /.hg*
/.vscode* /.vscode*
/.zed/
/CMakeCache*
/CMakeFiles*
/CTest*
/Makevars[.-]global* /Makevars[.-]global*
/Testing* /Testing*
/build* /build*
@@ -9,6 +15,7 @@
GNUmakefile* GNUmakefile*
MMakefile* MMakefile*
Makevars[.-]local* Makevars[.-]local*
compile_commands*.json
compile_flags*.txt compile_flags*.txt
Tmp* Tmp*
tmp* tmp*
@@ -37,19 +44,19 @@ tmp*
*.zip *.zip
*.zst *.zst
doc/*.man /doc/*.man
doc/*.ps /doc/*.ps
doc/*.tex /doc/*.tex
src/stub/**/.*-stamp /src/stub/**/.*-stamp
src/stub/tmp*/*.bin /src/stub/src/**/tmp*/*
src/stub/tmp*/*.bin.bindump /src/stub/tmp*/*.bin
src/stub/tmp*/*.bin.disasm /src/stub/tmp*/*.bin.bindump
src/stub/tmp*/*.o.disasm /src/stub/tmp*/*.bin.disasm
src/stub/tmp*/mips.r3000-*.[is] /src/stub/tmp*/*.o.disasm
src/stub/tmp*/mipsel.r3000-*.[is] /src/stub/tmp*/mips.r3000-*.[is]
src/stub/src/**/tmp*/* /src/stub/tmp*/mipsel.r3000-*.[is]
src/stub/tools/sstrip/amd64-linux-sstrip /src/stub/tools/sstrip/amd64-linux-sstrip
src/stub/tools/sstrip/i386-linux-sstrip /src/stub/tools/sstrip/i386-linux-sstrip
src/stub/tools/sstrip/sstrip /src/stub/tools/sstrip/sstrip
+44 -25
View File
@@ -21,12 +21,17 @@
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/.upx_cmake_config_done.txt") file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/.upx_cmake_config_done.txt")
if(DEFINED UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION) if(DEFINED UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION)
cmake_minimum_required(VERSION "${UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION}" FATAL_ERROR) cmake_minimum_required(VERSION "${UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION}" FATAL_ERROR)
elseif(NOT ${CMAKE_VERSION} VERSION_LESS "3.10")
cmake_minimum_required(VERSION "3.10" FATAL_ERROR)
else() else()
cmake_minimum_required(VERSION "3.8" FATAL_ERROR) # CMake >= 3.8 is needed for CXX_STANDARD 17 cmake_minimum_required(VERSION "3.8" FATAL_ERROR) # CMake >= 3.8 is needed for CXX_STANDARD 17
endif() endif()
# support functions and some utility # support functions and some utility
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/functions.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/functions.cmake")
upx_print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_GENERATOR)
upx_print_var(CMAKE_GENERATOR_TOOLSET CMAKE_GENERATOR_PLATFORM)
upx_print_env_var(CC CXX CPPFLAGS CFLAGS CXXFLAGS)
#*********************************************************************** #***********************************************************************
# options # options
@@ -43,7 +48,7 @@ if(NOT USE_STRICT_DEFAULTS)
option(UPX_CONFIG_DISABLE_WSTRICT "Do not compile with strict compiler warnings." ON) option(UPX_CONFIG_DISABLE_WSTRICT "Do not compile with strict compiler warnings." ON)
else() else()
# strict config defaults for Git developer builds # strict config defaults for Git developer builds
message(STATUS "===== UPX info: strict config defaults enabled") message(STATUS "===== UPX NOTE: strict developer config defaults enabled =====")
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with Git version info." OFF) option(UPX_CONFIG_DISABLE_GITREV "Do not compile with Git version info." OFF)
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with sanitize options." OFF) option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with sanitize options." OFF)
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with -Werror option." OFF) option(UPX_CONFIG_DISABLE_WERROR "Do not compile with -Werror option." OFF)
@@ -59,7 +64,7 @@ option(UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS "Do not run exhaustive tests"
# init # init
#*********************************************************************** #***********************************************************************
set(UPX_VERSION_STRING "4.2.4") # this should match src/version.h set(UPX_VERSION_STRING "5.0.3") # this should match src/version.h
upx_cmake_include_hook(2_init) upx_cmake_include_hook(2_init)
@@ -79,16 +84,15 @@ upx_cache_bool_vars(ON
CMAKE_C_STANDARD_REQUIRED CMAKE_CXX_STANDARD_REQUIRED CMAKE_C_STANDARD_REQUIRED CMAKE_CXX_STANDARD_REQUIRED
CMAKE_EXPORT_COMPILE_COMMANDS CMAKE_REQUIRED_QUIET CMAKE_EXPORT_COMPILE_COMMANDS CMAKE_REQUIRED_QUIET
) )
# internal UPX settings # internal UPX settings that default to OFF; useful for CI jobs
upx_cache_bool_vars(OFF upx_cache_bool_vars(OFF
UPX_CONFIG_CMAKE_DISABLE_TEST UPX_CONFIG_CMAKE_DISABLE_INSTALL UPX_CONFIG_CMAKE_DISABLE_TEST UPX_CONFIG_CMAKE_DISABLE_INSTALL
UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK
UPX_CONFIG_DISABLE_C_STANDARD UPX_CONFIG_DISABLE_CXX_STANDARD UPX_CONFIG_DISABLE_C_STANDARD UPX_CONFIG_DISABLE_CXX_STANDARD
UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST UPX_CONFIG_DISABLE_RUN_PACKED_TEST UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST UPX_CONFIG_DISABLE_RUN_PACKED_TEST
UPX_CONFIG_REQUIRE_THREADS UPX_CONFIG_DISABLE_SAVE_TEMPS UPX_CONFIG_DISABLE_SHARED_LIBS UPX_CONFIG_REQUIRE_THREADS
) )
upx_cache_bool_vars(ON UPX_CONFIG_EXPECT_THREADS) upx_cache_bool_vars(ON UPX_CONFIG_EXPECT_THREADS)
upx_print_env_var(CC CXX)
# determine Git revision # determine Git revision
set(GITREV_SHORT "") set(GITREV_SHORT "")
@@ -136,15 +140,14 @@ endif()
upx_set_default_build_type(Release) # default is CMAKE_BUILD_TYPE=Release upx_set_default_build_type(Release) # default is CMAKE_BUILD_TYPE=Release
project(upx VERSION "${UPX_VERSION_STRING}" LANGUAGES C CXX) project(upx VERSION "${UPX_VERSION_STRING}" LANGUAGES C CXX)
upx_apply_build_type() upx_apply_build_type()
upx_set_global_vars()
upx_check_working_build_rpath(UPX_CONFIG_HAVE_WORKING_BUILD_RPATH)
# set MSVC_FRONTEND, GNU_FRONTEND and MINGW if(DEFINED UPX_CONFIG_CMAKE_EXECUTABLE_SUFFIX)
if(NOT DEFINED MSVC_FRONTEND AND (MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC")) set(CMAKE_EXECUTABLE_SUFFIX "${UPX_CONFIG_CMAKE_EXECUTABLE_SUFFIX}")
set(MSVC_FRONTEND 1)
elseif (NOT DEFINED GNU_FRONTEND AND (CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^GNU" OR CMAKE_C_COMPILER_ID MATCHES "(Clang|GNU)"))
set(GNU_FRONTEND 1)
endif() endif()
if(NOT DEFINED MINGW AND CMAKE_C_PLATFORM_ID MATCHES "^MinGW") if(NOT UPX_CONFIG_CMAKE_DISABLE_INSTALL AND CMAKE_INSTALL_PREFIX)
set(MINGW 1) include(GNUInstallDirs)
endif() endif()
#*********************************************************************** #***********************************************************************
@@ -156,9 +159,20 @@ include(CheckFunctionExists)
include(CheckIncludeFile) include(CheckIncludeFile)
include(CheckStructHasMember) include(CheckStructHasMember)
include(CheckSymbolExists) include(CheckSymbolExists)
include(CheckTypeSize)
upx_cmake_include_hook(3_common_compilation_flags) upx_cmake_include_hook(3_common_compilation_flags)
# assert sane type sizes
check_type_size("size_t" C_SIZEOF_SIZE_T LANGUAGE C)
check_type_size("size_t" CXX_SIZEOF_SIZE_T LANGUAGE CXX)
if(NOT "${C_SIZEOF_SIZE_T}" MATCHES "^(4|8|16)$")
message(FATAL_ERROR "ERROR: unexpected C_SIZEOF_SIZE_T '${C_SIZEOF_SIZE_T}'")
endif()
if(NOT ",${C_SIZEOF_SIZE_T}," STREQUAL ",${CXX_SIZEOF_SIZE_T},")
message(FATAL_ERROR "FATAL ERROR: '${C_SIZEOF_SIZE_T}' '${CXX_SIZEOF_SIZE_T}' mismatch")
endif()
if(NOT DEFINED HAVE_UNISTD_H) if(NOT DEFINED HAVE_UNISTD_H)
check_include_file("unistd.h" HAVE_UNISTD_H) check_include_file("unistd.h" HAVE_UNISTD_H)
endif() endif()
@@ -215,6 +229,8 @@ if(MSVC_FRONTEND OR WIN32 OR MINGW OR CYGWIN)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-DWIN32_LEAN_AND_MEAN) add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-D__USE_MINGW_ANSI_STDIO) add_definitions(-D__USE_MINGW_ANSI_STDIO)
endif() endif()
@@ -248,9 +264,9 @@ endif()
#*********************************************************************** #***********************************************************************
# internal settings; these may change in a future versions # internal settings; these may change in a future versions
set(UPX_CONFIG_DISABLE_THREADS ON) # multithreading is currently not used; maybe in UPX version 5 set(UPX_CONFIG_DISABLE_THREADS ON) # multithreading is currently not used; maybe in UPX version 6
set(UPX_CONFIG_DISABLE_BZIP2 ON) # bzip2 is currently not used; we might need it to decompress linux kernels set(UPX_CONFIG_DISABLE_BZIP2 ON) # bzip2 is currently not used; we might need it to decompress linux kernels
set(UPX_CONFIG_DISABLE_ZSTD ON) # zstd is currently not used; maybe in UPX version 5 set(UPX_CONFIG_DISABLE_ZSTD ON) # zstd is currently not used; maybe in UPX version 6
upx_cmake_include_hook(4_targets) upx_cmake_include_hook(4_targets)
@@ -272,7 +288,9 @@ if(Threads_FOUND)
endif() endif()
if(NOT result) if(NOT result)
# failed; under MinGW be sure to use the posix-threads and NOT the win32-threads version # failed; under MinGW be sure to use the posix-threads and NOT the win32-threads version
#message(STATUS "Threads FAILED ${f}: ${output}") # debug output from try_compile if(UPX_CONFIG_REQUIRE_THREADS OR (UPX_CONFIG_EXPECT_THREADS AND NOT UPX_CONFIG_DISABLE_THREADS))
message(WARNING "Threads FAILED ${f}: ${output}") # output from try_compile
endif()
set(Threads_FOUND OFF) set(Threads_FOUND OFF)
break() break()
endif() endif()
@@ -354,6 +372,7 @@ endif()
upx_add_target_extra_compile_options(${t} UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UCL) upx_add_target_extra_compile_options(${t} UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UCL)
set(t upx_vendor_zlib) set(t upx_vendor_zlib)
target_include_directories(${t} PRIVATE vendor/zlib)
upx_compile_target_debug_with_O2(${t}) upx_compile_target_debug_with_O2(${t})
upx_sanitize_target(${t}) upx_sanitize_target(${t})
target_compile_definitions(${t} PRIVATE HAVE_VSNPRINTF=1) target_compile_definitions(${t} PRIVATE HAVE_VSNPRINTF=1)
@@ -433,6 +452,8 @@ upx_cmake_include_hook(6_test)
if(NOT UPX_CONFIG_CMAKE_DISABLE_TEST) if(NOT UPX_CONFIG_CMAKE_DISABLE_TEST)
add_custom_command(TARGET upx POST_BUILD COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/XTesting/$<CONFIG>")
include(CTest) include(CTest)
if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR) if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
upx_add_test(upx-version upx --version) upx_add_test(upx-version upx --version)
@@ -448,6 +469,7 @@ if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
# IMPORTANT NOTE: these tests can only work if the host executable format # IMPORTANT NOTE: these tests can only work if the host executable format
# is supported by UPX! # is supported by UPX!
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/self_pack_test.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/self_pack_test.cmake")
upx_self_pack_test()
endif() endif()
endif() endif()
@@ -469,17 +491,14 @@ if(NOT CMAKE_INSTALL_PREFIX)
#message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined") #message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined")
message(WARNING "WARNING: CMAKE_INSTALL_PREFIX is not defined") message(WARNING "WARNING: CMAKE_INSTALL_PREFIX is not defined")
endif() endif()
if(CMAKE_INSTALL_PREFIX)
include(GNUInstallDirs)
endif()
# install files # install files
if(CMAKE_INSTALL_PREFIX AND DEFINED CMAKE_INSTALL_FULL_BINDIR) if(CMAKE_INSTALL_PREFIX AND DEFINED CMAKE_INSTALL_BINDIR)
install(TARGETS upx DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}") install(TARGETS upx DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES install(FILES
COPYING LICENSE NEWS README doc/THANKS.txt doc/upx-doc.html doc/upx-doc.txt COPYING LICENSE NEWS README doc/THANKS.txt doc/upx-doc.html doc/upx-doc.txt
DESTINATION "${CMAKE_INSTALL_FULL_DOCDIR}" DESTINATION "${CMAKE_INSTALL_DOCDIR}"
) )
install(FILES doc/upx.1 DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1") install(FILES doc/upx.1 DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
endif() endif()
endif() # UPX_CONFIG_CMAKE_DISABLE_INSTALL endif() # UPX_CONFIG_CMAKE_DISABLE_INSTALL
@@ -493,7 +512,9 @@ upx_cmake_include_hook(8_summary)
upx_print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_GENERATOR) upx_print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_GENERATOR)
if(NOT UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO) if(NOT UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO)
# print detailed info
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/print_info.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/print_info.cmake")
upx_print_info()
endif() endif()
upx_print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_TRY_COMPILE_CONFIGURATION CMAKE_BUILD_TYPE) upx_print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_TRY_COMPILE_CONFIGURATION CMAKE_BUILD_TYPE)
if(Threads_FOUND) if(Threads_FOUND)
@@ -509,9 +530,7 @@ endif()
# extra sanity checks to detect incompatible C vs CXX settings # extra sanity checks to detect incompatible C vs CXX settings
if(NOT UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK) if(NOT UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK)
upx_platform_check_mismatch(CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID) upx_platform_check_c_cxx_mismatch()
upx_platform_check_mismatch(CMAKE_C_COMPILER_ABI CMAKE_CXX_COMPILER_ABI)
upx_platform_check_mismatch(CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
endif() endif()
upx_cmake_include_hook(9_finish) upx_cmake_include_hook(9_finish)
+31 -13
View File
@@ -9,7 +9,7 @@
# mkdir -p build/release # mkdir -p build/release
# cd build/release # cd build/release
# cmake ../.. # run config # cmake ../.. # run config
# make -j # and run build # make -j4 # and run build
CMAKE = cmake CMAKE = cmake
UPX_CMAKE_BUILD_FLAGS += --parallel UPX_CMAKE_BUILD_FLAGS += --parallel
@@ -26,10 +26,15 @@ endif
.DEFAULT_GOAL = build/release .DEFAULT_GOAL = build/release
run_cmake_config = $(CMAKE) -S . -B $1 $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE=$2 .NOTPARALLEL: # because the actual builds use "cmake --parallel"
run_cmake_build = $(CMAKE) --build $1 $(UPX_CMAKE_BUILD_FLAGS) --config $2 .PHONY: PHONY
.SECONDEXPANSION:
.SUFFIXES:
run_cmake_config = $(CMAKE) -S . -B "$1" $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE="$2"
run_cmake_build = $(CMAKE) --build "$1" $(UPX_CMAKE_BUILD_FLAGS) --config "$2"
# avoid re-running run_cmake_config if .upx_cmake_config_done.txt already exists # avoid re-running run_cmake_config if .upx_cmake_config_done.txt already exists
run_config = $(if $(wildcard $1/CMakeFiles/.upx_cmake_config_done.txt),,$(call run_cmake_config,$1,$2)) run_config = $(if $(wildcard $1/CMakeFiles/.*_cmake_config_done.txt),,$(call run_cmake_config,$1,$2))
run_build = $(call run_cmake_build,$1,$2) run_build = $(call run_cmake_build,$1,$2)
build/debug: PHONY build/debug: PHONY
@@ -40,11 +45,6 @@ build/release: PHONY
$(call run_config,$@,Release) $(call run_config,$@,Release)
$(call run_build,$@,Release) $(call run_build,$@,Release)
.NOTPARALLEL: # because the actual builds use "cmake --parallel"
.PHONY: PHONY
.SECONDEXPANSION:
.SUFFIXES:
# shortcuts (all => debug + release) # shortcuts (all => debug + release)
debug: build/debug PHONY debug: build/debug PHONY
release: build/release PHONY release: build/release PHONY
@@ -72,16 +72,34 @@ all+test build/all+test: build/debug+test build/release+test PHONY
test: $$(patsubst %+test,%,$$(.DEFAULT_GOAL))+test PHONY test: $$(patsubst %+test,%,$$(.DEFAULT_GOAL))+test PHONY
# #***********************************************************************
# install
#***********************************************************************
build/debug+install: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CMAKE) --install . --config Debug
build/%/debug+install: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CMAKE) --install . --config Debug
build/release+install: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CMAKE) --install . --config Release
build/%/release+install: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CMAKE) --install . --config Release
build/%/all+install: $$(dir $$@)debug+install $$(dir $$@)release+install PHONY ;
# shortcuts
debug+install: build/debug+install PHONY
release+install: build/release+install PHONY
all+install build/all+install: build/debug+install build/release+install PHONY
install: $$(patsubst %+install,%,$$(.DEFAULT_GOAL))+install PHONY
#***********************************************************************
# END of Makefile # END of Makefile
# #***********************************************************************
# extra pre-defined build configurations and some utility; optional # extra pre-defined build configurations and some utility; optional
include ./misc/make/Makefile-extra.mk -include ./Makevars-local.mk
-include ./misc/make/Makefile-extra.mk
# developer convenience # developer convenience
ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc. ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc.
ifneq ($(wildcard ./misc/scripts/.),) ifneq ($(and $(wildcard ./misc/scripts/.),$(wildcard ./doc/upx.pod)),)
check-whitespace clang-format run-testsuite run-testsuite-all run-testsuite-debug run-testsuite-release: src/Makefile PHONY check-whitespace clang-format run-testsuite run-testsuite-all run-testsuite-debug run-testsuite-release: src/Makefile PHONY
$(MAKE) -C src $@ $(MAKE) -C src $@
endif endif
+18
View File
@@ -2,6 +2,24 @@
User visible changes for UPX User visible changes for UPX
================================================================== ==================================================================
Changes in 5.0.3 (XX XXX XXXX):
* bug fixes - see https://github.com/upx/upx/milestone/21
Changes in 5.0.2 (20 Jul 2025):
* bug fixes - see https://github.com/upx/upx/milestone/20
Changes in 5.0.1 (06 May 2025):
* bug fixes - see https://github.com/upx/upx/milestone/19
Changes in 5.0.0 (20 Feb 2025):
* ELF: use of memfd_create supports Enforcing mode of SELinux
* ELF: two-step de-compression enables future per-PT_LOAD work
* ELF: --unmap-all-pages completely avoids /proc/self/exe
* ELF: PT_MIPS_ABIFLAGS is now forwarded into the compressed output;
qemu-mips can choose the right floating-point emulation
* ELF: many minor internal changes fix nits revealed by fuzzing
* bug fixes - see https://github.com/upx/upx/milestone/18
Changes in 4.2.4 (09 May 2024): Changes in 4.2.4 (09 May 2024):
* bug fixes - see https://github.com/upx/upx/milestone/17 * bug fixes - see https://github.com/upx/upx/milestone/17
+5 -5
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2024 Markus Oberhumer, Laszlo Molnar & John Reiser Copyright (c) 1996-2025 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io https://upx.github.io
@@ -85,13 +85,13 @@ THE FUTURE
COPYRIGHT COPYRIGHT
========= =========
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
UPX is distributed with full source code under the terms of the UPX is distributed with full source code under the terms of the
GNU General Public License v2+; either under the pure GPLv2+ (see GNU General Public License v2+; either under the pure GPLv2+ (see
the file COPYING), or (at your option) under the GPLv+2 with special the file COPYING), or (at your option) under the GPLv2+ with special
exceptions and restrictions granting the free usage for all binaries exceptions and restrictions granting the free usage for all binaries
including commercial programs (see the file LICENSE). including commercial programs (see the file LICENSE).
+1 -1
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2024 Markus Oberhumer, Laszlo Molnar & John Reiser Copyright (c) 1996-2025 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io https://upx.github.io
+1 -1
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2024 Markus Oberhumer, Laszlo Molnar & John Reiser Copyright (c) 1996-2025 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io https://upx.github.io
+1 -1
View File
@@ -1,5 +1,5 @@
Decompressing ELF Directly to Memory on Linux/x86 Decompressing ELF Directly to Memory on Linux/x86
Copyright (C) 2000-2024 John F. Reiser jreiser@BitWagon.com Copyright (C) 2000-2025 John F. Reiser jreiser@BitWagon.com
References: References:
<elf.h> definitions for the ELF file format <elf.h> definitions for the ELF file format
+4 -4
View File
@@ -22,7 +22,7 @@
<h1 id="ABSTRACT">ABSTRACT</h1> <h1 id="ABSTRACT">ABSTRACT</h1>
<pre><code> The Ultimate Packer for eXecutables <pre><code> The Ultimate Packer for eXecutables
Copyright (c) 1996-2024 Markus Oberhumer, Laszlo Molnar &amp; John Reiser Copyright (c) 1996-2025 Markus Oberhumer, Laszlo Molnar &amp; John Reiser
https://upx.github.io</code></pre> https://upx.github.io</code></pre>
<p><b>UPX</b> is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers <i>*very*</i> fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression.</p> <p><b>UPX</b> is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers <i>*very*</i> fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression.</p>
@@ -783,11 +783,11 @@ John F. Reiser &lt;jreiser@BitWagon.com&gt;</code></pre>
<h1 id="COPYRIGHT">COPYRIGHT</h1> <h1 id="COPYRIGHT">COPYRIGHT</h1>
<p>Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer</p> <p>Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer</p>
<p>Copyright (C) 1996-2024 Laszlo Molnar</p> <p>Copyright (C) 1996-2025 Laszlo Molnar</p>
<p>Copyright (C) 2000-2024 John F. Reiser</p> <p>Copyright (C) 2000-2025 John F. Reiser</p>
<p><b>UPX</b> is distributed with full source code under the terms of the GNU General Public License v2+; either under the pure GPLv2+ (see the file COPYING), or (at your option) under the GPLv+2 with special exceptions and restrictions granting the free usage for all binaries including commercial programs (see the file LICENSE).</p> <p><b>UPX</b> is distributed with full source code under the terms of the GNU General Public License v2+; either under the pure GPLv2+ (see the file COPYING), or (at your option) under the GPLv+2 with special exceptions and restrictions granting the free usage for all binaries including commercial programs (see the file LICENSE).</p>
+4 -4
View File
@@ -6,7 +6,7 @@ SYNOPSIS
ABSTRACT ABSTRACT
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2024 Markus Oberhumer, Laszlo Molnar & John Reiser Copyright (c) 1996-2025 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io https://upx.github.io
UPX is a portable, extendable, high-performance executable packer for UPX is a portable, extendable, high-performance executable packer for
@@ -816,11 +816,11 @@ AUTHORS
John F. Reiser <jreiser@BitWagon.com> John F. Reiser <jreiser@BitWagon.com>
COPYRIGHT COPYRIGHT
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
UPX is distributed with full source code under the terms of the GNU UPX is distributed with full source code under the terms of the GNU
General Public License v2+; either under the pure GPLv2+ (see the file General Public License v2+; either under the pure GPLv2+ (see the file
Generated
+5 -5
View File
@@ -55,7 +55,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "UPX 1" .IX Title "UPX 1"
.TH UPX 1 2024-05-09 "upx 4.2.4" " " .TH UPX 1 2025-07-21 "upx 5.0.3" " "
.\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents. .\" way too many mistakes in technical documents.
.if n .ad l .if n .ad l
@@ -69,7 +69,7 @@ upx \- compress or expand executable files
.IX Header "ABSTRACT" .IX Header "ABSTRACT"
.Vb 3 .Vb 3
\& The Ultimate Packer for eXecutables \& The Ultimate Packer for eXecutables
\& Copyright (c) 1996\-2024 Markus Oberhumer, Laszlo Molnar & John Reiser \& Copyright (c) 1996\-2025 Markus Oberhumer, Laszlo Molnar & John Reiser
\& https://upx.github.io \& https://upx.github.io
.Ve .Ve
.PP .PP
@@ -939,11 +939,11 @@ Please report all bugs immediately to the authors.
.Ve .Ve
.SH COPYRIGHT .SH COPYRIGHT
.IX Header "COPYRIGHT" .IX Header "COPYRIGHT"
Copyright (C) 1996\-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996\-2025 Markus Franz Xaver Johannes Oberhumer
.PP .PP
Copyright (C) 1996\-2024 Laszlo Molnar Copyright (C) 1996\-2025 Laszlo Molnar
.PP .PP
Copyright (C) 2000\-2024 John F. Reiser Copyright (C) 2000\-2025 John F. Reiser
.PP .PP
\&\fBUPX\fR is distributed with full source code under the terms of the \&\fBUPX\fR is distributed with full source code under the terms of the
GNU General Public License v2+; either under the pure GPLv2+ (see GNU General Public License v2+; either under the pure GPLv2+ (see
+4 -4
View File
@@ -13,7 +13,7 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
=head1 ABSTRACT =head1 ABSTRACT
The Ultimate Packer for eXecutables The Ultimate Packer for eXecutables
Copyright (c) 1996-2024 Markus Oberhumer, Laszlo Molnar & John Reiser Copyright (c) 1996-2025 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io https://upx.github.io
@@ -930,11 +930,11 @@ Please report all bugs immediately to the authors.
=head1 COPYRIGHT =head1 COPYRIGHT
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
B<UPX> is distributed with full source code under the terms of the B<UPX> is distributed with full source code under the terms of the
GNU General Public License v2+; either under the pure GPLv2+ (see GNU General Public License v2+; either under the pure GPLv2+ (see
+87 -14
View File
@@ -35,16 +35,35 @@ macro(upx_disallow_in_source_build)
endif() endif()
endmacro() endmacro()
# set the default build type; must be called before project() cmake init # ternary conditional operator
macro(upx_ternary result_var_name condition true_value false_value)
if(${condition})
set(${result_var_name} "${true_value}")
else()
set(${result_var_name} "${false_value}")
endif()
endmacro()
# set the default build type; must be called BEFORE project() cmake init
macro(upx_set_default_build_type type) macro(upx_set_default_build_type type)
set(upx_global_default_build_type "${type}") set(upx_global_default_build_type "${type}")
get_property(upx_global_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) get_property(upx_global_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT upx_global_is_multi_config AND NOT CMAKE_BUILD_TYPE) if(NOT upx_global_is_multi_config AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "${upx_global_default_build_type}" CACHE STRING "Choose the type of build." FORCE) set(CMAKE_BUILD_TYPE "${upx_global_default_build_type}" CACHE STRING "Choose the type of build." FORCE)
endif() endif()
# also enable some global settings by default
if(NOT DEFINED CMAKE_C_STANDARD_REQUIRED)
set(CMAKE_C_STANDARD_REQUIRED ON)
endif()
if(NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(NOT DEFINED CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
endmacro() endmacro()
# set the default multi-config build type; must be called after project() cmake init # set the default multi-config build type; must be called AFTER project() cmake init
macro(upx_apply_build_type) macro(upx_apply_build_type)
if(upx_global_is_multi_config) if(upx_global_is_multi_config)
set(c "${CMAKE_CONFIGURATION_TYPES}") set(c "${CMAKE_CONFIGURATION_TYPES}")
@@ -65,12 +84,34 @@ macro(upx_apply_build_type)
endif() endif()
endmacro() endmacro()
# ternary conditional operator # set MINGW, MSVC_FRONTEND, GNU_FRONTEND and MSVC_SIMULATE
macro(upx_ternary result_var_name condition true_value false_value) macro(upx_set_global_vars)
if(${condition}) if(NOT DEFINED MINGW AND CMAKE_C_PLATFORM_ID MATCHES "^MinGW")
set(${result_var_name} "${true_value}") set(MINGW 1)
endif()
if(NOT DEFINED MSVC_FRONTEND AND (MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC"))
set(MSVC_FRONTEND 1)
elseif(NOT DEFINED GNU_FRONTEND AND (CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^GNU" OR CMAKE_C_COMPILER_ID MATCHES "(Clang|GNU|LLVM)"))
set(GNU_FRONTEND 1)
endif()
if(NOT DEFINED MSVC_SIMULATE AND (CMAKE_C_SIMULATE_ID MATCHES "^MSVC"))
set(MSVC_SIMULATE 1)
endif()
endmacro()
# useful for CI jobs: check for working BUILD_RPATH
macro(upx_check_working_build_rpath var_name)
if(WIN32 OR MINGW OR CYGWIN)
# always works; DLLs reside next to the executables
set(${var_name} ON)
upx_cache_bool_vars(ON ${var_name})
elseif(CMAKE_BUILD_WITH_INSTALL_RPATH OR CMAKE_SKIP_RPATH OR CMAKE_SKIP_BUILD_RPATH)
# cannot work; BUILD_RPATH is disabled by global CMake settings
set(${var_name} OFF)
upx_cache_bool_vars(OFF ${var_name})
else() else()
set(${result_var_name} "${false_value}") # we do not know if/how the BUILD_RPATH is set; be cautious by default
upx_cache_bool_vars(OFF ${var_name})
endif() endif()
endmacro() endmacro()
@@ -97,6 +138,14 @@ function(upx_make_bool_var result_var_name var_name default_value)
set(${result_var_name} "${result}" PARENT_SCOPE) # return value set(${result_var_name} "${result}" PARENT_SCOPE) # return value
endfunction() endfunction()
function(upx_maybe_unused_var) # ARGV
foreach(var_name ${ARGV})
if(DEFINED ${var_name})
set(dummy "${${var_name}}")
endif()
endforeach()
endfunction()
function(upx_print_var) # ARGV function(upx_print_var) # ARGV
foreach(var_name ${ARGV}) foreach(var_name ${ARGV})
if(DEFINED ${var_name}) if(DEFINED ${var_name})
@@ -233,6 +282,14 @@ function(upx_platform_check_mismatch var_name_1 var_name_2)
endif() endif()
endfunction() endfunction()
# check for incompatible C vs CXX settings
function(upx_platform_check_c_cxx_mismatch)
upx_platform_check_mismatch(CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID)
upx_platform_check_mismatch(CMAKE_C_SIMULATE_ID CMAKE_CXX_SIMULATE_ID)
upx_platform_check_mismatch(CMAKE_C_COMPILER_ABI CMAKE_CXX_COMPILER_ABI)
upx_platform_check_mismatch(CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
endfunction()
#*********************************************************************** #***********************************************************************
# compilation flags # compilation flags
#*********************************************************************** #***********************************************************************
@@ -331,6 +388,14 @@ endfunction()
# sanitize a target; note that this may require special run-time support libs from your toolchain # sanitize a target; note that this may require special run-time support libs from your toolchain
function(upx_sanitize_target) # ARGV function(upx_sanitize_target) # ARGV
if(NOT DEFINED UPX_CONFIG_SANITIZE_FLAGS_DEBUG)
# default sanitizer for Debug builds
set(UPX_CONFIG_SANITIZE_FLAGS_DEBUG -fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all)
endif()
if(NOT DEFINED UPX_CONFIG_SANITIZE_FLAGS_RELEASE)
# default sanitizer for Release builds
set(UPX_CONFIG_SANITIZE_FLAGS_RELEASE -fstack-protector)
endif()
foreach(t ${ARGV}) foreach(t ${ARGV})
if(UPX_CONFIG_DISABLE_SANITIZE) if(UPX_CONFIG_DISABLE_SANITIZE)
# no-op # no-op
@@ -348,12 +413,19 @@ function(upx_sanitize_target) # ARGV
# unsupported compiler; unreliable/broken sanitize implementation before gcc-8 (May 2018) # unsupported compiler; unreliable/broken sanitize implementation before gcc-8 (May 2018)
message(WARNING "WARNING: ignoring SANITIZE for target '${t}'") message(WARNING "WARNING: ignoring SANITIZE for target '${t}'")
else() else()
# default sanitizer for Debug builds target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:${UPX_CONFIG_SANITIZE_FLAGS_DEBUG}>)
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>) target_compile_options(${t} PRIVATE $<$<CONFIG:MinSizeRel>:${UPX_CONFIG_SANITIZE_FLAGS_RELEASE}>)
# default sanitizer for Release builds target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:${UPX_CONFIG_SANITIZE_FLAGS_RELEASE}>)
target_compile_options(${t} PRIVATE $<$<CONFIG:MinSizeRel>:-fstack-protector>) target_compile_options(${t} PRIVATE $<$<CONFIG:RelWithDebInfo>:${UPX_CONFIG_SANITIZE_FLAGS_RELEASE}>)
target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:-fstack-protector>) get_target_property(target_type ${t} TYPE)
target_compile_options(${t} PRIVATE $<$<CONFIG:RelWithDebInfo>:-fstack-protector>) if(NOT ",${target_type}," STREQUAL ",STATIC_LIBRARY,")
if(${CMAKE_VERSION} VERSION_GREATER "3.12.99")
target_link_options(${t} PRIVATE $<$<CONFIG:Debug>:${UPX_CONFIG_SANITIZE_FLAGS_DEBUG}>)
target_link_options(${t} PRIVATE $<$<CONFIG:MinSizeRel>:${UPX_CONFIG_SANITIZE_FLAGS_RELEASE}>)
target_link_options(${t} PRIVATE $<$<CONFIG:Release>:${UPX_CONFIG_SANITIZE_FLAGS_RELEASE}>)
target_link_options(${t} PRIVATE $<$<CONFIG:RelWithDebInfo>:${UPX_CONFIG_SANITIZE_FLAGS_RELEASE}>)
endif() # CMAKE_VERSION
endif() # target_type
endif() endif()
endforeach() endforeach()
endfunction() endfunction()
@@ -365,7 +437,8 @@ endfunction()
function(upx_add_test) # ARGV function(upx_add_test) # ARGV
set(name "${ARGV0}") set(name "${ARGV0}")
list(REMOVE_AT ARGV 0) list(REMOVE_AT ARGV 0)
add_test(NAME "${name}" COMMAND ${ARGV}) set(wd "${CMAKE_CURRENT_BINARY_DIR}/XTesting/$<CONFIG>")
add_test(NAME "${name}" WORKING_DIRECTORY "${wd}" COMMAND ${ARGV})
endfunction() endfunction()
function(upx_test_depends) # ARGV function(upx_test_depends) # ARGV
+44 -30
View File
@@ -8,41 +8,55 @@
# print some info about the build configuration # print some info about the build configuration
#*********************************************************************** #***********************************************************************
# generator function(upx_print_info)
upx_print_var(CMAKE_GENERATOR_TOOLSET CMAKE_GENERATOR_PLATFORM) get_property(PROPERTY_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
get_property(PROPERTY_TARGET_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
# directories # generator
if(NOT ",${CMAKE_BINARY_DIR}," STREQUAL ",${CMAKE_CURRENT_BINARY_DIR}," OR NOT ",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_CURRENT_SOURCE_DIR},") upx_print_var(CMAKE_GENERATOR_TOOLSET CMAKE_GENERATOR_PLATFORM)
upx_print_var(CMAKE_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_SOURCE_DIR) upx_print_var(PROPERTY_GENERATOR_IS_MULTI_CONFIG)
endif()
# system # directories
upx_print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION CMAKE_HOST_SYSTEM_PROCESSOR) if(NOT ",${CMAKE_BINARY_DIR}," STREQUAL ",${CMAKE_CURRENT_BINARY_DIR}," OR NOT ",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_CURRENT_SOURCE_DIR},")
upx_print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_SYSTEM_PROCESSOR) upx_print_var(CMAKE_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_SOURCE_DIR)
upx_print_var(CMAKE_ANDROID_NDK CMAKE_ANDROID_NDK_VERSION CMAKE_ANDROID_STANDALONE_TOOLCHAIN) endif()
upx_print_var(CMAKE_APPLE_SILICON_PROCESSOR CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT)
upx_print_Var(CMAKE_CROSSCOMPILING CMAKE_CROSSCOMPILING_EMULATOR)
# binutils # system
upx_print_var(CMAKE_AR CMAKE_RANLIB) upx_print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION CMAKE_HOST_SYSTEM_PROCESSOR)
upx_print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_SYSTEM_PROCESSOR)
upx_print_var(CMAKE_ANDROID_NDK CMAKE_ANDROID_NDK_VERSION CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
upx_print_var(CMAKE_APPLE_SILICON_PROCESSOR CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT)
upx_print_var(CMAKE_VS_PLATFORM_TOOLSET CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE CMAKE_VS_PLATFORM_TOOLSET_VERSION)
upx_print_var(CMAKE_CROSSCOMPILING CMAKE_CROSSCOMPILING_EMULATOR)
upx_print_var(CMAKE_SIZEOF_VOID_P)
# compilers # binutils
foreach(lang IN ITEMS ASM C CXX) upx_print_var(CMAKE_EXECUTABLE_FORMAT CMAKE_EXECUTABLE_SUFFIX UPX_CONFIG_CMAKE_EXECUTABLE_SUFFIX)
upx_print_var(CMAKE_${lang}_COMPILER_LAUNCHER) upx_print_var(CMAKE_AR CMAKE_RANLIB)
upx_print_var(CMAKE_${lang}_COMPILER)
upx_print_var(CMAKE_${lang}_COMPILER_ID)
upx_print_var(CMAKE_${lang}_COMPILER_VERSION)
upx_print_var(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT )
upx_print_var(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID)
upx_print_var(CMAKE_${lang}_PLATFORM_ID)
upx_print_var(CMAKE_${lang}_COMPILER_ABI)
upx_print_var(CMAKE_${lang}_COMPILER_TARGET)
endforeach()
# misc # compilers
upx_print_var(CMAKE_INTERPROCEDURAL_OPTIMIZATION CMAKE_POSITION_INDEPENDENT_CODE) foreach(lang IN ITEMS ASM C CXX)
upx_print_var(CMAKE_${lang}_COMPILER_LAUNCHER)
upx_print_var(CMAKE_${lang}_COMPILER)
upx_print_var(CMAKE_${lang}_COMPILER_ARG1)
upx_print_var(CMAKE_${lang}_COMPILER_ID)
upx_print_var(CMAKE_${lang}_SIMULATE_ID)
upx_print_var(CMAKE_${lang}_COMPILER_VERSION)
upx_print_var(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT)
upx_print_var(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID)
upx_print_var(CMAKE_${lang}_PLATFORM_ID)
upx_print_var(CMAKE_${lang}_COMPILER_ABI)
upx_print_var(CMAKE_${lang}_COMPILER_TARGET)
endforeach()
# shortcuts # misc
upx_print_var(APPLE CLANG CYGWIN GNU_FRONTEND GNUC MINGW MSVC MSVC_FRONTEND MSVC_IDE MSVC_TOOLSET_VERSION MSVC_VERSION MSYS UNIX WIN32 WIN64) upx_print_var(CMAKE_BUILD_WITH_INSTALL_RPATH CMAKE_SKIP_RPATH CMAKE_SKIP_BUILD_RPATH CMAKE_SKIP_INSTALL_RPATH)
upx_print_var(CMAKE_INTERPROCEDURAL_OPTIMIZATION CMAKE_POSITION_INDEPENDENT_CODE)
upx_print_var(PROPERTY_TARGET_SUPPORTS_SHARED_LIBS)
upx_print_var(UPX_CONFIG_SANITIZE_FLAGS_DEBUG UPX_CONFIG_SANITIZE_FLAGS_RELEASE)
# shortcuts
upx_print_var(AIX APPLE CLANG CYGWIN GNU_FRONTEND GNUC MINGW MSVC MSVC_FRONTEND MSVC_IDE MSVC_SIMULATE MSVC_TOOLSET_VERSION MSVC_VERSION MSYS UNIX WIN32 WIN64)
endfunction()
# vim:set ft=cmake ts=4 sw=4 tw=0 et: # vim:set ft=cmake ts=4 sw=4 tw=0 et:
+36 -27
View File
@@ -10,6 +10,8 @@
# is supported by UPX! # is supported by UPX!
#*********************************************************************** #***********************************************************************
function(upx_self_pack_test)
set(emu "") set(emu "")
if(DEFINED CMAKE_CROSSCOMPILING_EMULATOR) if(DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
set(emu "${CMAKE_CROSSCOMPILING_EMULATOR}") set(emu "${CMAKE_CROSSCOMPILING_EMULATOR}")
@@ -114,35 +116,42 @@ endif()
if(NOT UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS) if(NOT UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS)
foreach(method IN ITEMS nrv2b nrv2d nrv2e lzma) foreach(method IN ITEMS nrv2b nrv2d nrv2e lzma)
foreach(level IN ITEMS 1 2 3 4 5 6 7) foreach(level IN ITEMS 1 2 3 4 5 6 7)
set(s "${method}-${level}") foreach(small IN ITEMS normal small)
upx_add_test(upx-self-pack-${s} upx --${method} -${level} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe}) set(s "${method}-${level}")
upx_add_test(upx-list-${s} upx -l upx-packed-${s}${exe}) set(ss "")
upx_add_test(upx-fileinfo-${s} upx --fileinfo upx-packed-${s}${exe}) if(small MATCHES "small")
upx_add_test(upx-test-${s} upx -t upx-packed-${s}${exe}) set(s "${method}-${level}-${small}")
upx_add_test(upx-unpack-${s} upx -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe}) set(ss "--small")
upx_add_test(upx-compare-${s} "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-${s}${exe}) endif()
upx_test_depends(upx-list-${s} upx-self-pack-${s}) upx_add_test(upx-self-pack-${s} upx --${method} -${level} ${ss} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe})
upx_test_depends(upx-fileinfo-${s} upx-self-pack-${s}) upx_add_test(upx-list-${s} upx -l upx-packed-${s}${exe})
upx_test_depends(upx-test-${s} upx-self-pack-${s}) upx_add_test(upx-fileinfo-${s} upx --fileinfo upx-packed-${s}${exe})
upx_test_depends(upx-unpack-${s} upx-self-pack-${s}) upx_add_test(upx-test-${s} upx -t upx-packed-${s}${exe})
upx_test_depends(upx-compare-${s} "upx-unpack;upx-unpack-${s}") upx_add_test(upx-unpack-${s} upx -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe})
if(method MATCHES "lzma") upx_add_test(upx-compare-${s} "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-${s}${exe})
set_tests_properties(upx-self-pack-${s} PROPERTIES COST "3${level}") upx_test_depends(upx-list-${s} upx-self-pack-${s})
else() upx_test_depends(upx-fileinfo-${s} upx-self-pack-${s})
set_tests_properties(upx-self-pack-${s} PROPERTIES COST "2${level}") upx_test_depends(upx-test-${s} upx-self-pack-${s})
endif() upx_test_depends(upx-unpack-${s} upx-self-pack-${s})
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST) upx_test_depends(upx-compare-${s} "upx-unpack;upx-unpack-${s}")
upx_add_test(upx-run-packed-${s} ${emu} ./upx-packed-${s}${exe} --version-short) if(method MATCHES "lzma")
upx_test_depends(upx-run-packed-${s} upx-self-pack-${s}) set_tests_properties(upx-self-pack-${s} PROPERTIES COST "3${level}")
endif() else()
set_tests_properties(upx-self-pack-${s} PROPERTIES COST "2${level}")
endif()
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST)
set(i 0)
while(${i} LESS 20)
math(EXPR i "${i} + 1")
upx_add_test(upx-run-packed-${s}-${i} ${emu} ./upx-packed-${s}${exe} --version-short)
upx_test_depends(upx-run-packed-${s}-${i} upx-self-pack-${s})
endwhile()
endif()
endforeach()
endforeach() endforeach()
endforeach() endforeach()
endif () # UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS endif() # UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS
# clean up endfunction()
set(emu "")
set(exe "")
set(upx_self_exe "")
set(fo "")
# vim:set ft=cmake ts=4 sw=4 tw=0 et: # vim:set ft=cmake ts=4 sw=4 tw=0 et:
+11
View File
@@ -0,0 +1,11 @@
#
# UPX "CMake" build file; see https://cmake.org/
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
#
if(NOT DEFINED USE_STRICT_DEFAULTS)
# use strict config defaults for Git developer builds
set(USE_STRICT_DEFAULTS TRUE CACHE INTERNAL "" FORCE)
endif()
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
+70 -17
View File
@@ -20,7 +20,7 @@ override ne = $(if $(subst x$1,,x$2)$(subst x$2,,x$1),1,)
override tolower = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) override tolower = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
override toupper = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))) override toupper = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
# canonicalize case of CMAKE_BUILD_TYPE to "Debug" and "Release" # canonicalize the case of CMAKE_BUILD_TYPE to "Debug" and "Release"
override cm_build_type = $(if $(call eq,$1,),$(error EMPTY-build-type),$(if $(call eq,$(call tolower,$1),debug),Debug,$(if $(call eq,$(call tolower,$1),release),Release,$(if $(call eq,$(call tolower,$1),none),None,$1)))) override cm_build_type = $(if $(call eq,$1,),$(error EMPTY-build-type),$(if $(call eq,$(call tolower,$1),debug),Debug,$(if $(call eq,$(call tolower,$1),release),Release,$(if $(call eq,$(call tolower,$1),none),None,$1))))
#*********************************************************************** #***********************************************************************
@@ -59,39 +59,63 @@ build/extra/clang-m64/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/clang-m64/%: export CC = clang -m64 build/extra/clang-m64/%: export CC = clang -m64
build/extra/clang-m64/%: export CXX = clang++ -m64 build/extra/clang-m64/%: export CXX = clang++ -m64
# force building with clang/clang++ -flto=auto
build/extra/clang-lto-auto/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/clang-lto-auto/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/clang-lto-auto/%: export CC = clang -flto=auto
build/extra/clang-lto-auto/%: export CXX = clang++ -flto=auto
# force building with clang/clang++ -pie
build/extra/clang-pie/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/clang-pie/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/clang-pie/%: export CC = clang -pie -fPIE -Wno-unused-command-line-argument
build/extra/clang-pie/%: export CXX = clang++ -pie -fPIE -Wno-unused-command-line-argument
build/extra/clang-pie/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with clang/clang++ -static # force building with clang/clang++ -static
build/extra/clang-static/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/clang-static/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/clang-static/release: PHONY; $(call run_config_and_build,$@,Release) 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 CC = clang -static
build/extra/clang-static/%: export CXX = clang++ -static build/extra/clang-static/%: export CXX = clang++ -static
build/extra/clang-static/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with clang/clang++ -static-pie # 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/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/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 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 build/extra/clang-static-pie/%: export CXX = clang++ -static-pie -fPIE -Wno-unused-command-line-argument
build/extra/clang-static-pie/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with clang/clang++ -static -flto # 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/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/clang-static-lto/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/clang-static-lto/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/clang-static-lto/%: export CC = clang -static -flto build/extra/clang-static-lto/%: export CC = clang -static -flto
build/extra/clang-static-lto/%: export CXX = clang++ -static -flto build/extra/clang-static-lto/%: export CXX = clang++ -static -flto
build/extra/clang-static-lto/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with clang/clang++ C17/C++20 # force building with clang/clang++ C++20 (and C17)
build/extra/clang-std-cxx20/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/clang-std-cxx20/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/clang-std-cxx20/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/clang-std-cxx20/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/clang-std-cxx20/%: export CC = clang -std=gnu17 build/extra/clang-std-cxx20/%: export CC = clang -std=gnu17
build/extra/clang-std-cxx20/%: export CXX = clang++ -std=gnu++20 build/extra/clang-std-cxx20/%: export CXX = clang++ -std=gnu++20
build/extra/clang-std-cxx20/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON build/extra/clang-std-cxx20/%: export UPX_CONFIG_DISABLE_C_STANDARD = ON
build/extra/clang-std-cxx20/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON build/extra/clang-std-cxx20/%: export UPX_CONFIG_DISABLE_CXX_STANDARD = ON
# force building with clang/clang++ C23/C++23 # force building with clang/clang++ C++23 (and C23)
build/extra/clang-std-cxx23/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/clang-std-cxx23/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/clang-std-cxx23/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/clang-std-cxx23/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/clang-std-cxx23/%: export CC = clang -std=gnu2x build/extra/clang-std-cxx23/%: export CC = clang -std=gnu2x -Wno-constant-logical-operand
build/extra/clang-std-cxx23/%: export CXX = clang++ -std=gnu++2b build/extra/clang-std-cxx23/%: export CXX = clang++ -std=gnu++2b
build/extra/clang-std-cxx23/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON build/extra/clang-std-cxx23/%: export UPX_CONFIG_DISABLE_C_STANDARD = ON
build/extra/clang-std-cxx23/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON build/extra/clang-std-cxx23/%: export UPX_CONFIG_DISABLE_CXX_STANDARD = ON
# force building with clang/clang++ C++26 (and C23)
build/extra/clang-std-cxx26/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/clang-std-cxx26/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/clang-std-cxx26/%: export CC = clang -std=gnu2x -Wno-constant-logical-operand
build/extra/clang-std-cxx26/%: export CXX = clang++ -std=gnu++2c
build/extra/clang-std-cxx26/%: export UPX_CONFIG_DISABLE_C_STANDARD = ON
build/extra/clang-std-cxx26/%: export UPX_CONFIG_DISABLE_CXX_STANDARD = ON
# force building with gcc/g++ # force building with gcc/g++
build/extra/gcc/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/gcc/debug: PHONY; $(call run_config_and_build,$@,Debug)
@@ -117,39 +141,63 @@ build/extra/gcc-m64/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-m64/%: export CC = gcc -m64 build/extra/gcc-m64/%: export CC = gcc -m64
build/extra/gcc-m64/%: export CXX = g++ -m64 build/extra/gcc-m64/%: export CXX = g++ -m64
# force building with gcc/g++ -flto=auto
build/extra/gcc-lto-auto/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/gcc-lto-auto/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-lto-auto/%: export CC = gcc -flto=auto
build/extra/gcc-lto-auto/%: export CXX = g++ -flto=auto
# force building with gcc/g++ -pie
build/extra/gcc-pie/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/gcc-pie/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-pie/%: export CC = gcc -pie -fPIE
build/extra/gcc-pie/%: export CXX = g++ -pie -fPIE
build/extra/gcc-pie/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with gcc/g++ -static # force building with gcc/g++ -static
build/extra/gcc-static/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/gcc-static/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/gcc-static/release: PHONY; $(call run_config_and_build,$@,Release) 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 CC = gcc -static
build/extra/gcc-static/%: export CXX = g++ -static build/extra/gcc-static/%: export CXX = g++ -static
build/extra/gcc-static/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with gcc/g++ -static-pie # 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/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/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 CC = gcc -static-pie -fPIE
build/extra/gcc-static-pie/%: export CXX = g++ -static-pie -fPIE build/extra/gcc-static-pie/%: export CXX = g++ -static-pie -fPIE
build/extra/gcc-static-pie/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with gcc/g++ -static -flto # 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/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/gcc-static-lto/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/gcc-static-lto/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-static-lto/%: export CC = gcc -static -flto build/extra/gcc-static-lto/%: export CC = gcc -static -flto
build/extra/gcc-static-lto/%: export CXX = g++ -static -flto build/extra/gcc-static-lto/%: export CXX = g++ -static -flto
build/extra/gcc-static-lto/%: export UPX_CONFIG_DISABLE_SHARED_LIBS = ON
# force building with gcc/g++ C17/C++20 # force building with gcc/g++ C++20 (and C17)
build/extra/gcc-std-cxx20/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/gcc-std-cxx20/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/gcc-std-cxx20/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/gcc-std-cxx20/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-std-cxx20/%: export CC = gcc -std=gnu17 build/extra/gcc-std-cxx20/%: export CC = gcc -std=gnu17
build/extra/gcc-std-cxx20/%: export CXX = g++ -std=gnu++20 build/extra/gcc-std-cxx20/%: export CXX = g++ -std=gnu++20
build/extra/gcc-std-cxx20/%: export UPX_CONFIG_DISABLE_C_STANDARD=ON build/extra/gcc-std-cxx20/%: export UPX_CONFIG_DISABLE_C_STANDARD = ON
build/extra/gcc-std-cxx20/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON build/extra/gcc-std-cxx20/%: export UPX_CONFIG_DISABLE_CXX_STANDARD = ON
# force building with gcc/g++ C23/C++23 # force building with gcc/g++ C++23 (and C23)
build/extra/gcc-std-cxx23/debug: PHONY; $(call run_config_and_build,$@,Debug) 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/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-std-cxx23/%: export CC = gcc -std=gnu2x build/extra/gcc-std-cxx23/%: export CC = gcc -std=gnu2x
build/extra/gcc-std-cxx23/%: export CXX = g++ -std=gnu++2b 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_C_STANDARD = ON
build/extra/gcc-std-cxx23/%: export UPX_CONFIG_DISABLE_CXX_STANDARD=ON build/extra/gcc-std-cxx23/%: export UPX_CONFIG_DISABLE_CXX_STANDARD = ON
# force building with gcc/g++ C++26 (and C23)
build/extra/gcc-std-cxx26/debug: PHONY; $(call run_config_and_build,$@,Debug)
build/extra/gcc-std-cxx26/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-std-cxx26/%: export CC = gcc -std=gnu23
build/extra/gcc-std-cxx26/%: export CXX = g++ -std=gnu++26
build/extra/gcc-std-cxx26/%: export UPX_CONFIG_DISABLE_C_STANDARD = ON
build/extra/gcc-std-cxx26/%: export UPX_CONFIG_DISABLE_CXX_STANDARD = ON
# cross compiler: Linux glibc aarch64-linux-gnu (arm64) # cross compiler: Linux glibc aarch64-linux-gnu (arm64)
build/extra/cross-linux-gnu-aarch64/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/cross-linux-gnu-aarch64/debug: PHONY; $(call run_config_and_build,$@,Debug)
@@ -216,7 +264,7 @@ build/analyze/clang-analyzer/%: export CCC_CXX ?= clang++
# run clang-tidy: uses file compile_commands.json from an existing clang build; # run clang-tidy: uses file compile_commands.json from an existing clang build;
# does not create any actual files, so purely PHONY # does not create any actual files, so purely PHONY
CLANG_TIDY_BUILD_BASE = build/extra/clang CLANG_TIDY_BUILD_BASE = build/extra/clang
RUN_CLANG_TIDY = time python3 ./misc/analyze/clang-tidy/run-clang-tidy.py -p $< RUN_CLANG_TIDY = time python3 ./misc/analyze/clang-tidy/run-clang-tidy.py -p "$<"
RUN_CLANG_TIDY_WERROR = $(RUN_CLANG_TIDY) '-warnings-as-errors=*' RUN_CLANG_TIDY_WERROR = $(RUN_CLANG_TIDY) '-warnings-as-errors=*'
build/analyze/clang-tidy-upx/debug build/analyze/clang-tidy-upx/release: $$(CLANG_TIDY_BUILD_BASE)/$$(notdir $$@) PHONY build/analyze/clang-tidy-upx/debug build/analyze/clang-tidy-upx/release: $$(CLANG_TIDY_BUILD_BASE)/$$(notdir $$@) PHONY
$(RUN_CLANG_TIDY_WERROR) -config-file ./.clang-tidy '/src/.*\.cpp' $(RUN_CLANG_TIDY_WERROR) -config-file ./.clang-tidy '/src/.*\.cpp'
@@ -256,12 +304,12 @@ build/$(UPX_XTARGET)/release: PHONY; $(call run_config_and_build,$@,Release)
build/$(UPX_XTARGET)/%: export CC := $(CC) build/$(UPX_XTARGET)/%: export CC := $(CC)
build/$(UPX_XTARGET)/%: export CXX := $(CXX) build/$(UPX_XTARGET)/%: export CXX := $(CXX)
# shortcuts # shortcuts
xtarget/all: xtarget/debug xtarget/release PHONY
xtarget/debug: build/$(UPX_XTARGET)/debug PHONY xtarget/debug: build/$(UPX_XTARGET)/debug PHONY
xtarget/release: build/$(UPX_XTARGET)/release 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/debug+test: build/$(UPX_XTARGET)/debug+test PHONY
xtarget/release+test: build/$(UPX_XTARGET)/release+test PHONY xtarget/release+test: build/$(UPX_XTARGET)/release+test PHONY
xtarget/all+test: xtarget/debug+test xtarget/release+test PHONY
# set new default # set new default
.DEFAULT_GOAL := build/$(UPX_XTARGET)/release .DEFAULT_GOAL := build/$(UPX_XTARGET)/release
@@ -276,11 +324,16 @@ endif
# it easy to set other variables like CMAKE_AR or CMAKE_RANLIB # it easy to set other variables like CMAKE_AR or CMAKE_RANLIB
#*********************************************************************** #***********************************************************************
UPX_CMAKE_CONFIG_FLAGS += $(UPX_CMAKE_CONFIG_FLAGS_GENERATOR)
UPX_CMAKE_CONFIG_FLAGS += $(UPX_CMAKE_CONFIG_FLAGS_TOOLSET)
UPX_CMAKE_CONFIG_FLAGS += $(UPX_CMAKE_CONFIG_FLAGS_PLATFORM)
$(call check_undefined,__add_cmake_config) $(call check_undefined,__add_cmake_config)
# promote an environment or Make variable to a CMake cache entry: # promote an environment or Make variable to a CMake cache entry:
__add_cmake_config = $(and $($1),-D$1="$($1)") __add_cmake_config = $(and $($1),-D$1="$($1)")
# pass common CMake settings # pass common CMake settings
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_INSTALL_PREFIX)
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_VERBOSE_MAKEFILE) UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_VERBOSE_MAKEFILE)
# pass common CMake toolchain settings # pass common CMake toolchain settings
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_ADDR2LINE) UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_ADDR2LINE)
+29
View File
@@ -0,0 +1,29 @@
From 741b9d2f24b5796fc499a411f632820ab4f889e5 Mon Sep 17 00:00:00 2001
From: "Markus F.X.J. Oberhumer" <markus@oberhumer.com>
Date: Wed, 9 Apr 2025 20:00:24 +0200
Subject: [PATCH] x
---
lib/libcxx/include/__config | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/libcxx/include/__config b/lib/libcxx/include/__config
index fec323f..a16d145 100644
--- a/lib/libcxx/include/__config
+++ b/lib/libcxx/include/__config
@@ -637,9 +637,11 @@ typedef __char32_t char32_t;
# define _DECLARE_C99_LDBL_MATH 1
# endif
+# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
+# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
// If we are getting operator new from the MSVC CRT, then allocation overloads
// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
-# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+# elif defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
# elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
// We're deferring to Microsoft's STL to provide aligned new et al. We don't
--
2.49.0
+16 -12
View File
@@ -8,18 +8,20 @@ ENV LANG=C.UTF-8
RUN dpkg --add-architecture i386 \ RUN dpkg --add-architecture i386 \
&& apt-get update && apt-get upgrade -y \ && apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
aria2 bash bash-completion ca-certificates curl git less libmpc3 \ aria2 bash bash-completion ca-certificates coreutils curl diffutils findutils git grep gzip \
make ncurses-term perl-base tar time wget xz-utils \ less libmpc3 make ncurses-term perl-base sed sudo tar time util-linux wget xz-utils \
libc6:i386 zlib1g:i386 \ libc6:i386 zlib1g:i386 \
# the following packages are not required for rebuilding the stubs, but # the following packages are not required for rebuilding the stubs, but
# they do make the image *much* more convenient and also allow building # they do make the image *much* more convenient and also allow building
# the full UPX binary inside the container via CMake: # the full UPX binary inside the container via CMake:
7zip bfs bubblewrap busybox bzip2 bzip3 cabextract ccache chrpath cmake cpio dash diffstat \ 7zip bat bfs btop bubblewrap busybox bzip2 bzip3 cabextract ccache chrpath cmake cpio \
elfutils execstack fd-find file fish fzf g++ gawk gdb gojq ht htop hyperfine jq ksh \ dash diffstat direnv dmidecode elfutils execstack eza fd-find file fish fzf \
libzstd-dev lsb-release lz4 lzip lzop minify mksh moreutils musl neovim ninja-build \ g++ gawk gdb gh gojq ht htop hyperfine jq just ksh \
lftp libzstd-dev lsb-release lsd lz4 lzip lzop minify mksh moreutils musl neovim ninja-build \
p7zip parallel patch patchelf patchutils pax-utils proot \ 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 \
re2c ripgrep rsync screen strace universal-ctags unzip valgrind yash yq \ python3-yaml python3-zstd \
re2c ripgrep rsync screen socat strace universal-ctags unzip valgrind yash yq \
zip zlib1g-dev zoxide zsh zstd \ zip zlib1g-dev zoxide zsh zstd \
# extra packages for compiling with "gcc -m32" and "gcc -mx32": # extra packages for compiling with "gcc -m32" and "gcc -mx32":
g++-multilib gcc-multilib \ g++-multilib gcc-multilib \
@@ -59,9 +61,9 @@ RUN cd /root \
# install official UPX release binaries into /usr/local/bin; not required but convenient for testing # install official UPX release binaries into /usr/local/bin; not required but convenient for testing
RUN cd /root \ RUN cd /root \
&& wget -q https://github.com/upx/upx/releases/download/v3.91/upx-3.91-amd64_linux.tar.bz2 \ && curl -sS -L -O https://github.com/upx/upx/releases/download/v3.91/upx-3.91-amd64_linux.tar.bz2 \
&& xzversions="3.92 3.93 3.94 3.95 3.96 4.0.0 4.0.1 4.0.2 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3" \ && xzversions="3.92 3.93 3.94 3.95 3.96 4.0.0 4.0.1 4.0.2 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 5.0.0 5.0.1 5.0.2" \
&& for v in $xzversions; do wget -q https://github.com/upx/upx/releases/download/v${v}/upx-${v}-amd64_linux.tar.xz; done \ && for v in $xzversions; do curl -sS -L -O https://github.com/upx/upx/releases/download/v${v}/upx-${v}-amd64_linux.tar.xz; done \
&& for f in ./upx-*.tar.*; do tar -xoaf $f; done \ && for f in ./upx-*.tar.*; do tar -xoaf $f; done \
&& for v in 3.91 $xzversions; do d=upx-${v}-amd64_linux; ./$d/upx -qq -d $d/upx -o /usr/local/bin/upx-${v}; done \ && for v in 3.91 $xzversions; do d=upx-${v}-amd64_linux; ./$d/upx -qq -d $d/upx -o /usr/local/bin/upx-${v}; done \
&& rm -r ./upx-*.tar.* ./upx-*linux \ && rm -r ./upx-*.tar.* ./upx-*linux \
@@ -79,15 +81,17 @@ RUN useradd upx -U --uid 2000 --shell /bin/bash -m \
# symlink upx-stubtools # symlink upx-stubtools
&& ln -s /usr/local/bin/bin-upx-20221212 .local/bin/bin-upx \ && ln -s /usr/local/bin/bin-upx-20221212 .local/bin/bin-upx \
# some convenience settings according to upx developer preferences # some convenience settings according to upx developer preferences
&& echo "alias path='echo PATH=\"\$PATH\"'" >> .bashrc \
&& echo "alias md=mkdir" >> .bashrc \ && echo "alias md=mkdir" >> .bashrc \
&& echo "alias rd=rmdir" >> .bashrc \ && echo "alias rd=rmdir" >> .bashrc \
&& echo 'mdd() { mkdir "$1" && cd "$1"; }' >> .bashrc \ && echo 'mdd() { mkdir "$1" && cd "$1"; }' >> .bashrc \
&& echo 'm() { make "$@"; }' >> .bashrc \ && echo 'm() { make "$@"; }' >> .bashrc \
&& echo 'mm() { make -j8 "$@"; }' >> .bashrc \
&& echo 'tn() { time nice "$@"; }' >> .bashrc \ && echo 'tn() { time nice "$@"; }' >> .bashrc \
&& echo 'tnm() { time nice make "$@"; }' >> .bashrc \ && echo 'tnm() { time nice make "$@"; }' >> .bashrc \
&& echo 'tnmm() { time nice make -j "$@"; }' >> .bashrc \ && echo 'tnmm() { time nice make -j8 "$@"; }' >> .bashrc \
&& echo 'source /usr/share/bash-completion/completions/make' >> .bashrc \ && echo 'source /usr/share/bash-completion/completions/make' >> .bashrc \
&& echo 'complete -F _make m tnm tnmm' >> .bashrc \ && echo 'complete -F _make m mm tnm tnmm' >> .bashrc \
&& echo 'eval "$(zoxide init bash)"' >> .bashrc \ && echo 'eval "$(zoxide init bash)"' >> .bashrc \
&& echo "alias zz=zi\nalias y=z\nalias yy=zi" >> .bashrc \ && echo "alias zz=zi\nalias y=z\nalias yy=zi" >> .bashrc \
&& echo "alias cd..='cd ..'" >> .bashrc \ && echo "alias cd..='cd ..'" >> .bashrc \
+323 -289
View File
File diff suppressed because it is too large Load Diff
+4 -5
View File
@@ -25,13 +25,12 @@ LC_ALL=C sort -z | xargs -0r perl -n -e '
if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); } if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); } if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) { if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files if ($ARGV =~ m,\.patch$,) { }
if ($1 ne " " || $ARGV !~ m,\.md$,) { else { print "ERROR: trailing whitespace detected $ARGV: $_"; exit(1); }
print "ERROR: trailing whitespace detected $ARGV: $_"; exit(1);
}
} }
if (m,\t,) { if (m,\t,) {
if ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { } if ($ARGV =~ m,\.patch$,) { }
elsif ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
elsif ($ARGV =~ m,\.mk$,) { } elsif ($ARGV =~ m,\.mk$,) { }
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { } elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { } elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { }
+4 -5
View File
@@ -19,13 +19,12 @@ git ls-files --full-name -z | perl -0 -n -e '
if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); } if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); } if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) { if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files if ($ARGV =~ m,\.patch$,) { }
if ($1 ne " " || $ARGV !~ m,\.md$,) { else { print "ERROR: trailing whitespace detected $ARGV: $_"; exit(1); }
print "ERROR: trailing whitespace detected $ARGV: $_"; exit(1);
}
} }
if (m,\t,) { if (m,\t,) {
if ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { } if ($ARGV =~ m,\.patch$,) { }
elsif ($ARGV =~ m,(^|/)(gnu|m)?make(file|vars),i) { }
elsif ($ARGV =~ m,\.mk$,) { } elsif ($ARGV =~ m,\.mk$,) { }
elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { } elsif ($ARGV =~ m,/tmp/.*\.(disasm|dump)$,) { }
elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { } elsif ($ARGV =~ m,/src/stub/src/arch/.*/lzma\w+\.S$,) { }
+1 -1
View File
@@ -14,7 +14,7 @@ __add_cmake_config() {
} }
# pass common CMake settings # pass common CMake settings
for v in CMAKE_VERBOSE_MAKEFILE; do for v in CMAKE_INSTALL_PREFIX CMAKE_VERBOSE_MAKEFILE; do
__add_cmake_config $v __add_cmake_config $v
done done
# pass common CMake toolchain settings # pass common CMake toolchain settings
+1 -1
View File
@@ -29,6 +29,6 @@ fi
# limit memory usage to 1 GiB (in case of clang-format problems with invalid files) # limit memory usage to 1 GiB (in case of clang-format problems with invalid files)
ulimit -v 1048576 || true ulimit -v 1048576 || true
#echo $UPX_CLANG_FORMAT #echo "$UPX_CLANG_FORMAT"
exec "$UPX_CLANG_FORMAT" -style=file "$@" exec "$UPX_CLANG_FORMAT" -style=file "$@"
exit 99 exit 99
+31 -14
View File
@@ -6,8 +6,9 @@ argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs")
# #
# Copyright (C) Markus Franz Xaver Johannes Oberhumer # Copyright (C) Markus Franz Xaver Johannes Oberhumer
# #
# mimic running "ctest", i.e. the "test" section of CMakeLists.txt; does not redirect stdout # mimic running "ctest", i.e. the "test" section of CMakeLists.txt
# (allows freely setting $upx_exe_runner, while CMake is restricted to configure-time settings) # - does not redirect stdout
# - allows freely setting $upx_exe_runner, while CMake is restricted to configure-time settings
# #
# requires: # requires:
# $upx_exe (required, but with convenience fallback "./upx") # $upx_exe (required, but with convenience fallback "./upx")
@@ -15,6 +16,12 @@ argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs")
# $upx_exe_runner (e.g. "qemu-x86_64 -cpu Nehalem" or "valgrind") # $upx_exe_runner (e.g. "qemu-x86_64 -cpu Nehalem" or "valgrind")
# #
# Debugging aid for locating failing commands. Depends on 'bash' shell.
# (BASH_LINENO is relative to current FUNCTION only; non-function ==> 0)
# Notice single-quoting of entire first argument.
trap 'echo ERROR: pwd=\"$PWD\" file=\"$BASH_SOURCE\" line=${BASH_LINENO[0]} cmd=\"$BASH_COMMAND\"' ERR
# Example: "false a b c" ==> ERROR: pwd="path/misc/testsuite" file="./mimic_ctest.sh" line=0 cmd="false a b c"
#*********************************************************************** #***********************************************************************
# init & checks # init & checks
#*********************************************************************** #***********************************************************************
@@ -48,7 +55,7 @@ if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help
#*********************************************************************** #***********************************************************************
# see CMakeLists.txt # see CMakeLists.txt
# #
# IDEA: create a Makefile and use "make -j" so that these tests can # IDEA: create a Makefile and use "make -j8" so that these tests can
# run in parallel much like "ctest --parallel 8" # run in parallel much like "ctest --parallel 8"
#*********************************************************************** #***********************************************************************
@@ -147,17 +154,27 @@ if [[ $UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS != ON ]]; then
set +x set +x
for method in nrv2b nrv2d nrv2e lzma; do for method in nrv2b nrv2d nrv2e lzma; do
for level in 1 2 3 4 5 6 7; do for level in 1 2 3 4 5 6 7; do
s="${method}-${level}" for small in normal small; do
echo "========== $s ==========" s="${method}-${level}"
"${run_upx[@]}" -qq --${method} -${level} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe} ss=
"${run_upx[@]}" -qq -l upx-packed-${s}${exe} if [[ $small == "small" ]]; then
"${run_upx[@]}" -qq --fileinfo upx-packed-${s}${exe} s="${method}-${level}-${small}"
"${run_upx[@]}" -qq -t upx-packed-${s}${exe} ss="--small"
"${run_upx[@]}" -qq -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe} fi
cmp -s upx-unpacked${exe} upx-unpacked-${s}${exe} echo "========== $s =========="
if [[ $UPX_CONFIG_DISABLE_RUN_PACKED_TEST != ON ]]; then "${run_upx[@]}" -qq --${method} -${level} ${ss} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe}
"${emu[@]}" ./upx-packed-${s}${exe} --version-short "${run_upx[@]}" -qq -l upx-packed-${s}${exe}
fi "${run_upx[@]}" -qq --fileinfo upx-packed-${s}${exe}
"${run_upx[@]}" -qq -t upx-packed-${s}${exe}
"${run_upx[@]}" -qq -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe}
cmp -s upx-unpacked${exe} upx-unpacked-${s}${exe}
if [[ $UPX_CONFIG_DISABLE_RUN_PACKED_TEST != ON ]]; then
: ${upx_run_packed_test_count:=20}
for ((i = 0; i < $upx_run_packed_test_count; i++)); do
"${emu[@]}" ./upx-packed-${s}${exe} --version-short
done
fi
done
done done
done done
fi fi
+46
View File
@@ -0,0 +1,46 @@
#! /usr/bin/env bash
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs")
#
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
#
# mimic running "ctest", i.e. the "test" section of CMakeLists.txt
# - does not redirect stdout
# - allows freely setting $upx_exe_runner, while CMake is restricted to configure-time settings
#
# requires:
# $upx_exe (required, but with convenience fallback "./upx")
# optional settings:
# $upx_exe_runner (e.g. "qemu-x86_64 -cpu Nehalem" or "valgrind")
#
cat >catch-sigsegv.gdb <<'EOF'
catch signal SIGSEGV
commands
x/i $pc
info reg
x/32i $pc-0x20
quit 77
end
EOF
catcher=$(readlink -fn catch-sigsegv.gdb)
function emu_gdb() {
gdb -q -x "$catcher" <<EOF --args "$@"
run
EOF
}
if [[ -n $upx_exe_runner ]]; then
true
elif [[ -n $CMAKE_CROSSCOMPILING_EMULATOR ]]; then
true
else
upx_exe_runner=emu_gdb
: ${upx_run_packed_test_count:=20}
fi
source "$argv0dir/mimic_ctest.sh"
+147 -147
View File
@@ -46,164 +46,164 @@ b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.
a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95 a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95
" "
expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\ expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\
ef49d1c9617dbb3dc1bb36ab70df8a263cd816cc5e91ad28cc62f91ccc77afa7 *amd64-linux.elf/upx-3.91 836d9c5d9092421e49aeb573cde449ef740afbfea54d131ccbd88d8c7d87860d *amd64-linux.elf/upx-3.91
253b1542cdcd5d554eb442e263eb44e400f00e63cfd4d0d727eacec5fcdbbd00 *amd64-linux.elf/upx-3.95 9776a2d030719f9d74413d17c1bb732aaabb610b341031facd2c1a75348fc661 *amd64-linux.elf/upx-3.95
d96c42d14684e7248de5712310364eafa28b337695bc0d8c37f91d593b869250 *amd64-win64.pe/upx-3.95.exe 822718cc0f6ac5e57bb23eeb65be6f3f7e73df8b062853abddcc924ec8207596 *amd64-win64.pe/upx-3.95.exe
c1d3b9ec3157f068097f5deffddce4fc4d3d95602daa539992e0accff6af0de8 *arm-linux.elf/upx-3.95 40353c37020fd4bb713c5d54273b8dc07666e262b83a4f0652ccb8a236465f9c *arm-linux.elf/upx-3.95
9ca862c0c92d7e4068145024486bb85a6031bf06f9a37c6af543234e08e8ab36 *arm-wince.pe/upx-3.91.exe 1440d6b44968954baf56fbc2a0739a51873455876114d4445ae4b67cb5e7893b *arm-wince.pe/upx-3.91.exe
9173b4e4b1ac0b92e63dc51168dbd41d38208520b0f4c17b91d22e584ad55ae4 *arm64-linux.elf/upx-3.95 35c08bf5086fe21ff19e3512359e54ac97c6d4513e6bb9ef4a59294bebf18f6a *arm64-linux.elf/upx-3.95
8c6c5f1678fb74d2f65a1e6c28e3089a4b99b49939fabac3ca1f71183bc73ffa *armeb-linux.elf/upx-3.91 0ca2dcd9e8b5c3f16dcb31e30b42ec57a70b8fe90281d412081095a3d7812f01 *armeb-linux.elf/upx-3.91
13caa682f323a0438a651f53768af9b7fb1208980d46d94c6fb984ecf4422599 *armeb-linux.elf/upx-3.95 462a72efbb580a2e90564412737bb3c1db1d930cde5b4f2c94782df91c8e4f4b *armeb-linux.elf/upx-3.95
55f30818e45da393628aa80c3518f3cf099666ae3af5014bded2196ea28ddaea *i386-dos32.djgpp2.coff/upx-3.91.exe a7ee051c5f9dcf233e2ee248274121b99fb8f098eff95469bc0638a7423723f0 *i386-dos32.djgpp2.coff/upx-3.91.exe
6b80b2be79ec38af3071fcaf8f0d0ec524e4523e7e52e2f10111862ab93ec793 *i386-dos32.djgpp2.coff/upx-3.95.exe 85cf31be166cb59587a99419cdd0fc5a79825d7508ab2c9a4bc0d700d603354d *i386-dos32.djgpp2.coff/upx-3.95.exe
9bb71da401ae398ca42cde73afffe0c0db29fff24f22196c4116636ab6385170 *i386-linux.elf/upx-3.91 fc7656d9a877967be7e339bfc98a0c63ea7b5abc30b96fa9e5931c75ecbe9827 *i386-linux.elf/upx-3.91
c2375a808f989c0f8290fcd9760db0033413323d8597deb796f182f8ac38afa2 *i386-linux.elf/upx-3.95 d454a7639e96b986ad422b02045ecfefa3b9405901eaa32d92a2c489292b9600 *i386-linux.elf/upx-3.95
892695e1abdc0fbbd110ee30c317fde56947f4a8b3dfe413507ee7665f109986 *i386-win32.pe/upx-3.91.exe 934dd17076c0298d35a738533ea668e1fcbf8fc85c6671fcdd3a12e7722502ce *i386-win32.pe/upx-3.91.exe
f76ec227836388da3174007e2c5e27fb6cb397a83297872e78befb298a65796d *i386-win32.pe/upx-3.95.exe 519a9f6b3de56f5f080151074b9d5d81e31c1961cd6e395f73d2d522b7f7f8e0 *i386-win32.pe/upx-3.95.exe
8f7c5b3d67c78c117c02bec8b30ec5fca7baa79a35d250a4d981cb7137f8635d *m68k-atari.tos/upx-3.91.ttp a7bd9f616231d883f6700b09e3c9a0af2880c6b5e5b0ce1cd8f06de43c48856c *m68k-atari.tos/upx-3.91.ttp
745ac3afd263f3a653165bd229e35c817a58c9b894a8d6fbd4e5aaf6c38c1264 *mips-linux.elf/upx-3.95 7a0479691e51ea4a8a0246a1f0ffa9694ee2f0e0cf3aa43dc0f1324c4d427ba3 *mips-linux.elf/upx-3.95
a11da76425bc3bb308de3c19e6df22f56bf12c95afcf96ee8c2d4aaeda07ac8a *mipsel-linux.elf/upx-3.91 f60bab42fe3914109ab1b9f5d00a5be753cd0a2c1a79a3998d58800efedbfff7 *mipsel-linux.elf/upx-3.91
76c458e8e9b94eceb60d8c51f602a5dec44b2617886ea0b5b7b8802c61d962e9 *mipsel-linux.elf/upx-3.95 b6d8cc9e2023a3fc415166afc378ccf2eb505487df84c8d959ec74b3fb4f8256 *mipsel-linux.elf/upx-3.95
cec277d9e6e0cbf551f697c1d52e5d29b48533efbe4269df0aafbc12731a93ed *powerpc-linux.elf/upx-3.91 acd3dc5ed3e4c4eeaa42e7cca71a79d687dd844ce5f384666ed6e78327b5a8e3 *powerpc-linux.elf/upx-3.91
92c6cec7bf40d1aa5a62a55fce95bb99d94c5b477edbea127ee0468471ddbdb3 *powerpc-linux.elf/upx-3.95 03600584c97fa466ef58239452baf9ec6ff2f06b79d97d45c8490953080de6e3 *powerpc-linux.elf/upx-3.95
df2f12597c901196e8f10782e72fb4c294955f03a66cc4e8bf3c24414929f717 *powerpc64le-linux.elf/upx-3.95 3f02885d1e94e59062eb78c4c910cde042475a6cadb77a85a603de747a50f45c *powerpc64le-linux.elf/upx-3.95
" "
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\ expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
f7e51450a373cb49f88e3e17c268f4198429f7ad06bed57dda28161b5383196a *amd64-linux.elf/upx-3.91 8431343adec632690cec669038c246438c799e7dc1b8bc85586e0d2bcd2eebad *amd64-linux.elf/upx-3.91
15c57828824d18604519fd43349f0340ccebfddf246ab355f8f30253123132ea *amd64-linux.elf/upx-3.95 1852bded40be6eb5ddb07a491476dcfcca69cadda45a5f128aa8f967d567fa0b *amd64-linux.elf/upx-3.95
728b2feceda3cfdd849aef4402d5d4e61aa6fa6d56266e7730b148dc66f4a7b0 *amd64-win64.pe/upx-3.95.exe 5ab022e2c3ecb09931e2181fb5f7699f35e2b453b54c823e42653c84b0df5f2c *amd64-win64.pe/upx-3.95.exe
188a3581ed2bac5fdfd50e08267e2e9cf4cf3ddbfc9f5ae15643298bda4bf11c *arm-linux.elf/upx-3.95 6de0cf1903760710a95cb5330d0ffb406a93f081dbe6806935f51b0c75e23f03 *arm-linux.elf/upx-3.95
0711f0b8531de9659f099f43f2a883d628bee8de67f927e7137c19c6d23a30bd *arm-wince.pe/upx-3.91.exe 53121baf42c85991900aa3947f3d817fe6e894bc6f325ab1d576de6fba5fbcbf *arm-wince.pe/upx-3.91.exe
ae6fa69b1242bdfe808d64b7bbefddfe9c1c96302627ee8c65fa2851102fc502 *arm64-linux.elf/upx-3.95 3c9e49445280de6a771e77f6a88b3c3957815baa193e92a893d5defe6699f50a *arm64-linux.elf/upx-3.95
7586b4029355eff2edf25141835ee2405ab9f936956e56420315c3d3fecc8bda *armeb-linux.elf/upx-3.91 627a3c77adfcd4ef8c32f1638a6b99e20e79bb914cbcebed6fb9ad5f96936530 *armeb-linux.elf/upx-3.91
e37875b1a91ef3c88bdba113649a061b72239dbfe77b77077c51254037a982b6 *armeb-linux.elf/upx-3.95 7faf9f0adf508cf29bf0ac2a62234df06d6c9153d6d59cf61019361db906daf8 *armeb-linux.elf/upx-3.95
536e5a6bb18378f3eea81be12f218f4da60ea81eddf480434aaf418610e4e52d *i386-dos32.djgpp2.coff/upx-3.91.exe 51e4faea51e12c7442b27bb50150f532ac51d8102f77a669cbce82f2675a2ef2 *i386-dos32.djgpp2.coff/upx-3.91.exe
386f3037b26b8b2ce49a527028d738956e7ef649b29a0ef15e32acef4a3b291a *i386-dos32.djgpp2.coff/upx-3.95.exe 1196f578ab0b862bae8ac6b5166b770f072cf0ac521a2a23a6347c19ea82a0da *i386-dos32.djgpp2.coff/upx-3.95.exe
5761d8e12b01163c2bf378bef813df9a621da08c4508773db992a1cce067c70c *i386-linux.elf/upx-3.91 3015651261f28fb43ed43a8c1fa257bcfcdc788e6fd3f436f3de23733736c724 *i386-linux.elf/upx-3.91
8afc2b549e2f78987641045697afaac0378b48e84c3e946334c9e4f1a7e693fa *i386-linux.elf/upx-3.95 8cca96ea354af889f5e9d3074b2c7005f982463a3f22e1cca2bc01aed9232de1 *i386-linux.elf/upx-3.95
1cc6663f3d9e847f9fec39a52c8efe38b39a66074c0ad77a880a84dde7c68d3f *i386-win32.pe/upx-3.91.exe 3edf364443a3cd56efd04e95cc7d7c1846bf76addedd7263cfe8330771f19509 *i386-win32.pe/upx-3.91.exe
edf158ec6064e9b11b677a73239a70e414fa8c4f3b8950f74e81514ccb28ef4f *i386-win32.pe/upx-3.95.exe 48141fd66443f85ea867d7fa0bb3a50debb10f15bdb26c71888026e17c88d3a8 *i386-win32.pe/upx-3.95.exe
faa36b6601743dcc5eaedb57187a893006652b6c68acecff179ce2cd123e6209 *m68k-atari.tos/upx-3.91.ttp 07e1c09a953a9c87afa33d1236f46244280161bf3802273a523d380318886177 *m68k-atari.tos/upx-3.91.ttp
6c76928b5914b5c2e072bf2f90a2c95049cc41aec6b98b1f0b3c4f84df069f02 *mips-linux.elf/upx-3.95 39b3a5c780d9354714d5e2ed69068511422f8faf9ab660706adc8ad5ecdf3598 *mips-linux.elf/upx-3.95
029c2a47f1f613c538d2f39674167489a9d1bbbb6649a06d51d2b5ea983b4924 *mipsel-linux.elf/upx-3.91 123ce137e4cd555470fcf9fe67df75179b6f337fee66d075ddc06f9848817a37 *mipsel-linux.elf/upx-3.91
4d837edcaf344505ad1a3721ec8e5db35ddaa273a747201e460b946c0a89d6ea *mipsel-linux.elf/upx-3.95 b78d8cd3a3402fed266c737cc34a32cc21b2b67b573e9e9071d4faf9fca89b89 *mipsel-linux.elf/upx-3.95
0e24a9e58939f7aacd3482db24e04bdac406a658dbb8d5e65d71d76d455e5aa5 *powerpc-linux.elf/upx-3.91 ea9cae1d1701db3a0c53e9a651766db5bdc30032f48913a4a9e99f193a800acc *powerpc-linux.elf/upx-3.91
04bd4885f37c77a34b39e76cca2fd363f794ed1611093d7fffe1ee19920ce1dd *powerpc-linux.elf/upx-3.95 aea86bf87870a1e48a454ac1ea9a80d90d8abe5113d418a71d8a9c4a74bb2d0a *powerpc-linux.elf/upx-3.95
3b6be5bff0e435a8dbd8529562912c58dafdcb9694d75564238f3d086048abd2 *powerpc64le-linux.elf/upx-3.95 62038c87489dc5cd3772e8e4051cf1d416edecf267d37f390a649f4ae657e0f9 *powerpc64le-linux.elf/upx-3.95
" "
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\ expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
715de64e0911c959d0ea208db13bf23a5e635e97e73feb9e04ac9d32117e6a3f *amd64-linux.elf/upx-3.91 f817034e8b7765d8b422dac9cb6f24f78ce5bfd7169cd3b33e8224e00b131eca *amd64-linux.elf/upx-3.91
da805c93ffea03da2f0c0dbb1b313cf0d88ef2c0cb0ad77b0be792210106cd6c *amd64-linux.elf/upx-3.95 d21441a05514c085c10e99b00d8cc4d45484297a8e4e8a246364ca4347d0ed56 *amd64-linux.elf/upx-3.95
213e6d3c80b4d741e8c78da915d32c1a2b74072d31e86ec46a10ac2535cf8f6f *amd64-win64.pe/upx-3.95.exe 7bd7cd37093200fa94d21dd7fdfef4d7fb9c3049fbf5f408f1f242cb8d9c6a55 *amd64-win64.pe/upx-3.95.exe
3a66e868147347208935c042517b9f0e2e30d2dbb5c004ec8df6a9ab1e42ecd5 *arm-linux.elf/upx-3.95 d328a89b333d0b36e96d0c61375bf686e8f3b73a188dd4d0df4d78e30af08632 *arm-linux.elf/upx-3.95
8d295980b1e6a8240bf75b86a9b8e4561424cbabeab01246f51e553d84b40839 *arm-wince.pe/upx-3.91.exe ad0a7a18e87657d28260b7c527d284863becd3c5f92259c570125465f88d4042 *arm-wince.pe/upx-3.91.exe
194947a439c1348570e45343e404c409be3f10feb70fdd87d9bca0addc772c44 *arm64-linux.elf/upx-3.95 0b700f0f7dde3118694155e876e6c2003ef701fe94856d6562936ec081278747 *arm64-linux.elf/upx-3.95
a01384f43803428e0bfc5f8152304eb8618ef862e4e996a4a4fa4dd9c4576833 *armeb-linux.elf/upx-3.91 53a1d04fa62e25e64e6f792b079e21b4c42676a73503ae6d9e67ae16c98e6d04 *armeb-linux.elf/upx-3.91
f2fdba359d52bb82fbab093176a3fbf37b9cb13e8d297523ed57051c3bd401e3 *armeb-linux.elf/upx-3.95 33ed1e3b84836d2af52295ba0b90343ac0b8d524539ce3b8d0aa9f19a51d70dd *armeb-linux.elf/upx-3.95
582030394a570f92be2d31b3862ab7fb0a6f08982c793a4d41c1471d2cabb939 *i386-dos32.djgpp2.coff/upx-3.91.exe 6fcdc8e34ce8b3501db2260c8a921c6e963954fdeffedfefca353a27bcc02d56 *i386-dos32.djgpp2.coff/upx-3.91.exe
f60dc2f332f58b7fa08f551f8c33d645d71d9ee79e2a719130d10ea4091373ef *i386-dos32.djgpp2.coff/upx-3.95.exe 6f4f901c1838252f9b3104060475a6f13a2ebec830096ff28d870148580e4287 *i386-dos32.djgpp2.coff/upx-3.95.exe
13887e5466a7d0fc2652aedcef44e33e6ee9b8d6f0ac21dbc4ec90fcc0613bfa *i386-linux.elf/upx-3.91 8127f8380300508e8062e9391e321abd0429a6a31fec41e769cc7fe80af27e27 *i386-linux.elf/upx-3.91
636759f884399ff05e8493a759f60ea52cd4640eb5e9760f12fc25fbf730b1ed *i386-linux.elf/upx-3.95 b0a7e6b822f038b7940a54ea160b045d2241e3dfa15a5081a23fbc4d42fb6773 *i386-linux.elf/upx-3.95
c4a5d27ce7d8f0f326e49489223eda188a9be61971a88758a559efb9f854611a *i386-win32.pe/upx-3.91.exe c78db15a8113b806e56812fd842fb467d2a9c9557fcdc0467dae3f4c33316630 *i386-win32.pe/upx-3.91.exe
4ca9a3dd0e0ec38cc1aa3720d9c666f86df4fbe9dcb87ef0dad56d0a47dc327a *i386-win32.pe/upx-3.95.exe 89314e8621c4a00e1a65e045686245d3c1e2ba0a858f1dcc8f3cc2d0eedccfb5 *i386-win32.pe/upx-3.95.exe
f34a020e6325d213052d9f09c775c4d292c34c51380b1ab1b22c6663645167f0 *m68k-atari.tos/upx-3.91.ttp 710ad88b63cc7e0fa0b413ebdbcebf41140678f551b5dd883ed6220507be3601 *m68k-atari.tos/upx-3.91.ttp
3006af1262a29173c46340f1ee4526fba41145f7476841d5bf6b499aa6dea0fd *mips-linux.elf/upx-3.95 c7e3478872650b7f4f8ccb4a0649944e62f44f5a9249cb9425210333e1f2fdf4 *mips-linux.elf/upx-3.95
6af81d3c7cb6f1388925fe2d78ea96313d91d5e17249268739de4d56857f27bd *mipsel-linux.elf/upx-3.91 cd9b3d3780a79cb416b261d622e8e86f2369fa8bb9bc49b529c50cac2980d528 *mipsel-linux.elf/upx-3.91
9d3849cd0037ef550703c574e0ccb3032b0d27217ec02c90a0ad8592d2a229f1 *mipsel-linux.elf/upx-3.95 5baf7db9e4335c0227106262efc9d18ad23b88c6d6bb636656aea67bb063b6ec *mipsel-linux.elf/upx-3.95
704b6eb2033cf3eab30cbc53c35fc85bf0cb17f904528792de33967a1406091d *powerpc-linux.elf/upx-3.91 aba8bd826ee52d533f9e1c4270d4f4194fe8d8747ea10a1d3ce59b6443f1a9f2 *powerpc-linux.elf/upx-3.91
b89b2f3b250ddd156cb857717c86a0c0325a26dd084717c64f3022277ad02be4 *powerpc-linux.elf/upx-3.95 6f737ccbf8c830476bed9c4dd33dd7757ea25bf2f8fb03b44d03e9b77ada0f1b *powerpc-linux.elf/upx-3.95
d52f201ab041fa64a4ee4234bd0e443e883e402bb93ced9e22554bd3ef3cc9ab *powerpc64le-linux.elf/upx-3.95 d313dd128a54189b9551a529b1ed21b222aa0394a30f9ba552cde96edcd4011e *powerpc64le-linux.elf/upx-3.95
" "
expected_sha256sums__t140_compress_lzma_2_no_filter="\ expected_sha256sums__t140_compress_lzma_2_no_filter="\
af8536d70ecb8c0680c1c9dc45ef60dcb13fab99f0e4644d9f86216a9cf003e2 *amd64-linux.elf/upx-3.91 fefac6fbd1e95479eb4066519f9bd801a30c29966685840b6a011e2911b984ca *amd64-linux.elf/upx-3.91
004a705f4981a19f35767b33bdb70b942717a701ad8635bd56ba33e347c6ed69 *amd64-linux.elf/upx-3.95 64487a0e0aade092a8ff7e6d8d9528ca550540cac8d432005ba610179782d042 *amd64-linux.elf/upx-3.95
cf07c202497ab38417ec3ccb65cbb0eb9b87f6c6df40d7dc4b44616282c8e0f8 *amd64-win64.pe/upx-3.95.exe a55ec5a7f2911f6da8b9336daf4f1051e753cfb7a4458c7f7baa6b63340c6daf *amd64-win64.pe/upx-3.95.exe
da153c1747e0e242cc8b90c04362f67caa0aa638562bc12fcc7fe08ebb1b4fcb *arm-linux.elf/upx-3.95 9f405739b904bb85053b75187c9175e4ac7f66a07ac5e320eaa4e9771e1ec79e *arm-linux.elf/upx-3.95
9755110ebc951c9767e376155d9c6fee9789b009ce82ae47276664f5c832557e *arm-wince.pe/upx-3.91.exe 7a6c603eecf214e5d6742f1fce922223c97c8bd2527678a968640dd6c1bc0d71 *arm-wince.pe/upx-3.91.exe
bb9e92b577ace19da295032c294063d724655cf5b97d014053c3fb05ce478884 *arm64-linux.elf/upx-3.95 c8435e2f82ba72a0b6abad4146539d40d495461c5e480af705b2bbd21d192128 *arm64-linux.elf/upx-3.95
a3c639403fd7b2f035315773c1aa3f68cc0532cf5cd075defd34fa44c4bbbb7a *armeb-linux.elf/upx-3.91 21fc48eaaedc73fe9239159fb864c6149f729ef1661a8407b88ad9c9a19f9a54 *armeb-linux.elf/upx-3.91
3f9604a69a945d86b93f2182ee82f754881331c7ef566d0cd4dc36d7acfa1aa0 *armeb-linux.elf/upx-3.95 742db587dc53f616c7b276a930c3f586da2b7c3ce6ccd523c041e88a9671b99b *armeb-linux.elf/upx-3.95
e6518528d60861e37cb8429376628a7f3d1d5fc90f0933facd70b4e9e0b50709 *i386-dos32.djgpp2.coff/upx-3.91.exe 7a8eaa5139b95cc56591200fce62d3c9af163671467952cab6fcf487318107bb *i386-dos32.djgpp2.coff/upx-3.91.exe
53280a22c34ee1733007ccf858e1f5416c0f7043a4361799087e19a4b2a7eaf4 *i386-dos32.djgpp2.coff/upx-3.95.exe 9b5fc0f54a5f811bda190c36fb2fa5c5b03c6c3de0c62693e4191230b5a419b8 *i386-dos32.djgpp2.coff/upx-3.95.exe
a51ce8993b3577fc2ee45b52174aaadc66c2f90ff53a0148ed096a65d99d24a2 *i386-linux.elf/upx-3.91 68b4ce63cb0bd7dd5b287e1f9fa5d9bc234ac36359ce3ebff863984c503a698e *i386-linux.elf/upx-3.91
d018260f04d1efc2b46c8b7ff5b132358e58cb062c158b08a7179fbb561b0e48 *i386-linux.elf/upx-3.95 aa75cf22f0b59cc796de678198432a3dc2d40ab871e4989dd97ff1a6c148f294 *i386-linux.elf/upx-3.95
121e4acc3fbad4954cb2d2b957d229b042beaf4b68749c4f85ebfc60fcc80d43 *i386-win32.pe/upx-3.91.exe 0e0780f5fccc52f6c78414f7279263b26e31de7c6ca1ec65a240e37cf0a4f5c9 *i386-win32.pe/upx-3.91.exe
d604523130da29af35705d9008098ae8b4bb9e7d4743357674470252dd68b8d3 *i386-win32.pe/upx-3.95.exe 3ddd6265d69e374f5f0f8c9f602e0e59c895da2f3fef611ef89f0ee4ae2c592b *i386-win32.pe/upx-3.95.exe
4d26f0be2b6b6c4802515a7f0dfd97998c6d23e696ae6c0393c9ac0893885a9b *m68k-atari.tos/upx-3.91.ttp e268c98fdacfd04268d76644f2bb4746ae04b57801407aaa1867798840eeeea0 *m68k-atari.tos/upx-3.91.ttp
4d3b0c7b4dabb5a7a193a0a2899f086f5dfc555106188131389678ecc137378a *mips-linux.elf/upx-3.95 499e1d1486810cfa5b6662e30189183979e25f45d35654d8cd60fd793d0c07d8 *mips-linux.elf/upx-3.95
be2e9fb66c087f37b58f203b406b618526296dd8c9c53e73bb622740f1e377ba *mipsel-linux.elf/upx-3.91 4a30189ad7312eafb2d47e1b526ec22eaf614a895f8dce96f3e1c7385438f44c *mipsel-linux.elf/upx-3.91
9da821fac44f787875727cf001ca33ed87e02c5fe477f0ebb965c5e0eb62c26c *mipsel-linux.elf/upx-3.95 339d38602413d97d9bba113f39884815af10ebcdccf37e3f5e8d0879f262a048 *mipsel-linux.elf/upx-3.95
98d7c0214663ae47f59244a90aabbb72a798a4ad0c74ce79d448013f5cad6893 *powerpc-linux.elf/upx-3.91 6d4f9d4383ebc9d8411d06a7c219dcf3e8513ea8c989f2d31ab382602f873ba5 *powerpc-linux.elf/upx-3.91
c58266817c4e38982c66e4b75e0002c6e7a51710864f930987b8670ee121ee0b *powerpc-linux.elf/upx-3.95 5dd727d8d5a35cc0ab86d629285d8ff450f52b538118679edaa886ce9c1fed7d *powerpc-linux.elf/upx-3.95
7fecab59271c9d4596bd79978e112a5fea72e33bd7c53c1985d187009d807724 *powerpc64le-linux.elf/upx-3.95 efec1e5bbb9bcf11dbc7081adfc2020de18fae326ad86194551c44fba0d2148d *powerpc64le-linux.elf/upx-3.95
" "
expected_sha256sums__t150_compress_ucl_2_all_filters="\ expected_sha256sums__t150_compress_ucl_2_all_filters="\
977380191b474f5a7fa78e8015a279bfaa77626bc56d83185fec8761531b3029 *amd64-linux.elf/upx-3.91 05b29bde32af1e63e837e2be499567c4b10d7e692c88082f24e3417e0c7b9f40 *amd64-linux.elf/upx-3.91
4f94c9bee7a2f7deed245dc767c215654a41373be978123c3f1ef9074454c59d *amd64-linux.elf/upx-3.95 65c142ee01af09fa8741932c1f21d466be971aad059cc5afddbb7ecdf142c1bb *amd64-linux.elf/upx-3.95
00aa338efc865f720a901afb1c19064cf137abb71d361be9b19192b0ff8a9479 *amd64-win64.pe/upx-3.95.exe cbb5c90bd9195bd9e3acd931312a70deeccfab5540f398ceda8826f8d6b332bf *amd64-win64.pe/upx-3.95.exe
c1908a58fcc23a9a964f2cd5f76f805a7cc9ca39480d129c6bdb8db30033840b *arm-linux.elf/upx-3.95 1ea1bb18c0ac85c07450f0a6704b84e58a1322556757e2943340ef381b2ce675 *arm-linux.elf/upx-3.95
78ffa99aa69e2f66f864dce88e787e3b1c0c056009e0f863986d65aabd186107 *arm-wince.pe/upx-3.91.exe 76a5f0518fc797bd3f132ce6eb61ca187b5d463f191417883a73d4584716c23a *arm-wince.pe/upx-3.91.exe
245c6bb22ae2b39671503244329f1e4498277b06d600447ad81c7d41ebc872d6 *arm64-linux.elf/upx-3.95 4df30002376a4f18029ea9dd8260d395bec3a3fa11fbc5aa19859c2f0efdc2e6 *arm64-linux.elf/upx-3.95
9e359728cdb9bf6ea21a864b2c9da56809eda27d6b88828b85ab815311bf77b6 *armeb-linux.elf/upx-3.91 ba03fd4889210435c9673f2dcbd2269162037090eccc79cf7d2b896e64a57e2e *armeb-linux.elf/upx-3.91
86edb5959b5cabad270d7c77e750bc710424b92cfb2ebaeedf3ba403382f4e93 *armeb-linux.elf/upx-3.95 681f32d01c76ff31776b8d6f1556daa38eee297f675aa40ff1bb2e47e12adf15 *armeb-linux.elf/upx-3.95
b65db2766ffdd45657a07edd57426c55acce2a73a1e3559ab43903ae77574131 *i386-dos32.djgpp2.coff/upx-3.91.exe aa05c3a2953f0f2d70842cba45786b707a79ffef22fd084f51e304762cc67765 *i386-dos32.djgpp2.coff/upx-3.91.exe
e827d64700b14e8c19de2882e66d0df0fca4cda0255ae41a66810e4c86583a93 *i386-dos32.djgpp2.coff/upx-3.95.exe c677241e9a8753ba1332ac3875ab6398fb2d792d2627edd9e58f2535b3131abe *i386-dos32.djgpp2.coff/upx-3.95.exe
c95a7ad9a5015abb1b8a163afe46b4f1529c70ca4ef9353cfb6e5c7eef60245c *i386-linux.elf/upx-3.91 7bcd42f58dcc8ddb6cb1a4e33d56b584fe6d49b002b01a0859571d1324dd593a *i386-linux.elf/upx-3.91
21ef65f5c756f216c0f9db9475a7514e10b8e003c30bc22416ec8156cba65252 *i386-linux.elf/upx-3.95 b6fe6220c0b3f4df131da3aaae566810f2aa1f13b63d23de3ead9174d08d82e1 *i386-linux.elf/upx-3.95
6db34f6cdc626c4857fc7b188910562909e571eed3be2116448e244ca82eaa64 *i386-win32.pe/upx-3.91.exe 8ec02f816f4727b519e8775edc1afb1df32991319a6c6f050ece416011925379 *i386-win32.pe/upx-3.91.exe
68a08dd3995681af594c66df4b94559e5900f0a09fcf822e3fc2522c3133ad69 *i386-win32.pe/upx-3.95.exe d5aeeedada49c0c2870ea450ed66b2cea31369bccfccf9407378ae0fb0736deb *i386-win32.pe/upx-3.95.exe
1546ce426b3cfe38bdea18fafadee409253d5d2b452aae5476e073b29e17bb58 *m68k-atari.tos/upx-3.91.ttp e414ad0aba43790d0498b26c23055fb051129b6cbe3e070a1406c91ac5b8032b *m68k-atari.tos/upx-3.91.ttp
6ecc64d1fb9fb2a675980ce939b0b8142e802e7218b8ea45f2bb82205ed9242e *mips-linux.elf/upx-3.95 c5107a84d32de820c81401259a7dd23435ea625588d56c6c75ad6fa14b0dbf8b *mips-linux.elf/upx-3.95
eb3c90f8f775e70cb2cc187b7e55d66a3bb28fa760e14a17353acd1130fd122a *mipsel-linux.elf/upx-3.91 78473f7d7ddf56812b8dee087ca62517ecdbd10fa14972ba6670338fc19061d1 *mipsel-linux.elf/upx-3.91
b47964dbe65e9975d6bddfbfdd321a5e6c96b6eba79b30d0f94ec4323b796991 *mipsel-linux.elf/upx-3.95 fd9ea397a29b41a2143f9e02217e181d0075d7ad7d87bdbadc7fc94bfb1b0d76 *mipsel-linux.elf/upx-3.95
c32a2deaa707eafaed36a4ab8fb26bb8d8c63a9743b19ad207e305553d14c7fe *powerpc-linux.elf/upx-3.91 c47d1299f6ecf86e62528fc54979117b2b2ddbb6c80f553689402399fc7eab28 *powerpc-linux.elf/upx-3.91
c4dbfbd0f5021d50f1addc68273f20b49204bf26ae8c8896a0aacc7d2c5a2d47 *powerpc-linux.elf/upx-3.95 77c3b4ba6909a4e20180bc13775e280086d67240519c323c2005f3fcee6e0b78 *powerpc-linux.elf/upx-3.95
bb96ea8a29500893b729dad4afe90b09186641c32c42a70a3d2380a771f896d9 *powerpc64le-linux.elf/upx-3.95 e3ce51b863905a4831958c72541b04e9f893f0d9827f32e615822db7aebd56bc *powerpc64le-linux.elf/upx-3.95
" "
expected_sha256sums__t160_compress_all_methods_1_no_filter="\ expected_sha256sums__t160_compress_all_methods_1_no_filter="\
de00c3bcb56d78c3fd1d1e633b3f64b884b3611abc305b9e79f4f14385178418 *amd64-linux.elf/upx-3.91 94c91b97fcce7402a4494b22699b2450e8e4e2a9f4ddd66e1133c76ce198c167 *amd64-linux.elf/upx-3.91
eb5aea4d780711dd59e3f86d34a49f16d3669acc6569292bf9ea445d406c5c80 *amd64-linux.elf/upx-3.95 5b3e85adb37919d051c6eaff205b8e1d77a2dfde0d8e7dcdee7c22f8fd5dc8c7 *amd64-linux.elf/upx-3.95
2fae12ccc55eeac6c05ff2c6b27539c66816080647283ac2e1b22576242b6bb5 *amd64-win64.pe/upx-3.95.exe 5a0ecb45658904bcd0b823b77dba039c9814e2eff4ed429784c36b7074b9858c *amd64-win64.pe/upx-3.95.exe
14120b8348172a08cd7651184941820ed1c69b7a8d859e375390eee529f5c94e *arm-linux.elf/upx-3.95 de93a219ca3c4ea84bd9c1b5fb37ff4aaa0a08ea6eac18da6d7a5865e4dad19c *arm-linux.elf/upx-3.95
a6690508c1acdaa07ce97feec0f330182c24206d8e9133949d2a42fccc1cbf27 *arm-wince.pe/upx-3.91.exe fdbe0395ac401285edb9c2f9bfbb0fbd3c0eaad5052a88d8369b1a66b35a8a3e *arm-wince.pe/upx-3.91.exe
4f30adcd3d047fad15344bf6cf3cf4f91cfbacbb121af889df8634fa4c888247 *arm64-linux.elf/upx-3.95 acdb7ff90d7c6f403872ec333e2987ee74e99d6e1390863b321b528d312c1084 *arm64-linux.elf/upx-3.95
f85f0a70b024a050999d476420b9db88206e340b2ffff3781c491b538ae03e37 *armeb-linux.elf/upx-3.91 54860e61da36414dc105aafcdbb86c79b745913a7d0da911fa58a6941f111e2d *armeb-linux.elf/upx-3.91
e1b2dc75427212dc268c6921aa2059adf5709b21f230432a4725b16e1c64b238 *armeb-linux.elf/upx-3.95 7c36b75cc8a0712515e12a9e565df4ca43bff6cc0077afb282d367fcc2ee2acd *armeb-linux.elf/upx-3.95
fcf64cfce9e9762e03740d2bf9e2e86d873ade1b6f4a68eb07625f516426810d *i386-dos32.djgpp2.coff/upx-3.91.exe 0a0099246096d20ff6035a4df6566954b9d8aff9ed8fdbd35aa5ee4995b02bfe *i386-dos32.djgpp2.coff/upx-3.91.exe
9188a6f911b79fb8629880836b2f5787eb4d938872ba4f1a64c93e70cde9f428 *i386-dos32.djgpp2.coff/upx-3.95.exe 5df7aa9f0896df87eb8798119ad16a9b89c87a7568a67339e33b5baa99ec361f *i386-dos32.djgpp2.coff/upx-3.95.exe
8369ff8112aeb55a1684ce0ec16e13e6bc524b734557b49b292f9aae60edccb6 *i386-linux.elf/upx-3.91 53e5aae9bc70f58e3dc2aef5a94f66df2517d547670e72ee2b3189b7da809f41 *i386-linux.elf/upx-3.91
c4e16cc1a64db618d9038ea9ba6032b7fe5aac05c0d7731b91373094a6a0f6e4 *i386-linux.elf/upx-3.95 adaa1e2f46f7a235ab838b15aa7e820057e5ed7011d9d07c67dc770a88e3dd62 *i386-linux.elf/upx-3.95
b21cf7756542b3bab5f4a59d4036cd3176e297dceb744dec96ac365be6568dcd *i386-win32.pe/upx-3.91.exe f3d33c5c9809943a902133490bcf0cfbe39a5ef1635a0c29b3bdc4f35dfffa50 *i386-win32.pe/upx-3.91.exe
b1bc0d360918d51ca7b7f32f5083845e4566c7fa7a425d0451f4b10f227d1eac *i386-win32.pe/upx-3.95.exe 474e68a2390cf0376f59402eaef4c902daa49428b628e025b1c8506428a37937 *i386-win32.pe/upx-3.95.exe
c40af5d1ba0531abb92587cbcbe604d4f562b685d6e7bbb40ec4d879fddf1267 *m68k-atari.tos/upx-3.91.ttp 1561dd69f67e8705804dba41ebd876bce6a4ce8ed8b0bc0d0e7628697e7fee68 *m68k-atari.tos/upx-3.91.ttp
0865d2f1d65e2693d801b3c28d64910a009707be65598772df655c640469a4e5 *mips-linux.elf/upx-3.95 74f7f69b4a8b2b7c428fa55e3970ee767c1947f19ed1b0644870ecb6b3cb713d *mips-linux.elf/upx-3.95
4cf108686c2419c6d82eecb2473a6d0ca0a0b47096cc01ea2b55113f84762cc7 *mipsel-linux.elf/upx-3.91 12a42365234c001a52586b74a9597dc7d65184ddf1ee1d40734823a3443cd92a *mipsel-linux.elf/upx-3.91
0a90a99e0ebb1e9c86e0bdf6a3eec6ca116e65b235ba1ee9029694b84cadc438 *mipsel-linux.elf/upx-3.95 68f674d081d87e86e54f0051eee9e2bc85b566051992774ab28ff3173cbcb75a *mipsel-linux.elf/upx-3.95
4d8f85d254b1fd87bebe2fd732afd6214c98b869cda17ff0c4c566358446038a *powerpc-linux.elf/upx-3.91 f569d8f49d7110bb8b262a48055b39d889e9977c40c5f1b21e74f8cbf93b27ae *powerpc-linux.elf/upx-3.91
bbc6179756637db10b636d7383226cb1d685866e8e9191069107725365b42f38 *powerpc-linux.elf/upx-3.95 d8227a8a88c083760889acaf259e7da59eab75a23e341289bc8e3c60563ae344 *powerpc-linux.elf/upx-3.95
52d7db1d6d6611d4a064c036b57044fd93d4c5762452be07188ee2ff6b1e42bc *powerpc64le-linux.elf/upx-3.95 e4b58ed65025b765953af02e80be9a171c49b6c707c835949b1c888fdbe8bba0 *powerpc64le-linux.elf/upx-3.95
" "
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\ expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
ee887f19ee6a5d5f0a0ce7116a41570e106c10bc0bb25acf7eb3ee254c1ed560 *amd64-linux.elf/upx-3.91 52a39c30b60abb82c1ec2826297eb46abdc29b5dd55d7a7a41dd2fc1c573f60a *amd64-linux.elf/upx-3.91
9bd019e6442b219825f19082a20e4e73c49b24a4dee39e9e2cf0fc907ecdb46f *amd64-linux.elf/upx-3.95 f0c728c42e8775767e0d963e1eef7ca78711f3f6dd180df980a1faef926d7cac *amd64-linux.elf/upx-3.95
382fe4b3e4f575322b746d7d45e4553ba3cf47cb4351b9900508fb52a00118ad *amd64-win64.pe/upx-3.95.exe e07e9babdeb12fddeebbfa1b0293163cc5e63017d6f0933d02587c8da1e90a82 *amd64-win64.pe/upx-3.95.exe
ae71103c2e105099ab345a648abf109b9aec3039137c90af30710dd4a4b51736 *arm-linux.elf/upx-3.95 f0359efa2247e9ea756f54c85e7518d61f3b293e08f566c3812c64c7d5f0db0f *arm-linux.elf/upx-3.95
9150f49be3fcb03a5f23b209e5db443c9b96fa4d8e20d3730195f9eafff5d8e8 *arm-wince.pe/upx-3.91.exe 8d1706ab02013b536c3a4cec20d40a96591ffa45fdcb464ccd3f038567006d79 *arm-wince.pe/upx-3.91.exe
100d9cee849b7996cbde2dc82df766e5104ae030055ae9b286c53b60e9e51405 *arm64-linux.elf/upx-3.95 14932490ff17e27bb5bedde576b8683892c4720f4a0058f373aab9f8894fda09 *arm64-linux.elf/upx-3.95
43ded21db5b7b8355bc371e39cd3b1be05e91635e3cb6d64f9a8aea16127e157 *armeb-linux.elf/upx-3.91 64a73512e40c2fb49d8ae3a1d496b379c97b8724cf8ca4461a85825ff04366a0 *armeb-linux.elf/upx-3.91
b0ac3a36871630af80bb9b6ba94604b3ebc1fe05fdb6d095a7c461916fb3d231 *armeb-linux.elf/upx-3.95 078e7cd073ba071f17ad4292e2211b7d635f57e974546e7f156cc87f9aa716e2 *armeb-linux.elf/upx-3.95
36b6a947567386e325f1d3ff84a55ecbd37687e3264cfb0a57aa5e3be5ff85f9 *i386-dos32.djgpp2.coff/upx-3.91.exe dda2c348c43741a1bd65049a8e7b51be1ebf873d215370ec002185c85390c168 *i386-dos32.djgpp2.coff/upx-3.91.exe
ad02fcac751563d49cb0711d818231c1030bad9ef2b12fd54e60e2bc6510e9d6 *i386-dos32.djgpp2.coff/upx-3.95.exe 560392427ded22f2f3fea59ef10e55d65cf841001e67b1e4558ef13514baa602 *i386-dos32.djgpp2.coff/upx-3.95.exe
d1b4e2c81a0baf4ad273dd96722783e9219e69049a78d536757f39761a7cfe8b *i386-linux.elf/upx-3.91 f3f8feceebe8536633554b204df68c2e94e1d1a313fe7a576b7f5d404c916083 *i386-linux.elf/upx-3.91
6e509d556ccd2af102d43924bd4eb1e9bed9d557e44387769032df4ede525f0d *i386-linux.elf/upx-3.95 e7f98419e346670f72d66ac25f3d6ad53201e768819980eecae24d801366be27 *i386-linux.elf/upx-3.95
2138186fb26cc7983ec4a4ead290573f2e8226fea4a0b9b6d668d86fb21d1573 *i386-win32.pe/upx-3.91.exe 3510bc5627237752bedd275e73c42bc02cd46145ff916e7bccbdec663f763ee4 *i386-win32.pe/upx-3.91.exe
5f286eaf28bab252a0f4f069b7b88910b9ce62327c4d15837b91ce65e4f9030e *i386-win32.pe/upx-3.95.exe ad47c7522167f6f7e47d495e1fa119431386ca5ea9bc16b6a4b9cb38cf9cd29f *i386-win32.pe/upx-3.95.exe
0ab25c2cd8cf53a31323464080991344479998f45fd9b215caba003f96e9e11c *m68k-atari.tos/upx-3.91.ttp 1c999e5c6cded8c99a7f6b4595879893ae63d2af1388dc61dd8b4e3106676480 *m68k-atari.tos/upx-3.91.ttp
ba14b6b4e846d29bd4211fbcdb2a641f55f8a5700806af64c52182736b757f46 *mips-linux.elf/upx-3.95 55a098c2cdce1917b76ce0845f434fc23b0bd30b34e884b19401c51c8c7f4756 *mips-linux.elf/upx-3.95
40c23e16bfe68ec0a59f9651ac747db1e81f07deabc4c22a732e40e03e2b1100 *mipsel-linux.elf/upx-3.91 4b6487d412f43acb8e41951a2135e56025139a9ad3e57102749df4d4bef934fa *mipsel-linux.elf/upx-3.91
7d353d8381c3401c3c9765fa6091c634791ae9b7338ca5b769f63c38f8f418e7 *mipsel-linux.elf/upx-3.95 1dcd626fc4566c608e987fd6999b695793c5cae7f78872e3d1a9a23942fea188 *mipsel-linux.elf/upx-3.95
b43bd16efb19081fe0945948231486cdd1b1157d193ab7cbbd470594f46c57ca *powerpc-linux.elf/upx-3.91 2047a4a880322bf41e8afbb4787f6103364de4a299b543808251a4144c4d990b *powerpc-linux.elf/upx-3.91
7a8a24fa57d17f99b11133a0822a5e499681d09695525b80f8c61d90d06c4ac8 *powerpc-linux.elf/upx-3.95 63679bd238f30bfb14853246eb257536471fea10f942b2adfdd43cbef21dea30 *powerpc-linux.elf/upx-3.95
0339ffc1d99f5b5ad12e8492b6a9dc707f705a120494a6bc453fb8617808d10a *powerpc64le-linux.elf/upx-3.95 c75d1548db879ed589b55bc1319869b49d37595f4560a64b34016951dc02f997 *powerpc64le-linux.elf/upx-3.95
" "
########## end .sha256sums.recreate ########## end .sha256sums.recreate
+2 -1
View File
@@ -119,11 +119,12 @@ cd testsuite_1 || exit 1
#*********************************************************************** #***********************************************************************
run_upx() { run_upx() {
local flags="--disable-random-id --fake-stub-version=5.01 --fake-stub-year=2025"
local ec=0 local ec=0
if [[ $UPX_TESTSUITE_VERBOSE == 1 ]]; then if [[ $UPX_TESTSUITE_VERBOSE == 1 ]]; then
echo "LOG: '${run_upx[*]}' $*" echo "LOG: '${run_upx[*]}' $*"
fi fi
"${run_upx[@]}" "$@" || ec=$? "${run_upx[@]}" $flags "$@" || ec=$?
if [[ $ec != 0 ]]; then if [[ $ec != 0 ]]; then
echo "FATAL: '${run_upx[*]}' $*" echo "FATAL: '${run_upx[*]}' $*"
echo " (exit code was $ec)" echo " (exit code was $ec)"
+10 -10
View File
@@ -25,11 +25,11 @@ endif
.SECONDEXPANSION: .SECONDEXPANSION:
.SUFFIXES: .SUFFIXES:
build/debug build/release build/all: PHONY; $(MAKE) -C $(top_srcdir) $@ build/debug build/release build/all: PHONY; $(MAKE) -C "$(top_srcdir)" $@
build/debug+test build/release+test build/all+test: PHONY; $(MAKE) -C $(top_srcdir) $@ build/debug+test build/release+test build/all+test: PHONY; $(MAKE) -C "$(top_srcdir)" $@
# shortcuts # shortcuts
debug release all: PHONY; $(MAKE) -C $(top_srcdir) $@ debug release all: PHONY; $(MAKE) -C "$(top_srcdir)" $@
debug+test release+test all+test: PHONY; $(MAKE) -C $(top_srcdir) $@ debug+test release+test all+test: PHONY; $(MAKE) -C "$(top_srcdir)" $@
test: $$(patsubst %+test,%,$$(.DEFAULT_GOAL))+test PHONY test: $$(patsubst %+test,%,$$(.DEFAULT_GOAL))+test PHONY
@@ -61,11 +61,11 @@ run-testsuite-%: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
run-testsuite-debug: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite-debug run-testsuite-debug: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite-debug
run-testsuite-debug: export upx_exe := $(top_srcdir)/build/debug/upx run-testsuite-debug: export upx_exe := $(top_srcdir)/build/debug/upx
run-testsuite-debug: build/debug PHONY run-testsuite-debug: build/debug PHONY
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh time -p bash "$(top_srcdir)/misc/testsuite/upx_testsuite_1.sh"
run-testsuite-release: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite-release run-testsuite-release: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite-release
run-testsuite-release: export upx_exe := $(top_srcdir)/build/release/upx run-testsuite-release: export upx_exe := $(top_srcdir)/build/release/upx
run-testsuite-release: build/release PHONY run-testsuite-release: build/release PHONY
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh time -p bash "$(top_srcdir)/misc/testsuite/upx_testsuite_1.sh"
endif endif
endif endif
@@ -75,9 +75,9 @@ endif
ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc. ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc.
CHECK_WHITESPACE = bash $(top_srcdir)/misc/scripts/check_whitespace.sh $(top_srcdir) CHECK_WHITESPACE = bash "$(top_srcdir)/misc/scripts/check_whitespace.sh" "$(top_srcdir)"
ifneq ($(wildcard $(top_srcdir)/.git/.),) ifneq ($(wildcard $(top_srcdir)/.git/.),)
CHECK_WHITESPACE = bash $(top_srcdir)/misc/scripts/check_whitespace_git.sh $(top_srcdir) CHECK_WHITESPACE = bash "$(top_srcdir)/misc/scripts/check_whitespace_git.sh" "$(top_srcdir)"
endif endif
check-whitespace: PHONY; $(CHECK_WHITESPACE) check-whitespace: PHONY; $(CHECK_WHITESPACE)
@@ -87,7 +87,7 @@ endif # /usr/bin/env
# make clang-format # make clang-format
#*********************************************************************** #***********************************************************************
# automatically format some C++ source code files # automatically format most C++ source code files
ifneq ($(wildcard /usr/bin/env),) ifneq ($(wildcard /usr/bin/env),)
ifeq ($(shell uname),Linux) ifeq ($(shell uname),Linux)
@@ -100,7 +100,7 @@ CLANG_FORMAT_FILES += $(sort $(wildcard ../misc/cmake/try_compile/*.[ch]*))
CLANG_FORMAT_FILES := $(sort $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES))) CLANG_FORMAT_FILES := $(sort $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES)))
clang-format: $(CLANG_FORMAT_FILES) PHONY clang-format: $(CLANG_FORMAT_FILES) PHONY
@echo "running upx-clang-format" @echo "running upx-clang-format"
@bash $(top_srcdir)/misc/scripts/upx-clang-format.sh -i $(CLANG_FORMAT_FILES) @bash "$(top_srcdir)/misc/scripts/upx-clang-format.sh" -i $(CLANG_FORMAT_FILES)
endif # Linux endif # Linux
endif # /usr/bin/env endif # /usr/bin/env
+438 -180
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -32,22 +32,30 @@
// NE - Native Endianness (aka Host Endianness aka CPU Endianness) // NE - Native Endianness (aka Host Endianness aka CPU Endianness)
// TE - Target Endianness (not used here, see various packers) // TE - Target Endianness (not used here, see various packers)
#if 1 static_assert(std::is_same_v<byte, unsigned char>);
// some platforms may provide their own system bswapXX() functions, so rename to avoid conflicts static_assert(std::is_same_v<upx_int32_t, int>);
#undef bswap16 static_assert(std::is_same_v<upx_uint32_t, unsigned>);
#undef bswap32
#undef bswap64 #if defined(upx_is_constant_evaluated)
#define bswap16 upx_bswap16 #define bele_constexpr constexpr
#define bswap32 upx_bswap32 #else
#define bswap64 upx_bswap64 #define bele_constexpr /*empty*/
#endif #endif
// forward declarations
struct BE16;
struct BE32;
struct BE64;
struct LE16;
struct LE32;
struct LE64;
/************************************************************************* /*************************************************************************
// XE - eXtended Endian compatibility // XE - eXtended Endian compatibility
// try to detect XX16 vs XX32 vs XX64 size mismatches // try to detect XX16 vs XX32 vs XX64 size mismatches
**************************************************************************/ **************************************************************************/
#if !(DEBUG) #if !defined(upx_is_constant_evaluated) && !(DEBUG)
// permissive version using "void *" // permissive version using "void *"
#define REQUIRE_XE16 /*empty*/ #define REQUIRE_XE16 /*empty*/
@@ -61,14 +69,6 @@ typedef void XE64;
#else // permissive version #else // permissive version
// forward declarations
struct BE16;
struct BE32;
struct BE64;
struct LE16;
struct LE32;
struct LE64;
namespace bele_detail { namespace bele_detail {
// Note: // Note:
@@ -109,93 +109,184 @@ using enable_if_xe64 = std::enable_if_t<is_xe64_type<T>, T>;
// core - NE // core - NE
**************************************************************************/ **************************************************************************/
forceinline bele_constexpr unsigned get_ne16(const byte *p) noexcept {
#if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::get_ne16(p);
else
#endif
{
upx_uint16_t v = 0;
upx_memcpy_inline(&v, p, sizeof(v));
return v;
}
}
forceinline bele_constexpr unsigned get_ne32(const byte *p) noexcept {
#if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::get_ne32(p);
else
#endif
{
upx_uint32_t v = 0;
upx_memcpy_inline(&v, p, sizeof(v));
return v;
}
}
forceinline bele_constexpr upx_uint64_t get_ne64(const byte *p) noexcept {
#if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::get_ne64(p);
else
#endif
{
upx_uint64_t v = 0;
upx_memcpy_inline(&v, p, sizeof(v));
return v;
}
}
forceinline bele_constexpr void set_ne16(byte *p, unsigned v) noexcept {
#if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
upx::compile_time::set_ne16(p, upx_uint16_t(v & 0xffff));
else
#endif
{
upx_uint16_t vv = upx_uint16_t(v & 0xffff);
upx_memcpy_inline(p, &vv, sizeof(vv));
}
}
forceinline bele_constexpr void set_ne32(byte *p, unsigned v) noexcept {
#if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
upx::compile_time::set_ne32(p, v);
else
#endif
{
upx_uint32_t vv = v;
upx_memcpy_inline(p, &vv, sizeof(vv));
}
}
forceinline bele_constexpr void set_ne64(byte *p, upx_uint64_t v) noexcept {
#if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
upx::compile_time::set_ne64(p, v);
else
#endif
{
upx_uint64_t vv = v;
upx_memcpy_inline(p, &vv, sizeof(vv));
}
}
/*************************************************************************
// core - NE
**************************************************************************/
REQUIRE_XE16 REQUIRE_XE16
static forceinline unsigned get_ne16(const XE16 *p) noexcept { forceinline bele_constexpr unsigned get_ne16(const XE16 *p) noexcept {
upx_uint16_t v = 0; return get_ne16(upx::ptr_static_cast<const byte *>(p));
upx_memcpy_inline(&v, p, sizeof(v));
return v;
} }
REQUIRE_XE32 REQUIRE_XE32
static forceinline unsigned get_ne32(const XE32 *p) noexcept { forceinline bele_constexpr unsigned get_ne32(const XE32 *p) noexcept {
upx_uint32_t v = 0; return get_ne32(upx::ptr_static_cast<const byte *>(p));
upx_memcpy_inline(&v, p, sizeof(v));
return v;
} }
REQUIRE_XE64 REQUIRE_XE64
static forceinline upx_uint64_t get_ne64(const XE64 *p) noexcept { forceinline bele_constexpr upx_uint64_t get_ne64(const XE64 *p) noexcept {
upx_uint64_t v = 0; return get_ne64(upx::ptr_static_cast<const byte *>(p));
upx_memcpy_inline(&v, p, sizeof(v));
return v;
} }
REQUIRE_XE16 REQUIRE_XE16
static forceinline void set_ne16(XE16 *p, unsigned vv) noexcept { forceinline bele_constexpr void set_ne16(XE16 *p, unsigned v) noexcept {
upx_uint16_t v = (upx_uint16_t) (vv & 0xffff); set_ne16(upx::ptr_static_cast<byte *>(p), v);
upx_memcpy_inline(p, &v, sizeof(v));
} }
REQUIRE_XE32 REQUIRE_XE32
static forceinline void set_ne32(XE32 *p, unsigned vv) noexcept { forceinline bele_constexpr void set_ne32(XE32 *p, unsigned v) noexcept {
upx_uint32_t v = vv; set_ne32(upx::ptr_static_cast<byte *>(p), v);
upx_memcpy_inline(p, &v, sizeof(v));
} }
REQUIRE_XE64 REQUIRE_XE64
static forceinline void set_ne64(XE64 *p, upx_uint64_t vv) noexcept { forceinline bele_constexpr void set_ne64(XE64 *p, upx_uint64_t v) noexcept {
upx_uint64_t v = vv; set_ne64(upx::ptr_static_cast<byte *>(p), v);
upx_memcpy_inline(p, &v, sizeof(v));
} }
/************************************************************************* /*************************************************************************
// core - bswap // core - bswap
**************************************************************************/ **************************************************************************/
#if (ACC_CC_MSC) #if __cpp_lib_byteswap >= 202110L
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4) forceinline constexpr unsigned bswap16(unsigned v) noexcept {
return std::byteswap(upx_uint16_t(v & 0xffff));
}
forceinline constexpr unsigned bswap32(unsigned v) noexcept { return std::byteswap(v); }
forceinline constexpr upx_uint64_t bswap64(upx_uint64_t v) noexcept { return std::byteswap(v); }
// unfortunately *not* constexpr with current MSVC #elif (ACC_CC_MSC)
static forceinline /*constexpr*/ unsigned bswap16(unsigned v) noexcept {
return (unsigned) _byteswap_ulong(v << 16); static_assert(sizeof(long) == 4);
// _byteswap_XXX is unfortunately *not* constexpr with current MSVC
forceinline bele_constexpr unsigned bswap16(unsigned v) noexcept {
#if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::bswap16(upx_uint16_t(v & 0xffff));
else
#endif
return (unsigned) _byteswap_ulong(v << 16);
} }
static forceinline /*constexpr*/ unsigned bswap32(unsigned v) noexcept { forceinline bele_constexpr unsigned bswap32(unsigned v) noexcept {
return (unsigned) _byteswap_ulong(v); #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::bswap32(v);
else
#endif
return (unsigned) _byteswap_ulong(v);
} }
static forceinline /*constexpr*/ upx_uint64_t bswap64(upx_uint64_t v) noexcept { forceinline bele_constexpr upx_uint64_t bswap64(upx_uint64_t v) noexcept {
return _byteswap_uint64(v); #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::bswap64(v);
else
#endif
return _byteswap_uint64(v);
} }
#else #else
static forceinline constexpr unsigned bswap16(unsigned v) noexcept { forceinline constexpr unsigned bswap16(unsigned v) noexcept {
#if defined(__riscv) && __riscv_xlen == 64 #if defined(__riscv) && __riscv_xlen == 64
return (unsigned) __builtin_bswap64((upx_uint64_t) v << 48); return (unsigned) __builtin_bswap64(upx_uint64_t(v) << 48);
#else #else
// return __builtin_bswap16((upx_uint16_t) (v & 0xffff)); // return __builtin_bswap16(upx_uint16_t(v & 0xffff));
return __builtin_bswap32(v << 16); return __builtin_bswap32(v << 16);
#endif #endif
} }
static forceinline constexpr unsigned bswap32(unsigned v) noexcept { forceinline constexpr unsigned bswap32(unsigned v) noexcept {
#if defined(__riscv) && __riscv_xlen == 64 #if defined(__riscv) && __riscv_xlen == 64
return (unsigned) __builtin_bswap64((upx_uint64_t) v << 32); return (unsigned) __builtin_bswap64(upx_uint64_t(v) << 32);
#else #else
return __builtin_bswap32(v); return __builtin_bswap32(v);
#endif #endif
} }
static forceinline constexpr upx_uint64_t bswap64(upx_uint64_t v) noexcept { forceinline constexpr upx_uint64_t bswap64(upx_uint64_t v) noexcept { return __builtin_bswap64(v); }
return __builtin_bswap64(v);
}
#endif #endif
static forceinline constexpr unsigned no_bswap16(unsigned v) noexcept { forceinline constexpr unsigned no_bswap16(unsigned v) noexcept {
// mask is needed so that for all v: bswap16(bswap16(v)) == no_bswap16(v) // mask is needed so that for all v: bswap16(bswap16(v)) == no_bswap16(v)
return v & 0xffff; return v & 0xffff;
} }
static forceinline constexpr unsigned no_bswap32(unsigned v) noexcept { return v; } forceinline constexpr unsigned no_bswap32(unsigned v) noexcept { return v; }
static forceinline constexpr upx_uint64_t no_bswap64(upx_uint64_t v) noexcept { return v; } forceinline constexpr upx_uint64_t no_bswap64(upx_uint64_t v) noexcept { return v; }
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
#define ne16_to_be16(v) no_bswap16(v) #define ne16_to_be16(v) no_bswap16(v)
@@ -218,72 +309,90 @@ static forceinline constexpr upx_uint64_t no_bswap64(upx_uint64_t v) noexcept {
**************************************************************************/ **************************************************************************/
REQUIRE_XE16 REQUIRE_XE16
inline unsigned get_be16(const XE16 *p) noexcept { return ne16_to_be16(get_ne16(p)); } inline bele_constexpr unsigned get_be16(const XE16 *p) noexcept {
return ne16_to_be16(get_ne16(p));
}
REQUIRE_XE32 REQUIRE_XE32
inline unsigned get_be32(const XE32 *p) noexcept { return ne32_to_be32(get_ne32(p)); } inline bele_constexpr unsigned get_be32(const XE32 *p) noexcept {
return ne32_to_be32(get_ne32(p));
}
REQUIRE_XE64 REQUIRE_XE64
inline upx_uint64_t get_be64(const XE64 *p) noexcept { return ne64_to_be64(get_ne64(p)); } inline bele_constexpr upx_uint64_t get_be64(const XE64 *p) noexcept {
return ne64_to_be64(get_ne64(p));
}
REQUIRE_XE16 REQUIRE_XE16
inline unsigned get_le16(const XE16 *p) noexcept { return ne16_to_le16(get_ne16(p)); } inline bele_constexpr unsigned get_le16(const XE16 *p) noexcept {
return ne16_to_le16(get_ne16(p));
}
REQUIRE_XE32 REQUIRE_XE32
inline unsigned get_le32(const XE32 *p) noexcept { return ne32_to_le32(get_ne32(p)); } inline bele_constexpr unsigned get_le32(const XE32 *p) noexcept {
return ne32_to_le32(get_ne32(p));
}
REQUIRE_XE64 REQUIRE_XE64
inline upx_uint64_t get_le64(const XE64 *p) noexcept { return ne64_to_le64(get_ne64(p)); } inline bele_constexpr upx_uint64_t get_le64(const XE64 *p) noexcept {
return ne64_to_le64(get_ne64(p));
}
REQUIRE_XE16 REQUIRE_XE16
inline void set_be16(XE16 *p, unsigned v) noexcept { set_ne16(p, ne16_to_be16(v)); } inline bele_constexpr void set_be16(XE16 *p, unsigned v) noexcept { set_ne16(p, ne16_to_be16(v)); }
REQUIRE_XE32 REQUIRE_XE32
inline void set_be32(XE32 *p, unsigned v) noexcept { set_ne32(p, ne32_to_be32(v)); } inline bele_constexpr void set_be32(XE32 *p, unsigned v) noexcept { set_ne32(p, ne32_to_be32(v)); }
REQUIRE_XE64 REQUIRE_XE64
inline void set_be64(XE64 *p, upx_uint64_t v) noexcept { set_ne64(p, ne64_to_be64(v)); } inline bele_constexpr void set_be64(XE64 *p, upx_uint64_t v) noexcept {
set_ne64(p, ne64_to_be64(v));
}
REQUIRE_XE16 REQUIRE_XE16
inline void set_le16(XE16 *p, unsigned v) noexcept { set_ne16(p, ne16_to_le16(v)); } inline bele_constexpr void set_le16(XE16 *p, unsigned v) noexcept { set_ne16(p, ne16_to_le16(v)); }
REQUIRE_XE32 REQUIRE_XE32
inline void set_le32(XE32 *p, unsigned v) noexcept { set_ne32(p, ne32_to_le32(v)); } inline bele_constexpr void set_le32(XE32 *p, unsigned v) noexcept { set_ne32(p, ne32_to_le32(v)); }
REQUIRE_XE64 REQUIRE_XE64
inline void set_le64(XE64 *p, upx_uint64_t v) noexcept { set_ne64(p, ne64_to_le64(v)); } inline bele_constexpr void set_le64(XE64 *p, upx_uint64_t v) noexcept {
set_ne64(p, ne64_to_le64(v));
}
/************************************************************************* /*************************************************************************
// get/set 24/26 // get/set 24/26
**************************************************************************/ **************************************************************************/
REQUIRE_XE24 inline constexpr unsigned get_be24(const byte *p) noexcept {
inline unsigned get_be24(const XE24 *p) noexcept { return upx::compile_time::get_be24(p);
const byte *b = ACC_CCAST(const byte *, p);
return (b[0] << 16) | (b[1] << 8) | (b[2] << 0);
} }
inline constexpr unsigned get_le24(const byte *p) noexcept {
return upx::compile_time::get_le24(p);
}
inline constexpr void set_be24(byte *p, unsigned v) noexcept { upx::compile_time::set_be24(p, v); }
inline constexpr void set_le24(byte *p, unsigned v) noexcept { upx::compile_time::set_le24(p, v); }
REQUIRE_XE24 REQUIRE_XE24
inline unsigned get_le24(const XE24 *p) noexcept { forceinline bele_constexpr unsigned get_be24(const XE24 *p) noexcept {
const byte *b = ACC_CCAST(const byte *, p); return get_be24(upx::ptr_static_cast<const byte *>(p));
return (b[0] << 0) | (b[1] << 8) | (b[2] << 16);
} }
REQUIRE_XE24 REQUIRE_XE24
inline void set_be24(XE24 *p, unsigned v) noexcept { forceinline bele_constexpr unsigned get_le24(const XE24 *p) noexcept {
byte *b = ACC_PCAST(byte *, p); return get_le24(upx::ptr_static_cast<const byte *>(p));
b[0] = ACC_ICONV(byte, (v >> 16) & 0xff);
b[1] = ACC_ICONV(byte, (v >> 8) & 0xff);
b[2] = ACC_ICONV(byte, (v >> 0) & 0xff);
} }
REQUIRE_XE24 REQUIRE_XE24
inline void set_le24(XE24 *p, unsigned v) noexcept { forceinline bele_constexpr void set_be24(XE24 *p, unsigned v) noexcept {
byte *b = ACC_PCAST(byte *, p); set_be24(upx::ptr_static_cast<byte *>(p), v);
b[0] = ACC_ICONV(byte, (v >> 0) & 0xff); }
b[1] = ACC_ICONV(byte, (v >> 8) & 0xff); REQUIRE_XE24
b[2] = ACC_ICONV(byte, (v >> 16) & 0xff); forceinline bele_constexpr void set_le24(XE24 *p, unsigned v) noexcept {
set_le24(upx::ptr_static_cast<byte *>(p), v);
} }
REQUIRE_XE32 REQUIRE_XE32
inline unsigned get_le26(const XE32 *p) noexcept { return get_le32(p) & 0x03ffffff; } inline bele_constexpr unsigned get_le26(const XE32 *p) noexcept { return get_le32(p) & 0x03ffffff; }
REQUIRE_XE32 REQUIRE_XE32
inline unsigned get_le19_5(const XE32 *p) noexcept { return (get_le32(p) >> 5) & 0x0007ffff; } inline bele_constexpr unsigned get_le19_5(const XE32 *p) noexcept {
return (get_le32(p) >> 5) & 0x0007ffff;
}
REQUIRE_XE32 REQUIRE_XE32
inline unsigned get_le14_5(const XE32 *p) noexcept { return (get_le32(p) >> 5) & 0x00003fff; } inline bele_constexpr unsigned get_le14_5(const XE32 *p) noexcept {
return (get_le32(p) >> 5) & 0x00003fff;
}
REQUIRE_XE32 REQUIRE_XE32
inline void set_le26(XE32 *p, unsigned v) noexcept { inline bele_constexpr void set_le26(XE32 *p, unsigned v) noexcept {
// preserve the top 6 bits // preserve the top 6 bits
// set_le32(p, (get_le32(p) & 0xfc000000) | (v & 0x03ffffff)); // set_le32(p, (get_le32(p) & 0xfc000000) | (v & 0x03ffffff));
// optimized version, saving a runtime bswap32 // optimized version, saving a runtime bswap32
@@ -291,11 +400,11 @@ inline void set_le26(XE32 *p, unsigned v) noexcept {
(ne32_to_le32(v) & ne32_to_le32(0x03ffffff))); (ne32_to_le32(v) & ne32_to_le32(0x03ffffff)));
} }
REQUIRE_XE32 REQUIRE_XE32
inline void set_le19_5(XE32 *p, unsigned v) noexcept { inline bele_constexpr void set_le19_5(XE32 *p, unsigned v) noexcept {
set_le32(p, (get_le32(p) & 0xff00001f) | ((v & 0x0007ffff) << 5)); set_le32(p, (get_le32(p) & 0xff00001f) | ((v & 0x0007ffff) << 5));
} }
REQUIRE_XE32 REQUIRE_XE32
inline void set_le14_5(XE32 *p, unsigned v) noexcept { inline bele_constexpr void set_le14_5(XE32 *p, unsigned v) noexcept {
set_le32(p, (get_le32(p) & 0xfff8001f) | ((v & 0x00003fff) << 5)); set_le32(p, (get_le32(p) & 0xfff8001f) | ((v & 0x00003fff) << 5));
} }
@@ -303,7 +412,7 @@ inline void set_le14_5(XE32 *p, unsigned v) noexcept {
// get signed values // get signed values
**************************************************************************/ **************************************************************************/
static forceinline constexpr int sign_extend(unsigned v, unsigned bits) noexcept { forceinline constexpr int sign_extend32(unsigned v, unsigned bits) noexcept {
#if (ACC_ARCH_M68K) // no barrel shifter #if (ACC_ARCH_M68K) // no barrel shifter
const unsigned sign_bit = 1u << (bits - 1); const unsigned sign_bit = 1u << (bits - 1);
return ACC_ICAST(int, (v & (sign_bit - 1)) - (v & sign_bit)); return ACC_ICAST(int, (v & (sign_bit - 1)) - (v & sign_bit));
@@ -312,9 +421,9 @@ static forceinline constexpr int sign_extend(unsigned v, unsigned bits) noexcept
#endif #endif
} }
static forceinline constexpr upx_int64_t sign_extend(upx_uint64_t v, unsigned bits) noexcept { forceinline constexpr upx_int64_t sign_extend64(upx_uint64_t v, unsigned bits) noexcept {
#if (ACC_ARCH_M68K) // no barrel shifter #if (ACC_ARCH_M68K) // no barrel shifter
const upx_uint64_t sign_bit = 1ull << (bits - 1); const upx_uint64_t sign_bit = upx_uint64_t(1) << (bits - 1);
return ACC_ICAST(upx_int64_t, (v & (sign_bit - 1)) - (v & sign_bit)); return ACC_ICAST(upx_int64_t, (v & (sign_bit - 1)) - (v & sign_bit));
#else #else
return ACC_ICAST(upx_int64_t, v << (64 - bits)) >> (64 - bits); return ACC_ICAST(upx_int64_t, v << (64 - bits)) >> (64 - bits);
@@ -322,71 +431,75 @@ static forceinline constexpr upx_int64_t sign_extend(upx_uint64_t v, unsigned bi
} }
REQUIRE_XE16 REQUIRE_XE16
inline int get_be16_signed(const XE16 *p) noexcept { inline bele_constexpr int get_be16_signed(const XE16 *p) noexcept {
unsigned v = get_be16(p); unsigned v = get_be16(p);
return sign_extend(v, 16); return sign_extend32(v, 16);
} }
REQUIRE_XE24 REQUIRE_XE24
inline int get_be24_signed(const XE24 *p) noexcept { inline bele_constexpr int get_be24_signed(const XE24 *p) noexcept {
unsigned v = get_be24(p); unsigned v = get_be24(p);
return sign_extend(v, 24); return sign_extend32(v, 24);
} }
REQUIRE_XE32 REQUIRE_XE32
inline int get_be32_signed(const XE32 *p) noexcept { inline bele_constexpr int get_be32_signed(const XE32 *p) noexcept {
unsigned v = get_be32(p); unsigned v = get_be32(p);
return sign_extend(v, 32); return sign_extend32(v, 32);
} }
REQUIRE_XE64 REQUIRE_XE64
inline upx_int64_t get_be64_signed(const XE64 *p) noexcept { inline bele_constexpr upx_int64_t get_be64_signed(const XE64 *p) noexcept {
upx_uint64_t v = get_be64(p); upx_uint64_t v = get_be64(p);
return sign_extend(v, 64); return sign_extend64(v, 64);
} }
REQUIRE_XE16 REQUIRE_XE16
inline int get_le16_signed(const XE16 *p) noexcept { inline bele_constexpr int get_le16_signed(const XE16 *p) noexcept {
unsigned v = get_le16(p); unsigned v = get_le16(p);
return sign_extend(v, 16); return sign_extend32(v, 16);
} }
REQUIRE_XE24 REQUIRE_XE24
inline int get_le24_signed(const XE24 *p) noexcept { inline bele_constexpr int get_le24_signed(const XE24 *p) noexcept {
unsigned v = get_le24(p); unsigned v = get_le24(p);
return sign_extend(v, 24); return sign_extend32(v, 24);
} }
REQUIRE_XE32 REQUIRE_XE32
inline int get_le32_signed(const XE32 *p) noexcept { inline bele_constexpr int get_le32_signed(const XE32 *p) noexcept {
unsigned v = get_le32(p); unsigned v = get_le32(p);
return sign_extend(v, 32); return sign_extend32(v, 32);
} }
REQUIRE_XE64 REQUIRE_XE64
inline upx_int64_t get_le64_signed(const XE64 *p) noexcept { inline bele_constexpr upx_int64_t get_le64_signed(const XE64 *p) noexcept {
upx_uint64_t v = get_le64(p); upx_uint64_t v = get_le64(p);
return sign_extend(v, 64); return sign_extend64(v, 64);
} }
/************************************************************************* /*************************************************************************
// classes for portable unaligned access // classes for portable unaligned access
// //
// Important: these classes must be PODs (Plain Old Data), i.e. no // Note: these classes must be PODs (Plain Old Data), i.e. no
// constructor, no destructor, no virtual functions and no default // constructor, no destructor, no virtual functions and no default
// assignment operator, and all fields must be public(!). // assignment operator, and all fields must be public
//
// [Actually we _can_ use a safe non-POD subset, but for this we need
// to have gcc bug 17519 fixed - see http://gcc.gnu.org/PR17519 ]
**************************************************************************/ **************************************************************************/
struct alignas(1) BE16 final { struct alignas(1) BE16 final {
typedef unsigned integral_conversion_type; // automatic conversion to unsigned typedef unsigned integral_conversion_type; // automatic conversion to unsigned
byte d[2]; byte d[2];
forceinline operator unsigned() const noexcept { return get_be16(d); } static forceinline constexpr BE16 make(const BE16 &x) noexcept { return x; }
static forceinline bele_constexpr BE16 make(unsigned v) noexcept {
BE16 x = {};
set_be16(x.d, v);
return x;
}
forceinline BE16 &operator=(unsigned v) noexcept { forceinline bele_constexpr operator unsigned() const noexcept { return get_be16(d); }
forceinline bele_constexpr BE16 &operator=(unsigned v) noexcept {
set_be16(d, v); set_be16(d, v);
return *this; return *this;
} }
@@ -427,17 +540,33 @@ struct alignas(1) BE16 final {
return *this; return *this;
} }
bool operator==(const BE16 &x) const noexcept { return memcmp(d, x.d, sizeof(d)) == 0; } bele_constexpr bool operator==(const BE16 &x) const noexcept {
bool operator<(const BE16 &x) const noexcept { return unsigned(*this) < unsigned(x); } #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::mem_eq(d, x.d, sizeof(d));
else
#endif
return upx_memcmp_inline(d, x.d, sizeof(d)) == 0;
}
bele_constexpr bool operator<(const BE16 &x) const noexcept {
return unsigned(*this) < unsigned(x);
}
}; };
struct alignas(1) BE32 final { struct alignas(1) BE32 final {
typedef unsigned integral_conversion_type; // automatic conversion to unsigned typedef unsigned integral_conversion_type; // automatic conversion to unsigned
byte d[4]; byte d[4];
forceinline operator unsigned() const noexcept { return get_be32(d); } static forceinline constexpr BE32 make(const BE32 &x) noexcept { return x; }
static forceinline bele_constexpr BE32 make(unsigned v) noexcept {
BE32 x = {};
set_be32(x.d, v);
return x;
}
forceinline BE32 &operator=(unsigned v) noexcept { forceinline bele_constexpr operator unsigned() const noexcept { return get_be32(d); }
forceinline bele_constexpr BE32 &operator=(unsigned v) noexcept {
set_be32(d, v); set_be32(d, v);
return *this; return *this;
} }
@@ -478,17 +607,33 @@ struct alignas(1) BE32 final {
return *this; return *this;
} }
bool operator==(const BE32 &x) const noexcept { return memcmp(d, x.d, sizeof(d)) == 0; } bele_constexpr bool operator==(const BE32 &x) const noexcept {
bool operator<(const BE32 &x) const noexcept { return unsigned(*this) < unsigned(x); } #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::mem_eq(d, x.d, sizeof(d));
else
#endif
return upx_memcmp_inline(d, x.d, sizeof(d)) == 0;
}
bele_constexpr bool operator<(const BE32 &x) const noexcept {
return unsigned(*this) < unsigned(x);
}
}; };
struct alignas(1) BE64 final { struct alignas(1) BE64 final {
typedef upx_uint64_t integral_conversion_type; // automatic conversion to upx_uint64_t typedef upx_uint64_t integral_conversion_type; // automatic conversion to upx_uint64_t
byte d[8]; byte d[8];
forceinline operator upx_uint64_t() const noexcept { return get_be64(d); } static forceinline constexpr BE64 make(const BE64 &x) noexcept { return x; }
static forceinline bele_constexpr BE64 make(upx_uint64_t v) noexcept {
BE64 x = {};
set_be64(x.d, v);
return x;
}
forceinline BE64 &operator=(upx_uint64_t v) noexcept { forceinline bele_constexpr operator upx_uint64_t() const noexcept { return get_be64(d); }
forceinline bele_constexpr BE64 &operator=(upx_uint64_t v) noexcept {
set_be64(d, v); set_be64(d, v);
return *this; return *this;
} }
@@ -529,17 +674,33 @@ struct alignas(1) BE64 final {
return *this; return *this;
} }
bool operator==(const BE64 &x) const noexcept { return memcmp(d, x.d, sizeof(d)) == 0; } bele_constexpr bool operator==(const BE64 &x) const noexcept {
bool operator<(const BE64 &x) const noexcept { return upx_uint64_t(*this) < upx_uint64_t(x); } #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::mem_eq(d, x.d, sizeof(d));
else
#endif
return upx_memcmp_inline(d, x.d, sizeof(d)) == 0;
}
bele_constexpr bool operator<(const BE64 &x) const noexcept {
return upx_uint64_t(*this) < upx_uint64_t(x);
}
}; };
struct alignas(1) LE16 final { struct alignas(1) LE16 final {
typedef unsigned integral_conversion_type; // automatic conversion to unsigned typedef unsigned integral_conversion_type; // automatic conversion to unsigned
byte d[2]; byte d[2];
forceinline operator unsigned() const noexcept { return get_le16(d); } static forceinline constexpr LE16 make(const LE16 &x) noexcept { return x; }
static forceinline bele_constexpr LE16 make(unsigned v) noexcept {
LE16 x = {};
set_le16(x.d, v);
return x;
}
forceinline LE16 &operator=(unsigned v) noexcept { forceinline bele_constexpr operator unsigned() const noexcept { return get_le16(d); }
forceinline bele_constexpr LE16 &operator=(unsigned v) noexcept {
set_le16(d, v); set_le16(d, v);
return *this; return *this;
} }
@@ -580,17 +741,33 @@ struct alignas(1) LE16 final {
return *this; return *this;
} }
bool operator==(const LE16 &x) const noexcept { return memcmp(d, x.d, sizeof(d)) == 0; } bele_constexpr bool operator==(const LE16 &x) const noexcept {
bool operator<(const LE16 &x) const noexcept { return unsigned(*this) < unsigned(x); } #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::mem_eq(d, x.d, sizeof(d));
else
#endif
return upx_memcmp_inline(d, x.d, sizeof(d)) == 0;
}
bele_constexpr bool operator<(const LE16 &x) const noexcept {
return unsigned(*this) < unsigned(x);
}
}; };
struct alignas(1) LE32 final { struct alignas(1) LE32 final {
typedef unsigned integral_conversion_type; // automatic conversion to unsigned typedef unsigned integral_conversion_type; // automatic conversion to unsigned
byte d[4]; byte d[4];
forceinline operator unsigned() const noexcept { return get_le32(d); } static forceinline constexpr LE32 make(const LE32 &x) noexcept { return x; }
static forceinline bele_constexpr LE32 make(unsigned v) noexcept {
LE32 x = {};
set_le32(x.d, v);
return x;
}
forceinline LE32 &operator=(unsigned v) noexcept { forceinline bele_constexpr operator unsigned() const noexcept { return get_le32(d); }
forceinline bele_constexpr LE32 &operator=(unsigned v) noexcept {
set_le32(d, v); set_le32(d, v);
return *this; return *this;
} }
@@ -631,17 +808,33 @@ struct alignas(1) LE32 final {
return *this; return *this;
} }
bool operator==(const LE32 &x) const noexcept { return memcmp(d, x.d, sizeof(d)) == 0; } bele_constexpr bool operator==(const LE32 &x) const noexcept {
bool operator<(const LE32 &x) const noexcept { return unsigned(*this) < unsigned(x); } #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::mem_eq(d, x.d, sizeof(d));
else
#endif
return upx_memcmp_inline(d, x.d, sizeof(d)) == 0;
}
bele_constexpr bool operator<(const LE32 &x) const noexcept {
return unsigned(*this) < unsigned(x);
}
}; };
struct alignas(1) LE64 final { struct alignas(1) LE64 final {
typedef upx_uint64_t integral_conversion_type; // automatic conversion to upx_uint64_t typedef upx_uint64_t integral_conversion_type; // automatic conversion to upx_uint64_t
byte d[8]; byte d[8];
forceinline operator upx_uint64_t() const noexcept { return get_le64(d); } static forceinline constexpr LE64 make(const LE64 &x) noexcept { return x; }
static forceinline bele_constexpr LE64 make(upx_uint64_t v) noexcept {
LE64 x = {};
set_le64(x.d, v);
return x;
}
forceinline LE64 &operator=(upx_uint64_t v) noexcept { forceinline bele_constexpr operator upx_uint64_t() const noexcept { return get_le64(d); }
forceinline bele_constexpr LE64 &operator=(upx_uint64_t v) noexcept {
set_le64(d, v); set_le64(d, v);
return *this; return *this;
} }
@@ -682,8 +875,17 @@ struct alignas(1) LE64 final {
return *this; return *this;
} }
bool operator==(const LE64 &x) const noexcept { return memcmp(d, x.d, sizeof(d)) == 0; } bele_constexpr bool operator==(const LE64 &x) const noexcept {
bool operator<(const LE64 &x) const noexcept { return upx_uint64_t(*this) < upx_uint64_t(x); } #if defined(upx_is_constant_evaluated)
if (upx_is_constant_evaluated())
return upx::compile_time::mem_eq(d, x.d, sizeof(d));
else
#endif
return upx_memcmp_inline(d, x.d, sizeof(d)) == 0;
}
bele_constexpr bool operator<(const LE64 &x) const noexcept {
return upx_uint64_t(*this) < upx_uint64_t(x);
}
}; };
/************************************************************************* /*************************************************************************
@@ -691,35 +893,35 @@ struct alignas(1) LE64 final {
**************************************************************************/ **************************************************************************/
template <class T> template <class T>
inline T *operator+(T *ptr, const BE16 &v) noexcept { inline bele_constexpr T *operator+(T *ptr, const BE16 &v) noexcept {
return ptr + unsigned(v); return ptr + unsigned(v);
} }
template <class T> template <class T>
inline T *operator-(T *ptr, const BE16 &v) noexcept { inline bele_constexpr T *operator-(T *ptr, const BE16 &v) noexcept {
return ptr - unsigned(v); return ptr - unsigned(v);
} }
template <class T> template <class T>
inline T *operator+(T *ptr, const BE32 &v) noexcept { inline bele_constexpr T *operator+(T *ptr, const BE32 &v) noexcept {
return ptr + unsigned(v); return ptr + unsigned(v);
} }
template <class T> template <class T>
inline T *operator-(T *ptr, const BE32 &v) noexcept { inline bele_constexpr T *operator-(T *ptr, const BE32 &v) noexcept {
return ptr - unsigned(v); return ptr - unsigned(v);
} }
template <class T> template <class T>
inline T *operator+(T *ptr, const LE16 &v) noexcept { inline bele_constexpr T *operator+(T *ptr, const LE16 &v) noexcept {
return ptr + unsigned(v); return ptr + unsigned(v);
} }
template <class T> template <class T>
inline T *operator-(T *ptr, const LE16 &v) noexcept { inline bele_constexpr T *operator-(T *ptr, const LE16 &v) noexcept {
return ptr - unsigned(v); return ptr - unsigned(v);
} }
template <class T> template <class T>
inline T *operator+(T *ptr, const LE32 &v) noexcept { inline bele_constexpr T *operator+(T *ptr, const LE32 &v) noexcept {
return ptr + unsigned(v); return ptr + unsigned(v);
} }
template <class T> template <class T>
inline T *operator-(T *ptr, const LE32 &v) noexcept { inline bele_constexpr T *operator-(T *ptr, const LE32 &v) noexcept {
return ptr - unsigned(v); return ptr - unsigned(v);
} }
@@ -750,40 +952,96 @@ template <class T>
T *operator+(const LE64 &v, T *ptr) noexcept DELETED_FUNCTION; T *operator+(const LE64 &v, T *ptr) noexcept DELETED_FUNCTION;
/************************************************************************* /*************************************************************************
// global overloads // some global overloads
**************************************************************************/ **************************************************************************/
// TODO later: move these to upx namespace in util/cxxlib.h; see conf.h namespace upx {
inline unsigned ALIGN_DOWN(unsigned a, const BE32 &b) { return ALIGN_DOWN(a, unsigned(b)); }
inline unsigned ALIGN_DOWN(const BE32 &a, unsigned b) { return ALIGN_DOWN(unsigned(a), b); }
inline unsigned ALIGN_UP(unsigned a, const BE32 &b) { return ALIGN_UP(a, unsigned(b)); }
inline unsigned ALIGN_UP(const BE32 &a, unsigned b) { return ALIGN_UP(unsigned(a), b); }
inline unsigned ALIGN_DOWN(unsigned a, const LE32 &b) { return ALIGN_DOWN(a, unsigned(b)); } #define REQUIRE_UINT32 \
inline unsigned ALIGN_DOWN(const LE32 &a, unsigned b) { return ALIGN_DOWN(unsigned(a), b); } template <class T, class = std::enable_if_t<std::is_same_v<T, upx_uint32_t>, T> >
inline unsigned ALIGN_UP(unsigned a, const LE32 &b) { return ALIGN_UP(a, unsigned(b)); } #define REQUIRE_UINT64 \
inline unsigned ALIGN_UP(const LE32 &a, unsigned b) { return ALIGN_UP(unsigned(a), b); } template <class T, class = std::enable_if_t<std::is_same_v<T, upx_uint64_t>, T> >
// TODO later: introduce upx::umax() and upx::umin() REQUIRE_UINT32
inline unsigned UPX_MAX(unsigned a, const BE16 &b) { return UPX_MAX(a, unsigned(b)); } inline bele_constexpr T align_down(const T &a, const BE32 &b) noexcept {
inline unsigned UPX_MAX(const BE16 &a, unsigned b) { return UPX_MAX(unsigned(a), b); } return align_down(a, T(b));
inline unsigned UPX_MIN(unsigned a, const BE16 &b) { return UPX_MIN(a, unsigned(b)); } }
inline unsigned UPX_MIN(const BE16 &a, unsigned b) { return UPX_MIN(unsigned(a), b); } REQUIRE_UINT32
inline bele_constexpr T align_down(const BE32 &a, const T &b) noexcept {
return align_down(T(a), b);
}
REQUIRE_UINT32
inline bele_constexpr T align_down(const T &a, const LE32 &b) noexcept {
return align_down(a, T(b));
}
REQUIRE_UINT32
inline bele_constexpr T align_down(const LE32 &a, const T &b) noexcept {
return align_down(T(a), b);
}
inline unsigned UPX_MAX(unsigned a, const BE32 &b) { return UPX_MAX(a, unsigned(b)); } REQUIRE_UINT32
inline unsigned UPX_MAX(const BE32 &a, unsigned b) { return UPX_MAX(unsigned(a), b); } inline bele_constexpr T align_up(const T &a, const LE32 &b) noexcept { return align_up(a, T(b)); }
inline unsigned UPX_MIN(unsigned a, const BE32 &b) { return UPX_MIN(a, unsigned(b)); } REQUIRE_UINT32
inline unsigned UPX_MIN(const BE32 &a, unsigned b) { return UPX_MIN(unsigned(a), b); } inline bele_constexpr T align_up(const LE32 &a, const T &b) noexcept { return align_up(T(a), b); }
REQUIRE_UINT32
inline bele_constexpr T align_up(const T &a, const BE32 &b) noexcept { return align_up(a, T(b)); }
REQUIRE_UINT32
inline bele_constexpr T align_up(const BE32 &a, const T &b) noexcept { return align_up(T(a), b); }
inline unsigned UPX_MAX(unsigned a, const LE16 &b) { return UPX_MAX(a, unsigned(b)); } REQUIRE_UINT32
inline unsigned UPX_MAX(const LE16 &a, unsigned b) { return UPX_MAX(unsigned(a), b); } inline bele_constexpr T min(const T &a, const BE16 &b) noexcept { return min(a, T(b)); }
inline unsigned UPX_MIN(unsigned a, const LE16 &b) { return UPX_MIN(a, unsigned(b)); } REQUIRE_UINT32
inline unsigned UPX_MIN(const LE16 &a, unsigned b) { return UPX_MIN(unsigned(a), b); } inline bele_constexpr T min(const BE16 &a, const T &b) noexcept { return min(T(a), b); }
REQUIRE_UINT32
inline bele_constexpr T min(const T &a, const BE32 &b) noexcept { return min(a, T(b)); }
REQUIRE_UINT32
inline bele_constexpr T min(const BE32 &a, const T &b) noexcept { return min(T(a), b); }
REQUIRE_UINT64
inline bele_constexpr T min(const T &a, const BE64 &b) noexcept { return min(a, T(b)); }
REQUIRE_UINT64
inline bele_constexpr T min(const BE64 &a, const T &b) noexcept { return min(T(a), b); }
REQUIRE_UINT32
inline bele_constexpr T min(const T &a, const LE16 &b) noexcept { return min(a, T(b)); }
REQUIRE_UINT32
inline bele_constexpr T min(const LE16 &a, const T &b) noexcept { return min(T(a), b); }
REQUIRE_UINT32
inline bele_constexpr T min(const T &a, const LE32 &b) noexcept { return min(a, T(b)); }
REQUIRE_UINT32
inline bele_constexpr T min(const LE32 &a, const T &b) noexcept { return min(T(a), b); }
REQUIRE_UINT64
inline bele_constexpr T min(const T &a, const LE64 &b) noexcept { return min(a, T(b)); }
REQUIRE_UINT64
inline bele_constexpr T min(const LE64 &a, const T &b) noexcept { return min(T(a), b); }
inline unsigned UPX_MAX(unsigned a, const LE32 &b) { return UPX_MAX(a, unsigned(b)); } REQUIRE_UINT32
inline unsigned UPX_MAX(const LE32 &a, unsigned b) { return UPX_MAX(unsigned(a), b); } inline bele_constexpr T max(const T &a, const BE16 &b) noexcept { return max(a, T(b)); }
inline unsigned UPX_MIN(unsigned a, const LE32 &b) { return UPX_MIN(a, unsigned(b)); } REQUIRE_UINT32
inline unsigned UPX_MIN(const LE32 &a, unsigned b) { return UPX_MIN(unsigned(a), b); } inline bele_constexpr T max(const BE16 &a, const T &b) noexcept { return max(T(a), b); }
REQUIRE_UINT32
inline bele_constexpr T max(const T &a, const BE32 &b) noexcept { return max(a, T(b)); }
REQUIRE_UINT32
inline bele_constexpr T max(const BE32 &a, const T &b) noexcept { return max(T(a), b); }
REQUIRE_UINT64
inline bele_constexpr T max(const T &a, const BE64 &b) noexcept { return max(a, T(b)); }
REQUIRE_UINT64
inline bele_constexpr T max(const BE64 &a, const T &b) noexcept { return max(T(a), b); }
REQUIRE_UINT32
inline bele_constexpr T max(const T &a, const LE16 &b) noexcept { return max(a, T(b)); }
REQUIRE_UINT32
inline bele_constexpr T max(const LE16 &a, const T &b) noexcept { return max(T(a), b); }
REQUIRE_UINT32
inline bele_constexpr T max(const T &a, const LE32 &b) noexcept { return max(a, T(b)); }
REQUIRE_UINT32
inline bele_constexpr T max(const LE32 &a, const T &b) noexcept { return max(T(a), b); }
REQUIRE_UINT64
inline bele_constexpr T max(const T &a, const LE64 &b) noexcept { return max(a, T(b)); }
REQUIRE_UINT64
inline bele_constexpr T max(const LE64 &a, const T &b) noexcept { return max(T(a), b); }
#undef REQUIRE_UINT32
#undef REQUIRE_UINT64
} // namespace upx
/************************************************************************* /*************************************************************************
// misc support // misc support
+7 -7
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -33,7 +33,7 @@
#if defined(BELE_CTP) #if defined(BELE_CTP)
// CTP - Compile-Time Polymorphism (templates) // CTP - Compile-Time Polymorphism (templates)
#define V static inline #define V static inline bele_constexpr
#define VV static forceinline_constexpr #define VV static forceinline_constexpr
#define S static int __acc_cdecl_qsort #define S static int __acc_cdecl_qsort
#define C noexcept #define C noexcept
@@ -49,7 +49,7 @@
#if defined(BELE_RTP) #if defined(BELE_RTP)
struct AbstractPolicy { struct AbstractPolicy {
explicit inline AbstractPolicy() noexcept {} explicit inline AbstractPolicy() noexcept = default;
virtual inline ~AbstractPolicy() noexcept {} virtual inline ~AbstractPolicy() noexcept {}
V bool isBE() C = 0; V bool isBE() C = 0;
V bool isLE() C = 0; V bool isLE() C = 0;
@@ -97,7 +97,7 @@ struct BEPolicy final
: public AbstractPolicy : public AbstractPolicy
#endif #endif
{ {
explicit inline BEPolicy() noexcept {} explicit inline BEPolicy() noexcept = default;
#if defined(BELE_CTP) #if defined(BELE_CTP)
typedef N_BELE_RTP::BEPolicy RTP_Policy; typedef N_BELE_RTP::BEPolicy RTP_Policy;
#elif defined(BELE_RTP) #elif defined(BELE_RTP)
@@ -156,7 +156,7 @@ struct LEPolicy final
: public AbstractPolicy : public AbstractPolicy
#endif #endif
{ {
explicit inline LEPolicy() noexcept {} explicit inline LEPolicy() noexcept = default;
#if defined(BELE_CTP) #if defined(BELE_CTP)
typedef N_BELE_RTP::LEPolicy RTP_Policy; typedef N_BELE_RTP::LEPolicy RTP_Policy;
#elif defined(BELE_RTP) #elif defined(BELE_RTP)
@@ -210,7 +210,7 @@ private:
UPX_CXX_DISABLE_NEW_DELETE(LEPolicy) UPX_CXX_DISABLE_NEW_DELETE(LEPolicy)
}; };
// Native Endianness policy (aka host policy) // Native Endianness policy (aka Host Policy)
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
typedef BEPolicy NEPolicy; typedef BEPolicy NEPolicy;
typedef BEPolicy HostPolicy; typedef BEPolicy HostPolicy;
+770 -143
View File
File diff suppressed because it is too large Load Diff
+736 -206
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -32,87 +32,7 @@
#include "../conf.h" #include "../conf.h"
/************************************************************************* /*************************************************************************
// compile-time checks // standard C++ library
**************************************************************************/
// need extra parenthesis because the C preprocessor does not understand C++ templates
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_all_v<int>) )
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_all_v<int, int>) )
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_all_v<int, int, int>) )
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_all_v<int, char>) )
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_all_v<int, char, int>) )
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_all_v<int, int, char>) )
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int>) )
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<int, int>) )
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<int, char, int>) )
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<int, int, char>) )
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char>) )
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char, char>) )
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char, long>) )
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<ptrdiff_t, int, long, long long>) )
ACC_COMPILE_TIME_ASSERT_HEADER(
(upx::is_same_any_v<size_t, unsigned, unsigned long, unsigned long long>) )
ACC_COMPILE_TIME_ASSERT_HEADER(
(upx::is_same_any_v<upx_uintptr_t, unsigned, unsigned long, unsigned long long>) )
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == sizeof(int))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof('a') == sizeof(char))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("") == 1)
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("a") == 2)
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("ab") == 3)
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L'a') == sizeof(wchar_t))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L"") == 1 * sizeof(wchar_t))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L"a") == 2 * sizeof(wchar_t))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(L"ab") == 3 * sizeof(wchar_t))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0) == sizeof(int))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0L) == sizeof(long))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(0LL) == sizeof(long long))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(nullptr) == sizeof(void *))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(sizeof(0)) == sizeof(size_t))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(usizeof(0)) == sizeof(unsigned))
#if 0
// works, but may trigger clang/gcc warnings "-Wunused-value"
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof((1LL, 1)) == sizeof(int))
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof((1, 1LL)) == sizeof(long long))
#endif
namespace compile_time = upx::compile_time;
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("") == 0)
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("a") == 1)
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("ab") == 2)
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_len("abc") == 3)
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_eq("", ""))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("a", ""))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("", "a"))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_eq("abc", "abc"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("ab", "abc"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_eq("abc", "ab"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("", ""))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("a", ""))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_lt("", "a"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("abc", "abc"))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_lt("ab", "abc"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("abc", "ab"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_lt("abc", "aba"))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_lt("abc", "abz"))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_ne("abc", "abz"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_gt("abc", "abz"))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_ge("abc", "abz"))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_le("abc", "abz"))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq((const char *) nullptr, nullptr, 0))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq((const byte *) nullptr, nullptr, 0))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq("", "", 0))
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq("abc", "abc", 3))
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::mem_eq("abc", "abz", 3))
/*************************************************************************
//
**************************************************************************/ **************************************************************************/
TEST_CASE("std::vector") { TEST_CASE("std::vector") {
@@ -121,16 +41,16 @@ TEST_CASE("std::vector") {
CHECK(v.end() - v.begin() == N); CHECK(v.end() - v.begin() == N);
CHECK(&v[0] == &(*(v.begin()))); CHECK(&v[0] == &(*(v.begin())));
// CHECK(&v[0] + N == &(*(v.end()))); // TODO later: is this legal?? // CHECK(&v[0] + N == &(*(v.end()))); // TODO later: is this legal??
// TODO later: make sure that this throws #if defined(_LIBCPP_HARDENING_MODE) && defined(_LIBCPP_HARDENING_MODE_DEBUG) && \
#if defined(_LIBCPP_HARDENING_MODE_DEBUG) && \
(_LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG) (_LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG)
CHECK_THROWS((void) &v[N]); // unfortunately this does NOT throw but ABORTS
////CHECK_THROWS((void) &v[N]);
#endif #endif
UNUSED(v); UNUSED(v);
} }
/************************************************************************* /*************************************************************************
// UPX_CXX_DISABLE_xxx // core util: UPX_CXX_DISABLE_xxx, noncopyable
**************************************************************************/ **************************************************************************/
namespace { namespace {
@@ -246,119 +166,209 @@ struct Z2_X2 : public X2 {
} // namespace test_disable_new_delete } // namespace test_disable_new_delete
TEST_CASE("upx::noncopyable") {
struct Test : private upx::noncopyable {
int v = 1;
};
Test t = {};
CHECK(t.v == 1);
#if (ACC_CC_MSC) // MSVC thinks that Test is not std::is_trivially_copyable; true or compiler bug?
// @COMPILER_BUG @MSVC_BUG
t.v = 0;
#else
mem_clear(&t);
#endif
CHECK(t.v == 0);
constexpr Test x = {};
static_assert(x.v == 1);
}
/*************************************************************************
// <type_traits>
**************************************************************************/
static_assert(!upx::is_bounded_array_v<std::nullptr_t>);
static_assert(!upx::is_bounded_array_v<decltype(nullptr)>);
static_assert(!upx::is_bounded_array_v<void *>);
static_assert(!upx::is_bounded_array_v<int *>);
static_assert(!upx::is_bounded_array_v<const int *>);
static_assert(!upx::is_bounded_array_v<volatile int *>);
static_assert(!upx::is_bounded_array_v<const volatile int *>);
static_assert(upx::is_bounded_array_v<int[1]>);
static_assert(upx::is_bounded_array_v<const int[1]>);
static_assert(upx::is_bounded_array_v<volatile int[1]>);
static_assert(upx::is_bounded_array_v<const volatile int[1]>);
static_assert(upx::is_bounded_array_v<int[1u]>);
static_assert(upx::is_bounded_array_v<const int[1u]>);
static_assert(upx::is_bounded_array_v<volatile int[1u]>);
static_assert(upx::is_bounded_array_v<const volatile int[1u]>);
static_assert(upx::is_bounded_array_v<int[1l]>);
static_assert(upx::is_bounded_array_v<const int[1l]>);
static_assert(upx::is_bounded_array_v<volatile int[1l]>);
static_assert(upx::is_bounded_array_v<const volatile int[1l]>);
static_assert(upx::is_same_all_v<int>);
static_assert(upx::is_same_all_v<int, int>);
static_assert(upx::is_same_all_v<int, int, int>);
static_assert(!upx::is_same_all_v<int, char>);
static_assert(!upx::is_same_all_v<int, char, int>);
static_assert(!upx::is_same_all_v<int, int, char>);
static_assert(!upx::is_same_any_v<int>);
static_assert(upx::is_same_any_v<int, int>);
static_assert(upx::is_same_any_v<int, char, int>);
static_assert(upx::is_same_any_v<int, int, char>);
static_assert(!upx::is_same_any_v<int, char>);
static_assert(!upx::is_same_any_v<int, char, char>);
static_assert(!upx::is_same_any_v<int, char, long>);
static_assert(upx::is_same_any_v<ptrdiff_t, int, long, long long>);
static_assert(upx::is_same_any_v<size_t, unsigned, unsigned long, unsigned long long>);
static_assert(upx::is_same_any_v<upx_ptraddr_t, unsigned, unsigned long, unsigned long long>);
#if defined(__CHERI__) && defined(__CHERI_PURE_CAPABILITY__)
static_assert(!upx::is_same_any_v<upx_uintptr_t, unsigned, unsigned long, unsigned long long>);
#else
static_assert(upx::is_same_any_v<upx_uintptr_t, unsigned, unsigned long, unsigned long long>);
#endif
static_assert(std::is_same_v<int, upx::remove_cvref_t<int> >);
static_assert(std::is_same_v<int, upx::remove_cvref_t<const int> >);
static_assert(std::is_same_v<int, upx::remove_cvref_t<int &> >);
static_assert(std::is_same_v<int, upx::remove_cvref_t<const int &> >);
static_assert(std::is_same_v<int, upx::remove_cvref_t<int &&> >);
static_assert(std::is_same_v<int, upx::remove_cvref_t<const int &&> >);
static_assert(std::is_same_v<int *, upx::remove_cvref_t<int *> >);
static_assert(std::is_same_v<int *, upx::remove_cvref_t<int *const> >);
static_assert(std::is_same_v<const int *, upx::remove_cvref_t<const int *> >);
static_assert(std::is_same_v<int *, upx::remove_cvref_t<int *&> >);
static_assert(std::is_same_v<int *, upx::remove_cvref_t<int *const &> >);
static_assert(std::is_same_v<const int *, upx::remove_cvref_t<const int *&> >);
static_assert(std::is_same_v<int *, upx::remove_cvref_t<int *&&> >);
static_assert(std::is_same_v<int *, upx::remove_cvref_t<int *const &&> >);
static_assert(std::is_same_v<const int *, upx::remove_cvref_t<const int *&&> >);
static_assert(std::is_same_v<int[1], upx::remove_cvref_t<int[1]> >);
static_assert(std::is_same_v<int[1], upx::remove_cvref_t<const int[1]> >);
static_assert(std::is_same_v<int, upx::type_identity_t<int> >);
static_assert(std::is_same_v<const int, upx::type_identity_t<const int> >);
static_assert(std::is_same_v<int *, upx::type_identity_t<int *> >);
static_assert(std::is_same_v<int *const, upx::type_identity_t<int *const> >);
static_assert(std::is_same_v<const int *, upx::type_identity_t<const int *> >);
static_assert(std::is_same_v<int &, upx::type_identity_t<int &> >);
static_assert(std::is_same_v<const int &, upx::type_identity_t<const int &> >);
static_assert(std::is_same_v<int &&, upx::type_identity_t<int &&> >);
static_assert(std::is_same_v<const int &&, upx::type_identity_t<const int &&> >);
static_assert(std::is_same_v<int[1], upx::type_identity_t<int[1]> >);
static_assert(std::is_same_v<const int[1], upx::type_identity_t<const int[1]> >);
/*************************************************************************
// <bit>
**************************************************************************/
static_assert(!upx::has_single_bit(0));
static_assert(upx::has_single_bit(1));
static_assert(upx::has_single_bit(2));
static_assert(!upx::has_single_bit(3));
static_assert(upx::has_single_bit(4));
/*************************************************************************
// <algorithm>
**************************************************************************/
static_assert(upx::align_down(0, 4) == 0);
static_assert(upx::align_down(1, 4) == 0);
static_assert(upx::align_down(2, 4) == 0);
static_assert(upx::align_down(3, 4) == 0);
static_assert(upx::align_down(4, 4) == 4);
static_assert(upx::align_up(0, 4) == 0);
static_assert(upx::align_up(1, 4) == 4);
static_assert(upx::align_up(2, 4) == 4);
static_assert(upx::align_up(3, 4) == 4);
static_assert(upx::align_up(4, 4) == 4);
static_assert(upx::align_up_gap(0, 4) == 0);
static_assert(upx::align_up_gap(1, 4) == 3);
static_assert(upx::align_up_gap(2, 4) == 2);
static_assert(upx::align_up_gap(3, 4) == 1);
static_assert(upx::align_up_gap(4, 4) == 0);
static_assert(upx::min<upx_int8_t>(1, 2) == 1);
static_assert(upx::min<upx_int16_t>(1, 2) == 1);
static_assert(upx::min<upx_int32_t>(1, 2) == 1);
static_assert(upx::min<upx_int64_t>(1, 2) == 1);
static_assert(upx::min<intmax_t>(1, 2) == 1);
static_assert(upx::max<upx_int8_t>(1, 2) == 2);
static_assert(upx::max<upx_int16_t>(1, 2) == 2);
static_assert(upx::max<upx_int32_t>(1, 2) == 2);
static_assert(upx::max<upx_int64_t>(1, 2) == 2);
static_assert(upx::max<intmax_t>(1, 2) == 2);
static_assert(upx::min(1, 2) == 1);
static_assert(upx::min(1l, 2l) == 1);
static_assert(upx::min(1ll, 2ll) == 1);
static_assert(upx::max(1, 2) == 2);
static_assert(upx::max(1l, 2l) == 2);
static_assert(upx::max(1ll, 2ll) == 2);
static_assert(upx::umin<upx_uint8_t>(1, 2) == 1);
static_assert(upx::umin<upx_uint16_t>(1, 2) == 1);
static_assert(upx::umin<upx_uint32_t>(1, 2) == 1);
static_assert(upx::umin<upx_uint64_t>(1, 2) == 1);
static_assert(upx::umin<uintmax_t>(1, 2) == 1);
static_assert(upx::umax<upx_uint8_t>(1, 2) == 2);
static_assert(upx::umax<upx_uint16_t>(1, 2) == 2);
static_assert(upx::umax<upx_uint32_t>(1, 2) == 2);
static_assert(upx::umax<upx_uint64_t>(1, 2) == 2);
static_assert(upx::umax<uintmax_t>(1, 2) == 2);
static_assert(upx::umin(1u, 2u) == 1);
static_assert(upx::umin(1ul, 2ul) == 1);
static_assert(upx::umin(1ull, 2ull) == 1);
static_assert(upx::umax(1u, 2u) == 2);
static_assert(upx::umax(1ul, 2ul) == 2);
static_assert(upx::umax(1ull, 2ull) == 2);
static_assert(upx::wrapping_add<upx_int8_t>(127, 2) == -127);
static_assert(upx::wrapping_add<upx_int16_t>(32767, 2) == -32767);
static_assert(upx::wrapping_add(2147483647, 2) == -2147483647);
static_assert(upx::wrapping_add(9223372036854775807ll, 2ll) == -9223372036854775807ll);
static_assert(upx::wrapping_sub<upx_int8_t>(-127, 2) == 127);
static_assert(upx::wrapping_sub<upx_int16_t>(-32767, 2) == 32767);
static_assert(upx::wrapping_sub(-2147483647, 2) == 2147483647);
static_assert(upx::wrapping_sub(-9223372036854775807ll, 2ll) == 9223372036854775807ll);
static_assert(upx::wrapping_add<upx_uint8_t>(255, 2) == 1);
static_assert(upx::wrapping_sub<upx_uint8_t>(1, 2) == 255);
/************************************************************************* /*************************************************************************
// util // util
**************************************************************************/ **************************************************************************/
#if WITH_THREADS // upx::UnsignedSizeOf
TEST_CASE("upx::ptr_std_atomic_cast") { static_assert(usizeof(int) == sizeof(int));
// pointer-size static_assert(usizeof('a') == sizeof(char));
CHECK_EQ(upx::ptr_std_atomic_cast((void **) nullptr), nullptr); static_assert(usizeof("") == 1);
CHECK_EQ(upx::ptr_std_atomic_cast((uintptr_t *) nullptr), nullptr); static_assert(usizeof("a") == 2);
CHECK_EQ(upx::ptr_std_atomic_cast((upx_uintptr_t *) nullptr), nullptr); static_assert(usizeof("ab") == 3);
#if 1 static_assert(usizeof(L'a') == sizeof(wchar_t));
// more fundamental types static_assert(usizeof(L"") == 1 * sizeof(wchar_t));
CHECK_EQ(upx::ptr_std_atomic_cast((char *) nullptr), nullptr); static_assert(usizeof(L"a") == 2 * sizeof(wchar_t));
CHECK_EQ(upx::ptr_std_atomic_cast((short *) nullptr), nullptr); static_assert(usizeof(L"ab") == 3 * sizeof(wchar_t));
CHECK_EQ(upx::ptr_std_atomic_cast((int *) nullptr), nullptr); static_assert(usizeof(0) == sizeof(int));
CHECK_EQ(upx::ptr_std_atomic_cast((long *) nullptr), nullptr); static_assert(usizeof(0L) == sizeof(long));
CHECK_EQ(upx::ptr_std_atomic_cast((ptrdiff_t *) nullptr), nullptr); static_assert(usizeof(0LL) == sizeof(long long));
CHECK_EQ(upx::ptr_std_atomic_cast((size_t *) nullptr), nullptr); static_assert(usizeof(nullptr) == sizeof(void *));
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int8_t *) nullptr), nullptr); static_assert(usizeof(sizeof(0)) == sizeof(size_t));
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int16_t *) nullptr), nullptr); static_assert(usizeof(usizeof(0)) == sizeof(unsigned));
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int32_t *) nullptr), nullptr); #if 0
// works, but may trigger clang/gcc warnings "-Wunused-value"
static_assert(usizeof((1LL, 1)) == sizeof(int));
static_assert(usizeof((1, 1LL)) == sizeof(long long));
#endif #endif
}
#endif
TEST_CASE("upx::atomic_exchange") {
{
upx_uintptr_t x = (upx_uintptr_t) 0 - 1;
upx_uintptr_t y = upx::atomic_exchange(&x, (upx_uintptr_t) 2);
CHECK_EQ(x, 2);
CHECK_EQ(y, (upx_uintptr_t) 0 - 1);
UNUSED(y);
}
{
const int buf[2] = {101, 202};
const int *ptr_array[2] = {&buf[0], &buf[1]};
assert_noexcept(*ptr_array[0] == 101 && *ptr_array[1] == 202);
const int *p = upx::atomic_exchange(&ptr_array[0], ptr_array[1]);
CHECK_EQ(p, buf + 0);
assert_noexcept(*ptr_array[0] == 202 && *ptr_array[1] == 202);
p = upx::atomic_exchange(&ptr_array[1], p);
CHECK_EQ(p, buf + 1);
assert_noexcept(*ptr_array[0] == 202 && *ptr_array[1] == 101);
UNUSED(p);
}
}
TEST_CASE("upx::ObjectDeleter 1") {
LE16 *o = nullptr; // object
LE32 *a = nullptr; // array
LE64 *m = nullptr; // malloc
{
auto o_deleter = upx::ObjectDeleter(&o, 1);
o = new LE16;
assert(o != nullptr);
auto a_deleter = upx::ArrayDeleter(&a, 1);
a = New(LE32, 1);
assert(a != nullptr);
auto m_deleter = upx::MallocDeleter(&m, 1);
m = (LE64 *) ::malloc(sizeof(LE64));
assert(m != nullptr);
}
assert(o == nullptr);
assert(a == nullptr);
assert(m == nullptr);
// test "const" versions
{
const auto o_deleter = upx::ObjectDeleter(&o, 1);
o = new LE16;
assert(o != nullptr);
const auto a_deleter = upx::ArrayDeleter(&a, 1);
a = New(LE32, 1);
assert(a != nullptr);
const auto m_deleter = upx::MallocDeleter(&m, 1);
m = (LE64 *) ::malloc(sizeof(LE64));
assert(m != nullptr);
}
assert(o == nullptr);
assert(a == nullptr);
assert(m == nullptr);
}
TEST_CASE("upx::ObjectDeleter 2") {
constexpr size_t N = 2;
BE16 *o[N]; // multiple objects
BE32 *a[N]; // multiple arrays
BE64 *m[N]; // multiple mallocs
{
auto o_deleter = upx::ObjectDeleter(o, 0);
auto a_deleter = upx::ArrayDeleter(a, 0);
auto m_deleter = upx::MallocDeleter(m, 0);
for (size_t i = 0; i < N; i++) {
o[i] = new BE16;
assert(o[i] != nullptr);
o_deleter.count += 1;
a[i] = New(BE32, 1 + i);
assert(a[i] != nullptr);
a_deleter.count += 1;
m[i] = (BE64 *) ::malloc(sizeof(BE64));
assert(m[i] != nullptr);
m_deleter.count += 1;
}
}
for (size_t i = 0; i < N; i++) {
assert(o[i] == nullptr);
assert(a[i] == nullptr);
assert(m[i] == nullptr);
}
}
TEST_CASE("upx::ptr_static_cast") { TEST_CASE("upx::ptr_static_cast") {
// check that we do not trigger any -Wcast-align warnings // check that we do not trigger any -Wcast-align warnings
using upx::ptr_static_cast; using upx::ptr_static_cast;
void *vp = nullptr; void *vp = nullptr;
byte *bp = nullptr; byte *bp = nullptr;
int *ip = nullptr; int *ip = nullptr;
@@ -396,30 +406,550 @@ TEST_CASE("upx::ptr_static_cast") {
assert((ic == ptr_static_cast<const int *>(ic))); assert((ic == ptr_static_cast<const int *>(ic)));
} }
TEST_CASE("upx::noncopyable") { TEST_CASE("upx::ptr_static_cast constexpr 1") {
struct Test : private upx::noncopyable { // check that casts work at compile-time
int v = 1; using upx::ptr_static_cast;
};
Test t = {}; constexpr void *vp = nullptr;
CHECK(t.v == 1); constexpr byte *bp = nullptr;
#if (ACC_CC_MSC) // MSVC thinks that Test is not std::is_trivially_copyable; true or compiler bug? constexpr int *ip = nullptr;
// @COMPILER_BUG @MSVC_BUG constexpr double *dp = nullptr;
t.v = 0; static_assert((vp == ptr_static_cast<void *>(vp)));
#else static_assert((bp == ptr_static_cast<byte *>(bp)));
mem_clear(&t); static_assert((ip == ptr_static_cast<int *>(ip)));
static_assert((dp == ptr_static_cast<double *>(dp)));
constexpr const void *vc = nullptr;
constexpr const byte *bc = nullptr;
constexpr const int *ic = nullptr;
constexpr const double *dc = nullptr;
static_assert((vc == ptr_static_cast<const void *>(vc)));
static_assert((bc == ptr_static_cast<const byte *>(bc)));
static_assert((ic == ptr_static_cast<const int *>(ic)));
static_assert((dc == ptr_static_cast<const double *>(dc)));
constexpr void **vpp = nullptr;
constexpr byte **bpp = nullptr;
constexpr int **ipp = nullptr;
constexpr double **dpp = nullptr;
static_assert((vpp == ptr_static_cast<void **>(vpp)));
static_assert((bpp == ptr_static_cast<byte **>(bpp)));
static_assert((ipp == ptr_static_cast<int **>(ipp)));
static_assert((dpp == ptr_static_cast<double **>(dpp)));
constexpr const void **vcp = nullptr;
constexpr const byte **bcp = nullptr;
constexpr const int **icp = nullptr;
constexpr const double **dcp = nullptr;
static_assert((vcp == ptr_static_cast<const void **>(vcp)));
static_assert((bcp == ptr_static_cast<const byte **>(bcp)));
static_assert((icp == ptr_static_cast<const int **>(icp)));
static_assert((dcp == ptr_static_cast<const double **>(dcp)));
constexpr void *const *vpc = nullptr;
constexpr byte *const *bpc = nullptr;
constexpr int *const *ipc = nullptr;
constexpr double *const *dpc = nullptr;
static_assert((vpc == ptr_static_cast<void *const *>(vpc)));
static_assert((bpc == ptr_static_cast<byte *const *>(bpc)));
static_assert((ipc == ptr_static_cast<int *const *>(ipc)));
static_assert((dpc == ptr_static_cast<double *const *>(dpc)));
constexpr const void *const *vcc = nullptr;
constexpr const byte *const *bcc = nullptr;
constexpr const int *const *icc = nullptr;
constexpr const double *const *dcc = nullptr;
static_assert((vcc == ptr_static_cast<const void *const *>(vcc)));
static_assert((bcc == ptr_static_cast<const byte *const *>(bcc)));
static_assert((icc == ptr_static_cast<const int *const *>(icc)));
static_assert((dcc == ptr_static_cast<const double *const *>(dcc)));
}
TEST_CASE("upx::ptr_static_cast constexpr 2") {
// check that casts work at compile-time
using upx::ptr_static_cast;
constexpr void *vp = nullptr;
constexpr byte *bp = nullptr;
constexpr int *ip = nullptr;
constexpr double *dp = nullptr;
static_assert((vp == static_cast<void *>(vp)));
static_assert((vp == static_cast<void *>(bp)));
static_assert((vp == static_cast<void *>(ip)));
static_assert((vp == static_cast<void *>(dp)));
static_assert((vp == ptr_static_cast<void *>(vp)));
static_assert((vp == ptr_static_cast<void *>(bp)));
static_assert((vp == ptr_static_cast<void *>(ip)));
static_assert((vp == ptr_static_cast<void *>(dp)));
constexpr const void *vc = nullptr;
constexpr const byte *bc = nullptr;
constexpr const int *ic = nullptr;
constexpr const double *dc = nullptr;
static_assert((vc == static_cast<const void *>(vp)));
static_assert((vc == static_cast<const void *>(bp)));
static_assert((vc == static_cast<const void *>(ip)));
static_assert((vc == static_cast<const void *>(dp)));
static_assert((vc == ptr_static_cast<const void *>(vp)));
static_assert((vc == ptr_static_cast<const void *>(dp)));
static_assert((vc == ptr_static_cast<const void *>(bp)));
static_assert((vc == ptr_static_cast<const void *>(ip)));
static_assert((vc == static_cast<const void *>(vc)));
static_assert((vc == static_cast<const void *>(bc)));
static_assert((vc == static_cast<const void *>(ic)));
static_assert((vc == static_cast<const void *>(dc)));
static_assert((vc == ptr_static_cast<const void *>(vc)));
static_assert((vc == ptr_static_cast<const void *>(dc)));
static_assert((vc == ptr_static_cast<const void *>(bc)));
static_assert((vc == ptr_static_cast<const void *>(ic)));
// these are invalid:
//// constexpr char *cc1 = static_cast<char *>(bp);
//// constexpr char *cc2 = ptr_static_cast<char *>(bp);
//// constexpr unsigned *uc1 = static_cast<unsigned *>(ip);
//// constexpr unsigned *uc2 = ptr_static_cast<unsigned *>(ip);
}
#if WITH_THREADS
TEST_CASE("upx::ptr_std_atomic_cast") {
// pointer-size
CHECK_EQ(upx::ptr_std_atomic_cast((void **) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((uintptr_t *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((upx_uintptr_t *) nullptr), nullptr);
#if 1
// more fundamental types
CHECK_EQ(upx::ptr_std_atomic_cast((char *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((short *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((int *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((long *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((ptrdiff_t *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((size_t *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int8_t *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int16_t *) nullptr), nullptr);
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int32_t *) nullptr), nullptr);
#endif #endif
CHECK(t.v == 0); }
constexpr Test x = {}; #endif // WITH_THREADS
static_assert(x.v == 1);
TEST_CASE("upx::atomic_exchange") {
{
upx_uintptr_t x = (upx_uintptr_t) 0 - 1;
upx_uintptr_t y = upx::atomic_exchange(&x, (upx_uintptr_t) 2);
CHECK_EQ(x, 2);
CHECK_EQ(y, (upx_uintptr_t) 0 - 1);
UNUSED(y);
}
{
const int buf[2] = {101, 202};
const int *ptr_array[2] = {&buf[0], &buf[1]};
assert_noexcept(*ptr_array[0] == 101 && *ptr_array[1] == 202);
const int *p = upx::atomic_exchange(&ptr_array[0], ptr_array[1]);
CHECK_EQ(p, buf + 0);
assert_noexcept(*ptr_array[0] == 202 && *ptr_array[1] == 202);
p = upx::atomic_exchange(&ptr_array[1], p);
CHECK_EQ(p, buf + 1);
assert_noexcept(*ptr_array[0] == 202 && *ptr_array[1] == 101);
UNUSED(p);
}
}
TEST_CASE("upx::ObjectDeleter 1") {
LE16 *o = nullptr; // object
LE32 *a = nullptr; // array
LE64 *m = nullptr; // malloc
{
// auto o_deleter = upx::ObjectDeleter(&o, 1);
upx::ObjectDeleter<LE16> o_deleter = upx::ObjectDeleter(&o, 1);
o = new LE16;
assert(o != nullptr);
auto a_deleter = upx::ArrayDeleter(&a, 1);
a = New(LE32, 1);
assert(a != nullptr);
auto m_deleter = upx::MallocDeleter(&m, 1);
m = (LE64 *) ::malloc(sizeof(LE64));
assert(m != nullptr);
}
assert(o == nullptr);
assert(a == nullptr);
assert(m == nullptr);
// test "const" versions
{
const auto o_deleter = upx::ObjectDeleter(&o, 1);
o = new LE16;
assert(o != nullptr);
const auto a_deleter = upx::ArrayDeleter(&a, 1);
a = New(LE32, 1);
assert(a != nullptr);
const auto m_deleter = upx::MallocDeleter(&m, 1);
m = (LE64 *) ::malloc(sizeof(LE64));
assert(m != nullptr);
}
assert(o == nullptr);
assert(a == nullptr);
assert(m == nullptr);
}
TEST_CASE("upx::ObjectDeleter 2") {
constexpr size_t N = 2;
BE16 *o[N]; // multiple objects
BE32 *a[N]; // multiple arrays
BE64 *m[N]; // multiple mallocs
{
// auto o_deleter = upx::ObjectDeleter(o, 0);
upx::ObjectDeleter<BE16> o_deleter = upx::ObjectDeleter(o, 0);
auto a_deleter = upx::ArrayDeleter(a, 0);
auto m_deleter = upx::MallocDeleter(m, 0);
for (size_t i = 0; i < N; i++) {
o[i] = new BE16;
assert(o[i] != nullptr);
o_deleter.count += 1;
a[i] = New(BE32, 1 + i);
assert(a[i] != nullptr);
a_deleter.count += 1;
m[i] = (BE64 *) ::malloc(sizeof(BE64));
assert(m[i] != nullptr);
m_deleter.count += 1;
}
}
for (size_t i = 0; i < N; i++) {
assert(o[i] == nullptr);
assert(a[i] == nullptr);
assert(m[i] == nullptr);
}
} }
/************************************************************************* /*************************************************************************
// TriBool checks // namespace upx::compile_time
**************************************************************************/
static_assert(upx::compile_time::string_len("") == 0);
static_assert(upx::compile_time::string_len("a") == 1);
static_assert(upx::compile_time::string_len("ab") == 2);
static_assert(upx::compile_time::string_len("abc") == 3);
static_assert(upx::compile_time::string_eq("", ""));
static_assert(!upx::compile_time::string_eq("a", ""));
static_assert(!upx::compile_time::string_eq("", "a"));
static_assert(upx::compile_time::string_eq("abc", "abc"));
static_assert(!upx::compile_time::string_eq("ab", "abc"));
static_assert(!upx::compile_time::string_eq("abc", "ab"));
static_assert(!upx::compile_time::string_lt("", ""));
static_assert(!upx::compile_time::string_lt("a", ""));
static_assert(upx::compile_time::string_lt("", "a"));
static_assert(!upx::compile_time::string_lt("abc", "abc"));
static_assert(upx::compile_time::string_lt("ab", "abc"));
static_assert(!upx::compile_time::string_lt("abc", "ab"));
static_assert(!upx::compile_time::string_lt("abc", "aba"));
static_assert(upx::compile_time::string_lt("abc", "abz"));
static_assert(upx::compile_time::string_ne("abc", "abz"));
static_assert(!upx::compile_time::string_gt("abc", "abz"));
static_assert(!upx::compile_time::string_ge("abc", "abz"));
static_assert(upx::compile_time::string_le("abc", "abz"));
static_assert(upx::compile_time::mem_eq((const char *) nullptr, (const char *) nullptr, 0));
static_assert(upx::compile_time::mem_eq((const char *) nullptr, (const byte *) nullptr, 0));
static_assert(upx::compile_time::mem_eq((const byte *) nullptr, (const char *) nullptr, 0));
static_assert(upx::compile_time::mem_eq((const byte *) nullptr, (const byte *) nullptr, 0));
static_assert(upx::compile_time::mem_eq("", "", 0));
static_assert(upx::compile_time::mem_eq("abc", "abc", 3));
static_assert(!upx::compile_time::mem_eq("abc", "abz", 3));
static_assert(upx::compile_time::bswap16(0x0102) == 0x0201);
static_assert(upx::compile_time::bswap32(0x01020304) == 0x04030201);
static_assert(upx::compile_time::bswap64(0x0102030405060708ull) == 0x0807060504030201ull);
namespace {
struct alignas(1) TestCT final {
byte d[8]; // public data
static constexpr TestCT makeBE16(upx_uint16_t v) noexcept {
TestCT x = {};
upx::compile_time::set_be16(x.d, v);
return x;
}
static constexpr TestCT makeBE24(upx_uint32_t v) noexcept {
TestCT x = {};
upx::compile_time::set_be24(x.d, v);
return x;
}
static constexpr TestCT makeBE32(upx_uint32_t v) noexcept {
TestCT x = {};
upx::compile_time::set_be32(x.d, v);
return x;
}
static constexpr TestCT makeBE64(upx_uint64_t v) noexcept {
TestCT x = {};
upx::compile_time::set_be64(x.d, v);
return x;
}
static constexpr TestCT makeLE16(upx_uint16_t v) noexcept {
TestCT x = {};
upx::compile_time::set_le16(x.d, v);
return x;
}
static constexpr TestCT makeLE24(upx_uint32_t v) noexcept {
TestCT x = {};
upx::compile_time::set_le24(x.d, v);
return x;
}
static constexpr TestCT makeLE32(upx_uint32_t v) noexcept {
TestCT x = {};
upx::compile_time::set_le32(x.d, v);
return x;
}
static constexpr TestCT makeLE64(upx_uint64_t v) noexcept {
TestCT x = {};
upx::compile_time::set_le64(x.d, v);
return x;
}
// run-time
static noinline upx_uint16_t noinline_bswap16(upx_uint16_t v) noexcept {
return upx::compile_time::bswap16(v);
}
static noinline upx_uint32_t noinline_bswap32(upx_uint32_t v) noexcept {
return upx::compile_time::bswap32(v);
}
static noinline upx_uint64_t noinline_bswap64(upx_uint64_t v) noexcept {
return upx::compile_time::bswap64(v);
}
static noinline upx_uint16_t noinline_get_be16(const byte *p) noexcept {
return upx::compile_time::get_be16(p);
}
static noinline upx_uint32_t noinline_get_be24(const byte *p) noexcept {
return upx::compile_time::get_be24(p);
}
static noinline upx_uint32_t noinline_get_be32(const byte *p) noexcept {
return upx::compile_time::get_be32(p);
}
static noinline upx_uint64_t noinline_get_be64(const byte *p) noexcept {
return upx::compile_time::get_be64(p);
}
static noinline upx_uint16_t noinline_get_le16(const byte *p) noexcept {
return upx::compile_time::get_le16(p);
}
static noinline upx_uint32_t noinline_get_le24(const byte *p) noexcept {
return upx::compile_time::get_le24(p);
}
static noinline upx_uint32_t noinline_get_le32(const byte *p) noexcept {
return upx::compile_time::get_le32(p);
}
static noinline upx_uint64_t noinline_get_le64(const byte *p) noexcept {
return upx::compile_time::get_le64(p);
}
static noinline void noinline_set_be16(byte * p, upx_uint16_t v) noexcept {
upx::compile_time::set_be16(p, v);
}
static noinline void noinline_set_be24(byte * p, upx_uint32_t v) noexcept {
upx::compile_time::set_be24(p, v);
}
static noinline void noinline_set_be32(byte * p, upx_uint32_t v) noexcept {
upx::compile_time::set_be32(p, v);
}
static noinline void noinline_set_be64(byte * p, upx_uint64_t v) noexcept {
upx::compile_time::set_be64(p, v);
}
static noinline void noinline_set_le16(byte * p, upx_uint16_t v) noexcept {
upx::compile_time::set_le16(p, v);
}
static noinline void noinline_set_le24(byte * p, upx_uint32_t v) noexcept {
upx::compile_time::set_le24(p, v);
}
static noinline void noinline_set_le32(byte * p, upx_uint32_t v) noexcept {
upx::compile_time::set_le32(p, v);
}
static noinline void noinline_set_le64(byte * p, upx_uint64_t v) noexcept {
upx::compile_time::set_le64(p, v);
}
};
static_assert(sizeof(TestCT) == 8);
static_assert(alignof(TestCT) == 1);
} // namespace
TEST_CASE("upx::compile_time 1") {
constexpr upx_uint16_t v16 = 0x0201;
constexpr upx_uint32_t v24 = 0x030201;
constexpr upx_uint32_t v32 = 0x04030201;
constexpr upx_uint64_t v64 = 0x0807060504030201ull;
{
static_assert(upx::compile_time::bswap16(v16) == 0x0102);
static_assert(upx::compile_time::bswap32(v32) == 0x01020304);
static_assert(upx::compile_time::bswap64(v64) == 0x0102030405060708ull);
assert_noexcept(TestCT::noinline_bswap16(v16) == 0x0102);
assert_noexcept(TestCT::noinline_bswap32(v32) == 0x01020304);
assert_noexcept(TestCT::noinline_bswap64(v64) == 0x0102030405060708ull);
}
{
constexpr const byte d[8] = {1, 2, 3, 4, 5, 6, 7, 8};
static_assert(upx::compile_time::get_be16(d) == 0x0102);
static_assert(upx::compile_time::get_be24(d) == 0x010203);
static_assert(upx::compile_time::get_be32(d) == 0x01020304);
static_assert(upx::compile_time::get_be64(d) == 0x0102030405060708ull);
static_assert(upx::compile_time::get_le16(d) == 0x0201);
static_assert(upx::compile_time::get_le24(d) == 0x030201);
static_assert(upx::compile_time::get_le32(d) == 0x04030201);
static_assert(upx::compile_time::get_le64(d) == 0x0807060504030201ull);
}
{
using upx::compile_time::mem_eq;
upx_alignas_max byte aligned_buffer[16] = {};
upx::compile_time::mem_set(aligned_buffer, 0xff, 16);
assert_noexcept(mem_eq(aligned_buffer, aligned_buffer + 8, 8));
byte *const buf = aligned_buffer + 7;
constexpr auto be16 = TestCT::makeBE16(v16);
static_assert(upx::compile_time::get_be16(be16.d) == v16);
static_assert(mem_eq(be16.d, "\x02\x01", 2));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_be16(buf, v16);
assert_noexcept(TestCT::noinline_get_be16(buf) == v16);
assert_noexcept(upx::compile_time::get_be16(buf) == v16);
assert_noexcept(memcmp(buf, be16.d, 8) == 0);
constexpr auto be24 = TestCT::makeBE24(v24);
static_assert(upx::compile_time::get_be24(be24.d) == v24);
static_assert(mem_eq(be24.d, "\x03\x02\x01", 3));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_be24(buf, v24);
assert_noexcept(TestCT::noinline_get_be24(buf) == v24);
assert_noexcept(upx::compile_time::get_be24(buf) == v24);
assert_noexcept(memcmp(buf, be24.d, 8) == 0);
constexpr auto be32 = TestCT::makeBE32(v32);
static_assert(upx::compile_time::get_be32(be32.d) == v32);
static_assert(mem_eq(be32.d, "\x04\x03\x02\x01", 4));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_be32(buf, v32);
assert_noexcept(TestCT::noinline_get_be32(buf) == v32);
assert_noexcept(upx::compile_time::get_be32(buf) == v32);
assert_noexcept(memcmp(buf, be32.d, 8) == 0);
constexpr auto be64 = TestCT::makeBE64(v64);
static_assert(upx::compile_time::get_be64(be64.d) == v64);
static_assert(mem_eq(be64.d, "\x08\x07\x06\x05\x04\x03\x02\x01", 8));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_be64(buf, v64);
assert_noexcept(TestCT::noinline_get_be64(buf) == v64);
assert_noexcept(upx::compile_time::get_be64(buf) == v64);
assert_noexcept(memcmp(buf, be64.d, 8) == 0);
constexpr auto le16 = TestCT::makeLE16(v16);
static_assert(upx::compile_time::get_le16(le16.d) == v16);
static_assert(mem_eq(le16.d, "\x01\x02", 2));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_le16(buf, v16);
assert_noexcept(TestCT::noinline_get_le16(buf) == v16);
assert_noexcept(upx::compile_time::get_le16(buf) == v16);
assert_noexcept(memcmp(buf, le16.d, 8) == 0);
constexpr auto le24 = TestCT::makeLE24(v24);
static_assert(upx::compile_time::get_le24(le24.d) == v24);
static_assert(mem_eq(le24.d, "\x01\x02\x03", 3));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_le24(buf, v24);
assert_noexcept(TestCT::noinline_get_le24(buf) == v24);
assert_noexcept(upx::compile_time::get_le24(buf) == v24);
assert_noexcept(memcmp(buf, le24.d, 8) == 0);
constexpr auto le32 = TestCT::makeLE32(v32);
static_assert(upx::compile_time::get_le32(le32.d) == v32);
static_assert(mem_eq(le32.d, "\x01\x02\x03\x04", 4));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_le32(buf, v32);
assert_noexcept(TestCT::noinline_get_le32(buf) == v32);
assert_noexcept(upx::compile_time::get_le32(buf) == v32);
assert_noexcept(memcmp(buf, le32.d, 8) == 0);
constexpr auto le64 = TestCT::makeLE64(v64);
static_assert(upx::compile_time::get_le64(le64.d) == v64);
static_assert(mem_eq(le64.d, "\x01\x02\x03\x04\x05\x06\x07\x08", 8));
upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_le64(buf, v64);
assert_noexcept(TestCT::noinline_get_le64(buf) == v64);
assert_noexcept(upx::compile_time::get_le64(buf) == v64);
assert_noexcept(memcmp(buf, le64.d, 8) == 0);
static_assert(upx::compile_time::bswap16(upx::compile_time::get_be16(be16.d)) ==
upx::compile_time::get_be16(le16.d));
static_assert(upx::compile_time::bswap32(upx::compile_time::get_be32(be32.d)) ==
upx::compile_time::get_be32(le32.d));
static_assert(upx::compile_time::bswap64(upx::compile_time::get_be64(be64.d)) ==
upx::compile_time::get_be64(le64.d));
assert_noexcept(TestCT::noinline_bswap16(TestCT::noinline_get_be16(be16.d)) ==
TestCT::noinline_get_be16(le16.d));
assert_noexcept(TestCT::noinline_bswap32(TestCT::noinline_get_be32(be32.d)) ==
TestCT::noinline_get_be32(le32.d));
assert_noexcept(TestCT::noinline_bswap64(TestCT::noinline_get_be64(be64.d)) ==
TestCT::noinline_get_be64(le64.d));
}
}
TEST_CASE("upx::compile_time 2") {
constexpr upx_uint16_t v16 = 0xf2f1;
constexpr upx_uint32_t v24 = 0xf3f2f1;
constexpr upx_uint32_t v32 = 0xf4f3f2f1;
constexpr upx_uint64_t v64 = 0xf8f7f6f5f4f3f2f1ull;
{
using upx::compile_time::mem_eq;
upx_alignas_max byte aligned_buffer[32];
byte *const buf1 = aligned_buffer + 3;
byte *const buf2 = aligned_buffer + 13;
upx::compile_time::set_be16(buf1, v16);
TestCT::noinline_set_be16(buf2, v16);
assert_noexcept(TestCT::noinline_get_be16(buf1) == v16);
assert_noexcept(TestCT::noinline_get_be16(buf2) == v16);
assert_noexcept(memcmp(buf1, buf2, 2) == 0);
upx::compile_time::set_be24(buf1, v24);
TestCT::noinline_set_be24(buf2, v24);
assert_noexcept(TestCT::noinline_get_be24(buf1) == v24);
assert_noexcept(TestCT::noinline_get_be24(buf2) == v24);
assert_noexcept(memcmp(buf1, buf2, 3) == 0);
upx::compile_time::set_be32(buf1, v32);
TestCT::noinline_set_be32(buf2, v32);
assert_noexcept(TestCT::noinline_get_be32(buf1) == v32);
assert_noexcept(TestCT::noinline_get_be32(buf2) == v32);
assert_noexcept(memcmp(buf1, buf2, 4) == 0);
upx::compile_time::set_be64(buf1, v64);
TestCT::noinline_set_be64(buf2, v64);
assert_noexcept(TestCT::noinline_get_be64(buf1) == v64);
assert_noexcept(TestCT::noinline_get_be64(buf2) == v64);
assert_noexcept(memcmp(buf1, buf2, 8) == 0);
upx::compile_time::set_le16(buf1, v16);
TestCT::noinline_set_le16(buf2, v16);
assert_noexcept(TestCT::noinline_get_le16(buf1) == v16);
assert_noexcept(TestCT::noinline_get_le16(buf2) == v16);
assert_noexcept(memcmp(buf1, buf2, 2) == 0);
upx::compile_time::set_le24(buf1, v24);
TestCT::noinline_set_le24(buf2, v24);
assert_noexcept(TestCT::noinline_get_le24(buf1) == v24);
assert_noexcept(TestCT::noinline_get_le24(buf2) == v24);
assert_noexcept(memcmp(buf1, buf2, 3) == 0);
upx::compile_time::set_le32(buf1, v32);
TestCT::noinline_set_le32(buf2, v32);
assert_noexcept(TestCT::noinline_get_le32(buf1) == v32);
assert_noexcept(TestCT::noinline_get_le32(buf2) == v32);
assert_noexcept(memcmp(buf1, buf2, 4) == 0);
upx::compile_time::set_le64(buf1, v64);
TestCT::noinline_set_le64(buf2, v64);
assert_noexcept(TestCT::noinline_get_le64(buf1) == v64);
assert_noexcept(TestCT::noinline_get_le64(buf2) == v64);
assert_noexcept(memcmp(buf1, buf2, 8) == 0);
}
}
/*************************************************************************
// TriBool
**************************************************************************/ **************************************************************************/
namespace { namespace {
template <class T> template <class T>
struct TestTriBool { struct TestTriBool final {
static noinline void test(bool expect_true) { static noinline void test(bool expect_true) {
static_assert(std::is_class<T>::value); static_assert(std::is_class<T>::value);
static_assert(std::is_nothrow_default_constructible<T>::value); static_assert(std::is_nothrow_default_constructible<T>::value);
+10 -2
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -55,10 +55,18 @@
#endif #endif
#endif #endif
#if defined(__FAST_MATH__) && defined(__clang__) && (__clang_major__ + 0 >= 6) #if defined(__FAST_MATH__) && defined(__clang__) && (__clang_major__ + 0 > 0)
#if __clang_major__ >= 6
// warning: comparison with NaN always evaluates to false in fast floating point modes // warning: comparison with NaN always evaluates to false in fast floating point modes
#pragma clang diagnostic ignored "-Wtautological-constant-compare" #pragma clang diagnostic ignored "-Wtautological-constant-compare"
#endif #endif
#if defined(__has_warning)
#if __has_warning("-Wnan-infinity-disabled")
// warning: use of NaN is undefined behavior due to the currently enabled floating-point options
#pragma clang diagnostic ignored "-Wnan-infinity-disabled"
#endif
#endif
#endif
#include <doctest/doctest/parts/doctest.cpp> #include <doctest/doctest/parts/doctest.cpp>
+1 -1
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+1 -1
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+1 -1
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+1 -1
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+15 -43
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -30,11 +30,9 @@
#if (ACC_CC_CLANG) #if (ACC_CC_CLANG)
#pragma clang diagnostic ignored "-Wshadow" #pragma clang diagnostic ignored "-Wshadow"
#endif #elif (ACC_CC_GNUC >= 0x040200)
#if (ACC_CC_GNUC >= 0x040200)
#pragma GCC diagnostic ignored "-Wshadow" #pragma GCC diagnostic ignored "-Wshadow"
#endif #elif (ACC_CC_MSC)
#if (ACC_CC_MSC)
#pragma warning(disable : 4456) // -Wno-shadow #pragma warning(disable : 4456) // -Wno-shadow
#endif #endif
@@ -50,41 +48,15 @@ void lzma_compress_config_t::reset() noexcept {
max_num_probs = 0; max_num_probs = 0;
} }
// INFO: the LZMA SDK is covered by a permissive license which allows // INFO: LZMA SDK is placed in the public domain.
// using unmodified LZMA source code in UPX and the UPX stubs.
// See SPECIAL EXCEPTION below.
// //
// Quoting from lzma-4.43/lzma.txt: // Anyone is free to copy, modify, publish, use, compile, sell, or
// distribute the original LZMA SDK code, either in source code form
// or as a compiled binary, for any purpose, commercial or non-commercial,
// and by any means.
// //
// LICENSE // https://www.7-zip.org/sdk.html
// ------- // https://sourceforge.net/p/sevenzip/discussion/45797/thread/685169cf/
//
// LZMA SDK is available under any of the following licenses:
//
// 1) GNU Lesser General Public License (GNU LGPL)
// 2) Common Public License (CPL)
// 3) Simplified license for unmodified code (read SPECIAL EXCEPTION)
// 4) Proprietary license
//
// It means that you can select one of these four options and follow rules
// of that license.
//
// 1,2) GNU LGPL and CPL licenses are pretty similar and both these
// licenses are classified as
// - "Free software licenses" at http://www.gnu.org/
// - "OSI-approved" at http://www.opensource.org/
//
// 3) SPECIAL EXCEPTION
//
// Igor Pavlov, as the author of this code, expressly permits you
// to statically or dynamically link your code (or bind by name)
// to the files from LZMA SDK without subjecting your linked
// code to the terms of the CPL or GNU LGPL.
// Any modifications or additions to files from LZMA SDK, however,
// are subject to the GNU LGPL or CPL terms.
//
// SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code,
// while you keep LZMA SDK code unmodified.
/************************************************************************* /*************************************************************************
// compress defaults // compress defaults
@@ -155,11 +127,11 @@ static bool prepare_result(lzma_compress_result_t *res, unsigned src_len, int me
// cconf overrides // cconf overrides
if (lcconf) { if (lcconf) {
oassign(res->pos_bits, lcconf->pos_bits); upx::oassign(res->pos_bits, lcconf->pos_bits);
oassign(res->lit_pos_bits, lcconf->lit_pos_bits); upx::oassign(res->lit_pos_bits, lcconf->lit_pos_bits);
oassign(res->lit_context_bits, lcconf->lit_context_bits); upx::oassign(res->lit_context_bits, lcconf->lit_context_bits);
oassign(res->dict_size, lcconf->dict_size); upx::oassign(res->dict_size, lcconf->dict_size);
oassign(res->num_fast_bytes, lcconf->num_fast_bytes); upx::oassign(res->num_fast_bytes, lcconf->num_fast_bytes);
} }
// limit dictionary size // limit dictionary size
+5 -1
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -248,8 +248,12 @@ static void __UCL_CDECL my_free(ucl_voidp p) { free(p); }
} // extern "C" } // extern "C"
int upx_ucl_init(void) { int upx_ucl_init(void) {
#if (ACC_CC_MSC && ACC_ARCH_I386) && (_MSC_VER >= 1940)
(void) ucl_init(); // TODO later
#else
if (ucl_init() != UCL_E_OK) if (ucl_init() != UCL_E_OK)
return -1; return -1;
#endif
if (UCL_VERSION != ucl_version() || strcmp(UCL_VERSION_STRING, ucl_version_string()) != 0) if (UCL_VERSION != ucl_version() || strcmp(UCL_VERSION_STRING, ucl_version_string()) != 0)
return -2; return -2;
ucl_set_malloc_hooks(my_malloc, my_free); ucl_set_malloc_hooks(my_malloc, my_free);
+15 -11
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -25,13 +25,6 @@
*/ */
#include "../conf.h" #include "../conf.h"
#include "compress.h"
#include "../util/membuffer.h"
// NOLINTBEGIN(clang-analyzer-optin.performance.Padding)
#define ZLIB_CONST 1
#include <zlib/zlib.h>
#include <zlib/deflate.h>
// NOLINTEND(clang-analyzer-optin.performance.Padding)
void zlib_compress_config_t::reset() noexcept { void zlib_compress_config_t::reset() noexcept {
mem_clear(this); mem_clear(this);
@@ -40,6 +33,15 @@ void zlib_compress_config_t::reset() noexcept {
strategy.reset(); strategy.reset();
} }
#if WITH_ZLIB
#include "compress.h"
#include "../util/membuffer.h"
// NOLINTBEGIN(clang-analyzer-optin.performance.Padding)
#define ZLIB_CONST 1
#include <zlib/zlib.h>
#include <zlib/deflate.h>
// NOLINTEND(clang-analyzer-optin.performance.Padding)
static int convert_errno_from_zlib(int zr) { static int convert_errno_from_zlib(int zr) {
switch (zr) { switch (zr) {
case Z_OK: case Z_OK:
@@ -95,9 +97,9 @@ int upx_zlib_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsi
zlib_compress_config_t::strategy_t strategy; zlib_compress_config_t::strategy_t strategy;
// cconf overrides // cconf overrides
if (lcconf) { if (lcconf) {
oassign(mem_level, lcconf->mem_level); upx::oassign(mem_level, lcconf->mem_level);
oassign(window_bits, lcconf->window_bits); upx::oassign(window_bits, lcconf->window_bits);
oassign(strategy, lcconf->strategy); upx::oassign(strategy, lcconf->strategy);
} }
z_stream s; z_stream s;
@@ -307,4 +309,6 @@ TEST_CASE("upx_zlib_decompress") {
UNUSED(r); UNUSED(r);
} }
#endif // WITH_ZLIB
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */
+1 -1
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+91 -79
View File
@@ -1,9 +1,9 @@
/* conf.h -- /* conf.h -- primary configuration
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -32,6 +32,7 @@
**************************************************************************/ **************************************************************************/
#include "util/system_headers.h" #include "util/system_headers.h"
#include "util/system_undefs.h"
#include "version.h" #include "version.h"
#if !defined(__has_attribute) #if !defined(__has_attribute)
@@ -40,29 +41,46 @@
#if !defined(__has_builtin) #if !defined(__has_builtin)
#define __has_builtin(x) 0 #define __has_builtin(x) 0
#endif #endif
#if !defined(__has_declspec_attribute)
#define __has_declspec_attribute(x) 0
#endif
#if !defined(__has_feature) #if !defined(__has_feature)
#define __has_feature(x) 0 #define __has_feature(x) 0
#endif #endif
#if !defined(__has_include)
#define __has_include(x) 0
#endif
#if !defined(__has_warning)
#define __has_warning(x) 0
#endif
// reserve name "upx" for namespace // reserve name "upx" for namespace
namespace upx {} namespace upx {}
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_BIT == 8) // check compiler core
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2) static_assert(CHAR_BIT == 8);
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4) static_assert(sizeof(short) == 2);
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(long long) == 8) static_assert(sizeof(int) == 4);
static_assert(sizeof(long long) == 8);
// check sane compiler mandatory flags // check sane compiler mandatory flags
ACC_COMPILE_TIME_ASSERT_HEADER(-1 == ~0) // two's complement - see http://wg21.link/P0907R4 static_assert(-1 == ~0); // two's complement - see https://wg21.link/P0907R4
ACC_COMPILE_TIME_ASSERT_HEADER(0u - 1 == ~0u) // two's complement - see http://wg21.link/P0907R4 static_assert(0u - 1 == ~0u); // two's complement - see https://wg21.link/P0907R4
ACC_COMPILE_TIME_ASSERT_HEADER((1u << 31) << 1 == 0) static_assert((1u << 31) << 1 == 0);
ACC_COMPILE_TIME_ASSERT_HEADER(((int) (1u << 31)) >> 31 == -1) // arithmetic right shift static_assert(((int) (1u << 31)) >> 31 == -1); // arithmetic right shift
ACC_COMPILE_TIME_ASSERT_HEADER((-1) >> 31 == -1) // arithmetic right shift static_assert((-1) >> 31 == -1); // arithmetic right shift
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char static_assert(CHAR_MAX == 255); // -funsigned-char
ACC_COMPILE_TIME_ASSERT_HEADER((char) (-1) == 255) static_assert((char) (-1) == 255); // -funsigned-char
// disable some more strict warnings
#if defined(__clang__) && __has_warning("-Wunnecessary-virtual-specifier")
#pragma clang diagnostic ignored "-Wunnecessary-virtual-specifier"
#endif
// enable some more strict warnings for Git developer builds // enable some more strict warnings for Git developer builds
#if defined(UPX_CONFIG_DISABLE_WSTRICT) && (UPX_CONFIG_DISABLE_WSTRICT + 0 == 0) #if defined(UPX_CONFIG_DISABLE_WSTRICT) && (UPX_CONFIG_DISABLE_WSTRICT + 0 == 0)
#if defined(UPX_CONFIG_DISABLE_WERROR) && (UPX_CONFIG_DISABLE_WERROR + 0 == 0) #if defined(UPX_CONFIG_DISABLE_WERROR) && (UPX_CONFIG_DISABLE_WERROR + 0 == 0)
#if (ACC_CC_MSC)
#pragma warning(error : 4714) // W4: function marked as __forceinline not inlined
#endif
#if (ACC_CC_CLANG >= 0x0b0000) #if (ACC_CC_CLANG >= 0x0b0000)
#pragma clang diagnostic error "-Wsuggest-override" #pragma clang diagnostic error "-Wsuggest-override"
#elif (ACC_CC_GNUC >= 0x0a0000) #elif (ACC_CC_GNUC >= 0x0a0000)
@@ -82,6 +100,14 @@ ACC_COMPILE_TIME_ASSERT_HEADER((char) (-1) == 255)
#endif // UPX_CONFIG_DISABLE_WERROR #endif // UPX_CONFIG_DISABLE_WERROR
#endif // UPX_CONFIG_DISABLE_WSTRICT #endif // UPX_CONFIG_DISABLE_WSTRICT
#if __cplusplus >= 202002L // C++20
#define upx_is_constant_evaluated std::is_constant_evaluated
#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
// multithreading (UPX currently does not use multithreading) // multithreading (UPX currently does not use multithreading)
#if (WITH_THREADS) #if (WITH_THREADS)
#define upx_thread_local thread_local #define upx_thread_local thread_local
@@ -115,7 +141,7 @@ inline constexpr bool upx_is_integral_v = upx_is_integral<T>::value;
#define upx_fake_alignas_16 __attribute__((__aligned__(2))) // object file maximum 2 ??? #define upx_fake_alignas_16 __attribute__((__aligned__(2))) // object file maximum 2 ???
#define upx_fake_alignas__(x) upx_fake_alignas_##x #define upx_fake_alignas__(x) upx_fake_alignas_##x
#define alignas(x) upx_fake_alignas__(x) #define alignas(x) upx_fake_alignas__(x)
#define upx_alignas_max upx_fake_alignas_4 #define upx_alignas_max upx_fake_alignas_2
#endif #endif
#ifndef upx_alignas_max #ifndef upx_alignas_max
#define upx_alignas_max alignas(std::max_align_t) #define upx_alignas_max alignas(std::max_align_t)
@@ -143,7 +169,19 @@ typedef acc_int32_t upx_int32_t;
typedef acc_uint32_t upx_uint32_t; typedef acc_uint32_t upx_uint32_t;
typedef acc_int64_t upx_int64_t; typedef acc_int64_t upx_int64_t;
typedef acc_uint64_t upx_uint64_t; typedef acc_uint64_t upx_uint64_t;
#if (__SIZEOF_INT128__ == 16)
typedef __int128 upx_int128_t;
typedef unsigned __int128 upx_uint128_t;
#endif
typedef acc_uintptr_t upx_uintptr_t; typedef acc_uintptr_t upx_uintptr_t;
#if defined(__PTRADDR_TYPE__) // CHERI
typedef __PTRADDR_TYPE__ upx_ptraddr_t;
#else
typedef upx_uintptr_t upx_ptraddr_t;
#endif
typedef std::make_signed_t<upx_ptraddr_t> upx_sptraddr_t; // signed ptraddr_t
typedef std::make_unsigned_t<ptrdiff_t> upx_uptrdiff_t; // unsigned ptrdiff_t
typedef std::make_signed_t<size_t> upx_ssize_t; // signed size_t
// UPX convention: use "byte" when dealing with data; use "char/uchar" when dealing // UPX convention: use "byte" when dealing with data; use "char/uchar" when dealing
// with strings; use "upx_uint8_t" when dealing with small integers // with strings; use "upx_uint8_t" when dealing with small integers
@@ -156,10 +194,10 @@ typedef unsigned char uchar;
// upx_charptr_unit_type is some opaque type with sizeof(type) == 1 // upx_charptr_unit_type is some opaque type with sizeof(type) == 1
//// typedef char upx_charptr_unit_type; // also works //// typedef char upx_charptr_unit_type; // also works
struct alignas(1) upx_charptr_unit_type final { char hidden__; }; struct alignas(1) upx_charptr_unit_type final { char hidden__; };
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(upx_charptr_unit_type) == 1) static_assert(sizeof(upx_charptr_unit_type) == 1);
// using the system off_t was a bad idea even back in 199x... // using the system off_t was a bad idea even back in 199x...
typedef upx_int64_t upx_off_t; typedef long long upx_off_t;
#undef off_t #undef off_t
#if 0 #if 0
// TODO later cleanup: at some future point we can do this: // TODO later cleanup: at some future point we can do this:
@@ -192,7 +230,7 @@ typedef upx_int64_t upx_off_t;
#define very_likely __acc_very_likely #define very_likely __acc_very_likely
#define very_unlikely __acc_very_unlikely #define very_unlikely __acc_very_unlikely
// cosmetic: explicitly annotate some functions which may throw exceptions // cosmetic: explicitly annotate some functions which may throw exceptions;
// note that noexcept(false) is the default for all C++ functions anyway // note that noexcept(false) is the default for all C++ functions anyway
#define may_throw noexcept(false) #define may_throw noexcept(false)
@@ -204,20 +242,6 @@ typedef upx_int64_t upx_off_t;
// portab // portab
**************************************************************************/ **************************************************************************/
// some platform system headers may pre-define these, so undef to avoid conflicts
#undef _
#undef __
#undef ___
#undef dos
#undef large
#undef linux
#undef PAGE_MASK
#undef PAGE_SIZE
#undef small
#undef SP
#undef SS
#undef tos
#undef unix
#if (ACC_OS_POSIX) && !defined(__unix__) #if (ACC_OS_POSIX) && !defined(__unix__)
#define __unix__ 1 #define __unix__ 1
#endif #endif
@@ -286,6 +310,14 @@ typedef upx_int64_t upx_off_t;
#endif #endif
#endif #endif
// some platforms may provide their own system bswapXX() functions, so rename to avoid conflicts
#undef bswap16
#undef bswap32
#undef bswap64
#define bswap16 upx_bswap16
#define bswap32 upx_bswap32
#define bswap64 upx_bswap64
// avoid warnings about shadowing global symbols // avoid warnings about shadowing global symbols
#undef _base #undef _base
#undef basename #undef basename
@@ -340,11 +372,18 @@ typedef upx_int64_t upx_off_t;
// for no-op debug output // for no-op debug output
inline void NO_printf(const char *, ...) noexcept attribute_format(1, 2); inline void NO_printf(const char *, ...) noexcept attribute_format(1, 2);
inline void NO_fprintf(FILE *, const char *, ...) noexcept attribute_format(2, 3);
inline void NO_printf(const char *, ...) noexcept {} inline void NO_printf(const char *, ...) noexcept {}
inline void NO_fprintf(FILE *, const char *, ...) noexcept attribute_format(2, 3);
inline void NO_fprintf(FILE *, const char *, ...) noexcept {} inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
#if __has_builtin(__builtin_memcpy_inline) #if __has_builtin(__builtin_memcmp)
#define upx_memcmp_inline __builtin_memcmp
#elif defined(__clang__) || defined(__GNUC__)
#define upx_memcmp_inline __builtin_memcmp
#else
#define upx_memcmp_inline memcmp
#endif
#if __has_builtin(__builtin_memcpy_inline) && 0 // TODO later: clang constexpr limitation?
#define upx_memcpy_inline __builtin_memcpy_inline #define upx_memcpy_inline __builtin_memcpy_inline
#elif __has_builtin(__builtin_memcpy) #elif __has_builtin(__builtin_memcpy)
#define upx_memcpy_inline __builtin_memcpy #define upx_memcpy_inline __builtin_memcpy
@@ -394,39 +433,6 @@ inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
#define TABLESIZE(table) ((sizeof(table) / sizeof((table)[0]))) #define TABLESIZE(table) ((sizeof(table) / sizeof((table)[0])))
// TODO later: move these to upx namespace in util/cxxlib.h; also see bele.h
template <class T>
inline T ALIGN_DOWN(const T &a, const T &b) {
T r;
r = (a / b) * b;
return r;
}
template <class T>
inline T ALIGN_UP(const T &a, const T &b) {
T r;
r = ((a + b - 1) / b) * b;
return r;
}
template <class T>
inline T ALIGN_GAP(const T &a, const T &b) {
T r;
r = ALIGN_UP(a, b) - a;
return r;
}
template <class T>
inline const T &UPX_MAX(const T &a, const T &b) {
if (a < b)
return b;
return a;
}
template <class T>
inline const T &UPX_MIN(const T &a, const T &b) {
if (a < b)
return a;
return b;
}
template <class T> template <class T>
inline void mem_clear(T *object) noexcept { inline void mem_clear(T *object) noexcept {
static_assert(std::is_class_v<T>); // UPX convention static_assert(std::is_class_v<T>); // UPX convention
@@ -474,11 +480,13 @@ noreturn void throwAssertFailed(const char *expr, const char *file, int line, co
// C++ support library // C++ support library
#include "util/cxxlib.h" #include "util/cxxlib.h"
using upx::is_same_any_v;
using upx::noncopyable;
using upx::OptVar;
using upx::tribool; using upx::tribool;
#define usizeof(expr) (upx::UnsignedSizeOf<sizeof(expr)>::value) #define usizeof(expr) (upx::UnsignedSizeOf<sizeof(expr)>::value)
#define ALIGN_DOWN(a, b) (upx::align_down((a), (b)))
#define ALIGN_UP(a, b) (upx::align_up((a), (b)))
#define ALIGN_UP_GAP(a, b) (upx::align_up_gap((a), (b)))
#define UPX_MAX(a, b) (upx::max((a), (b)))
#define UPX_MIN(a, b) (upx::min((a), (b)))
/************************************************************************* /*************************************************************************
// constants // constants
@@ -620,7 +628,9 @@ using upx::tribool;
#define WITH_LZMA 1 #define WITH_LZMA 1
#define WITH_UCL 1 #define WITH_UCL 1
#ifndef WITH_ZLIB
#define WITH_ZLIB 1 #define WITH_ZLIB 1
#endif
#if (WITH_UCL) #if (WITH_UCL)
#define ucl_compress_config_t REAL_ucl_compress_config_t #define ucl_compress_config_t REAL_ucl_compress_config_t
#include <ucl/include/ucl/uclconf.h> #include <ucl/include/ucl/uclconf.h>
@@ -650,11 +660,11 @@ struct bzip2_compress_config_t final {
}; };
struct lzma_compress_config_t final { struct lzma_compress_config_t final {
typedef OptVar<unsigned, 2u, 0u, 4u> pos_bits_t; // pb typedef upx::OptVar<unsigned, 2u, 0u, 4u> pos_bits_t; // pb
typedef OptVar<unsigned, 0u, 0u, 4u> lit_pos_bits_t; // lp typedef upx::OptVar<unsigned, 0u, 0u, 4u> lit_pos_bits_t; // lp
typedef OptVar<unsigned, 3u, 0u, 8u> lit_context_bits_t; // lc typedef upx::OptVar<unsigned, 3u, 0u, 8u> lit_context_bits_t; // lc
typedef OptVar<unsigned, (1u << 22), 1u, (1u << 30)> dict_size_t; typedef upx::OptVar<unsigned, (1u << 22), 1u, (1u << 30)> dict_size_t;
typedef OptVar<unsigned, 64u, 5u, 273u> num_fast_bytes_t; typedef upx::OptVar<unsigned, 64u, 5u, 273u> num_fast_bytes_t;
pos_bits_t pos_bits; // pb pos_bits_t pos_bits; // pb
lit_pos_bits_t lit_pos_bits; // lp lit_pos_bits_t lit_pos_bits; // lp
@@ -674,9 +684,9 @@ struct ucl_compress_config_t final : public REAL_ucl_compress_config_t {
}; };
struct zlib_compress_config_t final { struct zlib_compress_config_t final {
typedef OptVar<unsigned, 8u, 1u, 9u> mem_level_t; // ml typedef upx::OptVar<unsigned, 8u, 1u, 9u> mem_level_t; // ml
typedef OptVar<unsigned, 15u, 9u, 15u> window_bits_t; // wb typedef upx::OptVar<unsigned, 15u, 9u, 15u> window_bits_t; // wb
typedef OptVar<unsigned, 0u, 0u, 4u> strategy_t; // st typedef upx::OptVar<unsigned, 0u, 0u, 4u> strategy_t; // st
mem_level_t mem_level; // ml mem_level_t mem_level; // ml
window_bits_t window_bits; // wb window_bits_t window_bits; // wb
@@ -860,5 +870,7 @@ int upx_test_overlap ( const upx_bytep buf,
// xspan // xspan
#include "util/raw_bytes.h" #include "util/raw_bytes.h"
#include "util/xspan.h" #include "util/xspan.h"
//
#include "util/system_check_predefs.h"
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+6 -6
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -152,7 +152,7 @@ void throwCantPack(const char *format, ...) {
char msg[1024]; char msg[1024];
va_list ap; va_list ap;
va_start(ap, format); 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); va_end(ap);
throwCantPack(msg); throwCantPack(msg);
} }
@@ -162,7 +162,7 @@ void throwCantUnpack(const char *format, ...) {
char msg[1024]; char msg[1024];
va_list ap; va_list ap;
va_start(ap, format); 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); va_end(ap);
throwCantUnpack(msg); throwCantUnpack(msg);
} }
@@ -172,9 +172,9 @@ void throwInternalError(const char *format, ...) {
char msg[1024]; char msg[1024];
va_list ap; va_list ap;
va_start(ap, format); 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); va_end(ap);
throwCantUnpack(msg); throwInternalError(msg);
} }
/************************************************************************* /*************************************************************************
+7 -7
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -133,7 +133,7 @@ public:
CantPackException(const char *m = nullptr, bool w = false) noexcept : super(m, 0, w) {} CantPackException(const char *m = nullptr, bool w = false) noexcept : super(m, 0, w) {}
}; };
class UnknownExecutableFormatException : public CantPackException { class UnknownExecutableFormatException final : public CantPackException {
typedef CantPackException super; typedef CantPackException super;
public: public:
UnknownExecutableFormatException(const char *m = nullptr, bool w = false) noexcept UnknownExecutableFormatException(const char *m = nullptr, bool w = false) noexcept
@@ -200,15 +200,15 @@ noreturn void throwEOFException(const char *msg = nullptr, int e = 0) may_throw;
// some C++ template wizardry is needed to overload throwCantPack() for varargs // some C++ template wizardry is needed to overload throwCantPack() for varargs
template <class T> template <class T>
void throwCantPack(const T *, ...) DELETED_FUNCTION; void throwCantPack(const T *, ...) DELETED_FUNCTION;
template <>
noreturn void throwCantPack(const char *format, ...) may_throw attribute_format(1, 2);
template <class T> template <class T>
void throwCantUnpack(const T *, ...) DELETED_FUNCTION; void throwCantUnpack(const T *, ...) DELETED_FUNCTION;
template <>
noreturn void throwCantUnpack(const char *format, ...) may_throw attribute_format(1, 2);
template <class T> template <class T>
void throwInternalError(const T *, ...) DELETED_FUNCTION; void throwInternalError(const T *, ...) DELETED_FUNCTION;
template <> template <>
noreturn void throwCantPack(const char *format, ...) may_throw attribute_format(1, 2);
template <>
noreturn void throwCantUnpack(const char *format, ...) may_throw attribute_format(1, 2);
template <>
noreturn void throwInternalError(const char *format, ...) may_throw attribute_format(1, 2); noreturn void throwInternalError(const char *format, ...) may_throw attribute_format(1, 2);
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */
+12 -12
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -129,7 +129,8 @@ void FileBase::closex() may_throw {
upx_off_t FileBase::seek(upx_off_t off, int whence) { upx_off_t FileBase::seek(upx_off_t off, int whence) {
if (!isOpen()) if (!isOpen())
throwIOException("bad seek 1"); throwIOException("bad seek 1");
mem_size_assert(1, off >= 0 ? off : -off); // sanity check if (!mem_size_valid_bytes(off >= 0 ? off : -off)) // sanity check
throwIOException("bad seek");
if (whence == SEEK_SET) { if (whence == SEEK_SET) {
if (off < 0) if (off < 0)
throwIOException("bad seek 2"); throwIOException("bad seek 2");
@@ -318,26 +319,25 @@ void OutputFile::rewrite(SPAN_P(const void) buf, int len) {
} }
upx_off_t OutputFile::seek(upx_off_t off, int whence) { upx_off_t OutputFile::seek(upx_off_t off, int whence) {
mem_size_assert(1, off >= 0 ? off : -off); // sanity check if (!mem_size_valid_bytes(off >= 0 ? off : -off)) // sanity check
throwIOException("bad seek");
assert(!opt->to_stdout); assert(!opt->to_stdout);
switch (whence) { switch (whence) {
case SEEK_SET: { case SEEK_SET:
if (bytes_written < off) { if (bytes_written < off)
bytes_written = off; bytes_written = off;
}
_length = bytes_written; // cheap, lazy update; needed? _length = bytes_written; // cheap, lazy update; needed?
} break; break;
case SEEK_END: { case SEEK_END:
_length = bytes_written; // necessary _length = bytes_written; // necessary
} break; break;
} }
return super::seek(off, whence); return super::seek(off, whence);
} }
// WARNING: fsync() does not exist in some Windows environments. // WARNING: fsync() does not exist in some Windows environments.
// This trick works only on UNIX-like systems. // This trick works only on UNIX-like systems.
// int OutputFile::read(void *buf, int len) // int OutputFile::read(void *buf, int len) {
//{
// fsync(_fd); // fsync(_fd);
// InputFile infile; // InputFile infile;
// infile.open(this->getName(), O_RDONLY | O_BINARY); // infile.open(this->getName(), O_RDONLY | O_BINARY);
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+6 -6
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -355,6 +355,7 @@ static int s_ct24arm_be(Filter *f) {
**************************************************************************/ **************************************************************************/
#if 1 //{ old reliable #if 1 //{ old reliable
#define CT26ARM_LE(f, cond, addvalue, get, set) \ #define CT26ARM_LE(f, cond, addvalue, get, set) \
byte *b = f->buf; \ byte *b = f->buf; \
byte *b_end = b + f->buf_len - 4; \ byte *b_end = b + f->buf_len - 4; \
@@ -387,10 +388,9 @@ static int s_ct26arm_le(Filter *f) {
#else //}{ new enhanced but DIFFERENT; need new filter type! #else //}{ new enhanced but DIFFERENT; need new filter type!
static int CTarm64(Filter *f, int dir) // dir: 1, 0, -1 static int CTarm64(Filter *f, int dir) { // dir: 1, 0, -1
{ byte *b = f->buf; // will be incremented
upx_byte *b = f->buf; // will be incremented byte *const b_end = b + f->buf_len - 4;
upx_byte *const b_end = b + f->buf_len - 4;
do { do {
unsigned const a = b - f->buf; unsigned const a = b - f->buf;
int const d = dir * (f->addvalue + (a >> 2)); int const d = dir * (f->addvalue + (a >> 2));
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+4 -5
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -28,8 +28,6 @@
#include "../conf.h" #include "../conf.h"
#include "../filter.h" #include "../filter.h"
static unsigned umin(const unsigned a, const unsigned b) { return (a <= b) ? a : b; }
#define set_dummy(p, v) ((void) 0) #define set_dummy(p, v) ((void) 0)
#define get_8(p) (*(p)) #define get_8(p) (*(p))
#define set_8(p, v) (*(p) = (v)) #define set_8(p, v) (*(p) = (v))
@@ -206,7 +204,8 @@ static unsigned umin(const unsigned a, const unsigned b) { return (a <= b) ? a :
{ 0x36, 6, 0x00ffffff, f_ctoj32_e8e9_bswap_le, u_ctoj32_e8e9_bswap_le, s_ctoj32_e8e9_bswap_le }, { 0x36, 6, 0x00ffffff, f_ctoj32_e8e9_bswap_le, u_ctoj32_e8e9_bswap_le, s_ctoj32_e8e9_bswap_le },
// 32-bit calltrick with jmp, optional jcc; runtime can unfilter more than one block // 32-bit calltrick with jmp, optional jcc; runtime can unfilter more than one block
{ 0x46, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le }, // Note 0x46 uses 'ctoj', while 0x49 uses 'ctok'.
{ 0x46, 6, 0x00ffffff, f_ctoj32_e8e9_bswap_le, u_ctoj32_e8e9_bswap_le, s_ctoj32_e8e9_bswap_le },
{ 0x49, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le }, { 0x49, 6, 0x00ffffff, f_ctok32_e8e9_bswap_le, u_ctok32_e8e9_bswap_le, s_ctok32_e8e9_bswap_le },
// 24-bit calltrick for arm // 24-bit calltrick for arm
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+5 -5
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2004-2024 John F. Reiser Copyright (C) 2004-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -44,7 +44,7 @@ static int F(Filter *f) {
// scan // scan
const byte *b = f->buf; const byte *b = f->buf;
#endif #endif
const unsigned size = umin(f->buf_len, 0u - (~0u << (32 - (6 + W_CTO)))); const unsigned size = upx::umin(f->buf_len, 0u - (~0u << (32 - (6 + W_CTO))));
const unsigned size4 = size - 4; const unsigned size4 = size - 4;
unsigned ic; unsigned ic;
@@ -123,7 +123,7 @@ static int F(Filter *f) {
#ifdef U #ifdef U
static int U(Filter *f) { static int U(Filter *f) {
byte *b = f->buf; byte *b = f->buf;
const unsigned size4 = umin(f->buf_len - 4, 0u - (~0u << (32 - (6 + W_CTO)))); const unsigned size4 = upx::umin(f->buf_len - 4, 0u - (~0u << (32 - (6 + W_CTO))));
const unsigned addvalue = f->addvalue; const unsigned addvalue = f->addvalue;
unsigned ic; unsigned ic;
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+77 -17
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -114,13 +114,15 @@ struct PackerNames final {
unsigned methods[PackerBase::MAX_METHODS]; unsigned methods[PackerBase::MAX_METHODS];
unsigned filters[PackerBase::MAX_FILTERS]; unsigned filters[PackerBase::MAX_FILTERS];
}; };
Entry names[MAX_NAMES]; Entry names_array[MAX_NAMES];
Entry *names[MAX_NAMES];
unsigned names_count = 0; unsigned names_count = 0;
const Options *o = nullptr; const Options *o = nullptr;
void add(const PackerBase *pb) { void add(const PackerBase *pb) {
assert_noexcept(names_count < MAX_NAMES); assert_noexcept(names_count < MAX_NAMES);
Entry &e = names[names_count++]; Entry &e = names_array[names_count];
names[names_count++] = &e;
e.fname = pb->getFullName(o); e.fname = pb->getFullName(o);
e.sname = pb->getName(); e.sname = pb->getName();
e.methods_count = e.filters_count = 0; e.methods_count = e.filters_count = 0;
@@ -147,11 +149,10 @@ struct PackerNames final {
self->add(pb); self->add(pb);
return false; return false;
} }
static int __acc_cdecl_qsort compare_fname(const void *a, const void *b) { static int __acc_cdecl_qsort compare_fname(const void *aa, const void *bb) {
return strcmp(((const Entry *) a)->fname, ((const Entry *) b)->fname); const Entry *a = *(const Entry *const *) aa;
} const Entry *b = *(const Entry *const *) bb;
static int __acc_cdecl_qsort compare_sname(const void *a, const void *b) { return strcmp(a->fname, b->fname);
return strcmp(((const Entry *) a)->sname, ((const Entry *) b)->sname);
} }
}; };
} // namespace } // namespace
@@ -162,10 +163,11 @@ static noinline void list_all_packers(FILE *f, int verbose) {
PackerNames pn; PackerNames pn;
pn.o = &o; pn.o = &o;
(void) PackMaster::visitAllPackers(PackerNames::visit, nullptr, &o, &pn); (void) PackMaster::visitAllPackers(PackerNames::visit, nullptr, &o, &pn);
upx_gnomesort(pn.names, pn.names_count, sizeof(PackerNames::Entry), PackerNames::compare_fname); // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
upx_gnomesort(pn.names, pn.names_count, sizeof(pn.names[0]), PackerNames::compare_fname);
size_t pos = 0; size_t pos = 0;
for (size_t i = 0; i < pn.names_count; i++) { for (size_t i = 0; i < pn.names_count; i++) {
const PackerNames::Entry &e = pn.names[i]; const PackerNames::Entry &e = *pn.names[i];
const char *const fn = e.fname; const char *const fn = e.fname;
const char *const sn = e.sname; const char *const sn = e.sname;
if (verbose >= 3) { if (verbose >= 3) {
@@ -218,9 +220,12 @@ void show_help(int verbose) {
"%s" "%s"
" -d decompress -l list compressed file\n" " -d decompress -l list compressed file\n"
" -t test compressed file -V display version number\n" " -t test compressed file -V display version number\n"
"%s"
" -h give %s help -L display software license\n%s", " -h give %s help -L display software license\n%s",
verbose == 0 ? "" : " --best compress best (can be slow for big files)\n", verbose == 0 ? "" : " --best compress best (can be slow for big files)\n",
verbose == 0 ? "more" : "this", verbose == 0 ? "" : "\n"); verbose == 0 ? "" : " --fileinfo show parameters of already-compressed file\n",
verbose == 0 ? "more" : "this",
verbose == 0 ? "" : "\n");
fg = con_fg(f, FG_YELLOW); fg = con_fg(f, FG_YELLOW);
con_fprintf(f, "Options:\n"); con_fprintf(f, "Options:\n");
@@ -337,6 +342,7 @@ void show_help(int verbose) {
fg = con_fg(f, fg); fg = con_fg(f, fg);
con_fprintf(f, con_fprintf(f,
" --preserve-build-id copy .gnu.note.build-id to compressed output\n" " --preserve-build-id copy .gnu.note.build-id to compressed output\n"
" --catch-sigsegv debug errors in hardware or de-compressor\n"
"\n"); "\n");
} }
// clang-format on // clang-format on
@@ -463,15 +469,15 @@ void show_version(bool one_line) {
fprintf(f, "doctest C++ testing framework version %s\n", DOCTEST_VERSION_STR); fprintf(f, "doctest C++ testing framework version %s\n", DOCTEST_VERSION_STR);
#endif #endif
// clang-format off // clang-format off
fprintf(f, "Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer\n"); fprintf(f, "Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(f, "Copyright (C) 1996-2024 Laszlo Molnar\n"); fprintf(f, "Copyright (C) 1996-2025 Laszlo Molnar\n");
fprintf(f, "Copyright (C) 2000-2024 John F. Reiser\n"); fprintf(f, "Copyright (C) 2000-2025 John F. Reiser\n");
#if (WITH_ZLIB) #if (WITH_ZLIB)
// see vendor/zlib/LICENSE // see vendor/zlib/LICENSE
fprintf(f, "Copyright (C) 1995" "-2024 Jean-loup Gailly and Mark Adler\n"); fprintf(f, "Copyright (C) 1995" "-2024 Jean-loup Gailly and Mark Adler\n");
#endif #endif
#if (WITH_LZMA) #if (WITH_LZMA)
// see vendor/lzma-sdk/lzma.txt // see vendor/lzma-sdk
fprintf(f, "Copyright (C) 1999" "-2006 Igor Pavlov\n"); fprintf(f, "Copyright (C) 1999" "-2006 Igor Pavlov\n");
#endif #endif
#if (WITH_ZSTD) #if (WITH_ZSTD)
@@ -521,11 +527,16 @@ void show_sysinfo(const char *options_var) {
con_fprintf(f, fmt, v); con_fprintf(f, fmt, v);
con_fprintf(f, "\n"); con_fprintf(f, "\n");
}; };
// language // language
cf_print("__cplusplus", "%lld", __cplusplus + 0, 3); cf_print("__cplusplus", "%lld", __cplusplus + 0, 3);
#if defined(_MSVC_LANG) #if defined(_MSVC_LANG)
cf_print("_MSVC_LANG", "%lld", _MSVC_LANG + 0, 3); cf_print("_MSVC_LANG", "%lld", _MSVC_LANG + 0, 3);
#endif #endif
#if defined(upx_is_constant_evaluated)
cf_print("upx_is_constant_evaluated", "%lld", 1, 3);
#endif
// compiler // compiler
#if defined(ACC_CC_CLANG) #if defined(ACC_CC_CLANG)
cf_print("ACC_CC_CLANG", "0x%06llx", ACC_CC_CLANG + 0, 3); cf_print("ACC_CC_CLANG", "0x%06llx", ACC_CC_CLANG + 0, 3);
@@ -563,6 +574,30 @@ void show_sysinfo(const char *options_var) {
#if defined(_MSC_FULL_VER) #if defined(_MSC_FULL_VER)
cf_print("_MSC_FULL_VER", "%lld", _MSC_FULL_VER + 0); cf_print("_MSC_FULL_VER", "%lld", _MSC_FULL_VER + 0);
#endif #endif
// architecture
#if defined(__CHERI__)
cf_print("__CHERI__", "%lld", __CHERI__ + 0, 3);
#endif
#if defined(__CHERI_PURE_CAPABILITY__)
cf_print("__CHERI_PURE_CAPABILITY__", "%lld", __CHERI_PURE_CAPABILITY__ + 0, 3);
#endif
#if defined(__mips_hard_float)
cf_print("__mips_hard_float", "%lld", __mips_hard_float + 0);
#endif
#if defined(__mips_soft_float)
cf_print("__mips_soft_float", "%lld", __mips_soft_float + 0);
#endif
#if defined(__wasm__)
cf_print("__wasm__", "%lld", __wasm__ + 0);
#endif
#if defined(__wasm32__)
cf_print("__wasm32__", "%lld", __wasm32__ + 0);
#endif
#if defined(__wasm64__)
cf_print("__wasm64__", "%lld", __wasm64__ + 0);
#endif
// OS and libc // OS and libc
#if defined(WINVER) #if defined(WINVER)
cf_print("WINVER", "0x%04llx", WINVER + 0); cf_print("WINVER", "0x%04llx", WINVER + 0);
@@ -590,7 +625,30 @@ void show_sysinfo(const char *options_var) {
#if defined(__GLIBC_MINOR__) #if defined(__GLIBC_MINOR__)
cf_print("__GLIBC_MINOR__", "%lld", __GLIBC_MINOR__ + 0); cf_print("__GLIBC_MINOR__", "%lld", __GLIBC_MINOR__ + 0);
#endif #endif
#if defined(__wasi__)
cf_print("__wasi__", "%lld", __wasi__ + 0);
#endif
// misc compilation options // misc compilation options
#if defined(__PIC__)
cf_print("__PIC__", "%lld", __PIC__ + 0, 3);
#elif defined(__pic__)
cf_print("__pic__", "%lld", __pic__ + 0, 3);
#endif
#if defined(__PIE__)
cf_print("__PIE__", "%lld", __PIE__ + 0, 3);
#elif defined(__pie__)
cf_print("__pie__", "%lld", __pie__ + 0, 3);
#endif
#if defined(__SIZEOF_INT128__)
cf_print("__SIZEOF_INT128__", "%lld", __SIZEOF_INT128__ + 0, 3);
#endif
#if defined(__SIZEOF_LONG_LONG__) && (__SIZEOF_LONG_LONG__ + 0 > 8)
cf_print("__SIZEOF_LONG_LONG__", "%lld", __SIZEOF_LONG_LONG__ + 0, 3);
#endif
#if defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ + 0 > 8)
cf_print("__SIZEOF_POINTER__", "%lld", __SIZEOF_POINTER__ + 0, 3);
#endif
#if defined(UPX_CONFIG_DISABLE_WSTRICT) #if defined(UPX_CONFIG_DISABLE_WSTRICT)
cf_print("UPX_CONFIG_DISABLE_WSTRICT", "%lld", UPX_CONFIG_DISABLE_WSTRICT + 0, 3); cf_print("UPX_CONFIG_DISABLE_WSTRICT", "%lld", UPX_CONFIG_DISABLE_WSTRICT + 0, 3);
#endif #endif
@@ -600,12 +658,13 @@ void show_sysinfo(const char *options_var) {
#if defined(WITH_THREADS) #if defined(WITH_THREADS)
cf_print("WITH_THREADS", "%lld", WITH_THREADS + 0); cf_print("WITH_THREADS", "%lld", WITH_THREADS + 0);
#endif #endif
UNUSED(cf_count); UNUSED(cf_count);
UNUSED(cf_print); UNUSED(cf_print);
UNUSED(initial_win32_winnt); UNUSED(initial_win32_winnt);
} }
// run-time // run-time settings
#if defined(HAVE_LOCALTIME) && defined(HAVE_GMTIME) #if defined(HAVE_LOCALTIME) && defined(HAVE_GMTIME)
{ {
auto tm2str = [](char *s, size_t size, const struct tm *tmp) noexcept { auto tm2str = [](char *s, size_t size, const struct tm *tmp) noexcept {
@@ -624,6 +683,7 @@ void show_sysinfo(const char *options_var) {
} }
#endif #endif
// environment
if (options_var && options_var[0]) { if (options_var && options_var[0]) {
const char *e = upx_getenv(options_var); const char *e = upx_getenv(options_var);
con_fprintf(f, "\n"); con_fprintf(f, "\n");
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+4 -4
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -227,7 +227,7 @@ void ElfLinker::preprocessSymbols(char *start, char const *end) {
else if (sscanf(start, "%x%*8c %1023s %*x %1023s", &offset, section, symbol) == 3) else if (sscanf(start, "%x%*8c %1023s %*x %1023s", &offset, section, symbol) == 3)
#else #else
// work around broken scanf() implementations // work around broken scanf() implementations
// http://bugs.winehq.org/show_bug.cgi?id=10401 (fixed in Wine 0.9.58) // https://bugs.winehq.org/show_bug.cgi?id=10401 (fixed in Wine 0.9.58)
else if (sscanf(start, "%x%*c%*c%*c%*c%*c%*c%*c%*c %1023s %*x %1023s", &offset, section, else if (sscanf(start, "%x%*c%*c%*c%*c%*c%*c%*c%*c %1023s %*x %1023s", &offset, section,
symbol) == 3) symbol) == 3)
#endif #endif
@@ -680,7 +680,7 @@ void ElfLinkerArm64LE::relocate1(const Relocation *rel, byte *location, upx_uint
upx_uint32_t const m19 = ~(~0u << 19); upx_uint32_t const m19 = ~(~0u << 19);
upx_uint32_t w = get_le32(location); upx_uint32_t w = get_le32(location);
set_le32(location, (w & ~(m19 << 5)) | ((((w >> 5) + (value >> 2)) & m19) << 5)); set_le32(location, (w & ~(m19 << 5)) | ((((w >> 5) + (value >> 2)) & m19) << 5));
} else if (!strcmp(type, "CALL26")) { } else if (!strcmp(type, "CALL26") || !strcmp(type, "JUMP26")) {
value -= rel->section->offset + rel->offset; value -= rel->section->offset + rel->offset;
upx_uint32_t const m26 = ~(~0u << 26); upx_uint32_t const m26 = ~(~0u << 26);
upx_uint32_t w = get_le32(location); upx_uint32_t w = get_le32(location);
+6 -6
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -31,7 +31,7 @@
// ElfLinker // ElfLinker
**************************************************************************/ **************************************************************************/
class ElfLinker : private noncopyable { class ElfLinker /*not_final*/ : private upx::noncopyable {
friend class Packer; friend class Packer;
public: public:
@@ -114,7 +114,7 @@ protected:
const char *type); const char *type);
}; };
struct ElfLinker::Section : private noncopyable { struct ElfLinker::Section final : private upx::noncopyable {
char *name = nullptr; char *name = nullptr;
void *input = nullptr; void *input = nullptr;
byte *output = nullptr; byte *output = nullptr;
@@ -128,7 +128,7 @@ struct ElfLinker::Section : private noncopyable {
~Section() noexcept; ~Section() noexcept;
}; };
struct ElfLinker::Symbol : private noncopyable { struct ElfLinker::Symbol final : private upx::noncopyable {
char *name = nullptr; char *name = nullptr;
Section *section = nullptr; Section *section = nullptr;
upx_uint64_t offset = 0; upx_uint64_t offset = 0;
@@ -137,7 +137,7 @@ struct ElfLinker::Symbol : private noncopyable {
~Symbol() noexcept; ~Symbol() noexcept;
}; };
struct ElfLinker::Relocation : private noncopyable { struct ElfLinker::Relocation final : private upx::noncopyable {
const Section *section = nullptr; const Section *section = nullptr;
unsigned offset = 0; unsigned offset = 0;
const char *type = nullptr; const char *type = nullptr;
+20 -6
View File
@@ -1,9 +1,9 @@
/* main.cpp -- /* main.cpp -- main entry
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -343,7 +343,8 @@ done:
} }
template <class T, T default_value, T min_value, T max_value> template <class T, T default_value, T min_value, T max_value>
static int getoptvar(OptVar<T, default_value, min_value, max_value> *var, const char *arg_fatal) { static int getoptvar(upx::OptVar<T, default_value, min_value, max_value> *var,
const char *arg_fatal) {
T v = default_value; T v = default_value;
int r = getoptvar(&v, min_value, max_value, arg_fatal); int r = getoptvar(&v, min_value, max_value, arg_fatal);
if (r == 0) if (r == 0)
@@ -738,6 +739,12 @@ static int do_option(int optc, const char *arg) {
case 677: case 677:
opt->o_unix.force_pie = true; opt->o_unix.force_pie = true;
break; break;
case 678:
opt->o_unix.android_old = true;
break;
case 679:
opt->o_unix.catch_sigsegv = true;
break;
// ps1/exe // ps1/exe
case 670: case 670:
opt->ps1_exe.boot_only = true; opt->ps1_exe.boot_only = true;
@@ -836,8 +843,8 @@ int main_get_options(int argc, char **argv) {
{"force", 0, N, 'f'}, // force overwrite of output files {"force", 0, N, 'f'}, // force overwrite of output files
{"force-compress", 0, N, 'f'}, // and compression of suspicious files {"force-compress", 0, N, 'f'}, // and compression of suspicious files
{"force-overwrite", 0x90, N, 529}, // force overwrite of output files {"force-overwrite", 0x90, N, 529}, // force overwrite of output files
{"link", 0x90, N, 530}, // preserve hard link
{"info", 0, N, 'i'}, // info mode {"info", 0, N, 'i'}, // info mode
{"link", 0x90, N, 530}, // preserve hard link
{"no-env", 0x10, N, 519}, // no environment var {"no-env", 0x10, N, 519}, // no environment var
{"no-link", 0x90, N, 531}, // do not preserve hard link [default] {"no-link", 0x90, N, 531}, // do not preserve hard link [default]
{"no-mode", 0x10, N, 526}, // do not preserve mode (permissions) {"no-mode", 0x10, N, 526}, // do not preserve mode (permissions)
@@ -952,6 +959,8 @@ int main_get_options(int argc, char **argv) {
{"preserve-build-id", 0, N, 675}, {"preserve-build-id", 0, N, 675},
{"android-shlib", 0, N, 676}, {"android-shlib", 0, N, 676},
{"force-pie", 0x90, N, 677}, {"force-pie", 0x90, N, 677},
{"android-old", 0, N, 678},
{"catch-sigsegv", 0, N, 679},
// ps1/exe // ps1/exe
{"boot-only", 0x90, N, 670}, {"boot-only", 0x90, N, 670},
{"no-align", 0x90, N, 671}, {"no-align", 0x90, N, 671},
@@ -1210,6 +1219,7 @@ int upx_main(int argc, char *argv[]) may_throw {
} }
// Allow serial re-use of upx_main() as a subroutine // Allow serial re-use of upx_main() as a subroutine
exit_code = EXIT_OK;
opt->reset(); opt->reset();
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_TOS || ACC_OS_WIN16 || \ #if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_TOS || ACC_OS_WIN16 || \
@@ -1246,7 +1256,9 @@ int upx_main(int argc, char *argv[]) may_throw {
assert(upx_nrv_init() == 0); assert(upx_nrv_init() == 0);
#endif #endif
assert(upx_ucl_init() == 0); assert(upx_ucl_init() == 0);
#if (WITH_ZLIB)
assert(upx_zlib_init() == 0); assert(upx_zlib_init() == 0);
#endif
#if (WITH_ZSTD) #if (WITH_ZSTD)
assert(upx_zstd_init() == 0); assert(upx_zstd_init() == 0);
#endif #endif
@@ -1310,8 +1322,10 @@ int upx_main(int argc, char *argv[]) may_throw {
/* start work */ /* start work */
set_term(stdout); set_term(stdout);
if (do_files(i, argc, argv) != 0) if (do_files(i, argc, argv) != 0) {
assert(exit_code != 0);
return exit_code; return exit_code;
}
if (gitrev[0]) { if (gitrev[0]) {
// also see UPX_CONFIG_DISABLE_GITREV in CMakeLists.txt // also see UPX_CONFIG_DISABLE_GITREV in CMakeLists.txt
+3 -3
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -51,7 +51,7 @@ void printClearLine(FILE *f) noexcept {
fflush(stderr); fflush(stderr);
if (f == nullptr) if (f == nullptr)
f = stdout; f = stdout;
con_fprintf(f, "%s", clear_line_msg); con_fprintf(f, "%s", clear_line_msg); // NOLINT(clang-analyzer-unix.Stream)
fflush(f); fflush(f);
printSetNl(0); printSetNl(0);
} }
+4 -3
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -28,7 +28,8 @@
#include "conf.h" #include "conf.h"
static Options global_options; static Options global_options;
Options *opt = &global_options; // also see class PackMaster for per-file local options // also see class PackMaster for per-file local options
Options *opt = &global_options;
#if WITH_THREADS #if WITH_THREADS
std::mutex opt_lock_mutex; // for locking "opt" std::mutex opt_lock_mutex; // for locking "opt"
+6 -3
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -30,7 +30,8 @@
struct Options; struct Options;
#define options_t Options // old name #define options_t Options // old name
extern Options *opt; // global options, see class PackMaster for per-file local options // global options, see class PackMaster for per-file local options
extern Options *opt;
#if WITH_THREADS #if WITH_THREADS
extern std::mutex opt_lock_mutex; // for locking "opt" extern std::mutex opt_lock_mutex; // for locking "opt"
@@ -159,7 +160,9 @@ struct Options final {
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI] unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
bool preserve_build_id; // copy the build-id to the compressed binary bool preserve_build_id; // copy the build-id to the compressed binary
bool android_shlib; // keep some ElfXX_Shdr for dlopen() bool android_shlib; // keep some ElfXX_Shdr for dlopen()
bool android_old; // < Android_10 ==> no memfd_create, inconsistent __NR_ftruncate
bool force_pie; // choose DF_1_PIE instead of is_shlib bool force_pie; // choose DF_1_PIE instead of is_shlib
bool catch_sigsegv; // to debug hardware or de-compressor
} o_unix; } o_unix;
struct { struct {
bool boot_only; bool boot_only;
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+13 -17
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -150,27 +150,23 @@ static void handle_allegropak(InputFile *fi, OutputFile *fo) {
} }
int PackDjgpp2::readFileHeader() { int PackDjgpp2::readFileHeader() {
byte hdr[0x1c]; dos_header_t dos_hdr;
byte magic[8];
fi->seek(0, SEEK_SET); fi->seek(0, SEEK_SET);
fi->readx(hdr, sizeof(hdr)); fi->readx(&dos_hdr, sizeof(dos_hdr));
if (get_le16(hdr) == 0x5a4d) // MZ exe signature, stubbed? if (get_le16(&dos_hdr.e_magic) == 0x5a4d) { // MZ exe signature, stubbed?
{ byte magic[8];
coff_offset = 512 * get_le16(hdr + 4); fi->seek(16 * get_le16(&dos_hdr.e_cparhdr), SEEK_SET);
if (get_le16(hdr + 2) != 0)
coff_offset += get_le16(hdr + 2) - 512;
fi->seek(512, SEEK_SET);
fi->readx(magic, 8); fi->readx(magic, 8);
if (memcmp("go32stub", magic, 8) != 0) if (memcmp("go32stub", magic, 8) != 0)
return 0; // not V2 image return 0; // not V2 image
fi->seek(coff_offset, SEEK_SET);
if (fi->read(&coff_hdr, sizeof(coff_hdr)) != sizeof(coff_hdr))
throwCantPack("skipping djgpp symlink");
} else {
fi->seek(coff_offset, SEEK_SET);
fi->readx(&coff_hdr, 0xa8);
} }
coff_offset = 512 * get_le16(&dos_hdr.e_cp);
if (get_le16(&dos_hdr.e_cblp) != 0)
coff_offset += get_le16(&dos_hdr.e_cblp) - 512;
fi->seek(coff_offset, SEEK_SET);
if (fi->read(&coff_hdr, sizeof(coff_hdr)) != sizeof(coff_hdr))
throwCantPack("skipping djgpp symlink");
if (coff_hdr.f_magic != 0x014c) // I386MAGIC if (coff_hdr.f_magic != 0x014c) // I386MAGIC
return 0; return 0;
if ((coff_hdr.f_flags & 2) == 0) // F_EXEC - COFF executable if ((coff_hdr.f_flags & 2) == 0) // F_EXEC - COFF executable
+12 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -62,6 +62,16 @@ protected:
unsigned coff_offset; unsigned coff_offset;
// based on https://dox.ipxe.org/PeImage_8h_source.html
struct alignas(1) dos_header_t {
LE16 e_magic;
LE16 e_cblp; // Bytes on last page of file
LE16 e_cp; // Pages in file
LE16 e_crlc; // Relocations
LE16 e_cparhdr; // Size of header in paragraphs
LE16 e_OMITTED[32 - 5 * 2];
}; // 64 bytes
struct alignas(1) external_scnhdr_t { struct alignas(1) external_scnhdr_t {
byte _[12]; // name, paddr byte _[12]; // name, paddr
LE32 vaddr; LE32 vaddr;
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+11 -4
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -72,8 +72,9 @@ class Dummy {
ET_DYN = 3, /* Shared object file */ ET_DYN = 3, /* Shared object file */
ET_CORE = 4, /* Core file */ ET_CORE = 4, /* Core file */
}; };
enum { // e_machine enum { // e_machine
EM_386 = 3, // i386 EM_NONE = 0, // No machine
EM_386 = 3, // i386
EM_MIPS = 8, EM_MIPS = 8,
EM_MIPS_RS3_LE = 10, // MIPS R3000 little-endian EM_MIPS_RS3_LE = 10, // MIPS R3000 little-endian
EM_PPC = 20, EM_PPC = 20,
@@ -103,6 +104,11 @@ class Dummy {
PT_NUM = 8, /* Number of defined types in low range */ PT_NUM = 8, /* Number of defined types in low range */
PT_GNU_STACK = 0x6474e551, /* Indicates stack executability */ PT_GNU_STACK = 0x6474e551, /* Indicates stack executability */
PT_GNU_RELRO = 0x6474e552, /* Read-only after relocation */ PT_GNU_RELRO = 0x6474e552, /* Read-only after relocation */
PT_MIPS_REGINFO = 0x70000000,
/* Register usage information. */ //
// PT_MIPS_RTPROC = 0x70000001, /* Runtime procedure table. */
// PT_MIPS_OPTIONS = 0x70000002,
PT_MIPS_ABIFLAGS = 0x70000003, /* FP mode requirement. */
}; };
enum { // p_flags enum { // p_flags
@@ -133,6 +139,7 @@ class Dummy {
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */ SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
SHT_GROUP = 17, /* Section group */ SHT_GROUP = 17, /* Section group */
SHT_SYMTAB_SHNDX = 18, /* Extended section indices */ SHT_SYMTAB_SHNDX = 18, /* Extended section indices */
SHT_RELR = 19, /* RELR relative relocations */
SHT_GNU_HASH = 0x6ffffff6, /* GNU-style hash table. */ SHT_GNU_HASH = 0x6ffffff6, /* GNU-style hash table. */
SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */ SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
SHT_GNU_verdef = 0x6ffffffd, /* Version definition section. */ SHT_GNU_verdef = 0x6ffffffd, /* Version definition section. */
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+1730 -1234
View File
File diff suppressed because it is too large Load Diff
+28 -7
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -59,6 +59,12 @@ protected:
virtual off_t pack3(OutputFile *, Filter &) override = 0; // append loader virtual off_t pack3(OutputFile *, Filter &) override = 0; // append loader
//virtual void pack4(OutputFile *, Filter &) override = 0; // append pack header //virtual void pack4(OutputFile *, Filter &) override = 0; // append pack header
virtual unsigned pack2_shlib_overlay_init(OutputFile *fo);
virtual unsigned pack2_shlib_overlay_compress(MemBuffer &obuf,
upx_byte const *inp, unsigned u_len);
virtual unsigned pack2_shlib_overlay_write(OutputFile *fo, MemBuffer &obuf,
unsigned hdr_u_len, unsigned hdr_c_len);
virtual void generateElfHdr( virtual void generateElfHdr(
OutputFile *, OutputFile *,
void const *proto, void const *proto,
@@ -149,10 +155,13 @@ protected:
virtual void ARM_updateLoader(OutputFile *); virtual void ARM_updateLoader(OutputFile *);
virtual int ARM_is_QNX(void); virtual int ARM_is_QNX(void);
virtual upx_uint64_t canPack_Shdr(Elf32_Phdr const *pload_x0);
virtual void pack1(OutputFile *, Filter &) override; // generate executable header virtual void pack1(OutputFile *, Filter &) override; // generate executable header
virtual void asl_pack2_Shdrs(OutputFile *, unsigned pre_xct_top); // AndroidSharedLibrary processes Shdrs virtual void asl_pack2_Shdrs(OutputFile *, unsigned pre_xct_top); // AndroidSharedLibrary processes Shdrs
virtual void asl_slide_Shdrs(); // by so_slide if above xct_off virtual void asl_slide_Shdrs(); // by so_slide if above xct_off
virtual unsigned slide_sh_offset(Elf32_Shdr *shdr);
virtual int pack2(OutputFile *, Filter &) override; // append compressed data virtual int pack2(OutputFile *, Filter &) override; // append compressed data
virtual int pack2_shlib(OutputFile *fo, Filter &ft, unsigned pre_xct_top);
virtual off_t pack3(OutputFile *, Filter &) override; // append loader virtual off_t pack3(OutputFile *, Filter &) override; // append loader
virtual void pack4(OutputFile *, Filter &) override; // append pack header virtual void pack4(OutputFile *, Filter &) override; // append pack header
virtual unsigned forward_Shdrs(OutputFile *fo, Elf32_Ehdr *ehdro); virtual unsigned forward_Shdrs(OutputFile *fo, Elf32_Ehdr *ehdro);
@@ -206,7 +215,7 @@ protected:
unsigned elf_find_table_size(unsigned dt_type, unsigned sh_type); unsigned elf_find_table_size(unsigned dt_type, unsigned sh_type);
void sort_DT32_offsets(Elf32_Dyn const *const dynp0); void sort_DT32_offsets(Elf32_Dyn const *const dynp0);
int is_LOAD32(Elf32_Phdr const *phdr) const; // beware confusion with (1+ LO_PROC) int is_LOAD(Elf32_Phdr const *phdr) const; // beware confusion with (1+ LO_PROC)
unsigned check_pt_load(Elf32_Phdr const *); unsigned check_pt_load(Elf32_Phdr const *);
unsigned check_pt_dynamic(Elf32_Phdr const *); unsigned check_pt_dynamic(Elf32_Phdr const *);
void invert_pt_dynamic(Elf32_Dyn const *, unsigned dt_filesz); void invert_pt_dynamic(Elf32_Dyn const *, unsigned dt_filesz);
@@ -215,6 +224,7 @@ protected:
virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const override; virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const override;
unsigned find_dt_ndx(unsigned rva); unsigned find_dt_ndx(unsigned rva);
virtual int adjABS(Elf32_Sym *sym, unsigned delta); virtual int adjABS(Elf32_Sym *sym, unsigned delta);
void add_phdrx(Elf32_Phdr const *);
char const *get_str_name(unsigned st_name, unsigned symnum) const; char const *get_str_name(unsigned st_name, unsigned symnum) const;
char const *get_dynsym_name(unsigned symnum, unsigned relnum) const; char const *get_dynsym_name(unsigned symnum, unsigned relnum) const;
@@ -223,7 +233,10 @@ protected:
Elf32_Phdr *phdri; // for input file Elf32_Phdr *phdri; // for input file
Elf32_Shdr *shdri; // from input file Elf32_Shdr *shdri; // from input file
Elf32_Shdr *shdro; // for output file Elf32_Shdr *shdro; // for output file
Elf32_Phdr const *gnu_stack; // propagate NX static unsigned const END_PHDRX = 5;
Elf32_Phdr const *phdrx[END_PHDRX]; // "extra" arch-specific Phdr
unsigned n_phdrx; // number actually used
unsigned sz_phdrx; // total size of bodies
unsigned e_phoff; unsigned e_phoff;
unsigned e_shoff; unsigned e_shoff;
unsigned sz_dynseg; // PT_DYNAMIC.p_memsz unsigned sz_dynseg; // PT_DYNAMIC.p_memsz
@@ -314,9 +327,13 @@ protected:
virtual tribool canPack() override; virtual tribool canPack() override;
virtual tribool canUnpack() override; // bool, except -1: format known, but not packed virtual tribool canUnpack() override; // bool, except -1: format known, but not packed
virtual upx_uint64_t canPack_Shdr(Elf64_Phdr const *pload_x0);
virtual void pack1(OutputFile *, Filter &) override; // generate executable header virtual void pack1(OutputFile *, Filter &) override; // generate executable header
virtual void asl_pack2_Shdrs(OutputFile *, unsigned pre_xct_top); // AndroidSharedLibrary processes Shdrs virtual void asl_pack2_Shdrs(OutputFile *, unsigned pre_xct_top); // AndroidSharedLibrary processes Shdrs
virtual void asl_slide_Shdrs(); // by so_slide if above xct_off
virtual unsigned slide_sh_offset(Elf64_Shdr *shdr);
virtual int pack2(OutputFile *, Filter &) override; // append compressed data virtual int pack2(OutputFile *, Filter &) override; // append compressed data
virtual int pack2_shlib(OutputFile *fo, Filter &ft, unsigned pre_xct_top);
virtual off_t pack3(OutputFile *, Filter &) override; // append loader virtual off_t pack3(OutputFile *, Filter &) override; // append loader
virtual void pack4(OutputFile *, Filter &) override; // append pack header virtual void pack4(OutputFile *, Filter &) override; // append pack header
virtual unsigned forward_Shdrs(OutputFile *fo, Elf64_Ehdr *ehdro); virtual unsigned forward_Shdrs(OutputFile *fo, Elf64_Ehdr *ehdro);
@@ -367,7 +384,7 @@ protected:
Elf64_Dyn *elf_find_dynptr(unsigned) const; Elf64_Dyn *elf_find_dynptr(unsigned) const;
unsigned elf_find_table_size(unsigned dt_type, unsigned sh_type); unsigned elf_find_table_size(unsigned dt_type, unsigned sh_type);
void sort_DT64_offsets(Elf64_Dyn const *const dynp0); void sort_DT64_offsets(Elf64_Dyn const *const dynp0);
int is_LOAD64(Elf64_Phdr const *phdr) const; // beware confusion with (1+ LO_PROC) int is_LOAD(Elf64_Phdr const *phdr) const; // beware confusion with (1+ LO_PROC)
upx_uint64_t check_pt_load(Elf64_Phdr const *); upx_uint64_t check_pt_load(Elf64_Phdr const *);
upx_uint64_t check_pt_dynamic(Elf64_Phdr const *); upx_uint64_t check_pt_dynamic(Elf64_Phdr const *);
void invert_pt_dynamic(Elf64_Dyn const *, upx_uint64_t dt_filesz); void invert_pt_dynamic(Elf64_Dyn const *, upx_uint64_t dt_filesz);
@@ -376,6 +393,7 @@ protected:
virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const override; virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const override;
unsigned find_dt_ndx(u64_t rva); unsigned find_dt_ndx(u64_t rva);
virtual int adjABS(Elf64_Sym *sym, unsigned long delta); virtual int adjABS(Elf64_Sym *sym, unsigned long delta);
void add_phdrx(Elf64_Phdr const *);
char const *get_str_name(unsigned st_name, unsigned symnum) const; char const *get_str_name(unsigned st_name, unsigned symnum) const;
char const *get_dynsym_name(unsigned symnum, unsigned relnum) const; char const *get_dynsym_name(unsigned symnum, unsigned relnum) const;
@@ -384,7 +402,10 @@ protected:
Elf64_Phdr *phdri; // for input file Elf64_Phdr *phdri; // for input file
Elf64_Shdr *shdri; // from input file Elf64_Shdr *shdri; // from input file
Elf64_Shdr *shdro; // for output file Elf64_Shdr *shdro; // for output file
Elf64_Phdr const *gnu_stack; // propagate NX static unsigned const END_PHDRX = 5;
Elf64_Phdr const *phdrx[END_PHDRX]; // "extra" arch-specific Phdr
unsigned n_phdrx; // number actually used
unsigned sz_phdrx; // total size of bodies
upx_uint64_t e_phoff; upx_uint64_t e_phoff;
upx_uint64_t e_shoff; upx_uint64_t e_shoff;
upx_uint64_t sz_dynseg; // PT_DYNAMIC.p_memsz upx_uint64_t sz_dynseg; // PT_DYNAMIC.p_memsz
+4 -13
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2001-2024 John F. Reiser Copyright (C) 2001-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -279,15 +279,6 @@ PackLinuxI386::pack4(OutputFile *fo, Filter &ft)
fo->rewrite(&elfout, overlay_offset); fo->rewrite(&elfout, overlay_offset);
} }
static unsigned
umax(unsigned a, unsigned b)
{
if (a <= b) {
return b;
}
return a;
}
Linker *PackLinuxI386::newLinker() const Linker *PackLinuxI386::newLinker() const
{ {
return new ElfLinkerX86; return new ElfLinkerX86;
@@ -311,7 +302,7 @@ PackLinuxI386::buildLinuxLoader(
usizeof(l_info); usizeof(l_info);
if (0 == get_le32(fold_hdrlen + fold)) { if (0 == get_le32(fold_hdrlen + fold)) {
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils) // inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
fold_hdrlen = umax(0x80, fold_hdrlen); fold_hdrlen = upx::umax(0x80u, fold_hdrlen);
} }
} }
// This adds the definition to the "library", to be used later. // This adds the definition to the "library", to be used later.
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+5 -4
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -109,7 +109,8 @@ void PackLinuxElf32x86interp::pack1(OutputFile *fo, Filter &)
h3.phdr[1].p_flags = Elf32_Phdr::PF_W | Elf32_Phdr::PF_R; h3.phdr[1].p_flags = Elf32_Phdr::PF_W | Elf32_Phdr::PF_R;
h3.phdr[1].p_align = 1; h3.phdr[1].p_align = 1;
h3.phdr[2].p_type = PT_INTERP; h3.phdr[2].p_type = PT_INTERP;
h3.phdr[2].p_offset = (char *)&h3.phdr[2].p_vaddr - (char *)&h3; // h3.phdr[2].p_offset = (char *)&h3.phdr[2].p_vaddr - (char *)&h3;
h3.phdr[2].p_offset = offsetof(cprElfHdr3, phdr[2].p_vaddr);
memcpy(&h3.phdr[2].p_vaddr, "/upxrun", h3.phdr[2].p_filesz = 8); memcpy(&h3.phdr[2].p_vaddr, "/upxrun", h3.phdr[2].p_filesz = 8);
h3.phdr[2].p_align = 1; h3.phdr[2].p_align = 1;
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
+4 -13
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2025 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2024 Laszlo Molnar Copyright (C) 1996-2025 Laszlo Molnar
Copyright (C) 2000-2024 John F. Reiser Copyright (C) 2000-2025 John F. Reiser
All Rights Reserved. All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them UPX and the UCL library are free software; you can redistribute them
@@ -62,15 +62,6 @@ PackLinuxI386sh::~PackLinuxI386sh()
{ {
} }
static unsigned
umax(unsigned a, unsigned b)
{
if (a <= b) {
return b;
}
return a;
}
void void
PackLinuxI386sh::buildLoader(Filter const *ft) PackLinuxI386sh::buildLoader(Filter const *ft)
{ {
@@ -94,7 +85,7 @@ PackLinuxI386sh::buildLoader(Filter const *ft)
sizeof(Elf32_Phdr) * get_te16(&((Elf32_Ehdr const *)(void *)buf)->e_phnum); sizeof(Elf32_Phdr) * get_te16(&((Elf32_Ehdr const *)(void *)buf)->e_phnum);
if (0 == get_le32(buf + fold_hdrlen)) { if (0 == get_le32(buf + fold_hdrlen)) {
// inconsistent SIZEOF_HEADERS in *.lds (ld, binutils) // inconsistent SIZEOF_HEADERS in *.lds (ld, binutils)
fold_hdrlen = umax(0x80, fold_hdrlen); fold_hdrlen = upx::umax(0x80u, fold_hdrlen);
} }
bool success = fold_ft.filter(buf + fold_hdrlen, sz_fold - fold_hdrlen); bool success = fold_ft.filter(buf + fold_hdrlen, sz_fold - fold_hdrlen);
UNUSED(success); UNUSED(success);

Some files were not shown because too many files have changed in this diff Show More