Compare commits

...

96 Commits

Author SHA1 Message Date
Markus F.X.J. Oberhumer d767332943 CI updates
CI / Rebuild stubs (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-22.04) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-22.04-arm) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-24.04) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }}-0 (ubuntu-24.04-arm) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }} (ubuntu-22.04, true) (push) Has been cancelled
CI / ${{ format('{0}', matrix.os) }} (ubuntu-24.04, true, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-13, g++-13, macos-14, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-14, g++-14, macos-15, true) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-15, g++-15, macos-26, true) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-11-arm64, windows-11-arm, arm64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-11-arm64ec, windows-11-arm, true, arm64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2022-amd64, windows-2022, amd64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2022-i386, windows-2022, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2025-amd64, windows-2025, amd64, 2022) (push) Has been cancelled
CI / ${{ format('{0}', matrix.name) }} (windows-2025-i386, windows-2025, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (-arm64EC, /machine:arm64ec, arm64ec-win64-vs2025, windows-2025, amd64_arm64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (amd64-win64-vs2025, windows-2025, amd64, 2022) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (arm64-win64-vs2025, windows-2025, amd64_arm64, 2022) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (-march=i586, i386-linux-gnu.2.17) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (-march=i586, i386-linux-gnu.2.3.4) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (aarch64-macos-none) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (aarch64-windows-gnu) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (alpine:3.18, qemu-x86_64, -fPIE, x86_64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (i386-windows-gnu) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-aarch64, aarch64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-arm, arm-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-armeb, armeb-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-i386, -march=i586, -fPIE, i386-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-i386, -march=i586, i386-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mips, mips-linux-musleabi) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mips, mips-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mipsel, mipsel-linux-musleabi) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-mipsel, mipsel-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc, powerpc-linux-musleabihf) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64, -fPIE, powerpc64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64, powerpc64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64le, -fPIE, powerpc64le-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-ppc64le, powerpc64le-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-riscv64, UPX-UNSUPPORTED, -fPIE, riscv64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-riscv64, UPX-UNSUPPORTED, riscv64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-gnu.2.3.4) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (x86_64-macos-none) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (x86_64-windows-gnu) (push) Has been cancelled
CI / ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} (gcc-14, g++-14, macos-15-intel, true) (push) Has been cancelled
CI / ${{ format('windows-bh {0}', matrix.name) }} (i386-win32-vs2025, windows-2025, amd64_x86, 2022) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (alpine:3.18, qemu-aarch64, -fPIE, aarch64-linux-musl) (push) Has been cancelled
CI / ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} (qemu-x86_64, x86_64-linux-gnu.2.17) (push) Has been cancelled
2025-12-12 11:44:17 +01:00
John Reiser f3d4503e93 clang-format inconsistency
modified:   p_elf_enum.h
2025-12-10 10:33:46 -08:00
John Reiser 70cb4aadda Fix "bad slide" on 32-bit ARM shared library
https://github.com/upx/upx/issues/944
	modified:   src/p_elf_enum.h
	modified:   src/p_lx_elf.cpp
2025-12-10 10:24:53 -08:00
John Reiser 75325bf9ef bb1
modified:   src/p_lx_elf.cpp
2025-12-10 10:24:53 -08:00
Markus F.X.J. Oberhumer 669bf2251f CI updates 2025-12-10 12:30:09 +01:00
Markus F.X.J. Oberhumer 190fd76583 CI updates 2025-12-10 10:15:51 +01:00
Markus F.X.J. Oberhumer 8622e22be0 CI updates 2025-12-02 13:54:23 +01:00
Markus F.X.J. Oberhumer 139a0324b6 CI updates 2025-11-29 18:10:15 +01:00
Markus F.X.J. Oberhumer e39f2b2b2f CI updates 2025-11-29 15:12:15 +01:00
John Reiser 7a46365296 Fix unpack of PackLinuxI386 for upx version 11
Old b_info without .b_method
https://github.com/upx/upx/issues/942
        modified:   p_unix.cpp
2025-11-25 04:29:52 -08:00
Markus F.X.J. Oberhumer f83b7690e5 CI updates 2025-11-25 09:15:40 +01:00
Markus F.X.J. Oberhumer 98c00d0fcb CI updates 2025-11-08 09:05:25 +01:00
Markus F.X.J. Oberhumer b04d566b83 CI updates 2025-11-03 15:41:08 +01:00
Markus F.X.J. Oberhumer b3c765ac7c CI updates 2025-11-02 23:52:34 +01:00
Markus F.X.J. Oberhumer f7146b5af9 CI updates 2025-11-02 18:41:09 +01:00
John Reiser 5dbf94e49b Update README.SRC to enable success by newbies.
Need i386 version of zlib, updated libmfpr.so, g++ (not clang++).
https://github.com/upx/upx/issues/938
	modified:   README.SRC
2025-10-29 11:14:58 -07:00
Markus F.X.J. Oberhumer 2e39c924d5 CI updates 2025-10-29 10:03:11 +01:00
John Reiser 3068d19492 WinPE with TLS: fix relocation bugs
--strip-relocs not needed after bugfixes, but keep safety check.
Thanks to @ml1050.
https://github.com/upx/upx/issues/880
	modified:   pefile.cpp
2025-10-26 13:36:43 -07:00
Markus F.X.J. Oberhumer 09d7d08e55 all: version bump 2025-10-24 22:02:13 +02:00
Markus F.X.J. Oberhumer 31ff38049f CI updates 2025-10-24 21:53:23 +02:00
John Reiser a5f5e7fc73 WinPE: Require --strip-relocs if relocating compressed data
Thanks to @bitraid for investigating and suggestions.
https://github.com/upx/upx/issues/880
	modified:   pefile.cpp
2025-10-24 08:35:20 -07:00
Markus F.X.J. Oberhumer 3533ebe804 CI updates 2025-10-13 01:44:37 +02:00
Markus F.X.J. Oberhumer c4ed5cc159 CI updates 2025-10-11 02:59:23 +02:00
John Reiser 303ac34539 ord() not needed
modified:   scripts/bin2h.py
2025-10-10 13:34:15 -07:00
John Reiser e8947a6812 Cleanup deubg
modified:   scripts/brandelf.py
2025-10-10 13:10:14 -07:00
John Reiser 533e642945 Merge branch 'jreiser-python3a' into jreiser-python3 2025-10-10 11:50:22 -07:00
John Reiser 8ab47ba8a4 More python3
modified:   scripts/brandelf.py
	modified:   scripts/gpp_inc.py
	modified:   src/arch/i086/cleanasm.py
2025-10-10 11:43:39 -07:00
John Reiser e4c638aa73 Mixing python3 strings with bytes requires .encode and .decode
modified:   stub/scripts/bin2h.py
	modified:   stub/scripts/brandelf.py
	modified:   stub/scripts/gpp_inc.py
	modified:   stub/scripts/xstrip.py
2025-10-10 08:56:37 -07:00
John Reiser 4ec866594b Mixing python3 strings with bytes requires .encode and .decode
modified:   stub/scripts/bin2h.py
	modified:   stub/scripts/brandelf.py
	modified:   stub/scripts/gpp_inc.py
	modified:   stub/scripts/xstrip.py
2025-10-10 08:38:59 -07:00
John Reiser a3d5a0a7b8 Replace 'has_key' with 'in'
modified:   src/stub/scripts/bin2h.py
	modified:   src/stub/scripts/xstrip.py
	modified:   src/stub/src/arch/i086/cleanasm.py
2025-10-08 14:35:13 -07:00
John Reiser 59d5d25a77 python-is-python3
modified:   ci.yml
2025-10-08 14:24:32 -07:00
John Reiser e60ebd4027 install python
modified:   ci.yml
2025-10-08 14:22:12 -07:00
John Reiser 3a61782f12 no more PYTHON2
modified:   src/stub/Makefile
2025-10-08 14:18:52 -07:00
John Reiser 11041f44e6 need ../deps/packages
modified:   ci.yml
2025-10-08 14:05:01 -07:00
John Reiser 649063c8c6 ci.yml syntax
modified:   ci.yml
2025-10-08 08:40:23 -07:00
John Reiser 36271c3244 python (python3) replaces python2
https://github.com/upx/upx/issues/868
Thanks to 'tansy' for the patches to *.py .

	modified:   .github/workflows/ci.yml
	modified:   src/stub/scripts/bin2h.py
	modified:   src/stub/scripts/brandelf.py
	modified:   src/stub/scripts/gpp_inc.py
	modified:   src/stub/scripts/xstrip.py
	modified:   src/stub/src/arch/i086/cleanasm.py
	modified:   src/stub/src/arch/i086/wdis2gas.py
2025-10-08 08:32:24 -07:00
Markus F.X.J. Oberhumer 3c3caaa567 CI updates 2025-10-07 22:00:31 +02:00
Markus F.X.J. Oberhumer d3504d8af2 CI updates 2025-10-05 13:17:03 +02:00
Markus F.X.J. Oberhumer 12d1c6bbda CI updates 2025-09-30 20:38:33 +02:00
Markus F.X.J. Oberhumer 466ceb4a1f CI updates 2025-09-18 12:03:48 +02:00
John Reiser 3b71139426 WIP Propagate CETCOMPAT flag for PeFile.
https://github.com/upx/upx/issues/909
	modified:   pefile.cpp
	modified:   pefile.h
2025-09-13 15:50:01 -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
103 changed files with 19237 additions and 17007 deletions
+1
View File
@@ -20,6 +20,7 @@ Checks: >
-bugprone-suspicious-memory-comparison, -bugprone-suspicious-memory-comparison,
-bugprone-suspicious-string-compare, -bugprone-suspicious-string-compare,
-bugprone-switch-missing-default-case, -bugprone-switch-missing-default-case,
-bugprone-unintended-char-ostream-output,
clang-analyzer-*, clang-analyzer-*,
-clang-analyzer-optin.performance.Padding, -clang-analyzer-optin.performance.Padding,
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
+217 -88
View File
@@ -8,6 +8,8 @@ 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'
@@ -19,9 +21,9 @@ env:
UPX_CONFIG_HAVE_WORKING_BUILD_RPATH: 'ON' 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
ZSTD_CLEVEL: 9 ZSTD_CLEVEL: 17
# 2025-03-05 # 2025-10-11
ZIG_DIST_VERSION: 0.14.0 ZIG_DIST_VERSION: 0.15.2
jobs: jobs:
job-rebuild-and-verify-stubs: job-rebuild-and-verify-stubs:
@@ -37,13 +39,14 @@ jobs:
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 tar time xz-utils libc6:i386 zlib1g:i386 apt-get install -y --no-install-recommends bash ca-certificates curl git libmpc3 make perl-base python3-minimal tar time xz-utils libc6:i386 zlib1g:i386
# install python2-minimal packages from Debian-11 apt-get install -y gcc-riscv64-linux-gnu
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 ### install python2-minimal packages from Debian-11
curl -sS -L -O https://ftp.debian.org/debian/pool/main/p/python2.7/python2.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
dpkg -i ./*python2*.deb && rm ./*python2*.deb && ldconfig ## curl -sS -L -O https://ftp.debian.org/debian/pool/main/p/python2.7/python2.7-minimal_2.7.18-8+deb11u1_amd64.deb
ln -s -v python2.7 /usr/bin/python2 ## dpkg -i ./*python2*.deb && rm ./*python2*.deb && ldconfig
## ln -s -v python2.7 /usr/bin/python2
# manually unpack and install compat libs from Ubuntu-16.04 # manually unpack and install compat libs from Ubuntu-16.04
curl -sS -L -O https://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb curl -sS -L -O https://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb
for f in ./*.deb; do dpkg -x $f ./packages; done for f in ./*.deb; do dpkg -x $f ./packages; done
@@ -51,6 +54,7 @@ jobs:
rm -rf ./*.deb ./packages && ldconfig rm -rf ./*.deb ./packages && ldconfig
# install upx-stubtools # install upx-stubtools
curl -sS -L https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz | tar -xJ curl -sS -L https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz | tar -xJ
- run: dpkg -l
- name: Check out code - name: Check out code
run: | run: |
git config --global --add safe.directory '*' # needed when running in a container git config --global --add safe.directory '*' # needed when running in a container
@@ -61,7 +65,7 @@ jobs:
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
@@ -74,6 +78,78 @@ jobs:
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-0: # uses cmake + make
if: true
needs: [ job-rebuild-and-verify-stubs ]
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-22.04 }
- { 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:
- 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@v6
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@v5
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
ls -ld ./build/*/*/*/upx-* || true
rm -rf ./build/*/*/*/upx-*
- 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
ls -ld ./build/*/*/*/XTesting/*/* || true
rm -rf ./build/*/*/*/XTesting/*/*
- 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
ls -ld ./build/*/*/*/upx-* || true
rm -rf ./build/*/*/*/upx-*
job-linux-cmake: # uses cmake + make job-linux-cmake: # uses cmake + make
if: true if: true
@@ -82,8 +158,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
# { os: ubuntu-20.04, use_extra: true } - { os: ubuntu-22.04, use_extra: true }
- { os: ubuntu-22.04, use_extra: true, use_wine: true }
- { os: ubuntu-24.04, use_extra: true, use_wine: true } - { os: ubuntu-24.04, use_extra: true, use_wine: true }
name: ${{ format('{0}', matrix.os) }} name: ${{ format('{0}', matrix.os) }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@@ -94,6 +169,7 @@ jobs:
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
@@ -101,14 +177,19 @@ 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@v6
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
@@ -128,6 +209,8 @@ 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')
@@ -147,12 +230,24 @@ jobs:
(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst") (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@v5
with: { name: '${{ env.artifact_name }}', path: tmp/artifact } with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
- name: Run install tests - name: Run install tests
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
ls -ld ./build/*/*/*/upx-* || true
rm -rf ./build/*/*/*/upx-*
- 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"
@@ -161,12 +256,8 @@ 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 ls -ld ./build/*/*/*/XTesting/*/* || true
run: | rm -rf ./build/*/*/*/XTesting/*/*
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: |
@@ -178,6 +269,8 @@ jobs:
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/mimic_ctest.sh' ::: $jobs parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
ls -ld ./build/*/*/*/upx-* || true
rm -rf ./build/*/*/*/upx-*
fi fi
- name: Run file system tests - name: Run file system tests
run: | run: |
@@ -203,6 +296,8 @@ jobs:
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/upx_testsuite_1.sh' ::: $jobs parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/upx_testsuite_1.sh' ::: $jobs
ls -ld ./build/*/*/*/tmp-upx-testsuite* || true
rm -rf ./build/*/*/*/tmp-upx-testsuite*
job-macos-cmake: # uses cmake + make job-macos-cmake: # uses cmake + make
if: true if: true
@@ -213,9 +308,10 @@ jobs:
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: 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
- { os: macos-13, gcc: gcc-12, gxx: g++-12, testsuite: true }
- { os: macos-14, gcc: gcc-13, gxx: g++-13, testsuite: true } - { os: macos-14, gcc: gcc-13, gxx: g++-13, testsuite: true }
- { os: macos-15, gcc: gcc-14, gxx: g++-14, testsuite: true } - { os: macos-15, gcc: gcc-14, gxx: g++-14, testsuite: true }
- { os: macos-26, gcc: gcc-15, gxx: g++-15, testsuite: true }
- { os: macos-15-intel, gcc: gcc-14, gxx: g++-14, testsuite: true }
name: ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }} name: ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
@@ -229,7 +325,7 @@ 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 util-linux" 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
@@ -240,9 +336,9 @@ jobs:
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-1[345]) echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV ;; macos-[12][3456]*) echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV ;;
esac esac
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: { submodules: true } with: { submodules: true }
- name: Check out test suite - name: Check out test suite
if: ${{ matrix.testsuite }} if: ${{ matrix.testsuite }}
@@ -265,6 +361,8 @@ 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"
@@ -282,13 +380,14 @@ jobs:
(cd tmp/artifact && gtar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst") (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@v5
with: { name: '${{ env.artifact_name }}', path: tmp/artifact } with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
- name: Run install tests - name: Run install tests
run: | run: |
(cd build/extra/clang/release && DESTDIR="$PWD/Install with cmake" cmake --install .) (cd build/extra/clang/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
(cd build/extra/clang/release && DESTDIR="$PWD/Install with make" make install) (cd build/extra/clang/release && DESTDIR="$PWD/Install with make" make install)
- name: Run ctest tests - name: Run ctest tests
if: ${{ matrix.testsuite }}
run: | run: |
for f in ./build/extra/*/*/upx; do file $f; done for f in ./build/extra/*/*/upx; do file $f; done
jobs="clang/debug clang/release" jobs="clang/debug clang/release"
@@ -296,6 +395,7 @@ jobs:
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 - name: Mimic ctest tests
if: ${{ matrix.testsuite }}
run: | run: |
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
jobs="clang/debug clang/release" jobs="clang/debug clang/release"
@@ -303,7 +403,7 @@ 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
- name: Run file system tests - name: Run file system tests
if: ${{ matrix.testsuite }} # for coreutils readlink if: ${{ matrix.testsuite }}
run: | run: |
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH" export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
export upx_test_file="$PWD"/build/extra/clang/release/upx export upx_test_file="$PWD"/build/extra/clang/release/upx
@@ -328,24 +428,48 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- { name: windows-2019-amd64, os: windows-2019, vsversion: 2019, vsarch: amd64 } - { name: windows-11-arm64, os: windows-11-arm, vsversion: 2022, vsarch: arm64 }
- { name: windows-2022-amd64, os: windows-2022, vsversion: 2022, vsarch: amd64 } - { name: windows-11-arm64ec, os: windows-11-arm, vsversion: 2022, vsarch: arm64, use_arm64ec: true }
# { name: windows-11-arm64x, os: windows-11-arm, vsversion: 2022, vsarch: arm64, use_arm64x: true }
- { name: windows-2022-amd64, os: windows-2022, vsversion: 2022, vsarch: amd64 }
- { 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-i386, os: windows-2025, vsversion: 2022, vsarch: amd64_x86 }
name: ${{ format('{0}', matrix.name) }} name: ${{ format('{0}', matrix.name) }}
runs-on: ${{ matrix.os }} 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@v6
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.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.use_arm64x }}" == "true" ]]; then true;
echo "UPX_CMAKE_CONFIG_FLAGS_PLATFORM=-A ARM64X" >> $GITHUB_ENV
echo "UPX_CONFIG_DISABLE_SELF_PACK_TEST=ON" >> $GITHUB_ENV
elif [[ "${{ matrix.vsarch }}" == *amd64 ]]; then true;
echo "UPX_CMAKE_CONFIG_FLAGS_PLATFORM=-A x64" >> $GITHUB_ENV
elif [[ "${{ matrix.vsarch }}" == *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 }}" == *x86 ]]; then true;
echo "UPX_CMAKE_CONFIG_FLAGS_PLATFORM=-A Win32" >> $GITHUB_ENV
else
exit 1
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/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/InstallWithDestdir/release" cmake --install build/release --config Release
@@ -356,49 +480,47 @@ jobs:
cmake --install build/debug --config Debug --prefix "$PWD/tmp/artifact/$N/InstallWithCMake/InstallWithPrefixAndStrip/debug" --strip 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 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") #(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
(cd tmp/artifact && tar --sort=name --gzip -cf "$N.tar.gz" "$N" && rm -rf "./$N" && ls -la && gzip -tq "$N.tar.gz")
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@v5
with: { name: '${{ env.artifact_name }}', path: tmp/artifact } with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
- name: Run ctest tests - name: Run ctest tests
if: ${{ matrix.vsarch != 'amd64_arm64' }}
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
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' }}
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-bh-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: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- { name: amd64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64 } - { name: amd64-win64-vs2025, os: windows-2025, vsversion: 2022, vsarch: amd64 }
- { name: amd64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64 } - { name: arm64-win64-vs2025, os: windows-2025, vsversion: 2022, vsarch: amd64_arm64 }
- { name: arm64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64_arm64 } - { name: arm64ec-win64-vs2025, os: windows-2025, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64ec' }
- { name: arm64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64 } # { name: arm64x-win64-vs2025, os: windows-2025, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64x' }
- { name: arm64ec-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64ec' } - { name: i386-win32-vs2025, os: windows-2025, vsversion: 2022, vsarch: amd64_x86 }
# { name: arm64x-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64x' } name: ${{ format('windows-bh {0}', matrix.name) }}
- { 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) }}
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: env:
C: ${{ matrix.name }} C: ${{ matrix.name }}
B: release B: release
steps: steps:
- run: git config --global core.autocrlf false - run: git config --global core.autocrlf false
- uses: actions/checkout@v4 - uses: actions/checkout@v6
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}
@@ -446,34 +568,25 @@ 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-bh-${{ 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") #(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst")
(cd tmp/artifact && tar --sort=name --gzip -cf "$N.tar.gz" "$N" && rm -rf "./$N" && ls -la && gzip -tq "$N.tar.gz")
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@v5
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
@@ -487,17 +600,19 @@ jobs:
include: include:
# only build a few selected 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-macos.11.0-none } - { zig_target: aarch64-linux-musl, qemu: qemu-aarch64, zig_pic: -fPIE, container: 'alpine:3.18' }
- { zig_target: aarch64-macos-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: armeb-linux-musleabihf, qemu: qemu-armeb } - { 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-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-windows-gnu } - { zig_target: i386-windows-gnu }
- { zig_target: mips-linux-musleabi, zig_flags: -msoft-float, qemu: qemu-mips } - { zig_target: mips-linux-musleabi, qemu: qemu-mips }
- { zig_target: mips-linux-musleabihf, qemu: qemu-mips } - { zig_target: mips-linux-musleabihf, qemu: qemu-mips }
- { zig_target: mipsel-linux-musleabi, zig_flags: -msoft-float, qemu: qemu-mipsel } - { zig_target: mipsel-linux-musleabi, qemu: qemu-mipsel }
- { zig_target: mipsel-linux-musleabihf, qemu: qemu-mipsel } - { zig_target: mipsel-linux-musleabihf, qemu: qemu-mipsel }
# { zig_target: mips-linux-musleabi-mips32r2, zig_flags: -march=mips32r2, qemu: qemu-mips } # { zig_target: mips-linux-musleabi-mips32r2, zig_flags: -march=mips32r2, qemu: qemu-mips }
# { zig_target: mips-linux-musleabi-mips32r3, zig_flags: -march=mips32r3, qemu: qemu-mips } # { zig_target: mips-linux-musleabi-mips32r3, zig_flags: -march=mips32r3, qemu: qemu-mips }
@@ -505,18 +620,22 @@ jobs:
# { zig_target: mips-linux-musleabi-mips32r6, zig_flags: -march=mips32r6, 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: powerpc-linux-musleabihf, qemu: qemu-ppc }
- { zig_target: powerpc64-linux-musl, qemu: qemu-ppc64 } - { 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: riscv64-linux-musl, qemu: qemu-riscv64, tt: UPX-UNSUPPORTED }
- { zig_target: riscv64-linux-musl, qemu: qemu-riscv64, tt: UPX-UNSUPPORTED, 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-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-macos.11.0-none } - { 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-windows-gnu } - { zig_target: x86_64-windows-gnu }
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }} name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: 'alpine:3.21' container: ${{ matrix.container || 'alpine:3.23' }}
#container: ${{ contains(matrix.qemu, 'qemu-ppc64') && 'alpine:3.19' || 'alpine:3.21' }}
#container: ${{ (matrix.qemu == 'qemu-ppc64') && 'alpine:edge' || 'alpine:3.21' }}
env: env:
container: ${{ matrix.container || 'alpine:3.23' }}
UPX_CONFIG_HAVE_WORKING_BUILD_RPATH: '' 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
@@ -525,19 +644,19 @@ jobs:
ZIG_TARGET: ${{ matrix.zig_target }} ZIG_TARGET: ${{ matrix.zig_target }}
steps: steps:
- run: uname -a; pwd; id; umask - run: uname -a; pwd; id; umask
- name: Install Alpine Linux container packages shell: sh
if: ${{ job.container }} - 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 patch tar util-linux xz zstd apk update && apk upgrade && apk add bash cmake curl dmidecode file gdb git make parallel patch strace sudo tar util-linux xz zstd
# 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
mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi) mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi)
- uses: actions/checkout@v4 - run: (sudo dmidecode | sed -n -e '/System Information/,/^$/p') || true
- uses: actions/checkout@v6
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
@@ -549,13 +668,18 @@ jobs:
# 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
test -z "${{ matrix.tt }}" || echo "UPX_CONFIG_DISABLE_SELF_PACK_TEST=ON" >> $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_VERSION=${ZIG_DIST_VERSION/#zig-/}
ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION} ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION}
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/builds/${ZIG_DIST_NAME}.tar.xz
curl -sS -L -O https://ziglang.org/download/0.14.0/${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.2/${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
@@ -563,7 +687,7 @@ jobs:
echo -n 'zig version: '; zig version echo -n 'zig version: '; zig version
# patch zig # patch zig
ls -la "$HOME" "$GITHUB_WORKSPACE" || true ls -la "$HOME" "$GITHUB_WORKSPACE" || true
#(cd ${ZIG_DIST_NAME} && patch --verbose -p1 -i "$GITHUB_WORKSPACE"/misc/patches/zig/0001-x.patch) (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)
log= log=
log='set -x\n' log='set -x\n'
@@ -578,7 +702,7 @@ jobs:
[[ $ZIG_TARGET == mips-linux-musleabihf-* ]] && ZIG_TARGET=mips-linux-musleabihf [[ $ZIG_TARGET == mips-linux-musleabihf-* ]] && ZIG_TARGET=mips-linux-musleabihf
[[ $ZIG_TARGET == mipsel-linux-musleabi-* ]] && ZIG_TARGET=mipsel-linux-musleabi [[ $ZIG_TARGET == mipsel-linux-musleabi-* ]] && ZIG_TARGET=mipsel-linux-musleabi
[[ $ZIG_TARGET == mipsel-linux-musleabihf-* ]] && ZIG_TARGET=mipsel-linux-musleabihf [[ $ZIG_TARGET == mipsel-linux-musleabihf-* ]] && ZIG_TARGET=mipsel-linux-musleabihf
ZIG_TARGET=${ZIG_TARGET/i386-/x86-} # i386 => x86 ZIG_TARGET=${ZIG_TARGET/#i386-/x86-} # i386 => x86
echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV
# update ZIG_FLAGS # update ZIG_FLAGS
# -fPIE is for compilation only => also use the correct linker flag "-pie" # -fPIE is for compilation only => also use the correct linker flag "-pie"
@@ -593,6 +717,11 @@ jobs:
ZIG_FLAGS="$ZIG_FLAGS -fno-sanitize=all" ZIG_FLAGS="$ZIG_FLAGS -fno-sanitize=all"
echo "UPX_CONFIG_DISABLE_SANITIZE=ON" >> $GITHUB_ENV echo "UPX_CONFIG_DISABLE_SANITIZE=ON" >> $GITHUB_ENV
fi 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 echo "ZIG_FLAGS=$ZIG_FLAGS" >> $GITHUB_ENV
- run: set -x; zig version; zig-cc --version || true; zig-cxx --version || true - 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-cc -E -x c -dM /dev/null # list predefined macros for C
@@ -601,14 +730,13 @@ jobs:
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"
@@ -624,7 +752,7 @@ jobs:
(cd tmp/artifact && tar --sort=name --zstd -cf "$N.tar.zst" "$N" && rm -rf "./$N" && ls -la && zstd -tq "$N.tar.zst") (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@v5
with: { name: '${{ env.artifact_name }}', path: tmp/artifact } with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
- name: Run install tests - name: Run install tests
if: ${{ contains(matrix.zig_target, '-linux') }} if: ${{ contains(matrix.zig_target, '-linux') }}
@@ -656,7 +784,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' || contains(matrix.zig_target, 'x86_64-linux-gnu.2') }} #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
@@ -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
+2
View File
@@ -1,6 +1,8 @@
/.cache* /.cache*
/.idea/
/.hg* /.hg*
/.vscode* /.vscode*
/.zed/
/CMakeCache* /CMakeCache*
/CMakeFiles* /CMakeFiles*
/CTest* /CTest*
+10 -6
View File
@@ -30,6 +30,8 @@ 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_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
@@ -55,20 +57,22 @@ endif()
# test config options (see below) # test config options (see below)
# IMPORTANT NOTE: self-pack test can only work if the host executable format is supported by UPX! # IMPORTANT NOTE: self-pack test can only work if the host executable format is supported by UPX!
option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself" OFF) option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself." OFF)
option(UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS "Do not run exhaustive tests" OFF) option(UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS "Do not run exhaustive tests." OFF)
#*********************************************************************** #***********************************************************************
# init # init
#*********************************************************************** #***********************************************************************
set(UPX_VERSION_STRING "5.0.1") # this should match src/version.h set(UPX_VERSION_STRING "5.1.0") # this should match src/version.h
upx_cmake_include_hook(2_init) upx_cmake_include_hook(2_init)
# Disallow in-source build. Note that you will still have to manually # Disallow in-source build. Note that you will still have to manually
# clean up a few files if you accidentally try an in-source build. # clean up a few files if you accidentally try an in-source build.
upx_disallow_in_source_build() if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
upx_disallow_in_source_build()
endif()
# global settings # global settings
if(${CMAKE_VERSION} VERSION_GREATER "3.14.99" AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) if(${CMAKE_VERSION} VERSION_GREATER "3.14.99" AND NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
@@ -89,7 +93,6 @@ upx_cache_bool_vars(OFF
UPX_CONFIG_DISABLE_SAVE_TEMPS UPX_CONFIG_DISABLE_SHARED_LIBS 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 "")
@@ -286,7 +289,7 @@ if(Threads_FOUND)
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
if(UPX_CONFIG_REQUIRE_THREADS OR (UPX_CONFIG_EXPECT_THREADS AND NOT UPX_CONFIG_DISABLE_THREADS)) 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 message(WARNING "Threads FAILED ${f}: ${output}") # output from try_compile()
endif() endif()
set(Threads_FOUND OFF) set(Threads_FOUND OFF)
break() break()
@@ -466,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()
+28 -9
View File
@@ -26,8 +26,13 @@ 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/.*_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)
@@ -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,9 +72,26 @@ 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 ./Makevars-local.mk -include ./Makevars-local.mk
@@ -87,3 +104,5 @@ check-whitespace clang-format run-testsuite run-testsuite-all run-testsuite-debu
$(MAKE) -C src $@ $(MAKE) -C src $@
endif endif
endif endif
# vim:set ts=8 sw=8 noet:
+6
View File
@@ -2,6 +2,12 @@
User visible changes for UPX User visible changes for UPX
================================================================== ==================================================================
Changes in 5.1.0 (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): Changes in 5.0.1 (06 May 2025):
* bug fixes - see https://github.com/upx/upx/milestone/19 * bug fixes - see https://github.com/upx/upx/milestone/19
+4 -3
View File
@@ -61,8 +61,9 @@ SHORT DOCUMENTATION
'upx program.exe' will compress a program or DLL. For best compression 'upx program.exe' will compress a program or DLL. For best compression
results try 'upx --best program.exe' or 'upx --brute program.exe'. results try 'upx --best program.exe' or 'upx --brute program.exe'.
Please see the file UPX.DOC for the full documentation. The files Please see the file doc/upx-doc.txt for the full documentation. The files
NEWS and BUGS also contain various tidbits of information. NEWS and doc/BUGS.txt also contain various tidbits of information, as
does the output of 'upx --help'.
THE FUTURE THE FUTURE
@@ -91,7 +92,7 @@ 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).
+21 -1
View File
@@ -81,6 +81,15 @@ Developer quick start
4b) $ wget https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz 4b) $ wget https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz
# Extract to $HOME/bin/bin-upx or $HOME/local/bin/bin-upx. # Extract to $HOME/bin/bin-upx or $HOME/local/bin/bin-upx.
# See directions in: https://github.com/upx/upx-stubtools # See directions in: https://github.com/upx/upx-stubtools
# Some of the pre-built tools need i386 libz. On Ubuntu:
# # dpkg --add-architecture i386
# # apt-get update
# # apt-get install zlib1g-dev
# aarch64-linux-gnu/4.9.2/cc1 needs libmpfr.so.4. Make a symlink:
# # ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4
4c) $ make clean; make # verify that you can re-build stubs 4c) $ make clean; make # verify that you can re-build stubs
4d) $ popd # my-upx 4d) $ popd # my-upx
5) $ cd upx # my-upx/upx 5) $ cd upx # my-upx/upx
@@ -92,7 +101,18 @@ Developer quick start
# If stuck, then reset via "rm -rf vendor; git submodule update --init". # If stuck, then reset via "rm -rf vendor; git submodule update --init".
7) $ mkdir -p build/debug build/release 7) $ mkdir -p build/debug build/release
8) $ pushd build/debug # my-upx/upx/build/debug 8) $ pushd build/debug # my-upx/upx/build/debug
9) $ cmake ../.. # configure cmake
9a) Install GNU g++ so that it is used when invoking "c++" compiler.
On Ubuntu 24.04 with
cmake: cmake version 3.28.3
g++: Ubuntu clang version 18.1.3 (1ubuntu1)
/lib/llvm-18/lib/cmake/llvm/HandleLLVMOptions.cmake:
add_flag_if_supported("-fno-lifetime-dse" CMAKE_CXX_FLAGS)
then cmake invoking c++ uses -fno-lifetime-dse but gets
c++: error: unknown argument: '-fno-lifetime-dse'
Commenting out the "add_flag_if_supported' line still uses that unknown argument.
Installing g++ avoids the problem.
9b) $ cmake ../.. # configure cmake
10) $ cmake --build . --verbose # optional "--verbose" 10) $ cmake --build . --verbose # optional "--verbose"
# This relies on stub/*.h, which YOU must re-build if necessary. # This relies on stub/*.h, which YOU must re-build if necessary.
# When in doubt, then use "cd src/stub; make clean; make". # When in doubt, then use "cd src/stub; make clean; make".
Generated
+1 -1
View File
@@ -55,7 +55,7 @@
.\" ======================================================================== .\" ========================================================================
.\" .\"
.IX Title "UPX 1" .IX Title "UPX 1"
.TH UPX 1 2025-05-06 "upx 5.0.1" " " .TH UPX 1 2025-10-24 "upx 5.1.0" " "
.\" 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
+1 -1
View File
@@ -42,7 +42,7 @@ function(upx_print_info)
upx_print_var(CMAKE_${lang}_COMPILER_ID) upx_print_var(CMAKE_${lang}_COMPILER_ID)
upx_print_var(CMAKE_${lang}_SIMULATE_ID) upx_print_var(CMAKE_${lang}_SIMULATE_ID)
upx_print_var(CMAKE_${lang}_COMPILER_VERSION) upx_print_var(CMAKE_${lang}_COMPILER_VERSION)
upx_print_var(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT ) upx_print_var(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT)
upx_print_var(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID) upx_print_var(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID)
upx_print_var(CMAKE_${lang}_PLATFORM_ID) upx_print_var(CMAKE_${lang}_PLATFORM_ID)
upx_print_var(CMAKE_${lang}_COMPILER_ABI) upx_print_var(CMAKE_${lang}_COMPILER_ABI)
+35 -26
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:
+21 -3
View File
@@ -65,6 +65,13 @@ build/extra/clang-lto-auto/release: PHONY; $(call run_config_and_build,$@,Releas
build/extra/clang-lto-auto/%: export CC = clang -flto=auto build/extra/clang-lto-auto/%: export CC = clang -flto=auto
build/extra/clang-lto-auto/%: export CXX = 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)
@@ -140,6 +147,13 @@ 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 CC = gcc -flto=auto
build/extra/gcc-lto-auto/%: export CXX = g++ -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)
@@ -177,7 +191,7 @@ 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 (EXPERIMENTAL; need gcc-14) # 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/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/release: PHONY; $(call run_config_and_build,$@,Release)
build/extra/gcc-std-cxx26/%: export CC = gcc -std=gnu23 build/extra/gcc-std-cxx26/%: export CC = gcc -std=gnu23
@@ -250,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'
@@ -267,6 +281,7 @@ build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/c
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-ucl/$$(notdir $$@) build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-ucl/$$(notdir $$@)
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-zlib/$$(notdir $$@) build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-zlib/$$(notdir $$@)
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-zstd/$$(notdir $$@) build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-zstd/$$(notdir $$@)
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: PHONY
# OLD names [deprecated] # OLD names [deprecated]
build/extra/scan-build/debug: build/analyze/clang-analyzer/debug PHONY build/extra/scan-build/debug: build/analyze/clang-analyzer/debug PHONY
@@ -319,6 +334,7 @@ $(call check_undefined,__add_cmake_config)
__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)
@@ -362,6 +378,8 @@ UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_EXTRA_COMPILE_OPT
SUBMODULES = doctest lzma-sdk ucl valgrind zlib SUBMODULES = doctest lzma-sdk ucl valgrind zlib
$(foreach 1,$(SUBMODULES),$(if $(wildcard vendor/$1/[CL]*),,\ $(foreach 1,$(SUBMODULES),$(if $(wildcard vendor/$1/[CL]*),,\
$(error ERROR: missing git submodule '$1'; run 'git submodule update --init'))) $(error ERROR: missing git submodule '$1'; run 'git submodule update --init')))
endif # UPX_MAKEFILE_EXTRA_MK_INCLUDED endif # UPX_MAKEFILE_EXTRA_MK_INCLUDED
# vim:set ts=8 sw=8 noet:
+2 -1
View File
@@ -11,12 +11,13 @@ diff --git a/lib/libcxx/include/__config b/lib/libcxx/include/__config
index fec323f..a16d145 100644 index fec323f..a16d145 100644
--- a/lib/libcxx/include/__config --- a/lib/libcxx/include/__config
+++ b/lib/libcxx/include/__config +++ b/lib/libcxx/include/__config
@@ -637,9 +637,11 @@ typedef __char32_t char32_t; @@ -637,9 +637,12 @@ typedef __char32_t char32_t;
# define _DECLARE_C99_LDBL_MATH 1 # define _DECLARE_C99_LDBL_MATH 1
# endif # endif
+# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) +# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
+# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0 +# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0
+# elif defined(_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION)
// If we are getting operator new from the MSVC CRT, then allocation overloads // 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. // 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 -# if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
+8 -6
View File
@@ -8,23 +8,25 @@ 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 python3 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 bat bfs btop bubblewrap busybox bzip2 bzip3 cabextract ccache chrpath cmake cpio \ 7zip bat bfs btop bubblewrap busybox bzip2 bzip3 cabextract ccache chrpath cmake cpio \
dash diffstat direnv elfutils execstack eza fd-find file fish fzf \ dash diffstat direnv dmidecode elfutils execstack eza fd-find file fish fzf \
g++ gawk gdb gojq ht htop hyperfine jq ksh \ 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 \ 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-tomli python3-tomli-w \ python3-pyasn1 python3-pycryptodome python3-pycurl python3-tomli python3-tomli-w \
python3-yaml python3-zstd \ python3-yaml python3-zstd \
re2c ripgrep rsync screen socat strace universal-ctags unzip valgrind yash yq \ 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 \
&& apt-get install -y \
gcc-riscv64-linux-gnu \
&& true && true
# install python2-minimal packages from Debian-11; REQUIRED # install python2-minimal packages from Debian-11; REQUIRED
@@ -62,7 +64,7 @@ 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 \
&& curl -sS -L -O 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 4.2.4 5.0.0" \ && 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 curl -sS -L -O 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 \
+459 -400
View File
File diff suppressed because it is too large Load Diff
+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
+28 -11
View File
@@ -16,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
#*********************************************************************** #***********************************************************************
@@ -42,6 +48,7 @@ run_upx=( "${emu[@]}" "$upx_exe" )
echo "run_upx='${run_upx[*]}'" echo "run_upx='${run_upx[*]}'"
# run_upx sanity check # run_upx sanity check
"${run_upx[@]}" --version-short || true
if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
@@ -148,17 +155,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"
+49 -49
View File
@@ -46,14 +46,14 @@ 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="\
919f31ec6a70a81159f4fc1d3cd4e9d66800a242df2fac9e339a36e1bf648091 *amd64-linux.elf/upx-3.91 836d9c5d9092421e49aeb573cde449ef740afbfea54d131ccbd88d8c7d87860d *amd64-linux.elf/upx-3.91
548e950c9f082eb0eb42b18411bbc257365cfc9c937ab20f501ebf0db5850d25 *amd64-linux.elf/upx-3.95 9776a2d030719f9d74413d17c1bb732aaabb610b341031facd2c1a75348fc661 *amd64-linux.elf/upx-3.95
822718cc0f6ac5e57bb23eeb65be6f3f7e73df8b062853abddcc924ec8207596 *amd64-win64.pe/upx-3.95.exe 822718cc0f6ac5e57bb23eeb65be6f3f7e73df8b062853abddcc924ec8207596 *amd64-win64.pe/upx-3.95.exe
4d8b2a8f29b38e097287e550d11810d7ecd4c5f07744545b3a315de908987bf6 *arm-linux.elf/upx-3.95 40353c37020fd4bb713c5d54273b8dc07666e262b83a4f0652ccb8a236465f9c *arm-linux.elf/upx-3.95
1440d6b44968954baf56fbc2a0739a51873455876114d4445ae4b67cb5e7893b *arm-wince.pe/upx-3.91.exe 1440d6b44968954baf56fbc2a0739a51873455876114d4445ae4b67cb5e7893b *arm-wince.pe/upx-3.91.exe
04c08626d4b03a4e969018eed7093c24de191b5d27db2a25221b134827806929 *arm64-linux.elf/upx-3.95 35c08bf5086fe21ff19e3512359e54ac97c6d4513e6bb9ef4a59294bebf18f6a *arm64-linux.elf/upx-3.95
6c8b276a0b611402d336b43cf8514b9a8d98be4f55a8301e784b7b88031b2b85 *armeb-linux.elf/upx-3.91 0ca2dcd9e8b5c3f16dcb31e30b42ec57a70b8fe90281d412081095a3d7812f01 *armeb-linux.elf/upx-3.91
dcd0c0060d44886966ae4e97b79a2c172f02d56228ea76dbc5c880ad59ef4ee5 *armeb-linux.elf/upx-3.95 462a72efbb580a2e90564412737bb3c1db1d930cde5b4f2c94782df91c8e4f4b *armeb-linux.elf/upx-3.95
a7ee051c5f9dcf233e2ee248274121b99fb8f098eff95469bc0638a7423723f0 *i386-dos32.djgpp2.coff/upx-3.91.exe a7ee051c5f9dcf233e2ee248274121b99fb8f098eff95469bc0638a7423723f0 *i386-dos32.djgpp2.coff/upx-3.91.exe
85cf31be166cb59587a99419cdd0fc5a79825d7508ab2c9a4bc0d700d603354d *i386-dos32.djgpp2.coff/upx-3.95.exe 85cf31be166cb59587a99419cdd0fc5a79825d7508ab2c9a4bc0d700d603354d *i386-dos32.djgpp2.coff/upx-3.95.exe
fc7656d9a877967be7e339bfc98a0c63ea7b5abc30b96fa9e5931c75ecbe9827 *i386-linux.elf/upx-3.91 fc7656d9a877967be7e339bfc98a0c63ea7b5abc30b96fa9e5931c75ecbe9827 *i386-linux.elf/upx-3.91
@@ -66,17 +66,17 @@ f60bab42fe3914109ab1b9f5d00a5be753cd0a2c1a79a3998d58800efedbfff7 *mipsel-linux.e
b6d8cc9e2023a3fc415166afc378ccf2eb505487df84c8d959ec74b3fb4f8256 *mipsel-linux.elf/upx-3.95 b6d8cc9e2023a3fc415166afc378ccf2eb505487df84c8d959ec74b3fb4f8256 *mipsel-linux.elf/upx-3.95
acd3dc5ed3e4c4eeaa42e7cca71a79d687dd844ce5f384666ed6e78327b5a8e3 *powerpc-linux.elf/upx-3.91 acd3dc5ed3e4c4eeaa42e7cca71a79d687dd844ce5f384666ed6e78327b5a8e3 *powerpc-linux.elf/upx-3.91
03600584c97fa466ef58239452baf9ec6ff2f06b79d97d45c8490953080de6e3 *powerpc-linux.elf/upx-3.95 03600584c97fa466ef58239452baf9ec6ff2f06b79d97d45c8490953080de6e3 *powerpc-linux.elf/upx-3.95
2aa45e314e83a7ecc548a5116048a981755d00c3e102bd9a9fc6e9a2356047be *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="\
c5bafac11df5a38c1b72fd070373a0e1d5a066527129937c5bc9a280e21ad656 *amd64-linux.elf/upx-3.91 8431343adec632690cec669038c246438c799e7dc1b8bc85586e0d2bcd2eebad *amd64-linux.elf/upx-3.91
6cc1e01ac0b6140464a06f5aefb51c0388fdfe28f264a38061b50b3508203c07 *amd64-linux.elf/upx-3.95 1852bded40be6eb5ddb07a491476dcfcca69cadda45a5f128aa8f967d567fa0b *amd64-linux.elf/upx-3.95
5ab022e2c3ecb09931e2181fb5f7699f35e2b453b54c823e42653c84b0df5f2c *amd64-win64.pe/upx-3.95.exe 5ab022e2c3ecb09931e2181fb5f7699f35e2b453b54c823e42653c84b0df5f2c *amd64-win64.pe/upx-3.95.exe
e21b2305df2c1896eeae61010c3b65d8a50d476ea4a9bab6ec2fa4f9a0bed5a6 *arm-linux.elf/upx-3.95 6de0cf1903760710a95cb5330d0ffb406a93f081dbe6806935f51b0c75e23f03 *arm-linux.elf/upx-3.95
53121baf42c85991900aa3947f3d817fe6e894bc6f325ab1d576de6fba5fbcbf *arm-wince.pe/upx-3.91.exe 53121baf42c85991900aa3947f3d817fe6e894bc6f325ab1d576de6fba5fbcbf *arm-wince.pe/upx-3.91.exe
7431abc46f0960311364ecd690965dd1fc74b2de4baca8e0af8f966735b6372e *arm64-linux.elf/upx-3.95 3c9e49445280de6a771e77f6a88b3c3957815baa193e92a893d5defe6699f50a *arm64-linux.elf/upx-3.95
8b67fc95dc555c2de4e3d0c85e4ab977f4c3fba24d68a2f9c402c51e08ad5f3b *armeb-linux.elf/upx-3.91 627a3c77adfcd4ef8c32f1638a6b99e20e79bb914cbcebed6fb9ad5f96936530 *armeb-linux.elf/upx-3.91
c3b3e5b0a379022b26bae96432c3f5f946990f45b0b26afe056afe1170bf33c7 *armeb-linux.elf/upx-3.95 7faf9f0adf508cf29bf0ac2a62234df06d6c9153d6d59cf61019361db906daf8 *armeb-linux.elf/upx-3.95
51e4faea51e12c7442b27bb50150f532ac51d8102f77a669cbce82f2675a2ef2 *i386-dos32.djgpp2.coff/upx-3.91.exe 51e4faea51e12c7442b27bb50150f532ac51d8102f77a669cbce82f2675a2ef2 *i386-dos32.djgpp2.coff/upx-3.91.exe
1196f578ab0b862bae8ac6b5166b770f072cf0ac521a2a23a6347c19ea82a0da *i386-dos32.djgpp2.coff/upx-3.95.exe 1196f578ab0b862bae8ac6b5166b770f072cf0ac521a2a23a6347c19ea82a0da *i386-dos32.djgpp2.coff/upx-3.95.exe
3015651261f28fb43ed43a8c1fa257bcfcdc788e6fd3f436f3de23733736c724 *i386-linux.elf/upx-3.91 3015651261f28fb43ed43a8c1fa257bcfcdc788e6fd3f436f3de23733736c724 *i386-linux.elf/upx-3.91
@@ -89,17 +89,17 @@ c3b3e5b0a379022b26bae96432c3f5f946990f45b0b26afe056afe1170bf33c7 *armeb-linux.el
b78d8cd3a3402fed266c737cc34a32cc21b2b67b573e9e9071d4faf9fca89b89 *mipsel-linux.elf/upx-3.95 b78d8cd3a3402fed266c737cc34a32cc21b2b67b573e9e9071d4faf9fca89b89 *mipsel-linux.elf/upx-3.95
ea9cae1d1701db3a0c53e9a651766db5bdc30032f48913a4a9e99f193a800acc *powerpc-linux.elf/upx-3.91 ea9cae1d1701db3a0c53e9a651766db5bdc30032f48913a4a9e99f193a800acc *powerpc-linux.elf/upx-3.91
aea86bf87870a1e48a454ac1ea9a80d90d8abe5113d418a71d8a9c4a74bb2d0a *powerpc-linux.elf/upx-3.95 aea86bf87870a1e48a454ac1ea9a80d90d8abe5113d418a71d8a9c4a74bb2d0a *powerpc-linux.elf/upx-3.95
4b0c280570213f2cd94dad68aa8251baf05f817b4a569dda9444ff0d3adbb33d *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="\
509bc9676a0f5f5ce6df118da8e792151db816fcce5490eadc87fc525aad5a35 *amd64-linux.elf/upx-3.91 f817034e8b7765d8b422dac9cb6f24f78ce5bfd7169cd3b33e8224e00b131eca *amd64-linux.elf/upx-3.91
e8d6bf8204c6bf5d170ca8d4c9cb48b3b7a48b04d665dd6e111980081fcba3b3 *amd64-linux.elf/upx-3.95 d21441a05514c085c10e99b00d8cc4d45484297a8e4e8a246364ca4347d0ed56 *amd64-linux.elf/upx-3.95
7bd7cd37093200fa94d21dd7fdfef4d7fb9c3049fbf5f408f1f242cb8d9c6a55 *amd64-win64.pe/upx-3.95.exe 7bd7cd37093200fa94d21dd7fdfef4d7fb9c3049fbf5f408f1f242cb8d9c6a55 *amd64-win64.pe/upx-3.95.exe
4424d813ae55bec589779461c4d4b25361a58ea91659f4a12a7a2d08158cea64 *arm-linux.elf/upx-3.95 d328a89b333d0b36e96d0c61375bf686e8f3b73a188dd4d0df4d78e30af08632 *arm-linux.elf/upx-3.95
ad0a7a18e87657d28260b7c527d284863becd3c5f92259c570125465f88d4042 *arm-wince.pe/upx-3.91.exe ad0a7a18e87657d28260b7c527d284863becd3c5f92259c570125465f88d4042 *arm-wince.pe/upx-3.91.exe
0bbeb73af475bc852313074a14360ae863364175d7fbd4c2f3450790bc3a58ee *arm64-linux.elf/upx-3.95 0b700f0f7dde3118694155e876e6c2003ef701fe94856d6562936ec081278747 *arm64-linux.elf/upx-3.95
7da4a04118f50824821c00f4f9abf6056128ac33de6ac45a145fb5d4810850d9 *armeb-linux.elf/upx-3.91 53a1d04fa62e25e64e6f792b079e21b4c42676a73503ae6d9e67ae16c98e6d04 *armeb-linux.elf/upx-3.91
b4191959889ecb2b9bd2dd046318b414ab5a8268517572017466fbc9c986925e *armeb-linux.elf/upx-3.95 33ed1e3b84836d2af52295ba0b90343ac0b8d524539ce3b8d0aa9f19a51d70dd *armeb-linux.elf/upx-3.95
6fcdc8e34ce8b3501db2260c8a921c6e963954fdeffedfefca353a27bcc02d56 *i386-dos32.djgpp2.coff/upx-3.91.exe 6fcdc8e34ce8b3501db2260c8a921c6e963954fdeffedfefca353a27bcc02d56 *i386-dos32.djgpp2.coff/upx-3.91.exe
6f4f901c1838252f9b3104060475a6f13a2ebec830096ff28d870148580e4287 *i386-dos32.djgpp2.coff/upx-3.95.exe 6f4f901c1838252f9b3104060475a6f13a2ebec830096ff28d870148580e4287 *i386-dos32.djgpp2.coff/upx-3.95.exe
8127f8380300508e8062e9391e321abd0429a6a31fec41e769cc7fe80af27e27 *i386-linux.elf/upx-3.91 8127f8380300508e8062e9391e321abd0429a6a31fec41e769cc7fe80af27e27 *i386-linux.elf/upx-3.91
@@ -112,17 +112,17 @@ cd9b3d3780a79cb416b261d622e8e86f2369fa8bb9bc49b529c50cac2980d528 *mipsel-linux.e
5baf7db9e4335c0227106262efc9d18ad23b88c6d6bb636656aea67bb063b6ec *mipsel-linux.elf/upx-3.95 5baf7db9e4335c0227106262efc9d18ad23b88c6d6bb636656aea67bb063b6ec *mipsel-linux.elf/upx-3.95
aba8bd826ee52d533f9e1c4270d4f4194fe8d8747ea10a1d3ce59b6443f1a9f2 *powerpc-linux.elf/upx-3.91 aba8bd826ee52d533f9e1c4270d4f4194fe8d8747ea10a1d3ce59b6443f1a9f2 *powerpc-linux.elf/upx-3.91
6f737ccbf8c830476bed9c4dd33dd7757ea25bf2f8fb03b44d03e9b77ada0f1b *powerpc-linux.elf/upx-3.95 6f737ccbf8c830476bed9c4dd33dd7757ea25bf2f8fb03b44d03e9b77ada0f1b *powerpc-linux.elf/upx-3.95
91ee0982626eec07e524523d54873790b183aca5bdb27255771fcbfbc081cbc3 *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="\
ed2849169a873bb4070e9d878126f7bc19fb326d1dc6e169901ff3a3026661c3 *amd64-linux.elf/upx-3.91 fefac6fbd1e95479eb4066519f9bd801a30c29966685840b6a011e2911b984ca *amd64-linux.elf/upx-3.91
2b7f9baf27490274fe9301e8a962ac2bae03da0afec67c17df8f8f0e27157891 *amd64-linux.elf/upx-3.95 64487a0e0aade092a8ff7e6d8d9528ca550540cac8d432005ba610179782d042 *amd64-linux.elf/upx-3.95
a55ec5a7f2911f6da8b9336daf4f1051e753cfb7a4458c7f7baa6b63340c6daf *amd64-win64.pe/upx-3.95.exe a55ec5a7f2911f6da8b9336daf4f1051e753cfb7a4458c7f7baa6b63340c6daf *amd64-win64.pe/upx-3.95.exe
8765db7ae04a03af743ad8afc586b943b84b65aca9f1ec240232daa2161ba703 *arm-linux.elf/upx-3.95 9f405739b904bb85053b75187c9175e4ac7f66a07ac5e320eaa4e9771e1ec79e *arm-linux.elf/upx-3.95
7a6c603eecf214e5d6742f1fce922223c97c8bd2527678a968640dd6c1bc0d71 *arm-wince.pe/upx-3.91.exe 7a6c603eecf214e5d6742f1fce922223c97c8bd2527678a968640dd6c1bc0d71 *arm-wince.pe/upx-3.91.exe
810aa1e8f15d9617a0fac4bc4e5c5c5219fc44125d41ced661c744d6c5bb9857 *arm64-linux.elf/upx-3.95 c8435e2f82ba72a0b6abad4146539d40d495461c5e480af705b2bbd21d192128 *arm64-linux.elf/upx-3.95
1dbb05c09fb972c3a5f87ace0c802af48f8b20f7f977f5a14b91dad59800d6a6 *armeb-linux.elf/upx-3.91 21fc48eaaedc73fe9239159fb864c6149f729ef1661a8407b88ad9c9a19f9a54 *armeb-linux.elf/upx-3.91
a1fba814639540616175e0c058267e96f839d85a187b01af764af14ae1b6019c *armeb-linux.elf/upx-3.95 742db587dc53f616c7b276a930c3f586da2b7c3ce6ccd523c041e88a9671b99b *armeb-linux.elf/upx-3.95
7a8eaa5139b95cc56591200fce62d3c9af163671467952cab6fcf487318107bb *i386-dos32.djgpp2.coff/upx-3.91.exe 7a8eaa5139b95cc56591200fce62d3c9af163671467952cab6fcf487318107bb *i386-dos32.djgpp2.coff/upx-3.91.exe
9b5fc0f54a5f811bda190c36fb2fa5c5b03c6c3de0c62693e4191230b5a419b8 *i386-dos32.djgpp2.coff/upx-3.95.exe 9b5fc0f54a5f811bda190c36fb2fa5c5b03c6c3de0c62693e4191230b5a419b8 *i386-dos32.djgpp2.coff/upx-3.95.exe
68b4ce63cb0bd7dd5b287e1f9fa5d9bc234ac36359ce3ebff863984c503a698e *i386-linux.elf/upx-3.91 68b4ce63cb0bd7dd5b287e1f9fa5d9bc234ac36359ce3ebff863984c503a698e *i386-linux.elf/upx-3.91
@@ -135,17 +135,17 @@ e268c98fdacfd04268d76644f2bb4746ae04b57801407aaa1867798840eeeea0 *m68k-atari.tos
339d38602413d97d9bba113f39884815af10ebcdccf37e3f5e8d0879f262a048 *mipsel-linux.elf/upx-3.95 339d38602413d97d9bba113f39884815af10ebcdccf37e3f5e8d0879f262a048 *mipsel-linux.elf/upx-3.95
6d4f9d4383ebc9d8411d06a7c219dcf3e8513ea8c989f2d31ab382602f873ba5 *powerpc-linux.elf/upx-3.91 6d4f9d4383ebc9d8411d06a7c219dcf3e8513ea8c989f2d31ab382602f873ba5 *powerpc-linux.elf/upx-3.91
5dd727d8d5a35cc0ab86d629285d8ff450f52b538118679edaa886ce9c1fed7d *powerpc-linux.elf/upx-3.95 5dd727d8d5a35cc0ab86d629285d8ff450f52b538118679edaa886ce9c1fed7d *powerpc-linux.elf/upx-3.95
d915a3326dda439c0e30df2bd7abf9856a5b5e039142c4ea74e72cb43c854160 *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="\
fc30606d37c697f5c79742bf6e7d2afa8503e69fc87e52274d00b5210d03157a *amd64-linux.elf/upx-3.91 05b29bde32af1e63e837e2be499567c4b10d7e692c88082f24e3417e0c7b9f40 *amd64-linux.elf/upx-3.91
c6d66f6d4f92812801c021a854fbd94745a7b63e0477678b8eb1dc26c5b0a9a4 *amd64-linux.elf/upx-3.95 65c142ee01af09fa8741932c1f21d466be971aad059cc5afddbb7ecdf142c1bb *amd64-linux.elf/upx-3.95
cbb5c90bd9195bd9e3acd931312a70deeccfab5540f398ceda8826f8d6b332bf *amd64-win64.pe/upx-3.95.exe cbb5c90bd9195bd9e3acd931312a70deeccfab5540f398ceda8826f8d6b332bf *amd64-win64.pe/upx-3.95.exe
bb88759de778b1099b51a012f915e646ebfddcbd2fb26b3a1e760fc81a41d2b9 *arm-linux.elf/upx-3.95 1ea1bb18c0ac85c07450f0a6704b84e58a1322556757e2943340ef381b2ce675 *arm-linux.elf/upx-3.95
76a5f0518fc797bd3f132ce6eb61ca187b5d463f191417883a73d4584716c23a *arm-wince.pe/upx-3.91.exe 76a5f0518fc797bd3f132ce6eb61ca187b5d463f191417883a73d4584716c23a *arm-wince.pe/upx-3.91.exe
7b9290c2ab01632d8baa28b24498fbcd734caf8e3846864bb62a8282de3ffd9a *arm64-linux.elf/upx-3.95 4df30002376a4f18029ea9dd8260d395bec3a3fa11fbc5aa19859c2f0efdc2e6 *arm64-linux.elf/upx-3.95
0bafd7837327b590b3be06676ee73c52405e5e4a36a6d06f8b6773e93c499420 *armeb-linux.elf/upx-3.91 ba03fd4889210435c9673f2dcbd2269162037090eccc79cf7d2b896e64a57e2e *armeb-linux.elf/upx-3.91
aea39071ff8ce0b2a59f30e50603ef2ec39789693a3dd9baa4e6be1e49b4e068 *armeb-linux.elf/upx-3.95 681f32d01c76ff31776b8d6f1556daa38eee297f675aa40ff1bb2e47e12adf15 *armeb-linux.elf/upx-3.95
aa05c3a2953f0f2d70842cba45786b707a79ffef22fd084f51e304762cc67765 *i386-dos32.djgpp2.coff/upx-3.91.exe aa05c3a2953f0f2d70842cba45786b707a79ffef22fd084f51e304762cc67765 *i386-dos32.djgpp2.coff/upx-3.91.exe
c677241e9a8753ba1332ac3875ab6398fb2d792d2627edd9e58f2535b3131abe *i386-dos32.djgpp2.coff/upx-3.95.exe c677241e9a8753ba1332ac3875ab6398fb2d792d2627edd9e58f2535b3131abe *i386-dos32.djgpp2.coff/upx-3.95.exe
7bcd42f58dcc8ddb6cb1a4e33d56b584fe6d49b002b01a0859571d1324dd593a *i386-linux.elf/upx-3.91 7bcd42f58dcc8ddb6cb1a4e33d56b584fe6d49b002b01a0859571d1324dd593a *i386-linux.elf/upx-3.91
@@ -158,17 +158,17 @@ c5107a84d32de820c81401259a7dd23435ea625588d56c6c75ad6fa14b0dbf8b *mips-linux.elf
fd9ea397a29b41a2143f9e02217e181d0075d7ad7d87bdbadc7fc94bfb1b0d76 *mipsel-linux.elf/upx-3.95 fd9ea397a29b41a2143f9e02217e181d0075d7ad7d87bdbadc7fc94bfb1b0d76 *mipsel-linux.elf/upx-3.95
c47d1299f6ecf86e62528fc54979117b2b2ddbb6c80f553689402399fc7eab28 *powerpc-linux.elf/upx-3.91 c47d1299f6ecf86e62528fc54979117b2b2ddbb6c80f553689402399fc7eab28 *powerpc-linux.elf/upx-3.91
77c3b4ba6909a4e20180bc13775e280086d67240519c323c2005f3fcee6e0b78 *powerpc-linux.elf/upx-3.95 77c3b4ba6909a4e20180bc13775e280086d67240519c323c2005f3fcee6e0b78 *powerpc-linux.elf/upx-3.95
9741ba142aa8f9fb554dbab3a0295b1aa58e5f246274e2831583d8f99af59764 *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="\
115046275f6bccbaa34b7aefbedeba8741aba4e4876340a3d7363bae86ee4209 *amd64-linux.elf/upx-3.91 94c91b97fcce7402a4494b22699b2450e8e4e2a9f4ddd66e1133c76ce198c167 *amd64-linux.elf/upx-3.91
a8394890b5d731258316b520da2a5e4b43902742d237536fb7fbc578c6197fbb *amd64-linux.elf/upx-3.95 5b3e85adb37919d051c6eaff205b8e1d77a2dfde0d8e7dcdee7c22f8fd5dc8c7 *amd64-linux.elf/upx-3.95
5a0ecb45658904bcd0b823b77dba039c9814e2eff4ed429784c36b7074b9858c *amd64-win64.pe/upx-3.95.exe 5a0ecb45658904bcd0b823b77dba039c9814e2eff4ed429784c36b7074b9858c *amd64-win64.pe/upx-3.95.exe
0976be6c56de1ac2314d8a4962ae3d9d7be962847600db5e2bab529ab32cebd6 *arm-linux.elf/upx-3.95 de93a219ca3c4ea84bd9c1b5fb37ff4aaa0a08ea6eac18da6d7a5865e4dad19c *arm-linux.elf/upx-3.95
fdbe0395ac401285edb9c2f9bfbb0fbd3c0eaad5052a88d8369b1a66b35a8a3e *arm-wince.pe/upx-3.91.exe fdbe0395ac401285edb9c2f9bfbb0fbd3c0eaad5052a88d8369b1a66b35a8a3e *arm-wince.pe/upx-3.91.exe
1c8d536870d0244bb12cb8fdd6cd35ad7e9a53bbc4aa8e2e12af72447caaf467 *arm64-linux.elf/upx-3.95 acdb7ff90d7c6f403872ec333e2987ee74e99d6e1390863b321b528d312c1084 *arm64-linux.elf/upx-3.95
912b6ca141a028974bc46aeb571314db371647201974283992752933f39200b1 *armeb-linux.elf/upx-3.91 54860e61da36414dc105aafcdbb86c79b745913a7d0da911fa58a6941f111e2d *armeb-linux.elf/upx-3.91
0b5757e474bcf3136edf10e403f95e706b214a5cf7d8577fbf7778175b1bef61 *armeb-linux.elf/upx-3.95 7c36b75cc8a0712515e12a9e565df4ca43bff6cc0077afb282d367fcc2ee2acd *armeb-linux.elf/upx-3.95
0a0099246096d20ff6035a4df6566954b9d8aff9ed8fdbd35aa5ee4995b02bfe *i386-dos32.djgpp2.coff/upx-3.91.exe 0a0099246096d20ff6035a4df6566954b9d8aff9ed8fdbd35aa5ee4995b02bfe *i386-dos32.djgpp2.coff/upx-3.91.exe
5df7aa9f0896df87eb8798119ad16a9b89c87a7568a67339e33b5baa99ec361f *i386-dos32.djgpp2.coff/upx-3.95.exe 5df7aa9f0896df87eb8798119ad16a9b89c87a7568a67339e33b5baa99ec361f *i386-dos32.djgpp2.coff/upx-3.95.exe
53e5aae9bc70f58e3dc2aef5a94f66df2517d547670e72ee2b3189b7da809f41 *i386-linux.elf/upx-3.91 53e5aae9bc70f58e3dc2aef5a94f66df2517d547670e72ee2b3189b7da809f41 *i386-linux.elf/upx-3.91
@@ -181,17 +181,17 @@ f3d33c5c9809943a902133490bcf0cfbe39a5ef1635a0c29b3bdc4f35dfffa50 *i386-win32.pe/
68f674d081d87e86e54f0051eee9e2bc85b566051992774ab28ff3173cbcb75a *mipsel-linux.elf/upx-3.95 68f674d081d87e86e54f0051eee9e2bc85b566051992774ab28ff3173cbcb75a *mipsel-linux.elf/upx-3.95
f569d8f49d7110bb8b262a48055b39d889e9977c40c5f1b21e74f8cbf93b27ae *powerpc-linux.elf/upx-3.91 f569d8f49d7110bb8b262a48055b39d889e9977c40c5f1b21e74f8cbf93b27ae *powerpc-linux.elf/upx-3.91
d8227a8a88c083760889acaf259e7da59eab75a23e341289bc8e3c60563ae344 *powerpc-linux.elf/upx-3.95 d8227a8a88c083760889acaf259e7da59eab75a23e341289bc8e3c60563ae344 *powerpc-linux.elf/upx-3.95
1675cd12ecdccdcc8bb73d75e8841f5bfde6dfd424dc73cb0065ebf271ace1f8 *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="\
09cee61e2a4e94455d75a76711078719c3ca7fab77f047c4c85c9424e651956d *amd64-linux.elf/upx-3.91 52a39c30b60abb82c1ec2826297eb46abdc29b5dd55d7a7a41dd2fc1c573f60a *amd64-linux.elf/upx-3.91
0196cbaa36e5224b26729f1bb13990327878ffb0d2cd5784f8fbe715f12dcc1c *amd64-linux.elf/upx-3.95 f0c728c42e8775767e0d963e1eef7ca78711f3f6dd180df980a1faef926d7cac *amd64-linux.elf/upx-3.95
e07e9babdeb12fddeebbfa1b0293163cc5e63017d6f0933d02587c8da1e90a82 *amd64-win64.pe/upx-3.95.exe e07e9babdeb12fddeebbfa1b0293163cc5e63017d6f0933d02587c8da1e90a82 *amd64-win64.pe/upx-3.95.exe
4b93e4dd9baea301479fa989d935b7b6b43b2b54464c5def0db1a00b6a15d719 *arm-linux.elf/upx-3.95 f0359efa2247e9ea756f54c85e7518d61f3b293e08f566c3812c64c7d5f0db0f *arm-linux.elf/upx-3.95
8d1706ab02013b536c3a4cec20d40a96591ffa45fdcb464ccd3f038567006d79 *arm-wince.pe/upx-3.91.exe 8d1706ab02013b536c3a4cec20d40a96591ffa45fdcb464ccd3f038567006d79 *arm-wince.pe/upx-3.91.exe
be753ff9bc789d80f32cec35cc0f9c67b102d297f607b328779ba8d80da13593 *arm64-linux.elf/upx-3.95 14932490ff17e27bb5bedde576b8683892c4720f4a0058f373aab9f8894fda09 *arm64-linux.elf/upx-3.95
4c6d40107b5bce15a40aef514b57ac6dd644162998915aee412feca21582118a *armeb-linux.elf/upx-3.91 64a73512e40c2fb49d8ae3a1d496b379c97b8724cf8ca4461a85825ff04366a0 *armeb-linux.elf/upx-3.91
9d70d663c00378aa1c1c43d55327a895be33ea081bac13ce8a7ea6895b539679 *armeb-linux.elf/upx-3.95 078e7cd073ba071f17ad4292e2211b7d635f57e974546e7f156cc87f9aa716e2 *armeb-linux.elf/upx-3.95
dda2c348c43741a1bd65049a8e7b51be1ebf873d215370ec002185c85390c168 *i386-dos32.djgpp2.coff/upx-3.91.exe dda2c348c43741a1bd65049a8e7b51be1ebf873d215370ec002185c85390c168 *i386-dos32.djgpp2.coff/upx-3.91.exe
560392427ded22f2f3fea59ef10e55d65cf841001e67b1e4558ef13514baa602 *i386-dos32.djgpp2.coff/upx-3.95.exe 560392427ded22f2f3fea59ef10e55d65cf841001e67b1e4558ef13514baa602 *i386-dos32.djgpp2.coff/upx-3.95.exe
f3f8feceebe8536633554b204df68c2e94e1d1a313fe7a576b7f5d404c916083 *i386-linux.elf/upx-3.91 f3f8feceebe8536633554b204df68c2e94e1d1a313fe7a576b7f5d404c916083 *i386-linux.elf/upx-3.91
@@ -204,6 +204,6 @@ ad47c7522167f6f7e47d495e1fa119431386ca5ea9bc16b6a4b9cb38cf9cd29f *i386-win32.pe/
1dcd626fc4566c608e987fd6999b695793c5cae7f78872e3d1a9a23942fea188 *mipsel-linux.elf/upx-3.95 1dcd626fc4566c608e987fd6999b695793c5cae7f78872e3d1a9a23942fea188 *mipsel-linux.elf/upx-3.95
2047a4a880322bf41e8afbb4787f6103364de4a299b543808251a4144c4d990b *powerpc-linux.elf/upx-3.91 2047a4a880322bf41e8afbb4787f6103364de4a299b543808251a4144c4d990b *powerpc-linux.elf/upx-3.91
63679bd238f30bfb14853246eb257536471fea10f942b2adfdd43cbef21dea30 *powerpc-linux.elf/upx-3.95 63679bd238f30bfb14853246eb257536471fea10f942b2adfdd43cbef21dea30 *powerpc-linux.elf/upx-3.95
f075e10b0f7c9ab703d0f923387e7ae425fa22c04349cb8085916c32afe4eef2 *powerpc64le-linux.elf/upx-3.95 c75d1548db879ed589b55bc1319869b49d37595f4560a64b34016951dc02f997 *powerpc64le-linux.elf/upx-3.95
" "
########## end .sha256sums.recreate ########## end .sha256sums.recreate
+6
View File
@@ -9,6 +9,12 @@
Memcheck:Cond Memcheck:Cond
fun:enframe fun:enframe
} }
{
musl-malloc-get_nominal_size
Memcheck:Cond
fun:get_nominal_size
fun:__libc_free
}
# these are only needed for older musl versions # these are only needed for older musl versions
+9 -9
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)
@@ -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
+31 -14
View File
@@ -32,8 +32,9 @@
// 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)
static_assert(std::is_same_v<upx_uint32_t, unsigned>);
static_assert(std::is_same_v<byte, unsigned char>); static_assert(std::is_same_v<byte, unsigned char>);
static_assert(std::is_same_v<upx_int32_t, int>);
static_assert(std::is_same_v<upx_uint32_t, unsigned>);
#if defined(upx_is_constant_evaluated) #if defined(upx_is_constant_evaluated)
#define bele_constexpr constexpr #define bele_constexpr constexpr
@@ -294,13 +295,15 @@ forceinline constexpr upx_uint64_t no_bswap64(upx_uint64_t v) noexcept { return
#define ne16_to_le16(v) bswap16(v) #define ne16_to_le16(v) bswap16(v)
#define ne32_to_le32(v) bswap32(v) #define ne32_to_le32(v) bswap32(v)
#define ne64_to_le64(v) bswap64(v) #define ne64_to_le64(v) bswap64(v)
#else #elif (ACC_ABI_LITTLE_ENDIAN)
#define ne16_to_be16(v) bswap16(v) #define ne16_to_be16(v) bswap16(v)
#define ne32_to_be32(v) bswap32(v) #define ne32_to_be32(v) bswap32(v)
#define ne64_to_be64(v) bswap64(v) #define ne64_to_be64(v) bswap64(v)
#define ne16_to_le16(v) no_bswap16(v) #define ne16_to_le16(v) no_bswap16(v)
#define ne32_to_le32(v) no_bswap32(v) #define ne32_to_le32(v) no_bswap32(v)
#define ne64_to_le64(v) no_bswap64(v) #define ne64_to_le64(v) no_bswap64(v)
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
/************************************************************************* /*************************************************************************
@@ -359,8 +362,12 @@ inline constexpr unsigned get_be24(const byte *p) noexcept {
inline constexpr unsigned get_le24(const byte *p) noexcept { inline constexpr unsigned get_le24(const byte *p) noexcept {
return upx::compile_time::get_le24(p); return upx::compile_time::get_le24(p);
} }
inline constexpr unsigned get_ne24(const byte *p) noexcept {
return upx::compile_time::get_ne24(p);
}
inline constexpr void set_be24(byte *p, unsigned v) noexcept { upx::compile_time::set_be24(p, v); } 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); } inline constexpr void set_le24(byte *p, unsigned v) noexcept { upx::compile_time::set_le24(p, v); }
inline constexpr void set_ne24(byte *p, unsigned v) noexcept { upx::compile_time::set_ne24(p, v); }
REQUIRE_XE24 REQUIRE_XE24
forceinline bele_constexpr unsigned get_be24(const XE24 *p) noexcept { forceinline bele_constexpr unsigned get_be24(const XE24 *p) noexcept {
@@ -371,6 +378,10 @@ forceinline bele_constexpr unsigned get_le24(const XE24 *p) noexcept {
return get_le24(upx::ptr_static_cast<const byte *>(p)); return get_le24(upx::ptr_static_cast<const byte *>(p));
} }
REQUIRE_XE24 REQUIRE_XE24
forceinline bele_constexpr unsigned get_ne24(const XE24 *p) noexcept {
return get_ne24(upx::ptr_static_cast<const byte *>(p));
}
REQUIRE_XE24
forceinline bele_constexpr void set_be24(XE24 *p, unsigned v) noexcept { forceinline bele_constexpr void set_be24(XE24 *p, unsigned v) noexcept {
set_be24(upx::ptr_static_cast<byte *>(p), v); set_be24(upx::ptr_static_cast<byte *>(p), v);
} }
@@ -378,6 +389,10 @@ REQUIRE_XE24
forceinline bele_constexpr void set_le24(XE24 *p, unsigned v) noexcept { forceinline bele_constexpr void set_le24(XE24 *p, unsigned v) noexcept {
set_le24(upx::ptr_static_cast<byte *>(p), v); set_le24(upx::ptr_static_cast<byte *>(p), v);
} }
REQUIRE_XE24
forceinline bele_constexpr void set_ne24(XE24 *p, unsigned v) noexcept {
set_ne24(upx::ptr_static_cast<byte *>(p), v);
}
REQUIRE_XE32 REQUIRE_XE32
inline bele_constexpr 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; }
@@ -411,7 +426,7 @@ inline bele_constexpr void set_le14_5(XE32 *p, unsigned v) noexcept {
// get signed values // get signed values
**************************************************************************/ **************************************************************************/
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));
@@ -420,7 +435,7 @@ forceinline constexpr int sign_extend(unsigned v, unsigned bits) noexcept {
#endif #endif
} }
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 = upx_uint64_t(1) << (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));
@@ -432,49 +447,49 @@ forceinline constexpr upx_int64_t sign_extend(upx_uint64_t v, unsigned bits) noe
REQUIRE_XE16 REQUIRE_XE16
inline bele_constexpr 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 bele_constexpr 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 bele_constexpr 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 bele_constexpr 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 bele_constexpr 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 bele_constexpr 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 bele_constexpr 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 bele_constexpr 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);
} }
/************************************************************************* /*************************************************************************
@@ -1084,7 +1099,7 @@ TT_UPX_IS_INTEGRAL(LE32);
TT_UPX_IS_INTEGRAL(LE64); TT_UPX_IS_INTEGRAL(LE64);
#undef TT_UPX_IS_INTEGRAL #undef TT_UPX_IS_INTEGRAL
// native types // NE - Native Endianness (aka Host Endianness aka CPU Endianness)
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
typedef BE16 NE16; typedef BE16 NE16;
typedef BE32 NE32; typedef BE32 NE32;
@@ -1095,7 +1110,7 @@ typedef BE64 NE64;
#define ne16_compare_signed be16_compare_signed #define ne16_compare_signed be16_compare_signed
#define ne32_compare_signed be32_compare_signed #define ne32_compare_signed be32_compare_signed
#define ne64_compare_signed be64_compare_signed #define ne64_compare_signed be64_compare_signed
#else #elif (ACC_ABI_LITTLE_ENDIAN)
typedef LE16 NE16; typedef LE16 NE16;
typedef LE32 NE32; typedef LE32 NE32;
typedef LE64 NE64; typedef LE64 NE64;
@@ -1105,6 +1120,8 @@ typedef LE64 NE64;
#define ne16_compare_signed le16_compare_signed #define ne16_compare_signed le16_compare_signed
#define ne32_compare_signed le32_compare_signed #define ne32_compare_signed le32_compare_signed
#define ne64_compare_signed le64_compare_signed #define ne64_compare_signed le64_compare_signed
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
/************************************************************************* /*************************************************************************
+3 -3
View File
@@ -135,7 +135,7 @@ struct BEPolicy final
S u32_compare_signed(const void *a, const void *b) C { return be32_compare_signed(a, b); } S u32_compare_signed(const void *a, const void *b) C { return be32_compare_signed(a, b); }
S u64_compare_signed(const void *a, const void *b) C { return be64_compare_signed(a, b); } S u64_compare_signed(const void *a, const void *b) C { return be64_compare_signed(a, b); }
static void compileTimeAssertions() { static void compileTimeAssertions() noexcept {
COMPILE_TIME_ASSERT(sizeof(U16) == 2) COMPILE_TIME_ASSERT(sizeof(U16) == 2)
COMPILE_TIME_ASSERT(sizeof(U32) == 4) COMPILE_TIME_ASSERT(sizeof(U32) == 4)
COMPILE_TIME_ASSERT(sizeof(U64) == 8) COMPILE_TIME_ASSERT(sizeof(U64) == 8)
@@ -194,7 +194,7 @@ struct LEPolicy final
S u32_compare_signed(const void *a, const void *b) C { return le32_compare_signed(a, b); } S u32_compare_signed(const void *a, const void *b) C { return le32_compare_signed(a, b); }
S u64_compare_signed(const void *a, const void *b) C { return le64_compare_signed(a, b); } S u64_compare_signed(const void *a, const void *b) C { return le64_compare_signed(a, b); }
static void compileTimeAssertions() { static void compileTimeAssertions() noexcept {
COMPILE_TIME_ASSERT(sizeof(U16) == 2) COMPILE_TIME_ASSERT(sizeof(U16) == 2)
COMPILE_TIME_ASSERT(sizeof(U32) == 4) COMPILE_TIME_ASSERT(sizeof(U32) == 4)
COMPILE_TIME_ASSERT(sizeof(U64) == 8) COMPILE_TIME_ASSERT(sizeof(U64) == 8)
@@ -210,7 +210,7 @@ private:
UPX_CXX_DISABLE_NEW_DELETE(LEPolicy) UPX_CXX_DISABLE_NEW_DELETE(LEPolicy)
}; };
// Native Endianness policy (aka host policy) // NE - 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;
+46 -37
View File
@@ -262,7 +262,7 @@ ASSERT_SAME_TYPE(short, upx_int16_t);
ASSERT_SAME_TYPE(unsigned short, upx_uint16_t); ASSERT_SAME_TYPE(unsigned short, upx_uint16_t);
ASSERT_SAME_TYPE(int, upx_int32_t); ASSERT_SAME_TYPE(int, upx_int32_t);
ASSERT_SAME_TYPE(unsigned, upx_uint32_t); ASSERT_SAME_TYPE(unsigned, upx_uint32_t);
#if (__SIZEOF_LONG_LONG__ + 0 < 128) #if (__SIZEOF_LONG_LONG__ + 0 < 16)
ASSERT_SAME_TYPE(long long, upx_int64_t); ASSERT_SAME_TYPE(long long, upx_int64_t);
ASSERT_SAME_TYPE(unsigned long long, upx_uint64_t); ASSERT_SAME_TYPE(unsigned long long, upx_uint64_t);
#endif #endif
@@ -283,18 +283,18 @@ static_assert(bswap32(bswap32(0xf4f3f2f1)) == no_bswap32(0xf4f3f2f1));
static_assert(bswap64(bswap64(0xf8f7f6f5f4f3f2f1ull)) == no_bswap64(0xf8f7f6f5f4f3f2f1ull)); static_assert(bswap64(bswap64(0xf8f7f6f5f4f3f2f1ull)) == no_bswap64(0xf8f7f6f5f4f3f2f1ull));
#endif #endif
static_assert(sign_extend(0u + 0, 8) == 0); static_assert(sign_extend32(0u + 0, 8) == 0);
static_assert(sign_extend(0u + 1, 8) == 1); static_assert(sign_extend32(0u + 1, 8) == 1);
static_assert(sign_extend(0u + 127, 8) == 127); static_assert(sign_extend32(0u + 127, 8) == 127);
static_assert(sign_extend(0u + 128, 8) == -128); static_assert(sign_extend32(0u + 128, 8) == -128);
static_assert(sign_extend(0u - 1, 8) == -1); static_assert(sign_extend32(0u - 1, 8) == -1);
static_assert(sign_extend(0u + 256, 8) == 0); static_assert(sign_extend32(0u + 256, 8) == 0);
static_assert(sign_extend(0u + 257, 8) == 1); static_assert(sign_extend32(0u + 257, 8) == 1);
static_assert(sign_extend(0u + 383, 8) == 127); static_assert(sign_extend32(0u + 383, 8) == 127);
static_assert(sign_extend(0u + 384, 8) == -128); static_assert(sign_extend32(0u + 384, 8) == -128);
static_assert(sign_extend(0u + 511, 8) == -1); static_assert(sign_extend32(0u + 511, 8) == -1);
static_assert(sign_extend(upx_uint64_t(0) + 0, 1) == 0); static_assert(sign_extend64(upx_uint64_t(0) + 0, 1) == 0);
static_assert(sign_extend(upx_uint64_t(0) + 1, 1) == -1); static_assert(sign_extend64(upx_uint64_t(0) + 1, 1) == -1);
static_assert(CHAR_BIT == 8); static_assert(CHAR_BIT == 8);
#if 0 // does not work with MSVC #if 0 // does not work with MSVC
@@ -1101,14 +1101,14 @@ void upx_compiler_sanity_check(void) noexcept {
assert_noexcept(TestBELE<BE32>::test()); assert_noexcept(TestBELE<BE32>::test());
assert_noexcept(TestBELE<BE64>::test()); assert_noexcept(TestBELE<BE64>::test());
{ {
alignas(16) static constexpr byte dd[32] = { alignas(16) static constexpr const byte dd[32] = {
0, 0, 0, 0, 0, 0, 0, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, 0,
0, 0, 0, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0, 0, 0, 0, 0}; 0, 0, 0, 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0, 0, 0, 0, 0};
constexpr const byte *d = dd + 7;
#if !defined(upx_fake_alignas_16) #if !defined(upx_fake_alignas_16)
assert_noexcept(ptr_is_aligned<16>(dd)); assert_noexcept(ptr_is_aligned<16>(dd));
assert_noexcept(ptr_is_aligned(dd, 16)); assert_noexcept(ptr_is_aligned(dd, 16));
#endif #endif
constexpr const byte *d = dd + 7;
static_assert(upx::compile_time::get_be16(d) == 0xfffe); static_assert(upx::compile_time::get_be16(d) == 0xfffe);
static_assert(upx::compile_time::get_be24(d) == 0xfffefd); static_assert(upx::compile_time::get_be24(d) == 0xfffefd);
static_assert(upx::compile_time::get_be32(d) == 0xfffefdfc); static_assert(upx::compile_time::get_be32(d) == 0xfffefdfc);
@@ -1117,10 +1117,10 @@ void upx_compiler_sanity_check(void) noexcept {
static_assert(upx::compile_time::get_le24(d) == 0xfdfeff); static_assert(upx::compile_time::get_le24(d) == 0xfdfeff);
static_assert(upx::compile_time::get_le32(d) == 0xfcfdfeff); static_assert(upx::compile_time::get_le32(d) == 0xfcfdfeff);
static_assert(upx::compile_time::get_le64(d) == 0xf8f9fafbfcfdfeffULL); static_assert(upx::compile_time::get_le64(d) == 0xf8f9fafbfcfdfeffULL);
const N_BELE_RTP::AbstractPolicy *bele;
assert_noexcept(upx_adler32(d, 4) == 0x09f003f7); assert_noexcept(upx_adler32(d, 4) == 0x09f003f7);
assert_noexcept(upx_adler32(d, 4, 0) == 0x09ec03f6); assert_noexcept(upx_adler32(d, 4, 0) == 0x09ec03f6);
assert_noexcept(upx_adler32(d, 4, 1) == 0x09f003f7); assert_noexcept(upx_adler32(d, 4, 1) == 0x09f003f7);
const N_BELE_RTP::AbstractPolicy *bele;
bele = &N_BELE_RTP::be_policy; bele = &N_BELE_RTP::be_policy;
assert_noexcept(get_be16(d) == 0xfffe); assert_noexcept(get_be16(d) == 0xfffe);
assert_noexcept(bele->get16(d) == 0xfffe); assert_noexcept(bele->get16(d) == 0xfffe);
@@ -1212,29 +1212,33 @@ void upx_compiler_sanity_check(void) noexcept {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
{ {
const unsigned u = i; const unsigned u = i;
assert_noexcept(sign_extend(u, 1) == ((i & 1) ? -1 : 0)); assert_noexcept(sign_extend32(u, 1) == ((i & 1) ? -1 : 0));
assert_noexcept(sign_extend(u, 2) == ((i & 2) ? -2 + (i & 1) : (i & 1))); assert_noexcept(sign_extend32(u, 2) == ((i & 2) ? -2 + (i & 1) : (i & 1)));
assert_noexcept(sign_extend(u, 3) == ((i & 4) ? -4 + (i & 3) : (i & 3))); assert_noexcept(sign_extend32(u, 3) == ((i & 4) ? -4 + (i & 3) : (i & 3)));
assert_noexcept(sign_extend(u, 4) == ((i & 8) ? -8 + (i & 7) : (i & 7))); assert_noexcept(sign_extend32(u, 4) == ((i & 8) ? -8 + (i & 7) : (i & 7)));
assert_noexcept(sign_extend(u, 5) == ((i & 16) ? -16 + (i & 15) : (i & 15))); assert_noexcept(sign_extend32(u, 5) == ((i & 16) ? -16 + (i & 15) : (i & 15)));
assert_noexcept(sign_extend(u, 6) == ((i & 32) ? -32 + (i & 31) : (i & 31))); assert_noexcept(sign_extend32(u, 6) == ((i & 32) ? -32 + (i & 31) : (i & 31)));
assert_noexcept(sign_extend(u, 7) == ((i & 64) ? -64 + (i & 63) : (i & 63))); assert_noexcept(sign_extend32(u, 7) == ((i & 64) ? -64 + (i & 63) : (i & 63)));
assert_noexcept(sign_extend(u, 8) == ((i & 128) ? -128 + (i & 127) : (i & 127))); assert_noexcept(sign_extend32(u, 8) == ((i & 128) ? -128 + (i & 127) : (i & 127)));
assert_noexcept(sign_extend(u, 32) == i); assert_noexcept(sign_extend32(u, 9) == i);
assert_noexcept(sign_extend(0u - u, 32) == -i); assert_noexcept(sign_extend32(u, 32) == i);
assert_noexcept(sign_extend32(0u - u, 32) == -i);
} }
{ {
const upx_uint64_t u = i; const upx_uint64_t u = i;
assert_noexcept(sign_extend(u, 1) == ((i & 1) ? -1 : 0)); assert_noexcept(sign_extend64(u, 1) == ((i & 1) ? -1 : 0));
assert_noexcept(sign_extend(u, 2) == ((i & 2) ? -2 + (i & 1) : (i & 1))); assert_noexcept(sign_extend64(u, 2) == ((i & 2) ? -2 + (i & 1) : (i & 1)));
assert_noexcept(sign_extend(u, 3) == ((i & 4) ? -4 + (i & 3) : (i & 3))); assert_noexcept(sign_extend64(u, 3) == ((i & 4) ? -4 + (i & 3) : (i & 3)));
assert_noexcept(sign_extend(u, 4) == ((i & 8) ? -8 + (i & 7) : (i & 7))); assert_noexcept(sign_extend64(u, 4) == ((i & 8) ? -8 + (i & 7) : (i & 7)));
assert_noexcept(sign_extend(u, 5) == ((i & 16) ? -16 + (i & 15) : (i & 15))); assert_noexcept(sign_extend64(u, 5) == ((i & 16) ? -16 + (i & 15) : (i & 15)));
assert_noexcept(sign_extend(u, 6) == ((i & 32) ? -32 + (i & 31) : (i & 31))); assert_noexcept(sign_extend64(u, 6) == ((i & 32) ? -32 + (i & 31) : (i & 31)));
assert_noexcept(sign_extend(u, 7) == ((i & 64) ? -64 + (i & 63) : (i & 63))); assert_noexcept(sign_extend64(u, 7) == ((i & 64) ? -64 + (i & 63) : (i & 63)));
assert_noexcept(sign_extend(u, 8) == ((i & 128) ? -128 + (i & 127) : (i & 127))); assert_noexcept(sign_extend64(u, 8) == ((i & 128) ? -128 + (i & 127) : (i & 127)));
assert_noexcept(sign_extend(u, 64) == i); assert_noexcept(sign_extend64(u, 9) == i);
assert_noexcept(sign_extend(upx_uint64_t(0) - u, 64) == -i); assert_noexcept(sign_extend64(u, 32) == i);
assert_noexcept(sign_extend64(upx_uint64_t(0) - u, 32) == -i);
assert_noexcept(sign_extend64(u, 64) == i);
assert_noexcept(sign_extend64(upx_uint64_t(0) - u, 64) == -i);
} }
} }
} }
@@ -1288,6 +1292,9 @@ void upx_compiler_sanity_check(void) noexcept {
assert_noexcept(testNoAliasing(&u.v_int, &u.v_llong)); assert_noexcept(testNoAliasing(&u.v_int, &u.v_llong));
assert_noexcept(testNoAliasing(&u.v_long, &u.v_llong)); assert_noexcept(testNoAliasing(&u.v_long, &u.v_llong));
#if 1 && (ACC_CC_MSC) && (defined(_M_ARM64) || defined(_M_ARM64EC))
// @COMPILER_BUG @MSVC_BUG
#else
assert_noexcept(TestIntegerWrap<unsigned>::inc_gt(0)); assert_noexcept(TestIntegerWrap<unsigned>::inc_gt(0));
assert_noexcept(!TestIntegerWrap<unsigned>::inc_gt(UINT_MAX)); assert_noexcept(!TestIntegerWrap<unsigned>::inc_gt(UINT_MAX));
assert_noexcept(TestIntegerWrap<unsigned>::dec_lt(1)); assert_noexcept(TestIntegerWrap<unsigned>::dec_lt(1));
@@ -1304,6 +1311,7 @@ void upx_compiler_sanity_check(void) noexcept {
assert_noexcept(!TestIntegerWrap<int>::neg_eq(1)); assert_noexcept(!TestIntegerWrap<int>::neg_eq(1));
assert_noexcept(!TestIntegerWrap<int>::neg_eq(INT_MAX)); assert_noexcept(!TestIntegerWrap<int>::neg_eq(INT_MAX));
assert_noexcept(TestIntegerWrap<int>::neg_eq(INT_MIN)); // special case assert_noexcept(TestIntegerWrap<int>::neg_eq(INT_MIN)); // special case
#endif
} }
/************************************************************************* /*************************************************************************
@@ -1459,7 +1467,8 @@ TEST_CASE("libc qsort") {
return true; return true;
} }
}; };
constexpr size_t N = 4096;
constexpr size_t N = 256;
Elem e[N]; Elem e[N];
for (size_t n = 0; n <= N; n = 2 * n + 1) { for (size_t n = 0; n <= N; n = 2 * n + 1) {
// system sort functions // system sort functions
+7 -5
View File
@@ -558,7 +558,8 @@ TEST_CASE("upx::ObjectDeleter 1") {
LE32 *a = nullptr; // array LE32 *a = nullptr; // array
LE64 *m = nullptr; // malloc LE64 *m = nullptr; // malloc
{ {
auto o_deleter = upx::ObjectDeleter(&o, 1); // auto o_deleter = upx::ObjectDeleter(&o, 1);
upx::ObjectDeleter<LE16> o_deleter = upx::ObjectDeleter(&o, 1);
o = new LE16; o = new LE16;
assert(o != nullptr); assert(o != nullptr);
auto a_deleter = upx::ArrayDeleter(&a, 1); auto a_deleter = upx::ArrayDeleter(&a, 1);
@@ -594,7 +595,8 @@ TEST_CASE("upx::ObjectDeleter 2") {
BE32 *a[N]; // multiple arrays BE32 *a[N]; // multiple arrays
BE64 *m[N]; // multiple mallocs BE64 *m[N]; // multiple mallocs
{ {
auto o_deleter = upx::ObjectDeleter(o, 0); // auto o_deleter = upx::ObjectDeleter(o, 0);
upx::ObjectDeleter<BE16> o_deleter = upx::ObjectDeleter(o, 0);
auto a_deleter = upx::ArrayDeleter(a, 0); auto a_deleter = upx::ArrayDeleter(a, 0);
auto m_deleter = upx::MallocDeleter(m, 0); auto m_deleter = upx::MallocDeleter(m, 0);
for (size_t i = 0; i < N; i++) { for (size_t i = 0; i < N; i++) {
@@ -768,7 +770,7 @@ static_assert(sizeof(TestCT) == 8);
static_assert(alignof(TestCT) == 1); static_assert(alignof(TestCT) == 1);
} // namespace } // namespace
TEST_CASE("upx::compile_time") { TEST_CASE("upx::compile_time 1") {
constexpr upx_uint16_t v16 = 0x0201; constexpr upx_uint16_t v16 = 0x0201;
constexpr upx_uint32_t v24 = 0x030201; constexpr upx_uint32_t v24 = 0x030201;
constexpr upx_uint32_t v32 = 0x04030201; constexpr upx_uint32_t v32 = 0x04030201;
@@ -865,7 +867,7 @@ TEST_CASE("upx::compile_time") {
constexpr auto le64 = TestCT::makeLE64(v64); constexpr auto le64 = TestCT::makeLE64(v64);
static_assert(upx::compile_time::get_le64(le64.d) == 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)); static_assert(mem_eq(le64.d, "\x01\x02\x03\x04\x05\x06\x07\x08", 8));
memset(buf, 0, 8); upx::compile_time::mem_clear(buf, 8);
TestCT::noinline_set_le64(buf, v64); TestCT::noinline_set_le64(buf, v64);
assert_noexcept(TestCT::noinline_get_le64(buf) == v64); assert_noexcept(TestCT::noinline_get_le64(buf) == v64);
assert_noexcept(upx::compile_time::get_le64(buf) == v64); assert_noexcept(upx::compile_time::get_le64(buf) == v64);
@@ -886,7 +888,7 @@ TEST_CASE("upx::compile_time") {
} }
} }
TEST_CASE("upx::compile_time") { TEST_CASE("upx::compile_time 2") {
constexpr upx_uint16_t v16 = 0xf2f1; constexpr upx_uint16_t v16 = 0xf2f1;
constexpr upx_uint32_t v24 = 0xf3f2f1; constexpr upx_uint32_t v24 = 0xf3f2f1;
constexpr upx_uint32_t v32 = 0xf4f3f2f1; constexpr upx_uint32_t v32 = 0xf4f3f2f1;
+2
View File
@@ -68,7 +68,9 @@
#endif #endif
#endif #endif
// NOLINTBEGIN(bugprone-unintended-char-ostream-output)
#include <doctest/doctest/parts/doctest.cpp> #include <doctest/doctest/parts/doctest.cpp>
// NOLINTEND(bugprone-unintended-char-ostream-output)
#endif // DOCTEST_CONFIG_DISABLE #endif // DOCTEST_CONFIG_DISABLE
+189 -6
View File
@@ -101,9 +101,6 @@ TEST_CASE("basic xspan usage") {
CHECK(b0.raw_size_in_bytes() == 0u); CHECK(b0.raw_size_in_bytes() == 0u);
CHECK(bp.raw_size_in_bytes() == 0u); CHECK(bp.raw_size_in_bytes() == 0u);
#endif #endif
CHECK(raw_bytes(b0, 999999) == buf);
CHECK(raw_bytes(bp, 999999) == buf);
CHECK(raw_bytes(c0, 4) == buf); CHECK(raw_bytes(c0, 4) == buf);
CHECK(raw_index_bytes(c0, 1, 3) == buf + 1); CHECK(raw_index_bytes(c0, 1, 3) == buf + 1);
CHECK(raw_bytes(cp, 4) == buf); CHECK(raw_bytes(cp, 4) == buf);
@@ -180,9 +177,6 @@ TEST_CASE("basic xspan usage") {
CHECK(b0.raw_size_in_bytes() == 0u); CHECK(b0.raw_size_in_bytes() == 0u);
CHECK(bp.raw_size_in_bytes() == 0u); CHECK(bp.raw_size_in_bytes() == 0u);
#endif #endif
CHECK(raw_bytes(b0, 999999) == buf);
CHECK(raw_bytes(bp, 999999) == buf);
CHECK(raw_bytes(c0, 4) == buf); CHECK(raw_bytes(c0, 4) == buf);
CHECK(raw_index_bytes(c0, 1, 3) == buf + 1); CHECK(raw_index_bytes(c0, 1, 3) == buf + 1);
CHECK(raw_bytes(cp, 4) == buf); CHECK(raw_bytes(cp, 4) == buf);
@@ -876,6 +870,195 @@ TEST_CASE("PtrOrSpan int") {
CHECK(a == buf + 8); CHECK(a == buf + 8);
} }
/*************************************************************************
//
**************************************************************************/
#ifdef UPX_VERSION_HEX
namespace {
template <class T>
static noinline void check_bele_a(const T &mb, size_t i) {
if (i < 2) {
CHECK_THROWS(get_ne16(mb));
CHECK_THROWS(get_be16(mb));
CHECK_THROWS(get_le16(mb));
CHECK_THROWS(set_ne16(mb, 0));
CHECK_THROWS(set_be16(mb, 0));
CHECK_THROWS(set_le16(mb, 0));
} else {
CHECK_NOTHROW(get_ne16(mb));
CHECK_NOTHROW(get_be16(mb));
CHECK_NOTHROW(get_le16(mb));
CHECK_NOTHROW(set_ne16(mb, 0));
CHECK_NOTHROW(set_be16(mb, 0));
CHECK_NOTHROW(set_le16(mb, 0));
}
if (i < 3) {
CHECK_THROWS(get_ne24(mb));
CHECK_THROWS(get_be24(mb));
CHECK_THROWS(get_le24(mb));
CHECK_THROWS(set_ne24(mb, 0));
CHECK_THROWS(set_be24(mb, 0));
CHECK_THROWS(set_le24(mb, 0));
} else {
CHECK_NOTHROW(get_ne24(mb));
CHECK_NOTHROW(get_be24(mb));
CHECK_NOTHROW(get_le24(mb));
CHECK_NOTHROW(set_ne24(mb, 0));
CHECK_NOTHROW(set_be24(mb, 0));
CHECK_NOTHROW(set_le24(mb, 0));
}
if (i < 4) {
CHECK_THROWS(get_ne32(mb));
CHECK_THROWS(get_be32(mb));
CHECK_THROWS(get_le32(mb));
CHECK_THROWS(set_ne32(mb, 0));
CHECK_THROWS(set_be32(mb, 0));
CHECK_THROWS(set_le32(mb, 0));
} else {
CHECK_NOTHROW(get_ne32(mb));
CHECK_NOTHROW(get_be32(mb));
CHECK_NOTHROW(get_le32(mb));
CHECK_NOTHROW(set_ne32(mb, 0));
CHECK_NOTHROW(set_be32(mb, 0));
CHECK_NOTHROW(set_le32(mb, 0));
}
if (i < 8) {
CHECK_THROWS(get_ne64(mb));
CHECK_THROWS(get_be64(mb));
CHECK_THROWS(get_le64(mb));
CHECK_THROWS(set_ne64(mb, 0));
CHECK_THROWS(set_be64(mb, 0));
CHECK_THROWS(set_le64(mb, 0));
} else {
CHECK_NOTHROW(get_ne64(mb));
CHECK_NOTHROW(get_be64(mb));
CHECK_NOTHROW(get_le64(mb));
CHECK_NOTHROW(set_ne64(mb, 0));
CHECK_NOTHROW(set_be64(mb, 0));
CHECK_NOTHROW(set_le64(mb, 0));
}
}
template <class T>
static noinline void check_bele_c(const T &mb, size_t i) {
if (i < 2) {
CHECK_THROWS(get_ne16(mb));
CHECK_THROWS(get_be16(mb));
CHECK_THROWS(get_le16(mb));
} else {
CHECK_NOTHROW(get_ne16(mb));
CHECK_NOTHROW(get_be16(mb));
CHECK_NOTHROW(get_le16(mb));
}
if (i < 3) {
CHECK_THROWS(get_ne24(mb));
CHECK_THROWS(get_be24(mb));
CHECK_THROWS(get_le24(mb));
} else {
CHECK_NOTHROW(get_ne24(mb));
CHECK_NOTHROW(get_be24(mb));
CHECK_NOTHROW(get_le24(mb));
}
if (i < 4) {
CHECK_THROWS(get_ne32(mb));
CHECK_THROWS(get_be32(mb));
CHECK_THROWS(get_le32(mb));
} else {
CHECK_NOTHROW(get_ne32(mb));
CHECK_NOTHROW(get_be32(mb));
CHECK_NOTHROW(get_le32(mb));
}
if (i < 8) {
CHECK_THROWS(get_ne64(mb));
CHECK_THROWS(get_be64(mb));
CHECK_THROWS(get_le64(mb));
} else {
CHECK_NOTHROW(get_ne64(mb));
CHECK_NOTHROW(get_be64(mb));
CHECK_NOTHROW(get_le64(mb));
}
}
} // namespace
#endif // UPX_VERSION_HEX
TEST_CASE("xspan global overloads") {
byte buf_a[16] = {};
const byte buf_c[16] = {};
for (size_t i = 0; i < 16; i++) {
XSPAN_0_VAR(byte, a0, buf_a, i);
XSPAN_P_VAR(byte, ap, buf_a, i);
XSPAN_S_VAR(byte, as, buf_a, i);
XSPAN_0_VAR(const byte, c0, buf_c, i);
XSPAN_P_VAR(const byte, cp, buf_c, i);
XSPAN_S_VAR(const byte, cs, buf_c, i);
#ifdef UPX_VERSION_HEX
check_bele_a(a0, i);
check_bele_a(ap, i);
check_bele_a(as, i);
check_bele_c(c0, i);
check_bele_c(cp, i);
check_bele_c(cs, i);
CHECK_THROWS(upx_adler32(a0, i + 1));
CHECK_THROWS(upx_adler32(ap, i + 1));
CHECK_THROWS(upx_adler32(as, i + 1));
CHECK_THROWS(upx_adler32(c0, i + 1));
CHECK_THROWS(upx_adler32(cp, i + 1));
CHECK_THROWS(upx_adler32(cs, i + 1));
if (i == 0) {
CHECK_THROWS(upx_safe_strlen(a0));
CHECK_THROWS(upx_safe_strlen(ap));
CHECK_THROWS(upx_safe_strlen(as));
CHECK_THROWS(upx_safe_strlen(c0));
CHECK_THROWS(upx_safe_strlen(cp));
CHECK_THROWS(upx_safe_strlen(cs));
}
#endif
CHECK_THROWS(memchr(a0, 0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memchr(ap, 0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memchr(as, 0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memchr(c0, 0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memchr(cp, 0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memchr(cs, 0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK(memcmp(a0, a0, i) == 0);
CHECK(memcmp(ap, a0, i) == 0);
CHECK(memcmp(as, a0, i) == 0);
CHECK_THROWS(memcmp(a0, a0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memcmp(ap, a0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memcmp(as, a0, i + 1)); // NOLINT(bugprone-unused-return-value)
CHECK_NOTHROW(memcpy(a0, c0, i));
CHECK_NOTHROW(memcpy(ap, cp, i));
CHECK_NOTHROW(memcpy(as, cs, i));
CHECK_THROWS(memcpy(a0, c0, i + 1));
CHECK_THROWS(memcpy(ap, cp, i + 1));
CHECK_THROWS(memcpy(as, cs, i + 1));
CHECK_NOTHROW(memmove(a0, c0, i));
CHECK_NOTHROW(memmove(ap, cp, i));
CHECK_NOTHROW(memmove(as, cs, i));
CHECK_THROWS(memmove(a0, c0, i + 1));
CHECK_THROWS(memmove(ap, cp, i + 1));
CHECK_THROWS(memmove(as, cs, i + 1));
CHECK_NOTHROW(memset(a0, 255, i));
CHECK_NOTHROW(memset(ap, 255, i));
CHECK_NOTHROW(memset(as, 255, i));
CHECK_THROWS(memset(a0, 254, i + 1));
CHECK_THROWS(memset(ap, 254, i + 1));
CHECK_THROWS(memset(as, 254, i + 1));
}
}
/************************************************************************* /*************************************************************************
// codegen // codegen
**************************************************************************/ **************************************************************************/
+3 -2
View File
@@ -248,8 +248,9 @@ 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) #if 1 && (ACC_CC_MSC && ACC_ARCH_I386) && (_MSC_VER >= 1940)
(void) ucl_init(); // TODO later // @COMPILER_BUG @MSVC_BUG
(void) ucl_init();
#else #else
if (ucl_init() != UCL_E_OK) if (ucl_init() != UCL_E_OK)
return -1; return -1;
+17 -11
View File
@@ -71,6 +71,10 @@ static_assert((-1) >> 31 == -1); // arithmetic right shift
static_assert(CHAR_MAX == 255); // -funsigned-char static_assert(CHAR_MAX == 255); // -funsigned-char
static_assert((char) (-1) == 255); // -funsigned-char 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)
@@ -96,6 +100,7 @@ static_assert((char) (-1) == 255); // -funsigned-char
#endif // UPX_CONFIG_DISABLE_WERROR #endif // UPX_CONFIG_DISABLE_WERROR
#endif // UPX_CONFIG_DISABLE_WSTRICT #endif // UPX_CONFIG_DISABLE_WSTRICT
// upx_is_constant_evaluated
#if __cplusplus >= 202002L // C++20 #if __cplusplus >= 202002L // C++20
#define upx_is_constant_evaluated std::is_constant_evaluated #define upx_is_constant_evaluated std::is_constant_evaluated
#elif __has_builtin(__builtin_is_constant_evaluated) // clang-9, gcc-10 #elif __has_builtin(__builtin_is_constant_evaluated) // clang-9, gcc-10
@@ -115,7 +120,7 @@ static_assert((char) (-1) == 255); // -funsigned-char
#define upx_std_atomic(Type) Type #define upx_std_atomic(Type) Type
#define upx_std_once_flag upx_std_atomic(size_t) #define upx_std_once_flag upx_std_atomic(size_t)
template <class NoexceptCallable> template <class NoexceptCallable>
inline void upx_std_call_once(upx_std_once_flag &flag, NoexceptCallable &&f) { inline void upx_std_call_once(upx_std_once_flag &flag, NoexceptCallable &&f) noexcept {
if (__acc_unlikely(!flag)) { if (__acc_unlikely(!flag)) {
flag = 1; flag = 1;
f(); f();
@@ -137,7 +142,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)
@@ -193,11 +198,7 @@ struct alignas(1) upx_charptr_unit_type final { char hidden__; };
static_assert(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...
#if (__SIZEOF_INT128__ == 16) && 0
typedef upx_int128_t upx_off_t;
#else
typedef long long upx_off_t; typedef long long upx_off_t;
#endif
#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:
@@ -230,7 +231,7 @@ typedef long long 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)
@@ -376,6 +377,7 @@ 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 attribute_format(2, 3);
inline void NO_fprintf(FILE *, const char *, ...) noexcept {} inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
// upx_memcmp_inline
#if __has_builtin(__builtin_memcmp) #if __has_builtin(__builtin_memcmp)
#define upx_memcmp_inline __builtin_memcmp #define upx_memcmp_inline __builtin_memcmp
#elif defined(__clang__) || defined(__GNUC__) #elif defined(__clang__) || defined(__GNUC__)
@@ -383,6 +385,8 @@ inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
#else #else
#define upx_memcmp_inline memcmp #define upx_memcmp_inline memcmp
#endif #endif
// upx_memcpy_inline
#if __has_builtin(__builtin_memcpy_inline) && 0 // TODO later: clang constexpr limitation? #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)
@@ -393,6 +397,7 @@ inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
#define upx_memcpy_inline memcpy #define upx_memcpy_inline memcpy
#endif #endif
// upx_return_address()
#if defined(__wasi__) #if defined(__wasi__)
#define upx_return_address() nullptr #define upx_return_address() nullptr
#elif __has_builtin(__builtin_return_address) #elif __has_builtin(__builtin_return_address)
@@ -802,14 +807,15 @@ int upx_doctest_check();
// util/membuffer.h // util/membuffer.h
class MemBuffer; class MemBuffer;
void *membuffer_get_void_ptr(MemBuffer &mb) noexcept; void *membuffer_get_void_ptr(MemBuffer &mb) noexcept;
unsigned membuffer_get_size(MemBuffer &mb) noexcept; const void *membuffer_get_void_ptr(const MemBuffer &mb) noexcept;
unsigned membuffer_get_size_in_bytes(const MemBuffer &mb) noexcept;
// main.cpp // main.cpp
extern const char *progname; extern const char *progname;
bool main_set_exit_code(int ec); bool main_set_exit_code(int ec);
int main_get_options(int argc, char **argv); int main_get_options(int argc, char **argv);
void main_get_envoptions(); void main_get_envoptions();
int upx_main(int argc, char *argv[]) may_throw; noinline int upx_main(int argc, char *argv[]) may_throw;
// msg.cpp // msg.cpp
void printSetNl(int need_nl) noexcept; void printSetNl(int need_nl) noexcept;
@@ -826,8 +832,8 @@ void infoHeader();
void infoWriting(const char *what, upx_int64_t size); void infoWriting(const char *what, upx_int64_t size);
// work.cpp // work.cpp
void do_one_file(const char *iname, char *oname) may_throw; noinline void do_one_file(const char *iname, char *oname) may_throw;
int do_files(int i, int argc, char *argv[]) may_throw; noinline int do_files(int i, int argc, char *argv[]) may_throw;
// help.cpp // help.cpp
extern const char gitrev[]; extern const char gitrev[];
+4 -4
View File
@@ -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: */
+4 -3
View File
@@ -49,7 +49,7 @@ const char gitrev[] = UPX_VERSION_GITREV;
const char gitrev[1] = {0}; const char gitrev[1] = {0};
#endif #endif
void show_header(void) { void show_header() {
FILE *f = con_term; FILE *f = con_term;
int fg; int fg;
@@ -85,7 +85,7 @@ void show_header(void) {
// usage // usage
**************************************************************************/ **************************************************************************/
void show_usage(void) { void show_usage() {
FILE *f = con_term; FILE *f = con_term;
con_fprintf(f, "Usage: %s [-123456789dlthVL] [-qvfk] [-o file] %sfile..\n", progname, con_fprintf(f, "Usage: %s [-123456789dlthVL] [-qvfk] [-o file] %sfile..\n", progname,
@@ -342,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
@@ -380,7 +381,7 @@ void show_help(int verbose) {
// license // license
**************************************************************************/ **************************************************************************/
void show_license(void) { void show_license() {
FILE *f = con_term; FILE *f = con_term;
show_header(); show_header();
+2 -1
View File
@@ -367,6 +367,8 @@ int ElfLinker::addLoader(const char *sname) {
return outputlen; return outputlen;
char *begin = strdup(sname); char *begin = strdup(sname);
assert(begin != nullptr);
const auto begin_deleter = upx::MallocDeleter(&begin, 1); // don't leak memory
char *end = begin + strlen(begin); char *end = begin + strlen(begin);
for (char *sect = begin; sect < end;) { for (char *sect = begin; sect < end;) {
for (char *tokend = sect; *tokend; tokend++) for (char *tokend = sect; *tokend; tokend++)
@@ -418,7 +420,6 @@ int ElfLinker::addLoader(const char *sname) {
} }
sect += strlen(sect) + 1; sect += strlen(sect) + 1;
} }
::free(begin);
return outputlen; return outputlen;
} }
+1 -1
View File
@@ -35,7 +35,7 @@ class ElfLinker /*not_final*/ : private upx::noncopyable {
friend class Packer; friend class Packer;
public: public:
const N_BELE_RTP::AbstractPolicy *const bele; // target endianness const N_BELE_RTP::AbstractPolicy *const bele; // TE - Target Endianness
protected: protected:
struct Section; struct Section;
struct Symbol; struct Symbol;
+8 -7
View File
@@ -67,12 +67,9 @@ static void handle_opterr(acc_getopt_p g, const char *f, void *v) {
static int exit_code = EXIT_OK; static int exit_code = EXIT_OK;
#if (WITH_GUI) #if (WITH_GUI)
static noinline void do_exit(void) { throw exit_code; } static noreturn void do_exit() { throw exit_code; }
#else #else
#if defined(__GNUC__) static noreturn void do_exit() {
static void do_exit(void) __attribute__((__noreturn__));
#endif
static void do_exit(void) {
static bool in_exit = false; static bool in_exit = false;
if (in_exit) if (in_exit)
@@ -115,7 +112,7 @@ static noinline void e_exit(int ec) {
do_exit(); do_exit();
} }
static noinline void e_usage(void) { static noinline void e_usage() {
if (opt->debug.getopt_throw_instead_of_exit) if (opt->debug.getopt_throw_instead_of_exit)
throw EXIT_USAGE; throw EXIT_USAGE;
show_usage(); show_usage();
@@ -217,7 +214,7 @@ static void check_and_update_options(int i, int argc) {
// misc // misc
**************************************************************************/ **************************************************************************/
static void e_help(void) { static void e_help() {
show_help(0); show_help(0);
e_exit(EXIT_USAGE); e_exit(EXIT_USAGE);
} }
@@ -742,6 +739,9 @@ static int do_option(int optc, const char *arg) {
case 678: case 678:
opt->o_unix.android_old = true; opt->o_unix.android_old = true;
break; 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;
@@ -957,6 +957,7 @@ int main_get_options(int argc, char **argv) {
{"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}, {"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},
+1
View File
@@ -162,6 +162,7 @@ struct Options final {
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 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;
+3 -1
View File
@@ -108,7 +108,8 @@ class Dummy {
/* Register usage information. */ // /* Register usage information. */ //
// PT_MIPS_RTPROC = 0x70000001, /* Runtime procedure table. */ // PT_MIPS_RTPROC = 0x70000001, /* Runtime procedure table. */
// PT_MIPS_OPTIONS = 0x70000002, // PT_MIPS_OPTIONS = 0x70000002,
PT_MIPS_ABIFLAGS = 0x70000003, /* FP mode requirement. */ PT_ARM_EXIDX = (0x70000000 + 1), /* ARM unwind segment. */
PT_MIPS_ABIFLAGS = 0x70000003, /* FP mode requirement. */
}; };
enum { // p_flags enum { // p_flags
@@ -148,6 +149,7 @@ class Dummy {
SHT_LOOS = 0x60000000, /* LOcal OS; SHT_ANDROID_REL{,A} is +1, +2 */ SHT_LOOS = 0x60000000, /* LOcal OS; SHT_ANDROID_REL{,A} is +1, +2 */
SHT_LOPROC = 0x70000000, /* Start of processor-specific */ SHT_LOPROC = 0x70000000, /* Start of processor-specific */
SHT_ARM_EXIDX = (SHT_LOPROC + 1), /* ARM unwind section. */
SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3), /* ARM attributes section. */ SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3), /* ARM attributes section. */
}; };
+114 -74
View File
@@ -487,17 +487,17 @@ PackLinuxElf32::slide_sh_offset(Elf32_Shdr *shdr)
{ {
unsigned sh_offset = get_te32(&shdr->sh_offset); unsigned sh_offset = get_te32(&shdr->sh_offset);
unsigned sh_addr = get_te32(&shdr->sh_addr); unsigned sh_addr = get_te32(&shdr->sh_addr);
char const *sh_name = get_te32(&shdr->sh_name) + shstrtab;
(void)sh_name; // convenience for debug
if (Elf32_Shdr::SHF_WRITE & get_te32(&shdr->sh_flags) if (Elf32_Shdr::SHF_WRITE & get_te32(&shdr->sh_flags)
|| (sh_offset && !sh_addr)) || (sh_offset && !sh_addr))
{ {
unsigned newoff = so_slide + sh_offset + (is_asl ? asl_delta : 0); unsigned newoff = so_slide + sh_offset + (is_asl ? asl_delta : 0);
if ((unsigned)this->file_size < newoff) { if (sh_addr // only check "real memory"
&& (unsigned)this->file_size < newoff) {
throwInternalError("bad slide %p %#x", shdr, (unsigned)so_slide); throwInternalError("bad slide %p %#x", shdr, (unsigned)so_slide);
} }
set_te32(&shdr->sh_offset, newoff); set_te32(&shdr->sh_offset, newoff);
if (sh_addr) // change only if non-zero
set_te32(&shdr->sh_addr,
so_slide + sh_addr + (is_asl ? asl_delta : 0));
return newoff; return newoff;
} }
return sh_offset; return sh_offset;
@@ -520,17 +520,17 @@ PackLinuxElf64::slide_sh_offset(Elf64_Shdr *shdr)
{ {
unsigned sh_offset = get_te64(&shdr->sh_offset); unsigned sh_offset = get_te64(&shdr->sh_offset);
unsigned sh_addr = get_te64(&shdr->sh_addr); unsigned sh_addr = get_te64(&shdr->sh_addr);
char const *sh_name = get_te32(&shdr->sh_name) + shstrtab;
(void)sh_name; // convenience for debug
if (Elf64_Shdr::SHF_WRITE & get_te64(&shdr->sh_flags) if (Elf64_Shdr::SHF_WRITE & get_te64(&shdr->sh_flags)
|| (sh_offset && !sh_addr)) || (sh_offset && !sh_addr))
{ {
unsigned newoff = so_slide + sh_offset + (is_asl ? asl_delta : 0); unsigned newoff = so_slide + sh_offset + (is_asl ? asl_delta : 0);
if ((unsigned)this->file_size < newoff) { if (sh_addr // only check "real memory"
&& (unsigned)this->file_size < newoff) {
throwInternalError("bad slide %p %#x", shdr, (unsigned)so_slide); throwInternalError("bad slide %p %#x", shdr, (unsigned)so_slide);
} }
set_te64(&shdr->sh_offset, newoff); set_te64(&shdr->sh_offset, newoff);
if (sh_addr) // change only if non-zero
set_te64(&shdr->sh_addr,
so_slide + sh_addr + (is_asl ? asl_delta : 0));
return newoff; return newoff;
} }
return sh_offset; return sh_offset;
@@ -641,25 +641,18 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
Elf32_Phdr *const phdr0 = (Elf32_Phdr *)lowmem.subref( Elf32_Phdr *const phdr0 = (Elf32_Phdr *)lowmem.subref(
"bad e_phoff", e_phoff, e_phnum * sizeof(Elf32_Phdr)); "bad e_phoff", e_phoff, e_phnum * sizeof(Elf32_Phdr));
Elf32_Phdr *phdr = phdr0; Elf32_Phdr *phdr = phdr0, *outp = phdr0;
upx_off_t off = fo->st_size(); // 64 bits upx_off_t off = fo->st_size(); // 64 bits
so_slide = 0; so_slide = 0;
for (unsigned j = 0; j < e_phnum; ++j, ++phdr) { for (unsigned j = 0; j < e_phnum; ++j, ++phdr) {
// p_vaddr and p_paddr do not change! // p_vaddr and p_paddr do not change!
unsigned const len = get_te32(&phdr->p_filesz);
unsigned const ioff = get_te32(&phdri[j].p_offset); // without asl_delta unsigned const ioff = get_te32(&phdri[j].p_offset); // without asl_delta
unsigned align= get_te32(&phdr->p_align); unsigned align= get_te32(&phdr->p_align);
unsigned const type = get_te32(&phdr->p_type); unsigned const type = get_te32(&phdr->p_type);
if (Elf32_Phdr::PT_INTERP==type) { unsigned const len = get_te32(&phdr->p_filesz);
// Rotate to highest position, so it can be lopped if (Elf32_Phdr::PT_INTERP==type
// by decrementing e_phnum. || Elf32_Phdr::PT_ARM_EXIDX==type) {
memcpy((unsigned char *)ibuf, phdr, sizeof(*phdr)); // extract /* OMIT */ continue; // OMIT: reference to compressed data
memmove(phdr, 1+phdr, (e_phnum - (1+ j))*sizeof(*phdr)); // overlapping
memcpy(&phdr[e_phnum - (1+ j)], (unsigned char *)ibuf, sizeof(*phdr)); // to top
--phdr; --e_phnum;
set_te16(&ehdri.e_phnum, e_phnum);
set_te16(&((Elf32_Ehdr *)(unsigned char *)lowmem)->e_phnum, e_phnum);
continue;
} }
if (PT_LOAD == type) { if (PT_LOAD == type) {
if (!ioff) { // first PT_LOAD must contain everything written so far if (!ioff) { // first PT_LOAD must contain everything written so far
@@ -707,12 +700,21 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
fo->seek(0, SEEK_END); fo->seek(0, SEEK_END);
} }
} }
continue; // all done with this PT_LOAD
} }
if (xct_off < ioff) { else if (Elf32_Phdr::PT_DYNAMIC == type
set_te32(&phdr->p_offset, so_slide + (is_asl ? asl_delta : 0) + ioff); || Elf32_Phdr::PT_GNU_RELRO == type) {
unsigned delta = so_slide + (is_asl ? asl_delta : 0);
set_te32(&phdr->p_offset, delta + ioff);
// unsigned x = get_te32(&phdr->p_vaddr);
// set_te32(&phdr->p_vaddr, delta + x);
// unsigned y = get_te32(&phdr->p_paddr);
// set_te32(&phdr->p_paddr, delta + y);
} }
*outp++ = *phdr; // propagate
} // end each Phdr } // end each Phdr
e_phnum = outp - phdr0;
set_te16(&ehdri.e_phnum, e_phnum);
set_te16(&((Elf32_Ehdr *)(unsigned char *)lowmem)->e_phnum, e_phnum);
if (sec_arm_attr || is_asl) { // must update Shdr.sh_offset for so_slide if (sec_arm_attr || is_asl) { // must update Shdr.sh_offset for so_slide
Elf32_Shdr *shdr = shdri; Elf32_Shdr *shdr = shdri;
@@ -769,6 +771,7 @@ off_t PackLinuxElf32::pack3(OutputFile *fo, Filter &ft)
return total_out; return total_out;
} }
// NYI 2025-12-10: should be updated from the Elf32::pack3 version
off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft) off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
{ {
if (!overlay_offset) { if (!overlay_offset) {
@@ -835,7 +838,7 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
Elf64_Phdr *const phdr0 = (Elf64_Phdr *)lowmem.subref( Elf64_Phdr *const phdr0 = (Elf64_Phdr *)lowmem.subref(
"bad e_phoff", e_phoff, e_phnum * sizeof(Elf64_Phdr)); "bad e_phoff", e_phoff, e_phnum * sizeof(Elf64_Phdr));
Elf64_Phdr *phdr = phdr0; Elf64_Phdr *phdr = phdr0, *outp = phdr0;
upx_off_t off = fo->st_size(); // 64 bits upx_off_t off = fo->st_size(); // 64 bits
so_slide = 0; so_slide = 0;
for (unsigned j = 0; j < e_phnum; ++j, ++phdr) { for (unsigned j = 0; j < e_phnum; ++j, ++phdr) {
@@ -845,16 +848,9 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
u64_t align= get_te64(&phdr->p_align); u64_t align= get_te64(&phdr->p_align);
unsigned const type = get_te32(&phdr->p_type); unsigned const type = get_te32(&phdr->p_type);
if (Elf64_Phdr::PT_INTERP==type) { if (Elf64_Phdr::PT_INTERP==type) {
// Rotate to highest position, so it can be lopped continue; // OMIT
// by decrementing e_phnum.
memcpy((unsigned char *)ibuf, phdr, sizeof(*phdr)); // extract
memmove(phdr, 1+phdr, (e_phnum - (1+ j))*sizeof(*phdr)); // overlapping
memcpy(&phdr[e_phnum - (1+ j)], (unsigned char *)ibuf, sizeof(*phdr)); // to top
--phdr; --e_phnum;
set_te16(&ehdri.e_phnum, e_phnum);
set_te16(&((Elf64_Ehdr *)(unsigned char *)lowmem)->e_phnum, e_phnum);
continue;
} }
*outp++ = *phdr; // propagate
if (PT_LOAD == type) { if (PT_LOAD == type) {
if (!ioff) { // first PT_LOAD must contain everything written so far if (!ioff) { // first PT_LOAD must contain everything written so far
set_te64(&phdr->p_filesz, sz_pack2 + lsize); // is this correct? set_te64(&phdr->p_filesz, sz_pack2 + lsize); // is this correct?
@@ -903,6 +899,9 @@ off_t PackLinuxElf64::pack3(OutputFile *fo, Filter &ft)
set_te64(&phdr->p_offset, so_slide + (is_asl ? asl_delta : 0) + ioff); set_te64(&phdr->p_offset, so_slide + (is_asl ? asl_delta : 0) + ioff);
} }
} // end each Phdr } // end each Phdr
e_phnum = outp - phdr0;
set_te16(&ehdri.e_phnum, e_phnum);
set_te16(&((Elf64_Ehdr *)(unsigned char *)lowmem)->e_phnum, e_phnum);
if (sec_arm_attr || is_asl) { // must update Shdr.sh_offset for so_slide if (sec_arm_attr || is_asl) { // must update Shdr.sh_offset for so_slide
// Update {DYNAMIC}.sh_offset by so_slide. // Update {DYNAMIC}.sh_offset by so_slide.
@@ -1532,7 +1531,7 @@ PackLinuxElf32::buildLinuxLoader(
// EXP_TAIL FIXME: unfilter // EXP_TAIL FIXME: unfilter
// SO_TAIL // SO_TAIL
// SO_MAIN C-language supervision based on PT_LOADs // SO_MAIN C-language supervision based on PT_LOADs
char sec[120]; memset(sec, 0, sizeof(sec)); // debug convenience char sec[200]; memset(sec, 0, sizeof(sec)); // debug convenience
int len = 0; int len = 0;
unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method))); unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method)));
len += snprintf(sec, sizeof(sec), "%s", "SO_HEAD,ptr_NEXT,EXP_HEAD"); len += snprintf(sec, sizeof(sec), "%s", "SO_HEAD,ptr_NEXT,EXP_HEAD");
@@ -1584,7 +1583,7 @@ PackLinuxElf32::buildLinuxLoader(
|| this->e_machine==Elf32_Ehdr::EM_MIPS || this->e_machine==Elf32_Ehdr::EM_MIPS
) { // main program with ELF2 de-compressor (folded portion) ) { // main program with ELF2 de-compressor (folded portion)
initLoader(fold, szfold); initLoader(fold, szfold);
char sec[120]; memset(sec, 0, sizeof(sec)); // debug convenience char sec[200]; memset(sec, 0, sizeof(sec)); // debug convenience
int len = 0; int len = 0;
unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method))); unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method)));
len += snprintf(sec, sizeof(sec), "%s", ".text,EXP_HEAD"); len += snprintf(sec, sizeof(sec), "%s", ".text,EXP_HEAD");
@@ -1681,7 +1680,11 @@ PackLinuxElf32::buildLinuxLoader(
|| this->e_machine==Elf32_Ehdr::EM_MIPS || this->e_machine==Elf32_Ehdr::EM_MIPS
) { // main program with ELF2 de-compressor ) { // main program with ELF2 de-compressor
addLoader("ELFMAINX"); addLoader("ELFMAINX");
if (this->e_machine==Elf32_Ehdr::EM_ARM) { // hardware is more problematic
if (opt->o_unix.catch_sigsegv && hasLoaderSection("ELFSIGSEGV"))
addLoader("ELFSIGSEGV");
addLoader("ELFMAINX2");
}
// Only if $ARCH-linux.elf-entry.S calls upx_mmap_and_fd instead of memfd_create // Only if $ARCH-linux.elf-entry.S calls upx_mmap_and_fd instead of memfd_create
if (this->e_machine != Elf32_Ehdr::EM_PPC if (this->e_machine != Elf32_Ehdr::EM_PPC
&& this->e_machine != Elf32_Ehdr::EM_MIPS) && this->e_machine != Elf32_Ehdr::EM_MIPS)
@@ -1700,6 +1703,8 @@ PackLinuxElf32::buildLinuxLoader(
relocateLoader(); relocateLoader();
} }
unsigned bb1; // aid for possible debugging NRV/UCL
void void
PackLinuxElf64::buildLinuxLoader( PackLinuxElf64::buildLinuxLoader(
upx_byte const *const proto, upx_byte const *const proto,
@@ -1729,7 +1734,7 @@ PackLinuxElf64::buildLinuxLoader(
// EXP_TAIL FIXME: unfilter // EXP_TAIL FIXME: unfilter
// SO_TAIL // SO_TAIL
// SO_MAIN C-language supervision based on PT_LOADs // SO_MAIN C-language supervision based on PT_LOADs
char sec[120]; memset(sec, 0, sizeof(sec)); // debug convenience char sec[200]; memset(sec, 0, sizeof(sec)); // debug convenience
int len = 0; int len = 0;
unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method))); unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method)));
len += snprintf(sec, sizeof(sec), "%s", "SO_HEAD,ptr_NEXT,EXP_HEAD"); len += snprintf(sec, sizeof(sec), "%s", "SO_HEAD,ptr_NEXT,EXP_HEAD");
@@ -1774,7 +1779,7 @@ PackLinuxElf64::buildLinuxLoader(
|| this->e_machine==Elf64_Ehdr::EM_PPC64 || this->e_machine==Elf64_Ehdr::EM_PPC64
) { // main program with ELF2 de-compressor (folded portion) ) { // main program with ELF2 de-compressor (folded portion)
initLoader(fold, szfold); initLoader(fold, szfold);
char sec[120]; memset(sec, 0, sizeof(sec)); // debug convenience char sec[200]; memset(sec, 0, sizeof(sec)); // debug convenience
int len = 0; int len = 0;
unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method))); unsigned m_decompr = methods_used | (1u << (0xFF & ph_forced_method(ph.method)));
len += snprintf(sec, sizeof(sec), "%s", ".text,EXP_HEAD"); len += snprintf(sec, sizeof(sec), "%s", ".text,EXP_HEAD");
@@ -1871,7 +1876,14 @@ PackLinuxElf64::buildLinuxLoader(
|| this->e_machine==Elf64_Ehdr::EM_AARCH64 || this->e_machine==Elf64_Ehdr::EM_AARCH64
|| this->e_machine==Elf64_Ehdr::EM_PPC64 || this->e_machine==Elf64_Ehdr::EM_PPC64
) { // main program with ELF2 de-compressor ) { // main program with ELF2 de-compressor
addLoader("ELFMAINX,ELFMAINZ,FOLDEXEC,IDENTSTR"); addLoader("ELFMAINX");
// NYI for PPC64 {
if (opt->o_unix.catch_sigsegv && hasLoaderSection("ELFSIGSEGV"))
addLoader("ELFSIGSEGV");
if (this->e_machine!=Elf64_Ehdr::EM_PPC64)
addLoader("ELFMAINX2");
// } end NYI for PPC64
addLoader("ELFMAINZ,FOLDEXEC,IDENTSTR");
if (this->e_machine==Elf64_Ehdr::EM_PPC64 if (this->e_machine==Elf64_Ehdr::EM_PPC64
&& ehdri.e_ident[Elf64_Ehdr::EI_DATA]==Elf64_Ehdr::ELFDATA2MSB) { && ehdri.e_ident[Elf64_Ehdr::EI_DATA]==Elf64_Ehdr::ELFDATA2MSB) {
addLoader("ELFMAINZe"); addLoader("ELFMAINZe");
@@ -2378,10 +2390,11 @@ PackLinuxElf32::invert_pt_dynamic(Elf32_Dyn const *dynp, u32_t headway)
throwCantPack("bad DT_STRSZ %#x", strtab_max); throwCantPack("bad DT_STRSZ %#x", strtab_max);
} }
// Find end of DT_SYMTAB { // Find end of DT_SYMTAB
unsigned const tmp2 = elf_find_table_size(Elf32_Dyn::DT_SYMTAB, unsigned const tmp2 = elf_find_table_size(Elf32_Dyn::DT_SYMTAB,
Elf32_Shdr::SHT_DYNSYM); Elf32_Shdr::SHT_DYNSYM);
symnum_max = (~0u == tmp2) ? 0 : tmp1 / sizeof(Elf32_Sym); symnum_max = (~0u == tmp2) ? 0 : tmp2 / sizeof(Elf32_Sym);
}
unsigned v_sym = dt_table[Elf32_Dyn::DT_SYMTAB]; unsigned v_sym = dt_table[Elf32_Dyn::DT_SYMTAB];
if (v_sym) { if (v_sym) {
@@ -6093,6 +6106,8 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho)
// Keep _Shdr for SHF_WRITE. // Keep _Shdr for SHF_WRITE.
// Discard _Shdr with (0==sh_addr), except _Shdr[0] // Discard _Shdr with (0==sh_addr), except _Shdr[0]
// Keep ARM_ATTRIBUTES // Keep ARM_ATTRIBUTES
// Remove .ARM.extab(PROGBITS) and .ARM.exidx(SHT_ARM_EXIDX)
// because they refer to compressed .text(PT_LOAD)
unsigned const want_types_mask = 0 unsigned const want_types_mask = 0
| 1u<<SHT_PROGBITS // see comment above, and special code below | 1u<<SHT_PROGBITS // see comment above, and special code below
| 1u<<SHT_HASH | 1u<<SHT_HASH
@@ -6167,30 +6182,14 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho)
|| (Elf32_Shdr::SHT_ARM_ATTRIBUTES == sh_type) || (Elf32_Shdr::SHT_ARM_ATTRIBUTES == sh_type)
) { ) {
*sh_out = *sh_in; // *sh_in is a candidate for fowarding *sh_out = *sh_in; // *sh_in is a candidate for fowarding
if (sh_offset > xct_off) { // may slide down: earlier compression
if (sh_offset >= xct_off_hi) { // easy: so_slide down
if (Elf32_Shdr::SHT_ARM_ATTRIBUTES != sh_type) {
slide_sh_offset(sh_out);
}
}
else { // somewhere in compressed; try proportional (aligned)
// But note that PROGBITS without SHF_ALLOC
// will be dropped below.
u32_t const slice = xct_off + (~0xFu & (unsigned)(
(sh_offset - xct_off) *
((sh_offset - xct_off) / (float)(xct_off_hi - xct_off))));
//set_te32(&sh_out->sh_addr, slice);
set_te32(&sh_out->sh_offset, slice);
}
u32_t const max_sz = total_out - get_te32(&sh_out->sh_offset);
if (sh_size > max_sz) { // avoid complaint "extends beyond EOF"
set_te32(&sh_out->sh_size, max_sz);
}
}
if (j == e_shstrndx) { // changes Elf32_Ehdr itself if (j == e_shstrndx) { // changes Elf32_Ehdr itself
set_te16(&eho->e_shstrndx, sh_out - set_te16(&eho->e_shstrndx, sh_out -
(Elf32_Shdr *)mb_shdro.getVoidPtr()); (Elf32_Shdr *)mb_shdro.getVoidPtr());
} }
if (Elf32_Shdr::SHT_ARM_EXIDX == sh_type
|| 0==strcmp(".ARM.extab", name)) {
/* OMIT */ continue; // OMIT: compressed contents
}
if (Elf32_Shdr::SHT_ARM_ATTRIBUTES == sh_type if (Elf32_Shdr::SHT_ARM_ATTRIBUTES == sh_type
|| (SHT_NOTE == sh_type && xct_off < sh_offset) || (SHT_NOTE == sh_type && xct_off < sh_offset)
) { // append a copy ) { // append a copy
@@ -6204,7 +6203,7 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho)
if (!(Elf32_Shdr::SHF_ALLOC & sh_flags)) { if (!(Elf32_Shdr::SHF_ALLOC & sh_flags)) {
// .debug_*, .gnu_debuglink etc. Typically compressed // .debug_*, .gnu_debuglink etc. Typically compressed
// but not in RAM, and gdb (BFD) gets confused. // but not in RAM, and gdb (BFD) gets confused.
continue; // OMIT the commit: do not forward /* OMIT */ continue; // OMIT the commit: do not forward
} else } else
if (sh_offset <= xct_off if (sh_offset <= xct_off
&& 0 == strcmp(".text", name) ) { && 0 == strcmp(".text", name) ) {
@@ -6219,9 +6218,31 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho)
n_shstrsec = sh_out; n_shstrsec = sh_out;
} else } else
if (strcmp(".dynstr", name)) { if (strcmp(".dynstr", name)) {
continue; // OMIT the commit of non-global symbol names /* OMIT */ continue; // OMIT the commit of non-global symbol names
} }
} }
if (sh_offset > xct_off) { // may slide down: earlier compression
if (sh_offset >= xct_off_hi) { // easy: so_slide down
if (Elf32_Shdr::SHT_ARM_ATTRIBUTES != sh_type
// && Elf32_Shdr::SHT_ARM_EXIDX != sh_type
) {
slide_sh_offset(sh_out);
}
}
else { // somewhere in compressed; try proportional (aligned)
// Note that PROGBITS without SHF_ALLOC is already omitted.
u32_t const slice = xct_off + (~0xFu & (unsigned)(
(sh_offset - xct_off) *
((sh_offset - xct_off) / (float)(xct_off_hi - xct_off))));
//set_te32(&sh_out->sh_addr, slice);
set_te32(&sh_out->sh_offset, slice);
}
u32_t const max_sz = total_out - get_te32(&sh_out->sh_offset);
if (sh_size > max_sz) { // avoid complaint "extends beyond EOF"
set_te32(&sh_out->sh_size, max_sz);
}
}
// Will be forwarded, but needs a name.
set_te32(&sh_out->sh_name, ptr_shstrings - (char *)mb_shstrings.getVoidPtr()); set_te32(&sh_out->sh_name, ptr_shstrings - (char *)mb_shstrings.getVoidPtr());
do { // stupid MSVC lacks stpcpy() do { // stupid MSVC lacks stpcpy()
*ptr_shstrings++ = *name; *ptr_shstrings++ = *name;
@@ -6267,6 +6288,7 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho)
} }
} }
} }
UNUSED(ptr);
fo->seek(0, SEEK_SET); fo->seek(0, SEEK_SET);
fo->rewrite(eho, sizeof(*eho)); fo->rewrite(eho, sizeof(*eho));
@@ -6277,6 +6299,7 @@ unsigned PackLinuxElf32::forward_Shdrs(OutputFile *fo, Elf32_Ehdr *const eho)
return penalty; return penalty;
} }
// NYI 2025-12-10: should be merged from Elf32::forward_Shdrs
unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho) unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho)
{ {
if (!fo) { if (!fo) {
@@ -6288,7 +6311,9 @@ unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho)
// Keep _Shdr for rtld data (below xct_off). // Keep _Shdr for rtld data (below xct_off).
// Discard _Shdr for compressed regions, except ".text" for gdb. // Discard _Shdr for compressed regions, except ".text" for gdb.
// Keep _Shdr with SHF_WRITE. // Keep _Shdr with SHF_WRITE.
// Keep ARM_ATTRIBUTES // Keep ARM_ATTRIBUTES.
// Remove .ARM.extab(PROGBITS) and .ARM.exidx(ARM_EXIDX)
// because they refer to compressed .text.
// Discard _Shdr with (0==sh_addr), except _Shdr[0] // Discard _Shdr with (0==sh_addr), except _Shdr[0]
unsigned const want_types_mask = unsigned const want_types_mask =
1u<<SHT_SYMTAB 1u<<SHT_SYMTAB
@@ -6336,7 +6361,6 @@ unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho)
for (unsigned j = 1; j < e_shnum; ++j, ++sh_in) { for (unsigned j = 1; j < e_shnum; ++j, ++sh_in) {
char const *sh_name = &shstrtab[get_te32(&sh_in->sh_name)]; char const *sh_name = &shstrtab[get_te32(&sh_in->sh_name)];
(void)sh_name; // debugging
unsigned sh_type = get_te32(&sh_in->sh_type); unsigned sh_type = get_te32(&sh_in->sh_type);
u64_t sh_flags = get_te64(&sh_in->sh_flags); u64_t sh_flags = get_te64(&sh_in->sh_flags);
u64_t sh_addr = get_te64(&sh_in->sh_addr); u64_t sh_addr = get_te64(&sh_in->sh_addr);
@@ -6381,6 +6405,9 @@ unsigned PackLinuxElf64::forward_Shdrs(OutputFile *fo, Elf64_Ehdr *const eho)
set_te16(&eho->e_shstrndx, sh_out - set_te16(&eho->e_shstrndx, sh_out -
(Elf64_Shdr *)mb_shdro.getVoidPtr()); (Elf64_Shdr *)mb_shdro.getVoidPtr());
} }
if (0==strcmp(".ARM.extab", sh_name)) {
/* OMIT */ continue; // OMIT: compressed contents
}
if (j == e_shstrndx if (j == e_shstrndx
|| sec_arm_attr == sh_in || sec_arm_attr == sh_in
|| (SHT_NOTE == sh_type && xct_off < sh_offset) || (SHT_NOTE == sh_type && xct_off < sh_offset)
@@ -8470,10 +8497,11 @@ PackLinuxElf64::invert_pt_dynamic(Elf64_Dyn const *dynp, upx_uint64_t headway)
throwCantPack("bad DT_STRSZ %#x", strtab_max); throwCantPack("bad DT_STRSZ %#x", strtab_max);
} }
// Find end of DT_SYMTAB { // Find end of DT_SYMTAB
unsigned const tmp2 = elf_find_table_size(Elf64_Dyn::DT_SYMTAB, unsigned const tmp2 = elf_find_table_size(Elf64_Dyn::DT_SYMTAB,
Elf64_Shdr::SHT_DYNSYM); Elf64_Shdr::SHT_DYNSYM);
symnum_max = (~0u == tmp2) ? 0 : tmp1 / sizeof(Elf64_Sym); symnum_max = (~0u == tmp2) ? 0 : tmp2 / sizeof(Elf64_Sym);
}
unsigned v_sym = dt_table[Elf64_Dyn::DT_SYMTAB]; unsigned v_sym = dt_table[Elf64_Dyn::DT_SYMTAB];
if (v_sym) { if (v_sym) {
@@ -8661,6 +8689,7 @@ Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
break; // end sentinel break; // end sentinel
} }
if (n_bucket) { if (n_bucket) {
void const *EOM = file_size + (char const *)file_image.getVoidPtr();
unsigned const m = elf_hash(name) % n_bucket; unsigned const m = elf_hash(name) % n_bucket;
unsigned n_visit = 0; unsigned n_visit = 0;
unsigned si; unsigned si;
@@ -8674,6 +8703,9 @@ Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
return &dynsym[si]; return &dynsym[si];
if (l_sym <= &dynsym[n_visit++]) if (l_sym <= &dynsym[n_visit++])
throwCantPack("circular DT_HASH chain %d\n", si); throwCantPack("circular DT_HASH chain %d\n", si);
// Detect next si out-of-bounds
if ((unsigned)((unsigned int const *)EOM - chains) <= si)
throwCantPack("bad DT_HASH chain %d\n", si);
} }
} }
} }
@@ -8704,9 +8736,9 @@ Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
if (1& (w>>hbit1) & (w>>hbit2)) { if (1& (w>>hbit1) & (w>>hbit2)) {
unsigned const hhead = get_te32(&buckets[h % n_bucket]); unsigned const hhead = get_te32(&buckets[h % n_bucket]);
if (n_bucket <= (hhead - symbias)) { if (symnum_max <= hhead || (hhead && hhead < symbias)) {
throwCantPack("bad DT_GNU_HASH n_bucket{%#x} <= buckets[%d]{%#x} - symbias{%#x}\n", throwCantPack("bad DT_GNU_HASH symnum_max{%#x} <= buckets[%d]{%#x} < symbias{%#x}\n",
n_bucket, h % n_bucket, hhead, symbias); symnum_max, h % n_bucket, hhead, symbias);
} }
if (hhead) { if (hhead) {
Elf32_Sym const *dsp = &dynsym[hhead]; Elf32_Sym const *dsp = &dynsym[hhead];
@@ -8762,6 +8794,7 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const
break; //end break; //end
} }
if (n_bucket) { // -rust-musl can have "empty" hashtab if (n_bucket) { // -rust-musl can have "empty" hashtab
void const *const EOM = file_size + (char const *)file_image.getVoidPtr();
unsigned const m = elf_hash(name) % n_bucket; unsigned const m = elf_hash(name) % n_bucket;
unsigned n_visit = 0; unsigned n_visit = 0;
unsigned si; unsigned si;
@@ -8775,6 +8808,9 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const
return &dynsym[si]; return &dynsym[si];
if (l_sym <= &dynsym[n_visit++]) if (l_sym <= &dynsym[n_visit++])
throwCantPack("circular DT_HASH chain %d\n", si); throwCantPack("circular DT_HASH chain %d\n", si);
// Detect next si out-of-bounds
if ((unsigned)((unsigned int const *)EOM - chains) <= si)
throwCantPack("bad DT_HASH chain %d\n", si);
} }
} }
} }
@@ -8805,6 +8841,10 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const
upx_uint64_t const w = get_te64(&bitmask[(n_bitmask -1) & (h>>6)]); upx_uint64_t const w = get_te64(&bitmask[(n_bitmask -1) & (h>>6)]);
if (1& (w>>hbit1) & (w>>hbit2)) { if (1& (w>>hbit1) & (w>>hbit2)) {
unsigned hhead = get_te32(&buckets[h % n_bucket]); unsigned hhead = get_te32(&buckets[h % n_bucket]);
if (symnum_max <= hhead || (hhead && hhead < symbias)) {
throwCantPack("bad DT_GNU_HASH symnum_max{%#x} <= buckets[%d]{%#x} < symbias{%#x}\n",
symnum_max, h % n_bucket, hhead, symbias);
}
if (hhead) { if (hhead) {
Elf64_Sym const *dsp = &dynsym[hhead]; Elf64_Sym const *dsp = &dynsym[hhead];
unsigned const *hp = &hasharr[hhead - symbias]; unsigned const *hp = &hasharr[hhead - symbias];
+2
View File
@@ -1418,6 +1418,7 @@ void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e
unsigned const sz_threado = threado_size(); unsigned const sz_threado = threado_size();
MemBuffer space(sz_threado); memset(space, 0, sz_threado); MemBuffer space(sz_threado); memset(space, 0, sz_threado);
fo->write(space, sz_threado); fo->write(space, sz_threado);
UNUSED(cmdsize);
} }
else if (my_filetype == Mach_header::MH_DYLIB) { else if (my_filetype == Mach_header::MH_DYLIB) {
Mach_command const *ptr = (Mach_command const *)rawmseg; Mach_command const *ptr = (Mach_command const *)rawmseg;
@@ -1449,6 +1450,7 @@ void PackMachBase<T>::pack1(OutputFile *const fo, Filter &/*ft*/) // generate e
} }
memset(&linkitem, 0, sizeof(linkitem)); memset(&linkitem, 0, sizeof(linkitem));
fo->write(&linkitem, sizeof(linkitem)); fo->write(&linkitem, sizeof(linkitem));
UNUSED(cmdsize);
} }
sz_mach_headers = fo->getBytesWritten(); sz_mach_headers = fo->getBytesWritten();
gap = secTEXT.offset - sz_mach_headers; gap = secTEXT.offset - sz_mach_headers;
+5 -1
View File
@@ -658,7 +658,11 @@ void PackUnix::unpack(OutputFile *fo)
fi->readx(&bhdr, szb_info); fi->readx(&bhdr, szb_info);
ph.u_len = sz_unc = get_te32(&bhdr.sz_unc); ph.u_len = sz_unc = get_te32(&bhdr.sz_unc);
ph.c_len = sz_cpr = get_te32(&bhdr.sz_cpr); ph.c_len = sz_cpr = get_te32(&bhdr.sz_cpr);
ph.set_method(bhdr.b_method); if (szb_info < sizeof(b_info)) { // some upx version 11
bhdr.b_method = ph.method;
bhdr.b_ftid = ph.filter;
bhdr.b_cto8 = ph.filter_cto;
}
if (sz_unc == 0) // uncompressed size 0 -> EOF if (sz_unc == 0) // uncompressed size 0 -> EOF
{ {
+6 -6
View File
@@ -857,9 +857,9 @@ void Packer::relocateLoader() {
} }
/************************************************************************* /*************************************************************************
// void Packer::compressWithFilters(): // void Packer::compressWithFilters():
// Try compression with several methods and filters, choose the best // Try compression with several methods and filters, choose the best
/ or first working one. Needs buildLoader(). // or first working one. Needs buildLoader().
// //
// Required inputs: // Required inputs:
// this->ph // this->ph
@@ -1015,9 +1015,9 @@ void Packer::compressWithFilters(byte *i_ptr,
byte *const hdr_ptr, const unsigned hdr_len, byte *const hdr_ptr, const unsigned hdr_len,
Filter *const parm_ft, // updated Filter *const parm_ft, // updated
const unsigned overlap_range, const unsigned overlap_range,
upx_compress_config_t const *const cconf, const upx_compress_config_t *const cconf,
int filter_strategy, // in+out for prepareFilters int filter_strategy, // in+out for prepareFilters
bool const inhibit_compression_check) { const bool inhibit_compression_check) {
parm_ft->buf_len = f_len; parm_ft->buf_len = f_len;
// struct copies // struct copies
const PackHeader orig_ph = this->ph; const PackHeader orig_ph = this->ph;
@@ -1219,7 +1219,7 @@ void Packer::compressWithFilters(Filter *ft, const unsigned overlap_range,
} }
void Packer::compressWithFilters(Filter *ft, const unsigned overlap_range, void Packer::compressWithFilters(Filter *ft, const unsigned overlap_range,
upx_compress_config_t const *cconf, int filter_strategy, const upx_compress_config_t *cconf, int filter_strategy,
unsigned filter_off, unsigned ibuf_off, unsigned obuf_off, unsigned filter_off, unsigned ibuf_off, unsigned obuf_off,
byte *const hdr_ptr, unsigned hdr_len, byte *const hdr_ptr, unsigned hdr_len,
bool inhibit_compression_check) { bool inhibit_compression_check) {
+11 -11
View File
@@ -48,7 +48,7 @@ protected:
public: public:
virtual ~PackerBase() noexcept {} virtual ~PackerBase() noexcept {}
// getVersion() enables detecting forward incompatibility of unpack() // getVersion() enables detecting forward incompatibility of unpack()
// by old upx when newer upx changes the format of compressed output. // by old UPX when newer UPX changes the format of compressed output.
virtual int getVersion() const = 0; virtual int getVersion() const = 0;
// A unique integer ID for this executable format; see UPX_F_xxx in conf.h. // A unique integer ID for this executable format; see UPX_F_xxx in conf.h.
virtual int getFormat() const = 0; virtual int getFormat() const = 0;
@@ -58,11 +58,11 @@ public:
virtual const int *getFilters() const = 0; virtual const int *getFilters() const = 0;
// canPack() should throw a cantPackException explaining why it cannot pack // canPack() should throw a cantPackException explaining why it cannot pack
// a recognized format. // a recognized format.
// canPack() can also return -1 to fail early; see class PackMaster // canPack() can also return -1 to fail early; see class PackMaster
virtual tribool canPack() = 0; virtual tribool canPack() = 0;
// canUnpack() should throw a cantUnpackException explaining why it cannot unpack // canUnpack() should throw a cantUnpackException explaining why it cannot unpack
// a recognized format. // a recognized format.
// canUnpack() can also return -1 to fail early; see class PackMaster // canUnpack() can also return -1 to fail early; see class PackMaster
virtual tribool canUnpack() = 0; virtual tribool canUnpack() = 0;
@@ -162,7 +162,7 @@ protected:
unsigned f_len, // subset of [*i_ptr, +i_len) unsigned f_len, // subset of [*i_ptr, +i_len)
byte *const hdr_ptr, unsigned hdr_len, byte *const hdr_ptr, unsigned hdr_len,
Filter *parm_ft, // updated Filter *parm_ft, // updated
unsigned overlap_range, upx_compress_config_t const *cconf, unsigned overlap_range, const upx_compress_config_t *cconf,
int filter_strategy, bool inhibit_compression_check = false); int filter_strategy, bool inhibit_compression_check = false);
// util for verifying overlapping decompression // util for verifying overlapping decompression
@@ -248,7 +248,7 @@ protected:
int patch_le32(void *b, int blen, const void *old, unsigned new_); int patch_le32(void *b, int blen, const void *old, unsigned new_);
void checkPatch(void *b, int blen, int boff, int size); void checkPatch(void *b, int blen, int boff, int size);
// relocation util // relocation util [see packer_r.cpp]
static unsigned optimizeReloc(unsigned relocnum, SPAN_P(byte) relocs, SPAN_S(byte) out, static unsigned optimizeReloc(unsigned relocnum, SPAN_P(byte) relocs, SPAN_S(byte) out,
SPAN_P(byte) image, unsigned image_size, int bits, bool bswap, SPAN_P(byte) image, unsigned image_size, int bits, bool bswap,
int *big); int *big);
@@ -260,7 +260,7 @@ protected:
// permissive version using "void *" // permissive version using "void *"
inline unsigned get_te16(const void *p) const noexcept { return bele->get16(p); } inline unsigned get_te16(const void *p) const noexcept { return bele->get16(p); }
inline unsigned get_te32(const void *p) const noexcept { return bele->get32(p); } inline unsigned get_te32(const void *p) const noexcept { return bele->get32(p); }
inline unsigned get_te64_32(const void *p) const { return (unsigned) bele->get64(p); } inline unsigned get_te64_32(const void *p) const may_throw { return (unsigned) bele->get64(p); }
inline upx_uint64_t get_te64(const void *p) const noexcept { return bele->get64(p); } inline upx_uint64_t get_te64(const void *p) const noexcept { return bele->get64(p); }
inline void set_te16(void *p, unsigned v) noexcept { bele->set16(p, v); } inline void set_te16(void *p, unsigned v) noexcept { bele->set16(p, v); }
inline void set_te32(void *p, unsigned v) noexcept { bele->set32(p, v); } inline void set_te32(void *p, unsigned v) noexcept { bele->set32(p, v); }
@@ -293,11 +293,11 @@ protected:
return bele->get32(p); return bele->get32(p);
} }
template <class T, class = enable_if_te64<T> > template <class T, class = enable_if_te64<T> >
inline unsigned get_te64_32(const T *p) const { inline unsigned get_te64_32(const T *p) const may_throw {
upx_uint64_t val = get_te64(p); upx_uint64_t v = bele->get64(p);
if (val >> 32) if ((v >> 32) != 0)
throwCantPack("64-bit value too big %#llx", val); throwCantPack("64-bit value too big %#llx", v);
return (unsigned) val; return (unsigned) v;
} }
template <class T, class = enable_if_te64<T> > template <class T, class = enable_if_te64<T> >
inline upx_uint64_t get_te64(const T *p) const noexcept { inline upx_uint64_t get_te64(const T *p) const noexcept {
+3 -3
View File
@@ -39,12 +39,13 @@ struct PackHeader final {
~PackHeader() noexcept = default; ~PackHeader() noexcept = default;
void reset() noexcept; void reset() noexcept;
int set_method(int m, unsigned offset = 0); // check, then assign
int getPackHeaderSize() const;
void putPackHeader(SPAN_S(byte) p) const; void putPackHeader(SPAN_S(byte) p) const;
bool decodePackHeaderFromBuf(SPAN_S(const byte) b, int blen); bool decodePackHeaderFromBuf(SPAN_S(const byte) b, int blen);
int getPackHeaderSize() const;
// fields stored in compressed file => see stub/src/include/header.S // fields stored in compressed file => see stub/src/include/header.S
// enum { magic = UPX_MAGIC_LE32 }; // enum { magic = UPX_MAGIC_LE32 };
int version; int version;
@@ -63,7 +64,6 @@ struct PackHeader final {
int n_mru; // specific name for filter ctojr int n_mru; // specific name for filter ctojr
}; };
int header_checksum; int header_checksum;
int set_method(int m, unsigned offset = 0); // check, then assign
// support fields for verifying decompression // support fields for verifying decompression
unsigned saved_u_adler; unsigned saved_u_adler;
+2
View File
@@ -25,6 +25,8 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com> <markus@oberhumer.com> <ezerotven+github@gmail.com>
*/ */
// dispatch to a concrete subclass of class PackerBase; see work.cpp
#include "conf.h" #include "conf.h"
#include "file.h" #include "file.h"
#include "packmast.h" #include "packmast.h"
+89 -45
View File
@@ -96,6 +96,7 @@ PeFile::PeFile(InputFile *f) : super(f) {
use_tls_callbacks = false; use_tls_callbacks = false;
oloadconf = nullptr; oloadconf = nullptr;
soloadconf = 0; soloadconf = 0;
dbgCET = nullptr;
isdll = false; isdll = false;
isrtm = false; isrtm = false;
@@ -580,14 +581,15 @@ void PeFile32::processRelocs() // pass1
// deliberately corrupt. Sometimes it is even tuned to cause us trouble! // deliberately corrupt. Sometimes it is even tuned to cause us trouble!
// Use an extra check to avoid AccessViolation (SIGSEGV) when appending // Use an extra check to avoid AccessViolation (SIGSEGV) when appending
// the relocs into one array. // the relocs into one array.
if ((4 * relocnum + 8192) < if ((sizeof(LE32) * relocnum + 8192) <
(sorelocs + 4 * (2 + xcounts[IMAGE_REL_BASED_LOW] + xcounts[IMAGE_REL_BASED_HIGH]))) (sorelocs +
sizeof(LE32) * (2 + xcounts[IMAGE_REL_BASED_LOW] + xcounts[IMAGE_REL_BASED_HIGH])))
throwCantUnpack("Invalid relocs"); throwCantUnpack("Invalid relocs");
// append relocs type "LOW" then "HIGH" // append relocs type "LOW" then "HIGH"
for (unsigned ic = IMAGE_REL_BASED_LOW; ic >= IMAGE_REL_BASED_HIGH; ic--) { for (unsigned ic = IMAGE_REL_BASED_LOW; ic >= IMAGE_REL_BASED_HIGH; ic--) {
memcpy(orelocs + sorelocs, fix[ic], 4 * xcounts[ic]); memcpy(orelocs + sorelocs, fix[ic], sizeof(LE32) * xcounts[ic]);
sorelocs += 4 * xcounts[ic]; sorelocs += sizeof(LE32) * xcounts[ic];
set_le32(orelocs + sorelocs, 0); set_le32(orelocs + sorelocs, 0);
if (xcounts[ic]) { if (xcounts[ic]) {
sorelocs += 4; sorelocs += 4;
@@ -1224,7 +1226,15 @@ void PeFile::Export::convert(unsigned eoffs, unsigned esize) {
size += len; size += len;
iv.add_interval(edir.name, len); iv.add_interval(edir.name, len);
len = 4 * edir.functions; // This test is weak because it does not consider other necessary storage.
// But it does detect outrageous individual members.
// Note: sizeof(LE32) <= sizeof(char *)
if (UPX_RSIZE_MAX_MEM / sizeof(char *) <= edir.functions ||
UPX_RSIZE_MAX_MEM / sizeof(char *) <= edir.names) {
throwCantPack("export directory too big: functions=%#x names=%#x",
(unsigned) edir.functions, (unsigned) edir.names);
}
len = sizeof(LE32) * edir.functions;
functionptrs = New(char, len + 1); functionptrs = New(char, len + 1);
memcpy(functionptrs, base + edir.addrtable, len); memcpy(functionptrs, base + edir.addrtable, len);
size += len; size += len;
@@ -1233,14 +1243,14 @@ void PeFile::Export::convert(unsigned eoffs, unsigned esize) {
unsigned ic; unsigned ic;
names = New(char *, edir.names + edir.functions + 1); names = New(char *, edir.names + edir.functions + 1);
for (ic = 0; ic < edir.names; ic++) { for (ic = 0; ic < edir.names; ic++) {
char *n = base + get_le32(base + edir.nameptrtable + ic * 4); char *n = base + get_le32(base + edir.nameptrtable + ic * sizeof(LE32));
len = strlen(n) + 1; len = strlen(n) + 1;
names[ic] = strdup(n); names[ic] = strdup(n);
size += len; size += len;
iv.add_interval(get_le32(base + edir.nameptrtable + ic * 4), len); iv.add_interval(get_le32(base + edir.nameptrtable + ic * sizeof(LE32)), len);
} }
iv.add_interval(edir.nameptrtable, 4 * edir.names); iv.add_interval(edir.nameptrtable, sizeof(LE32) * edir.names);
size += 4 * edir.names; size += sizeof(LE32) * edir.names;
LE32 *fp = (LE32 *) functionptrs; LE32 *fp = (LE32 *) functionptrs;
// export forwarders // export forwarders
@@ -1270,8 +1280,8 @@ void PeFile::Export::convert(unsigned eoffs, unsigned esize) {
void PeFile::Export::build(char *newbase, unsigned newoffs) { void PeFile::Export::build(char *newbase, unsigned newoffs) {
char *const functionp = newbase + sizeof(edir); char *const functionp = newbase + sizeof(edir);
char *const namep = functionp + 4 * edir.functions; char *const namep = functionp + sizeof(LE32) * edir.functions;
char *const ordinalp = namep + 4 * edir.names; char *const ordinalp = namep + sizeof(LE32) * edir.names;
char *const enamep = ordinalp + 2 * edir.names; char *const enamep = ordinalp + 2 * edir.names;
char *exports = enamep + strlen(ename) + 1; char *exports = enamep + strlen(ename) + 1;
@@ -1286,15 +1296,15 @@ void PeFile::Export::build(char *newbase, unsigned newoffs) {
unsigned ic; unsigned ic;
for (ic = 0; ic < edir.names; ic++) { for (ic = 0; ic < edir.names; ic++) {
strcpy(exports, names[ic]); strcpy(exports, names[ic]);
set_le32(namep + 4 * ic, newoffs + ptr_diff_bytes(exports, newbase)); set_le32(namep + sizeof(LE32) * ic, newoffs + ptr_diff_bytes(exports, newbase));
exports += strlen(exports) + 1; exports += strlen(exports) + 1;
} }
memcpy(functionp, functionptrs, 4 * edir.functions); memcpy(functionp, functionptrs, sizeof(LE32) * edir.functions);
for (ic = 0; ic < edir.functions; ic++) for (ic = 0; ic < edir.functions; ic++)
if (names[edir.names + ic]) { if (names[edir.names + ic]) {
strcpy(exports, names[edir.names + ic]); strcpy(exports, names[edir.names + ic]);
set_le32(functionp + 4 * ic, newoffs + ptr_diff_bytes(exports, newbase)); set_le32(functionp + sizeof(LE32) * ic, newoffs + ptr_diff_bytes(exports, newbase));
exports += strlen(exports) + 1; exports += strlen(exports) + 1;
} }
@@ -1470,29 +1480,39 @@ void PeFile::processTls2(Reloc *const rel, const Interval *const iv, unsigned ne
if (sotls == 0) if (sotls == 0)
return; return;
// add new relocation entries
// add new relocation entries
if (tls_handler_offset > 0 && tls_handler_offset_reloc > 0) if (tls_handler_offset > 0 && tls_handler_offset_reloc > 0)
rel->add_reloc(tls_handler_offset + tls_handler_offset_reloc, reloc_type); rel->add_reloc(tls_handler_offset + tls_handler_offset_reloc, reloc_type);
unsigned ic;
// NEW: if TLS callbacks are used, relocate the VA of the callback chain, too - Stefan Widmann // NEW: if TLS callbacks are used, relocate the VA of the callback chain, too - Stefan Widmann
for (ic = 0; ic < (use_tls_callbacks ? 4 * cb_size : 3 * cb_size); ic += cb_size) for (unsigned ic = 0; ic < (unsigned) (use_tls_callbacks ? 4 : 3); ic++)
rel->add_reloc(newaddr + ic, reloc_type); rel->add_reloc(newaddr + ic * cb_size, reloc_type);
SPAN_S_VAR(tls, const tlsp, mb_otls); SPAN_S_VAR(tls, const tlsp, mb_otls);
// now the relocation entries in the tls data area // now the relocation entries in the tls data area
for (ic = 0; ic < iv->ivnum; ic += 4) { for (unsigned ic = 0; ic < iv->ivnum; ic++) {
SPAN_S_VAR(byte, const pp, SPAN_S_VAR(byte, const pp,
otls + (iv->ivarr[ic].start - (tlsp->datastart - imagebase) + sizeof(tls))); otls + (iv->ivarr[ic].start - (tlsp->datastart - imagebase) + sizeof(tls)));
LEXX *const p = (LEXX *) raw_bytes(pp, sizeof(LEXX)); LEXX *const p = (LEXX *) raw_bytes(pp, sizeof(LEXX));
cb_value_t kc = *p; cb_value_t kc = *p;
if (kc < tlsp->dataend && kc >= tlsp->datastart) { if (kc >= tlsp->datastart && kc < tlsp->dataend) {
// add a relocation entry referring to an address inside of the original tls data area
// - as the new tls area is moved, the referred address have to be also adjusted
kc += newaddr + sizeof(tls) - tlsp->datastart; kc += newaddr + sizeof(tls) - tlsp->datastart;
*p = kc + imagebase; *p = kc + imagebase;
rel->add_reloc(kc, iv->ivarr[ic].len); rel->add_reloc(kc, iv->ivarr[ic].len);
} else } else {
rel->add_reloc(kc - imagebase, iv->ivarr[ic].len); // add a relocation entry referring to an address outside of the original tls data area
// by adding the difference of the new tlsdatastart and the old tlsdatastart to
// the address of the original relocation record
const unsigned a =
iv->ivarr[ic].start + (newaddr + sizeof(tls)) - (tlsp->datastart - imagebase);
// Must not overwrite compressed data
if (a < newaddr && !opt->win32_pe.strip_relocs)
throwCantPack("relocation too low (%#x < %#x); try --strip-relocs", a, newaddr);
rel->add_reloc(a, iv->ivarr[ic].len);
}
} }
const unsigned tls_data_size = tlsp->dataend - tlsp->datastart; const unsigned tls_data_size = tlsp->dataend - tlsp->datastart;
@@ -1716,15 +1736,15 @@ PeFile::Resource::upx_rnode *PeFile::Resource::convert(const void *rnode, upx_rn
branch->name = nullptr; branch->name = nullptr;
branch->parent = parent; branch->parent = parent;
branch->nc = ic; branch->nc = ic;
branch->children = New(upx_rnode *, ic); branch->children = New0(upx_rnode *, ic);
branch->data = *node; branch->data = *node;
if (!root) // first one if (!root) // first one
root = branch; // prevent leak if xcheck throws (hacked unpack or test) root = branch; // prevent leak if xcheck throws (hacked unpack or test)
for (const res_dir_entry *rde = node->entries + ic - 1; --ic >= 0; rde--) { for (const res_dir_entry *rde = node->entries + ic - 1; --ic >= 0; rde--) {
upx_rnode *child = convert(start + (rde->child & 0x7fffffff), branch, level + 1); upx_rnode *child = convert(start + (rde->child & 0x7fffffff), branch, level + 1);
xcheck(child);
branch->children[ic] = child; branch->children[ic] = child;
xcheck(child);
child->id = rde->tnl; child->id = rde->tnl;
if (child->id & 0x80000000) { if (child->id & 0x80000000) {
const byte *p = start + (child->id & 0x7fffffff); const byte *p = start + (child->id & 0x7fffffff);
@@ -2073,25 +2093,32 @@ unsigned PeFile::stripDebug(unsigned overlaystart) {
if (IDADDR(PEDIR_DEBUG) == 0) if (IDADDR(PEDIR_DEBUG) == 0)
return overlaystart; return overlaystart;
struct alignas(1) DebugDir final {
byte _[16]; // flags, time/date, version, type
LE32 size;
byte __[4]; // rva
LE32 fpos;
};
COMPILE_TIME_ASSERT(sizeof(DebugDir) == 28) COMPILE_TIME_ASSERT(sizeof(DebugDir) == 28)
COMPILE_TIME_ASSERT_ALIGNED1(DebugDir) COMPILE_TIME_ASSERT_ALIGNED1(DebugDir)
COMPILE_TIME_ASSERT(sizeof(((DebugDir *) nullptr)->_) == 16)
COMPILE_TIME_ASSERT(sizeof(((DebugDir *) nullptr)->__) == 4)
const unsigned skip = IDADDR(PEDIR_DEBUG); const unsigned skip = IDADDR(PEDIR_DEBUG);
const unsigned take = IDSIZE(PEDIR_DEBUG); const unsigned take = IDSIZE(PEDIR_DEBUG);
const DebugDir *dd = (const DebugDir *) ibuf.subref("bad debug %#x", skip, take); DebugDir *const dd0 = (DebugDir *) ibuf.subref("bad debug %#x", skip, take);
for (unsigned ic = 0; ic < IDSIZE(PEDIR_DEBUG) / sizeof(DebugDir); ic++, dd++) DebugDir *dd = dd0;
for (unsigned ic = 0; ic < IDSIZE(PEDIR_DEBUG) / sizeof(DebugDir); ic++, dd++) {
if (IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS == dd->type && dd->size == sizeof(LE32) &&
dd->fpos <= (file_size_u - sizeof(LE32))) {
// fpos need not belong to any PEDIR_* section.
// Read directly from input file, but keep position (paranoia).
LE32 word;
upx_off_t const now_pos = fi->tell();
fi->seek(dd->fpos, SEEK_SET);
fi->read(&word, sizeof(word));
fi->seek(now_pos, SEEK_SET);
if (IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT & word) {
*(dbgCET = dd0) = *dd; // remember presence; copy to front
}
}
if (overlaystart == dd->fpos) if (overlaystart == dd->fpos)
overlaystart += dd->size; overlaystart += dd->size;
ibuf.fill(IDADDR(PEDIR_DEBUG), IDSIZE(PEDIR_DEBUG), FILLVAL); }
ibuf.fill((!dbgCET ? 0 : sizeof(DebugDir)) + IDADDR(PEDIR_DEBUG),
(!dbgCET ? 0 : -(int) sizeof(DebugDir)) + IDSIZE(PEDIR_DEBUG), FILLVAL);
return overlaystart; return overlaystart;
} }
@@ -2478,8 +2505,8 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
obuf.clear(ph.c_len, c_len - ph.c_len); obuf.clear(ph.c_len, c_len - ph.c_len);
const unsigned aligned_sotls = ALIGN_UP(sotls, usizeof(LEXX)); const unsigned aligned_sotls = ALIGN_UP(sotls, usizeof(LEXX));
const unsigned s1size = const unsigned s1size = ALIGN_UP(ic + c_len + codesize, usizeof(LEXX)) + aligned_sotls +
ALIGN_UP(ic + c_len + codesize, usizeof(LEXX)) + aligned_sotls + soloadconf; soloadconf + (dbgCET ? (sizeof(LE32) + sizeof(*dbgCET)) : 0);
const unsigned s1addr = (newvsize - (ic + c_len) + oam1) & ~oam1; const unsigned s1addr = (newvsize - (ic + c_len) + oam1) & ~oam1;
const unsigned ncsection = (s1addr + s1size + oam1) & ~oam1; const unsigned ncsection = (s1addr + s1size + oam1) & ~oam1;
@@ -2497,7 +2524,7 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
oh.chksum = 0; oh.chksum = 0;
// fill the data directory // fill the data directory
ODADDR(PEDIR_DEBUG) = 0; ODADDR(PEDIR_DEBUG) = 0; // dbgCET later
ODSIZE(PEDIR_DEBUG) = 0; ODSIZE(PEDIR_DEBUG) = 0;
ODADDR(PEDIR_IAT) = 0; ODADDR(PEDIR_IAT) = 0;
ODSIZE(PEDIR_IAT) = 0; ODSIZE(PEDIR_IAT) = 0;
@@ -2505,7 +2532,8 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
ODSIZE(PEDIR_BOUND_IMPORT) = 0; ODSIZE(PEDIR_BOUND_IMPORT) = 0;
// tls & loadconf are put into section 1 // tls & loadconf are put into section 1
ic = s1addr + s1size - aligned_sotls - soloadconf; ic = s1addr + s1size - aligned_sotls - soloadconf -
(dbgCET ? (sizeof(LE32) + sizeof(*dbgCET)) : 0);
if (use_tls_callbacks) if (use_tls_callbacks)
tls_handler_offset = linker->getSymbolOffset("PETLSC2") + upxsection; tls_handler_offset = linker->getSymbolOffset("PETLSC2") + upxsection;
@@ -2520,6 +2548,11 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
ODSIZE(PEDIR_LOAD_CONFIG) = soloadconf; ODSIZE(PEDIR_LOAD_CONFIG) = soloadconf;
ic += soloadconf; ic += soloadconf;
if (dbgCET) {
ODADDR(PEDIR_DEBUG) = ic;
ODSIZE(PEDIR_DEBUG) = sizeof(*dbgCET);
ic += sizeof(LE32) + ODSIZE(PEDIR_DEBUG);
}
const bool rel_at_sections_start = last_section_rsrc_only; const bool rel_at_sections_start = last_section_rsrc_only;
ic = ncsection; ic = ncsection;
@@ -2665,6 +2698,19 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
fo->write(ibuf, sizeof(LEXX) - ic); fo->write(ibuf, sizeof(LEXX) - ic);
fo->write(otls, aligned_sotls); fo->write(otls, aligned_sotls);
fo->write(oloadconf, soloadconf); fo->write(oloadconf, soloadconf);
if (dbgCET) {
ic = fo->getBytesWritten();
dbgCET->fpos = ic + sizeof(*dbgCET);
dbgCET->rva = rvamin + 0x400 + dbgCET->fpos; // 0x400 => soheaders
LE32 word;
set_le32(&word, IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT);
if (0) { // set all bytes t0 zero
memset(dbgCET, 0, sizeof(*dbgCET));
set_le32(&word, 0);
}
fo->write(dbgCET, sizeof(*dbgCET));
fo->write(&word, sizeof(word));
}
if ((ic = fo->getBytesWritten() & fam1) != 0) if ((ic = fo->getBytesWritten() & fam1) != 0)
fo->write(ibuf, oh.filealign - ic); fo->write(ibuf, oh.filealign - ic);
if (!last_section_rsrc_only) if (!last_section_rsrc_only)
@@ -2685,7 +2731,7 @@ void PeFile::pack0(OutputFile *fo, ht &ih, ht &oh, unsigned subsystem_mask,
fo->write(ibuf, oh.filealign - ic); fo->write(ibuf, oh.filealign - ic);
} }
#if 0 #if 0 // (debug) print section sizes
printf("%-13s: program hdr : %8d bytes\n", getName(), (int) sizeof(oh)); printf("%-13s: program hdr : %8d bytes\n", getName(), (int) sizeof(oh));
printf("%-13s: sections : %8d bytes\n", getName(), (int) sizeof(osection[0]) * oobjs); printf("%-13s: sections : %8d bytes\n", getName(), (int) sizeof(osection[0]) * oobjs);
printf("%-13s: ident : %8d bytes\n", getName(), (int) identsize); printf("%-13s: ident : %8d bytes\n", getName(), (int) identsize);
@@ -2760,12 +2806,12 @@ void PeFile::rebuildRelocs(SPAN_S(byte) & extra_info, unsigned bits, unsigned fl
SPAN_S_VAR(byte, const wrkmem, mb_wrkmem); SPAN_S_VAR(byte, const wrkmem, mb_wrkmem);
for (unsigned ic = 0; ic < relocnum; ic++) { for (unsigned ic = 0; ic < relocnum; ic++) {
OPTR_VAR(byte, const p, obuf + get_le32(wrkmem + 4 * ic)); OPTR_VAR(byte, const p, obuf + get_le32(wrkmem + sizeof(LE32) * ic));
if (bits == 32) if (bits == 32)
set_le32(p, get_le32(p) + imagebase + rvamin); set_le32(p, get_le32(p) + imagebase + rvamin);
else else
set_le64(p, get_le64(p) + imagebase + rvamin); set_le64(p, get_le64(p) + imagebase + rvamin);
rel.add_reloc(rvamin + get_le32(wrkmem + 4 * ic), rel.add_reloc(rvamin + get_le32(wrkmem + sizeof(LE32) * ic),
bits == 32 ? IMAGE_REL_BASED_HIGHLOW : IMAGE_REL_BASED_DIR64); bits == 32 ? IMAGE_REL_BASED_HIGHLOW : IMAGE_REL_BASED_DIR64);
} }
rel.finish(oxrelocs, soxrelocs); rel.finish(oxrelocs, soxrelocs);
@@ -3020,8 +3066,6 @@ void PeFile::unpack0(OutputFile *fo, const ht &ih, ht &oh, ord_mask_t ord_mask,
// memset(eistart, 0, ptr_udiff_bytes(extra_info, eistart) + 4); // memset(eistart, 0, ptr_udiff_bytes(extra_info, eistart) + 4);
// fill the data directory // fill the data directory
ODADDR(PEDIR_DEBUG) = 0;
ODSIZE(PEDIR_DEBUG) = 0;
ODADDR(PEDIR_IAT) = 0; ODADDR(PEDIR_IAT) = 0;
ODSIZE(PEDIR_IAT) = 0; ODSIZE(PEDIR_IAT) = 0;
ODADDR(PEDIR_BOUND_IMPORT) = 0; ODADDR(PEDIR_BOUND_IMPORT) = 0;
+11
View File
@@ -519,6 +519,17 @@ protected:
void build(char *base, unsigned newoffs); void build(char *base, unsigned newoffs);
unsigned getsize() const { return size; } unsigned getsize() const { return size; }
}; };
struct alignas(1) DebugDir final {
LE32 flags, date_time, version;
LE32 type;
LE32 size;
LE32 rva;
LE32 fpos;
};
enum { IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS = 20 };
enum { IMAGE_DLLCHARACTERISTICS_EX_CET_COMPAT = 0x001 };
struct DebugDir *dbgCET = nullptr;
}; };
class PeFile32 : public PeFile { class PeFile32 : public PeFile {
+9 -7
View File
@@ -167,7 +167,7 @@ all: $$(all.targets)
@echo "timestamp" > $@ @echo "timestamp" > $@
.DELETE_ON_ERROR: .upx-stubtools-stamp .DELETE_ON_ERROR: .upx-stubtools-stamp
%/.tmp-stamp: %/.tmp-stamp:
@mkdir -p $(dir $@) @mkdir -p "$(dir $@)"
@echo "timestamp" > $@ @echo "timestamp" > $@
.PRECIOUS: %/.tmp-stamp .PRECIOUS: %/.tmp-stamp
.all-stamp: $$(STUBS) .all-stamp: $$(STUBS)
@@ -208,6 +208,7 @@ ECHO_e = /bin/echo -e
ECHO_E = /bin/echo -E ECHO_E = /bin/echo -E
PERL = perl PERL = perl
PYTHON2 = python2 PYTHON2 = python2
PYTHON3 = python3
UNIX2DOS := $(PERL) -i -pe 's/$$/\r/;' UNIX2DOS := $(PERL) -i -pe 's/$$/\r/;'
# trim (strip) trailing whitespace # trim (strip) trailing whitespace
@@ -240,15 +241,15 @@ define tc
endef endef
# default tools # default tools
tc.default.bin2h = $(PYTHON2) $(top_srcdir)/src/stub/scripts/bin2h.py --ident=auto-stub tc.default.bin2h = $(PYTHON3) "$(top_srcdir)/src/stub/scripts/bin2h.py" --ident=auto-stub
##tc.default.bin2h-c = $(call tc,bin2h) --compress=14,15,0 ##tc.default.bin2h-c = $(call tc,bin2h) --compress=14,15,0
tc.default.bin2h-c = $(call tc,bin2h) --compress=0 tc.default.bin2h-c = $(call tc,bin2h) --compress=0
tc.default.brandelf = $(PYTHON2) $(top_srcdir)/src/stub/scripts/brandelf.py $(if $(tc_bfdname),--bfdname=$(tc_bfdname)) tc.default.brandelf = $(PYTHON3) "$(top_srcdir)/src/stub/scripts/brandelf.py" $(if $(tc_bfdname),--bfdname=$(tc_bfdname))
tc.default.gpp_inc = $(PYTHON2) $(top_srcdir)/src/stub/scripts/gpp_inc.py tc.default.gpp_inc = $(PYTHON3) "$(top_srcdir)/src/stub/scripts/gpp_inc.py"
tc.default.gpp_mkdep = $(PYTHON2) $(top_srcdir)/src/stub/scripts/gpp_inc.py -o /dev/null tc.default.gpp_mkdep = $(PYTHON3) "$(top_srcdir)/src/stub/scripts/gpp_inc.py" -o /dev/null
tc.default.pp-as = i386-linux-gcc-3.4.6 -E -nostdinc -x assembler-with-cpp -Wall tc.default.pp-as = i386-linux-gcc-3.4.6 -E -nostdinc -x assembler-with-cpp -Wall
tc.default.sstrip = sstrip-20060518 tc.default.sstrip = sstrip-20060518
tc.default.xstrip = $(PYTHON2) $(top_srcdir)/src/stub/scripts/xstrip.py tc.default.xstrip = $(PYTHON3) "$(top_srcdir)/src/stub/scripts/xstrip.py"
# default multiarch-binutils # default multiarch-binutils
tc.default.m-ar = multiarch-ar-2.17 tc.default.m-ar = multiarch-ar-2.17
@@ -318,7 +319,7 @@ endef
define tc.default.f-embed_objinfo_without_xstrip_keep_dot_text define tc.default.f-embed_objinfo_without_xstrip_keep_dot_text
chmod a-x $1 chmod a-x $1
$(call tc,objcopy) -R .data -R .bss $1 $(call tc,objcopy) -R .data -R .bss $1
$(call tc,objcopy) -R .comment -R .note -R .note.GNU-stack -R .reginfo $1 $(call tc,objcopy) -R .comment -R .note -R .note.GNU-stack -R .reginfo $1
$(call tc,objcopy) --strip-unneeded --keep-symbol=_start --keep-symbol=upx_so_main $1 $(call tc,objcopy) --strip-unneeded --keep-symbol=_start --keep-symbol=upx_so_main $1
# #
@@ -550,6 +551,7 @@ amd64-win64.pe.h : tc_objdump_disasm_options = -M intel-mnemonic
tc.amd64-win64.pe.gcc = amd64-linux-gcc-4.1.1 -m64 -nostdinc -DWINDOWS_BACK=1 -MMD -MT $@ tc.amd64-win64.pe.gcc = amd64-linux-gcc-4.1.1 -m64 -nostdinc -DWINDOWS_BACK=1 -MMD -MT $@
tc.amd64-win64.pe.gcc += -fno-exceptions -fno-asynchronous-unwind-tables tc.amd64-win64.pe.gcc += -fno-exceptions -fno-asynchronous-unwind-tables
tc.amd64-win64.pe.gcc += -mno-red-zone
tc.amd64-win64.pe.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werror tc.amd64-win64.pe.gcc += -Wall -W -Wcast-align -Wcast-qual -Wstrict-prototypes -Wwrite-strings -Werror
tc.amd64-win64.pe.objdump = multiarch-objdump-2.23.90 tc.amd64-win64.pe.objdump = multiarch-objdump-2.23.90
+182 -74
View File
@@ -1,5 +1,5 @@
/* amd64-linux.elf-entry.h /* amd64-linux.elf-entry.h
created from amd64-linux.elf-entry.bin, 1141 (0x475) bytes created from amd64-linux.elf-entry.bin, 2869 (0xb35) bytes
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
@@ -32,81 +32,189 @@
/* clang-format off */ /* clang-format off */
#define STUB_AMD64_LINUX_ELF_ENTRY_SIZE 1141 #define STUB_AMD64_LINUX_ELF_ENTRY_SIZE 2869
#define STUB_AMD64_LINUX_ELF_ENTRY_ADLER32 0xd3b74a90 #define STUB_AMD64_LINUX_ELF_ENTRY_ADLER32 0xf865154a
#define STUB_AMD64_LINUX_ELF_ENTRY_CRC32 0x52b418e2 #define STUB_AMD64_LINUX_ELF_ENTRY_CRC32 0xe81955ed
unsigned char stub_amd64_linux_elf_entry[1141] = { unsigned char stub_amd64_linux_elf_entry[2869] = {
/* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0010 */ 1, 0, 62, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0010 */ 1, 0, 62, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0020 */ 0, 0, 0, 0, 0, 0, 0, 0, 16, 2, 0, 0, 0, 0, 0, 0, /* 0x0020 */ 0, 0, 0, 0, 0, 0, 0, 0, 80, 5, 0, 0, 0, 0, 0, 0,
/* 0x0030 */ 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, /* 0x0030 */ 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0,
/* 0x0040 */ 243, 15, 30,250, 89, 84, 95, 81, 82, 49,192, 72,175,117,252, 72, /* 0x0040 */ 243, 15, 30,250, 89, 84, 95, 81, 82, 76,141, 61, 0, 0, 0, 0,
/* 0x0050 */ 175,117,252, 87,186, 0, 16, 0, 0, 94, 72,173,133,192,116, 8, /* 0x0050 */ 87, 41,210, 82, 72,141, 5, 45, 0, 0, 0, 80,104, 4, 0, 0,
/* 0x0060 */ 131,248, 6, 72,173,117,243,146, 88, 72,247,218, 82, 80,104,117, /* 0x0060 */ 4, 72,141, 5, 43, 0, 0, 0, 80, 76,141, 61,219, 2, 0, 0,
/* 0x0070 */ 112, 88, 0, 84, 95,106, 16, 94,184, 63, 1, 0, 0, 15, 5,133, /* 0x0070 */ 84, 94,106, 11, 95,106, 8, 65, 90,106, 13, 88, 15, 5, 72,131,
/* 0x0080 */ 192,121, 29,133,246,116, 4, 49,246,235,237, 72,141, 53, 28, 1, /* 0x0080 */ 196, 32, 95,233,216, 2, 0, 0,243, 15, 30,250,184, 15, 0, 0,
/* 0x0090 */ 0, 0,173,146,173, 86,150, 95,106, 2, 88,232, 0, 1, 0, 0, /* 0x0090 */ 0, 15, 5,243, 15, 30,250, 82,186, 26, 0, 0, 0, 72,141, 53,
/* 0x00a0 */ 73,137,196, 89, 72,141, 61,145,255,255,255,139, 15, 72, 41,207, /* 0x00a0 */ 111, 0, 0, 0,106, 2, 95,106, 1, 88, 15, 5, 49,246, 72,141,
/* 0x00b0 */ 72,141, 53, 0, 0, 0, 0,173,147, 65,137,221,173,146,131,194, /* 0x00b0 */ 61,120, 0, 0, 0,106, 2, 88, 15, 5, 73,137,196,187, 0, 16,
/* 0x00c0 */ 16, 82,106,255, 87, 72, 41,217, 81, 72, 1,251, 83, 84, 93, 72, /* 0x00c0 */ 0, 0, 72, 41,220,137,218, 84, 94, 76,137,231, 49,192, 15, 5,
/* 0x00d0 */ 41,212, 72,131,228,192, 84, 95,173, 80,173,102,131,248, 2,116, /* 0x00d0 */ 133,192,126, 14,137,194, 84, 94,106, 2, 95,106, 1, 88, 15, 5,
/* 0x00e0 */ 1,244, 88, 72, 1,240, 80, 85, 49,219, 49,201, 72,141, 21,204, /* 0x00e0 */ 235,227, 76,137,231, 72, 1,220,106, 3, 88, 15, 5, 90,106, 57,
/* 0x00f0 */ 0, 0, 0,106,255, 93,252,168,164,255,210,114,251,141, 65, 1, /* 0x00f0 */ 88,232, 0, 0, 0, 0,133,192, 15,132,141, 1, 0, 0,235,254,
/* 0x0100 */ 255,210, 17,192,255,210,115,248,131,232, 3,114, 12,193,224, 8, /* 0x0100 */ 47,112,114,111, 99, 47,115,101,108,102, 47, 99,109,100,108,105,
/* 0x0110 */ 172,131,240,255,116, 47, 72, 99,232,141, 65, 1,255,210, 17,201, /* 0x0110 */ 110,101, 0, 10, 10, 83, 73, 71, 83, 69, 71, 86, 32, 97,100,100,
/* 0x0120 */ 255,210, 17,201,117, 13,137,193,131,192, 2,255,210, 17,201,255, /* 0x0120 */ 114,101,115,115, 32,115,112, 97, 99,101, 58, 10, 0, 47,112,114,
/* 0x0130 */ 210,115,248,129,253, 0,243,255,255, 17,193, 86, 72,141, 52, 47, /* 0x0130 */ 111, 99, 47,115,101,108,102, 47,109, 97,112,115, 0, 45,113, 0,
/* 0x0140 */ 243,164, 94,235,180, 93, 89, 72, 57,206,116, 1,244, 72,139, 69, /* 0x0140 */ 47,117,115,114, 47, 98,105,110, 47,103,100, 98, 0,115,101,116,
/* 0x0150 */ 48, 72,137, 4, 36, 72,139, 85, 32, 72,131,234, 16, 84, 94, 76, /* 0x0150 */ 32,112,114,111,109,112,116, 10,105,110,102,111, 32,105,110,102,
/* 0x0160 */ 137,231, 82,106, 1, 88,232, 53, 0, 0, 0, 72, 1,198, 41,194, /* 0x0160 */ 101,114,105,111,114,115, 10,112,114,105,110,116, 32, 34,114, 56,
/* 0x0170 */ 117,241, 94, 85, 92, 77, 49,201, 77,137,224,106, 1, 65, 90,106, /* 0x0170 */ 32, 45, 32,114, 49, 53, 34, 10,120, 47, 56,120,103, 32, 36,114,
/* 0x0180 */ 5, 90, 41,255,106, 9, 88,232, 20, 0, 0, 0, 80, 72,137, 69, /* 0x0180 */ 100,120, 32, 43, 32, 53, 42, 56, 10,112,114,105,110,116, 32, 34,
/* 0x0190 */ 24, 65, 80, 95,106, 3, 88, 15, 5, 88, 72,131,192, 8,255,224, /* 0x0190 */ 114,100,105, 44, 32,114,115,105, 44, 32,114, 98,112, 44, 32,114,
/* 0x01a0 */ 80, 15, 5, 89, 72, 61, 0,240,255,255,114, 1,244,195,192, 1, /* 0x01a0 */ 98,120, 34, 10,120, 47, 52,120,103, 10,112,114,105,110,116, 32,
/* 0x01b0 */ 0, 0, 2, 0, 65, 0, 47,100,101,118, 47,115,104,109, 0,243, /* 0x01b0 */ 34,114,100,120, 44, 32,114, 97,120, 44, 32,114, 99,120, 44, 32,
/* 0x01c0 */ 15, 30,250, 1,219,116, 2,243,195,139, 30, 72,131,238,252, 17, /* 0x01c0 */ 114,115,112, 34, 10,120, 47, 52,120,103, 10,112,114,105,110,116,
/* 0x01d0 */ 219,243,195, 0, 0, 0, 0, 0,102,105,108,101, 32,102,111,114, /* 0x01d0 */ 32, 34,114,105,112, 44, 32,101,102,108, 34, 10,120, 47, 50,120,
/* 0x01e0 */ 109, 97,116, 32,101,108,102, 54, 52, 45,120, 56, 54, 45, 54, 52, /* 0x01e0 */ 103, 10,115,101,116, 32, 36,112, 99, 32, 61, 32, 42, 40,108,111,
/* 0x01f0 */ 10, 10, 83,101, 99,116,105,111,110,115, 58, 10, 73,100,120, 32, /* 0x01f0 */ 110,103, 32, 42, 41, 40, 36,114,100,120, 32, 43, 32, 49, 54, 56,
/* 0x0200 */ 78, 97,109,101, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 83,105, /* 0x0200 */ 41, 10,112,114,105,110,116, 32, 34,102, 97,117,108,116,105,110,
/* 0x0210 */ 122,101, 32, 32, 32, 32, 32, 32, 86, 77, 65, 32, 32, 32, 32, 32, /* 0x0210 */ 103, 32,105,110,115,116,114, 34, 10,120, 47,105, 32, 36,112, 99,
/* 0x0220 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 76, 77, 65, 32, 32, 32, /* 0x0220 */ 10,112,114,105,110,116, 32, 34,102, 97,117,108,116, 32, 99,111,
/* 0x0230 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 70,105,108,101, /* 0x0230 */ 110,116,101,120,116, 34, 10,120, 47, 49, 54,105, 32, 36,112, 99,
/* 0x0240 */ 32,111,102,102, 32, 32, 65,108,103,110, 32, 32, 70,108, 97,103, /* 0x0240 */ 32, 45, 32, 48,120, 50, 48, 10,112,114,105,110,116, 32, 34,117,
/* 0x0250 */ 115, 10, 32, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, 88, 32, 32, /* 0x0250 */ 115,101,114, 32,115,116, 97, 99,107, 34, 10,120, 47, 54, 52,120,
/* 0x0260 */ 32, 32, 32, 32, 48, 49, 57, 51, 32, 32, 48, 32, 32, 48, 32, 32, /* 0x0260 */ 103, 32, 42, 40,108,111,110,103, 32, 42, 41, 40, 36,114,100,120,
/* 0x0270 */ 48, 52, 48, 32, 32, 50, 42, 42, 48, 32, 32, 67, 79, 78, 84, 69, /* 0x0270 */ 32, 43, 32, 53, 42, 56, 32, 43, 32, 49, 53, 42, 56, 41, 10,107,
/* 0x0280 */ 78, 84, 83, 10, 32, 32, 49, 32, 69, 76, 70, 77, 65, 73, 78, 90, /* 0x0280 */ 105,108,108, 10,113,117,105,116, 32, 49, 0, 72,129,236, 0, 16,
/* 0x0290 */ 32, 32, 32, 32, 32, 32, 48, 52, 32, 32, 48, 32, 32, 48, 32, 32, /* 0x0290 */ 0, 0, 72,141, 61,103,254,255,255,106, 0, 94,106, 2, 88,232,
/* 0x02a0 */ 48, 49,100, 52, 32, 32, 50, 42, 42, 50, 32, 32, 67, 79, 78, 84, /* 0x02a0 */ 0, 0, 0, 0, 80, 95, 84, 94,104, 0, 16, 0, 0, 90,106, 0,
/* 0x02b0 */ 69, 78, 84, 83, 10, 83, 89, 77, 66, 79, 76, 32, 84, 65, 66, 76, /* 0x02b0 */ 88,232, 0, 0, 0, 0,106, 3, 88,232, 0, 0, 0, 0,106,110,
/* 0x02c0 */ 69, 58, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x02c0 */ 88, 15, 5, 80, 94, 49,192, 80, 80, 84, 95,232, 89, 0, 0, 0,
/* 0x02d0 */ 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, 77, /* 0x02d0 */ 84, 94,106, 0, 86, 72,131,198, 16, 86, 72,141, 5, 92,254,255,
/* 0x02e0 */ 65, 73, 78, 90, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, 90, 10, /* 0x02e0 */ 255, 80, 72,131,192, 3, 80, 49,255,106, 3, 88, 15, 5, 80, 84,
/* 0x02f0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x02f0 */ 95,106, 22, 88,232, 0, 0, 0, 0, 95, 72,193,239, 32,104, 62,
/* 0x0300 */ 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, 77, 65, 73, 78, /* 0x0300 */ 1, 0, 0, 90, 72,141, 53, 66,254,255,255,106, 1, 88,232, 0,
/* 0x0310 */ 88, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, 88, 10, 48, 48, 48, /* 0x0310 */ 0, 0, 0,106, 3, 88, 15, 5,106, 0, 90, 84, 94, 72,139, 62,
/* 0x0320 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32,103, 32, /* 0x0320 */ 106, 59, 88,232, 0, 0, 0, 0,244,106, 10, 89,137,240,232, 4,
/* 0x0330 */ 32, 32, 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 32, 48, /* 0x0330 */ 0, 0, 0,198, 7, 0,195, 49,210,247,241, 82,133,192,116, 5,
/* 0x0340 */ 32, 95,115,116, 97,114,116, 10, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x0340 */ 232,242,255,255,255, 88,131,192, 48,170,195,243, 15, 30,250,106,
/* 0x0350 */ 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 32, 32, 32, 32, 32, 32, /* 0x0350 */ 8, 65, 90, 49,210, 49,246,106, 11, 95,106, 13, 88, 15, 5,195,
/* 0x0360 */ 32, 42, 85, 78, 68, 42, 32, 48, 32, 79, 95, 66, 73, 78, 70, 79, /* 0x0360 */ 49,192, 72,175,117,252, 72,175,117,252, 87,186, 0, 16, 0, 0,
/* 0x0370 */ 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, /* 0x0370 */ 94, 72,173,133,192,116, 8,131,248, 6, 72,173,117,243,146, 88,
/* 0x0380 */ 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, /* 0x0380 */ 72,247,218, 82, 80,104,117,112, 88, 0, 84, 95,106, 16, 94,184,
/* 0x0390 */ 78, 88, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 32, 32, /* 0x0390 */ 63, 1, 0, 0, 15, 5,133,192,121, 29,133,246,116, 4, 49,246,
/* 0x03a0 */ 32, 32, 32, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32, 32, /* 0x03a0 */ 235,237, 72,141, 53, 38, 1, 0, 0,173,146,173, 86,150, 95,106,
/* 0x03b0 */ 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 10, 48, 48, /* 0x03b0 */ 2, 88,232, 10, 1, 0, 0, 73,137,196, 89, 72,141, 61, 0, 0,
/* 0x03c0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 55, 51, 32, 82, /* 0x03c0 */ 0, 0,139, 15, 72, 41,207, 72,141, 53, 0, 0, 0, 0,173,147,
/* 0x03d0 */ 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32, 32, 32, 32, /* 0x03d0 */ 65,137,221,173,146,131,194, 16, 82,106,255, 87, 72, 41,217, 81,
/* 0x03e0 */ 32, 69, 76, 70, 77, 65, 73, 78, 90, 43, 48,120,102,102,102,102, /* 0x03e0 */ 72, 1,251, 83, 84, 93, 72, 41,212, 72,131,228,192, 84, 95,173,
/* 0x03f0 */ 102,102,102,102,102,102,102,102,102,102,102, 99, 10, 10, 82, 69, /* 0x03f0 */ 80,173,102,131,248, 2,116, 1,244, 88, 72, 1,240, 80, 85, 49,
/* 0x0400 */ 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, 79, 82, 68, 83, /* 0x0400 */ 219, 49,201, 72,141, 21,214, 0, 0, 0,106,255, 93,252,168,164,
/* 0x0410 */ 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, 78, 90, 93, 58, /* 0x0410 */ 255,210,114,251,141, 65, 1,255,210, 17,192,255,210,115,248,131,
/* 0x0420 */ 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 0x0420 */ 232, 3,114, 12,193,224, 8,172,131,240,255,116, 47, 72, 99,232,
/* 0x0430 */ 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 0x0430 */ 141, 65, 1,255,210, 17,201,255,210, 17,201,117, 13,137,193,131,
/* 0x0440 */ 32, 32, 32, 32, 86, 65, 76, 85, 69, 10, 48, 48, 48, 48, 48, 48, /* 0x0440 */ 192, 2,255,210, 17,201,255,210,115,248,129,253, 0,243,255,255,
/* 0x0450 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32, 82, 95, 88, 56, 54, /* 0x0450 */ 17,193, 86, 72,141, 52, 47,243,164, 94,235,180, 93, 89, 72, 57,
/* 0x0460 */ 95, 54, 52, 95, 51, 50, 32, 32, 32, 32, 32, 32, 32, 79, 95, 66, /* 0x0460 */ 206,116, 1,244, 72,139, 69, 48, 72,137, 4, 36, 76,137,124, 36,
/* 0x0470 */ 73, 78, 70, 79, 10 /* 0x0470 */ 8, 72,139, 85, 32, 72,131,234, 16, 84, 94, 76,137,231, 82,106,
/* 0x0480 */ 1, 88,232, 58, 0, 0, 0, 72, 1,198, 41,194,117,241, 94, 85,
/* 0x0490 */ 92, 77, 49,201, 77,137,224,106, 1, 65, 90,106, 5, 90, 41,255,
/* 0x04a0 */ 106, 9, 88,232, 25, 0, 0, 0, 80, 72,137, 69, 24, 65, 80, 95,
/* 0x04b0 */ 106, 3, 88, 15, 5, 88, 72,131,192, 16,255,224,243, 15, 30,250,
/* 0x04c0 */ 195, 80, 15, 5, 89, 72, 61, 0,240,255,255,114, 1,244,195,192,
/* 0x04d0 */ 1, 0, 0, 2, 0, 65, 0, 47,100,101,118, 47,115,104,109, 0,
/* 0x04e0 */ 243, 15, 30,250, 1,219,116, 2,243,195,139, 30, 72,131,238,252,
/* 0x04f0 */ 17,219,243,195, 0, 0, 0, 0,102,105,108,101, 32,102,111,114,
/* 0x0500 */ 109, 97,116, 32,101,108,102, 54, 52, 45,120, 56, 54, 45, 54, 52,
/* 0x0510 */ 10, 10, 83,101, 99,116,105,111,110,115, 58, 10, 73,100,120, 32,
/* 0x0520 */ 78, 97,109,101, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 83,105,
/* 0x0530 */ 122,101, 32, 32, 32, 32, 32, 32, 86, 77, 65, 32, 32, 32, 32, 32,
/* 0x0540 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 76, 77, 65, 32, 32, 32,
/* 0x0550 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 70,105,108,101,
/* 0x0560 */ 32,111,102,102, 32, 32, 65,108,103,110, 32, 32, 70,108, 97,103,
/* 0x0570 */ 115, 10, 32, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, 88, 32, 32,
/* 0x0580 */ 32, 32, 32, 32, 48, 49, 48, 32, 32, 48, 32, 32, 48, 32, 32, 48,
/* 0x0590 */ 52, 48, 32, 32, 50, 42, 42, 48, 32, 32, 67, 79, 78, 84, 69, 78,
/* 0x05a0 */ 84, 83, 10, 32, 32, 49, 32, 69, 76, 70, 83, 73, 71, 83, 69, 71,
/* 0x05b0 */ 86, 32, 32, 32, 32, 48, 51, 49, 48, 32, 32, 48, 32, 32, 48, 32,
/* 0x05c0 */ 32, 48, 53, 48, 32, 32, 50, 42, 42, 48, 32, 32, 67, 79, 78, 84,
/* 0x05d0 */ 69, 78, 84, 83, 10, 32, 32, 50, 32, 69, 76, 70, 77, 65, 73, 78,
/* 0x05e0 */ 88, 50, 32, 32, 32, 32, 32, 48, 49, 57, 52, 32, 32, 48, 32, 32,
/* 0x05f0 */ 48, 32, 32, 48, 51, 54, 48, 32, 32, 50, 42, 42, 48, 32, 32, 67,
/* 0x0600 */ 79, 78, 84, 69, 78, 84, 83, 10, 32, 32, 51, 32, 69, 76, 70, 77,
/* 0x0610 */ 65, 73, 78, 90, 32, 32, 32, 32, 32, 32, 48, 52, 32, 32, 48, 32,
/* 0x0620 */ 32, 48, 32, 32, 48, 52,102, 52, 32, 32, 50, 42, 42, 50, 32, 32,
/* 0x0630 */ 67, 79, 78, 84, 69, 78, 84, 83, 10, 83, 89, 77, 66, 79, 76, 32,
/* 0x0640 */ 84, 65, 66, 76, 69, 58, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0650 */ 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32,
/* 0x0660 */ 69, 76, 70, 77, 65, 73, 78, 88, 32, 48, 32, 69, 76, 70, 77, 65,
/* 0x0670 */ 73, 78, 88, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0680 */ 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70,
/* 0x0690 */ 77, 65, 73, 78, 88, 50, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78,
/* 0x06a0 */ 88, 50, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x06b0 */ 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, 77,
/* 0x06c0 */ 65, 73, 78, 90, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, 90, 10,
/* 0x06d0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x06e0 */ 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, 83, 73, 71, 83,
/* 0x06f0 */ 69, 71, 86, 32, 48, 32, 69, 76, 70, 83, 73, 71, 83, 69, 71, 86,
/* 0x0700 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0710 */ 48, 32,103, 32, 32, 32, 32, 32, 32, 32, 69, 76, 70, 77, 65, 73,
/* 0x0720 */ 78, 88, 32, 48, 32, 95,115,116, 97,114,116, 10, 48, 48, 48, 48,
/* 0x0730 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 32, 32,
/* 0x0740 */ 32, 32, 32, 32, 32, 42, 85, 78, 68, 42, 32, 48, 32, 79, 95, 66,
/* 0x0750 */ 73, 78, 70, 79, 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78,
/* 0x0760 */ 32, 82, 69, 67, 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76,
/* 0x0770 */ 70, 77, 65, 73, 78, 88, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32,
/* 0x0780 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 84, 89, 80, 69, 32, 32,
/* 0x0790 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85,
/* 0x07a0 */ 69, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x07b0 */ 48, 99, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50,
/* 0x07c0 */ 32, 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,
/* 0x07d0 */ 120, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,
/* 0x07e0 */ 56, 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69,
/* 0x07f0 */ 67, 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76, 70, 83, 73,
/* 0x0800 */ 71, 83, 69, 71, 86, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32, 32,
/* 0x0810 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32,
/* 0x0820 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69,
/* 0x0830 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 97,
/* 0x0840 */ 50, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32,
/* 0x0850 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120,
/* 0x0860 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,100,
/* 0x0870 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 53,
/* 0x0880 */ 48, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32,
/* 0x0890 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120,
/* 0x08a0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,100,
/* 0x08b0 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 54,
/* 0x08c0 */ 50, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32,
/* 0x08d0 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120,
/* 0x08e0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,100,
/* 0x08f0 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 54,
/* 0x0900 */ 97, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32,
/* 0x0910 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120,
/* 0x0920 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,100,
/* 0x0930 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 97,
/* 0x0940 */ 53, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32,
/* 0x0950 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120,
/* 0x0960 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,100,
/* 0x0970 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50, 98,
/* 0x0980 */ 102, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32,
/* 0x0990 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120,
/* 0x09a0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,100,
/* 0x09b0 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 50,100,
/* 0x09c0 */ 52, 32, 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32,
/* 0x09d0 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120,
/* 0x09e0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 53,100,
/* 0x09f0 */ 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67,
/* 0x0a00 */ 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73,
/* 0x0a10 */ 78, 88, 50, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 32,
/* 0x0a20 */ 32, 32, 32, 32, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32,
/* 0x0a30 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 10, 48,
/* 0x0a40 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 53,101, 32,
/* 0x0a50 */ 82, 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32, 32, 32,
/* 0x0a60 */ 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 43, 48,120,102,102,102,
/* 0x0a70 */ 102,102,102,102,102,102,102,102,102,102,102,102, 56, 10, 48, 48,
/* 0x0a80 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 54, 97, 32, 82,
/* 0x0a90 */ 95, 88, 56, 54, 95, 54, 52, 95, 80, 67, 51, 50, 32, 32, 32, 32,
/* 0x0aa0 */ 32, 69, 76, 70, 77, 65, 73, 78, 90, 43, 48,120,102,102,102,102,
/* 0x0ab0 */ 102,102,102,102,102,102,102,102,102,102,102, 99, 10, 10, 82, 69,
/* 0x0ac0 */ 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, 79, 82, 68, 83,
/* 0x0ad0 */ 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, 78, 90, 93, 58,
/* 0x0ae0 */ 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32,
/* 0x0af0 */ 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
/* 0x0b00 */ 32, 32, 32, 32, 86, 65, 76, 85, 69, 10, 48, 48, 48, 48, 48, 48,
/* 0x0b10 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32, 82, 95, 88, 56, 54,
/* 0x0b20 */ 95, 54, 52, 95, 51, 50, 32, 32, 32, 32, 32, 32, 32, 79, 95, 66,
/* 0x0b30 */ 73, 78, 70, 79, 10
}; };
+1314 -1313
View File
File diff suppressed because it is too large Load Diff
+1184 -1181
View File
File diff suppressed because it is too large Load Diff
+962 -834
View File
File diff suppressed because it is too large Load Diff
+2267 -2270
View File
File diff suppressed because it is too large Load Diff
+969 -840
View File
File diff suppressed because it is too large Load Diff
+2275 -2278
View File
File diff suppressed because it is too large Load Diff
+188 -106
View File
@@ -1,5 +1,5 @@
/* arm64-linux.elf-entry.h /* arm64-linux.elf-entry.h
created from arm64-linux.elf-entry.bin, 1656 (0x678) bytes created from arm64-linux.elf-entry.bin, 2971 (0xb9b) bytes
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
@@ -32,113 +32,195 @@
/* clang-format off */ /* clang-format off */
#define STUB_ARM64_LINUX_ELF_ENTRY_SIZE 1656 #define STUB_ARM64_LINUX_ELF_ENTRY_SIZE 2971
#define STUB_ARM64_LINUX_ELF_ENTRY_ADLER32 0xebefbc2c #define STUB_ARM64_LINUX_ELF_ENTRY_ADLER32 0x0d9b4202
#define STUB_ARM64_LINUX_ELF_ENTRY_CRC32 0x6e19662b #define STUB_ARM64_LINUX_ELF_ENTRY_CRC32 0x7209b84d
unsigned char stub_arm64_linux_elf_entry[1656] = { unsigned char stub_arm64_linux_elf_entry[2971] = {
/* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0000 */ 127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0010 */ 1, 0,183, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0010 */ 1, 0,183, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 0x0020 */ 0, 0, 0, 0, 0, 0, 0, 0, 64, 4, 0, 0, 0, 0, 0, 0, /* 0x0020 */ 0, 0, 0, 0, 0, 0, 0, 0, 64, 8, 0, 0, 0, 0, 0, 0,
/* 0x0030 */ 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, /* 0x0030 */ 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0,
/* 0x0040 */ 0, 0, 0, 0,224, 7,191,169,211,255,255, 24,224, 99, 0,145, /* 0x0040 */ 0, 0, 0, 0,224, 7,191,169,211,255,255, 24, 18, 0, 0, 16,
/* 0x0050 */ 76, 0, 0,148, 75, 0, 0,148,246, 3, 0,170,255,131, 0,209, /* 0x0050 */ 32, 20, 0, 16,129, 0,128,210,224, 7,188,169,255, 15, 0,249,
/* 0x0060 */ 1, 8,193,168, 63, 24, 0,113, 96, 0, 0, 84,161,255,255, 53, /* 0x0060 */ 255, 19, 0,249, 3, 1,128,210,226, 3, 31,170,225, 3, 0,145,
/* 0x0070 */ 34, 0,160,210,250, 3, 2,203,250, 3, 0,249, 0, 0, 0,148, /* 0x0070 */ 96, 1,128, 82,200, 16,128, 82, 1, 0, 0,212,255, 3, 1,145,
/* 0x0080 */ 244, 3, 30,170, 1, 2,128, 82, 0, 0, 0, 16,232, 34,128, 82, /* 0x0080 */ 114, 25, 0, 16,209, 0, 0, 20, 47,112,114,111, 99, 47,115,101,
/* 0x0090 */ 1, 0, 0,212, 0, 2,248, 54, 97, 0, 0, 52,225, 3, 31, 42, /* 0x0090 */ 108,102, 47, 99,109,100,108,105,110,101, 0, 10, 10, 83, 73, 71,
/* 0x00a0 */ 250,255,255, 23, 6, 0, 0,148,192, 1, 0, 0, 2, 64, 64, 0, /* 0x00a0 */ 83, 69, 71, 86, 32, 97,100,100,114,101,115,115, 32,115,112, 97,
/* 0x00b0 */ 47,100,101,118, 47,115,104,109, 0, 0, 0, 0,195, 71, 64,184, /* 0x00b0 */ 99,101, 58, 10, 0, 47,112,114,111, 99, 47,115,101,108,102, 47,
/* 0x00c0 */ 194, 71, 64,184,225, 3, 30,170, 96, 12,128, 18, 8, 7,128, 82, /* 0x00c0 */ 109, 97,112,115, 0, 45,113, 0, 47,117,115,114, 47, 98,105,110,
/* 0x00d0 */ 1, 0, 0,212,251, 3, 0, 42,128, 6, 64,185,253, 3, 0,145, /* 0x00d0 */ 47,103,100, 98, 0,115,101,116, 32,112,114,111,109,112,116, 10,
/* 0x00e0 */ 160, 3, 0,203, 0,236,124,146, 31, 0, 0,145,226, 3, 0,170, /* 0x00e0 */ 105,110,102,111, 32,105,110,102,101,114,105,111,114,115, 10,112,
/* 0x00f0 */ 225, 15, 31,248,227, 3, 0,145,128, 66, 0,145,129, 10, 64,185, /* 0x00f0 */ 114,105,110,116, 32, 34,120, 48, 45,120, 55, 34, 10,120, 47, 56,
/* 0x0100 */ 132, 50, 64, 57, 34, 0, 0,148,232, 7, 65,248,250, 3, 0,249, /* 0x0100 */ 120,103, 32, 36,115,112, 32, 43, 32, 48,120, 49, 51, 56, 10,112,
/* 0x0110 */ 130, 6, 64,185,225, 3, 0,145,224, 3, 27, 42, 8, 8,128, 82, /* 0x0110 */ 114,105,110,116, 32, 34,120, 56, 45,120, 49, 53, 34, 10,120, 47,
/* 0x0120 */ 1, 0, 0,212,191, 3, 0,145, 5, 0,128,210,228, 3, 27, 42, /* 0x0120 */ 56,120,103, 10,112,114,105,110,116, 32, 34,120, 49, 54, 45,120,
/* 0x0130 */ 35, 0,128, 82,162, 0,128, 82,129, 6, 64,185,225, 15, 0,249, /* 0x0130 */ 50, 51, 34, 10,120, 47, 56,120,103, 10,112,114,105,110,116, 32,
/* 0x0140 */ 0, 0,128,210,200, 27,128, 82, 1, 0, 0,212,224, 11, 0,249, /* 0x0140 */ 34,120, 50, 52, 45,120, 51, 48, 34, 10,120, 47, 55,120,103, 10,
/* 0x0150 */ 252, 3, 0,170,224, 3, 27, 42, 40, 7,128, 82, 1, 0, 0,212, /* 0x0150 */ 115,101,116, 32, 36,112, 99, 32, 61, 32, 42, 40,108,111,110,103,
/* 0x0160 */ 253, 11, 64,185,129, 2, 64,185,158, 83, 0,145,189, 3, 1, 75, /* 0x0160 */ 32, 42, 41, 40, 36,115,112, 32, 43, 32, 48,120, 50, 51, 56, 41,
/* 0x0170 */ 253, 7, 0,249, 33,120, 30, 18, 60, 3, 1,139,192, 3, 31,214, /* 0x0170 */ 10,112,114,105,110,116, 32, 34,102, 97,117,108,116,105,110,103,
/* 0x0180 */ 1,132, 64,248,225,255,255,181,192, 3, 95,214, 1, 64, 33,139, /* 0x0180 */ 32,105,110,115,116,114, 34, 10,120, 47,105, 32, 36,112, 99, 10,
/* 0x0190 */ 225, 11,190,169,227,123, 1,169, 5, 0,128, 18, 4, 0,176, 82, /* 0x0190 */ 112,114,105,110,116, 32, 34,102, 97,117,108,116, 32, 99,111,110,
/* 0x01a0 */ 26, 0, 0, 20,228,123, 65,169,225, 15,194,168, 0, 0, 1,203, /* 0x01a0 */ 116,101,120,116, 34, 10,120, 47, 49, 53,105, 32, 36,112, 99, 32,
/* 0x01b0 */ 66, 0, 3,203,130, 0, 0,185,229, 3, 0,170,224, 3, 3,170, /* 0x01b0 */ 45, 32, 55, 42, 52, 10,115,101,116, 32, 36,115,112, 32, 61, 32,
/* 0x01c0 */ 97, 0, 2,139,224, 3, 5,170,192, 3, 95,214,132, 0, 4, 43, /* 0x01c0 */ 42, 40,108,111,110,103, 32, 42, 41, 40, 36,115,112, 32, 43, 32,
/* 0x01d0 */ 68, 0, 0, 52,192, 3, 95,214, 4, 68, 64,184,132, 0, 4, 58, /* 0x01d0 */ 48,120, 50, 51, 48, 41, 10,112,114,105,110,116, 32, 34,117,115,
/* 0x01e0 */ 192, 3, 95,214, 33, 0,128, 82,240, 3, 30,170,248,255,255,151, /* 0x01e0 */ 101,114, 32,115,116, 97, 99,107, 34, 10,120, 47, 54, 52,120,103,
/* 0x01f0 */ 33, 0, 1, 58,246,255,255,151,163,255,255, 84, 0, 2, 31,214, /* 0x01f0 */ 32, 36,115,112, 10,107,105,108,108, 10,113,117,105,116, 32, 49,
/* 0x0200 */ 3, 20, 64, 56, 67, 20, 0, 56,241,255,255,151,162,255,255, 84, /* 0x0200 */ 0, 0, 0, 0, 0, 0,128, 82, 40, 7,128, 82, 1, 0, 0,212,
/* 0x0210 */ 245,255,255,151, 35, 12, 0,113, 1, 0,128, 82,163, 0, 0, 84, /* 0x0210 */ 255,127,191,169, 1, 0,128, 82,224, 3, 0,145,104, 7,128, 82,
/* 0x0220 */ 5, 20, 64, 56,165, 32, 3, 42,229, 3, 37, 42,197,251,255, 52, /* 0x0220 */ 1, 0, 0,212,240, 19, 0,145, 19, 2, 64,185,255, 67, 0,145,
/* 0x0230 */ 231,255,255,151, 33, 0, 1, 58,229,255,255,151, 33, 0, 1, 58, /* 0x0230 */ 130, 37,128, 82, 1,245,255, 48,224, 3, 19, 42, 8, 8,128, 82,
/* 0x0240 */ 97, 0, 0, 84,232,255,255,151, 33, 8, 0, 17,191, 0, 52, 49, /* 0x0240 */ 1, 0, 0,212,224, 3, 19, 42, 40, 7,128, 82, 1, 0, 0,212,
/* 0x0250 */ 33, 36,129, 26, 67,200,101, 56, 33, 4, 0,113, 67, 20, 0, 56, /* 0x0250 */ 255, 7, 64,209, 2, 0,128, 82,129,241,255, 16, 0, 0,128,146,
/* 0x0260 */ 162,255,255, 84,233,255,255, 23,117,112,120, 0,217, 19, 1,209, /* 0x0260 */ 8, 7,128, 82, 1, 0, 0,212,243, 3, 0, 42,225, 3, 0,145,
/* 0x0270 */ 32, 3, 64,185, 57, 67, 32,203,224, 7, 0,249,192, 3, 63,214, /* 0x0270 */ 2, 0,130, 82,232, 7,128, 82, 1, 0, 0,212,224, 3, 19, 42,
/* 0x0280 */ 0, 0, 0, 0,102,105,108,101, 32,102,111,114,109, 97,116, 32, /* 0x0280 */ 40, 7,128, 82, 1, 0, 0,212,168, 21,128, 82, 1, 0, 0,212,
/* 0x0290 */ 101,108,102, 54, 52, 45,108,105,116,116,108,101, 97, 97,114, 99, /* 0x0290 */ 255,127,191,169,225, 3, 0, 42,224, 3, 0,145, 49, 0, 0,148,
/* 0x02a0 */ 104, 54, 52, 10, 10, 83,101, 99,116,105,111,110,115, 58, 10, 73, /* 0x02a0 */ 227, 3, 0,145,226, 67, 0,145,225,240,255, 48,224,240,255, 16,
/* 0x02b0 */ 100,120, 32, 78, 97,109,101, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 0x02b0 */ 224, 7,189,169,226, 15, 1,169,255, 19, 0,249, 2, 0,128,210,
/* 0x02c0 */ 32, 83,105,122,101, 32, 32, 32, 32, 32, 32, 86, 77, 65, 32, 32, /* 0x02c0 */ 225, 3, 0,145,168, 27,128, 82, 1, 0, 0,212, 0, 0, 0, 20,
/* 0x02d0 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 76, 77, 65, /* 0x02d0 */ 31, 32, 3,213,225, 11, 63,169, 66, 3,128,210,225,237,255,112,
/* 0x02e0 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 70, /* 0x02e0 */ 64, 0,128, 82, 8, 8,128, 82, 1, 0, 0,212, 2, 0,128, 82,
/* 0x02f0 */ 105,108,101, 32,111,102,102, 32, 32, 65,108,103,110, 32, 32, 70, /* 0x02f0 */ 33,238,255, 48, 0, 0,128, 18, 8, 7,128, 82, 1, 0, 0,212,
/* 0x0300 */ 108, 97,103,115, 10, 32, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, /* 0x0300 */ 243, 3, 0, 42,255, 7, 64,209, 2, 0,130,210,225, 3, 0,145,
/* 0x0310 */ 88, 32, 32, 32, 32, 32, 32, 48, 50, 50, 56, 32, 32, 48, 32, 32, /* 0x0310 */ 224, 3, 19, 42,232, 7,128, 82, 1, 0, 0,212,224, 0, 0, 52,
/* 0x0320 */ 48, 32, 32, 48, 52, 48, 32, 32, 50, 42, 42, 50, 32, 32, 67, 79, /* 0x0320 */ 226, 3, 0,170,225, 3, 0,145, 64, 0,128, 82, 8, 8,128, 82,
/* 0x0330 */ 78, 84, 69, 78, 84, 83, 10, 32, 32, 49, 32, 69, 76, 70, 77, 65, /* 0x0330 */ 1, 0, 0,212,245,255,255, 23,255, 7, 64,145,224, 3, 16,170,
/* 0x0340 */ 73, 78, 89, 32, 32, 32, 32, 32, 32, 48, 32, 32, 48, 32, 32, 48, /* 0x0340 */ 40, 7,128, 82, 1, 0, 0,212, 0, 0,128,210, 1, 0,128,210,
/* 0x0350 */ 32, 32, 48, 50, 54, 56, 32, 32, 50, 42, 42, 48, 32, 32, 67, 79, /* 0x0350 */ 136, 27,128, 82, 1, 0, 0,212, 96,245,255,180, 0, 0, 0, 20,
/* 0x0360 */ 78, 84, 69, 78, 84, 83, 10, 32, 32, 50, 32, 69, 76, 70, 77, 65, /* 0x0360 */ 254,127,191,169, 4, 0, 0,148,254, 7,193,168, 1, 0, 0, 57,
/* 0x0370 */ 73, 78, 90, 32, 32, 32, 32, 32, 32, 48, 49, 99, 32, 32, 48, 32, /* 0x0370 */ 192, 3, 95,214,162,153,153, 82,130,153,185,114, 34,124,162,155,
/* 0x0380 */ 32, 48, 32, 32, 48, 50, 54, 56, 32, 32, 50, 42, 42, 50, 32, 32, /* 0x0380 */ 67,252, 99,211, 98, 8, 3, 11, 33, 4, 2, 75,254, 7,191,169,
/* 0x0390 */ 67, 79, 78, 84, 69, 78, 84, 83, 10, 83, 89, 77, 66, 79, 76, 32, /* 0x0390 */ 99, 0, 0,180,225, 3, 3, 42,247,255,255,151,254, 7,193,168,
/* 0x03a0 */ 84, 65, 66, 76, 69, 58, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x03a0 */ 33,192, 0, 17, 1, 20, 0, 56,192, 3, 95,214, 3, 1,128,210,
/* 0x03b0 */ 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32, /* 0x03b0 */ 226, 3, 31,170,225, 3, 31,170, 96, 1,128, 82,200, 16,128, 82,
/* 0x03c0 */ 69, 76, 70, 77, 65, 73, 78, 90, 32, 48, 32, 69, 76, 70, 77, 65, /* 0x03c0 */ 1, 0, 0,212,192, 3, 95,214,224, 99, 0,145, 82, 0, 0,148,
/* 0x03d0 */ 73, 78, 90, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x03d0 */ 81, 0, 0,148,246, 3, 0,170,255,131, 0,209, 1, 8,193,168,
/* 0x03e0 */ 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, /* 0x03e0 */ 63, 24, 0,113, 96, 0, 0, 84,161,255,255, 53, 34, 0,160,210,
/* 0x03f0 */ 77, 65, 73, 78, 88, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, 88, /* 0x03f0 */ 250, 3, 2,203,250, 3, 0,249, 25, 0, 0, 16, 32, 3, 64,185,
/* 0x0400 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x0400 */ 224, 7, 0,249, 57, 67, 32,203, 0, 0, 0,148,244, 3, 30,170,
/* 0x0410 */ 48, 32,108, 32, 32, 32, 32,100, 32, 32, 69, 76, 70, 77, 65, 73, /* 0x0410 */ 1, 2,128, 82, 0, 0, 0, 16,232, 34,128, 82, 1, 0, 0,212,
/* 0x0420 */ 78, 89, 32, 48, 32, 69, 76, 70, 77, 65, 73, 78, 89, 10, 48, 48, /* 0x0420 */ 0, 2,248, 54, 97, 0, 0, 52,225, 3, 31, 42,250,255,255, 23,
/* 0x0430 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, /* 0x0430 */ 6, 0, 0,148,192, 1, 0, 0, 2, 64, 64, 0, 47,100,101,118,
/* 0x0440 */ 32, 32, 32, 32, 32, 32, 32, 42, 85, 78, 68, 42, 32, 48, 32, 77, /* 0x0440 */ 47,115,104,109, 0, 0, 0, 0,195, 71, 64,184,194, 71, 64,184,
/* 0x0450 */ 70, 76, 71, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x0450 */ 225, 3, 30,170, 96, 12,128, 18, 8, 7,128, 82, 1, 0, 0,212,
/* 0x0460 */ 48, 48, 48, 52, 32,103, 32, 32, 32, 32, 32, 32, 32, 69, 76, 70, /* 0x0460 */ 251, 3, 0, 42,128, 6, 64,185,253, 3, 0,145,160, 3, 0,203,
/* 0x0470 */ 77, 65, 73, 78, 88, 32, 48, 32, 95,115,116, 97,114,116, 10, 48, /* 0x0470 */ 0,236,124,146, 31, 0, 0,145,226, 3, 0,170,225, 15, 31,248,
/* 0x0480 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 52, 99, 32, /* 0x0480 */ 227, 3, 0,145,128, 66, 0,145,129, 10, 64,185,132, 50, 64, 57,
/* 0x0490 */ 103, 32, 32, 32, 32, 32, 70, 32, 69, 76, 70, 77, 65, 73, 78, 88, /* 0x0490 */ 36, 0, 0,148,232, 7, 65,248,250, 3, 0,249,242, 7, 0,249,
/* 0x04a0 */ 32, 48,100, 99, 32,117, 99,108, 95,110,114,118, 50, 98, 95,100, /* 0x04a0 */ 130, 6, 64,185,225, 3, 0,145,224, 3, 27, 42, 8, 8,128, 82,
/* 0x04b0 */ 101, 99,111,109,112,114,101,115,115, 95, 51, 50, 10, 48, 48, 48, /* 0x04b0 */ 1, 0, 0,212,191, 3, 0,145, 5, 0,128,210,228, 3, 27, 42,
/* 0x04c0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32,103, 32, /* 0x04c0 */ 35, 0,128, 82,162, 0,128, 82,129, 6, 64,185,225, 15, 0,249,
/* 0x04d0 */ 32, 32, 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 89, 32, 48, /* 0x04d0 */ 0, 0,128,210,200, 27,128, 82, 1, 0, 0,212,224, 11, 0,249,
/* 0x04e0 */ 32,101,110,100, 95,100,101, 99,111,109,112,114,101,115,115, 10, /* 0x04e0 */ 252, 3, 0,170,224, 3, 27, 42, 40, 7,128, 82, 1, 0, 0,212,
/* 0x04f0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x04f0 */ 253, 11, 64,185,129, 2, 64,185,158,115, 0,145,189, 3, 1, 75,
/* 0x0500 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 42, 85, 78, 68, 42, 32, 48, /* 0x0500 */ 253, 7, 0,249, 33,120, 30, 18, 60, 3, 1,139,192, 3, 31,214,
/* 0x0510 */ 32, 79, 95, 66, 73, 78, 70, 79, 10, 10, 82, 69, 76, 79, 67, 65, /* 0x0510 */ 192, 3, 95,214, 1,132, 64,248,225,255,255,181,192, 3, 95,214,
/* 0x0520 */ 84, 73, 79, 78, 32, 82, 69, 67, 79, 82, 68, 83, 32, 70, 79, 82, /* 0x0520 */ 1, 64, 33,139,225, 11,190,169,227,123, 1,169, 5, 0,128, 18,
/* 0x0530 */ 32, 91, 69, 76, 70, 77, 65, 73, 78, 88, 93, 58, 10, 79, 70, 70, /* 0x0530 */ 4, 0,176, 82, 26, 0, 0, 20,228,123, 65,169,225, 15,194,168,
/* 0x0540 */ 83, 69, 84, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 84, 89, /* 0x0540 */ 0, 0, 1,203, 66, 0, 3,203,130, 0, 0,185,229, 3, 0,170,
/* 0x0550 */ 80, 69, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, /* 0x0550 */ 224, 3, 3,170, 97, 0, 2,139,224, 3, 5,170,192, 3, 95,214,
/* 0x0560 */ 86, 65, 76, 85, 69, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, /* 0x0560 */ 132, 0, 4, 43, 68, 0, 0, 52,192, 3, 95,214, 4, 68, 64,184,
/* 0x0570 */ 48, 48, 48, 48, 48, 48, 32, 82, 95, 65, 65, 82, 67, 72, 54, 52, /* 0x0570 */ 132, 0, 4, 58,192, 3, 95,214, 33, 0,128, 82,240, 3, 30,170,
/* 0x0580 */ 95, 65, 66, 83, 51, 50, 32, 32, 32, 77, 70, 76, 71, 10, 48, 48, /* 0x0580 */ 248,255,255,151, 33, 0, 1, 58,246,255,255,151,163,255,255, 84,
/* 0x0590 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 51, 99, 32, 82, /* 0x0590 */ 0, 2, 31,214, 3, 20, 64, 56, 67, 20, 0, 56,241,255,255,151,
/* 0x05a0 */ 95, 65, 65, 82, 67, 72, 54, 52, 95, 67, 65, 76, 76, 50, 54, 32, /* 0x05a0 */ 162,255,255, 84,245,255,255,151, 35, 12, 0,113, 1, 0,128, 82,
/* 0x05b0 */ 32, 69, 76, 70, 77, 65, 73, 78, 90, 43, 48,120, 48, 48, 48, 48, /* 0x05b0 */ 163, 0, 0, 84, 5, 20, 64, 56,165, 32, 3, 42,229, 3, 37, 42,
/* 0x05c0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 10, 48, 48, 48, /* 0x05c0 */ 197,251,255, 52,231,255,255,151, 33, 0, 1, 58,229,255,255,151,
/* 0x05d0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 56, 32, 82, 95, /* 0x05d0 */ 33, 0, 1, 58, 97, 0, 0, 84,232,255,255,151, 33, 8, 0, 17,
/* 0x05e0 */ 65, 65, 82, 67, 72, 54, 52, 95, 65, 68, 82, 95, 80, 82, 69, 76, /* 0x05e0 */ 191, 0, 52, 49, 33, 36,129, 26, 67,200,101, 56, 33, 4, 0,113,
/* 0x05f0 */ 95, 76, 79, 50, 49, 32, 32, 69, 76, 70, 77, 65, 73, 78, 90, 10, /* 0x05f0 */ 67, 20, 0, 56,162,255,255, 84,233,255,255, 23,117,112,120, 0,
/* 0x0600 */ 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, 79, /* 0x0600 */ 192, 3, 63,214, 0, 0, 0, 0,102,105,108,101, 32,102,111,114,
/* 0x0610 */ 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, 78, /* 0x0610 */ 109, 97,116, 32,101,108,102, 54, 52, 45,108,105,116,116,108,101,
/* 0x0620 */ 90, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 32, 32, 32, /* 0x0620 */ 97, 97,114, 99,104, 54, 52, 10, 10, 83,101, 99,116,105,111,110,
/* 0x0630 */ 32, 32, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32, 32, 32, /* 0x0630 */ 115, 58, 10, 73,100,120, 32, 78, 97,109,101, 32, 32, 32, 32, 32,
/* 0x0640 */ 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 10, 48, 48, 48, /* 0x0640 */ 32, 32, 32, 32, 32, 83,105,122,101, 32, 32, 32, 32, 32, 32, 86,
/* 0x0650 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 56, 32, 82, 95, /* 0x0650 */ 77, 65, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
/* 0x0660 */ 65, 65, 82, 67, 72, 54, 52, 95, 65, 66, 83, 51, 50, 32, 32, 32, /* 0x0660 */ 32, 76, 77, 65, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
/* 0x0670 */ 79, 95, 66, 73, 78, 70, 79, 10 /* 0x0670 */ 32, 32, 32, 70,105,108,101, 32,111,102,102, 32, 32, 65,108,103,
/* 0x0680 */ 110, 32, 32, 70,108, 97,103,115, 10, 32, 32, 48, 32, 69, 76, 70,
/* 0x0690 */ 77, 65, 73, 78, 88, 32, 32, 32, 32, 32, 32, 48, 49, 48, 32, 32,
/* 0x06a0 */ 48, 32, 32, 48, 32, 32, 48, 52, 48, 32, 32, 50, 42, 42, 48, 32,
/* 0x06b0 */ 32, 67, 79, 78, 84, 69, 78, 84, 83, 10, 32, 32, 49, 32, 69, 76,
/* 0x06c0 */ 70, 83, 73, 71, 83, 69, 71, 86, 32, 32, 32, 32, 48, 51, 55, 56,
/* 0x06d0 */ 32, 32, 48, 32, 32, 48, 32, 32, 48, 53, 48, 32, 32, 50, 42, 42,
/* 0x06e0 */ 50, 32, 32, 67, 79, 78, 84, 69, 78, 84, 83, 10, 32, 32, 50, 32,
/* 0x06f0 */ 69, 76, 70, 77, 65, 73, 78, 88, 50, 32, 32, 32, 32, 32, 48, 50,
/* 0x0700 */ 51, 52, 32, 32, 48, 32, 32, 48, 32, 32, 48, 51, 99, 56, 32, 32,
/* 0x0710 */ 50, 42, 42, 50, 32, 32, 67, 79, 78, 84, 69, 78, 84, 83, 10, 32,
/* 0x0720 */ 32, 51, 32, 69, 76, 70, 77, 65, 73, 78, 89, 32, 32, 32, 32, 32,
/* 0x0730 */ 32, 48, 32, 32, 48, 32, 32, 48, 32, 32, 48, 53,102, 99, 32, 32,
/* 0x0740 */ 50, 42, 42, 48, 32, 32, 67, 79, 78, 84, 69, 78, 84, 83, 10, 32,
/* 0x0750 */ 32, 52, 32, 69, 76, 70, 77, 65, 73, 78, 90, 32, 32, 32, 32, 32,
/* 0x0760 */ 32, 48, 99, 32, 32, 48, 32, 32, 48, 32, 32, 48, 53,102, 99, 32,
/* 0x0770 */ 32, 50, 42, 42, 50, 32, 32, 67, 79, 78, 84, 69, 78, 84, 83, 10,
/* 0x0780 */ 83, 89, 77, 66, 79, 76, 32, 84, 65, 66, 76, 69, 58, 10, 48, 48,
/* 0x0790 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32,108,
/* 0x07a0 */ 32, 32, 32, 32,100, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 32,
/* 0x07b0 */ 48, 32, 69, 76, 70, 77, 65, 73, 78, 88, 10, 48, 48, 48, 48, 48,
/* 0x07c0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, 32,
/* 0x07d0 */ 32,100, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 50, 32, 48, 32,
/* 0x07e0 */ 69, 76, 70, 77, 65, 73, 78, 88, 50, 10, 48, 48, 48, 48, 48, 48,
/* 0x07f0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, 32, 32,
/* 0x0800 */ 100, 32, 32, 69, 76, 70, 77, 65, 73, 78, 90, 32, 48, 32, 69, 76,
/* 0x0810 */ 70, 77, 65, 73, 78, 90, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0820 */ 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32, 32,
/* 0x0830 */ 69, 76, 70, 83, 73, 71, 83, 69, 71, 86, 32, 48, 32, 69, 76, 70,
/* 0x0840 */ 83, 73, 71, 83, 69, 71, 86, 10, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0850 */ 48, 48, 48, 48, 48, 48, 48, 48, 32,108, 32, 32, 32, 32,100, 32,
/* 0x0860 */ 32, 69, 76, 70, 77, 65, 73, 78, 89, 32, 48, 32, 69, 76, 70, 77,
/* 0x0870 */ 65, 73, 78, 89, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0880 */ 48, 48, 48, 48, 48, 32, 32, 32, 32, 32, 32, 32, 32, 32, 42, 85,
/* 0x0890 */ 78, 68, 42, 32, 48, 32, 77, 70, 76, 71, 10, 48, 48, 48, 48, 48,
/* 0x08a0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 32,103, 32, 32, 32,
/* 0x08b0 */ 32, 32, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 32, 48, 32, 95,
/* 0x08c0 */ 115,116, 97,114,116, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x08d0 */ 48, 48, 48, 49, 53, 56, 32,103, 32, 32, 32, 32, 32, 70, 32, 69,
/* 0x08e0 */ 76, 70, 77, 65, 73, 78, 88, 50, 32, 48,100, 99, 32,117, 99,108,
/* 0x08f0 */ 95,110,114,118, 50, 98, 95,100,101, 99,111,109,112,114,101,115,
/* 0x0900 */ 115, 95, 51, 50, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0910 */ 48, 48, 48, 48, 48, 32,103, 32, 32, 32, 32, 32, 32, 32, 69, 76,
/* 0x0920 */ 70, 77, 65, 73, 78, 89, 32, 48, 32,101,110,100, 95,100,101, 99,
/* 0x0930 */ 111,109,112,114,101,115,115, 10, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x0940 */ 48, 48, 48, 48, 48, 48, 48, 48, 32, 32, 32, 32, 32, 32, 32, 32,
/* 0x0950 */ 32, 42, 85, 78, 68, 42, 32, 48, 32, 79, 95, 66, 73, 78, 70, 79,
/* 0x0960 */ 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67,
/* 0x0970 */ 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73,
/* 0x0980 */ 78, 88, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 32, 32,
/* 0x0990 */ 32, 32, 32, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32, 32,
/* 0x09a0 */ 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 10, 48, 48,
/* 0x09b0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 32, 82,
/* 0x09c0 */ 95, 65, 65, 82, 67, 72, 54, 52, 95, 65, 66, 83, 51, 50, 32, 32,
/* 0x09d0 */ 32, 77, 70, 76, 71, 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
/* 0x09e0 */ 48, 48, 48, 48, 48, 99, 32, 82, 95, 65, 65, 82, 67, 72, 54, 52,
/* 0x09f0 */ 95, 65, 68, 82, 95, 80, 82, 69, 76, 95, 76, 79, 50, 49, 32, 32,
/* 0x0a00 */ 69, 76, 70, 77, 65, 73, 78, 88, 50, 43, 48,120, 48, 48, 48, 48,
/* 0x0a10 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 49, 52, 56, 10, 10, 82, 69,
/* 0x0a20 */ 76, 79, 67, 65, 84, 73, 79, 78, 32, 82, 69, 67, 79, 82, 68, 83,
/* 0x0a30 */ 32, 70, 79, 82, 32, 91, 69, 76, 70, 77, 65, 73, 78, 88, 50, 93,
/* 0x0a40 */ 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32, 32, 32, 32, 32, 32,
/* 0x0a50 */ 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32, 32, 32, 32, 32, 32,
/* 0x0a60 */ 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 10, 48, 48, 48, 48, 48,
/* 0x0a70 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 51, 48, 32, 82, 95, 65, 65,
/* 0x0a80 */ 82, 67, 72, 54, 52, 95, 65, 68, 82, 95, 80, 82, 69, 76, 95, 76,
/* 0x0a90 */ 79, 50, 49, 32, 32, 69, 76, 70, 77, 65, 73, 78, 88, 45, 48,120,
/* 0x0aa0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52,
/* 0x0ab0 */ 10, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52,
/* 0x0ac0 */ 48, 32, 82, 95, 65, 65, 82, 67, 72, 54, 52, 95, 67, 65, 76, 76,
/* 0x0ad0 */ 50, 54, 32, 32, 69, 76, 70, 77, 65, 73, 78, 90, 43, 48,120, 48,
/* 0x0ae0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 10,
/* 0x0af0 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 52, 99,
/* 0x0b00 */ 32, 82, 95, 65, 65, 82, 67, 72, 54, 52, 95, 65, 68, 82, 95, 80,
/* 0x0b10 */ 82, 69, 76, 95, 76, 79, 50, 49, 32, 32, 69, 76, 70, 77, 65, 73,
/* 0x0b20 */ 78, 90, 10, 10, 82, 69, 76, 79, 67, 65, 84, 73, 79, 78, 32, 82,
/* 0x0b30 */ 69, 67, 79, 82, 68, 83, 32, 70, 79, 82, 32, 91, 69, 76, 70, 77,
/* 0x0b40 */ 65, 73, 78, 90, 93, 58, 10, 79, 70, 70, 83, 69, 84, 32, 32, 32,
/* 0x0b50 */ 32, 32, 32, 32, 32, 32, 32, 32, 84, 89, 80, 69, 32, 32, 32, 32,
/* 0x0b60 */ 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 86, 65, 76, 85, 69, 10,
/* 0x0b70 */ 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 56,
/* 0x0b80 */ 32, 82, 95, 65, 65, 82, 67, 72, 54, 52, 95, 65, 66, 83, 51, 50,
/* 0x0b90 */ 32, 32, 32, 79, 95, 66, 73, 78, 70, 79, 10
}; };
+1106 -1105
View File
File diff suppressed because it is too large Load Diff
+963 -834
View File
File diff suppressed because it is too large Load Diff
+2267 -2271
View File
File diff suppressed because it is too large Load Diff
+1061 -1060
View File
File diff suppressed because it is too large Load Diff
+1054 -1053
View File
File diff suppressed because it is too large Load Diff
+39 -36
View File
@@ -1,4 +1,4 @@
#! /usr/bin/env python2 #! /usr/bin/env python3
## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*-
# #
# bin2h.py -- # bin2h.py --
@@ -45,7 +45,7 @@ class opts:
# ************************************************************************/ # ************************************************************************/
def w_header_c(w, ifile, ofile, n): def w_header_c(w, ifile, ofile, n):
w("/* %s\n created from %s, %d (0x%x) bytes\n" % (os.path.basename(ofile), os.path.basename(ifile), n, n)) w(("/* %s\n created from %s, %d (0x%x) bytes\n" % (os.path.basename(ofile), os.path.basename(ifile), n, n)).encode())
w("""\n\ w("""\n\
This file is part of the UPX executable compressor. This file is part of the UPX executable compressor.
@@ -74,7 +74,7 @@ def w_header_c(w, ifile, ofile, n):
John F. Reiser John F. Reiser
<jreiser@users.sourceforge.net> <jreiser@users.sourceforge.net>
*/\n\n""") */\n\n""".encode())
# /*********************************************************************** # /***********************************************************************
@@ -87,11 +87,11 @@ class DataWriter:
self.pos = None self.pos = None
def w_bol(self, pos): def w_bol(self, pos):
self.w("/* 0x%04x */ " % (pos)) self.w(("/* 0x%04x */ " % (pos)).encode())
self.pos = pos self.pos = pos
def w_eol(self, fill=""): def w_eol(self, fill=""):
if self.pos is not None: if self.pos is not None:
self.w(fill.rstrip() + "\n") self.w((fill.rstrip() + "\n").encode())
class DataWriter_c(DataWriter): class DataWriter_c(DataWriter):
@@ -101,8 +101,8 @@ class DataWriter_c(DataWriter):
if i & 15 == 0: if i & 15 == 0:
self.w_eol() self.w_eol()
self.w_bol(i) self.w_bol(i)
w("%3d" % ord(data[i])) w(("%3d" % data[i]).encode())
if i != n - 1: w(",") if i != n - 1: w(",".encode())
self.w_eol() self.w_eol()
@@ -113,10 +113,10 @@ class DataWriter_gas(DataWriter):
if i & 15 == 0: if i & 15 == 0:
self.w_eol() self.w_eol()
self.w_bol(i) self.w_bol(i)
w(".byte ") w(".byte ".encode())
else: else:
w(",") w(",".encode())
w("%3d" % ord(data[i])) w(("%3d" % data[i]).encode())
self.w_eol() self.w_eol()
@@ -128,12 +128,12 @@ class _DataWriter_gas_u32(DataWriter):
if i & 15 == 0: if i & 15 == 0:
self.w_eol() self.w_eol()
self.w_bol(i) self.w_bol(i)
w(".int ") w(".int ".encode())
else: else:
w(",") w(",".encode())
v = struct.unpack(self.DECODE, data[i:i+4]) v = struct.unpack(self.DECODE, data[i:i+4])
assert len(v) == 1, v assert len(v) == 1, v
w("0x%08x" % (v[0] & 0xffffffffL)) w(("0x%08x" % (v[0] & 0xffffffff)).encode())
self.w_eol() self.w_eol()
class DataWriter_gas_be32(_DataWriter_gas_u32): class DataWriter_gas_be32(_DataWriter_gas_u32):
@@ -148,7 +148,7 @@ class DataWriter_nasm(DataWriter):
def w_eol(self, fill=""): def w_eol(self, fill=""):
if self.pos is not None: if self.pos is not None:
self.w(fill) self.w(fill)
self.w(" ; 0x%04x\n" % (self.pos)) self.w((" ; 0x%04x\n" % (self.pos)).encode())
def w_data(self, data): def w_data(self, data):
w, n = self.w, len(data) w, n = self.w, len(data)
@@ -156,10 +156,10 @@ class DataWriter_nasm(DataWriter):
if i & 15 == 0: if i & 15 == 0:
self.w_eol() self.w_eol()
self.w_bol(i) self.w_bol(i)
w("db ") w("db ".encode())
else: else:
w(",") w(",".encode())
w("%3d" % ord(data[i])) w(("%3d" % ord(data[i])).encode())
nn = ((n + 15) & ~15) - n nn = ((n + 15) & ~15) - n
self.w_eol(" " * 4 * nn) self.w_eol(" " * 4 * nn)
@@ -169,21 +169,21 @@ class DataWriter_nasm(DataWriter):
# ************************************************************************/ # ************************************************************************/
def w_checksum_c(w, s, data): def w_checksum_c(w, s, data):
w("#define %s_SIZE %d\n" % (s, len(data))) w(("#define %s_SIZE %d\n" % (s, len(data))).encode())
w("#define %s_ADLER32 0x%08x\n" % (s, 0xffffffffL & zlib.adler32(data))) w(("#define %s_ADLER32 0x%08x\n" % (s, 0xffffffff & zlib.adler32(data))).encode())
w("#define %s_CRC32 0x%08x\n" % (s, 0xffffffffL & zlib.crc32(data))) w(("#define %s_CRC32 0x%08x\n" % (s, 0xffffffff & zlib.crc32(data))).encode())
w("\n") w("\n".encode())
def write_stub(w, odata, method_index, methods): def write_stub(w, odata, method_index, methods):
method = methods[method_index] method = methods[method_index]
if len(methods) > 1: if len(methods) > 1:
if method_index == 0: if method_index == 0:
w("#if (%s == %d)\n\n" % (opts.mname, method)) w(("#if (%s == %d)\n\n" % (opts.mname, method)).encode())
elif method_index < len(methods) - 1: elif method_index < len(methods) - 1:
w("\n#elif (%s == %d)\n\n" % (opts.mname, method)) w(("\n#elif (%s == %d)\n\n" % (opts.mname, method)).encode())
else: else:
w("\n#else\n\n") w("\n#else\n\n".encode())
if opts.ident: if opts.ident:
if opts.mode == "c": if opts.mode == "c":
@@ -193,8 +193,8 @@ def write_stub(w, odata, method_index, methods):
#w("#if defined(__ELF__)\n") #w("#if defined(__ELF__)\n")
#w('__attribute__((__section__("upx_stubs")))\n') #w('__attribute__((__section__("upx_stubs")))\n')
#w("#endif\n") #w("#endif\n")
w("ATTRIBUTE_FOR_STUB(%s)\n" % (opts.ident)) w(("ATTRIBUTE_FOR_STUB(%s)\n" % (opts.ident)).encode())
w("unsigned char %s[%d] = {\n" % (opts.ident, len(odata))) w(("unsigned char %s[%d] = {\n" % (opts.ident, len(odata))).encode())
if opts.mode == "c": if opts.mode == "c":
DataWriter_c(w).w_data(odata) DataWriter_c(w).w_data(odata)
elif opts.mode == "gas": elif opts.mode == "gas":
@@ -209,11 +209,11 @@ def write_stub(w, odata, method_index, methods):
assert 0, ("invalid mode", opts.mode) assert 0, ("invalid mode", opts.mode)
if opts.ident: if opts.ident:
if opts.mode == "c": if opts.mode == "c":
w("};\n") w("};\n".encode())
if len(methods) > 1: if len(methods) > 1:
if method_index == len(methods) - 1: if method_index == len(methods) - 1:
w("\n#endif\n") w("\n#endif\n".encode())
# /*********************************************************************** # /***********************************************************************
@@ -293,10 +293,10 @@ def main(argv):
# check file size # check file size
st = os.stat(ifile) st = os.stat(ifile)
if 1 and st.st_size <= 0: if 1 and st.st_size <= 0:
print >> sys.stderr, "%s: ERROR: empty file" % (ifile) sys.stderr.write("%s: ERROR: empty file\n" % (ifile))
sys.exit(1) sys.exit(1)
if 1 and st.st_size > 128*1024: if 1 and st.st_size > 128*1024:
print >> sys.stderr, "%s: ERROR: file is too big (%d bytes)" % (ifile, st.st_size) sys.stderr.write("%s: ERROR: file is too big (%d bytes)\n" % (ifile, st.st_size))
sys.exit(1) sys.exit(1)
# read ifile # read ifile
@@ -321,19 +321,22 @@ def main(argv):
# compress stubs # compress stubs
# (process in reverse order so that incompressible do not get sorted first) # (process in reverse order so that incompressible do not get sorted first)
mdata, mdata_odata = [], {} mdata, mdata_odata = [], {}
assert len(opts.methods) >= 1 ### FIXME assert len(opts.methods) >= 1
r_methods = opts.methods[:] ### r_methods = opts.methods[:]
r_methods.reverse() ### r_methods.reverse()
r_methods = [];
for m in opts.methods:
r_methods.insert(0, m)
for method in r_methods: for method in r_methods:
method, odata = compress_stub(method, idata) method, odata = compress_stub(method, idata)
if mdata_odata.has_key(method): if method in mdata_odata:
assert mdata_odata[method] == odata assert mdata_odata[method] == odata
else: else:
mdata_odata[method] = odata mdata_odata[method] = odata
mdata.append(method) mdata.append(method)
assert len(mdata) >= 1 assert len(mdata) >= 1
mdata.reverse() mdata.reverse()
##print opts.methods, [(i, len(mdata_odata[i])) for i in mdata] ##print (opts.methods, [(i, len(mdata_odata[i])) for i in mdata])
# write ofile # write ofile
if opts.dry_run: if opts.dry_run:
@@ -349,7 +352,7 @@ def main(argv):
if opts.mode == "c": if opts.mode == "c":
if opts.verbose >= 0: if opts.verbose >= 0:
w_header_c(w, ifile, ofile, len(idata)) w_header_c(w, ifile, ofile, len(idata))
w("/* clang" + "-format" + " off */\n\n") w(("/* clang" + "-format" + " off */\n\n").encode())
for i in range(len(mdata)): for i in range(len(mdata)):
write_stub(w, mdata_odata[mdata[i]], i, mdata) write_stub(w, mdata_odata[mdata[i]], i, mdata)
if ofp: if ofp:
+8 -8
View File
@@ -1,4 +1,4 @@
#! /usr/bin/env python2 #! /usr/bin/env python3
## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*-
# #
# brandelf.py -- # brandelf.py --
@@ -54,32 +54,32 @@ def do_file(fn):
def write(s): def write(s):
if not opts.dry_run: if not opts.dry_run:
fp.write(s) fp.write(s.encode())
def brand_arm(s): def brand_arm(s):
if e_ident[4:7] != s: if e_ident[4:7] != s.encode():
raise Exception("%s is not %s" % (fn, opts.bfdname)) raise Exception("%s is not %s" % (fn, opts.bfdname))
write("\x61") # ELFOSABI_ARM write("\x61") # ELFOSABI_ARM
def brand_freebsd(s): def brand_freebsd(s):
if e_ident[4:7] != s: if e_ident[4:7] != s.encode():
raise Exception("%s is not %s" % (fn, opts.bfdname)) raise Exception("%s is not %s" % (fn, opts.bfdname))
write("\x09") write("\x09")
def brand_linux(s): def brand_linux(s):
if e_ident[4:7] != s: if e_ident[4:7] != s.encode():
raise Exception("%s is not %s" % (fn, opts.bfdname)) raise Exception("%s is not %s" % (fn, opts.bfdname))
##write("\x00Linux\x00\x00\x00") ##write("\x00Linux\x00\x00\x00")
write("\x00" * 9) write("\x00" * 9)
def brand_netbsd(s): def brand_netbsd(s):
if e_ident[4:7] != s: if e_ident[4:7] != s.encode():
raise Exception("%s is not %s" % (fn, opts.bfdname)) raise Exception("%s is not %s" % (fn, opts.bfdname))
write("\x02") write("\x02")
def brand_openbsd(s): def brand_openbsd(s):
if e_ident[4:7] != s: if e_ident[4:7] != s.encode():
raise Exception("%s is not %s" % (fn, opts.bfdname)) raise Exception("%s is not %s" % (fn, opts.bfdname))
write("\x0c") write("\x0c")
if opts.bfdname[:3] == "elf": if opts.bfdname[:3] == "elf":
if e_ident[:4] != "\x7f\x45\x4c\x46": if e_ident[:4] != "\x7f\x45\x4c\x46".encode():
raise Exception("%s is not %s" % (fn, "ELF")) raise Exception("%s is not %s" % (fn, "ELF"))
fp.seek(7, 0) fp.seek(7, 0)
if opts.bfdname == "elf32-bigarm" and opts.elfosabi == "arm": if opts.bfdname == "elf32-bigarm" and opts.elfosabi == "arm":
+8 -8
View File
@@ -1,4 +1,4 @@
#! /usr/bin/env python2 #! /usr/bin/env python3
## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*-
# #
# gpp_inc.py -- Generic PreProcessor: include # gpp_inc.py -- Generic PreProcessor: include
@@ -83,7 +83,7 @@ def parse_comment(state, l, comment):
def handle_inc_c(state, l, ofp): def handle_inc_c(state, l, ofp):
m = re.search(r"^\s*\#\s*include\s+([\"\<])(.+?)([\"\>])(.*)$", l) m = re.search(r"^\s*\#\s*include\s+([\"\<])(.+?)([\"\>])(.*)$", l.decode())
if not m: if not m:
return l return l
q1, inc, q2, comment = m.groups() q1, inc, q2, comment = m.groups()
@@ -93,7 +93,7 @@ def handle_inc_c(state, l, ofp):
elif q1 == '"' and q2 == '"': elif q1 == '"' and q2 == '"':
dirs = [state[1]] + opts.includes dirs = [state[1]] + opts.includes
else: else:
raise Exception("syntax error: include line " + l) raise Exception("syntax error: include line " + l.decode())
for dir in dirs: for dir in dirs:
fn = os.path.join(dir, inc) fn = os.path.join(dir, inc)
if os.path.isfile(fn): if os.path.isfile(fn):
@@ -130,13 +130,13 @@ def handle_file(ifn, ofp, parent_state=None):
ifp = open(ifn, "rb") ifp = open(ifn, "rb")
for l in ifp.readlines(): for l in ifp.readlines():
state[2] += 1 # line counter state[2] += 1 # line counter
l = l.rstrip("\n") l = l.rstrip("\n".encode())
if opts.mode == "c": if opts.mode == "c":
l = handle_inc_c(state, l, ofp) l = handle_inc_c(state, l, ofp)
elif opts.mode == "nasm": elif opts.mode == "nasm":
l = handle_inc_nasm(state, l, ofp) l = handle_inc_nasm(state, l, ofp)
if l is not None: if l is not None:
ofp.write(l + "\n") ofp.write(l + "\n".encode())
def main(argv): def main(argv):
@@ -179,12 +179,12 @@ def main(argv):
os.unlink(fn) os.unlink(fn)
if files_mmd: if files_mmd:
fp = open(fn, "wb") fp = open(fn, "wb")
fp.write("%s : \\\n" % opts.target_mmd) fp.write(("%s : \\\n" % opts.target_mmd).encode())
for i, f in enumerate(files_mmd): for i, f in enumerate(files_mmd):
if i < len(files_mmd) - 1: if i < len(files_mmd) - 1:
fp.write(" %s \\\n" % f) fp.write((" %s \\\n" % f).encode())
else: else:
fp.write(" %s\n" % f) fp.write((" %s\n" % f).encode())
fp.close() fp.close()
+13 -13
View File
@@ -1,4 +1,4 @@
#! /usr/bin/env python2 #! /usr/bin/env python3
## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*- ## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*-
# #
# xstrip.py -- truncate ELF objects created by multiarch-objcopy-2.17 # xstrip.py -- truncate ELF objects created by multiarch-objcopy-2.17
@@ -46,7 +46,7 @@ def strip_with_dump(dump_fn, eh, idata):
new_len = 0 new_len = 0
lines = open(dump_fn, "rb").readlines() lines = open(dump_fn, "rb").readlines()
for l in lines: for l in lines:
l = re.sub(r"\s+", " ", l.strip()) l = re.sub(r"\s+", " ", l.strip().decode())
f = l.split(" ") f = l.split(" ")
if len(f) >= 8: if len(f) >= 8:
if f[7].startswith("CONTENTS"): if f[7].startswith("CONTENTS"):
@@ -54,9 +54,9 @@ def strip_with_dump(dump_fn, eh, idata):
sh_size = int("0x" + f[2], 16) sh_size = int("0x" + f[2], 16)
if sh_offset + sh_size > new_len: if sh_offset + sh_size > new_len:
new_len = sh_offset + sh_size new_len = sh_offset + sh_size
##print sh_offset, sh_size, f ##print (sh_offset, sh_size, f)
if new_len > len(eh): if new_len > len(eh):
##print dump_fn, new_len ##print (dump_fn, new_len)
return eh, idata[:new_len-len(eh)] return eh, idata[:new_len-len(eh)]
return eh, idata return eh, idata
@@ -67,7 +67,7 @@ def strip_with_dump(dump_fn, eh, idata):
def check_dump(dump_fn): def check_dump(dump_fn):
lines = open(dump_fn, "rb").readlines() lines = open(dump_fn, "rb").readlines()
lines = map(lambda l: re.sub(r"\s+", " ", l.strip()).strip(), lines) lines = map(lambda l: re.sub(r"\s+", " ", l.strip().decode()).strip(), lines)
lines = filter(None, lines) lines = filter(None, lines)
d = "\n".join(lines) d = "\n".join(lines)
psections = d.find("Sections:\n") psections = d.find("Sections:\n")
@@ -88,10 +88,10 @@ def check_dump(dump_fn):
assert int(f[0], 10) == len(sections) assert int(f[0], 10) == len(sections)
e = f[1], int(f[2], 16), int(f[5], 16), int(f[6][3:], 10), len(sections) e = f[1], int(f[2], 16), int(f[5], 16), int(f[6][3:], 10), len(sections)
sections.append(e) sections.append(e)
assert not section_names.has_key(e[0]), e assert not e[0] in section_names, e
assert not e[0].endswith(":"), ("bad section name", e) assert not e[0].endswith(":"), ("bad section name", e)
section_names[e[0]] = e section_names[e[0]] = e
##print sections ##print (sections)
# preprocessSymbols # preprocessSymbols
symbols = [] symbols = []
section = None section = None
@@ -140,25 +140,25 @@ def do_file(fn):
fp = open(fn, "r+b") fp = open(fn, "r+b")
fp.seek(0, 0) fp.seek(0, 0)
idata = fp.read() idata = fp.read()
if idata[:4] != "\x7f\x45\x4c\x46": if idata[:4] != "\x7f\x45\x4c\x46".encode():
raise Exception("%s is not %s" % (fn, "ELF")) raise Exception("%s is not %s" % (fn, "ELF"))
if idata[4:7] == "\x01\x01\x01": if idata[4:7] == "\x01\x01\x01".encode():
# ELF32 LE # ELF32 LE
eh, idata = idata[:52], idata[52:] eh, idata = idata[:52], idata[52:]
e_shnum, e_shstrndx = struct.unpack("<HH", eh[48:52]) e_shnum, e_shstrndx = struct.unpack("<HH", eh[48:52])
assert e_shstrndx + 3 == e_shnum assert e_shstrndx + 3 == e_shnum
##eh = eh[:48] + struct.pack("<HH", e_shnum - 3, e_shstrndx) ##eh = eh[:48] + struct.pack("<HH", e_shnum - 3, e_shstrndx)
elif idata[4:7] == "\x01\x02\x01": elif idata[4:7] == "\x01\x02\x01".encode():
# ELF32 BE # ELF32 BE
eh, idata = idata[:52], idata[52:] eh, idata = idata[:52], idata[52:]
e_shnum, e_shstrndx = struct.unpack(">HH", eh[48:52]) e_shnum, e_shstrndx = struct.unpack(">HH", eh[48:52])
assert e_shstrndx + 3 == e_shnum assert e_shstrndx + 3 == e_shnum
elif idata[4:7] == "\x02\x01\x01": elif idata[4:7] == "\x02\x01\x01".encode():
# ELF64 LE # ELF64 LE
eh, idata = idata[:64], idata[64:] eh, idata = idata[:64], idata[64:]
e_shnum, e_shstrndx = struct.unpack("<HH", eh[60:64]) e_shnum, e_shstrndx = struct.unpack("<HH", eh[60:64])
assert e_shstrndx + 3 == e_shnum assert e_shstrndx + 3 == e_shnum
elif idata[4:7] == "\x02\x02\x01": elif idata[4:7] == "\x02\x02\x01".encode():
# ELF64 BE # ELF64 BE
eh, idata = idata[:64], idata[64:] eh, idata = idata[:64], idata[64:]
e_shnum, e_shstrndx = struct.unpack(">HH", eh[60:64]) e_shnum, e_shstrndx = struct.unpack(">HH", eh[60:64])
@@ -167,7 +167,7 @@ def do_file(fn):
raise Exception("%s is not %s" % (fn, "ELF")) raise Exception("%s is not %s" % (fn, "ELF"))
odata = None odata = None
pos = idata.find("\0.symtab\0.strtab\0.shstrtab\0") pos = idata.find("\0.symtab\0.strtab\0.shstrtab\0".encode())
if opts.with_dump: if opts.with_dump:
eh, odata = strip_with_dump(opts.with_dump, eh, idata) eh, odata = strip_with_dump(opts.with_dump, eh, idata)
# Other compilers can intermix the contents of .rela sections # Other compilers can intermix the contents of .rela sections
+212 -1
View File
@@ -94,7 +94,212 @@ _start: .globl _start
push %rsp; pop %rdi // argv push %rsp; pop %rdi // argv
push %rcx // argc push %rcx // argc
push %rdx // param for atexit() push %rdx // param for atexit()
lea cancel_dummy(%rip),%r15
section ELFSIGSEGV
// install SIGSEGV handler for debugging
SIGSEGV= 11
SA_SIGINFO= 4 // /usr/include/bits/sigaction.h
SA_RESTORER= 0x04000000
__NR_rt_sigaction= 13 // /usr/include/asm/unistd_64.h
push %rdi // save reg
sub %edx,%edx // arg3= 0 ==> do not save old sigaction
push %rdx // .sa_mask: 64 bits (8 bytes) of flags for signals
lea __restore_rt(%rip),%rax; push %rax // .sa_restorer
push $SA_RESTORER | SA_SIGINFO // .sa_flags
lea sigsegv_sigaction(%rip),%rax; push %rax // .sa_sigaction
lea cancel_sigsegv(%rip),%r15
push %rsp; pop %rsi // arg2= &new struct sigaction
push $SIGSEGV; pop %rdi // arg1= signum
push $8; pop %r10 // sys4= sizeof(__sigset_t) ==> 64 bits
push $__NR_rt_sigaction; pop %rax; syscall
add $(3 + 1) * NBPW,%rsp // toss struct sigaction
pop %rdi // restore reg
#if 0 //{ TEST ONLY
movl $0x18181818,%r8d
movl $0x19191919,%r9d
movl $0x1a1a1a1a,%r10d
movl $0x1b1b1b1b,%r11d
movl $0x1c1c1c1c,%r12d
movl $0x1d1d1d1d,%r13d
movl $0x1e1e1e1e,%r14d
movl $0x1f1f1f1f,%r15d
movl $0xaaaaaaaa,%eax
movl $0xbbbbbbbb,%ebx
movl $0xcccccccc,%ecx
movl $0xdddddddd,%edx
movl $0x55555555,%ebp
movl $0x66666666,%esi
movl $0x77777777,%edi
movl (%rdx),%edx // force SIGSEGV
#endif // TEST_ONLY}
jmp end_sigsegv
__NR_rt_sigreturn= 15
__restore_rt:
endbr64
mov $__NR_rt_sigreturn,%eax
syscall
sigsegv_sigaction:
endbr64
push %rdx // save &ucontext_t
// print /proc/self/maps of child (same as parent: the beauty of fork())
mov $end_announce_sigaction - announce_sigaction,%edx // arg3 len
lea announce_sigaction(%rip),%rsi // arg2 buf
push $2; pop %rdi // arg1 fd_stderr
push $__NR_write; pop %rax; syscall // ignore error on write()
xor %esi,%esi // arg2 O_RDONLY
lea proc_self_maps(%rip),%arg1
push $__NR_open; pop %rax; syscall
mov %rax,%r12 // fd_maps
BUFLEN= 4096
mov $BUFLEN,%ebx; sub %rbx,%rsp // allocate buffer
loop_maps:
mov %ebx,%edx // arg3 buflen
push %rsp; pop %rsi // arg2 buffer
mov %r12,%rdi // arg1 fd_maps
xor %eax,%eax; syscall // __NR_read
test %eax,%eax; jle done_maps // ignore error on read()
mov %eax,%edx // arg3 buflen
push %rsp; pop %rsi // arg2 buf
push $2; pop %rdi // arg1 fd_stderr
push $__NR_write; pop %rax; syscall // ignore error on write()
jmp loop_maps
done_maps:
mov %r12,%rdi //arg1 fd_maps
add %rbx,%rsp // discard buffer
push $__NR_close; pop %rax; syscall
// end printing of /proc/self/maps
pop %rdx // restore &ucontext_t
__NR_fork= 57
push $__NR_fork; pop %rax; call sys_check
test %eax,%eax; je child
parent:
jmp parent // spin; paused by gdb
proc_self_cmdline:
.asciz "/proc/self/cmdline"
announce_sigaction:
.asciz "\n\nSIGSEGV address space:\n"
end_announce_sigaction:
proc_self_maps:
.asciz "/proc/self/maps"
minus_q:
.asciz "-q"
path_gdb:
.asciz "/usr/bin/gdb"
commands_gdb:
.ascii "set prompt\n" // null string prompt
.ascii "info inferiors\n"
// ucontext_t, mcontext_t, gregset_t, gret_t, REG_xxx: <sys/ucontext.h>
// stack_t <bits/types/stack_t.h>
.ascii "print \"r8 - r15\"\n"
.ascii "x/8xg $rdx + 5*8\n"
.ascii "print \"rdi, rsi, rbp, rbx\"\n"
.ascii "x/4xg\n"
.ascii "print \"rdx, rax, rcx, rsp\"\n"
.ascii "x/4xg\n"
.ascii "print \"rip, efl\"\n"
.ascii "x/2xg\n"
.ascii "set $pc = *(long *)($rdx + 168)\n"
.ascii "print \"faulting instr\"\n"
.ascii "x/i $pc\n"
.ascii "print \"fault context\"\n"
.ascii "x/16i $pc - 0x20\n"
.ascii "print \"user stack\"\n"
.ascii "x/64xg *(long *)($rdx + 5*8 + 15*8)\n"
.ascii "kill\n"
.ascii "quit 1"
.byte 0
commands_gdb_end:
child:
PATH_MAX= 4096
sub $PATH_MAX,%rsp
lea proc_self_cmdline(%rip),%arg1
O_RDONLY= 0
push $O_RDONLY; pop %arg2
push $__NR_open; pop %rax; call sys_check
push %rax; pop %arg1 // fd
push %rsp; pop %arg2 // buffer
push $PATH_MAX; pop %arg3
__NR_read= 0
push $__NR_read; pop %rax; call sys_check
push $__NR_close; pop %rax; call sys_check
__NR_getppid= 110
push $__NR_getppid; pop %rax; syscall
push %rax; pop %rsi
xor %eax,%eax; push %rax; push %rax // decimal(pid) fits in 16 bytes
push %rsp; pop %rdi; call unsimal
// argv
push %rsp; pop %rsi // fence post: &pid.unsimal
push $0 // argv[4]
push %rsi // arg3 pid
add $16,%rsi; push %rsi // arg2 exename
lea minus_q(%rip),%rax; push %rax // arg1 "-q"
add $(path_gdb - minus_q),%rax; push %rax // arg[0] "/usr/bin/gdb"
#if 1 //{ pipe input to gdb
xor %edi,%edi; push $__NR_close; pop %rax; syscall
push %rax; push %rsp; pop %rdi // &fd_pipe[2]; 4 bytes each
__NR_pipe= 22
push $__NR_pipe; pop %rax; call sys_check
pop %rdi; shr $32,%rdi // arg1 write side of pipe
push $commands_gdb_end - commands_gdb; pop %arg3
lea commands_gdb(%rip),%arg2
__NR_write= 1
push $__NR_write; pop %rax; call sys_check
push $__NR_close; pop %rax; syscall
#endif //}
push $0; pop %arg3 // _environ BUG
push %rsp; pop %arg2 // argv
movq (%arg2),%arg1 // "/usr/bin/gdb"
__NR_execve= 59
push $__NR_execve; pop %rax; call sys_check
hlt
unsimal: // (dst, value)
push $10; pop %rcx // radix
mov %esi,%eax // value
call 0f
movb $0,(%rdi) // terminator
ret
0:
xor %edx,%edx; div %ecx; push %rdx // eax= quo(%edx:%eax / %ecx); edx= rem
// 'div' undefines all flags!
test %eax,%eax; je 1f; call 0b
1:
pop %rax; add $'0',%eax
stosb
ret
// Uninstall SIGSEGV handler
cancel_sigsegv:
endbr64
push $8; pop %sys4 // sys_arg4 minimal byte count
xor %edx,%edx // no old
xor %esi,%esi // no new
push $SIGSEGV; pop %rdi
push $__NR_rt_sigaction; pop %eax; syscall
ret
end_sigsegv:
section ELFMAINX2
#define old_sp %rbp #define old_sp %rbp
F_FRAME= 7*NBPW F_FRAME= 7*NBPW
F_ENTR= 6*NBPW; F_PMASK= F_ENTR F_ENTR= 6*NBPW; F_PMASK= F_ENTR
@@ -105,8 +310,9 @@ F_ELFA= 2*NBPW
F_LENX= 1*NBPW F_LENX= 1*NBPW
F_ADRX= 0*NBPW F_ADRX= 0*NBPW
D_FOLD= 1*NBPW // .data space at start of unfold D_FOLD= 2*NBPW // .data space at start of unfold
D_PMASK= 0*NBPW D_PMASK= 0*NBPW
D_XSIGSEGV= 1*NBPW
// find auxv // find auxv
xor %eax,%eax // 0 xor %eax,%eax // 0
@@ -264,6 +470,7 @@ eof_n2b:
// Write de-compressed 'fold' to file // Write de-compressed 'fold' to file
mov F_PMASK(old_sp),%rax; mov %rax,/*D_PMASK*/(%rsp) // propagate PAGE_MASK mov F_PMASK(old_sp),%rax; mov %rax,/*D_PMASK*/(%rsp) // propagate PAGE_MASK
mov %r15,D_XSIGSEGV(%rsp) // propagate cancel_sigsegv
mov F_LENU(old_sp),%arg3 // LENU mov F_LENU(old_sp),%arg3 // LENU
sub $INSURANCE,%arg3 // memcheck limit sub $INSURANCE,%arg3 // memcheck limit
push %rsp; pop %arg2 // buffer push %rsp; pop %arg2 // buffer
@@ -295,6 +502,10 @@ eof_n2b:
add $D_FOLD,%rax // beyond .data add $D_FOLD,%rax // beyond .data
jmp *%rax // goto unfolded stub jmp *%rax // goto unfolded stub
cancel_dummy:
endbr64
ret
sys_check: sys_check:
push %rax // save __NR_ for debug push %rax // save __NR_ for debug
syscall syscall
+8 -4
View File
@@ -81,6 +81,7 @@ is_ptinterp= (1<<0)
.balign 8 .balign 8
PAGE_MASK: .quad -1<<12 // default PAGE_MASK: .quad -1<<12 // default
cancel_sigsegv: .quad 0 // subroutine that cancels sigaction(SIGSEGV,)
// IN: [ADRX,+LENX): compressed data; [ADRU,+LENU): expanded fold (w/ upx_main2) // IN: [ADRX,+LENX): compressed data; [ADRU,+LENU): expanded fold (w/ upx_main2)
// %rsp= %rbp= &F_ADRX; %r13= O_BINFO | is_ptinterp | unmap_all_pages // %rsp= %rbp= &F_ADRX; %r13= O_BINFO | is_ptinterp | unmap_all_pages
@@ -174,9 +175,12 @@ no_env_pse:
*/ */
// rsp/ {OVERHEAD},ADRU,LENU,rdx,%entry, argc,argv,0,envp,0,auxv,0,strings // rsp/ {OVERHEAD},ADRU,LENU,rdx,%entry, argc,argv,0,envp,0,auxv,0,strings
addq $OVERHEAD,%rsp # Elf64_Ehdr temporary space addq $OVERHEAD,%rsp # Elf64_Ehdr temporary space
mov %ebp,%ebx # fd #define r_fd ebx
mov %ebp,%r_fd
movq %rax,3*NBPW(%rsp) # entry movq %rax,3*NBPW(%rsp) # entry
call *cancel_sigsegv(%rip)
sz_Ehdr= 8*NBPW sz_Ehdr= 8*NBPW
e_type= 16 e_type= 16
ET_EXEC= 2 ET_EXEC= 2
@@ -190,16 +194,16 @@ p_memsz= 5*NBPW
movq %r13,%arg1; call munmap # discard C_TEXT compressed data movq %r13,%arg1; call munmap # discard C_TEXT compressed data
// Map 1 page of /proc/self/exe so that the symlink does not disappear. // Map 1 page of /proc/self/exe so that the symlink does not disappear.
test %ebx,%ebx; js no_pse_map test %r_fd,%r_fd; js no_pse_map
subq %arg6,%arg6 # 0 offset subq %arg6,%arg6 # 0 offset
mov %ebx,%arg5l # fd mov %r_fd,%arg5l # fd
push $MAP_PRIVATE; pop %arg4 push $MAP_PRIVATE; pop %arg4
push $PROT_READ; pop %arg3 push $PROT_READ; pop %arg3
mov $1<<12,%arg2l mov $1<<12,%arg2l
subl %arg1l,%arg1l # 0 subl %arg1l,%arg1l # 0
call mmap call mmap
mov %ebx,%edi # fd mov %r_fd,%edi # fd
call close call close
.macro NOTRACK .macro NOTRACK
+18 -3
View File
@@ -102,7 +102,7 @@ memcpy: .globl memcpy // void *memcpy(void *dst, void const *src, size_t n)
/* 64-bit mode only! */ /* 64-bit mode only! */
__NR_read= 0 __NR_read= 0
__NR_write= 1 __NR_write= 1
//__NR_open= 2 __NR_open= 2
__NR_openat= 257 __NR_openat= 257
FD_CWD= -100 FD_CWD= -100
__NR_close= 3 __NR_close= 3
@@ -190,8 +190,6 @@ exit: .globl exit
push $ __NR_exit; 5: jmp 5f push $ __NR_exit; 5: jmp 5f
ftruncate: .globl ftruncate ftruncate: .globl ftruncate
push $__NR_ftruncate; 5: jmp 5f push $__NR_ftruncate; 5: jmp 5f
memfd_create: .globl memfd_create
push $__NR_memfd_create; 5: jmp 5f
close: .globl close close: .globl close
push $ __NR_close; 5: jmp 5f push $ __NR_close; 5: jmp 5f
openat: .globl openat openat: .globl openat
@@ -202,4 +200,21 @@ write: .globl write
read: .globl read read: .globl read
push $ __NR_read; 5: jmp sysgo push $ __NR_read; 5: jmp sysgo
memfd_create: .globl memfd_create
0:
movl $__NR_memfd_create,%eax; syscall
test %eax,%eax; js 1f; ret // success
1:
test %arg2l,%arg2l; jz no_memfd // memfd_create failed twice
xor %arg2l,%arg2l; jmp 0b // try again without MFD_EXEC
no_memfd: // so try /dev/shm
O_RDWR= 2
O_DIRECTORY= 0200000 // 0x010000
O_TMPFILE= 020000000 // 0x400000
call 0f; .int 0700, O_RDWR|O_DIRECTORY|O_TMPFILE; .asciz "/dev/shm"; 0: pop %rsi
lodsl; xchg %eax,%arg3l
lodsl; push %rsi; xchg %eax,%arg2l
pop %arg1
push $__NR_open; jmp sysgo
// section SO_MAIN inserted here // section SO_MAIN inserted here
+2 -2
View File
@@ -198,7 +198,7 @@ ifneq ($(wildcard $(WATCOM)/binl/wcl),)
# step 3: clean asm # step 3: clean asm
lzma_d_c%.S : tmp/lzma_d_c%.i cleanasm.py $(MAKEFILE_LIST) lzma_d_c%.S : tmp/lzma_d_c%.i cleanasm.py $(MAKEFILE_LIST)
$(PYTHON) cleanasm.py --label-prefix=$(LABEL_PREFIX) $< $@ $(PYTHON2) cleanasm.py --label-prefix=$(LABEL_PREFIX) $< $@
# step 2: compile, strip and disasm # step 2: compile, strip and disasm
tmp/lzma_d_c%.i : tmp/lzma_d_c%.S $(MAKEFILE_LIST) tmp/lzma_d_c%.i : tmp/lzma_d_c%.S $(MAKEFILE_LIST)
@@ -233,7 +233,7 @@ ifneq ($(wildcard $(WATCOM)/binl/wcl),)
$(call tc,wdis) tmp/$T_wc.obj | $(RTRIM) > tmp/$T_wc.obj.disasm $(call tc,wdis) tmp/$T_wc.obj | $(RTRIM) > tmp/$T_wc.obj.disasm
endif endif
# convert # convert
$(PYTHON) wdis2gas.py tmp/$T_wc.obj.disasm $@ $(PYTHON2) wdis2gas.py tmp/$T_wc.obj.disasm $@
.PRECIOUS: tmp/lzma_d_c%.i tmp/lzma_d_c%.S .PRECIOUS: tmp/lzma_d_c%.i tmp/lzma_d_c%.S
+250 -28
View File
@@ -66,6 +66,8 @@ MAP_ANONYMOUS= 0x20
MAP_FIXED= 0x10 MAP_FIXED= 0x10
MAP_PRIVATE= 0x02 MAP_PRIVATE= 0x02
FD_CWD= -1 // AT_CWD= -100
FD_stdin= 0
FD_stderr= 2 FD_stderr= 2
O_RDONLY= 0 O_RDONLY= 0
@@ -81,13 +83,15 @@ PAGE_SIZE = ( 1<<PAGE_SHIFT)
__NR_SYSCALL_BASE = 0 __NR_SYSCALL_BASE = 0
__NR_exit= 1 + __NR_SYSCALL_BASE
__NR_open= 5 + __NR_SYSCALL_BASE
__NR_close= 6 + __NR_SYSCALL_BASE __NR_close= 6 + __NR_SYSCALL_BASE
__NR_execve= 11 + __NR_SYSCALL_BASE
__NR_exit= 1 + __NR_SYSCALL_BASE
__NR_fdatasync=148 + __NR_SYSCALL_BASE __NR_fdatasync=148 + __NR_SYSCALL_BASE
__NR_fork= 2 + __NR_SYSCALL_BASE
__NR_fsync= 118 + __NR_SYSCALL_BASE __NR_fsync= 118 + __NR_SYSCALL_BASE
__NR_ftruncate=93 + __NR_SYSCALL_BASE __NR_ftruncate=93 + __NR_SYSCALL_BASE
__NR_getpid= 20 + __NR_SYSCALL_BASE __NR_getpid= 20 + __NR_SYSCALL_BASE
__NR_getppid= 64 + __NR_SYSCALL_BASE
__NR_lseek= 19 + __NR_SYSCALL_BASE __NR_lseek= 19 + __NR_SYSCALL_BASE
__NR_memfd_create= 385 + __NR_SYSCALL_BASE __NR_memfd_create= 385 + __NR_SYSCALL_BASE
__NR_mkdir= 39 + __NR_SYSCALL_BASE __NR_mkdir= 39 + __NR_SYSCALL_BASE
@@ -95,12 +99,16 @@ __NR_mmap2= 192 + __NR_SYSCALL_BASE
__NR_mprotect=125 + __NR_SYSCALL_BASE __NR_mprotect=125 + __NR_SYSCALL_BASE
__NR_msync= 144 + __NR_SYSCALL_BASE // 0x90 __NR_msync= 144 + __NR_SYSCALL_BASE // 0x90
__NR_open= 5 + __NR_SYSCALL_BASE __NR_open= 5 + __NR_SYSCALL_BASE
__NR_openat= 322 + __NR_SYSCALL_BASE
__NR_pipe= 42 + __NR_SYSCALL_BASE
__NR_read= 3 + __NR_SYSCALL_BASE __NR_read= 3 + __NR_SYSCALL_BASE
__NR_sigaction=67 + __NR_SYSCALL_BASE
__NR_stat= 106 + __NR_SYSCALL_BASE __NR_stat= 106 + __NR_SYSCALL_BASE
__NR_uname= 122 + __NR_SYSCALL_BASE __NR_uname= 122 + __NR_SYSCALL_BASE
__NR_unlink= 10 + __NR_SYSCALL_BASE __NR_unlink= 10 + __NR_SYSCALL_BASE
__NR_write= 4 + __NR_SYSCALL_BASE __NR_write= 4 + __NR_SYSCALL_BASE
__ARM_NR_BASE= 0xf0000 + __NR_SYSCALL_BASE __ARM_NR_BASE= 0xf0000 + __NR_SYSCALL_BASE
__ARM_NR_cacheflush= 2 + __ARM_NR_BASE __ARM_NR_cacheflush= 2 + __ARM_NR_BASE
@@ -118,21 +126,24 @@ __ARM_NR_cacheflush= 2 + __ARM_NR_BASE
section ELFMAINX section ELFMAINX
F_ADRX= 0*NBPW F_ADRX= 0*NBPW
F_obinfo= F_ADRX // unmap_all_pages in lo bits
F_LENX= 1*NBPW F_LENX= 1*NBPW
F_ELFA= 2*NBPW F_ELFA= 2*NBPW
F_ADRU= 3*NBPW F_SEGV= 3*NBPW
F_LENU= 4*NBPW F_ADRU= 4*NBPW
F_R0= 5*NBPW F_LENU= 5*NBPW
F_R1= 6*NBPW F_R0= 6*NBPW
F_ENTR= 7*NBPW F_R1= 7*NBPW
F_QFLG= F_ENTR F_ENTR= 8*NBPW
F_SIZE= 8*NBPW F_qflg= F_ENTR // QNX mmap flags
F_SIZE= 9*NBPW
// (read-only) .data space at start of unfolded code // (read-only) .data space at start of unfolded code
D_PMASK= 0*NBPW D_PMASK= 0*NBPW
D_FNAME= 1*NBPW D_QFLG= 1*NBPW
D_QFLG= 2*NBPW D_FNAME= 2*NBPW
D_FOLD= 3*NBPW // start of code D_XSEGV= 3*NBPW
D_FOLD= 4*NBPW // start of code
r_pack2 .req r9 r_pack2 .req r9
r_pmask .req r8 r_pmask .req r8
@@ -142,9 +153,58 @@ sz_pack2= . - NBPW
mflg: mflg:
.word MFLG // MAP_{PRIVATE|ANONYMOUS} // QNX vs linux .word MFLG // MAP_{PRIVATE|ANONYMOUS} // QNX vs linux
_start: .globl _start _start: .globl _start
//// nop; bkpt // DEBUG //// nop; bkpt // DEBUG
stmdb sp!,{r0,r1,lr} // ABI crt0 -static may have data here ldr r_pack2,sz_pack2
sub sp,sp,#-3*NBPW + F_SIZE // F_R0,F_R1 separately ldr r2,mflg
adr r3,sz_pack2
sub r3,r3,r_pack2 @ elfaddr= &Elf_Ehdr of this program
call 0f; cancel_dummy: ret; 0:
stmdb sp!,{r0,r1,r2} // F_R0,F_R1,%F_ENTR(F_QFLG)
sub sp,sp,#2*NBPW // space for F_ADRU, F_LENU
stmdb sp!,{r0,r1,r3,lr} // %F_ADRX,%F_LENX,F_ELFA,F_SEGV
section ELFSIGSEGV
// install SIGSEGV handler for debugging
SIGSEGV= 11
SA_SIGINFO= 4 // /usr/include/bits/sigaction.h
SA_RESTORER= 0x04000000
sa_sigaction = 0 * NBPW
sa_flags = 1 * NBPW
sa_mask = 3 * NBPW // location of mask
sa_restorer = 4 * NBPW
sa_frame = 5 * NBPW
call adr_sigaction; mov r0,lr // .sa_sigaction
mov r1,#SA_SIGINFO // .sa_flags
mov r2,#0 // .sa_mask
mov r3,#0
mov r4,#0 // .sa_restorer
stmdb sp!,{r0,r1,r2,r3,r4}
mov arg4,#8 // 8 bytes ==> 64 bits
mov arg3,#0 // do not save old_sigaction
mov arg2,sp // &new_sigaction
mov arg1,#SIGSEGV
do_sys7t __NR_sigaction
add sp,sp,#sa_frame
call 0f
cancel_sigsegv:
mov r3,#8 // space for 8 bytes of signal flags
mov r2,#0 // no old
mov r1,#0 // no new
mov r0,#SIGSEGV
do_sys7t __NR_sigaction
ret
0:
str lr,[sp,#F_SEGV]
#if 0 //{ TEST ONLY
mov r0,#0xc0;mov r1,#0xc1;mov r2,#0xc2;mov r3,#0xc3;mov r4,#0xc4;mov r5,#0xc5;mov r6,#0xc6;mov r7,#0xc7
mov r8,#0xc8;mov r9,#0xc9;mov r10,#0xca;mov r11,#0xcb;mov r12,#0xcc
ldr r0,[r0] // cause SIGSEGV
#endif //}
section ELFMAINX2
add arg1,sp,#NBPW + F_SIZE // avoid feint of 0==argc add arg1,sp,#NBPW + F_SIZE // avoid feint of 0==argc
call zfind // out: r0= &envp call zfind // out: r0= &envp
call zfind call zfind
@@ -159,14 +219,6 @@ _start: .globl _start
mvn r2,r2; add r2,r2,#1 // neg mvn r2,r2; add r2,r2,#1 // neg
mov r_pmask,r2 mov r_pmask,r2
ldr r1,sz_pack2
adr r0,sz_pack2
sub r0,r0,r1 @ elfaddr= &Elf_Ehdr of this program
str r0,[sp,#F_ELFA]
mov r_pack2,r1 @ save sz_pack2
ldr r0,mflg
str r0,[sp,#F_QFLG]
call get_data // cpr0 can be too far away call get_data // cpr0 can be too far away
old_sp .req r11 old_sp .req r11
@@ -216,10 +268,11 @@ mfd .req old_sp
mov mfd,r0 mov mfd,r0
//}{ r0 free, r1 busy //}{ r0 free, r1 busy
add r4,r_unc,# 2*NBPW + D_FOLD add r4,r_unc,# 2*NBPW + D_FOLD
ldr r5,[sp,#F_SEGV]
and r4,r4, #-2*NBPW // align displacement and r4,r4, #-2*NBPW // align displacement
ldr r3,[sp,#F_QFLG] ldr r3,[sp,#F_qflg]
mov r2,r_pmask mov r2,r_pmask
stmia r1,{r2,r3,r4} // D_PMASK, D_QFLG, D_FNAME stmia r1,{r2,r3,r4,r5} // F_ADRU: D_PMASK, D_QFLG, D_FNAME, D_SEGV
.unreq r_pmask .unreq r_pmask
// De-compress folded stage of stub // De-compress folded stage of stub
@@ -242,7 +295,7 @@ mfd .req old_sp
ldr arg3,[sp,#F_LENU] ldr arg3,[sp,#F_LENU]
ldr arg2,[sp,#F_ADRU] ldr arg2,[sp,#F_ADRU]
mov arg1,mfd mov arg1,mfd
do_sys __NR_write do_sys7t __NR_write
mov r5,#0 mov r5,#0
mov r4,mfd mov r4,mfd
@@ -261,13 +314,182 @@ mfd .req old_sp
add r4,r0,r1 @ ADRX= &b_info | unmap_all_pages add r4,r0,r1 @ ADRX= &b_info | unmap_all_pages
bic r1,r1,#unmap_all_pages bic r1,r1,#unmap_all_pages
sub r5,r_pack2,r1 @ LENX= sz_pack2 - O_BINFO sub r5,r_pack2,r1 @ LENX= sz_pack2 - O_BINFO
stmia sp,{r4,r5} // F_ADRX, F_LENX stmia sp,{r4,r5} // sp: F_ADRX, F_LENX; (sp no change)
#if DEBUG /*{*/ #if DEBUG /*{*/
stmdb sp!,{TRACE_REGS}; mov r0,#3; bl trace stmdb sp!,{TRACE_REGS}; mov r0,#3; bl trace
#endif /*}*/ #endif /*}*/
ldr r12,[sp,#F_ADRU] ldr r12,[sp,#F_ADRU]
add pc,r12,#D_FOLD // goto unfolded code add pc,r12,#D_FOLD // goto unfolded code
proc_self_cmdline:
.asciz "/proc/self/cmdline"
.balign 4
#define r_fd r6
PATH_MAX= 4096
child:
#if 1 //{ pipe input to gdb
mov arg1,#FD_stdin; do_sys7t __NR_close
mov arg2,#0; mov arg1,#0; stmdb sp!,{arg1,arg2} // space for result of pipe()
mov arg1,sp
do_sys7t __NR_pipe // read side will be 0 (FD_stdin)
ldmia sp!,{r0,r_fd} // write side of pipe
mov arg3,#commands_gdb_end - commands_gdb // len
adr arg2,commands_gdb
mov arg1,r_fd
do_sys7t __NR_write
mov arg1,r_fd; do_sys7t __NR_close
#endif //}
sub sp,sp,#PATH_MAX
mov arg3,#O_RDONLY
adr arg2,proc_self_cmdline
mov arg1,#FD_CWD
do_sys7t2 __NR_openat; mov r_fd,r0 // fd
mov arg2,sp // buffer
mov arg3,#PATH_MAX
do_sys7t __NR_read
mov arg1,r_fd; do_sys7t __NR_close
do_sys7t __NR_getppid
sub sp,sp,#16 // decimal(pid) fits in 16 bytes
mov arg2,arg1; mov arg1,sp; call unsimal
mov arg5,#0 // terminator
mov arg4,sp // &"pid" (result of unsimal)
add arg3,sp,#16 // cmdline argv[0] [skip "pid"]
adr arg2,minus_q
adr arg1,path_gdb
stmdb sp!,{arg1,arg2,arg3,arg4,arg5} // argv
mov arg3,#0 // _envviron BUG
mov arg2,sp // &argv
do_sys7t __NR_execve
0:
b 0b
minus_q:
.asciz "-q"
path_gdb:
.asciz "/usr/bin/gdb"
commands_gdb:
.ascii "set prompt\n" // null string prompt
.ascii "info inferiors\n"
.ascii "print \"r0-r7\"\n"
.ascii "x/8xw $sp + 0x28\n"
.ascii "print \"r8-r15\"\n"
.ascii "x/8xw\n"
.ascii "set $pc = *(int *)($sp + 0x64)\n"
.ascii "print \"faulting instr\"\n"
.ascii "x/i $pc\n"
.ascii "print \"fault context\"\n"
.ascii "x/15i $pc - 7*4\n"
//.ascii "print \"intercept stack\"\n"
//.ascii "x/76xw $sp\n"
.ascii "set $sp = *(long *)($sp + 0x5c)\n"
.ascii "print \"user stack\"\n"
.ascii "x/64xw $sp\n"
.ascii "kill\n"
.ascii "quit 1"
.byte 0
commands_gdb_end:
.balign 4
// ucontext_t, mcontext_t, gregset_t, gret_t, REG_xxx: <sys/ucontext.h>
// stack_t <bits/types/stack_t.h>
__restore_rt:
nop
proc_self_maps:
.asciz "/proc/self/maps"
announce_sigaction:
.ascii "\n\nSIGSEGV address space:\n"
end_announce_sigaction:
.balign 4
adr_sigaction:
mov r12,lr; mov lr,pc; mov pc,r12 // blx lr
sigsegv_sigaction:
stmdb sp!,{arg2,arg3} // save siginfo *, ucontext *
// print /proc/self/maps of child (same as parent: the beauty of fork())
mov arg3,#end_announce_sigaction - announce_sigaction // arg3 len
adr arg2,announce_sigaction // buf
mov arg1,#FD_stderr
do_sys7t __NR_write
mov arg3,#O_RDONLY // flags
adr arg2,proc_self_maps // path
mov arg1,#FD_CWD
do_sys7t2 __NR_openat; mov r_fd,r0 // fd_maps
BUFLEN= 4096
sub sp,sp,#BUFLEN
loop_maps:
mov arg3,#BUFLEN // buflen
mov arg2,sp // buffer
mov arg1,r_fd // fd_maps
do_sys7t __NR_read
cmp r0,#0; beq done_maps
mov arg3,r0 // buflen
mov arg2,sp // buf
mov arg1,#FD_stderr
do_sys7t __NR_write
b loop_maps
done_maps:
add sp,sp,#BUFLEN // discard buffer
mov arg1,r_fd; do_sys7t __NR_close
// end printing of /proc/self/maps
mov arg1,#0; mov arg2,#0 // paranoia
do_sys7t __NR_fork
cmp r0,#0; beq child // fork()
parent:
NR_exit= 1
b parent // spin; paused by gdb
unsimal: // (dst, value)
mov r2,#0
stmdb sp!,{r2,lr}; call 0f
ldmia sp!,{r2,lr}
strb r2,[r0] // terminator
ret
0:
mov ip,r1 // extra copy used at end
mov r2,#0 // hi
mov r3,r1 // copy lo
adds r1,r1,r1,lsl #3 // 9*lo
adc r2,r2,r2,lsl #3 // 9*hi + C
add r2,r2,r3,lsr #(32 - 3) // bits shifted from lo to hi
mov r3,r1 // copy lo
adds r1,r1,r1,lsl #4
adc r2,r2,r2,lsl #4
add r2,r2,r3,lsr #(32 - 4) // * 0x99
mov r3,r1 // copy lo
adds r1,r1,r1,lsl #8
adc r2,r2,r2,lsl #8
add r2,r2,r3,lsr #(32 - 8) // * 0x9999
mov r3,r1 // copy lo
adds r1,r1,r1,lsl #16
adc r2,r2,r2,lsl #16
add r2,r2,r3,lsr #(32 - 16) // * 0x99999999
subs r1,r1,ip,lsl #(32 - 1) // - * 0x80000000
sbc r2,r2,ip,lsr #1 // * 0x19999999
adds r1,r1,ip
adcs r1,r2,#0 // * 0x0.1999999a; r1 = quo(ip, 10); set flags
add r2,r1,r1,lsl #2 // r2 = quo * 5
sub r2,ip,r2,lsl #1 // rem = ip - 10 * quo
stmdb sp!,{r2,lr} // save rem and retaddr
beq 1f; call 0b // stop if 0==quo; else recurse for next remainder
1:
ldmia sp!,{r1,lr}; add r1,r1,#'0'; strb r1,[r0],#1
ret
zfind: zfind:
ldr r1,[r0],#NBPW ldr r1,[r0],#NBPW
cmp r1,#0; bne zfind cmp r1,#0; bne zfind
@@ -322,7 +544,7 @@ L610: @ each word
mov r0,#'\n'; strb r0,[r2],#1 mov r0,#'\n'; strb r0,[r2],#1
sub r2,r2,sp @ count sub r2,r2,sp @ count
mov r1,sp @ buf mov r1,sp @ buf
mov r0,#2 @ FD_STDERR mov r0,#FD_stderr
#if defined(ARMEL_EABI4) /*{*/ #if defined(ARMEL_EABI4) /*{*/
mov r7,#__NR_write mov r7,#__NR_write
swi 0 swi 0
+29 -21
View File
@@ -66,11 +66,6 @@ PATH_MAX= 4096
#define call bl #define call bl
#include "MAX_ELF_HDR.S" #include "MAX_ELF_HDR.S"
ZERO= . - 3*NBPW
page_mask= . - 3*NBPW; .globl page_mask
qflg_data = . - 2*NBPW // QNX vs Linux: MAP_PRIVATE | MAP_ANONYMOUS
upxfn_path= . - 1*NBPW // displacement from "zero"
arg1 .req r0 arg1 .req r0
arg2 .req r1 arg2 .req r1
arg3 .req r2 arg3 .req r2
@@ -78,6 +73,12 @@ arg4 .req r3
arg5 .req r4 arg5 .req r4
arg6 .req r5 arg6 .req r5
ZERO= . - 4*NBPW // 4 words initialized prior to unfolded code
page_mask= . - 4*NBPW
qflg_data = . - 3*NBPW // QNX vs Linux: MAP_PRIVATE | MAP_ANONYMOUS
upxfn_path= . - 2*NBPW // displacement from ZERO
cancel_sigsegv= . - 1*NBPW
fold_begin: // enter here fold_begin: // enter here
b L05 // put page_mask and qflg_data within short-displacement of uses b L05 // put page_mask and qflg_data within short-displacement of uses
@@ -141,20 +142,21 @@ mmap_do: // sp: saved r4,r5,lr
proc_self_exe: .asciz "/proc/self/exe"; .balign 4 proc_self_exe: .asciz "/proc/self/exe"; .balign 4
// In: sp/ F_ADRX,F_LENX,F_ELFA,F_ADRU,F_LENU,F_R0,F_R1,%F_ENTR,F_argc // In: sp/ F_ADRX,F_LENX,F_ELFA,f_SEGV,F_ADRU,F_LENU,F_R0,F_R1,%F_ENTR,F_argc
// [ADRX, +LENX) = extent of compressed program // [ADRX, +LENX) = extent of compressed program
// [ADRU, +LENU) = params to munmap unfolded stub // [ADRU, +LENU) = params to munmap unfolded stub
F_ADRX= 0*NBPW F_ADRX= 0*NBPW
F_obinfo= F_ADRX // unmap_all_pages in lo bits F_obinfo= F_ADRX // unmap_all_pages in lo bits
F_LENX= 1*NBPW F_LENX= 1*NBPW
F_ELFA= 2*NBPW F_ELFA= 2*NBPW
F_ADRU= 3*NBPW F_SEGV= 3*NBPW
F_LENU= 4*NBPW F_ADRU= 4*NBPW
F_R0= 5*NBPW F_LENU= 5*NBPW
F_R1= 6*NBPW F_R0= 6*NBPW
F_ENTR= 7*NBPW F_R1= 7*NBPW
F_qflg = F_ENTR // QNX mmap flags F_ENTR= 8*NBPW
F_ARGC= 8*NBPW F_qflg= F_ENTR // QNX mmap flags
F_argc= 9*NBPW
is_ptinterp= (1<<0) is_ptinterp= (1<<0)
unmap_all_pages= (1<<1) unmap_all_pages= (1<<1)
@@ -162,17 +164,17 @@ unmap_all_pages= (1<<1)
/* In: /* In:
r4= ADRX | unmap_all_pages r4= ADRX | unmap_all_pages
r5= LENX r5= LENX
sp/ ADRX|uap,LENX,ELFA,ADRU,LENU,r0,r1,%entry, argc,argv,0,envp,0,auxv sp/ ADRX|uap,LENX,ELFA,r0,r1,%entry,SEGV,ADRU,LENU, argc,argv,0,envp,0,auxv
(ADRX,LENX) = extent of compressed program (ADRX,LENX) = extent of compressed program
(ADRU,LENU) = params to munmap unfolded stub (ADRU,LENU) = params to munmap unfolded stub
*/ */
L05: L05:
ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12} // F_ADRX .. F_ARGC ldmia sp!,{r3,r4,r5,r6,r7,r8,r9,r10,r11,r12} // F_ADRX .. F_ARGC
mov r1,sp @ src mov r1,sp @ src
tst r4,#unmap_all_pages; bne 0f; sub sp,sp,#PATH_MAX; 0: tst r3,#unmap_all_pages; bne 0f; sub sp,sp,#PATH_MAX; 0:
mov r0,sp @ dst mov r0,sp @ dst
stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12} stmdb sp!,{r3,r4,r5,r6,r7,r8,r9,r10,r11,r12}
0: // copy argv down 0: // copy argv down
ldr r3,[r1],#NBPW; cmp r3,#0 ldr r3,[r1],#NBPW; cmp r3,#0
@@ -255,6 +257,9 @@ r_elfa .req r9
add sp,sp,#MAX_ELF_HDR_32 + OVERHEAD @ un-alloca add sp,sp,#MAX_ELF_HDR_32 + OVERHEAD @ un-alloca
str r0,[sp,#F_ENTR] @ entry address str r0,[sp,#F_ENTR] @ entry address
adr lr,0f; ldr pc,[sp,#F_SEGV] // cancel_sigsegv
0:
// Map 1 page of /proc/self/exe so that it does not disappear // Map 1 page of /proc/self/exe so that it does not disappear
ldr r0,[sp,#F_obinfo]; tst r0,#unmap_all_pages; bne no_map_pse ldr r0,[sp,#F_obinfo]; tst r0,#unmap_all_pages; bne no_map_pse
mov arg6,#0 @ SEEK_SET offset mov arg6,#0 @ SEEK_SET offset
@@ -290,7 +295,7 @@ sweep:
add sp,sp,#(1<<18) @ pop stack add sp,sp,#(1<<18) @ pop stack
#endif //} #endif //}
add sp,sp,#3*NBPW // toss F_ADRX,F_LENX,F_ELFA add sp,sp,#4*NBPW // toss F_ADRX,F_LENX,F_ELFA,F_SEGV
ldmia sp!,{arg1,arg2} @ F_ADRU,F_LENU ldmia sp!,{arg1,arg2} @ F_ADRU,F_LENU
stmdb sp!,{r_auxe} stmdb sp!,{r_auxe}
mov r3,#0 @ clear registers: paranoia mov r3,#0 @ clear registers: paranoia
@@ -315,6 +320,9 @@ sweep:
#endif /*}*/ #endif /*}*/
ldmia sp!,{r12} // r_auxe ldmia sp!,{r12} // r_auxe
ldr pc,[r12,#NBPW -2*NBPW] @ hatch: Elf32_auxv_t[AT_NULL@.a_type].a_val ldr pc,[r12,#NBPW -2*NBPW] @ hatch: Elf32_auxv_t[AT_NULL@.a_type].a_val
// hatch:
// svc 0 // In: r7= __NR_munmap; arg1= F_ADRU; arg2= F_LENU
// pop {r0,r1,pc} // F_R0, F_R1, F_ENTR
f_unfilter: @ (char *ptr, uint len, uint cto, uint fid) f_unfilter: @ (char *ptr, uint len, uint cto, uint fid)
ptr .req r0 ptr .req r0
+215 -8
View File
@@ -76,12 +76,18 @@ PAGE_SIZE = -(~0<<PAGE_SHIFT)
// /usr/include/asm-generic/unistd.h // /usr/include/asm-generic/unistd.h
__NR_close = 0x39 // 57 __NR_close = 0x39 // 57
__NR_execve = 0xdd // 221
__NR_exit = 0x5d // 93 __NR_exit = 0x5d // 93
__NR_fork = 0xdc // 220
__NR_getppid = 0xad // 173
__NR_memfd_create= 0x117 // 279 __NR_memfd_create= 0x117 // 279
__NR_mmap = 0xde // 222 __NR_mmap = 0xde // 222
__NR_mprotect = 0xe2 // 226 __NR_mprotect = 0xe2 // 226
__NR_munmap = 0xd7 // 215 __NR_munmap = 0xd7 // 215
__NR_openat = 0x38 // 56 __NR_openat = 0x38 // 56
__NR_pipe2 = 0x3b // 59
__NR_read = 0x3f // 63
__NR_sigaction = 0x86 // 134
AT_FDCWD= -100 AT_FDCWD= -100
__NR_write = 0x40 // 64 __NR_write = 0x40 // 64
@@ -134,6 +140,13 @@ wszuf .req w21
xszuf .req x21 xszuf .req x21
xFOLD .req x20 xFOLD .req x20
wPrivAnon .req w19 wPrivAnon .req w19
cancel_SEGV .req x18
D_PMASK= 0*NBPW
D_XSIGSEGV= 1*NBPW
D_GETPM= 2*NBPW
D_PRIVANON= 2*NBPW + 2*4
D_FOLD= 2*NBPW + 3*4 // .data space at start of unfold
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
// x18 is CLOBBERED: "The platform register" // x18 is CLOBBERED: "The platform register"
@@ -154,7 +167,198 @@ _start: .globl _start
#endif /*}*/ #endif /*}*/
stp x0,x1,[sp,#-2*NBPW]! // ABI: -static crt0 might pass data in x0,x1 stp x0,x1,[sp,#-2*NBPW]! // ABI: -static crt0 might pass data in x0,x1
ldr wPrivAnon,mflg ldr wPrivAnon,mflg
adr cancel_SEGV,cancel_dummy
section ELFSIGSEGV
// install SIGSEGV handler for debugging hardware and de-compressor
SIGSEGV= 11
SA_SIGINFO= 4 // /usr/include/bits/sigaction.h
SA_RESTORER= 0x04000000
sa_sigaction = 0 * NBPW
sa_flags = 1 * NBPW
sa_mask = 3 * NBPW // location of mask
sa_restorer = 4 * NBPW
sa_frame = 8 * NBPW
adr x0,sigsegv_sigaction // handler
mov x1,#SA_SIGINFO // flag bits
stp x0,x1,[sp,-sa_frame]! // .sa_sigaction, .sa_flags
str xzr,[sp,sa_mask] // .sa_mask
str xzr,[sp,sa_restorer]
mov x3,#8 // 8 bytes ==> 64 bits
mov x2,xzr // do not save old_sigaction
mov x1,sp // &new_sigaction
mov w0,#SIGSEGV
do_sys __NR_sigaction
add sp,sp,sa_frame
adr cancel_SEGV,cancel_sigsegv
b L300
#if 0 //{ TEST ONLY
mov x0,#0xc0;mov x1,#0xc1;mov x2,#0xc2;mov x3,#0xc3;mov x4,#0xc4;mov x5,#0xc5;mov x6,#0xc6;mov x7,#0xc7
mov x8,#0xc8;mov x9,#0xc9;mov x10,#0xca;mov x11,#0xcb;mov x12,#0xcc;mov x13,#0xcd;mov x14,#0xce;mov x15,#0xcf
mov x16,#0xd0;mov x17,#0xd1;mov x18,#0xd2;mov x19,#0xd3;mov x20,#0xd4;mov x21,#0xd5;mov x22,#0xd6;mov x23,#0xd7
mov x24,#0xd8;mov x25,#0xd9;mov x26,#0xda;mov x27,#0xdb;mov x28,#0xdc;mov x29,#0xdd;mov x30,#0xde
ldr x0,[x0] // cause SIGSEGV
#endif //}
proc_self_cmdline:
.asciz "/proc/self/cmdline"
announce_sigaction:
.asciz "\n\nSIGSEGV address space:\n"
end_announce_sigaction:
proc_self_maps:
.asciz "/proc/self/maps"
minus_q:
.asciz "-q"
path_gdb:
.asciz "/usr/bin/gdb"
commands_gdb:
.ascii "set prompt\n" // null string prompt
.ascii "info inferiors\n"
.ascii "print \"x0-x7\"\n"
.ascii "x/8xg $sp + 0x138\n"
.ascii "print \"x8-x15\"\n"
.ascii "x/8xg\n"
.ascii "print \"x16-x23\"\n"
.ascii "x/8xg\n"
.ascii "print \"x24-x30\"\n"
.ascii "x/7xg\n"
.ascii "set $pc = *(long *)($sp + 0x238)\n"
.ascii "print \"faulting instr\"\n"
.ascii "x/i $pc\n"
.ascii "print \"fault context\"\n"
.ascii "x/15i $pc - 7*4\n"
//.ascii "print \"intercept stack\"\n"
//.ascii "x/76xg $sp\n"
.ascii "set $sp = *(long *)($sp + 0x230)\n"
.ascii "print \"user stack\"\n"
.ascii "x/64xg $sp\n"
.ascii "kill\n"
.ascii "quit 1"
.byte 0
commands_gdb_end:
.balign 4
#define r_fd w19
PATH_MAX= 4096
child:
#if 1 //{ pipe input to gdb
mov arg1w,#0; do_sys __NR_close // fd_stdin
stp xzr,xzr,[sp,-2 * NBPW]! // &fd_pipe[2]; 4 bytes each; but stack align
mov arg2w,#0
mov arg1,sp
do_sys __NR_pipe2 // read size will be 0 (fd_stdin)
add x16,sp,#4
ldr r_fd,[x16] // write side of pipe
add sp,sp,#2*NBPW
mov w2,#commands_gdb_end - commands_gdb // arg3 len
adr x1,commands_gdb // arg2
mov w0,r_fd // arg1 fd
do_sys __NR_write
mov w0,r_fd; do_sys __NR_close
#endif //}
sub sp,sp,#PATH_MAX
mov arg3w,#O_RDONLY
adr arg2,proc_self_cmdline
mov arg1,#-1 // fake FD_CWD
do_sys __NR_openat; mov r_fd,w0
mov arg2,sp // buffer
mov arg3w,#PATH_MAX
do_sys __NR_read
mov arg1w,r_fd; do_sys __NR_close
do_sys __NR_getppid
stp xzr,xzr,[sp,-2 * NBPW]! // decimal(pid) fits in 16 bytes
mov w1,w0; mov x0,sp; call unsimal
mov arg4,sp // &"pid" (result of unsimal)
add arg3,sp,#2 * NBPW // cmdline argv[0] [skip "pid"]
adr arg2,minus_q
adr arg1,path_gdb // arg1 path
stp arg1,arg2,[sp,-6 *NBPW]! // path_gdb, "-q"
stp arg3,arg4,[sp,2 *NBPW] // argv[0], "pid"
str xzr,[sp,4 * NBPW] // NULL
mov arg3,#0 // _envviron BUG
mov arg2,sp // &argv
do_sys __NR_execve
0:
b 0b
// ucontext_t, mcontext_t, gregset_t, gret_t, REG_xxx: <sys/ucontext.h>
// stack_t <bits/types/stack_t.h>
__restore_rt:
nop
sigsegv_sigaction:
stp x1,x2,[sp,-2 * NBPW] // save siginfo *, ucontext *
// print /proc/self/maps of child (same as parent: the beauty of fork())
mov x2,#end_announce_sigaction - announce_sigaction // arg3 len
adr x1,announce_sigaction // arg2 buf
mov w0,#2 // arg1 fd_stderr
do_sys __NR_write
mov w2,#O_RDONLY // arg3 flags
adr x1,proc_self_maps // arg2 path
mov w0,#-1 // fake FD_CWD
do_sys __NR_openat
mov r_fd,w0 // fd_maps
BUFLEN= 4096
sub sp,sp,#BUFLEN
loop_maps:
mov x2,#BUFLEN // arg3 buflen
mov x1,sp // arg2 buffer
mov w0,r_fd // arg1 fd_maps
do_sys __NR_read
cbz w0,done_maps
mov x2,x0 // arg3 buflen
mov x1,sp // arg2 buf
mov w0,#2 // fd_stderr
do_sys __NR_write
b loop_maps
done_maps:
add sp,sp,#BUFLEN // discard buffer
mov x0,x16; do_sys __NR_close
// end printing of /proc/self/maps
mov arg1,#0; mov arg2,#0 // paranoia
do_sys __NR_fork; cbz x0,child
parent:
b parent // spin; paused by gdb
unsimal: // (dst, value)
stp lr,xzr,[sp,-2 * NBPW]!; call 0f
ldp lr,x1,[sp],#2 * NBPW
strb w1,[x0] // terminator
ret
0:
mov w2,#0xcccd
movk w2, 0xcccc, lsl 16 // 0xcccccccd ==> 4/5 as 32-bit fraction
umull x2,w1,w2
//add x2,x2,#0x1000 // BUG? unsimal(p, 730)
lsr x3,x2,35 // quo(value, 10)
add w2,w3,w3,lsl 2 // 5 * quo
sub w1,w1,w2,lsl 1 // rem = (val - (10 * quo))
stp lr,x1,[sp,-2 * NBPW]!
cbz x3,1f; mov w1,w3; call 0b
1:
ldp lr,x1,[sp],#2 * NBPW; add w1,w1,#'0'; strb w1,[x0],#1
ret
cancel_sigsegv:
mov x3,#8 // 8 bytes ==> 64 bits
mov x2,xzr // no old
mov x1,xzr // no new
mov w0,#SIGSEGV
do_sys __NR_sigaction
ret
L300:
section ELFMAINX2
add x0,sp,#(1+ 2)*NBPW add x0,sp,#(1+ 2)*NBPW
call zfind // avoid feint of 0==argc; out: x0= &envp call zfind // avoid feint of 0==argc; out: x0= &envp
call zfind; mov xauxv,x0 // &Elf64_auxv call zfind; mov xauxv,x0 // &Elf64_auxv
@@ -175,8 +379,11 @@ F_LENU= 3 * NBPW
neg xPMASK,x2 // save for folded code neg xPMASK,x2 // save for folded code
str xPMASK,[sp,#F_PMASK] str xPMASK,[sp,#F_PMASK]
adr xelfa,sz_pack2
ldr w0,[xelfa] // sz_pack2 causes unknown R_AARCH64_LD_PREL_LO19
str x0,[sp,#F_SZPK2]
sub xelfa,xelfa,w0,uxtw
call main call main
L00:
mov xFOLD,lr mov xFOLD,lr
mov w1,#MFD_EXEC // flags mov w1,#MFD_EXEC // flags
@@ -231,7 +438,8 @@ wmeth .req w4
.unreq xmeth .unreq xmeth
.unreq wmeth .unreq wmeth
str xPMASK,[sp] // propagate PAGE_MASK str xPMASK,[sp] // propagate PAGE_MASK D_PMASK
str cancel_SEGV,[sp, #D_XSIGSEGV]
// Write de-compressed stub // Write de-compressed stub
ldr w2,[xFOLD,#sz_unc + LBINFO - LxFOLD] // .sz_unc of fold ldr w2,[xFOLD,#sz_unc + LBINFO - LxFOLD] // .sz_unc of fold
@@ -255,13 +463,16 @@ wmeth .req w4
// Use the unfolded stub // Use the unfolded stub
ldr wLENC,[sp,#F_SZPK2] ldr wLENC,[sp,#F_SZPK2]
ldr w1,[xFOLD, #LOBINFO - LxFOLD] // O_BINFO ldr w1,[xFOLD, #LOBINFO - LxFOLD] // O_BINFO
add lr,xADRU,#3*4 + NBPW // jmp to fold_begin add lr,xADRU,#D_FOLD // jmp to fold_begin
sub wLENC,wLENC,w1 sub wLENC,wLENC,w1
str xLENC,[sp,#F_SZPK2] str xLENC,[sp,#F_SZPK2]
bic w1,w1,#unmap_all_pages bic w1,w1,#unmap_all_pages
add xADRC,xelfa,x1 // &b_info of compressed input data add xADRC,xelfa,x1 // &b_info of compressed input data
jr lr // goto unfolded stub jr lr // goto unfolded stub
cancel_dummy:
ret
zfind: zfind:
ldr x1,[x0],#NBPW; cbnz x1,zfind ldr x1,[x0],#NBPW; cbnz x1,zfind
ret ret
@@ -383,12 +594,8 @@ strupx:
.asciz "upx" .asciz "upx"
.balign 4 .balign 4
main: main: // In: w0= sz_pack2
lr .req x30 lr .req x30
add xelfa,lr,#sz_pack2 - L00 // &sz_pack2
ldr w0,[xelfa]
sub xelfa,xelfa,w0,uxtw
str x0,[sp,#F_SZPK2]
callr lr callr lr
LxFOLD: LxFOLD:
LOBINFO: LOBINFO:
+9 -6
View File
@@ -84,16 +84,16 @@ PATH_MAX= 4096
#define OVERHEAD 2048 #define OVERHEAD 2048
#include "MAX_ELF_HDR.S" #include "MAX_ELF_HDR.S"
PAGE_MASK: .quad ~0<<12 // default PAGE_MASK: .quad ~0<<12 // default D_PMASK
get_page_mask: .globl get_page_mask cancel_sigsegv: .quad 0 // D_XSIGSEGV
get_page_mask: .globl get_page_mask // D_GETPM
ldr x0,PAGE_MASK ldr x0,PAGE_MASK
ret ret
bits_privanon: // known offset (2*NBPW + 2*4) D_PRIVANON
bits_privanon: // known offset (NBPW + 2*4)
.int MAP_PRIVATE | MAP_ANONYMOUS // Linux default; else QNX .int MAP_PRIVATE | MAP_ANONYMOUS // Linux default; else QNX
fold_begin: // known offset (NBPW + 3*4) fold_begin: // known offset D_FOLD = (2*NBPW + 3*4)
//// bkpt // DEBUG
b L10 b L10
// In: sp/ PMASK,LENC,ADRU,LENU, x0,x1, argc,argv,... // In: sp/ PMASK,LENC,ADRU,LENU, x0,x1, argc,argv,...
@@ -271,6 +271,9 @@ no_env_pse:
add sp,sp,#MAX_ELF_HDR_64 + OVERHEAD // un-alloca add sp,sp,#MAX_ELF_HDR_64 + OVERHEAD // un-alloca
mov xfexp,x0 // entry address mov xfexp,x0 // entry address
ldr x0,cancel_sigsegv
blr x0 // callr
// Discard pages of compressed input data (includes [ADRC,+LENC) ) // Discard pages of compressed input data (includes [ADRC,+LENC) )
ldr x1,[xelfa,#p_memsz+sz_Phdr+sz_Ehdr] // Phdr[C_TEXT= 1].p_memsz ldr x1,[xelfa,#p_memsz+sz_Phdr+sz_Ehdr] // Phdr[C_TEXT= 1].p_memsz
mov x0,xelfa // hi &Elf64_Ehdr mov x0,xelfa // hi &Elf64_Ehdr
+18 -9
View File
@@ -129,7 +129,7 @@ Pprotect: .globl Pprotect
b mprotect b mprotect
Psync: .globl Psync // (addr, len, flags) Psync: .globl Psync // (addr, len, flags)
mflr r0; bl 0f; 0: mflr r6; mtlr r0; lwz r0,page_mask - 0b(r6) mflr r0; bl 0f; 0: mflr r6; mtlr r0; ld r0,page_mask - 0b(r6)
andc r0,a0,r0 // offset within page andc r0,a0,r0 // offset within page
sub a0,a0,r0 sub a0,a0,r0
add a1,a1,r0 add a1,a1,r0
@@ -418,21 +418,30 @@ close: .globl close
li r0,SYS_close; 5: b sysgo li r0,SYS_close; 5: b sysgo
upxfd_create: .globl upxfd_create // (char *tag, unsigned flags) upxfd_create: .globl upxfd_create // (char *tag, unsigned flags)
stdu a0,-AL_STK(sp) // push tag onto aligned stack
0: // try memfd_create 0: // try memfd_create
ld a0,0(sp) // get tag
li r0,SYS_memfd_create; sc; bns+ ok_memfd li r0,SYS_memfd_create; sc; bns+ ok_memfd
cmpwi a2,0; beq no_memfd // memfd_create failed twice // failed syscall returns errno in a0
li a2,0; b 0b // try again without MFD_EXEC cmpwi a0,EINVAL; bne 8f // unexpected error number
cmpwi a1,0; beq no_memfd // memfd_create failed twice
li a1,0; b 0b // try again without MFD_EXEC
no_memfd: // so try /dev/shm no_memfd: // so try /dev/shm
O_RDWR= 2 O_RDWR= 2
O_DIRECTORY= 040000 // 0x4000 O_DIRECTORY= 040000 // 0x4000
O_TMPFILE= 020000000 // 0x400000 O_TMPFILE= 020000000 // 0x400000
mflr r6; bl 0f; .asciz "/dev/shm"; .balign 4; mflr r6
0: mflr a1; mtlr r6 bl 0f; .asciz "/dev/shm"; .balign 4
li a2,0700 0: mflr a0
lis a3,O_TMPFILE>>16 mtlr r6
ori a3,a3,O_RDWR | O_DIRECTORY li a2,0700 // mode
li r0,SYS_open; sc; bns+ ok_memfd; teq r0,r0 lis a1,O_TMPFILE>>16
ori a1,a1,O_RDWR | O_DIRECTORY
li r0,SYS_open; sc; bns+ ok_memfd // name, flags, mode
8:
teq r0,r0 // unexpected errno
ok_memfd: ok_memfd:
addi sp,sp,AL_STK // toss tag
ret ret
__NR_memfd_create= 360 __NR_memfd_create= 360
+23 -4
View File
@@ -2,17 +2,36 @@ file format elf64-x86-64
Sections: Sections:
Idx Name Size VMA LMA File off Algn Flags Idx Name Size VMA LMA File off Algn Flags
0 ELFMAINX 0193 0 0 040 2**0 CONTENTS 0 ELFMAINX 010 0 0 040 2**0 CONTENTS
1 ELFMAINZ 04 0 0 01d4 2**2 CONTENTS 1 ELFSIGSEGV 0310 0 0 050 2**0 CONTENTS
2 ELFMAINX2 0194 0 0 0360 2**0 CONTENTS
3 ELFMAINZ 04 0 0 04f4 2**2 CONTENTS
SYMBOL TABLE: SYMBOL TABLE:
0000000000000000 l d ELFMAINZ 0 ELFMAINZ
0000000000000000 l d ELFMAINX 0 ELFMAINX 0000000000000000 l d ELFMAINX 0 ELFMAINX
0000000000000000 l d ELFMAINX2 0 ELFMAINX2
0000000000000000 l d ELFMAINZ 0 ELFMAINZ
0000000000000000 l d ELFSIGSEGV 0 ELFSIGSEGV
0000000000000000 g ELFMAINX 0 _start 0000000000000000 g ELFMAINX 0 _start
0000000000000000 *UND* 0 O_BINFO 0000000000000000 *UND* 0 O_BINFO
RELOCATION RECORDS FOR [ELFMAINX]: RELOCATION RECORDS FOR [ELFMAINX]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
0000000000000073 R_X86_64_PC32 ELFMAINZ+0xfffffffffffffffc 000000000000000c R_X86_64_PC32 ELFMAINX2+0x0000000000000158
RELOCATION RECORDS FOR [ELFSIGSEGV]:
OFFSET TYPE VALUE
00000000000000a2 R_X86_64_PC32 ELFMAINX2+0x000000000000015d
0000000000000250 R_X86_64_PC32 ELFMAINX2+0x000000000000015d
0000000000000262 R_X86_64_PC32 ELFMAINX2+0x000000000000015d
000000000000026a R_X86_64_PC32 ELFMAINX2+0x000000000000015d
00000000000002a5 R_X86_64_PC32 ELFMAINX2+0x000000000000015d
00000000000002bf R_X86_64_PC32 ELFMAINX2+0x000000000000015d
00000000000002d4 R_X86_64_PC32 ELFMAINX2+0x000000000000015d
RELOCATION RECORDS FOR [ELFMAINX2]:
OFFSET TYPE VALUE
000000000000005e R_X86_64_PC32 ELFMAINX+0xfffffffffffffff8
000000000000006a R_X86_64_PC32 ELFMAINZ+0xfffffffffffffffc
RELOCATION RECORDS FOR [ELFMAINZ]: RELOCATION RECORDS FOR [ELFMAINZ]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
+8 -8
View File
@@ -8,14 +8,14 @@ Linker script and memory map
0x0000000000000040 . = SIZEOF_HEADERS 0x0000000000000040 . = SIZEOF_HEADERS
.text 0x0000000000000000 0x9cd .text 0x0000000000000000 0x9d9
.text 0x0000000000000000 0x165 tmp/amd64-linux.elf-fold.o .text 0x0000000000000000 0x173 tmp/amd64-linux.elf-fold.o
0x000000000000015d get_page_mask 0x000000000000016b get_page_mask
*fill* 0x0000000000000165 0x3 00 *fill* 0x0000000000000173 0x1 00
.text 0x0000000000000168 0x0 tmp/amd64-expand.o .text 0x0000000000000174 0x0 tmp/amd64-expand.o
.text 0x0000000000000168 0x865 tmp/amd64-linux.elf-main2.o .text 0x0000000000000174 0x865 tmp/amd64-linux.elf-main2.o
0x0000000000000898 upx_main2 0x00000000000008a4 upx_main2
0x00000000000002c6 underlay 0x00000000000002d2 underlay
UMF_LINUX 0x0000000000000000 0xf9 UMF_LINUX 0x0000000000000000 0xf9
UMF_LINUX 0x0000000000000000 0xf9 tmp/amd64-linux.elf-upxfd_linux.o UMF_LINUX 0x0000000000000000 0xf9 tmp/amd64-linux.elf-upxfd_linux.o
+18 -18
View File
@@ -8,18 +8,18 @@ Idx Name Size VMA LMA File off Algn
3 SO_MAIN 0813 0 0 0150 2**4 CONTENTS 3 SO_MAIN 0813 0 0 0150 2**4 CONTENTS
4 SO_HEAD 044 0 0 0963 2**0 CONTENTS 4 SO_HEAD 044 0 0 0963 2**0 CONTENTS
5 ptr_NEXT 0 0 0 09a7 2**0 CONTENTS 5 ptr_NEXT 0 0 0 09a7 2**0 CONTENTS
6 SO_TAIL 0c9 0 0 09a7 2**0 CONTENTS 6 SO_TAIL 0fa 0 0 09a7 2**0 CONTENTS
7 EXP_HEAD 0e9 0 0 0a70 2**0 CONTENTS 7 EXP_HEAD 0e9 0 0 0aa1 2**0 CONTENTS
8 NRV2E 0e8 0 0 0b59 2**0 CONTENTS 8 NRV2E 0e8 0 0 0b8a 2**0 CONTENTS
9 NRV2D 0db 0 0 0c41 2**0 CONTENTS 9 NRV2D 0db 0 0 0c72 2**0 CONTENTS
10 NRV2B 0c4 0 0 0d1c 2**0 CONTENTS 10 NRV2B 0c4 0 0 0d4d 2**0 CONTENTS
11 LZMA_DAISY 0a 0 0 0de0 2**0 CONTENTS 11 LZMA_DAISY 0a 0 0 0e11 2**0 CONTENTS
12 LZMA_ELF00 065 0 0 0dea 2**0 CONTENTS 12 LZMA_ELF00 065 0 0 0e1b 2**0 CONTENTS
13 LZMA_DEC10 09f7 0 0 0e4f 2**0 CONTENTS 13 LZMA_DEC10 09f7 0 0 0e80 2**0 CONTENTS
14 LZMA_DEC20 09f7 0 0 01846 2**0 CONTENTS 14 LZMA_DEC20 09f7 0 0 01877 2**0 CONTENTS
15 LZMA_DEC30 019 0 0 0223d 2**0 CONTENTS 15 LZMA_DEC30 019 0 0 0226e 2**0 CONTENTS
16 EXP_TAIL 014 0 0 02258 2**2 CONTENTS 16 EXP_TAIL 014 0 0 02288 2**2 CONTENTS
17 STRCON 04b 0 0 0226c 2**0 CONTENTS 17 STRCON 04b 0 0 0229c 2**0 CONTENTS
SYMBOL TABLE: SYMBOL TABLE:
0000000000000000 l d SO_HEAD 0 SO_HEAD 0000000000000000 l d SO_HEAD 0 SO_HEAD
0000000000000000 l d EXP_HEAD 0 EXP_HEAD 0000000000000000 l d EXP_HEAD 0 EXP_HEAD
@@ -54,22 +54,22 @@ SYMBOL TABLE:
0000000000000000 g F UMF_LINUX 0f9 upx_mmap_and_fd_linux 0000000000000000 g F UMF_LINUX 0f9 upx_mmap_and_fd_linux
0000000000000000 g F SO_TAIL 0 eof 0000000000000000 g F SO_TAIL 0 eof
00000000000004c3 g F SO_MAIN 0b9 prep_SELinux 00000000000004c3 g F SO_MAIN 0b9 prep_SELinux
00000000000000c1 g SO_TAIL 0 write 00000000000000ba g SO_TAIL 0 write
00000000000003fa g F SO_MAIN 01d PF_to_PROT 00000000000003fa g F SO_MAIN 01d PF_to_PROT
00000000000000af g SO_TAIL 0 memfd_create 00000000000000c2 g SO_TAIL 0 memfd_create
00000000000000c5 g SO_TAIL 0 read 00000000000000be g SO_TAIL 0 read
0000000000000184 g F SO_MAIN 0ef make_hatch 0000000000000184 g F SO_MAIN 0ef make_hatch
0000000000000013 g SO_TAIL 0 memset 0000000000000013 g SO_TAIL 0 memset
0000000000000042 g SO_TAIL 0 msync 0000000000000042 g SO_TAIL 0 msync
0000000000000011 g SO_TAIL 0 my_bkpt 0000000000000011 g SO_TAIL 0 my_bkpt
0000000000000046 g SO_TAIL 0 Pprotect 0000000000000046 g SO_TAIL 0 Pprotect
00000000000000c1 g SO_TAIL 0 Pwrite 00000000000000ba g SO_TAIL 0 Pwrite
0000000000000095 g SO_TAIL 0 Punmap 0000000000000095 g SO_TAIL 0 Punmap
00000000000000a7 g SO_TAIL 0 exit 00000000000000a7 g SO_TAIL 0 exit
00000000000000ba g SO_TAIL 0 openat 00000000000000b3 g SO_TAIL 0 openat
0000000000000080 g SO_TAIL 0 open 0000000000000080 g SO_TAIL 0 open
0000000000000057 g SO_TAIL 0 mprotect 0000000000000057 g SO_TAIL 0 mprotect
00000000000000b6 g SO_TAIL 0 close 00000000000000af g SO_TAIL 0 close
000000000000057c g F SO_MAIN 0297 upx_so_main 000000000000057c g F SO_MAIN 0297 upx_so_main
RELOCATION RECORDS FOR [HUMF_A]: RELOCATION RECORDS FOR [HUMF_A]:
+81 -59
View File
@@ -2,53 +2,100 @@ file format elf32-littlearm
Sections: Sections:
Idx Name Size VMA LMA File off Algn Flags Idx Name Size VMA LMA File off Algn Flags
0 ELFMAINY 0 0 0 034 2**0 CONTENTS 0 ELFSIGSEGV 05c 0 0 034 2**0 CONTENTS
1 HUMF_A 04 0 0 034 2**0 CONTENTS 1 ELFMAINX2 0598 0 0 090 2**2 CONTENTS
2 HUMF_L 04 0 0 038 2**0 CONTENTS 2 ELFMAINY 0 0 0 0628 2**0 CONTENTS
3 UMF_ANDROID 0544 0 0 03c 2**2 CONTENTS 3 HUMF_A 04 0 0 0628 2**0 CONTENTS
4 UMF_LINUX 0144 0 0 0580 2**2 CONTENTS 4 HUMF_L 04 0 0 062c 2**0 CONTENTS
5 ELFMAINX 0264 0 0 06c4 2**2 CONTENTS 5 UMF_ANDROID 0544 0 0 0630 2**2 CONTENTS
6 ELFMAINZ 0218 0264 0264 0928 2**0 CONTENTS 6 UMF_LINUX 0144 0 0 0b74 2**2 CONTENTS
7 ELFMAINX 028 0 0 0cb8 2**0 CONTENTS
8 ELFMAINZ 0218 028 028 0ce0 2**0 CONTENTS
SYMBOL TABLE: SYMBOL TABLE:
00000000 l d ELFSIGSEGV 0 ELFSIGSEGV
00000000 l d ELFMAINX2 0 ELFMAINX2
00000000 l d UMF_ANDROID 0 UMF_ANDROID 00000000 l d UMF_ANDROID 0 UMF_ANDROID
00000000 l d UMF_LINUX 0 UMF_LINUX 00000000 l d UMF_LINUX 0 UMF_LINUX
00000000 l d ELFMAINX 0 ELFMAINX 00000000 l d ELFMAINX 0 ELFMAINX
00000264 l d ELFMAINZ 0 ELFMAINZ 00000028 l d ELFMAINZ 0 ELFMAINZ
00000000 l d ELFMAINY 0 ELFMAINY 00000000 l d ELFMAINY 0 ELFMAINY
00000000 l d HUMF_A 0 HUMF_A 00000000 l d HUMF_A 0 HUMF_A
00000000 l d HUMF_L 0 HUMF_L 00000000 l d HUMF_L 0 HUMF_L
00000258 g ELFMAINX 0 get_page_mask 0000058c g ELFMAINX2 0 get_page_mask
00000000 *UND* 0 MFLG 00000000 *UND* 0 MFLG
00000350 g ELFMAINZ 0 getpid 00000114 g ELFMAINZ 0 getpid
00000264 g ELFMAINX 0 upx_mmap_and_fd 00000598 g ELFMAINX2 0 upx_mmap_and_fd
0000026c g ELFMAINZ 0 memcpy 00000030 g ELFMAINZ 0 memcpy
00000000 *UND* 0 O_BINFO 00000000 *UND* 0 O_BINFO
00000404 g ELFMAINZ 0 Psync 000001c8 g ELFMAINZ 0 Psync
000002b0 g ELFMAINZ 0 mempcpy 00000074 g ELFMAINZ 0 mempcpy
0000033c g ELFMAINZ 0 ftruncate 00000100 g ELFMAINZ 0 ftruncate
00000364 g ELFMAINZ 0 lseek 00000128 g ELFMAINZ 0 lseek
000002c4 g F UMF_ANDROID 0280 upx_mmap_and_fd_android 000002c4 g F UMF_ANDROID 0280 upx_mmap_and_fd_android
00000434 g ELFMAINZ 0 mmap 000001f8 g ELFMAINZ 0 mmap
00000000 g F UMF_LINUX 0144 upx_mmap_and_fd_linux 00000000 g F UMF_LINUX 0144 upx_mmap_and_fd_linux
000003c8 g ELFMAINZ 0 uname 0000018c g ELFMAINZ 0 uname
00000000 g ELFMAINY 0 end_decompress 00000000 g ELFMAINY 0 end_decompress
000003f0 g ELFMAINZ 0 write 000001b4 g ELFMAINZ 0 write
00000314 g ELFMAINZ 0 fdatasync 000000d8 g ELFMAINZ 0 fdatasync
00000264 g ELFMAINZ 0 get_upxfn_path 00000028 g ELFMAINZ 0 get_upxfn_path
000002cc g ELFMAINZ 0 memfd_create 00000090 g ELFMAINZ 0 memfd_create
00000004 g ELFMAINX 0 _start 00000004 g ELFMAINX 0 _start
000003a0 g ELFMAINZ 0 read 00000164 g ELFMAINZ 0 read
000003dc g ELFMAINZ 0 unlink 000001a0 g ELFMAINZ 0 unlink
00000290 g ELFMAINZ 0 memset 00000054 g ELFMAINZ 0 memset
00000194 g F ELFMAINX 0c4 ucl_nrv2b_decompress_8 000004c8 g F ELFMAINX2 0c4 ucl_nrv2b_decompress_8
0000042c g ELFMAINZ 0 my_bkpt 000001f0 g ELFMAINZ 0 my_bkpt
00000328 g ELFMAINZ 0 fsync 000000ec g ELFMAINZ 0 fsync
000003b4 g ELFMAINZ 0 stat 00000178 g ELFMAINZ 0 stat
0000047c g ELFMAINZ 0 cpr0 00000240 g ELFMAINZ 0 cpr0
00000300 g ELFMAINZ 0 exit 000000c4 g ELFMAINZ 0 exit
0000038c g ELFMAINZ 0 open 00000150 g ELFMAINZ 0 open
00000378 g ELFMAINZ 0 mkdir 0000013c g ELFMAINZ 0 mkdir
000002ec g ELFMAINZ 0 close 000000b0 g ELFMAINZ 0 close
RELOCATION RECORDS FOR [ELFSIGSEGV]:
OFFSET TYPE VALUE
00000000 R_ARM_PC24 ELFMAINX2
00000038 R_ARM_PC24 ELFSIGSEGV
RELOCATION RECORDS FOR [ELFMAINX2]:
OFFSET TYPE VALUE
00000004 R_ARM_PC24 ELFMAINX2
00000008 R_ARM_PC24 ELFMAINX2
00000014 R_ARM_PC24 ELFMAINX2
0000001c R_ARM_PC24 ELFMAINX2
00000030 R_ARM_PC24 ELFMAINZ
00000068 R_ARM_PC24 ELFMAINX2
00000078 R_ARM_PC24 upx_mmap_and_fd
00000080 R_ARM_PC24 ELFMAINX2
000000b0 R_ARM_PC24 ELFMAINX2
000000f0 R_ARM_PC24 ELFMAINX2
0000020c R_ARM_PC24 ELFMAINX2
00000238 R_ARM_PC24 ELFMAINX2
000003dc R_ARM_PC24 ELFMAINX2
000003f4 R_ARM_PC24 ELFMAINX2
0000041c R_ARM_PC24 ELFMAINX2
00000420 R_ARM_PC24 ELFMAINX2
0000042c R_ARM_PC24 ELFMAINX2
000004a0 R_ARM_PC24 ELFMAINX2
000004a4 R_ARM_PC24 ELFMAINX2
000004c0 R_ARM_PC24 ELFMAINX2
000004d8 R_ARM_PC24 ELFMAINX2
00000510 R_ARM_PC24 ELFMAINX2
00000518 R_ARM_PC24 ELFMAINX2
0000051c R_ARM_PC24 ELFMAINX2
0000052c R_ARM_PC24 ELFMAINX2
00000530 R_ARM_PC24 ELFMAINX2
00000534 R_ARM_PC24 ELFMAINX2
00000540 R_ARM_PC24 ELFMAINX2
00000550 R_ARM_PC24 ELFMAINX2
00000554 R_ARM_PC24 ELFMAINX2
0000055c R_ARM_PC24 ELFMAINX2
00000564 R_ARM_PC24 ELFMAINX2
00000568 R_ARM_PC24 ELFMAINX2
00000584 R_ARM_PC24 ELFMAINX2
00000588 R_ARM_PC24 ELFMAINX2
RELOCATION RECORDS FOR [HUMF_A]: RELOCATION RECORDS FOR [HUMF_A]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
@@ -171,32 +218,7 @@ OFFSET TYPE VALUE
RELOCATION RECORDS FOR [ELFMAINX]: RELOCATION RECORDS FOR [ELFMAINX]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
00000000 R_ARM_ABS32 MFLG 00000000 R_ARM_ABS32 MFLG
00000010 R_ARM_PC24 ELFMAINX
00000014 R_ARM_PC24 ELFMAINX 00000014 R_ARM_PC24 ELFMAINX
00000020 R_ARM_PC24 ELFMAINX
00000028 R_ARM_PC24 ELFMAINX
00000058 R_ARM_PC24 ELFMAINZ
00000090 R_ARM_PC24 ELFMAINX
000000a0 R_ARM_PC24 upx_mmap_and_fd
000000a8 R_ARM_PC24 ELFMAINX
000000d8 R_ARM_PC24 ELFMAINX
00000114 R_ARM_PC24 ELFMAINX
0000018c R_ARM_PC24 ELFMAINX
000001a4 R_ARM_PC24 ELFMAINX
000001dc R_ARM_PC24 ELFMAINX
000001e4 R_ARM_PC24 ELFMAINX
000001e8 R_ARM_PC24 ELFMAINX
000001f8 R_ARM_PC24 ELFMAINX
000001fc R_ARM_PC24 ELFMAINX
00000200 R_ARM_PC24 ELFMAINX
0000020c R_ARM_PC24 ELFMAINX
0000021c R_ARM_PC24 ELFMAINX
00000220 R_ARM_PC24 ELFMAINX
00000228 R_ARM_PC24 ELFMAINX
00000230 R_ARM_PC24 ELFMAINX
00000234 R_ARM_PC24 ELFMAINX
00000250 R_ARM_PC24 ELFMAINX
00000254 R_ARM_PC24 ELFMAINX
RELOCATION RECORDS FOR [ELFMAINZ]: RELOCATION RECORDS FOR [ELFMAINZ]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
+10 -11
View File
@@ -7,24 +7,23 @@ Name Origin Length Attributes
Linker script and memory map Linker script and memory map
.text 0x0000000000000000 0xcb8 .text 0x0000000000000000 0xcc0
.text 0x0000000000000000 0x398 tmp/arm.v4a-linux.elf-fold.o .text 0x0000000000000000 0x3a0 tmp/arm.v4a-linux.elf-fold.o
0x0000000000000004 get_page_mask 0x0000000000000004 get_page_mask
0x0000000000000338 memcpy 0x0000000000000340 memcpy
0x0000000000000048 Psync 0x0000000000000048 Psync
0x000000000000037c mempcpy 0x0000000000000384 mempcpy
0x00000000000000b0 mmap 0x00000000000000b0 mmap
0x0000000000000098 mmap_privanon 0x0000000000000098 mmap_privanon
0x000000000000000c get_upxfn_path 0x000000000000000c get_upxfn_path
0x000000000000035c memset 0x0000000000000364 memset
0x00000000fffffff4 page_mask
0x0000000000000024 Pprotect 0x0000000000000024 Pprotect
0x0000000000000024 mprotect 0x0000000000000024 mprotect
.text 0x0000000000000398 0x0 tmp/arm.v4a-linux.elf-help_umf.o .text 0x00000000000003a0 0x0 tmp/arm.v4a-linux.elf-help_umf.o
.text 0x0000000000000398 0x0 tmp/arm.v4a-expand.o .text 0x00000000000003a0 0x0 tmp/arm.v4a-expand.o
.text 0x0000000000000398 0x920 tmp/arm.v4a-linux.elf-main2.o .text 0x00000000000003a0 0x920 tmp/arm.v4a-linux.elf-main2.o
0x0000000000000c54 underlay 0x0000000000000c5c underlay
0x0000000000000b24 upx_main 0x0000000000000b2c upx_main
SYSCALLS 0x0000000000000000 0x214 SYSCALLS 0x0000000000000000 0x214
SYSCALLS 0x0000000000000000 0x214 tmp/arm.v4a-linux.elf-fold.o SYSCALLS 0x0000000000000000 0x214 tmp/arm.v4a-linux.elf-fold.o
+57 -35
View File
@@ -2,14 +2,18 @@ file format elf32-littlearm
Sections: Sections:
Idx Name Size VMA LMA File off Algn Flags Idx Name Size VMA LMA File off Algn Flags
0 ELFMAINY 0 0 0 034 2**0 CONTENTS 0 ELFSIGSEGV 05c 0 0 034 2**0 CONTENTS
1 ELFMAINZ 0218 0 0 034 2**0 CONTENTS 1 ELFMAINX2 0598 0 0 090 2**2 CONTENTS
2 HUMF_A 04 0 0 024c 2**0 CONTENTS 2 ELFMAINY 0 0 0 0628 2**0 CONTENTS
3 HUMF_L 04 0 0 0250 2**0 CONTENTS 3 ELFMAINZ 0218 0 0 0628 2**0 CONTENTS
4 UMF_ANDROID 054c 0 0 0254 2**2 CONTENTS 4 HUMF_A 04 0 0 0840 2**0 CONTENTS
5 UMF_LINUX 0140 0 0 07a0 2**2 CONTENTS 5 HUMF_L 04 0 0 0844 2**0 CONTENTS
6 ELFMAINX 0264 0 0 08e0 2**2 CONTENTS 6 UMF_ANDROID 054c 0 0 0848 2**2 CONTENTS
7 UMF_LINUX 0140 0 0 0d94 2**2 CONTENTS
8 ELFMAINX 028 0 0 0ed4 2**0 CONTENTS
SYMBOL TABLE: SYMBOL TABLE:
00000000 l d ELFSIGSEGV 0 ELFSIGSEGV
00000000 l d ELFMAINX2 0 ELFMAINX2
00000000 l d ELFMAINZ 0 ELFMAINZ 00000000 l d ELFMAINZ 0 ELFMAINZ
00000000 l d UMF_ANDROID 0 UMF_ANDROID 00000000 l d UMF_ANDROID 0 UMF_ANDROID
00000000 l d UMF_LINUX 0 UMF_LINUX 00000000 l d UMF_LINUX 0 UMF_LINUX
@@ -17,10 +21,10 @@ SYMBOL TABLE:
00000000 l d ELFMAINY 0 ELFMAINY 00000000 l d ELFMAINY 0 ELFMAINY
00000000 l d HUMF_A 0 HUMF_A 00000000 l d HUMF_A 0 HUMF_A
00000000 l d HUMF_L 0 HUMF_L 00000000 l d HUMF_L 0 HUMF_L
00000258 g ELFMAINX 0 get_page_mask 0000058c g ELFMAINX2 0 get_page_mask
00000000 *UND* 0 MFLG 00000000 *UND* 0 MFLG
000000ec g ELFMAINZ 0 getpid 000000ec g ELFMAINZ 0 getpid
00000264 g ELFMAINX 0 upx_mmap_and_fd 00000598 g ELFMAINX2 0 upx_mmap_and_fd
00000008 g ELFMAINZ 0 memcpy 00000008 g ELFMAINZ 0 memcpy
00000000 *UND* 0 O_BINFO 00000000 *UND* 0 O_BINFO
000001a0 g ELFMAINZ 0 Psync 000001a0 g ELFMAINZ 0 Psync
@@ -40,7 +44,7 @@ SYMBOL TABLE:
0000013c g ELFMAINZ 0 read 0000013c g ELFMAINZ 0 read
00000178 g ELFMAINZ 0 unlink 00000178 g ELFMAINZ 0 unlink
0000002c g ELFMAINZ 0 memset 0000002c g ELFMAINZ 0 memset
00000194 g F ELFMAINX 0c4 ucl_nrv2b_decompress_8 000004c8 g F ELFMAINX2 0c4 ucl_nrv2b_decompress_8
000001c8 g ELFMAINZ 0 my_bkpt 000001c8 g ELFMAINZ 0 my_bkpt
000000c4 g ELFMAINZ 0 fsync 000000c4 g ELFMAINZ 0 fsync
00000150 g ELFMAINZ 0 stat 00000150 g ELFMAINZ 0 stat
@@ -50,6 +54,49 @@ SYMBOL TABLE:
00000114 g ELFMAINZ 0 mkdir 00000114 g ELFMAINZ 0 mkdir
00000088 g ELFMAINZ 0 close 00000088 g ELFMAINZ 0 close
RELOCATION RECORDS FOR [ELFSIGSEGV]:
OFFSET TYPE VALUE
00000000 R_ARM_PC24 ELFMAINX2
00000038 R_ARM_PC24 ELFSIGSEGV
RELOCATION RECORDS FOR [ELFMAINX2]:
OFFSET TYPE VALUE
00000004 R_ARM_PC24 ELFMAINX2
00000008 R_ARM_PC24 ELFMAINX2
00000014 R_ARM_PC24 ELFMAINX2
0000001c R_ARM_PC24 ELFMAINX2
00000030 R_ARM_PC24 ELFMAINZ
00000068 R_ARM_PC24 ELFMAINX2
00000078 R_ARM_PC24 upx_mmap_and_fd
00000080 R_ARM_PC24 ELFMAINX2
000000b0 R_ARM_PC24 ELFMAINX2
000000f0 R_ARM_PC24 ELFMAINX2
0000020c R_ARM_PC24 ELFMAINX2
00000238 R_ARM_PC24 ELFMAINX2
000003dc R_ARM_PC24 ELFMAINX2
000003f4 R_ARM_PC24 ELFMAINX2
0000041c R_ARM_PC24 ELFMAINX2
00000420 R_ARM_PC24 ELFMAINX2
0000042c R_ARM_PC24 ELFMAINX2
000004a0 R_ARM_PC24 ELFMAINX2
000004a4 R_ARM_PC24 ELFMAINX2
000004c0 R_ARM_PC24 ELFMAINX2
000004d8 R_ARM_PC24 ELFMAINX2
00000510 R_ARM_PC24 ELFMAINX2
00000518 R_ARM_PC24 ELFMAINX2
0000051c R_ARM_PC24 ELFMAINX2
0000052c R_ARM_PC24 ELFMAINX2
00000530 R_ARM_PC24 ELFMAINX2
00000534 R_ARM_PC24 ELFMAINX2
00000540 R_ARM_PC24 ELFMAINX2
00000550 R_ARM_PC24 ELFMAINX2
00000554 R_ARM_PC24 ELFMAINX2
0000055c R_ARM_PC24 ELFMAINX2
00000564 R_ARM_PC24 ELFMAINX2
00000568 R_ARM_PC24 ELFMAINX2
00000584 R_ARM_PC24 ELFMAINX2
00000588 R_ARM_PC24 ELFMAINX2
RELOCATION RECORDS FOR [ELFMAINZ]: RELOCATION RECORDS FOR [ELFMAINZ]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
0000000c R_ARM_PC24 ELFMAINZ 0000000c R_ARM_PC24 ELFMAINZ
@@ -183,29 +230,4 @@ OFFSET TYPE VALUE
RELOCATION RECORDS FOR [ELFMAINX]: RELOCATION RECORDS FOR [ELFMAINX]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
00000000 R_ARM_ABS32 MFLG 00000000 R_ARM_ABS32 MFLG
00000010 R_ARM_PC24 ELFMAINX
00000014 R_ARM_PC24 ELFMAINX 00000014 R_ARM_PC24 ELFMAINX
00000020 R_ARM_PC24 ELFMAINX
00000028 R_ARM_PC24 ELFMAINX
00000058 R_ARM_PC24 ELFMAINZ
00000090 R_ARM_PC24 ELFMAINX
000000a0 R_ARM_PC24 upx_mmap_and_fd
000000a8 R_ARM_PC24 ELFMAINX
000000d8 R_ARM_PC24 ELFMAINX
00000114 R_ARM_PC24 ELFMAINX
0000018c R_ARM_PC24 ELFMAINX
000001a4 R_ARM_PC24 ELFMAINX
000001dc R_ARM_PC24 ELFMAINX
000001e4 R_ARM_PC24 ELFMAINX
000001e8 R_ARM_PC24 ELFMAINX
000001f8 R_ARM_PC24 ELFMAINX
000001fc R_ARM_PC24 ELFMAINX
00000200 R_ARM_PC24 ELFMAINX
0000020c R_ARM_PC24 ELFMAINX
0000021c R_ARM_PC24 ELFMAINX
00000220 R_ARM_PC24 ELFMAINX
00000228 R_ARM_PC24 ELFMAINX
00000230 R_ARM_PC24 ELFMAINX
00000234 R_ARM_PC24 ELFMAINX
00000250 R_ARM_PC24 ELFMAINX
00000254 R_ARM_PC24 ELFMAINX
+10 -11
View File
@@ -7,24 +7,23 @@ Name Origin Length Attributes
Linker script and memory map Linker script and memory map
.text 0x0000000000000000 0xcb8 .text 0x0000000000000000 0xcc0
.text 0x0000000000000000 0x398 tmp/arm.v5a-linux.elf-fold.o .text 0x0000000000000000 0x3a0 tmp/arm.v5a-linux.elf-fold.o
0x0000000000000004 get_page_mask 0x0000000000000004 get_page_mask
0x0000000000000338 memcpy 0x0000000000000340 memcpy
0x0000000000000048 Psync 0x0000000000000048 Psync
0x000000000000037c mempcpy 0x0000000000000384 mempcpy
0x00000000000000b0 mmap 0x00000000000000b0 mmap
0x0000000000000098 mmap_privanon 0x0000000000000098 mmap_privanon
0x000000000000000c get_upxfn_path 0x000000000000000c get_upxfn_path
0x000000000000035c memset 0x0000000000000364 memset
0x00000000fffffff4 page_mask
0x0000000000000024 Pprotect 0x0000000000000024 Pprotect
0x0000000000000024 mprotect 0x0000000000000024 mprotect
.text 0x0000000000000398 0x0 tmp/arm.v5a-linux.elf-help_umf.o .text 0x00000000000003a0 0x0 tmp/arm.v5a-linux.elf-help_umf.o
.text 0x0000000000000398 0x0 tmp/arm.v5a-expand.o .text 0x00000000000003a0 0x0 tmp/arm.v5a-expand.o
.text 0x0000000000000398 0x920 tmp/arm.v5a-linux.elf-main2.o .text 0x00000000000003a0 0x920 tmp/arm.v5a-linux.elf-main2.o
0x0000000000000c54 underlay 0x0000000000000c5c underlay
0x0000000000000b24 upx_main 0x0000000000000b2c upx_main
SYSCALLS 0x0000000000000000 0x214 SYSCALLS 0x0000000000000000 0x214
SYSCALLS 0x0000000000000000 0x214 tmp/arm.v5a-linux.elf-fold.o SYSCALLS 0x0000000000000000 0x214 tmp/arm.v5a-linux.elf-fold.o
+17 -8
View File
@@ -2,25 +2,34 @@ file format elf64-littleaarch64
Sections: Sections:
Idx Name Size VMA LMA File off Algn Flags Idx Name Size VMA LMA File off Algn Flags
0 ELFMAINX 0228 0 0 040 2**2 CONTENTS 0 ELFMAINX 010 0 0 040 2**0 CONTENTS
1 ELFMAINY 0 0 0 0268 2**0 CONTENTS 1 ELFSIGSEGV 0378 0 0 050 2**2 CONTENTS
2 ELFMAINZ 01c 0 0 0268 2**2 CONTENTS 2 ELFMAINX2 0234 0 0 03c8 2**2 CONTENTS
3 ELFMAINY 0 0 0 05fc 2**0 CONTENTS
4 ELFMAINZ 0c 0 0 05fc 2**2 CONTENTS
SYMBOL TABLE: SYMBOL TABLE:
0000000000000000 l d ELFMAINZ 0 ELFMAINZ
0000000000000000 l d ELFMAINX 0 ELFMAINX 0000000000000000 l d ELFMAINX 0 ELFMAINX
0000000000000000 l d ELFMAINX2 0 ELFMAINX2
0000000000000000 l d ELFMAINZ 0 ELFMAINZ
0000000000000000 l d ELFSIGSEGV 0 ELFSIGSEGV
0000000000000000 l d ELFMAINY 0 ELFMAINY 0000000000000000 l d ELFMAINY 0 ELFMAINY
0000000000000000 *UND* 0 MFLG 0000000000000000 *UND* 0 MFLG
0000000000000004 g ELFMAINX 0 _start 0000000000000004 g ELFMAINX 0 _start
000000000000014c g F ELFMAINX 0dc ucl_nrv2b_decompress_32 0000000000000158 g F ELFMAINX2 0dc ucl_nrv2b_decompress_32
0000000000000000 g ELFMAINY 0 end_decompress 0000000000000000 g ELFMAINY 0 end_decompress
0000000000000000 *UND* 0 O_BINFO 0000000000000000 *UND* 0 O_BINFO
RELOCATION RECORDS FOR [ELFMAINX]: RELOCATION RECORDS FOR [ELFMAINX]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
0000000000000000 R_AARCH64_ABS32 MFLG 0000000000000000 R_AARCH64_ABS32 MFLG
000000000000003c R_AARCH64_CALL26 ELFMAINZ+0x0000000000000004 000000000000000c R_AARCH64_ADR_PREL_LO21 ELFMAINX2+0x0000000000000148
0000000000000048 R_AARCH64_ADR_PREL_LO21 ELFMAINZ
RELOCATION RECORDS FOR [ELFMAINX2]:
OFFSET TYPE VALUE
0000000000000030 R_AARCH64_ADR_PREL_LO21 ELFMAINX-0x0000000000000004
0000000000000040 R_AARCH64_CALL26 ELFMAINZ+0x0000000000000004
000000000000004c R_AARCH64_ADR_PREL_LO21 ELFMAINZ
RELOCATION RECORDS FOR [ELFMAINZ]: RELOCATION RECORDS FOR [ELFMAINZ]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
0000000000000018 R_AARCH64_ABS32 O_BINFO 0000000000000008 R_AARCH64_ABS32 O_BINFO
+13 -13
View File
@@ -12,19 +12,19 @@ LOAD tmp/arm64-expand.o
LOAD tmp/arm64-linux.elf-main2.o LOAD tmp/arm64-linux.elf-main2.o
OUTPUT(tmp/arm64-linux.elf-fold.bin elf64-littleaarch64) OUTPUT(tmp/arm64-linux.elf-fold.bin elf64-littleaarch64)
.text 0x0000000000000000 0xb84 .text 0x0000000000000000 0xb94
.text 0x0000000000000000 0x2c4 tmp/arm64-linux.elf-fold.o .text 0x0000000000000000 0x2d4 tmp/arm64-linux.elf-fold.o
0x0000000000000008 get_page_mask 0x0000000000000010 get_page_mask
0x0000000000000018 mmap_privanon 0x0000000000000020 mmap_privanon
0x0000000000000028 Psync 0x0000000000000030 Psync
0x0000000000000098 msync 0x00000000000000a0 msync
0x00000000000000a4 mmap 0x00000000000000ac mmap
0x00000000000000c0 Pprotect 0x00000000000000c8 Pprotect
0x00000000000000c0 mprotect 0x00000000000000c8 mprotect
.text 0x00000000000002c4 0x0 tmp/arm64-expand.o .text 0x00000000000002d4 0x0 tmp/arm64-expand.o
.text 0x00000000000002c4 0x8c0 tmp/arm64-linux.elf-main2.o .text 0x00000000000002d4 0x8c0 tmp/arm64-linux.elf-main2.o
0x00000000000009e0 underlay 0x00000000000009f0 underlay
0x0000000000000a4c upx_main2 0x0000000000000a5c upx_main2
.data 0x0000000000000000 0x0 .data 0x0000000000000000 0x0
.data 0x0000000000000000 0x0 tmp/arm64-linux.elf-fold.o .data 0x0000000000000000 0x0 tmp/arm64-linux.elf-fold.o
+57 -35
View File
@@ -2,14 +2,18 @@ file format elf32-bigarm
Sections: Sections:
Idx Name Size VMA LMA File off Algn Flags Idx Name Size VMA LMA File off Algn Flags
0 ELFMAINY 0 0 0 034 2**0 CONTENTS 0 ELFSIGSEGV 05c 0 0 034 2**0 CONTENTS
1 ELFMAINZ 0218 0 0 034 2**0 CONTENTS 1 ELFMAINX2 0598 0 0 090 2**2 CONTENTS
2 HUMF_A 04 0 0 024c 2**0 CONTENTS 2 ELFMAINY 0 0 0 0628 2**0 CONTENTS
3 HUMF_L 04 0 0 0250 2**0 CONTENTS 3 ELFMAINZ 0218 0 0 0628 2**0 CONTENTS
4 UMF_ANDROID 0544 0 0 0254 2**2 CONTENTS 4 HUMF_A 04 0 0 0840 2**0 CONTENTS
5 UMF_LINUX 0144 0 0 0798 2**2 CONTENTS 5 HUMF_L 04 0 0 0844 2**0 CONTENTS
6 ELFMAINX 0264 0 0 08dc 2**2 CONTENTS 6 UMF_ANDROID 0544 0 0 0848 2**2 CONTENTS
7 UMF_LINUX 0144 0 0 0d8c 2**2 CONTENTS
8 ELFMAINX 028 0 0 0ed0 2**0 CONTENTS
SYMBOL TABLE: SYMBOL TABLE:
00000000 l d ELFSIGSEGV 0 ELFSIGSEGV
00000000 l d ELFMAINX2 0 ELFMAINX2
00000000 l d ELFMAINZ 0 ELFMAINZ 00000000 l d ELFMAINZ 0 ELFMAINZ
00000000 l d UMF_ANDROID 0 UMF_ANDROID 00000000 l d UMF_ANDROID 0 UMF_ANDROID
00000000 l d UMF_LINUX 0 UMF_LINUX 00000000 l d UMF_LINUX 0 UMF_LINUX
@@ -17,10 +21,10 @@ SYMBOL TABLE:
00000000 l d ELFMAINY 0 ELFMAINY 00000000 l d ELFMAINY 0 ELFMAINY
00000000 l d HUMF_A 0 HUMF_A 00000000 l d HUMF_A 0 HUMF_A
00000000 l d HUMF_L 0 HUMF_L 00000000 l d HUMF_L 0 HUMF_L
00000258 g ELFMAINX 0 get_page_mask 0000058c g ELFMAINX2 0 get_page_mask
00000000 *UND* 0 MFLG 00000000 *UND* 0 MFLG
000000ec g ELFMAINZ 0 getpid 000000ec g ELFMAINZ 0 getpid
00000264 g ELFMAINX 0 upx_mmap_and_fd 00000598 g ELFMAINX2 0 upx_mmap_and_fd
00000008 g ELFMAINZ 0 memcpy 00000008 g ELFMAINZ 0 memcpy
00000000 *UND* 0 O_BINFO 00000000 *UND* 0 O_BINFO
000001a0 g ELFMAINZ 0 Psync 000001a0 g ELFMAINZ 0 Psync
@@ -40,7 +44,7 @@ SYMBOL TABLE:
0000013c g ELFMAINZ 0 read 0000013c g ELFMAINZ 0 read
00000178 g ELFMAINZ 0 unlink 00000178 g ELFMAINZ 0 unlink
0000002c g ELFMAINZ 0 memset 0000002c g ELFMAINZ 0 memset
00000194 g F ELFMAINX 0c4 ucl_nrv2b_decompress_8 000004c8 g F ELFMAINX2 0c4 ucl_nrv2b_decompress_8
000001c8 g ELFMAINZ 0 my_bkpt 000001c8 g ELFMAINZ 0 my_bkpt
000000c4 g ELFMAINZ 0 fsync 000000c4 g ELFMAINZ 0 fsync
00000150 g ELFMAINZ 0 stat 00000150 g ELFMAINZ 0 stat
@@ -50,6 +54,49 @@ SYMBOL TABLE:
00000114 g ELFMAINZ 0 mkdir 00000114 g ELFMAINZ 0 mkdir
00000088 g ELFMAINZ 0 close 00000088 g ELFMAINZ 0 close
RELOCATION RECORDS FOR [ELFSIGSEGV]:
OFFSET TYPE VALUE
00000000 R_ARM_PC24 ELFMAINX2
00000038 R_ARM_PC24 ELFSIGSEGV
RELOCATION RECORDS FOR [ELFMAINX2]:
OFFSET TYPE VALUE
00000004 R_ARM_PC24 ELFMAINX2
00000008 R_ARM_PC24 ELFMAINX2
00000014 R_ARM_PC24 ELFMAINX2
0000001c R_ARM_PC24 ELFMAINX2
00000030 R_ARM_PC24 ELFMAINZ
00000068 R_ARM_PC24 ELFMAINX2
00000078 R_ARM_PC24 upx_mmap_and_fd
00000080 R_ARM_PC24 ELFMAINX2
000000b0 R_ARM_PC24 ELFMAINX2
000000f0 R_ARM_PC24 ELFMAINX2
0000020c R_ARM_PC24 ELFMAINX2
00000238 R_ARM_PC24 ELFMAINX2
000003dc R_ARM_PC24 ELFMAINX2
000003f4 R_ARM_PC24 ELFMAINX2
0000041c R_ARM_PC24 ELFMAINX2
00000420 R_ARM_PC24 ELFMAINX2
0000042c R_ARM_PC24 ELFMAINX2
000004a0 R_ARM_PC24 ELFMAINX2
000004a4 R_ARM_PC24 ELFMAINX2
000004c0 R_ARM_PC24 ELFMAINX2
000004d8 R_ARM_PC24 ELFMAINX2
00000510 R_ARM_PC24 ELFMAINX2
00000518 R_ARM_PC24 ELFMAINX2
0000051c R_ARM_PC24 ELFMAINX2
0000052c R_ARM_PC24 ELFMAINX2
00000530 R_ARM_PC24 ELFMAINX2
00000534 R_ARM_PC24 ELFMAINX2
00000540 R_ARM_PC24 ELFMAINX2
00000550 R_ARM_PC24 ELFMAINX2
00000554 R_ARM_PC24 ELFMAINX2
0000055c R_ARM_PC24 ELFMAINX2
00000564 R_ARM_PC24 ELFMAINX2
00000568 R_ARM_PC24 ELFMAINX2
00000584 R_ARM_PC24 ELFMAINX2
00000588 R_ARM_PC24 ELFMAINX2
RELOCATION RECORDS FOR [ELFMAINZ]: RELOCATION RECORDS FOR [ELFMAINZ]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
0000000c R_ARM_PC24 ELFMAINZ 0000000c R_ARM_PC24 ELFMAINZ
@@ -181,29 +228,4 @@ OFFSET TYPE VALUE
RELOCATION RECORDS FOR [ELFMAINX]: RELOCATION RECORDS FOR [ELFMAINX]:
OFFSET TYPE VALUE OFFSET TYPE VALUE
00000000 R_ARM_ABS32 MFLG 00000000 R_ARM_ABS32 MFLG
00000010 R_ARM_PC24 ELFMAINX
00000014 R_ARM_PC24 ELFMAINX 00000014 R_ARM_PC24 ELFMAINX
00000020 R_ARM_PC24 ELFMAINX
00000028 R_ARM_PC24 ELFMAINX
00000058 R_ARM_PC24 ELFMAINZ
00000090 R_ARM_PC24 ELFMAINX
000000a0 R_ARM_PC24 upx_mmap_and_fd
000000a8 R_ARM_PC24 ELFMAINX
000000d8 R_ARM_PC24 ELFMAINX
00000114 R_ARM_PC24 ELFMAINX
0000018c R_ARM_PC24 ELFMAINX
000001a4 R_ARM_PC24 ELFMAINX
000001dc R_ARM_PC24 ELFMAINX
000001e4 R_ARM_PC24 ELFMAINX
000001e8 R_ARM_PC24 ELFMAINX
000001f8 R_ARM_PC24 ELFMAINX
000001fc R_ARM_PC24 ELFMAINX
00000200 R_ARM_PC24 ELFMAINX
0000020c R_ARM_PC24 ELFMAINX
0000021c R_ARM_PC24 ELFMAINX
00000220 R_ARM_PC24 ELFMAINX
00000228 R_ARM_PC24 ELFMAINX
00000230 R_ARM_PC24 ELFMAINX
00000234 R_ARM_PC24 ELFMAINX
00000250 R_ARM_PC24 ELFMAINX
00000254 R_ARM_PC24 ELFMAINX
+10 -11
View File
@@ -7,24 +7,23 @@ Name Origin Length Attributes
Linker script and memory map Linker script and memory map
.text 0x0000000000000000 0xccc .text 0x0000000000000000 0xcd4
.text 0x0000000000000000 0x398 tmp/armeb.v4a-linux.elf-fold.o .text 0x0000000000000000 0x3a0 tmp/armeb.v4a-linux.elf-fold.o
0x0000000000000004 get_page_mask 0x0000000000000004 get_page_mask
0x0000000000000338 memcpy 0x0000000000000340 memcpy
0x0000000000000048 Psync 0x0000000000000048 Psync
0x000000000000037c mempcpy 0x0000000000000384 mempcpy
0x00000000000000b0 mmap 0x00000000000000b0 mmap
0x0000000000000098 mmap_privanon 0x0000000000000098 mmap_privanon
0x000000000000000c get_upxfn_path 0x000000000000000c get_upxfn_path
0x000000000000035c memset 0x0000000000000364 memset
0x00000000fffffff4 page_mask
0x0000000000000024 Pprotect 0x0000000000000024 Pprotect
0x0000000000000024 mprotect 0x0000000000000024 mprotect
.text 0x0000000000000398 0x0 tmp/armeb.v4a-linux.elf-help_umf.o .text 0x00000000000003a0 0x0 tmp/armeb.v4a-linux.elf-help_umf.o
.text 0x0000000000000398 0x0 tmp/armeb.v4a-expand.o .text 0x00000000000003a0 0x0 tmp/armeb.v4a-expand.o
.text 0x0000000000000398 0x934 tmp/armeb.v4a-linux.elf-main2.o .text 0x00000000000003a0 0x934 tmp/armeb.v4a-linux.elf-main2.o
0x0000000000000c68 underlay 0x0000000000000c70 underlay
0x0000000000000b34 upx_main 0x0000000000000b3c upx_main
SYSCALLS 0x0000000000000000 0x214 SYSCALLS 0x0000000000000000 0x214
SYSCALLS 0x0000000000000000 0x214 tmp/armeb.v4a-linux.elf-fold.o SYSCALLS 0x0000000000000000 0x214 tmp/armeb.v4a-linux.elf-fold.o
+5 -5
View File
@@ -27,8 +27,8 @@ OUTPUT(tmp/powerpc64-linux.elf-fold.bin elf64-powerpc)
.bss 0x0000000000000000 0x0 .bss 0x0000000000000000 0x0
.bss 0x0000000000000000 0x0 tmp/powerpc64-linux.elf-fold.o .bss 0x0000000000000000 0x0 tmp/powerpc64-linux.elf-fold.o
SYSCALLS 0x0000000000000000 0x148 SYSCALLS 0x0000000000000000 0x15c
SYSCALLS 0x0000000000000000 0x148 tmp/powerpc64-linux.elf-fold.o SYSCALLS 0x0000000000000000 0x15c tmp/powerpc64-linux.elf-fold.o
0x0000000000000008 mmap 0x0000000000000008 mmap
0x0000000000000020 munmap 0x0000000000000020 munmap
0x0000000000000028 mprotect 0x0000000000000028 mprotect
@@ -44,9 +44,9 @@ SYSCALLS 0x0000000000000000 0x148
0x0000000000000070 openat 0x0000000000000070 openat
0x0000000000000078 close 0x0000000000000078 close
0x0000000000000080 upxfd_create 0x0000000000000080 upxfd_create
0x00000000000000d8 memfd_create 0x00000000000000ec memfd_create
0x000000000000011c memcpy 0x0000000000000130 memcpy
0x0000000000000140 my_bkpt 0x0000000000000154 my_bkpt
.comment 0x0000000000000000 0x33 .comment 0x0000000000000000 0x33
.comment 0x0000000000000000 0x33 tmp/powerpc64-linux.elf-fold.o .comment 0x0000000000000000 0x33 tmp/powerpc64-linux.elf-fold.o
+5 -5
View File
@@ -27,8 +27,8 @@ OUTPUT(tmp/powerpc64le-linux.elf-fold.bin elf64-powerpcle)
.bss 0x0000000000000000 0x0 .bss 0x0000000000000000 0x0
.bss 0x0000000000000000 0x0 tmp/powerpc64le-linux.elf-fold.o .bss 0x0000000000000000 0x0 tmp/powerpc64le-linux.elf-fold.o
SYSCALLS 0x0000000000000000 0x148 SYSCALLS 0x0000000000000000 0x15c
SYSCALLS 0x0000000000000000 0x148 tmp/powerpc64le-linux.elf-fold.o SYSCALLS 0x0000000000000000 0x15c tmp/powerpc64le-linux.elf-fold.o
0x0000000000000008 mmap 0x0000000000000008 mmap
0x0000000000000020 munmap 0x0000000000000020 munmap
0x0000000000000028 mprotect 0x0000000000000028 mprotect
@@ -44,9 +44,9 @@ SYSCALLS 0x0000000000000000 0x148
0x0000000000000070 openat 0x0000000000000070 openat
0x0000000000000078 close 0x0000000000000078 close
0x0000000000000080 upxfd_create 0x0000000000000080 upxfd_create
0x00000000000000d8 memfd_create 0x00000000000000ec memfd_create
0x000000000000011c memcpy 0x0000000000000130 memcpy
0x0000000000000140 my_bkpt 0x0000000000000154 my_bkpt
.comment 0x0000000000000000 0x33 .comment 0x0000000000000000 0x33
.comment 0x0000000000000000 0x33 tmp/powerpc64le-linux.elf-fold.o .comment 0x0000000000000000 0x33 tmp/powerpc64le-linux.elf-fold.o
+373 -355
View File
@@ -33,351 +33,6 @@
namespace upx { namespace upx {
/*************************************************************************
// core util
**************************************************************************/
// disable taking the address => force passing by reference (instead of pointer)
#define UPX_CXX_DISABLE_ADDRESS(Klass) \
private: \
Klass *operator&() const noexcept DELETED_FUNCTION;
// disable copy and move
#define UPX_CXX_DISABLE_COPY(KlassName) \
private: \
KlassName(const KlassName &) noexcept DELETED_FUNCTION; /* copy constructor */ \
KlassName &operator=(const KlassName &) noexcept DELETED_FUNCTION; /* copy assignment */
#define UPX_CXX_DISABLE_MOVE(KlassName) \
private: \
KlassName(KlassName &&) noexcept DELETED_FUNCTION; /* move constructor */ \
KlassName &operator=(KlassName &&) noexcept DELETED_FUNCTION; /* move assignment */
#define UPX_CXX_DISABLE_COPY_MOVE(KlassName) \
UPX_CXX_DISABLE_COPY(KlassName) \
UPX_CXX_DISABLE_MOVE(KlassName)
// fun with C++: disable common "new" and ALL "delete" operators
// https://en.cppreference.com/w/cpp/memory/new/operator_delete
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \
private: \
/* common allocation functions (4) */ \
static void *operator new(std::size_t) DELETED_FUNCTION; \
static void *operator new[](std::size_t) DELETED_FUNCTION; \
static void *operator new(std::size_t, void *) DELETED_FUNCTION; \
static void *operator new[](std::size_t, void *) DELETED_FUNCTION; \
/* replaceable placement deallocation functions (4) */ \
static void operator delete(void *, const std::nothrow_t &) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, const std::nothrow_t &) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::align_val_t, const std::nothrow_t &) \
noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::align_val_t, const std::nothrow_t &) \
noexcept DELETED_FUNCTION; \
/* non-allocating placement deallocation functions (2) */ \
static void operator delete(void *, void *) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, void *) noexcept DELETED_FUNCTION;
/* class-specific usual deallocation functions (8) */
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_A__(Klass) \
protected: \
static void operator delete(void *) noexcept {} \
static void operator delete(void *, std::align_val_t) noexcept {} \
static void operator delete(void *, std::size_t) noexcept {} \
static void operator delete(void *, std::size_t, std::align_val_t) noexcept {} \
private: \
static void operator delete[](void *) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION;
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_B__(Klass) \
private: \
static void operator delete(void *) noexcept DELETED_FUNCTION; \
static void operator delete[](void *) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::size_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION;
/* class-specific usual destroying deallocation functions (4) */
#if __cplusplus >= 202002L
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass) \
protected: \
static void operator delete(Klass *, std::destroying_delete_t) noexcept {} \
static void operator delete(Klass *, std::destroying_delete_t, std::align_val_t) noexcept {} \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t) noexcept {} \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t, std::align_val_t) \
noexcept {} \
private:
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass) \
private: \
static void operator delete(Klass *, std::destroying_delete_t) noexcept DELETED_FUNCTION; \
static void operator delete(Klass *, std::destroying_delete_t, std::align_val_t) \
noexcept DELETED_FUNCTION; \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t) \
noexcept DELETED_FUNCTION; \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t, std::align_val_t) \
noexcept DELETED_FUNCTION;
#else
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass) private:
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass) private:
#endif
// for classes which may have virtual methods
#define UPX_CXX_DISABLE_NEW_DELETE(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_A__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass)
// this only works for classes WITHOUT any virtual methods
#define UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_B__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass)
#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) // do not use std::align_val_t
#undef UPX_CXX_DISABLE_NEW_DELETE
#undef UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL
#define UPX_CXX_DISABLE_NEW_DELETE(Klass) private:
#define UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(Klass) private:
#endif
class noncopyable {
protected:
forceinline constexpr noncopyable() noexcept {}
#if __cplusplus >= 202002L
forceinline constexpr ~noncopyable() noexcept = default;
#else
forceinline ~noncopyable() noexcept = default;
#endif
UPX_CXX_DISABLE_COPY_MOVE(noncopyable)
};
/*************************************************************************
// <type_traits>
**************************************************************************/
// is_bounded_array from C++20
template <class T>
struct is_bounded_array : public std::false_type {};
template <class T, std::size_t N>
struct is_bounded_array<T[N]> : public std::true_type {};
template <class T>
inline constexpr bool is_bounded_array_v = is_bounded_array<T>::value;
// is_same_all and is_same_any: std::is_same for multiple types
template <class T, class... Ts>
struct is_same_all : public std::conjunction<std::is_same<T, Ts>...> {};
template <class T, class... Ts>
inline constexpr bool is_same_all_v = is_same_all<T, Ts...>::value;
template <class T, class... Ts>
struct is_same_any : public std::disjunction<std::is_same<T, Ts>...> {};
template <class T, class... Ts>
inline constexpr bool is_same_any_v = is_same_any<T, Ts...>::value;
// remove_cvref from C++20
template <class T>
struct remove_cvref {
typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
};
template <class T>
using remove_cvref_t = typename remove_cvref<T>::type;
// type_identity from C++20
template <class T>
struct type_identity {
typedef T type;
};
template <class T>
using type_identity_t = typename type_identity<T>::type;
/*************************************************************************
// <bit> C++20
**************************************************************************/
template <class T>
forceinline constexpr bool has_single_bit(T x) noexcept {
return !(x == 0) && (x & (x - 1)) == 0;
}
/*************************************************************************
// <algorithm>
**************************************************************************/
template <class T>
inline constexpr T align_down(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
r = x - (x & (alignment - 1));
return r;
}
template <class T>
inline constexpr T align_down_gap(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
r = x & (alignment - 1);
return r;
}
template <class T>
inline constexpr T align_up(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
constexpr T zero = {};
r = x + ((zero - x) & (alignment - 1));
return r;
}
template <class T>
inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
constexpr T zero = {};
r = (zero - x) & (alignment - 1);
return r;
}
template <class T>
forceinline constexpr T min(const T &a, const T &b) noexcept {
return b < a ? b : a;
}
template <class T>
forceinline constexpr T max(const T &a, const T &b) noexcept {
return a < b ? b : a;
}
template <class T>
inline constexpr bool is_uminmax_type = std::is_integral_v<T> && std::is_unsigned_v<T>;
template <class T, class = std::enable_if_t<is_uminmax_type<T>, T> >
forceinline constexpr T umin(const T &a, const T &b) noexcept {
return b < a ? b : a;
}
template <class T, class = std::enable_if_t<is_uminmax_type<T>, T> >
forceinline constexpr T umax(const T &a, const T &b) noexcept {
return a < b ? b : a;
}
template <class T>
forceinline constexpr T wrapping_add(const T &a, const T &b) noexcept {
static_assert(std::is_integral_v<T>);
typedef std::make_unsigned_t<T> U;
return T(U(a) + U(b));
}
template <class T>
forceinline constexpr T wrapping_sub(const T &a, const T &b) noexcept {
static_assert(std::is_integral_v<T>);
typedef std::make_unsigned_t<T> U;
return T(U(a) - U(b));
}
/*************************************************************************
// util
**************************************************************************/
template <std::size_t Size>
struct UnsignedSizeOf final {
static_assert(Size >= 1 && Size <= UPX_RSIZE_MAX_MEM);
static constexpr unsigned value = unsigned(Size);
};
// a static_cast that does not trigger -Wcast-align warnings
template <class Result, class From>
forceinline constexpr Result ptr_static_cast(From *ptr) noexcept {
static_assert(std::is_pointer_v<Result>);
// don't cast through "void *" if type is convertible
typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *>
VoidPtr;
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
return static_cast<Result>(static_cast<VoidPtr>(ptr));
}
template <class Result, class From>
forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept {
static_assert(std::is_pointer_v<Result>);
static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required
// don't cast through "const void *" if type is convertible
typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *>
VoidPtr;
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
return static_cast<Result>(static_cast<VoidPtr>(ptr));
}
#if WITH_THREADS
// cast "T *" to "std::atomic<T> *"
template <class T>
forceinline std::atomic<T> *ptr_std_atomic_cast(T *ptr) noexcept {
// TODO later: make sure that this cast is indeed legal
std::atomic<T> *result = ptr_static_cast<std::atomic<T> *>(ptr);
static_assert(sizeof(*result) == sizeof(*ptr));
static_assert(alignof(decltype(*result)) == alignof(decltype(*ptr)));
return result;
}
#endif // WITH_THREADS
// atomic_exchange
template <class T>
forceinline T atomic_exchange(T *ptr, T new_value) noexcept {
#if 1
static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now
#endif
static_assert(std::is_standard_layout_v<T>);
static_assert(std::is_trivially_copyable_v<T>);
#if !(WITH_THREADS)
T old_value = *ptr;
*ptr = new_value;
return old_value;
#else
static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types
static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment
#if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST)
return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST);
#elif __has_builtin(__sync_swap)
return __sync_swap(ptr, new_value);
#else
return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value);
#endif
#endif
}
// helper classes so we don't leak memory on exceptions
template <class T>
struct ObjectDeleter final {
T **items; // public
std::size_t count; // public
explicit ObjectDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}
~ObjectDeleter() noexcept { delete_items(); }
void delete_items() noexcept {
for (std::size_t i = 0; i < count; i++) {
T *item = atomic_exchange(&items[i], (T *) nullptr);
delete item; // single object delete
}
}
};
template <class T>
struct ArrayDeleter final {
T **items; // public
std::size_t count; // public
explicit ArrayDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}
~ArrayDeleter() noexcept { delete_items(); }
void delete_items() noexcept {
for (std::size_t i = 0; i < count; i++) {
T *item = atomic_exchange(&items[i], (T *) nullptr);
delete[] item; // array delete
}
}
};
template <class T>
struct MallocDeleter final {
T **items; // public
std::size_t count; // public
explicit MallocDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}
~MallocDeleter() noexcept { delete_items(); }
void delete_items() noexcept {
for (std::size_t i = 0; i < count; i++) {
T *item = atomic_exchange(&items[i], (T *) nullptr);
::free(item); // free memory from malloc()
}
}
};
/************************************************************************* /*************************************************************************
// compile_time // compile_time
**************************************************************************/ **************************************************************************/
@@ -537,63 +192,426 @@ forceinline constexpr void set_le64(byte *p, upx_uint64_t v) noexcept {
forceinline constexpr upx_uint16_t get_ne16(const byte *p) noexcept { forceinline constexpr upx_uint16_t get_ne16(const byte *p) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
return get_be16(p); return get_be16(p);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
return get_le16(p); return get_le16(p);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
forceinline constexpr upx_uint32_t get_ne24(const byte *p) noexcept { forceinline constexpr upx_uint32_t get_ne24(const byte *p) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
return get_be24(p); return get_be24(p);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
return get_le24(p); return get_le24(p);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
forceinline constexpr upx_uint32_t get_ne32(const byte *p) noexcept { forceinline constexpr upx_uint32_t get_ne32(const byte *p) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
return get_be32(p); return get_be32(p);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
return get_le32(p); return get_le32(p);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
forceinline constexpr upx_uint64_t get_ne64(const byte *p) noexcept { forceinline constexpr upx_uint64_t get_ne64(const byte *p) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
return get_be64(p); return get_be64(p);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
return get_le64(p); return get_le64(p);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
forceinline constexpr void set_ne16(byte *p, upx_uint16_t v) noexcept { forceinline constexpr void set_ne16(byte *p, upx_uint16_t v) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
set_be16(p, v); set_be16(p, v);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
set_le16(p, v); set_le16(p, v);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
forceinline constexpr void set_ne24(byte *p, upx_uint32_t v) noexcept { forceinline constexpr void set_ne24(byte *p, upx_uint32_t v) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
set_be24(p, v); set_be24(p, v);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
set_le24(p, v); set_le24(p, v);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
forceinline constexpr void set_ne32(byte *p, upx_uint32_t v) noexcept { forceinline constexpr void set_ne32(byte *p, upx_uint32_t v) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
set_be32(p, v); set_be32(p, v);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
set_le32(p, v); set_le32(p, v);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
forceinline constexpr void set_ne64(byte *p, upx_uint64_t v) noexcept { forceinline constexpr void set_ne64(byte *p, upx_uint64_t v) noexcept {
#if (ACC_ABI_BIG_ENDIAN) #if (ACC_ABI_BIG_ENDIAN)
set_be64(p, v); set_be64(p, v);
#else #elif (ACC_ABI_LITTLE_ENDIAN)
set_le64(p, v); set_le64(p, v);
#else
#error "ACC_ABI_ENDIAN"
#endif #endif
} }
} // namespace compile_time } // namespace compile_time
/*************************************************************************
// core util
**************************************************************************/
// disable taking the address => force passing by reference (instead of pointer)
#define UPX_CXX_DISABLE_ADDRESS(Klass) \
private: \
Klass *operator&() const noexcept DELETED_FUNCTION;
// disable copy and move
#define UPX_CXX_DISABLE_COPY(KlassName) \
private: \
KlassName(const KlassName &) noexcept DELETED_FUNCTION; /* copy constructor */ \
KlassName &operator=(const KlassName &) noexcept DELETED_FUNCTION; /* copy assignment */
#define UPX_CXX_DISABLE_MOVE(KlassName) \
private: \
KlassName(KlassName &&) noexcept DELETED_FUNCTION; /* move constructor */ \
KlassName &operator=(KlassName &&) noexcept DELETED_FUNCTION; /* move assignment */
#define UPX_CXX_DISABLE_COPY_MOVE(KlassName) \
UPX_CXX_DISABLE_COPY(KlassName) \
UPX_CXX_DISABLE_MOVE(KlassName)
// fun with C++: disable common "new" and ALL "delete" operators
// https://en.cppreference.com/w/cpp/memory/new/operator_delete
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \
private: \
/* common allocation functions (4) */ \
static void *operator new(std::size_t) DELETED_FUNCTION; \
static void *operator new[](std::size_t) DELETED_FUNCTION; \
static void *operator new(std::size_t, void *) DELETED_FUNCTION; \
static void *operator new[](std::size_t, void *) DELETED_FUNCTION; \
/* replaceable placement deallocation functions (4) */ \
static void operator delete(void *, const std::nothrow_t &) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, const std::nothrow_t &) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::align_val_t, const std::nothrow_t &) \
noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::align_val_t, const std::nothrow_t &) \
noexcept DELETED_FUNCTION; \
/* non-allocating placement deallocation functions (2) */ \
static void operator delete(void *, void *) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, void *) noexcept DELETED_FUNCTION;
/* class-specific usual deallocation functions (8) */
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_A__(Klass) \
protected: \
static void operator delete(void *) noexcept {} \
static void operator delete(void *, std::align_val_t) noexcept {} \
static void operator delete(void *, std::size_t) noexcept {} \
static void operator delete(void *, std::size_t, std::align_val_t) noexcept {} \
private: \
static void operator delete[](void *) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION;
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_B__(Klass) \
private: \
static void operator delete(void *) noexcept DELETED_FUNCTION; \
static void operator delete[](void *) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::size_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t) noexcept DELETED_FUNCTION; \
static void operator delete(void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION; \
static void operator delete[](void *, std::size_t, std::align_val_t) noexcept DELETED_FUNCTION;
/* class-specific usual destroying deallocation functions (4) */
#if __cplusplus >= 202002L
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass) \
protected: \
static void operator delete(Klass *, std::destroying_delete_t) noexcept {} \
static void operator delete(Klass *, std::destroying_delete_t, std::align_val_t) noexcept {} \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t) noexcept {} \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t, std::align_val_t) \
noexcept {} \
private:
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass) \
private: \
static void operator delete(Klass *, std::destroying_delete_t) noexcept DELETED_FUNCTION; \
static void operator delete(Klass *, std::destroying_delete_t, std::align_val_t) \
noexcept DELETED_FUNCTION; \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t) \
noexcept DELETED_FUNCTION; \
static void operator delete(Klass *, std::destroying_delete_t, std::size_t, std::align_val_t) \
noexcept DELETED_FUNCTION;
#else
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass) private:
#define UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass) private:
#endif
// for classes which may have virtual methods
#define UPX_CXX_DISABLE_NEW_DELETE(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_A__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_A__(Klass)
// this only works for classes WITHOUT any virtual methods
#define UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDF_B__(Klass) \
UPX_CXX_DISABLE_NEW_DELETE_IMPL_CSUDDF_B__(Klass)
#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) // do not use std::align_val_t
#undef UPX_CXX_DISABLE_NEW_DELETE
#undef UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL
#define UPX_CXX_DISABLE_NEW_DELETE(Klass) private:
#define UPX_CXX_DISABLE_NEW_DELETE_NO_VIRTUAL(Klass) private:
#endif
class NonCopyAble {
protected:
forceinline constexpr NonCopyAble() noexcept {}
#if __cplusplus >= 202002L
forceinline constexpr ~NonCopyAble() noexcept = default;
#else
forceinline ~NonCopyAble() noexcept = default;
#endif
UPX_CXX_DISABLE_COPY_MOVE(NonCopyAble)
};
typedef NonCopyAble noncopyable;
/*************************************************************************
// <type_traits>
**************************************************************************/
// is_bounded_array from C++20
template <class T>
struct is_bounded_array : public std::false_type {};
template <class T, std::size_t N>
struct is_bounded_array<T[N]> : public std::true_type {};
template <class T>
inline constexpr bool is_bounded_array_v = is_bounded_array<T>::value;
// is_same_all and is_same_any: std::is_same for multiple types
template <class T, class... Ts>
struct is_same_all : public std::conjunction<std::is_same<T, Ts>...> {};
template <class T, class... Ts>
struct is_same_any : public std::disjunction<std::is_same<T, Ts>...> {};
template <class T, class... Ts>
inline constexpr bool is_same_all_v = is_same_all<T, Ts...>::value;
template <class T, class... Ts>
inline constexpr bool is_same_any_v = is_same_any<T, Ts...>::value;
// remove_cvref from C++20
template <class T>
struct remove_cvref {
typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
};
template <class T>
using remove_cvref_t = typename remove_cvref<T>::type;
// type_identity from C++20
template <class T>
struct type_identity {
typedef T type;
};
template <class T>
using type_identity_t = typename type_identity<T>::type;
/*************************************************************************
// <bit> C++20
**************************************************************************/
template <class T>
forceinline constexpr bool has_single_bit(T x) noexcept {
return !(x == 0) && (x & (x - 1)) == 0;
}
/*************************************************************************
// <algorithm>
**************************************************************************/
template <class T>
inline constexpr T align_down(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
r = x - (x & (alignment - 1));
return r;
}
template <class T>
inline constexpr T align_down_gap(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
r = x & (alignment - 1);
return r;
}
template <class T>
inline constexpr T align_up(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
constexpr T zero = {};
r = x + ((zero - x) & (alignment - 1));
return r;
}
template <class T>
inline constexpr T align_up_gap(const T &x, const T &alignment) noexcept {
// assert_noexcept(has_single_bit(alignment)); // (not constexpr)
T r = {};
constexpr T zero = {};
r = (zero - x) & (alignment - 1);
return r;
}
template <class T>
forceinline constexpr T min(const T &a, const T &b) noexcept {
return b < a ? b : a;
}
template <class T>
forceinline constexpr T max(const T &a, const T &b) noexcept {
return a < b ? b : a;
}
template <class T>
inline constexpr bool is_uminmax_type = std::is_integral_v<T> && std::is_unsigned_v<T>;
template <class T, class = std::enable_if_t<is_uminmax_type<T>, T> >
forceinline constexpr T umin(const T &a, const T &b) noexcept {
return b < a ? b : a;
}
template <class T, class = std::enable_if_t<is_uminmax_type<T>, T> >
forceinline constexpr T umax(const T &a, const T &b) noexcept {
return a < b ? b : a;
}
template <class T>
forceinline constexpr T wrapping_add(const T &a, const T &b) noexcept {
static_assert(std::is_integral_v<T>);
typedef std::make_unsigned_t<T> U;
return T(U(a) + U(b));
}
template <class T>
forceinline constexpr T wrapping_sub(const T &a, const T &b) noexcept {
static_assert(std::is_integral_v<T>);
typedef std::make_unsigned_t<T> U;
return T(U(a) - U(b));
}
/*************************************************************************
// util
**************************************************************************/
template <std::size_t Size>
struct UnsignedSizeOf final {
static_assert(Size >= 1 && Size <= UPX_RSIZE_MAX_MEM);
static constexpr unsigned value = unsigned(Size);
};
// a static_cast that does not trigger -Wcast-align warnings
template <class Result, class From>
forceinline constexpr Result ptr_static_cast(From *ptr) noexcept {
static_assert(std::is_pointer_v<Result>);
// don't cast through "void *" if type is convertible
typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, void *>
VoidPtr;
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
return static_cast<Result>(static_cast<VoidPtr>(ptr));
}
template <class Result, class From>
forceinline constexpr Result ptr_static_cast(const From *ptr) noexcept {
static_assert(std::is_pointer_v<Result>);
static_assert(std::is_const_v<std::remove_pointer_t<Result> >); // required
// don't cast through "const void *" if type is convertible
typedef std::conditional_t<std::is_convertible_v<decltype(ptr), Result>, Result, const void *>
VoidPtr;
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
return static_cast<Result>(static_cast<VoidPtr>(ptr));
}
#if WITH_THREADS
// cast "T *" to "std::atomic<T> *"
template <class T>
forceinline std::atomic<T> *ptr_std_atomic_cast(T *ptr) noexcept {
// TODO later: make sure that this cast is indeed legal
std::atomic<T> *result = ptr_static_cast<std::atomic<T> *>(ptr);
static_assert(sizeof(*result) == sizeof(*ptr));
static_assert(alignof(decltype(*result)) == alignof(decltype(*ptr)));
return result;
}
#endif // WITH_THREADS
// atomic_exchange
template <class T>
forceinline T atomic_exchange(T *ptr, T new_value) noexcept {
#if 1
static_assert(sizeof(T) == sizeof(void *)); // UPX convention: restrict to pointer-size for now
#endif
static_assert(std::is_standard_layout_v<T>);
static_assert(std::is_trivially_copyable_v<T>);
#if !(WITH_THREADS)
T old_value = *ptr;
*ptr = new_value;
return old_value;
#else
static_assert(sizeof(T) <= sizeof(void *)); // UPX convention: restrict to fundamental types
static_assert(alignof(T) == sizeof(T)); // UPX convention: require proper alignment
#if __has_builtin(__atomic_exchange_n) && defined(__ATOMIC_SEQ_CST)
return __atomic_exchange_n(ptr, new_value, __ATOMIC_SEQ_CST);
#elif __has_builtin(__sync_swap)
return __sync_swap(ptr, new_value);
#else
return std::atomic_exchange(ptr_std_atomic_cast(ptr), new_value);
#endif
#endif
}
// helper classes so we don't leak memory on exceptions
template <class T>
struct ObjectDeleter final {
static_assert(std::is_nothrow_destructible_v<T>);
T **items; // public
std::size_t count; // public
explicit ObjectDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}
~ObjectDeleter() noexcept { delete_items(); }
void delete_items() noexcept {
for (std::size_t i = 0; i < count; i++) {
T *item = atomic_exchange(&items[i], (T *) nullptr);
delete item; // single object delete
}
}
};
template <class T>
struct ArrayDeleter final {
static_assert(std::is_nothrow_destructible_v<T>);
T **items; // public
std::size_t count; // public
explicit ArrayDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}
~ArrayDeleter() noexcept { delete_items(); }
void delete_items() noexcept {
for (std::size_t i = 0; i < count; i++) {
T *item = atomic_exchange(&items[i], (T *) nullptr);
delete[] item; // array delete
}
}
};
template <class T>
struct MallocDeleter final {
T **items; // public
std::size_t count; // public
explicit MallocDeleter(T **p, std::size_t n) noexcept : items(p), count(n) {}
~MallocDeleter() noexcept { delete_items(); }
void delete_items() noexcept {
for (std::size_t i = 0; i < count; i++) {
T *item = atomic_exchange(&items[i], (T *) nullptr);
::free(item); // free memory from malloc()
}
}
};
/************************************************************************* /*************************************************************************
// TriBool - tri-state bool // TriBool - tri-state bool
// an enum with an underlying type and 3 values // an enum with an underlying type and 3 values
@@ -605,10 +623,10 @@ struct TriBool final {
static constexpr bool is_third_true = IsThirdTrue; static constexpr bool is_third_true = IsThirdTrue;
// types // types
typedef T underlying_type; typedef T underlying_type;
static_assert(std::is_integral_v<underlying_type>);
typedef decltype(T(0) + T(0)) promoted_type; typedef decltype(T(0) + T(0)) promoted_type;
static_assert(std::is_integral_v<promoted_type>);
enum value_type : underlying_type { False = 0, True = 1, Third = 2 }; enum value_type : underlying_type { False = 0, True = 1, Third = 2 };
static_assert(std::is_integral_v<underlying_type>);
static_assert(std::is_integral_v<promoted_type>);
static_assert(sizeof(value_type) == sizeof(underlying_type)); static_assert(sizeof(value_type) == sizeof(underlying_type));
static_assert(sizeof(underlying_type) <= sizeof(promoted_type)); static_assert(sizeof(underlying_type) <= sizeof(promoted_type));
// constructors // constructors
+229 -100
View File
@@ -33,7 +33,8 @@
// extra functions to reduce dependency on membuffer.h // extra functions to reduce dependency on membuffer.h
void *membuffer_get_void_ptr(MemBuffer &mb) noexcept { return mb.getVoidPtr(); } void *membuffer_get_void_ptr(MemBuffer &mb) noexcept { return mb.getVoidPtr(); }
unsigned membuffer_get_size(MemBuffer &mb) noexcept { return mb.getSize(); } const void *membuffer_get_void_ptr(const MemBuffer &mb) noexcept { return mb.getVoidPtr(); }
unsigned membuffer_get_size_in_bytes(const MemBuffer &mb) noexcept { return mb.getSizeInBytes(); }
/*static*/ MemBuffer::Stats MemBuffer::stats; /*static*/ MemBuffer::Stats MemBuffer::stats;
@@ -61,7 +62,7 @@ static noinline void init_use_simple_mcheck() noexcept {
} }
use_simple_mcheck_flag = r; use_simple_mcheck_flag = r;
} }
static bool use_simple_mcheck() noexcept { static noinline bool use_simple_mcheck() noexcept {
static upx_std_once_flag init_done; static upx_std_once_flag init_done;
upx_std_call_once(init_done, init_use_simple_mcheck); upx_std_call_once(init_done, init_use_simple_mcheck);
// NOTE: clang-analyzer-unix.Malloc does not know that this flag is "constant"; see below // NOTE: clang-analyzer-unix.Malloc does not know that this flag is "constant"; see below
@@ -83,22 +84,6 @@ MemBuffer::MemBuffer(upx_uint64_t bytes) may_throw : MemBufferBase<byte>() {
MemBuffer::~MemBuffer() noexcept { this->dealloc(); } MemBuffer::~MemBuffer() noexcept { this->dealloc(); }
// similar to BoundedPtr, except checks only at creation
// skip == offset, take == size_in_bytes
void *MemBuffer::subref_impl(const char *errfmt, size_t skip, size_t take) {
debug_set(debug.last_return_address_subref, upx_return_address());
// check overrun and wrap-around
if (skip + take > size_in_bytes || skip + take < skip) {
char buf[100];
// printf is using unsigned formatting
if (!errfmt || !errfmt[0])
errfmt = "bad subref %#x %#x";
upx_safe_snprintf(buf, sizeof(buf), errfmt, (unsigned) skip, (unsigned) take);
throwCantPack(buf);
}
return ptr + skip;
}
/*static*/ /*static*/
unsigned MemBuffer::getSizeForCompression(unsigned uncompressed_size, unsigned extra) { unsigned MemBuffer::getSizeForCompression(unsigned uncompressed_size, unsigned extra) {
if (uncompressed_size == 0) if (uncompressed_size == 0)
@@ -134,13 +119,31 @@ void MemBuffer::allocForDecompression(unsigned uncompressed_size, unsigned extra
debug_set(debug.last_return_address_alloc, upx_return_address()); debug_set(debug.last_return_address_alloc, upx_return_address());
} }
void MemBuffer::fill(unsigned off, unsigned len, int value) { void MemBuffer::fill(size_t off, size_t bytes, int value) {
debug_set(debug.last_return_address_fill, upx_return_address()); debug_set(debug.last_return_address_fill, upx_return_address());
checkState(); checkState();
if (off > size_in_bytes || len > size_in_bytes || off + len > size_in_bytes) // check overrun and wrap-around
if very_unlikely (off + bytes > size_in_bytes || off + bytes < off)
throwCantPack("MemBuffer::fill out of range; take care!"); throwCantPack("MemBuffer::fill out of range; take care!");
if (len > 0) if (bytes > 0)
memset(ptr + off, value, len); memset(ptr + off, value, bytes);
}
// similar to BoundedPtr, except checks only at creation
// skip == offset, take == size_in_bytes
void *MemBuffer::subref_impl(const char *errfmt, size_t skip, size_t take) {
debug_set(debug.last_return_address_subref, upx_return_address());
checkState();
// check overrun and wrap-around
if very_unlikely (skip + take > size_in_bytes || skip + take < skip) {
char buf[100];
// printf is using unsigned formatting
if (!errfmt || !errfmt[0])
errfmt = "bad subref %#x %#x";
upx_safe_snprintf(buf, sizeof(buf), errfmt, (unsigned) skip, (unsigned) take);
throwCantPack(buf);
}
return ptr + skip;
} }
/************************************************************************* /*************************************************************************
@@ -153,21 +156,21 @@ void MemBuffer::fill(unsigned off, unsigned len, int value) {
#define MAGIC2(p) ((PTR_BITS32(p) ^ 0xfefdbeeb ^ 0x88224411) | 1) #define MAGIC2(p) ((PTR_BITS32(p) ^ 0xfefdbeeb ^ 0x88224411) | 1)
void MemBuffer::checkState() const may_throw { void MemBuffer::checkState() const may_throw {
if (!ptr) if very_unlikely (ptr == nullptr)
throwInternalError("block not allocated"); throwInternalError("block not allocated");
assert(size_in_bytes > 0); assert(size_in_bytes > 0);
if (use_simple_mcheck()) { if (use_simple_mcheck()) {
const byte *p = (const byte *) ptr; const byte *p = (const byte *) ptr;
if (get_ne32(p - 4) != MAGIC1(p)) if very_unlikely (get_ne32(p - 4) != MAGIC1(p))
throwInternalError("memory clobbered before allocated block 1"); throwInternalError("memory clobbered before allocated block 1");
if (get_ne32(p - 8) != size_in_bytes) if very_unlikely (get_ne32(p - 8) != size_in_bytes)
throwInternalError("memory clobbered before allocated block 2"); throwInternalError("memory clobbered before allocated block 2");
if (get_ne32(p + size_in_bytes) != MAGIC2(p)) if very_unlikely (get_ne32(p + size_in_bytes) != MAGIC2(p))
throwInternalError("memory clobbered past end of allocated block"); throwInternalError("memory clobbered past end of allocated block");
} }
} }
void MemBuffer::alloc(upx_uint64_t bytes) may_throw { void MemBuffer::alloc(const upx_uint64_t bytes) may_throw {
// INFO: we don't automatically free a used buffer // INFO: we don't automatically free a used buffer
assert(ptr == nullptr); assert(ptr == nullptr);
assert(size_in_bytes == 0); assert(size_in_bytes == 0);
@@ -183,7 +186,7 @@ void MemBuffer::alloc(upx_uint64_t bytes) may_throw {
NO_printf("MemBuffer::alloc %llu: %p\n", bytes, p); NO_printf("MemBuffer::alloc %llu: %p\n", bytes, p);
if (!p) if (!p)
throwOutOfMemoryException(); throwOutOfMemoryException();
size_in_bytes = ACC_ICONV(unsigned, bytes); size_in_bytes = size_type(bytes);
if (use_simple_mcheck()) { if (use_simple_mcheck()) {
p += 16; p += 16;
// store magic constants to detect buffer overruns // store magic constants to detect buffer overruns
@@ -206,49 +209,60 @@ void MemBuffer::alloc(upx_uint64_t bytes) may_throw {
} }
void MemBuffer::dealloc() noexcept { void MemBuffer::dealloc() noexcept {
if (ptr != nullptr) { if (ptr == nullptr) {
debug_set(debug.last_return_address_dealloc, upx_return_address());
#if DEBUG || 1
// info: calling checkState() here violates "noexcept", so we need a try block
bool shall_check = true;
// bool shall_check = (std::uncaught_exceptions() == 0); // only if not unwinding
// TODO later: add a priority() method to class Throwable
if (shall_check) {
try {
checkState();
} catch (const Throwable &e) {
printErr("unknown", e);
std::terminate();
} catch (...) {
std::terminate();
}
}
#endif
stats.global_dealloc_counter += 1;
stats.global_total_active_bytes -= size_in_bytes;
if (use_simple_mcheck()) {
byte *p = (byte *) ptr;
// clear magic constants
set_ne32(p - 8, 0);
set_ne32(p - 4, 0);
set_ne32(p + size_in_bytes, 0);
set_ne32(p + size_in_bytes + 4, 0);
//
::free(p - 16); // NOLINT(clang-analyzer-unix.Malloc) // see NOTE above
} else {
::free(ptr); // NOLINT(clang-analyzer-unix.Malloc) // see NOTE above
}
ptr = nullptr;
size_in_bytes = 0;
} else {
assert_noexcept(size_in_bytes == 0); assert_noexcept(size_in_bytes == 0);
return;
} }
debug_set(debug.last_return_address_dealloc, upx_return_address());
#if DEBUG || 1
// info: calling checkState() here violates "noexcept", so we need a try block
bool shall_check = true;
// bool shall_check = (std::uncaught_exceptions() == 0); // only if not unwinding
// TODO later: add a priority() method to class Throwable
if (shall_check) {
try {
checkState();
} catch (const Throwable &e) {
printErr("unknown", e);
std::terminate();
} catch (...) {
std::terminate();
}
}
#endif
stats.global_dealloc_counter += 1;
stats.global_total_active_bytes -= size_in_bytes;
if (use_simple_mcheck()) {
byte *p = (byte *) ptr;
// clear magic constants
set_ne32(p - 8, 0);
set_ne32(p - 4, 0);
set_ne32(p + size_in_bytes, 0);
set_ne32(p + size_in_bytes + 4, 0);
//
::free(p - 16); // NOLINT(clang-analyzer-unix.Malloc) // see NOTE above
} else {
::free(ptr); // NOLINT(clang-analyzer-unix.Malloc) // see NOTE above
}
ptr = nullptr;
size_in_bytes = 0;
} }
/************************************************************************* /*************************************************************************
// //
**************************************************************************/ **************************************************************************/
TEST_CASE("MemBuffer unused 1") {
MemBuffer mb;
(void) mb;
}
TEST_CASE("MemBuffer unused 2") {
MemBuffer mb;
CHECK(mb.raw_ptr() == nullptr);
CHECK(mb.raw_size_in_bytes() == 0);
}
TEST_CASE("MemBuffer core") { TEST_CASE("MemBuffer core") {
constexpr size_t N = 64; constexpr size_t N = 64;
MemBuffer mb; MemBuffer mb;
@@ -292,45 +306,160 @@ TEST_CASE("MemBuffer core") {
} }
TEST_CASE("MemBuffer global overloads") { TEST_CASE("MemBuffer global overloads") {
MemBuffer mb(1); {
MemBuffer mb4(4); MemBuffer mb1(1);
mb.clear(); MemBuffer mb4(4);
mb4.clear(); mb1.clear();
CHECK(memcmp(mb, "\x00", 1) == 0); mb4.clear();
CHECK_THROWS(memcmp(mb, "\x00\x00", 2)); // NOLINT(bugprone-unused-return-value) CHECK(memcmp(mb1, "\x00", 1) == 0);
CHECK_THROWS(memcmp("\x00\x00", mb, 2)); // NOLINT(bugprone-unused-return-value) CHECK_THROWS(memcmp(mb1, "\x00\x00", 2)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memcmp(mb, mb4, 2)); // NOLINT(bugprone-unused-return-value) CHECK_THROWS(memcmp("\x00\x00", mb1, 2)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memcmp(mb4, mb, 2)); // NOLINT(bugprone-unused-return-value) CHECK_THROWS(memcmp(mb1, mb4, 2)); // NOLINT(bugprone-unused-return-value)
CHECK_NOTHROW(memset(mb, 255, 1)); CHECK_THROWS(memcmp(mb4, mb1, 2)); // NOLINT(bugprone-unused-return-value)
CHECK_THROWS(memset(mb, 254, 2)); CHECK_NOTHROW(memset(mb1, 255, 1));
CHECK(mb[0] == 255); CHECK_THROWS(memset(mb1, 254, 2));
CHECK_THROWS(get_be16(mb)); CHECK(mb1[0] == 255);
CHECK_THROWS(get_be32(mb)); }
CHECK_THROWS(get_be64(mb));
CHECK_THROWS(get_le16(mb));
CHECK_THROWS(get_le32(mb));
CHECK_THROWS(get_le64(mb));
CHECK_NOTHROW(get_be16(mb4));
CHECK_NOTHROW(get_be32(mb4));
CHECK_THROWS(get_be64(mb4));
CHECK_NOTHROW(get_le16(mb4));
CHECK_NOTHROW(get_le32(mb4));
CHECK_THROWS(get_le64(mb4));
CHECK_NOTHROW(set_be32(mb4, 0));
CHECK_THROWS(set_be64(mb4, 0));
CHECK_NOTHROW(set_le32(mb4, 0));
CHECK_THROWS(set_le64(mb4, 0));
}
TEST_CASE("MemBuffer unused 1") { for (size_t i = 1; i <= 16; i++) {
MemBuffer mb; MemBuffer mb(i);
CHECK(mb.raw_ptr() == nullptr); mb.clear();
CHECK(mb.raw_size_in_bytes() == 0);
}
TEST_CASE("MemBuffer unused 2") { if (i < 2) {
MemBuffer mb; CHECK_THROWS(get_ne16(mb));
(void) mb; CHECK_THROWS(get_be16(mb));
CHECK_THROWS(get_le16(mb));
CHECK_THROWS(set_ne16(mb, 0));
CHECK_THROWS(set_be16(mb, 0));
CHECK_THROWS(set_le16(mb, 0));
} else {
CHECK_NOTHROW(get_ne16(mb));
CHECK_NOTHROW(get_be16(mb));
CHECK_NOTHROW(get_le16(mb));
CHECK_NOTHROW(set_ne16(mb, 0));
CHECK_NOTHROW(set_be16(mb, 0));
CHECK_NOTHROW(set_le16(mb, 0));
}
if (i < 3) {
CHECK_THROWS(get_ne24(mb));
CHECK_THROWS(get_be24(mb));
CHECK_THROWS(get_le24(mb));
CHECK_THROWS(set_ne24(mb, 0));
CHECK_THROWS(set_be24(mb, 0));
CHECK_THROWS(set_le24(mb, 0));
} else {
CHECK_NOTHROW(get_ne24(mb));
CHECK_NOTHROW(get_be24(mb));
CHECK_NOTHROW(get_le24(mb));
CHECK_NOTHROW(set_ne24(mb, 0));
CHECK_NOTHROW(set_be24(mb, 0));
CHECK_NOTHROW(set_le24(mb, 0));
}
if (i < 4) {
CHECK_THROWS(get_ne32(mb));
CHECK_THROWS(get_be32(mb));
CHECK_THROWS(get_le32(mb));
CHECK_THROWS(set_ne32(mb, 0));
CHECK_THROWS(set_be32(mb, 0));
CHECK_THROWS(set_le32(mb, 0));
} else {
CHECK_NOTHROW(get_ne32(mb));
CHECK_NOTHROW(get_be32(mb));
CHECK_NOTHROW(get_le32(mb));
CHECK_NOTHROW(set_ne32(mb, 0));
CHECK_NOTHROW(set_be32(mb, 0));
CHECK_NOTHROW(set_le32(mb, 0));
}
if (i < 8) {
CHECK_THROWS(get_ne64(mb));
CHECK_THROWS(get_be64(mb));
CHECK_THROWS(get_le64(mb));
CHECK_THROWS(set_ne64(mb, 0));
CHECK_THROWS(set_be64(mb, 0));
CHECK_THROWS(set_le64(mb, 0));
} else {
CHECK_NOTHROW(get_ne64(mb));
CHECK_NOTHROW(get_be64(mb));
CHECK_NOTHROW(get_le64(mb));
CHECK_NOTHROW(set_ne64(mb, 0));
CHECK_NOTHROW(set_be64(mb, 0));
CHECK_NOTHROW(set_le64(mb, 0));
}
CHECK_NOTHROW(mb.subref("", 0, 0));
CHECK_NOTHROW(mb.subref("", 0, i));
CHECK_NOTHROW(mb.subref("", i, 0));
CHECK_NOTHROW(mb.subref("", i - 1, 1));
CHECK_THROWS(mb.subref("", 0, i + 1));
CHECK_THROWS(mb.subref("", i + 1, 0));
CHECK_THROWS(mb.subref("", i, 1));
CHECK_THROWS(mb.subref("", (size_t) -1, 0));
CHECK_THROWS(mb.subref("", (size_t) -1, i));
#if DEBUG || !(ACC_CC_CLANG && __PPC64__ && ACC_ABI_BIG_ENDIAN) || 0
// @COMPILER_BUG @CLANG_BUG
if (i < 2) {
CHECK_THROWS(mb.subref("", 0, sizeof(NE16)));
CHECK_THROWS(mb.subref("", 0, sizeof(BE16)));
CHECK_THROWS(mb.subref("", 0, sizeof(LE16)));
} else {
CHECK_NOTHROW(mb.subref("", 0, sizeof(NE16)));
CHECK_NOTHROW(mb.subref("", 0, sizeof(BE16)));
CHECK_NOTHROW(mb.subref("", 0, sizeof(LE16)));
}
if (i < 4) {
CHECK_THROWS(mb.subref("", 0, sizeof(NE32)));
CHECK_THROWS(mb.subref("", 0, sizeof(BE32)));
CHECK_THROWS(mb.subref("", 0, sizeof(LE32)));
} else {
CHECK_NOTHROW(mb.subref("", 0, sizeof(NE32)));
CHECK_NOTHROW(mb.subref("", 0, sizeof(BE32)));
CHECK_NOTHROW(mb.subref("", 0, sizeof(LE32)));
}
if (i < 8) {
CHECK_THROWS(mb.subref("", 0, sizeof(NE64)));
CHECK_THROWS(mb.subref("", 0, sizeof(BE64)));
CHECK_THROWS(mb.subref("", 0, sizeof(LE64)));
} else {
CHECK_NOTHROW(mb.subref("", 0, sizeof(NE64)));
CHECK_NOTHROW(mb.subref("", 0, sizeof(BE64)));
CHECK_NOTHROW(mb.subref("", 0, sizeof(LE64)));
}
CHECK_NOTHROW(mb.subref_u<byte *>("", 0));
CHECK_NOTHROW(mb.subref_u<byte *>("", i - 1));
CHECK_THROWS(mb.subref_u<byte *>("", i));
CHECK_THROWS(mb.subref_u<byte *>("", (size_t) -1));
if (i < 2) {
CHECK_THROWS(mb.subref_u<NE16 *>("", 0));
CHECK_THROWS(mb.subref_u<BE16 *>("", 0));
CHECK_THROWS(mb.subref_u<LE16 *>("", 0));
} else {
CHECK_NOTHROW(mb.subref_u<NE16 *>("", 0));
CHECK_NOTHROW(mb.subref_u<BE16 *>("", 0));
CHECK_NOTHROW(mb.subref_u<LE16 *>("", 0));
}
if (i < 4) {
CHECK_THROWS(mb.subref_u<NE32 *>("", 0));
CHECK_THROWS(mb.subref_u<BE32 *>("", 0));
CHECK_THROWS(mb.subref_u<LE32 *>("", 0));
} else {
CHECK_NOTHROW(mb.subref_u<NE32 *>("", 0));
CHECK_NOTHROW(mb.subref_u<BE32 *>("", 0));
CHECK_NOTHROW(mb.subref_u<LE32 *>("", 0));
}
if (i < 8) {
CHECK_THROWS(mb.subref_u<NE64 *>("", 0));
CHECK_THROWS(mb.subref_u<BE64 *>("", 0));
CHECK_THROWS(mb.subref_u<LE64 *>("", 0));
} else {
CHECK_NOTHROW(mb.subref_u<NE64 *>("", 0));
CHECK_NOTHROW(mb.subref_u<BE64 *>("", 0));
CHECK_NOTHROW(mb.subref_u<LE64 *>("", 0));
}
#endif
}
} }
TEST_CASE("MemBuffer array access") { TEST_CASE("MemBuffer array access") {
+22 -11
View File
@@ -41,9 +41,9 @@ public:
typedef T element_type; typedef T element_type;
typedef typename std::add_lvalue_reference<T>::type reference; typedef typename std::add_lvalue_reference<T>::type reference;
typedef typename std::add_pointer<T>::type pointer; typedef typename std::add_pointer<T>::type pointer;
typedef unsigned size_type; // limited by UPX_RSIZE_MAX
typedef pointer iterator; typedef pointer iterator;
typedef typename std::add_pointer<const T>::type const_iterator; typedef typename std::add_pointer<const T>::type const_iterator;
typedef size_t size_type; // limited by UPX_RSIZE_MAX
protected: protected:
static const size_t element_size = sizeof(element_type); static const size_t element_size = sizeof(element_type);
@@ -62,8 +62,8 @@ public:
// array access // array access
reference operator[](ptrdiff_t i) const may_throw { reference operator[](ptrdiff_t i) const may_throw {
// NOTE: &array[SIZE] is *not* legal for containers like std::vector and MemBuffer ! // NOTE: &array[SIZE] is *not* legal for containers like std::vector and MemBuffer !
if very_unlikely (i < 0 || mem_size(element_size, i) + element_size > size_in_bytes) if very_unlikely (i < 0 || mem_size(element_size, i) >= size_in_bytes)
throwCantPack("MemBuffer invalid array index %td (%u bytes)", i, size_in_bytes); throwCantPack("MemBuffer invalid array index %td (%zu bytes)", i, size_in_bytes);
return ptr[i]; return ptr[i];
} }
// dereference // dereference
@@ -169,8 +169,8 @@ inline typename MemBufferBase<T>::pointer raw_index_bytes(const MemBufferBase<T>
#define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \ #define XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION(A, B, RType) \
typename std::enable_if<std::is_same<A, B>::value, RType>::type typename std::enable_if<std::is_same<A, B>::value, RType>::type
#endif #endif
#define C MemBufferBase
#define XSPAN_FWD_C_IS_MEMBUFFER 1 #define XSPAN_FWD_C_IS_MEMBUFFER 1
#define C MemBufferBase
#if WITH_XSPAN >= 1 #if WITH_XSPAN >= 1
#define D XSPAN_NS(Ptr) #define D XSPAN_NS(Ptr)
#endif #endif
@@ -194,22 +194,22 @@ public:
static unsigned getSizeForDecompression(unsigned uncompressed_size, unsigned extra = 0) static unsigned getSizeForDecompression(unsigned uncompressed_size, unsigned extra = 0)
may_throw; may_throw;
void alloc(upx_uint64_t bytes) may_throw; noinline void alloc(upx_uint64_t bytes) may_throw;
void allocForCompression(unsigned uncompressed_size, unsigned extra = 0) may_throw; void allocForCompression(unsigned uncompressed_size, unsigned extra = 0) may_throw;
void allocForDecompression(unsigned uncompressed_size, unsigned extra = 0) may_throw; void allocForDecompression(unsigned uncompressed_size, unsigned extra = 0) may_throw;
void dealloc() noexcept; noinline void checkState() const may_throw;
void checkState() const may_throw; noinline void dealloc() noexcept;
// explicit conversion // explicit conversion
void *getVoidPtr() noexcept { return (void *) ptr; } void *getVoidPtr() noexcept { return (void *) ptr; }
const void *getVoidPtr() const noexcept { return (const void *) ptr; } const void *getVoidPtr() const noexcept { return (const void *) ptr; }
unsigned getSizeInBytes() const noexcept { return size_in_bytes; } unsigned getSizeInBytes() const noexcept { return size_in_bytes; }
unsigned getSize() const noexcept { return size_in_bytes; } // note: element_size == 1 unsigned getSize() const noexcept { return size_in_bytes / element_size; }
// util // util
noinline void fill(unsigned off, unsigned len, int value) may_throw; noinline void fill(size_t off, size_t bytes, int value) may_throw;
forceinline void clear(unsigned off, unsigned len) may_throw { fill(off, len, 0); } forceinline void clear(size_t off, size_t bytes) may_throw { fill(off, bytes, 0); }
forceinline void clear() may_throw { fill(0, size_in_bytes, 0); } forceinline void clear() may_throw { fill(0, size_in_bytes, 0); }
// If the entire range [skip, skip+take) is inside the buffer, // If the entire range [skip, skip+take) is inside the buffer,
@@ -219,9 +219,19 @@ public:
forceinline pointer subref(const char *errfmt, size_t skip, size_t take) may_throw { forceinline pointer subref(const char *errfmt, size_t skip, size_t take) may_throw {
return (pointer) subref_impl(errfmt, skip, take); return (pointer) subref_impl(errfmt, skip, take);
} }
template <class U>
forceinline U subref_u(const char *errfmt, size_t skip) may_throw {
COMPILE_TIME_ASSERT(std::is_pointer<U>::value)
return (U) subref_impl(errfmt, skip, sizeof(typename std::remove_pointer<U>::type));
}
template <class U>
forceinline U subref_u(const char *errfmt, size_t skip, size_t take) may_throw {
COMPILE_TIME_ASSERT(std::is_pointer<U>::value)
return (U) subref_impl(errfmt, skip, take);
}
private: private:
void *subref_impl(const char *errfmt, size_t skip, size_t take) may_throw; noinline void *subref_impl(const char *errfmt, size_t skip, size_t take) may_throw;
// static debug stats // static debug stats
struct Stats { struct Stats {
@@ -237,6 +247,7 @@ private:
#endif #endif
}; };
static Stats stats; static Stats stats;
#if DEBUG #if DEBUG
// debugging aid // debugging aid
struct Debug { struct Debug {
+2 -2
View File
@@ -115,8 +115,8 @@
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 != 4321) #if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_BIG_ENDIAN__ + 0 != 4321)
#error "unexpected __ORDER_BIG_ENDIAN__" #error "unexpected __ORDER_BIG_ENDIAN__"
#endif #endif
#if !defined(__ORDER_BIG_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 != 1234) #if !defined(__ORDER_LITTLE_ENDIAN__) || (__ORDER_LITTLE_ENDIAN__ + 0 != 1234)
#error "unexpected __ORDER_BIG_ENDIAN__" #error "unexpected __ORDER_LITTLE_ENDIAN__"
#endif #endif
#if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__) #if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
#error "unexpected __BYTE_ORDER__" #error "unexpected __BYTE_ORDER__"
+1 -1
View File
@@ -75,6 +75,6 @@
#define _LIBCPP_HAS_ALIGNED_ALLOCATION 0 #define _LIBCPP_HAS_ALIGNED_ALLOCATION 0
#endif #endif
#endif #endif
#endif #endif // _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
/* vim:set ts=4 sw=4 et: */ /* vim:set ts=4 sw=4 et: */
+1
View File
@@ -48,6 +48,7 @@
#undef i386 #undef i386
#undef large #undef large
#undef linux #undef linux
#undef mc68000
#undef mips #undef mips
#undef near #undef near
#undef powerpc #undef powerpc
+30 -29
View File
@@ -71,7 +71,7 @@ bool mem_size_valid(upx_uint64_t element_size, upx_uint64_t n, upx_uint64_t extr
} }
upx_rsize_t mem_size(upx_uint64_t element_size, upx_uint64_t n, upx_uint64_t extra1, upx_rsize_t mem_size(upx_uint64_t element_size, upx_uint64_t n, upx_uint64_t extra1,
upx_uint64_t extra2) { upx_uint64_t extra2) may_throw {
assert(element_size > 0); assert(element_size > 0);
if very_unlikely (element_size == 0 || element_size > UPX_RSIZE_MAX) if very_unlikely (element_size == 0 || element_size > UPX_RSIZE_MAX)
throwCantPack("mem_size 1; take care"); throwCantPack("mem_size 1; take care");
@@ -144,7 +144,8 @@ TEST_CASE("ptr_diff") {
} }
// check that 2 buffers do not overlap; will throw on error // check that 2 buffers do not overlap; will throw on error
void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size) { void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size)
may_throw {
if very_unlikely (a == 0 || b == 0) if very_unlikely (a == 0 || b == 0)
throwCantPack("ptr_check_no_overlap-nullptr"); throwCantPack("ptr_check_no_overlap-nullptr");
upx_ptraddr_t a_end = a + mem_size(1, a_size); upx_ptraddr_t a_end = a + mem_size(1, a_size);
@@ -160,7 +161,7 @@ void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, s
// check that 3 buffers do not overlap; will throw on error // check that 3 buffers do not overlap; will throw on error
void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size, void ptraddr_check_no_overlap(upx_ptraddr_t a, size_t a_size, upx_ptraddr_t b, size_t b_size,
upx_ptraddr_t c, size_t c_size) { upx_ptraddr_t c, size_t c_size) may_throw {
if very_unlikely (a == 0 || b == 0 || c == 0) if very_unlikely (a == 0 || b == 0 || c == 0)
throwCantPack("ptr_check_no_overlap-nullptr"); throwCantPack("ptr_check_no_overlap-nullptr");
upx_ptraddr_t a_end = a + mem_size(1, a_size); upx_ptraddr_t a_end = a + mem_size(1, a_size);
@@ -253,6 +254,14 @@ TEST_CASE("ptr_check_no_overlap 3") {
// stdlib // stdlib
**************************************************************************/ **************************************************************************/
void *upx_calloc(size_t n, size_t element_size) may_throw {
const upx_rsize_t bytes = mem_size(element_size, n); // assert size
void *p = ::malloc(bytes);
if (p != nullptr && bytes > 0)
memset(p, 0, bytes);
return p;
}
const char *upx_getenv(const char *envvar) noexcept { const char *upx_getenv(const char *envvar) noexcept {
if (envvar != nullptr && envvar[0]) if (envvar != nullptr && envvar[0])
return ::getenv(envvar); return ::getenv(envvar);
@@ -260,11 +269,11 @@ const char *upx_getenv(const char *envvar) noexcept {
} }
// random value from libc; quality is not important for UPX // random value from libc; quality is not important for UPX
int upx_rand(void) noexcept { int upx_rand() noexcept {
return ::rand(); // NOLINT(clang-analyzer-security.insecureAPI.rand) return ::rand(); // NOLINT(clang-analyzer-security.insecureAPI.rand)
} }
void upx_rand_init(void) noexcept { void upx_rand_init() noexcept {
unsigned seed = 0; unsigned seed = 0;
seed ^= UPX_VERSION_HEX; seed ^= UPX_VERSION_HEX;
#if (!HAVE_GETTIMEOFDAY || (ACC_OS_DOS32 && defined(__DJGPP__))) && !defined(__wasi__) #if (!HAVE_GETTIMEOFDAY || (ACC_OS_DOS32 && defined(__DJGPP__))) && !defined(__wasi__)
@@ -282,14 +291,6 @@ void upx_rand_init(void) noexcept {
::srand(seed); ::srand(seed);
} }
void *upx_calloc(size_t n, size_t element_size) may_throw {
size_t bytes = mem_size(element_size, n); // assert size
void *p = ::malloc(bytes);
if (p != nullptr)
memset(p, 0, bytes);
return p;
}
// simple unoptimized memswap() // simple unoptimized memswap()
// TODO later: CHERI clang-14 bug/miscompilation with upx_memswap(); or // TODO later: CHERI clang-14 bug/miscompilation with upx_memswap(); or
// maybe caused by tagged-memory issues ??? // maybe caused by tagged-memory issues ???
@@ -420,6 +421,22 @@ void upx_std_stable_sort(void *array, size_t n, upx_compare_func_t compare) {
#endif #endif
} }
#if UPX_CONFIG_USE_STABLE_SORT
// instantiate function templates for all element sizes we need; efficient
// run-time, but code size bloat (about 4KiB code size for each function
// with my current libstdc++); not really needed as libc qsort() is
// good enough for our use cases
template void upx_std_stable_sort<1>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<2>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<4>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<5>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<8>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<16>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<32>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<56>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<72>(void *, size_t, upx_compare_func_t);
#endif // UPX_CONFIG_USE_STABLE_SORT
TEST_CASE("upx_memswap") { TEST_CASE("upx_memswap") {
auto check4 = [](int off1, int off2, int len, int a, int b, int c, int d) { auto check4 = [](int off1, int off2, int len, int a, int b, int c, int d) {
byte p[4] = {0, 1, 2, 3}; byte p[4] = {0, 1, 2, 3};
@@ -473,22 +490,6 @@ TEST_CASE("upx_memswap") {
} }
} }
#if UPX_CONFIG_USE_STABLE_SORT
// instantiate function templates for all element sizes we need; efficient
// run-time, but code size bloat (about 4KiB code size for each function
// with my current libstdc++); not really needed as libc qsort() is
// good enough for our use cases
template void upx_std_stable_sort<1>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<2>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<4>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<5>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<8>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<16>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<32>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<56>(void *, size_t, upx_compare_func_t);
template void upx_std_stable_sort<72>(void *, size_t, upx_compare_func_t);
#endif // UPX_CONFIG_USE_STABLE_SORT
#if !defined(DOCTEST_CONFIG_DISABLE) && DEBUG #if !defined(DOCTEST_CONFIG_DISABLE) && DEBUG
#if __cplusplus >= 202002L // use C++20 std::next_permutation() to test all permutations #if __cplusplus >= 202002L // use C++20 std::next_permutation() to test all permutations
namespace { namespace {
+25 -13
View File
@@ -67,13 +67,12 @@ inline void mem_size_assert(upx_uint64_t element_size, upx_uint64_t n) may_throw
} }
// "new" with asserted size; will throw on invalid size // "new" with asserted size; will throw on invalid size
#if DEBUG
template <class T> template <class T>
T *NewArray(upx_uint64_t n) may_throw { inline T *NewT(upx_uint64_t n) may_throw {
COMPILE_TIME_ASSERT(std::is_standard_layout<T>::value) COMPILE_TIME_ASSERT(std::is_standard_layout<T>::value)
COMPILE_TIME_ASSERT(std::is_trivially_copyable<T>::value) COMPILE_TIME_ASSERT(std::is_trivially_copyable<T>::value)
COMPILE_TIME_ASSERT(std::is_trivially_default_constructible<T>::value) COMPILE_TIME_ASSERT(std::is_trivially_default_constructible<T>::value)
upx_rsize_t bytes = mem_size(sizeof(T), n); // assert size const upx_rsize_t bytes = mem_size(sizeof(T), n); // assert size
T *array = new T[size_t(n)]; T *array = new T[size_t(n)];
#if !defined(__SANITIZE_MEMORY__) #if !defined(__SANITIZE_MEMORY__)
if (array != nullptr && bytes > 0) { if (array != nullptr && bytes > 0) {
@@ -84,11 +83,25 @@ T *NewArray(upx_uint64_t n) may_throw {
UNUSED(bytes); UNUSED(bytes);
return array; return array;
} }
#define New(type, n) (NewArray<type>((n))) #if DEBUG || 1
#define New(type, n) (NewT<type>((n)))
#else #else
#define New(type, n) new type[mem_size_get_n(sizeof(type), (n))] #define New(type, n) new type[mem_size_get_n(sizeof(type), (n))]
#endif #endif
template <class T>
inline T *New0T(upx_uint64_t n) may_throw {
COMPILE_TIME_ASSERT(std::is_standard_layout<T>::value)
COMPILE_TIME_ASSERT(std::is_trivially_copyable<T>::value)
COMPILE_TIME_ASSERT(std::is_trivially_default_constructible<T>::value)
const upx_rsize_t bytes = mem_size(sizeof(T), n); // assert size
T *array = new T[size_t(n)];
if (array != nullptr && bytes > 0)
memset(array, 0, bytes); // NOLINT(bugprone-multi-level-implicit-pointer-conversion)
return array;
}
#define New0(type, n) (New0T<type>((n)))
/************************************************************************* /*************************************************************************
// ptr util // ptr util
**************************************************************************/ **************************************************************************/
@@ -121,18 +134,17 @@ forceinline bool ptr_is_aligned(const void *p, size_t alignment) noexcept {
// ptrdiff_t with nullptr checks and asserted size; will throw on failure // ptrdiff_t with nullptr checks and asserted size; will throw on failure
// NOTE: returns size_in_bytes, not number of elements! // NOTE: returns size_in_bytes, not number of elements!
int ptr_diff_bytes(const void *a, const void *b) may_throw; noinline int ptr_diff_bytes(const void *a, const void *b) may_throw;
unsigned ptr_udiff_bytes(const void *a, const void *b) may_throw; // asserts a >= b noinline unsigned ptr_udiff_bytes(const void *a, const void *b) may_throw; // asserts a >= b
// short names "ptr_diff" and "ptr_udiff" for types with sizeof(X) == 1 // short names "ptr_diff" and "ptr_udiff" for types with sizeof(X) == 1
template <class T, class U> template <class T, class U>
inline typename std::enable_if<sizeof(T) == 1 && sizeof(U) == 1, int>::type ptr_diff(const T *a, forceinline typename std::enable_if<sizeof(T) == 1 && sizeof(U) == 1, int>::type
const U *b) ptr_diff(const T *a, const U *b) may_throw {
may_throw {
return ptr_diff_bytes(a, b); return ptr_diff_bytes(a, b);
} }
template <class T, class U> template <class T, class U>
inline typename std::enable_if<sizeof(T) == 1 && sizeof(U) == 1, unsigned>::type forceinline typename std::enable_if<sizeof(T) == 1 && sizeof(U) == 1, unsigned>::type
ptr_udiff(const T *a, const U *b) may_throw { ptr_udiff(const T *a, const U *b) may_throw {
return ptr_udiff_bytes(a, b); return ptr_udiff_bytes(a, b);
} }
@@ -181,8 +193,8 @@ noinline const char *upx_getenv(const char *envvar) noexcept;
noinline void upx_memswap(void *a, void *b, size_t bytes) noexcept; noinline void upx_memswap(void *a, void *b, size_t bytes) noexcept;
noinline void upx_rand_init(void) noexcept; noinline void upx_rand_init() noexcept;
noinline int upx_rand(void) noexcept; noinline int upx_rand() noexcept;
typedef int(__acc_cdecl_qsort *upx_compare_func_t)(const void *, const void *); typedef int(__acc_cdecl_qsort *upx_compare_func_t)(const void *, const void *);
typedef void (*upx_sort_func_t)(void *array, size_t n, size_t element_size, upx_compare_func_t); typedef void (*upx_sort_func_t)(void *array, size_t n, size_t element_size, upx_compare_func_t);
@@ -229,7 +241,7 @@ bool maketempname(char *ofilename, size_t size, const char *ifilename, const cha
bool force = true); bool force = true);
bool makebakname(char *ofilename, size_t size, const char *ifilename, bool force = true); bool makebakname(char *ofilename, size_t size, const char *ifilename, bool force = true);
bool is_envvar_true(const char *envvar, const char *alternate_name = nullptr) noexcept; noinline bool is_envvar_true(const char *envvar, const char *alternate_name = nullptr) noexcept;
unsigned get_ratio(upx_uint64_t u_len, upx_uint64_t c_len); unsigned get_ratio(upx_uint64_t u_len, upx_uint64_t c_len);
bool set_method_name(char *buf, size_t size, int method, int level); bool set_method_name(char *buf, size_t size, int method, int level);
+7 -7
View File
@@ -44,33 +44,33 @@ struct XSpanStats {
static XSpanStats xspan_stats; static XSpanStats xspan_stats;
// HINT: set env-var "UPX_DEBUG_DOCTEST_DISABLE=1" for improved debugging experience // HINT: set env-var "UPX_DEBUG_DOCTEST_DISABLE=1" for improved debugging experience
void xspan_fail_nullptr() { void xspan_fail_nullptr() may_throw {
xspan_stats.fail_nullptr += 1; xspan_stats.fail_nullptr += 1;
throwCantPack("xspan unexpected NULL pointer; take care!"); throwCantPack("xspan unexpected NULL pointer; take care!");
} }
void xspan_fail_nullbase() { void xspan_fail_nullbase() may_throw {
xspan_stats.fail_nullbase += 1; xspan_stats.fail_nullbase += 1;
throwCantPack("xspan unexpected NULL base; take care!"); throwCantPack("xspan unexpected NULL base; take care!");
} }
void xspan_fail_not_same_base() { void xspan_fail_not_same_base() may_throw {
xspan_stats.fail_not_same_base += 1; xspan_stats.fail_not_same_base += 1;
throwCantPack("xspan unexpected base pointer; take care!"); throwCantPack("xspan unexpected base pointer; take care!");
} }
void xspan_fail_range_nullptr() { void xspan_fail_range_nullptr() may_throw {
xspan_stats.fail_range_nullptr += 1; xspan_stats.fail_range_nullptr += 1;
throwCantPack("xspan_check_range: unexpected NULL pointer; take care!"); throwCantPack("xspan_check_range: unexpected NULL pointer; take care!");
} }
void xspan_fail_range_nullbase() { void xspan_fail_range_nullbase() may_throw {
xspan_stats.fail_range_nullbase += 1; xspan_stats.fail_range_nullbase += 1;
throwCantPack("xspan_check_range: unexpected NULL base; take care!"); throwCantPack("xspan_check_range: unexpected NULL base; take care!");
} }
void xspan_fail_range_range() { void xspan_fail_range_range() may_throw {
xspan_stats.fail_range_range += 1; xspan_stats.fail_range_range += 1;
throwCantPack("xspan_check_range: pointer out of range; take care!"); throwCantPack("xspan_check_range: pointer out of range; take care!");
} }
void xspan_check_range(const void *ptr, const void *base, ptrdiff_t size_in_bytes) { void xspan_check_range(const void *ptr, const void *base, ptrdiff_t size_in_bytes) may_throw {
xspan_stats.check_range_counter += 1; xspan_stats.check_range_counter += 1;
if very_unlikely (ptr == nullptr) if very_unlikely (ptr == nullptr)
xspan_fail_range_nullptr(); xspan_fail_range_nullptr();
+18 -2
View File
@@ -92,7 +92,7 @@ XSPAN_FWD_TU_VOIDPTR(int) memcmp(const C<T> &a, const E<U> &b, size_t n) {
#endif #endif
template <class T> template <class T>
inline void *memcpy(C<T> a, const void *b, size_t n) { inline void *memcpy(const C<T> a, const void *b, size_t n) {
return memcpy(a.raw_bytes(n), b, n); return memcpy(a.raw_bytes(n), b, n);
} }
template <class T> template <class T>
@@ -114,7 +114,7 @@ XSPAN_FWD_TU_VOIDPTR(void *) memcpy(const C<T> &a, const E<U> &b, size_t n) {
#endif #endif
template <class T> template <class T>
inline void *memmove(C<T> a, const void *b, size_t n) { inline void *memmove(const C<T> a, const void *b, size_t n) {
return memmove(a.raw_bytes(n), b, n); return memmove(a.raw_bytes(n), b, n);
} }
template <class T> template <class T>
@@ -204,6 +204,10 @@ inline unsigned get_ne16(const C<T> &a) {
return get_ne16(a.raw_bytes(2)); return get_ne16(a.raw_bytes(2));
} }
template <class T> template <class T>
inline unsigned get_ne24(const C<T> &a) {
return get_ne24(a.raw_bytes(3));
}
template <class T>
inline unsigned get_ne32(const C<T> &a) { inline unsigned get_ne32(const C<T> &a) {
return get_ne32(a.raw_bytes(4)); return get_ne32(a.raw_bytes(4));
} }
@@ -217,6 +221,10 @@ inline unsigned get_be16(const C<T> &a) {
return get_be16(a.raw_bytes(2)); return get_be16(a.raw_bytes(2));
} }
template <class T> template <class T>
inline unsigned get_be24(const C<T> &a) {
return get_be24(a.raw_bytes(3));
}
template <class T>
inline unsigned get_be32(const C<T> &a) { inline unsigned get_be32(const C<T> &a) {
return get_be32(a.raw_bytes(4)); return get_be32(a.raw_bytes(4));
} }
@@ -247,6 +255,10 @@ inline void set_ne16(const C<T> &a, unsigned v) {
return set_ne16(a.raw_bytes(2), v); return set_ne16(a.raw_bytes(2), v);
} }
template <class T> template <class T>
inline void set_ne24(const C<T> &a, unsigned v) {
return set_ne24(a.raw_bytes(3), v);
}
template <class T>
inline void set_ne32(const C<T> &a, unsigned v) { inline void set_ne32(const C<T> &a, unsigned v) {
return set_ne32(a.raw_bytes(4), v); return set_ne32(a.raw_bytes(4), v);
} }
@@ -260,6 +272,10 @@ inline void set_be16(const C<T> &a, unsigned v) {
return set_be16(a.raw_bytes(2), v); return set_be16(a.raw_bytes(2), v);
} }
template <class T> template <class T>
inline void set_be24(const C<T> &a, unsigned v) {
return set_be24(a.raw_bytes(3), v);
}
template <class T>
inline void set_be32(const C<T> &a, unsigned v) { inline void set_be32(const C<T> &a, unsigned v) {
return set_be32(a.raw_bytes(4), v); return set_be32(a.raw_bytes(4), v);
} }
+8 -6
View File
@@ -43,12 +43,12 @@
XSPAN_NAMESPACE_BEGIN XSPAN_NAMESPACE_BEGIN
// HINT: set env-var "UPX_DEBUG_DOCTEST_DISABLE=1" for improved debugging experience // HINT: set env-var "UPX_DEBUG_DOCTEST_DISABLE=1" for improved debugging experience
noreturn void xspan_fail_nullptr(void) may_throw; noreturn void xspan_fail_nullptr() may_throw;
noreturn void xspan_fail_nullbase(void) may_throw; noreturn void xspan_fail_nullbase() may_throw;
noreturn void xspan_fail_not_same_base(void) may_throw; noreturn void xspan_fail_not_same_base() may_throw;
noreturn void xspan_fail_range_nullptr(void) may_throw; noreturn void xspan_fail_range_nullptr() may_throw;
noreturn void xspan_fail_range_nullbase(void) may_throw; noreturn void xspan_fail_range_nullbase() may_throw;
noreturn void xspan_fail_range_range(void) may_throw; noreturn void xspan_fail_range_range() may_throw;
void xspan_check_range(const void *ptr, const void *base, ptrdiff_t size_in_bytes) may_throw; void xspan_check_range(const void *ptr, const void *base, ptrdiff_t size_in_bytes) may_throw;
// help constructor to distinguish between number of elements and bytes // help constructor to distinguish between number of elements and bytes
@@ -225,6 +225,7 @@ XSPAN_NAMESPACE_END
#ifndef XSPAN_DELETED_FUNCTION #ifndef XSPAN_DELETED_FUNCTION
#define XSPAN_DELETED_FUNCTION = delete #define XSPAN_DELETED_FUNCTION = delete
#endif #endif
// function/method constraints // function/method constraints
#define XSPAN_REQUIRES_CONVERTIBLE_ONE_DIRECTION(From, To, RType) \ #define XSPAN_REQUIRES_CONVERTIBLE_ONE_DIRECTION(From, To, RType) \
typename std::enable_if<XSPAN_NS(XSpan_is_convertible) < From, To>::value, RType > ::type typename std::enable_if<XSPAN_NS(XSpan_is_convertible) < From, To>::value, RType > ::type
@@ -250,6 +251,7 @@ XSPAN_NAMESPACE_END
#include "xspan_impl_ptr_or_span.h" #include "xspan_impl_ptr_or_span.h"
#include "xspan_impl_span.h" #include "xspan_impl_span.h"
#include "xspan_impl_ptr.h" #include "xspan_impl_ptr.h"
#undef XSPAN_REQUIRES_CONVERTIBLE_ONE_DIRECTION #undef XSPAN_REQUIRES_CONVERTIBLE_ONE_DIRECTION
#undef XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION #undef XSPAN_REQUIRES_CONVERTIBLE_ANY_DIRECTION
#undef XSPAN_REQUIRES_CONVERTIBLE_A #undef XSPAN_REQUIRES_CONVERTIBLE_A
+16 -13
View File
@@ -34,11 +34,6 @@ class CSelf {
#endif #endif
public: public:
typedef T element_type;
typedef typename std::add_lvalue_reference<T>::type reference;
typedef typename std::add_pointer<T>::type pointer;
typedef size_t size_type;
// befriend all // befriend all
template <class> template <class>
friend struct PtrOrSpan; friend struct PtrOrSpan;
@@ -47,6 +42,11 @@ public:
template <class> template <class>
friend struct Span; friend struct Span;
typedef T element_type;
typedef typename std::add_lvalue_reference<T>::type reference;
typedef typename std::add_pointer<T>::type pointer;
typedef size_t size_type;
#if XSPAN_CONFIG_ENABLE_IMPLICIT_CONVERSION #if XSPAN_CONFIG_ENABLE_IMPLICIT_CONVERSION
public: public:
operator pointer() const noexcept { return ptr; } operator pointer() const noexcept { return ptr; }
@@ -119,6 +119,7 @@ forceinline ~CSelf() noexcept {}
size_in_bytes = 0; size_in_bytes = 0;
assertInvariants(); assertInvariants();
} }
// constructors from pointers // constructors from pointers
CSelf(pointer first, XSpanCount count) CSelf(pointer first, XSpanCount count)
: ptr(makePtr(first)), base(makeBase(first)), : ptr(makePtr(first)), base(makeBase(first)),
@@ -171,12 +172,13 @@ forceinline ~CSelf() noexcept {}
// constructors from MemBuffer // constructors from MemBuffer
CSelf(MemBuffer &mb) CSelf(MemBuffer &mb)
: CSelf(makeNotNull((pointer) membuffer_get_void_ptr(mb)), : CSelf(makeNotNull((pointer) membuffer_get_void_ptr(mb)),
XSpanSizeInBytes(membuffer_get_size(mb))) {} XSpanSizeInBytes(membuffer_get_size_in_bytes(mb))) {}
CSelf(pointer first, MemBuffer &mb) CSelf(pointer first, MemBuffer &mb)
: CSelf(first, XSpanSizeInBytes(membuffer_get_size(mb)), : CSelf(first, XSpanSizeInBytes(membuffer_get_size_in_bytes(mb)),
makeNotNull((pointer) membuffer_get_void_ptr(mb))) {} makeNotNull((pointer) membuffer_get_void_ptr(mb))) {}
CSelf(std::nullptr_t, MemBuffer &) XSPAN_DELETED_FUNCTION; CSelf(std::nullptr_t, MemBuffer &) XSPAN_DELETED_FUNCTION;
#endif #endif
// disable constructors from nullptr to catch compile-time misuse // disable constructors from nullptr to catch compile-time misuse
private: private:
CSelf(std::nullptr_t, XSpanCount) XSPAN_DELETED_FUNCTION; CSelf(std::nullptr_t, XSpanCount) XSPAN_DELETED_FUNCTION;
@@ -404,7 +406,7 @@ public:
} }
private: private:
pointer check_deref(pointer p) const { pointer check_deref(pointer p) const may_throw {
assertInvariants(); assertInvariants();
if __acc_cte (!configRequirePtr && p == nullptr) if __acc_cte (!configRequirePtr && p == nullptr)
xspan_fail_nullptr(); xspan_fail_nullptr();
@@ -412,7 +414,7 @@ private:
xspan_check_range(p, base, size_in_bytes - sizeof(T)); xspan_check_range(p, base, size_in_bytes - sizeof(T));
return p; return p;
} }
pointer check_deref(pointer p, ptrdiff_t n) const { pointer check_deref(pointer p, ptrdiff_t n) const may_throw {
assertInvariants(); assertInvariants();
if __acc_cte (!configRequirePtr && p == nullptr) if __acc_cte (!configRequirePtr && p == nullptr)
xspan_fail_nullptr(); xspan_fail_nullptr();
@@ -422,7 +424,7 @@ private:
xspan_check_range(p, base, size_in_bytes - sizeof(T)); xspan_check_range(p, base, size_in_bytes - sizeof(T));
return p; return p;
} }
pointer check_add(pointer p, ptrdiff_t n) const { pointer check_add(pointer p, ptrdiff_t n) const may_throw {
assertInvariants(); assertInvariants();
if __acc_cte (!configRequirePtr && p == nullptr) if __acc_cte (!configRequirePtr && p == nullptr)
xspan_fail_nullptr(); xspan_fail_nullptr();
@@ -442,14 +444,15 @@ public: // raw access
pointer raw_base() const noexcept { return base; } pointer raw_base() const noexcept { return base; }
size_type raw_size_in_bytes() const noexcept { return size_in_bytes; } size_type raw_size_in_bytes() const noexcept { return size_in_bytes; }
pointer raw_bytes(size_t bytes) const { pointer raw_bytes(size_t bytes) const may_throw {
assertInvariants(); assertInvariants();
if (bytes > 0) { if (bytes > 0) {
if __acc_cte (!configRequirePtr && ptr == nullptr) if __acc_cte (!configRequirePtr && ptr == nullptr)
xspan_fail_nullptr(); xspan_fail_nullptr();
if __acc_cte (configRequireBase || base != nullptr) { if __acc_cte (configRequireBase || base != nullptr)
xspan_check_range(ptr, base, size_in_bytes - bytes); xspan_check_range(ptr, base, size_in_bytes - bytes);
} if very_unlikely (__acc_cte(VALGRIND_CHECK_MEM_IS_ADDRESSABLE(ptr, bytes) != 0))
throwCantPack("raw_bytes valgrind-check-mem");
} }
return ptr; return ptr;
} }

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