Compare commits

...

737 Commits

Author SHA1 Message Date
Markus F.X.J. Oberhumer 69ca635c4c all: prepare for 4.0.0 release 2022-10-28 10:38:03 +02:00
Markus F.X.J. Oberhumer e0bf460993 src: rename membuffer "Uncompression" to "Decompression" 2022-10-28 10:34:31 +02:00
Markus F.X.J. Oberhumer 29762a8a96 CI: small update 2022-10-28 07:51:00 +02:00
Markus F.X.J. Oberhumer c7ef08dc2d testsuite: update 2022-10-27 22:35:45 +02:00
John Reiser 50a6698715 Each PROT_WRITE segment has implicit .bss on end of last page (64-bit only for now);
Also  workaround kernel bug invoking the escape hatch on arm64 (aarch64).
https://github.com/upx/upx/issues/611
2022-10-27 11:01:37 -07:00
Markus F.X.J. Oberhumer 7dd2cdea1e src: deprecate util/bptr.h 2022-10-27 17:52:15 +02:00
Markus F.X.J. Oberhumer af87f7f2bf doc: add missing NEWS entries 2022-10-27 18:10:29 +02:00
Markus F.X.J. Oberhumer 295889023f all: set next version back to 4.0.0, bump tentative release date, update
docs
2022-10-27 17:36:02 +02:00
Markus F.X.J. Oberhumer feef2e38cf all: final tweaks for release 2022-10-27 16:53:16 +02:00
Markus F.X.J. Oberhumer 80d30aab32 testsuite: update checksums caused by version change 2022-10-27 16:03:08 +02:00
Markus F.X.J. Oberhumer e910a9dc3e all: change version back to 3.99; docs: warn about know regressions and
clarify GPLv2+ COPYING
2022-10-27 16:00:25 +02:00
Markus F.X.J. Oberhumer 504224696c misc: update misc/rebuild-stubs-with-podman to install previous UPX versions 2022-10-27 15:35:59 +02:00
Markus F.X.J. Oberhumer e2acd666df CI: remove some obsolete stuff 2022-10-25 02:53:49 +02:00
Markus F.X.J. Oberhumer e5c0d998b7 src: fully deprecate src/Makefile; minor doc and CI cleanups 2022-10-25 01:48:45 +02:00
Markus F.X.J. Oberhumer 63f6fef964 all: don't use egrep or fgrep 2022-10-25 01:47:42 +02:00
Markus F.X.J. Oberhumer 983eb6d676 src: improve error message when using doctest options like '--dt-help'; add
doctest info to help.cpp
2022-10-25 01:47:38 +02:00
Markus F.X.J. Oberhumer 98fedef1a1 testsuite: update checksums 2022-10-24 12:56:49 +02:00
Markus F.X.J. Oberhumer 75a769759d src/stub: sync stubs 2022-10-24 12:56:49 +02:00
John Reiser 2354b01bad Adapt to libbfd: "no Shdrs" requires 0==.e_shentsize and 0==.e_shnum
modified:   p_lx_elf.cpp
2022-10-24 12:56:49 +02:00
John Reiser c331b9f1e2 Zero the tail of last RW page, even when variable page size
https://github.com/upx/upx/issues/611
	modified:   stub/src/amd64-linux.elf-main.c
2022-10-24 12:56:49 +02:00
John Reiser afeaeeddec munmap(, Phdr[C_TEXT=1].p_memsz); // not .p_vaddr
modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
2022-10-24 12:56:49 +02:00
John Reiser ab7ef9f511 Document the value of "brk #0" instruction
modified:   stub/src/arm64-linux.elf-entry.S
2022-10-24 12:56:49 +02:00
John Reiser d3ad6d25d8 PackLinuxElf64::asl_pack2_Shdrs() for better fit in logical flow
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2022-10-24 12:56:49 +02:00
John Reiser 2e29f9fa5f pack2() fixes for --android-shlib
WIP for https://github.com/upx/upx/issues/599
	modified:   p_lx_elf.cpp
2022-10-24 12:56:49 +02:00
John Reiser 5d9f71bb13 asl_pack1_Shdrs()
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2022-10-24 12:56:49 +02:00
John Reiser 82ed25bb44 Major fix 64-bit un_shlib_1() and unpack(), but not --android-shlib
Also canUnpack() is really a 'bool' which sets overlay_offset
when 'true'; confusing!
        https://github.com/upx/upx/issues/599 (partial)
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.h
2022-10-24 12:56:49 +02:00
Markus F.X.J. Oberhumer f57393c0e8 all: simplify include path handling; update src/Makefile 2022-10-24 12:56:35 +02:00
Markus F.X.J. Oberhumer b54cced19c src: add some tests for compress_zlib 2022-10-24 12:18:25 +02:00
Markus F.X.J. Oberhumer 60a0544314 all: bump tentative release date 2022-10-23 23:15:00 +02:00
Markus F.X.J. Oberhumer 283c1cf931 src: add --version-short option; support doctest --dt-XXX options; cleanups 2022-10-23 23:09:13 +02:00
Markus F.X.J. Oberhumer fff53efc05 src: add some more xspan tests 2022-10-20 14:06:20 +02:00
Markus F.X.J. Oberhumer 07d368adca all: misc cleanups 2022-10-20 02:09:05 +02:00
Markus F.X.J. Oberhumer 13276d93fa all: bump tentative release date 2022-10-18 21:07:48 +02:00
Markus F.X.J. Oberhumer 79b1b1a586 submodules: update for new version 2022-10-18 20:32:03 +02:00
Markus F.X.J. Oberhumer 2f083f3e56 submodules: update for new version 2022-10-14 11:21:19 +02:00
Markus F.X.J. Oberhumer 73b0b4db9d submodules: update for new version 2022-10-12 17:26:11 +02:00
Markus F.X.J. Oberhumer ca0e614b56 CI: update for new GitHub Actions deprecated set-output commands 2022-10-12 16:29:20 +02:00
John Reiser 72613d06a5 Look for PackHeader in the right place.
https://github.com/upx/upx/issues/606
	modified:   p_mach.cpp
2022-10-11 08:08:55 -07:00
John Reiser 48ad5513ff un_shlib_1() allows test mode ("-t") which has (nullptr == fo)
modified:   p_lx_elf.cpp
2022-10-07 12:52:21 -07:00
John Reiser 201d9f1346 Fix length when stub unmaps compressed input for main program
https://github.com/upx/upx/issues/606
	modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/tmp/amd64-linux.elf-fold.map
2022-10-07 09:53:29 +02:00
John Reiser 1e8f1f49d0 is_bad_linker_command() ignores LC_REQ_DYLD
https://github.com/upx/upx/issues/606
	modified:   p_mach.cpp
2022-10-06 10:15:10 -07:00
Markus F.X.J. Oberhumer 65707900bc src: remove more traces of fictional powerpc64le-darwin 2022-10-06 15:53:50 +02:00
Markus F.X.J. Oberhumer 39c5be43aa CI: add Visual Studio 2022 builds; updates 2022-10-06 15:35:51 +02:00
Markus F.X.J. Oberhumer c4437cb293 all: add support for a basic "make test" 2022-10-06 14:10:35 +02:00
Markus F.X.J. Oberhumer e2b86a49db src: fix recently introduced bug in unoptimzeReloc 2022-10-06 14:09:45 +02:00
Markus F.X.J. Oberhumer 8fe83be87f misc: update misc/rebuild-stubs-with-podman so that we can build
the full upx program in a container
2022-10-05 16:07:12 +02:00
Markus F.X.J. Oberhumer 17167d4905 CI: update macos-12 build 2022-10-05 02:05:20 +02:00
John Reiser 05ff7e35a1 Warn for big shell scripts, and send them to --force-execve.
Also propagte error code when execve() fails for compressed shell,
to avoid confusion of `hlt` ==> SIGSEGV.
https://github.com/upx/upx/issues/604
2022-10-05 01:30:32 +02:00
Markus F.X.J. Oberhumer f67cec4752 submodules: update for new version 2022-10-04 15:33:27 +02:00
Markus F.X.J. Oberhumer fd4882abcf CI: run close-stale-issues.yml once per week 2022-10-04 13:28:51 +02:00
Markus F.X.J. Oberhumer 0f42579e68 src: fix djgpp and musl builds 2022-10-02 20:00:30 +02:00
Markus F.X.J. Oberhumer 7398d8f68f src: enable -Wsuggest-override in src/conf.h 2022-09-27 18:17:28 +02:00
John Reiser ec33109b22 clang-10 requires the use of 'override'
Discovered during gitlab auto-build for https://github.com/upx/upx/issues/595
	modified:   Makefile
	modified:   p_armpe.h
	modified:   p_djgpp2.h
	modified:   p_lx_elf.h
	modified:   p_lx_exc.h
	modified:   p_lx_interp.h
	modified:   p_lx_sh.h
	modified:   p_mach.h
	modified:   p_ps1.h
	modified:   p_tmt.h
	modified:   p_unix.h
	modified:   p_vmlinx.h
	modified:   p_vmlinz.h
	modified:   p_w32pe.h
	modified:   p_w64pep.h
	modified:   pefile.h
2022-09-27 18:15:48 +02:00
Markus F.X.J. Oberhumer 2cfa4c1eb7 CI: update testsuite checksums caused by getVersion() bump 2022-09-27 18:15:48 +02:00
John Reiser a13b4d10d9 After upx-3.96, the de-compressing stub for ELF moved
... so unpack() of newly-compressed ELF by upx-3.96 now says
"CantUnpackException: need a newer version of UPX"
        https://github.com/upx/upx/issues/595
	modified:   p_lx_elf.h
	modified:   packer.h
2022-09-27 18:09:20 +02:00
Markus F.X.J. Oberhumer 36e94e58d0 stub: add mising powerpc64-darwin tmp dump files 2022-09-27 18:09:20 +02:00
John Reiser d0a52bd483 More cleanup of stubs for powerpc64le-darwin* which does not exist.
Only powerpc64-darwin (BigEndian, no suffix) exists.
https://github.com/upx/upx/issues/596
2022-09-27 15:58:35 +02:00
dependabot[bot] 38a1d3179b build(deps): bump actions/stale from 5 to 6
Bumps [actions/stale](https://github.com/actions/stale) from 5 to 6.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-22 17:07:26 +00:00
Markus F.X.J. Oberhumer 0d639d6386 CI: add macos job 2022-09-21 21:55:07 +02:00
Markus F.X.J. Oberhumer 4256057c27 src: add a mem_size() call hinted by GitHub CodeQL 2022-09-21 19:28:46 +02:00
Markus F.X.J. Oberhumer b720b47c12 CI: update testsuite caused by previous commit 2022-09-21 19:22:39 +02:00
John Reiser 55e4a4f086 Assembler local symbol ("1:") clobbered by code in .macro
https://github.com/upx/upx/issues/534
	modified:   stub/arm64-darwin.macho-entry.h
	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/arm64-linux.shlib-init.h
	modified:   stub/src/arch/arm64/v8/lzma_d.S
	modified:   stub/src/arch/arm64/v8/macros.S
2022-09-20 13:08:14 -07:00
Markus F.X.J. Oberhumer b4cb9f8b2f src: silence some bogus GitHub CodeQL warnings; add MemBuffer "+" overload 2022-09-17 07:53:14 +02:00
Markus F.X.J. Oberhumer 63298ebd6d src: silence clang-15 compiler warnings 2022-09-16 16:31:34 +02:00
Markus F.X.J. Oberhumer 73c816e468 doc: work on improving docs; add generated files to Git repo 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 0492e650ef submodules: update for new versions 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer b8b94ee89e src: more cleanups; NFCI 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 81176716d5 src: linker: fix a minor printf format issue detected by codeql 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 26e7ae00e9 CI: create codeql-analysis.yml 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer c75d7a685d src: major cleanups, introduce new eXtended Span class
- initial minimally invasive eXtended Span implementation
- rename ptr_diff to ptr_diff_bytes
- move some files to util subdir
- lots of cleanups
- start using the new checked pointers - this needs some real-world testing
2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 4318cc22ee src: cleanup option handling, add testcases; fixes #587 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 575cb720c6 doc: work on README 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 5db34fbf92 src: new ACC version 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 7cfef2f6bf CI: update testsuite checksums caused by version date bump 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 4603f1df4b src: bump tentative release date 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer c69fcfff9d src: doctest: start work on using doctest 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 70f14101ed doc: update README.SRC, mention misc/rebuild-stubs-with-podman 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer a9803459ed doc: move BUGS into doc subdirectory 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 43034e8e92 doc: remove outdated README.1ST 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer ef547034f6 misc: add misc/rebuild-stubs-with-podman files 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer e87fc60391 misc: update clang-format files 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 45e6e73d85 misc: move some scripts from src/stub/scripts to misc/scripts 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer be30c26dbb make: update src/Makefile 2022-09-16 13:26:13 +02:00
Markus F.X.J. Oberhumer 79e9b0762c CI: work on new cmake-based CI; updates 2022-09-16 13:26:10 +02:00
Markus F.X.J. Oberhumer a9a806c418 CI: remove obsolete travis_deploy.sh - superseded by GitHub Actions 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer c7d8b6fed1 make: add new top-level Makefile, now using CMake 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer a723efd225 make: remove top-level Makefile 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer cf429dfce4 cmake: add CMakeLists.txt for building with CMake 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer 3fcd64a0c0 misc: update files 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer 83cb38022b misc: add compile_flags.txt to support editors using clangd LSP 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer 93c04d1f66 misc: add .gitattributes for GitHub linguist 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer 3c47898cf4 make: adjust for new vendor/lzma-sdk location 2022-09-11 13:26:32 +02:00
Markus F.X.J. Oberhumer 61e1366122 submodules: add new upx-vendor submodules in directory "vendor" 2022-09-11 13:26:29 +02:00
Markus F.X.J. Oberhumer a20636fd63 submodules: remove submodule src/lzma-sdk 2022-09-04 04:24:39 +02:00
Markus F.X.J. Oberhumer aa8cdca0a9 src: consistently use TESTING for internal development tests 2022-09-04 04:24:39 +02:00
Markus F.X.J. Oberhumer 6931a3aa70 src: enable -Wzero-as-null-pointer-constant when using clang 2022-09-04 04:24:39 +02:00
Markus F.X.J. Oberhumer d001a63bce Welcome 2022. 2022-09-04 04:24:39 +02:00
Markus F.X.J. Oberhumer 0d3377f48b src: p_mach.cpp: disable -Wcast-align warning 2022-08-17 19:54:44 +02:00
John Reiser aeb04d97c8 powerpc64-darwin.macho (not powerpc64le-darwin.macho)
All Apple PowerPC are BigEndian only.
        https://github.com/upx/upx/issues/596
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   packmast.cpp
2022-09-03 12:39:50 -07:00
John Reiser eb68ab91cd PackDjgpp2::canPack() allows "loose" (non-contiguous) text,data,bss
Hack: grow text to eliminate gap; don't complain unless bss overlaps data
https://github.com/upx/upx/issues/45
	modified:   p_djgpp2.cpp
2022-08-29 11:37:46 +02:00
Markus F.X.J. Oberhumer ee242ba987 CI: improve workflows/close-stale-issues.yml 2022-08-27 21:04:56 +02:00
cui fliter 44a53736ff fix some typos
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-08-23 19:20:21 +02:00
Markus F.X.J. Oberhumer 1b21fef081 CI: improve workflows/close-stale-issues.yml 2022-08-12 17:59:32 +02:00
Markus F.X.J. Oberhumer 5f9c50cd3e clang-format 2022-08-10 23:29:43 +02:00
Markus F.X.J. Oberhumer 793d8c1d2e Fix compilation with C++20. 2022-07-17 21:16:11 +02:00
Markus F.X.J. Oberhumer 81f868a0c6 Add .github/workflows/close-stale-issues.yml 2022-08-10 23:12:09 +02:00
John Reiser dadbbbdc64 Avoid trouble: disallow empty name of export directory
https://github.com/upx/upx/issues/425
	modified:   pefile.cpp
2022-08-13 12:25:30 -07:00
John Reiser bfd2153f2b Delete trailing space characters
https://github.com/upx/upx/pull/589
	modified:   pefile.cpp
2022-07-26 20:09:16 -07:00
S01den 077793fa5e Update pefile.cpp
I found a bug by participating to the Binary Golf Grand Prix 3 (https://tmpout.sh/bggp/3/) : upx text.exe segfaults when NumberOfSections in the IMAGE_FILE_HEADER is NULL, so 
if (memcmp(isection[0].name,"UPX",3) == 0) triggers a NULL pointer dereference causing a crash.
To fix it, just have to check if isection is NULL (which means NumberOfSections = 0) or not.
2022-07-27 01:54:01 +02:00
John Reiser acad3c3000 DT_INIT_ARRAY noes not pertain to DT_* for symbol table info
https://github.com/upx/upx/issues/586
	modified:   p_lx_elf.cpp
2022-07-02 20:52:18 -07:00
John Reiser 3b4627e17e Add filename to infoWarning("file coruupted")
modified:   p_mach.cpp
2022-06-01 08:34:23 -07:00
John Reiser 05976ee1a7 Try harder to de-compress corrupted Mach-o file.
https://github.com/upx/upx/issues/579
	modified:   p_mach.cpp
2022-05-31 11:52:10 -07:00
John Reiser c1311c78a3 Extra space to force "git commit" to force rebuild for tagging Issue
https://github.com/upx/upx/issues/577
	modified:   p_lx_elf.cpp
2022-05-30 15:19:18 -07:00
John Reiser 717150b7f3 Stupid MSVC: bad C4706: assignment within conditional expression
-    for (unsigned j=0; (k = dt_names[j]); ++j) {
+    for (unsigned j=0; ((k = dt_names[j]), k); ++j) {

The complaint was:
    p_lx_elf.cpp(5710) : warning C4706: assignment within conditional expression
which is INCORRECT, as shown in the change which is 100% equivalent.
The assignment occurs BEFORE the conditional expression.
	modified:   p_lx_elf.cpp
2022-05-30 15:09:34 -07:00
John Reiser a68c62d938 More placate compilers
https://github.com/upx/upx/issues/577
	modified:   p_lx_elf.cpp
2022-05-30 15:02:53 -07:00
John Reiser c11f8a569a Placate 'clang' -Wcast-align
https://github.com/upx/upx/issues/577
	modified:   p_lx_elf.cpp
2022-05-30 14:55:39 -07:00
John Reiser 03436d2415 Bug in handling DT_GNU_HASH table.
Fix includes a more-general and stronger heuristic to find the end of
GNU_HASH table when there is no ElfXX_Shdr for it.  64-bit only for now.
(This is needed to help prevent SIGSEGV when processing tampered .exe.)

https://github.com/upx/upx/issues/577
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2022-05-30 14:24:21 -07:00
John Reiser 4ae75375e0 LC_BUILD_VERSION etc for XCode 13+
https://github.com/upx/upx/issues/578
	modified:   p_mach.cpp
	modified:   p_mach_enum.h
2022-05-30 01:05:09 -07:00
John Reiser 2721ef0636 ElfLinker::init() allows symbols and relocations (but not Sections) to be empty
modified:   linker.cpp
	modified:   linker.h
2022-05-04 13:29:36 -07:00
John Reiser 7a232cb330 Allow qemu on host with smaller PAGE_SIZE. Sync stubs.
https://github.com/upx/upx/issues/571
	modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/tmp/arm64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2022-03-25 09:13:10 -07:00
John Reiser 52f19ae330 Cleanup powerpc64le-linux.elf-*.S (forgotten when powerpc-linux.elf*.S)
https://github.com/upx/upx/issues/571
	modified:   stub/powerpc64-linux.elf-entry.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-entry.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/tmp/powerpc64-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2022-03-24 19:14:56 -07:00
John Reiser 275477f914 ElfLinker::addSection omits "ABS*" and "UND*" sections
modified:   linker.cpp
2022-03-24 19:09:09 -07:00
John Reiser 2ed6755d5d Sync stubs
https://github.com/upx/upx/issues/570
	modified:   .github/travis_testsuite_1-expected_sha256sums.sh
2022-03-22 19:27:27 -07:00
John Reiser 78c555b4a6 Handle old-style compressed main programs when de-compressing
modified:   p_lx_elf.cpp
2022-03-22 19:20:09 -07:00
John Reiser a127125707 Comment the breakpoint instructions for faster analysis by 'grep'
modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm.v5a-darwin.macho-fold.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
2022-03-22 19:18:19 -07:00
John Reiser f853f91c5b Placate clang re: missing 'override'
modified:   file.h
2022-03-22 19:16:15 -07:00
John Reiser e7ca5c54ff Fix --brute for p_lx_elf.cpp, which compresses multiple pieces
Force all pieces to use the same de-compressor.
(Future: allow each PT_LOAD to choose its own.)
Has minor wobbles due to page alignment, and size of de-compressor.
64-bit only for now.
https://github.com/upx/upx/issues/570
https://github.com/upx/upx/issues/297
	modified:   p_lx_elf.cpp
	modified:   p_unix.cpp
	modified:   packer.cpp
	modified:   packer.h
2022-03-22 11:46:25 -07:00
John Reiser 663d6b466b WIP: clarify compressWithFilters; reduce size of obuf for PackLinuxElf64
modified:   p_lx_elf.cpp
	modified:   packer.cpp
	modified:   packer.h
2022-03-21 13:49:46 -07:00
John Reiser 0e2a9de2b2 Empty commit to force re-build Action
https://github.com/upx/upx/issues/568
2022-03-14 15:51:09 -07:00
John Reiser 34df0d6ef1 More empty HASH and/or GNU_HASH when Rust-musl
https://github.com/upx/upx/issues/568
	modified:   p_lx_elf.cpp
2022-03-12 14:21:51 -08:00
John Reiser 540164849b whitespace
https://github.com/upx/upx/issues/446
	modified:   macho-snip.c
2022-03-01 16:05:37 -08:00
John Reiser 252143d0bb WIP: smallest executable on Apple M1 (aarch64 or arm64)
Requirements for success after snipping a loader_command:
    "codesign -s - my_app" must succeed.
    "lldb my_app; process launch -s; continue" must succeed.

Optional loader_commands (macho-snip can remove these successfully):
    LC_UUID, LC_BUILD_VERSION, LC_SOURCE_VERISON,
    LC_DATA_IN_CODE (when 0==datasize)

Apple "strip -N" clears out LC_SYMTAB and LC_DYSYMTAB, but leaves
LC_DYLD_INFO_ONLY.export_size.  Perhaps this could be zero if
constructed that way; snipping seems tedious because codesign
requires that __LINKEDIT must have no gaps.

LC_FUNCTION_STARTS seems to be required by codesign.
codesign wants offsets that point into __LINKEDIT to be in order:
    LC_DYLD_INFO_ONLY, LC_FUNCTION_STARTS, LC_DATA_IN_CODE, LC_SYMTAB

MacOS seesm to require LC_LOAD_DYLINKER (else "zsh: Kiled"),
which seems to require LD_LOAD_DYLIB (else SIGABRT).

https://github.com/upx/upx/issues/446
----
        modified:   macho-snip.c
	modified:   udf.s
2022-03-01 15:06:58 -08:00
John Reiser 480ab51650 Evade poratbility constraints of UPX build system
when building a tool to investigate "minimal" Mach-O executable
on Apple MacOS Big Sur using Apple M1 hardware (aarch64).
https://github.com/upx/upx/issues/567
	modified:   stub/tools/macho-snip/Makefile
	modified:   stub/tools/macho-snip/macho-snip.c
	modified:   stub/tools/macho-snip/udf.s
2022-03-01 11:12:19 -08:00
John Reiser 972c76eb42 Tool for snipping loader_commands in Mach-O on Apple M1 (aarch64) on BigSur.
experimental!
https://github.com/upx/upx/issues/424
	new file:   macho-snip/Makefile
	new file:   macho-snip/macho-snip.c
	new file:   macho-snip/udf.s
2022-02-28 19:53:25 -08:00
John Reiser e5aeea9ed2 Check more carefully in invert_pt_dynamic()
https://github.com/upx/upx/issues/566
	modified:   p_lx_elf.cpp
2022-02-28 07:55:49 -08:00
John Reiser f204670008 Mach unpack checks for bad load_command in compressed input
https://github.com/upx/upx/issues/564
	modified:   p_mach.cpp
2022-02-25 10:17:04 -08:00
John Reiser 651155c64d Check Mach_header.ncmds at unpack
https://github.com/upx/upx/issues/563
	modified:   p_mach.cpp
2022-02-25 09:32:29 -08:00
John Reiser 660aee6d22 More checking for unpack of tampered Elf_Phdr
https://github.com/upx/upx/issues/562
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
2022-02-25 09:23:55 -08:00
John Reiser a646231630 aligned_sotls, per Laszlo
https://github.com/upx/upx/issues/556
	modified:   pefile.cpp
2022-02-07 08:39:13 -08:00
John Reiser 1050de5171 Native alignment for the "load config" table
https://github.com/upx/upx/issues/556
	modified:   pefile.cpp
2022-01-15 06:45:47 -08:00
John Reiser b7a5b9437a Fix checking of sh_name versus shstrsec->sh_size
https://github.com/upx/upx/issues/509
	modified:   p_vmlinx.cpp
2022-01-01 14:20:18 -08:00
Kornel Pal 620955a724 PE: Fix has_oxrelocs (TLS always has oxrelocs) 2021-12-31 20:45:28 +01:00
John Reiser 2e64a277f8 Fix headway during optimizeReloc()
Later: "Assertion `(soxrelocs == 0) == !has_oxrelocs' failed."
https://github.com/upx/upx/issues/552
	modified:   packer.cpp
	modified:   packer.h
	modified:   pefile.cpp
2021-12-31 10:27:58 -08:00
John Reiser ea567a8b14 Check when optimizeRelocs()
https://github.com/upx/upx/issues/513
	modified:   packer.h
	modified:   packer.cpp
	modified:   pefile.cpp
	modified:   p_wcle.cpp
	modified:   p_tmt.cpp
2021-12-29 16:57:52 -08:00
John Reiser be23f93ee6 upx_uint8_t
https://github.com/upx/upx/issues/545
	modified:   p_mach.h
2021-12-27 08:49:05 -08:00
John Reiser fcdf0e92c1 Use upx_uint32_t, upx_uint64_t
Avoid complaints from x86_64-w64-mingw32-gcc (GCC) 9.3-win32 20200320
https://github.com/upx/upx/issues/545
	modified:   p_mach.h
2021-12-27 08:33:54 -08:00
John Reiser 2d6987252e is_bad_linker_command()
https://github.com/upx/upx/issues/545
	modified:   p_mach.cpp
2021-12-27 08:14:19 -08:00
John Reiser 4a9c46253e Validate input LC_ commands in order to defend against fuzzers
TODO: validate in ::unpack(), too
https://github.com/upx/upx/issues/545
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
2021-12-26 19:40:34 -08:00
John Reiser 5bcf9dd8af Do not complain for minimal DT_GNU_HASH as by Rust.
Also: .p_type is 32 bits only!

https://github.com/upx/upx/issues/525
	modified:   p_lx_elf.cpp
2021-12-25 12:39:31 -08:00
John Reiser 284adb203f Better checking of DT_HASH.nbuckets
https://github.com/upx/upx/issues/507
	modified:   p_lx_elf.cpp
2021-12-24 15:52:16 -08:00
John Reiser adafa841f7 Some PT_LOAD must have (p_flags & PF_X)
https://github.com/upx/upx/issues/511
	modified:   p_lx_elf.cpp
2021-12-24 15:32:19 -08:00
John Reiser fdc5d25d03 Require DT_STRSZ
https://github.com/upx/upx/issues/512
	modified:   p_lx_elf.cpp
2021-12-24 15:08:22 -08:00
John Reiser 294a7077de Announce support for EFI files (PE x86)
modified:   NEWS
2021-12-24 15:05:53 -08:00
Kornel Pal 990d0ec543 PE: Remove duplicate oxrelocs write 2021-12-22 05:07:54 +01:00
John Reiser bb90c4dff4 Sync PE stubs
modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
2021-12-24 07:34:06 -08:00
Kornel Pal 00e3d992e8 Sync stubs 2021-12-22 03:05:53 +01:00
Kornel Pal 937bfa4e49 PE: Add support for EFI images 2021-12-22 03:05:24 +01:00
Kornel Pal 1d9c211eed PE: Make imports in decompressor stub optional 2021-12-22 03:00:17 +01:00
Kornel Pal 76ddf6b8da PE: Add position independent decompressor stub for i386 2021-12-22 02:58:09 +01:00
Kornel Pal 7f1f29b0d8 PE: Remove empty non-compressed section 2021-12-22 02:57:10 +01:00
Kornel Pal 222471744f PE: Remove file alignment restriction 2021-12-22 02:56:09 +01:00
Kornel Pal cc100be26e PE: Fix stripped relocation handling 2021-12-22 02:55:33 +01:00
Kornel Pal 966b571b7c PE: Use no red zone on AMD64 2021-12-16 06:59:26 +01:00
Kornel Pal f3e710394a PE: Set header size on 64-bit too 2021-12-16 06:57:39 +01:00
Kornel Pal bfd1f1fbfa PE: Fix relocation parsing and validation 2021-12-16 06:56:01 +01:00
Efreak a09146b5e0 unreferenced variable breaks build 2021-12-02 14:00:40 -08:00
John Reiser bbf2b08f48 Update testsuite with new signatures for i386-linux.elf
https://github.com/upx/upx/issues/540
	modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
2021-12-03 08:53:08 -08:00
John Reiser e2dbc661f1 Sync stub
modified:   stub/i386-linux.elf-entry.h
2021-12-03 08:38:26 -08:00
John Reiser 7626e09f66 Fix jl ==> jb (unsigned compare)
modified:   stub/src/i386-linux.elf-entry.S
2021-12-03 08:27:23 -08:00
Kirill A. Korinsky 248a6980cf Revert -std=c++14
This commit reverts 648fa30f22 which was removed by d60c46371d which is fixed https://github.com/upx/upx/issues/440
2021-11-27 13:22:54 +01:00
John Reiser f956bfc797 Allow slack for non-GLIBC tool chains versus -Wzero-as-null-pointer-constant
https://github.com/upx/upx/pull/531
	modified:   conf.h
2021-11-27 06:58:38 -08:00
bitraid 6da79783ea PE: Handle empty imports 2021-05-15 21:41:31 +03:00
a1346054 22329e0ab2 trim excess whitespace 2021-08-22 11:23:41 +00:00
a1346054 a94b0329c9 update codestyle in travis scripts to conform to guidelines
* adds and fixes indentation in a few places
* removes redundant quotes
* adds quotes around some arguments to silence shellcheck warnings
* fixes spelling
2021-08-22 11:21:28 +00:00
a1346054 be8601f8cc use grep -E instead of egrep
egrep will go away at some point, and grep -E is standardized
2021-08-22 11:19:38 +00:00
John Reiser bd441e83ae WIP: de-compression of old-style shlib
modified:   p_lx_elf.cpp
2021-09-06 08:43:20 -07:00
John Reiser 02bd9cc403 IMAGE_SUBSYSTEM_EFI_APPLICATION
Beginning of support for compressing EFI files; lacks run-time decompressor.
https://github.com/upx/upx/issues/518
	modified:   p_armpe.cpp
	modified:   p_w32pe.cpp
	modified:   p_w64pep.cpp
	modified:   pefile.cpp
	modified:   pefile.h
2021-09-06 08:38:51 -07:00
John Reiser c9f6a3583c WIP 64-bit shlib
modified:   p_lx_elf.cpp
2021-08-07 06:45:01 -07:00
John Reiser 076aaf829a WIP: Elf64 shlib compress+decompress seems to work
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2021-07-05 13:47:19 -07:00
John Reiser 85f0c5a445 WIP: Elf64 shlib cleanup
modified:   file.cpp
	modified:   file.h
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-07-02 18:33:38 -07:00
John Reiser d5263a56ce WIP: handling shared library
modified:   p_lx_elf.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
2021-05-22 16:03:53 -07:00
John Reiser ef5b55b4d1 sync stubs
https://github.com/upx/upx/issues/441
	modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
2021-05-16 10:14:03 -07:00
Markus F.X.J. Oberhumer d65e65b2b1 Update CI. 2021-05-15 07:24:16 +02:00
Markus F.X.J. Oberhumer 6aa641e5aa Update submodules. 2021-05-15 06:03:48 +02:00
John Reiser 504839951a arm64 clear_cache at end of de-compress
https://github.com/upx/upx/issues/441
	modified:   stub/src/arch/arm64/v8/macros.S

	modified:   stub/src/arch/arm64/v8/lzma_d.S
	modified:   stub/src/arch/arm64/v8/nrv2b_d32.S
	modified:   stub/src/arch/arm64/v8/nrv2d_d32.S
	modified:   stub/src/arch/arm64/v8/nrv2e_d32.S

	modified:   stub/arm64-darwin.macho-entry.h
	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/arm64-linux.shlib-init.h
	modified:   stub/tmp/arm64-darwin.macho-entry.bin.dump
	modified:   stub/tmp/arm64-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm64-linux.shlib-init.bin.dump
2021-05-16 09:53:03 -07:00
bitraid d55746f62d PE: disable CFG and compress with --force 2021-05-01 18:05:27 +03:00
bitraid 144010295e Improve --strip-relocs
- Remove .reloc section
- Enable for 64-bit images
- Abort if explicitly set on unsupported image
- Use with --force to remove ASLR / apply when imagebase < default
2021-04-25 20:15:07 +03:00
John Reiser 181c752488 WIP: un_shlib_1
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-05-08 11:14:31 -07:00
John Reiser bd4aca5c12 generated stub files
https://github.com/upx/upx/issues/473
	modified:   stub/mips.r3000-linux.shlib-init.h
	modified:   stub/mipsel.r3000-linux.shlib-init.h
	modified:   stub/tmp/mips.r3000-linux.shlib-init.bin.dump
	modified:   stub/tmp/mipsel.r3000-linux.shlib-init.bin.dump
2021-05-07 11:15:41 -07:00
John Reiser ad6d73c875 /proc/self/auxv for AT_PAGESZ because musl calls _init with no args
https://github.com/upx/upx/issues/473
	modified:   mipsel.r3000-linux.shlib-init.S
2021-05-07 09:36:07 -07:00
bitraid c5cc83d424 Fix unoptimizeReloc() to process all relocs 2021-04-21 23:06:55 +03:00
bitraid fe949bdf67 Build: Enable wildcard argument expansion for msvc 2021-04-12 11:20:13 +03:00
John Reiser 766fe466d6 PAGE_SIZE varies: Apple M1 uses 16K
modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
2021-04-11 15:19:24 -07:00
John Reiser 333a288248 shlib: Don't compress below xct_off (except Elf headers)
modified:   p_lx_elf.cpp
2021-04-11 15:16:34 -07:00
John Reiser 613df414ed Fix off-by-1 in invert_pt_dynamic; SHT_NOBITS occupies no space
modified:   p_lx_elf.cpp
2021-04-11 15:09:55 -07:00
John Reiser be050693f2 PackLinuxElf::canUnpack must checkEhdr() for ELF input
https://github.com/upx/upx/issues/485
	modified:   p_lx_elf.cpp
2021-04-10 10:11:48 -07:00
goushibee bf957f435e fix issue 486 2021-04-07 15:40:13 +08:00
John Reiser 3a6f688265 Sync testsuite checksums for PE: fix SizeOfHeaders
https://github.com/upx/upx/pull/483
	modified:   .github/travis_testsuite_1-expected_sha256sums.sh
2021-04-10 08:51:27 -07:00
Sebastien Rosset (serosset) 1084a7896c Add default goal 2021-04-03 13:08:01 -07:00
bitraid 9ea2b31541 PE: fix SectionHeadersSize of SizeOfHeaders value 2021-04-06 22:49:31 +03:00
Sebastien Rosset (serosset) 09da986742 build instructions 2021-04-03 11:57:05 -07:00
John Reiser cb70a5fef5 Enable usual grep for function definition
Developer convenience: no space between function name and left paren
	modified:   compress.cpp
2021-04-03 12:46:20 -07:00
John Reiser 4fa6a6aeef Sync testsuite checksums for PE: fix SizeOfHeaders
https://github.com/upx/upx/pull/477
	modified:   .github/travis_testsuite_1-expected_sha256sums.sh
2021-04-02 19:37:29 -07:00
Markus F.X.J. Oberhumer ab31e8dde9 testsuite: change exit code to 98 for FATAL decompression checksum mismatchs. 2021-03-28 22:06:42 +02:00
Markus F.X.J. Oberhumer 53d7b5449f testsuite: change exit code to 99 for checksum mismatchs. 2021-03-28 21:49:32 +02:00
Markus F.X.J. Oberhumer d33a34f016 Revert some changes from previous commit to pacify clang
-Winconsistent-missing-override warnings.
2021-03-28 21:40:13 +02:00
Markus F.X.J. Oberhumer f6ff5a2805 Cleanups: start working on -Wsuggest-override, add some "final". NFCI. 2021-03-28 21:19:29 +02:00
bitraid 1518e5bc98 PE: fix SizeOfHeaders value of Optional Header field 2021-03-25 21:41:49 +02:00
John Reiser 78f48d65d5 Allow 0==nbucket for DT_HASH, DT_GNU_HASH
static linked 'Rust' program with no symbols
https://github.com/upx/upx/issues/476
2021-03-25 07:22:01 -07:00
John Reiser b81ec224b7 Fix headway argument to invert_pt_dynamic()
https://github.com/upx/upx/issues/473
	modified:   p_lx_elf.cpp
2021-03-25 07:10:40 -07:00
John Reiser 4be6cfebcd get_te32() when checking DT_GNU_HASH chains (MIPS .so)
https://github.com/upx/upx/issues/473
        modified:   p_lx_elf.cpp
2021-03-23 18:21:45 -07:00
John Reiser 98973dd8b9 get_te32() when checking DT_HASH chains (MIPS .so)
https://github.com/upx/upx/issues/473
	modified:   p_lx_elf.cpp
2021-03-23 06:45:01 -07:00
John Reiser 1218b6ff2a Check more in invert_pt_dynamic
https://github.com/upx/upx/issues/471
	modified:   p_lx_elf.cpp
2021-03-16 18:46:11 -07:00
John Reiser ba5c77c9e5 Reject if MZ and PE headers overlap
Overlap ('leanify', etc.) causes headaches.
https://github.com/upx/upx/issues/231
	modified:   p_w32pe.cpp
	modified:   p_w64pep.cpp
	modified:   pefile.cpp
2021-03-14 15:20:15 -07:00
jsm174 cbaedffce2 ci: make artifacts for all builds 2021-03-09 09:36:08 -05:00
John Reiser cb60603950 Turn off BUILD_TYPE_DEBUG to enable CI build amd64-win64-gcc-9 to pass.
modified:   Makefile
2021-03-07 09:33:16 -08:00
John Reiser 0a69e7803b Fix errors detected by "make run-testsuite".
total_out does not matter when option -t writes no output file.
Subtle error in generateElfHdr() [noted by address sanitizer].
New member function is_LOAD32() to avoid confusion with (1+ LO_PROC).
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-03-06 15:31:56 -08:00
John Reiser baa9090198 Change back to lzma-sdk d5bed9963d051c9e5690b12199eab6884a592c43
modified:   lzma-sdk
2021-03-06 12:05:23 -08:00
John Reiser e78a08b8fc change lzma-sdk to latest commit 44db23cc6d6b607986dace07b17fece1af925558 on its master 2021-03-06 10:46:40 -08:00
John Reiser 7e5e6012df PackMachFat::canPack handles case PackMachFat::CPU_TYPE_ARM64
modified:   p_mach.cpp
2021-03-06 09:59:51 -08:00
John Reiser 0a1d24d1d9 Remove nit from PackLinuxElf64::generateElfHdr [address sanitizer]
modified:   p_lx_elf.cpp
2021-03-05 16:33:25 -08:00
John Reiser 35555bfb8a WIP: PackLinuxElf64::unpack working for shared libraries (non-Android)
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_unix.cpp
2021-03-05 16:20:36 -08:00
John Reiser c9cb42df40 WIP: hacking un_shlib_1
modified:   p_lx_elf.cpp
2021-02-28 17:12:20 -08:00
John Reiser 2be03028f4 WIP: un_shlib_1
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2021-02-27 19:27:12 -08:00
John Reiser 214dd0a522 4 fewer bytes of code?
modified:   arm64-linux.elf-fold.h
	modified:   tmp/arm64-linux.elf-fold.map
2021-02-23 02:24:24 -08:00
John Reiser 182e0796df Split PackLinuxElf64::unpack for main program vs shared library
modified:   p_lx_elf.cpp
2021-02-22 16:15:03 -08:00
John Reiser fb844a8ed1 total_in, total_out move to PackUnix
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_lx_interp.cpp
	modified:   p_mach.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
2021-02-22 16:13:40 -08:00
John Reiser 6be3e747ca Remove unrelated debugging
modified:   stub/src/arm64-linux.elf-fold.S
2021-02-15 11:40:04 -08:00
John Reiser 23f63e4196 WIP unpacking ELF shared library
modified:   Makefile
	modified:   lzma-sdk
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_mach.cpp
	modified:   p_unix.cpp
	modified:   p_unix.h
	modified:   packer.cpp
	modified:   packer.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/tmp/arm64-linux.elf-fold.map
2021-01-15 14:11:09 -08:00
John Reiser fd6837b267 Another checkAlreadyPacked()
https://github.com/upx/upx/issues/463
	modified:   Makefile
	modified:   p_mach.cpp
2021-02-26 15:15:28 -08:00
John Reiser 1c29f921e0 getSizeForCompression worst cases
https://github.com/upx/upx/issues/463
	modified:   Makefile
	modified:   mem.cpp
2021-02-25 20:04:16 -08:00
John Reiser 1ab6e01de2 MacOS BigSur wants no MH_DYLDLINK for our MH_EXECUTE
https://github.com/upx/upx/issues/434
	modified:   p_mach.cpp
2021-02-14 13:23:19 -08:00
Markus F.X.J. Oberhumer 801618740c CI: fix current Ubuntu problem. 2021-02-01 13:06:49 +01:00
John Reiser 2469563b26 Mach_ARM64_thread_state padded to (0 mod 8)
https://github.com/upx/upx/issues/446  (partial)
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
2021-01-30 16:11:32 -08:00
John Reiser 00139caf43 More robust PackWcle::decodeFixups()
https://github.com/upx/upx/issues/455
	modified:   p_wcle.cpp
2021-01-23 15:37:52 -08:00
John Reiser 21d102c84f Better checking of Mach_header.ncmds, .sizeofcmds
Improves earlier fix.
https://github.com/upx/upx/issues/447
	modified:   p_mach.cpp
2021-01-23 13:52:54 -08:00
John Reiser f17d9967c2 Clarify comment in previous commit
modified:   main.cpp
2021-01-20 05:54:53 -08:00
Liam Murphy 0569ef37ba add comment explaining code as per PR review 2021-01-20 02:29:08 +00:00
Liam Murphy 984334c9a1 reset done_output_name counter upx_main() 2021-01-18 00:16:49 +00:00
John Reiser 34a25e61c7 "%zx" for ptrdiff_t in hex printf
modified:   p_wcle.cpp
2021-01-17 19:36:36 -08:00
John Reiser ed3f45953e Try not to run off the end of selfrel_fixups.
https://github.com/upx/upx/issues/455
	modified:   p_wcle.cpp
	modified:   packer.cpp
2021-01-17 19:21:32 -08:00
John Reiser 80de11bc5b Detect Mach_header.sizeofcmds==0
https://github.com/upx/upx/issues/448
	modified:   p_mach.cpp
2021-01-17 17:09:35 -08:00
Darío Hereñú c9fe84c9aa Typo fixed (line 61) 2021-01-09 14:04:47 -03:00
John Reiser 5f98bb0ab0 De-compress allows old-style LC_UNIXTHREAD with one LC_SEGMENT
https://github.com/upx/upx/issues/447
	modified:   p_mach.cpp
2021-01-15 15:03:26 -08:00
Markus F.X.J. Oberhumer d86d5314ba Modernize libc usage: more cleanups. 2021-01-05 22:03:29 +01:00
Markus F.X.J. Oberhumer 700c8730cf Modernize libc usage: stop using off_t, use modern printf.
C++ 14 is here, and old versions of MSVC and MSVCRT have
haunted us long enough.
2021-01-05 18:52:05 +01:00
Markus F.X.J. Oberhumer b4429e1a42 CI: add sanitizer builds. 2021-01-04 22:03:23 +01:00
Markus F.X.J. Oberhumer a8fa3ca5cf Use correct native types with "alignas(1)". 2021-01-04 21:13:49 +01:00
Markus F.X.J. Oberhumer 9aef7b0d6f Use C++ 14 alignas(), init some struct fields just because of good practice. 2021-01-04 21:02:07 +01:00
Markus F.X.J. Oberhumer 2575eef3c0 clang-format more files.
"Gofmt's style is nobody's favourite, but gofmt is everybody's favourite."
    - Rob Pike
2021-01-04 20:26:31 +01:00
Markus F.X.J. Oberhumer 8236276a90 Add and use .clang-format file. 2021-01-04 19:07:17 +01:00
Markus F.X.J. Oberhumer fdc68812c5 clang-format-10.0.1 files. 2021-01-04 17:27:48 +01:00
Markus F.X.J. Oberhumer 9db6d18d11 Now using upx-stubtools 20210104 with new clang-format-10.0.1. 2021-01-04 17:23:57 +01:00
Markus F.X.J. Oberhumer f962afe146 Various cosmetic updates and refactors. NFCI. 2021-01-04 17:20:57 +01:00
Markus F.X.J. Oberhumer adcd569852 Makefile: update default sanitizer flags. 2021-01-04 17:20:06 +01:00
Markus F.X.J. Oberhumer d045b7f223 Update bele.h to better work with modern compilers. 2021-01-02 16:45:58 +01:00
Markus F.X.J. Oberhumer 57cb6a7530 CI: add mingw64 build. 2021-01-02 01:03:24 +01:00
Markus F.X.J. Oberhumer baa1ed9be3 Update CI to use lastest zlib. Update Makefile. 2021-01-01 23:24:31 +01:00
Markus F.X.J. Oberhumer 16af6e1a29 Update testsuite checksums caused by version bump. 2021-01-01 20:52:07 +01:00
Markus F.X.J. Oberhumer 0af8998be6 Bump version date. 2021-01-01 20:45:11 +01:00
Markus F.X.J. Oberhumer c32f517fa5 Remove obsolete PROJECTS file. 2021-01-01 20:43:34 +01:00
Markus F.X.J. Oberhumer 9131d5216f Welcome 2021. 2021-01-01 20:39:22 +01:00
Markus F.X.J. Oberhumer fb14a7991d Fix Makefile breakage in previous commit. 2020-12-15 02:15:34 +01:00
Markus F.X.J. Oberhumer ff53862dab Extract upx_main() for compilation with -DWITH_GUI. 2020-12-14 22:10:07 +01:00
Markus F.X.J. Oberhumer 49245a20c5 Update Makefile and compiler checks so that users don't inadvertently
change mandatory compiler flags.
2020-12-14 20:53:54 +01:00
John Reiser 13bc031163 Check DT_REL/DT_RELA, DT_RELSZ/DT_RELASZ
https://github.com/upx/upx/issues/421
	modified:   p_lx_elf.cpp
2020-12-11 13:38:18 -08:00
John Reiser 0c18c1c35c Include --lzma as a compression tuning option in --help.
modified:   help.cpp
2020-12-11 12:34:38 -08:00
John Reiser 63dc19ce25 -std=c++14
modified:   Makefile
2020-12-11 11:38:38 -08:00
John Reiser 6871c2fc0a Tweak unoptimizeReloc again
modified:   packer.cpp
2020-12-10 19:56:02 -08:00
Markus F.X.J. Oberhumer 4ae3a8b2b0 Revert useless "fast exit" check from b2c00aa637. 2020-12-08 07:13:11 +01:00
Markus F.X.J. Oberhumer f2e562b5de Update CI. 2020-12-08 06:22:10 +01:00
Markus F.X.J. Oberhumer f7e2266c3f Start using some C++ 14 features. 2020-12-08 05:40:17 +01:00
Markus F.X.J. Oberhumer 361a3056cb Update submodules. 2020-12-08 05:40:07 +01:00
Markus F.X.J. Oberhumer ca0437556d Start using "noexcept". 2020-12-08 00:45:41 +01:00
Markus F.X.J. Oberhumer 51899957a9 Require C++ 14. Finally!
This is the default for gcc >= 6, clang >= 6 and MSVC >= 2019.
2020-12-07 23:05:13 +01:00
Markus F.X.J. Oberhumer 7b0b760d78 src/Makefile: add -Wsign-compare to warning flags to better match MSVC. 2020-12-07 23:04:37 +01:00
Markus F.X.J. Oberhumer 4f5866b5a7 Remove AppVeyor CI. 2020-12-07 23:04:01 +01:00
John Reiser a6b5033cf1 Fix overlap detection for PE unoptimizeReloc()
https://github.com/upx/upx/issues/438
	modified:   packer.cpp
2020-12-10 19:31:56 -08:00
John Reiser a6296ecd67 Avoid complaint from "gcc -Wsign-conversion"
modified:   compress_lzma.cpp
	modified:   compress_zlib.cpp
2020-12-06 15:22:58 -08:00
John Reiser bb1df15958 Use 'mb_' prefix on instances of MemBuffer
modified:   pefile.cpp
	modified:   pefile.h
2020-12-05 13:53:14 -08:00
Liam Murphy 249431f45f tweak formatting to reduce diff 2020-11-26 03:00:21 +00:00
Liam Murphy cbe129795e migrate to MemBuffer class from New() to remove leak 2020-11-26 00:14:00 +00:00
John Reiser 2a135e245b Prefer MemBuffer instead of New()+delete
https://github.com/upx/upx/issues/428
	modified:   pefile.cpp
	modified:   pefile.h
2020-12-05 13:44:19 -08:00
Markus F.X.J. Oberhumer 05a0b3557a Update CI. 2020-12-05 14:04:46 +01:00
Markus F.X.J. Oberhumer c7cfe8b608 Remove Travis CI. 2020-12-05 06:29:57 +01:00
Markus F.X.J. Oberhumer 8d3e1d28a7 Update GitHub CI. 2020-12-05 04:37:30 +01:00
John Reiser 7841e15583 Prefer MemBuffer instead of New()+delete
https://github.com/upx/upx/issues/428
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2020-12-05 10:31:55 -08:00
Markus F.X.J. Oberhumer dd164fbc86 Undo Makefile change in 9b0f523d00. 2020-12-03 18:16:11 +01:00
Markus F.X.J. Oberhumer 23fe02e84a Add GitHub Actions CI. 2020-12-03 13:58:38 +01:00
Markus F.X.J. Oberhumer 94e72238f2 Fix some warnings. 2020-12-03 03:10:12 +01:00
Markus F.X.J. Oberhumer 8f7ac520eb Run clang-format. 2020-12-03 02:15:14 +01:00
Markus F.X.J. Oberhumer bd193201b2 Avoid a clang-11 warning. 2020-12-03 02:14:47 +01:00
Markus F.X.J. Oberhumer 8ced672d24 docs: add a note about security considerations. 2020-12-03 02:10:05 +01:00
Markus F.X.J. Oberhumer f218812858 Fix spelling of some constants. 2020-12-03 01:46:30 +01:00
Markus F.X.J. Oberhumer 8a7b980fc0 Avoid a MSVC warning. 2020-12-03 01:44:09 +01:00
Markus F.X.J. Oberhumer 385c9877f8 Update submodules. 2020-12-03 01:27:05 +01:00
John Reiser 10df93536e Yet another attempt to suppress MSVC C4245
https://github.com/upx/upx/issues/435
	modified:   pefile.cpp
2020-11-29 00:01:22 -08:00
John Reiser 6cad27896f Another attempt to suppress MSVC C4245
https://github.com/upx/upx/issues/435
	modified:   pefile.cpp
2020-11-28 23:53:49 -08:00
John Reiser 052392d97b Attempt workaround for MSVC C4245 signed/unsigned mismatch in template 'argument'
https://github.com/upx/upx/issues/435
	modified:   pefile.cpp
2020-11-28 20:23:01 -08:00
John Reiser ce6b5a0688 Fix MSVC warning C4245: signed/unsigned mismatch in prototype matching
The type of the return value must match exactly the function prototype.
MSVC warning C4245: 'argument': conversion from 'int' to 'unsigned int', signed/unsigned mismatch
https://github.com/upx/upx/issues/435
	modified:   bele_policy.h
2020-11-28 19:45:54 -08:00
John Reiser 1879185e42 Check Mach_command.cmdsize
https://github.com/upx/upx/issues/426
Also use MemBuffer to avoid leaks that result from throw()
	modified:   p_mach.cpp
	modified:   p_mach.h
2020-11-28 10:56:28 -08:00
John Reiser a928a08f9d ptrTEXT in PackMachBase<T>::canUnpack()
https://github.com/upx/upx/issues/417
	modified:   p_mach.cpp
2020-11-06 19:14:18 -08:00
John Reiser 1805cb6857 headway vs size
https://github.com/upx/upx/issues/414
	modified:   packhead.cpp
2020-11-06 14:25:36 -08:00
Liam Murphy 6ce625b535 fix build 2020-11-05 22:21:19 +00:00
Liam Murphy 4702f12818 tweaks: some extra checks on lengths 2020-11-05 04:43:40 +00:00
Matthijs Lavrijsen 4f3054f07d PE: only add a TLS relocation if tls_handler_offset_reloc != 0 2020-09-08 11:44:56 +02:00
bitraid 0d7bd52e21 Only pack w/ -f PE files that force integrity check 2020-10-31 19:53:33 +02:00
John Reiser c3466f579c fillPackHeader: revise and add yet more checks
https://github.com/upx/upx/issues/414
https://github.com/upx/upx/pull/415  revised
	modified:   packhead.cpp
2020-11-06 13:53:29 -08:00
John Reiser 7c105d7af5 omemmove exactly as much
Fix 14992260c60b8d6677a677a9cdfae98b11353df7; revealed by testsuite
	modified:   pefile.cpp
2020-11-05 15:05:52 -08:00
John Reiser 924b229afb fillPackHeader more checks
https://github.com/upx/upx/issues/414
	modified:   packhead.cpp
2020-11-03 01:58:39 -08:00
John Reiser 890d66ecf0 Avoid overlap when rebuild relocs.
Based on a hint from a little bird.
	modified:   packer.cpp
2020-09-20 15:08:39 -07:00
John Reiser 143049922b Beware overlap when rebuildImports
Based on a hint from a little bird.
	modified:   pefile.cpp
2020-09-20 14:10:24 -07:00
John Reiser e6ccef2cf1 MSVC strikes again
modified:   p_lx_elf.cpp
2020-09-05 19:19:11 -07:00
John Reiser be61e9f584 Fix 64-bit ET_EXEC
https://github.com/upx/upx/issues/405
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c

	modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
	modified:   stub/tmp/arm64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2020-09-04 10:21:14 -07:00
Mattiwatti 89d0fda9fa Make PE load config directory address dword aligned 2020-01-21 16:03:40 +01:00
bitraid 6a85bab5da Don't pack Cotrol Flow Guard PE files 2020-07-28 17:36:13 +03:00
John Reiser c1a55b063e 0==e_shnum obviates testing of e_shoff
modified:   p_lx_elf.cpp
2020-07-26 20:00:05 -07:00
John Reiser 77c914bce5 Check de-compressed SHT_SYMTAB
https://github.com/upx/upx/issues/396
	modified:   p_lx_elf.cpp
2020-07-25 09:28:02 -07:00
John Reiser cc60f03b2e Check Shdr more
https://github.com/upx/upx/issues/395
	modified:   p_lx_elf.cpp
2020-07-25 08:19:45 -07:00
John Reiser cc9ccdbbd1 Check .sh_offset and .sh_size in SHT_DYNAMIC and SHT_STRNDX
https://github.com/upx/upx/issues/394
	modified:   p_lx_elf.cpp
2020-07-25 07:41:43 -07:00
John Reiser 9dfc8f573c Avoid 0==nbucket
https://github.com/upx/upx/issues/393
	modified:   p_lx_elf.cpp
2020-07-23 05:44:18 -07:00
John Reiser 4e2fdb464a Defend against bad PT_DYNAMIC
https://github.com/upx/upx/issues/391
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2020-07-23 05:09:52 -07:00
John Reiser 73b854874e Defend against junk PT_DYNAMIC
https://github.com/upx/upx/issues/390
	modified:   p_lx_elf.cpp
2020-07-23 04:14:34 -07:00
John Reiser 0016512df1 Unpack: Phdrs must be within expansion of first compressed block
https://github.com/upx/upx/issues/388
	modified:   p_lx_elf.cpp
2020-07-22 19:34:27 -07:00
John Reiser 527139978a DT_HASH chains might be trimmed (64-bit, too)
https://github.com/upx/upx/issues/383
	modified:   p_lx_elf.cpp
2020-06-08 12:37:53 -07:00
John Reiser 47bc68fa6b DT_HASH chains might be trimmed
https://github.com/upx/upx/issues/383
	modified:   p_lx_elf.cpp
2020-06-07 19:35:49 -07:00
John Reiser 972b670a64 Set .b_extra for hdr, especially for Mach-o for 'go'.
https://github.com/upx/upx/issues/222
	modified:   p_unix.cpp
2020-06-06 17:11:32 -07:00
John Reiser d7c416f243 More DPRINTF debugging
modified:   stub/src/amd64-darwin.macho-main.c
2020-06-06 17:10:53 -07:00
John Reiser 3ace7a0468 Documentation only
modified:   stub/src/amd64-darwin.macho-main.c
2020-06-06 15:32:45 -07:00
John Reiser d305023f5e Sync testsuite checksums for "ELF pageholes" feature
modified:   .github/travis_testsuite_1-expected_sha256sums.sh
2020-05-30 13:56:12 -07:00
John Reiser 963392a5ae De-compress (upx -d) for ELF pageholes
modified:   p_lx_elf.cpp
2020-05-30 13:54:11 -07:00
John Reiser 2f453acf5d use UPX_RSIZE_MAX_MEM
modified:   p_mach.cpp
2020-05-28 15:45:07 -07:00
John Reiser 4ae1576726 Mach-o LC_SEGMENTs not monotonic in file (__DWARF for 'go')
https://github.com/upx/upx/issues/222  go-1.14 (but not go-1.14.3 ?)
	modified:   ../p_mach.cpp
	modified:   ../p_mach.h
	modified:   ../p_unix.cpp
	modified:   ../p_unix.h
	modified:   ../stub/src/amd64-darwin.macho-main.c

	modified:   ../stub/amd64-darwin.macho-fold.h
	modified:   ../stub/arm.v5a-darwin.macho-fold.h
	modified:   ../stub/arm64-darwin.macho-fold.h
	modified:   ../stub/tmp/amd64-darwin.macho-fold.map
	modified:   ../stub/tmp/arm.v5a-darwin.macho-fold.map
	modified:   ../stub/tmp/arm64-darwin.macho-fold.map
2020-05-30 02:54:09 -07:00
bitraid 17bd0b3248 Don't use --strip-reloc with -d
Always restore the relocation section of Portable Executables on
unpacking, if it exists in the compressed image.
2020-04-13 21:38:22 +03:00
Markus F.X.J. Oberhumer a1ad1aee99 Use "python2" instead of "python". 2020-05-23 20:07:23 +02:00
John Reiser a817ed0692 uintptr_t for MSVC
modified:   p_lx_elf.cpp
2020-05-23 11:02:46 -07:00
John Reiser 828a6cf07b invert_pt_dynamic() more checking
https://github.com/upx/upx/issues/378
https://github.com/upx/upx/issues/379
	modified:   p_lx_elf.cpp
2020-05-23 10:51:03 -07:00
John Reiser 962c35aa08 More checking of DT_GNU_HASH and DT_HASH tables
https://github.com/upx/upx/issues/381
	modified:   p_lx_elf.cpp
2020-05-23 10:04:38 -07:00
John Reiser b327645e64 More checking of DT_GNU_HASH and DT_HASH tables
https://github.com/upx/upx/issues/380
	modified:   p_lx_elf.cpp
2020-05-23 09:41:41 -07:00
John Reiser e1b42616a2 workaround: MIPS.r3000 early uClibc forgot memset(,0,) of local array
ldso/ldso/ldso.c: _dl_get_ready_to_run()
    _dl_memset(app_tpnt, 0, sizeof(*app_tpnt));
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S

	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
2020-05-26 14:49:25 -07:00
John Reiser f96638c42a MIPS32 works: ELF layout for page holes
modified:   stub/src/include/linux.h
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S

	modified:   stub/mips.r3000-linux.elf-entry.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-entry.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/tmp/mips.r3000-linux.elf-entry.bin.dump
	modified:   stub/tmp/mips.r3000-linux.elf-fold.map
	modified:   stub/tmp/mipsel.r3000-linux.elf-entry.bin.dump
	modified:   stub/tmp/mipsel.r3000-linux.elf-fold.map
2020-05-25 14:13:01 -07:00
John Reiser 6272152dfe phdr[C_BASE].p_memsz for ET_EXEC
modified:   p_lx_elf.cpp
2020-05-25 14:11:46 -07:00
John Reiser 030a200c08 clarity; no functional change
modified:   stub/src/powerpc-linux.elf-entry.S
2020-05-25 14:07:58 -07:00
John Reiser 994da63b4d DPRINTF the munmap
modified:   stub/src/i386-linux.elf-main.c
2020-05-25 14:05:58 -07:00
John Reiser 2315bff280 powerpc64 works: ELF layout for page holes
modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S

	modified:   stub/powerpc64-linux.elf-entry.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-entry.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/tmp/powerpc64-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2020-05-23 11:18:32 -07:00
John Reiser 98dddf93d8 powerpc32 works: ELF layout for page holes
modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S

	modified:   stub/powerpc-linux.elf-entry.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/tmp/powerpc-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc-linux.elf-fold.map
2020-05-23 08:00:35 -07:00
John Reiser fd2939e18d i386 works: ELF layout for page holes
modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main.c

	modified:   stub/arm.v4a-linux.elf-fold.h
	modified:   stub/arm.v5a-linux.elf-fold.h
	modified:   stub/armeb.v4a-linux.elf-fold.h
	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/src/include/linux.h
	modified:   stub/tmp/arm.v4a-linux.elf-fold.map
	modified:   stub/tmp/arm.v5a-linux.elf-fold.map
	modified:   stub/tmp/armeb.v4a-linux.elf-fold.map
	modified:   stub/tmp/i386-linux.elf-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf-fold.map
	modified:   stub/tmp/mips.r3000-linux.elf-fold.map
	modified:   stub/tmp/mipsel.r3000-linux.elf-fold.map
	modified:   stub/tmp/powerpc-linux.elf-fold.map
2020-05-15 16:05:26 -07:00
John Reiser 80c27e0822 arm.v4a works: ELF layout for page holes
modified:   p_lx_elf.cpp
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S

	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v4a-linux.elf-fold.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-fold.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-fold.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/tmp/arm.v4a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v4a-linux.elf-fold.map
	modified:   stub/tmp/arm.v5a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v5a-linux.elf-fold.map
	modified:   stub/tmp/armeb.v4a-linux.elf-entry.bin.dump
	modified:   stub/tmp/armeb.v4a-linux.elf-fold.map
	modified:   stub/tmp/i386-linux.elf-fold.map
	modified:   stub/tmp/mips.r3000-linux.elf-fold.map
	modified:   stub/tmp/mipsel.r3000-linux.elf-fold.map
	modified:   stub/tmp/powerpc-linux.elf-fold.map
2020-05-14 15:10:40 -07:00
John Reiser b463f24eda arm64 works: ELF layout for page holes
modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S

	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/tmp/arm64-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm64-linux.elf-fold.map
2020-05-10 09:18:06 -07:00
John Reiser 2a849444db un-debug
modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
2020-05-09 09:46:51 -07:00
John Reiser 69e106c0c5 unmap C_TEXT
modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
2020-05-09 09:45:02 -07:00
John Reiser 926481dace ELF layout for page holes when runtime PAGE_SIZE < .p_align
amd64 works
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   Makefile
	modified:   stub/amd64-linux.elf-entry.h
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/amd64-linux.shlib-init.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/src/amd64-linux.shlib-init.S
	modified:   stub/tmp/amd64-linux.elf-entry.bin.dump
	modified:   stub/tmp/amd64-linux.elf-fold.map
	modified:   stub/tmp/amd64-linux.shlib-init.bin.dump
	modified:   stub/tmp/arm64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2020-05-09 08:05:05 -07:00
John Reiser a3b2cde58d max_bucket versus symbias
modified:   p_lx_elf.cpp
2020-04-17 17:09:47 -07:00
John Reiser 30f37d2cc6 DT_GNU_HASH check the buckets
https://github.com/upx/upx/issues/365
	modified:   p_lx_elf.cpp
2020-04-17 16:49:54 -07:00
John Reiser c4d61dd9fe --preserve-build-id for ET_EXEC
https://github.com/upx/upx/issues/371
	modified:   p_lx_elf.cpp
2020-04-17 16:17:29 -07:00
John Reiser 210870f840 invert_pt_dynamic() DT_GNU_HASH trims hash array for Rust and Android
https://github.com/upx/upx/issues/369
	modified:   p_lx_elf.cpp
2020-04-15 17:29:03 -07:00
John Reiser 4cb4bd38eb check_pt_dynamic() checks PT_DYNAMIC.p_memsz
https://github.com/upx/upx/issues/368
	modified:   p_lx_elf.cpp
2020-04-15 14:24:05 -07:00
John Reiser 58c6d19f7c unpack() checks PT_DYNAMIC.p_filesz
https://github.com/upx/upx/issues/367
	modified:   p_lx_elf.cpp
2020-04-15 14:12:06 -07:00
John Reiser f99ae94747 More checking .e_shstrndx
https://github.com/upx/upx/issues/366
	modified:   p_vmlinx.cpp
2020-04-15 13:44:35 -07:00
John Reiser 6868ca7953 getElfSections concentrates on _Shdr[.e_shstrndx]
https://github.com/upx/upx/issues/363
	modified:   p_vmlinx.cpp
2020-04-15 13:29:01 -07:00
John Reiser 87a5a4ef32 WIP but should concentrate on section .e_shstrndx instead.
modified:   p_vmlinx.cpp
2020-04-15 13:13:45 -07:00
John Reiser c67a5d677c More bounds checking for DT_INIT (etc.) in shlib
https://github.com/upx/upx/issues/364
	modified:   p_lx_elf.cpp
2020-04-13 17:08:49 -07:00
bitraid 1ce6f0e6f4 Fix unpacking of ASLR enabled PE files 2020-04-12 03:19:57 +03:00
John Reiser 740b4ff865 ELF shared lib: PT_DYNAMIC might be below xct_off, such as MIPS
https://github.com/upx/upx/issues/298
	modified:   p_lx_elf.cpp
2020-02-15 15:04:44 -08:00
John Reiser 1059f62566 MIPS stub mprotect() suffered from [non-]inlining.
https://github.com/upx/upx/issues/342
https://github.com/upx/upx/issues/339
	modified:   src/stub/src/include/linux.h
   consequences:
	modified:   .github/travis_testsuite_1-expected_sha256sums.sh
	modified:   src/stub/mips.r3000-linux.elf-fold.h
	modified:   src/stub/mipsel.r3000-linux.elf-fold.h
	modified:   src/stub/tmp/mips.r3000-linux.elf-fold.map
	modified:   src/stub/tmp/mipsel.r3000-linux.elf-fold.map
2020-02-08 19:55:08 -08:00
Markus F.X.J. Oberhumer df3193c1ee Use new ASCII art logo. 2020-01-23 00:21:44 +01:00
Jonas Zeitler 67860e3704 fix kerning on ascii art logo 2019-01-11 17:22:56 +01:00
Markus F.X.J. Oberhumer 35fbb1ecb6 Update testsuite checksums caused by version bump. 2020-01-22 23:26:41 +01:00
Markus F.X.J. Oberhumer c63a71ad42 Prepare for switch to semantic versioning. 2020-01-22 23:24:00 +01:00
Markus F.X.J. Oberhumer f33645f739 Post-release version bump. 2020-01-22 23:11:13 +01:00
Markus F.X.J. Oberhumer d7ba31cab8 Bump release date. 2020-01-22 22:29:58 +01:00
John Reiser 342b1b7d6c EM_PPC64 forgot get_te16(&...) for ehdri.e_machine
So compression on big-endian host was not correct.
https://github.com/upx/upx/issues/334
	modified:   p_lx_elf.cpp
2020-01-19 18:48:50 -08:00
John Reiser 936013f60c Decompression escape hatch for ELF can require a new page.
If not enough room on last page of .text, and ElfXX_Ehdr not PF_X,
then the escape hatch must use a new page.
https://github.com/upx/upx/issues/308
	modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-main.c
    Plus stub/*-linux.elf-fold.h and stub/tmp/*-linux.elf-fold.map
2020-01-19 13:25:55 -08:00
Markus F.X.J. Oberhumer fdf2eddc73 Update Travis. 2020-01-16 13:38:30 +01:00
Markus F.X.J. Oberhumer 4409753014 Update Travis. 2020-01-16 01:54:41 +01:00
Markus F.X.J. Oberhumer 9172ae3d19 New ACC version. 2020-01-16 01:53:55 +01:00
John Reiser e2f60adc95 Detect 0==DT_SYMTAB in invert_pt_dynamic()
https://github.com/upx/upx/issues/333
	modified:   p_lx_elf.cpp
2020-01-14 18:45:52 -08:00
John Reiser 1bb93d4fce Detect bad e_shstrtab better.
https://github.com/upx/upx/issues/332
	modified:   p_lx_elf.cpp
2020-01-13 17:26:31 -08:00
John Reiser eb90eab632 Detect bogus DT_SYMENT.
https://github.com/upx/upx/issues/331
	modified:   p_lx_elf.cpp
2020-01-13 17:10:02 -08:00
Markus F.X.J. Oberhumer 0f4975fd7f Update Travis. 2020-01-08 17:30:03 +01:00
Markus F.X.J. Oberhumer b5b1f06a11 Avoid some compilation warnings. 2020-01-08 06:04:21 +01:00
Markus F.X.J. Oberhumer 86f8eb0930 Fix shadowing global symbols. 2020-01-08 05:44:06 +01:00
Markus F.X.J. Oberhumer 91ad0e7572 Revert "Cleanup legacy symbols: basename, index"
This reverts commit 47ddace96a.
2020-01-08 05:41:56 +01:00
Markus F.X.J. Oberhumer b034ee98fe Revert "Mention --assume-execute-permission"
This reverts commit 29fa358077.
2020-01-08 05:40:40 +01:00
Markus F.X.J. Oberhumer ded07f8781 Revert "MSVC lacks S_IXUSR"
This reverts commit 62a07df45e.
2020-01-08 05:38:44 +01:00
Markus F.X.J. Oberhumer 849bdd87e1 Revert "Option --assume-execute-permission"
This reverts commit 4484acf9d6.
2020-01-08 05:38:19 +01:00
Markus F.X.J. Oberhumer 643e48efd7 Update Travis. 2020-01-08 05:18:43 +01:00
Markus F.X.J. Oberhumer 92f072cf70 Silence some compiler warnings. 2020-01-08 04:49:27 +01:00
Markus F.X.J. Oberhumer 95bf2e2e41 Update testsuite checksums caused by version date bump. 2020-01-08 04:37:59 +01:00
Markus F.X.J. Oberhumer 6a6c6d84eb Rebuild stubs. 2020-01-08 04:30:08 +01:00
Markus F.X.J. Oberhumer 08a689c81e Bump tentative release date. 2020-01-08 04:21:30 +01:00
Markus F.X.J. Oberhumer d1174385ef Welcome 2020. 2020-01-08 04:13:28 +01:00
John Reiser cb5f590e10 More hacking Android shlib.
https://github.com/upx/upx/issues/318
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
2019-12-12 20:23:33 -08:00
John Reiser 5ed9c66ed9 Hack Android shared libraries on arm64.
https://github.com/upx/upx/issues/318
	modified:   p_lx_elf.cpp
2019-12-12 17:05:50 -08:00
John Reiser b8f52d14f4 user_init_va on AARCH64
https://github.com/upx/upx/issues/318  (work-in-progress)
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
2019-12-04 14:26:46 -08:00
John Reiser 5d295c24f0 DT_NEEDED can be duplicated
modified:   p_lx_elf.cpp
2019-11-26 19:33:27 -08:00
John Reiser 8be9da8280 Avoid bogus values in PT_DYNAMIC segment.
Detect duplicate DT_*.
Detect out-of-bounds hashtab and gashtab.
Detect missing DT_REL, DT_RELA.
Detect out-of-bounds d_val.
https://github.com/upx/upx/issues/317
	modified:   p_lx_elf.cpp
2019-11-23 20:06:14 -08:00
John Reiser 819c33fee2 Detect malformed Mach-o file in ::canUnpack()
https://github.com/upx/upx/issues/314
https://github.com/upx/upx/issues/315
	modified:   p_mach.cpp
2019-11-15 21:32:06 -08:00
John Reiser 75a2cc4ecb Sync testsuite (amd64, 32-bit ARM, 64-bit ARM)
modified:   ../.github/travis_testsuite_1-expected_sha256sums.sh
	modified:   Makefile
2019-10-27 21:56:30 -07:00
John Reiser e2833cf303 Message when /proc/self/exe lacks Read permission
Done: amd64, 32-bit ARM, 64-bit ARM.  TODO: mips, PowerpC
https://github.com/upx/upx/issues/302
	modified:   stub/amd64-linux.elf-entry.h
	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/tmp/amd64-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v4a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v5a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm64-linux.elf-entry.bin.dump
	modified:   stub/tmp/armeb.v4a-linux.elf-entry.bin.dump
2019-10-27 21:30:41 -07:00
John Reiser 801de73dbe random assembler?
modified:   ../stub/arm64-linux.elf-entry.h
2019-10-27 21:15:15 -07:00
John Reiser 6a53c0b3d4 [Append to previous commit message.]
https://github.com/upx/upx/issues/286
	modified:   p_vmlinx.cpp
2019-07-21 10:51:59 -07:00
John Reiser 58b122d97d Better checking for malformed input
https://github.com/upx/upx/issues
	modified:   p_vmlinx.cpp
2019-07-21 10:48:50 -07:00
John Reiser 276b748aa6 Ignore malformed ElfXX_Shdr in search for .text or .note
https://github.com/upx/upx/issues/287
	modified:   p_vmlinx.cpp
2019-07-21 07:40:21 -07:00
John Reiser 23570097cf MSVC barfs on {unsigned == long int) [because sizeof() is the same!]
https://github.com/upx/upx/issues/283
	modified:   p_lx_elf.cpp
2019-07-14 13:39:09 -07:00
John Reiser 62a07df45e MSVC lacks S_IXUSR
modified:   p_unix.cpp
2019-07-14 13:38:51 -07:00
John Reiser 593a69ce25 PT_LOAD[0] with ElfXX.Ehdr only
https://github.com/upx/upx/issues/283
	modified:   p_lx_elf.cpp
2019-07-14 13:08:56 -07:00
John Reiser c33603e324 'bound' register was clobbered
modified:   stub/src/arch/arm64/v8/lzma_d-arm.S
2019-07-14 13:05:52 -07:00
John Reiser 29fa358077 Mention --assume-execute-permission
for MSYS2 and other permission-poor OS.
	modified:   NEWS
2019-05-10 07:03:51 -07:00
John Reiser 49766388bc Fix compression and de-compression of Android shared libraries
Handle relocation (and DT_INIT_ARRAY[0]==NULL) when !DT_INIT.
Warn about missing --android-shlib if (ET_DYN && !DF_1_PIE && Arm*).
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
https://github.com/upx/upx/issues/265
https://github.com/upx/upx/issues/262
https://github.com/upx/upx/issues/259
https://github.com/upx/upx/issues/243
https://github.com/upx/upx/issues/229
https://github.com/upx/upx/issues/220
2019-04-14 19:59:08 -07:00
John Reiser f23267bddd Fix rotate+lop of PT_INTERP in shared library
Found while working on https://github.com/upx/upx/issues/262
but probably does not help that bug.
	modified:   p_lx_elf.cpp
2019-04-01 21:35:53 -07:00
John Reiser 4484acf9d6 Option --assume-execute-permission
modified:   main.cpp
	modified:   options.h
	modified:   p_unix.cpp
https://github.com/upx/upx/issues/256
2019-03-31 10:25:06 -07:00
John Reiser 47ddace96a Cleanup legacy symbols: basename, index
modified:   conf.h
https://github.com/upx/upx/issues/257
2019-03-31 10:12:41 -07:00
John Reiser 8aadbcd786 Enable standalone compiling, to investigate size of compiled code
modified:   stub/src/arch/arm64/v8/lzma_d-arm.S
	modified:   stub/src/arch/arm64/v8/lzma_d.S
	modified:   stub/src/arch/arm64/v8/nrv2b_d32.S
	modified:   stub/src/arch/arm64/v8/nrv2d_d32.S
	modified:   stub/src/arch/arm64/v8/nrv2e_d32.S
2019-03-03 14:27:33 -08:00
John Reiser 517bc9db0b PR_SET_MM (previous commit had typo) is from 7 years ago: 2012
modified:   stub/src/include/linux.h
2019-03-03 14:26:20 -08:00
John Reiser 16bfa7b846 PT_SET_MM since 2012
modified:   stub/src/include/linux.h
2019-03-02 16:12:14 -08:00
John Reiser 570b2d0e88 arm64-linux.elf changed when PT_LOAD[1] no longer forces 4KB alignment
modified:   travis_testsuite_1-expected_sha256sums.sh
2019-03-02 16:10:37 -08:00
John Reiser 2653a0749a de-tabify
modified:   stub/src/arch/i386/bxx.S
2019-03-02 15:48:44 -08:00
John Reiser 3de0008543 i386-darwin.macho re-implementation, especially for MacOS <= 10.8.x (Mountain Lion)
[i386 will not be supported by new MacOS beginning fall 2019.]
https://github.com/upx/upx/issues/246
	modified:   p_mach.cpp
	modified:   stub/i386-darwin.macho-entry.h
	modified:   stub/i386-darwin.macho-fold.h
	modified:   stub/i386-darwin.macho-upxmain.exe
	modified:   stub/i386-darwin.macho-upxmain.h
	new file:   stub/src/arch/i386/bxx.S
	new file:   stub/src/arch/i386/nrv2b_d32-easy.S
	new file:   stub/src/arch/i386/nrv2d_d32-easy.S
	new file:   stub/src/arch/i386/nrv2e_d32-easy.S
	modified:   stub/src/i386-darwin.macho-entry.S
	modified:   stub/src/i386-darwin.macho-fold.S
	modified:   stub/src/i386-darwin.macho-main.c
	modified:   stub/src/i386-darwin.macho-upxmain.c
	modified:   stub/tmp/i386-darwin.macho-entry.bin.dump
	modified:   stub/tmp/i386-darwin.macho-fold.map
2019-03-02 15:39:30 -08:00
John Reiser d4e2d7e8a8 arm64 (aarch64) and PAGE_SIZE > 4KiB
Future: use prctl(PR_SET_MM, PR_SET_MM_START_BRK, addr)
https://github.com/upx/upx/issues/254
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
2019-03-01 20:31:41 -08:00
John Reiser a9c08c6f52 __MSYS2__ acts like UNIX but cannot handle --x permission
https://github.com/upx/upx/issues/256
	modified:   p_unix.cpp
2019-03-01 16:46:49 -08:00
Markus F.X.J. Oberhumer c2aa5c35f7 Silence a gcc-4.6 compiler warning. 2019-02-25 13:41:54 +01:00
John Reiser 423f1a8758 pack4() "__TEXT".nsects can differ from prototype to actual
modified:   p_mach.cpp
2019-02-18 14:41:43 -08:00
Markus F.X.J. Oberhumer cc5f684e33 Update testsuite checksums caused by version date bump. 2019-02-15 11:14:18 +01:00
Markus F.X.J. Oberhumer b6646d319a Bump tentative release date. 2019-02-15 11:12:07 +01:00
Markus F.X.J. Oberhumer 3667fa4e44 Welcome 2019. 2019-02-15 11:04:09 +01:00
John Reiser d1c80154f6 SHT_NOTE with ~SHF_ALLOC; as for 'gold' linker version
https://github.com/upx/upx/issues/243
	modified:   p_lx_elf.cpp
2019-02-12 21:13:24 -08:00
John Reiser 3c2bfc742e g++ -Wsign-compare is not as picky as MSVC warning C4018: '<': signed/unsigned mismatch
https://github.com/upx/upx/issues/247
	modified:   p_lx_elf.cpp
2019-02-09 08:04:58 -08:00
John Reiser d60fef753f check_pt_load(); u32_t, u64_t; (off_t) is not unsigned!
https://github.com/upx/upx/issues/247
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2019-02-01 19:31:57 -08:00
John Reiser 70ed2d0d03 Allow Load Configuration directory > 256, with info().
https://github.com/upx/upx/issues/245
	modified:   pefile.cpp
2019-01-26 07:51:16 -08:00
John Reiser 716d203a78 Testsuite checksums
amd64-linux.elf
commit 6b500bc83b
Date:   Wed Aug 22 14:39:14 2018 -0700

arm-linux.elf, armeb-linux.elf:
commit 75c31dff1d
Date:   Thu Dec 13 20:10:57 2018 -0800

	modified:   .github/travis_testsuite_1-expected_sha256sums.sh
2018-12-31 11:08:53 -08:00
John Reiser 9719a7dd56 MSVC pettiness
https://github.com/upx/upx/issues/238
	modified:   p_lx_elf.cpp
2018-12-26 18:38:30 -08:00
John Reiser c097233bf3 Stronger checks for DT_HASH, DT_GNU_HASH
https://github.com/upx/upx/issues/238
	modified:   p_lx_elf.cpp
2018-12-26 13:00:20 -08:00
John Reiser 69a583281f MemBuffer::subref() for 64-bit offsets; better diagnosis for bad .e_shoff
https://github.com/upx/upx/issues/235 (POC14)
	modified:   mem.cpp
	modified:   mem.h
	modified:   p_lx_elf.cpp
2018-12-16 16:00:15 -08:00
John Reiser 8e90c9af2b Corner cases for e_shnum vs e_shstrndx
modified:   p_lx_elf.cpp
2018-12-16 15:36:51 -08:00
John Reiser a784284b7f Check user_init_off. Also remove '\n' from error messages.
https://github.com/upx/upx/issues/235  POC11
	modified:   p_lx_elf.cpp
2018-12-16 12:14:22 -08:00
John Reiser 0509edf08d ElfXX_Sym.st_name is always 32 bits
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-12-16 11:32:58 -08:00
John Reiser 7ca20f424f Typos
modified:   p_lx_elf.cpp
2018-12-15 21:17:26 -08:00
John Reiser b74d51c2a8 More checking of e_shstrndx
https://github.com/upx/upx/issues/235  POC6
	modified:   p_lx_elf.cpp
2018-12-15 21:12:15 -08:00
John Reiser 58061cd121 Check .p_offset
https://github.com/upx/upx/issues/235  POC13
	modified:   p_lx_elf.cpp
2018-12-15 20:59:45 -08:00
John Reiser b8f6be5389 More checking of DT_HASH and DT_GNU_HASH
https://github.com/upx/upx/issues/235  POC12
	modified:   p_lx_elf.cpp
2018-12-15 20:43:33 -08:00
John Reiser 7c766b3313 Check e_shstrndx and Shdr.st_name
https://github.com/upx/upx/issues/235  POC10
	modified:   p_lx_elf.cpp
2018-12-15 20:27:20 -08:00
John Reiser 91b81b587b Abandon when outrageous Elf64_Dyn.d_tag
https://github.com/upx/upx/issues/235  POC8
	modified:   p_lx_elf.cpp
2018-12-15 19:35:13 -08:00
John Reiser 780a4347b8 Check DT_HASH and DT_GNU_HASH.
https://github.com/upx/upx/issues/235  POC2,POC4
Also cleanup checking of symbol number and .st_name
in POC1,POC3,POC5,POC7,POC9,POC11
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-12-15 19:16:14 -08:00
John Reiser 606ad08dd1 Check symbol number and .st_name
https://github.com/upx/upx/issues/235  POC1,POC3,POC7,POC9
	modified:   p_elf_enum.h
	modified:   p_lx_elf.h
	modified:   p_lx_elf.cpp
2018-12-14 21:32:49 -08:00
John Reiser 75c31dff1d Use THUMB 'ret' when in THUMB mode.
https://github.com/upx/upx/issues/236
https://github.com/upx/upx/issues/229
	modified:   src/arm.v4t-linux.shlib-init.S

	modified:   arm.v5t-linux.shlib-init.h
	modified:   tmp/arm.v5t-linux.shlib-init.bin.dump
2018-12-13 20:14:14 -08:00
John Reiser 473b90419f Mach-o for 'rust' has intermixed LC_SEGMENT64 "__DWARF" with 0==.vmsize
https://github.com/upx/upx/issues/222
	modified:   p_mach.cpp
	modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/amd64-darwin.macho-upxmain.c
	also *-darwin.macho-fold.{h,map}
2018-10-13 21:06:37 -07:00
John Reiser f88b85e126 MSVC error C4146: unary minus operator applied to unsigned type, result still unsigned
modified:   p_lx_elf.cpp
2018-10-09 20:27:19 -07:00
John Reiser b122f8e9d0 Optimize /proc/self/exe. Sync stubs.
See also commit 78b1da5c00 earlier today
for https://github.com/upx/upx/issues/225 .
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	also *.h, *.map, *.bin.dump
2018-10-09 20:11:34 -07:00
John Reiser cb8b1595a1 Pay more attention to 0==.e_shnum
modified:   p_lx_elf.cpp
2018-10-09 19:38:43 -07:00
John Reiser 1bee919276 cosmetic: developer quality-of-life
modified:   packer.cpp
2018-10-09 19:35:03 -07:00
John Reiser 78b1da5c00 Avoid dcache==>icache trouble with mflg_data; heuristic cache_flush for 32-bit ARM
modified:   arm.v4a-linux.elf-entry.S
	modified:   arm.v4a-linux.elf-fold.S
2018-10-09 19:24:50 -07:00
John Reiser bb8239ccda more DPRINTF
modified:   amd64-linux.elf-main.c
2018-10-09 19:23:06 -07:00
John Reiser 2a594ad0a7 Better return value when de-compression method mismatches.
modified:   arch/amd64/lzma_d.S
	modified:   arch/amd64/nrv2b_d.S
	modified:   arch/amd64/nrv2d_d.S
	modified:   arch/amd64/nrv2e_d.S
2018-10-07 10:15:48 -07:00
John Reiser b05073550c "pop %rcx", not %ecx
modified:   amd64-darwin.macho-entry.S
	modified:   amd64-linux.elf-entry.S
2018-10-07 10:11:45 -07:00
John Reiser 37d6a34e58 MSVC is a nimrod. (All verions 10.0 through 14.1)
"(4074): error C4146: unary minus operator applied to unsigned type, result still unsigned"
So what?  Many programmers are much better than the typical Microsoft coder.
The C standard GUARANTEES that unsigned arithmetic uses two's complement,
ignores overflow, and the result is what the hardware adder produces.
	modified:   p_lx_elf.cpp
2018-09-23 20:45:07 -07:00
John Reiser 4f0cba9bb6 /proc/self/exe mapping had wrong offset in stub for 32-bit ARM
https://github.com/upx/upx/issues/221
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	also arm*.*-linux.elf-*.{h,map}
2018-09-23 20:32:37 -07:00
John Reiser 4d1c754af9 Preserve Mach_segment_header.flags; fix non-PIE main programs on MacOS.
https://github.com/upx/upx/issues/222
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   stub/src/amd64-darwin.macho-entry.S
	also *.macho-*.h, *.macho-fold.map, amd64-darwin.macho-entry.bin.dump
2018-09-22 18:50:37 -07:00
John Reiser c1cfde21d7 Map when .vmsize (not .filesize). More debugging DPRINTF;
modified:   stub/src/amd64-darwin.macho-main.c
	also *.macho-fold.h, *.macho-fold.map
2018-09-22 13:06:45 -07:00
John Reiser bb1f9cdecd Propagate pagezero_vmsize; fix overlay_offset.
modified:   p_mach.cpp
2018-09-22 12:11:51 -07:00
John Reiser b259b0ca28 Print failed syscalls to stderr
modified:   stub/src/amd64-darwin.macho-fold.S
2018-09-22 12:09:22 -07:00
John Reiser 0051dfc84f --android-shlib: Relocate ABS _edata etc.
https://github.com/upx/upx/issues/220
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-09-16 15:10:40 -07:00
John Reiser 9f294e6ce5 Fix "upx -d" de-compression when input is compressed Android shlib.
https://github.com/upx/upx/issues/220
	modified:   p_lx_elf.cpp
2018-09-16 13:09:43 -07:00
John Reiser 153ea8be03 MSVC signed/unsigned
modified:   p_mach.cpp
2018-09-11 21:13:27 -07:00
John Reiser f3f7f97f8d MSVC signed/unsigned
modified:   p_mach.cpp
2018-09-09 15:58:24 -07:00
John Reiser 9bb6854e64 Fix stub for MacOS El Capitan, which has "pre-linked" /usr/bin/dyld
https://github.com/upx/upx/issues/218
https://github.com/Homebrew/homebrew-core/pull/31846
	modified:   src/amd64-darwin.macho-main.c
	    also *-darwin.mach-fold.{h,map}
2018-09-09 15:37:54 -07:00
John Reiser 4bba1e6cb7 Merge branch 'devel' of https://github.com/upx/upx into devel 2018-09-08 11:43:41 -07:00
John Reiser 597e8fe407 Fix de-compression for Mach-O files (MacOS)
https://github.com/upx/upx/issues/219
	modified:   p_mach.cpp
	modified:   p_mach.h
2018-09-08 11:41:38 -07:00
Markus F.X.J. Oberhumer 556c541ffb Sync with latest upx-testsuite changes. 2018-09-06 13:57:15 +02:00
John Reiser 5963f18f7c Merge branch 'devel' of https://github.com/upx/upx into devel 2018-09-04 20:54:21 -07:00
John Reiser 0dac6b7be3 MacOS de-compression (upx -d)
https://github.com/upx/upx/issues/218
	modified:   p_mach.cpp
2018-09-04 20:52:17 -07:00
Markus F.X.J. Oberhumer 296ede780b Update Travis. 2018-08-29 15:13:46 +02:00
Markus F.X.J. Oberhumer faaa19331a Update Travis. 2018-08-27 16:43:21 +02:00
Markus F.X.J. Oberhumer 88cb5886f3 Update Travis. 2018-08-26 06:42:46 +02:00
Markus F.X.J. Oberhumer 2fcc3f86c0 Introduce environment variable UPX_DISABLE_GITREV_WARNING. 2018-08-26 06:29:58 +02:00
Markus F.X.J. Oberhumer 9362fde9eb Update testsuite checksums caused by version bump. 2018-08-26 06:15:54 +02:00
Markus F.X.J. Oberhumer 56f4d781c1 Post-release version bump. 2018-08-26 06:08:40 +02:00
Markus F.X.J. Oberhumer 7a3637ff5a Update NEWS. 2018-08-26 04:58:09 +02:00
John Reiser 2923c0968e Merge branch 'devel' of https://github.com/upx/upx into devel
Fix Conflicts:
	.github/travis_testsuite_1.sh
2018-08-22 14:58:36 -07:00
John Reiser 98cfe99d65 sync testsuite
modified:   .github/travis_testsuite_1.sh
2018-08-22 14:52:00 -07:00
John Reiser bdd97fe0b2 build stubs
modified:   amd64-linux.elf-fold.h
	modified:   arm64-linux.elf-fold.h
	modified:   i386-bsd.elf-fold.h
	modified:   i386-linux.elf.interp-fold.h
	modified:   i386-netbsd.elf-fold.h
	modified:   i386-openbsd.elf-fold.h
	modified:   powerpc64-linux.elf-fold.h
	modified:   powerpc64le-linux.elf-fold.h
	modified:   tmp/amd64-linux.elf-fold.map
	modified:   tmp/arm64-linux.elf-fold.map
	modified:   tmp/i386-bsd.elf-fold.map
	modified:   tmp/i386-linux.elf.interp-fold.map
	modified:   tmp/i386-netbsd.elf-fold.map
	modified:   tmp/i386-openbsd.elf-fold.map
	modified:   tmp/powerpc64-linux.elf-fold.map
	modified:   tmp/powerpc64le-linux.elf-fold.map
2018-08-22 14:48:15 -07:00
John Reiser 6b500bc83b auxv_up() quit at AT_NULL, especially when AT_BASE has been omitted.
Based on contribution from Brian Geffon 'bgaff'
https://github.com/upx/upx/pull/215 ; bgaff
	modified:   amd64-linux.elf-main.c
	modified:   i386-bsd.elf-main.c
	modified:   i386-linux.elf.interp-main.c
	modified:   i386-openbsd.elf-main.c
2018-08-22 14:39:14 -07:00
Markus F.X.J. Oberhumer 92a12a2ec1 Update testsuite checksums caused by version date bump. 2018-08-22 13:16:39 +02:00
Markus F.X.J. Oberhumer 04d79040f9 Bump tentative release date. 2018-08-22 13:15:50 +02:00
Markus F.X.J. Oberhumer 3201ddc680 Update .editorconfig. 2018-08-22 13:06:39 +02:00
Markus F.X.J. Oberhumer 2f06de54c5 Cosmetic update. 2018-08-22 12:43:23 +02:00
John Reiser 6489ec9bba Fix PT_LOAD for ELF shared library.
modified:   p_lx_elf.cpp
2018-08-20 19:36:27 -07:00
John Reiser 1a5ba22fe7 Highlight changes for upx-3.95.
modified:   NEWS
2018-08-20 17:10:00 -07:00
John Reiser 8f9713ed53 Appease MSVC warning C4018: s/igned/unsigned mismatch
modified:   p_lx_elf.cpp
2018-08-13 18:47:42 -07:00
John Reiser 90eb68b3b9 Adapt to 4 PT_LOAD in binutils-2.31 and gcc-8.2.1 (Fedora 29)
0:        PF_R: .gnu.hash .dynsym .dynstr
1: PF_X | PF_R: .plt .plt.sec .text
2:        PF_R: .rodata .hash
3: PF_W | PF_R: .data.rel.ro .dynamic .got .got.plt .data .bss
	modified:   p_lx_elf.cpp

https://github.com/upx/upx/issues/212 (partial, Fedora 29)
2018-08-13 17:36:56 -07:00
John Reiser 95fcbcb4f2 ::PackLinuxElf64amd() sets lg2_page back to 12.
https://github.com/upx/upx/issues/212 (partial, Fedora 29)
	modified:   p_lx_elf.cpp
2018-08-10 20:28:40 -07:00
John Reiser b97688d119 Stub updates AT_PHDR for 32-bit libmusl, particularly -fPIE
https://github.com/upx/upx/issues/200
	modified:   stub/src/i386-linux.elf-main.c
	  also *.elf-fold.h, *.elf-fold.map for arm, armeb, i386, mips, mipsel, powerpc
	modified:   ../.github/travis_testsuite_1.sh
2018-08-04 18:26:02 -07:00
John Reiser 5ea3627cab --android-shlib, --force-pie
modified:   NEWS
2018-05-19 06:30:23 -07:00
John Reiser d9288213ec More checking of PT_DYNAMIC and its contents.
https://github.com/upx/upx/issues/206
	modified:   p_lx_elf.cpp
2018-05-17 21:48:26 -07:00
John Reiser 614c86fb7d --force-pie inhibits treating as shared library (for 'rust', etc.)
https://github.com/upx/upx/issues/200
	modified:   main.cpp
	modified:   options.h
	modified:   p_lx_elf.cpp
2018-04-26 13:44:17 -07:00
John Reiser 9f651ee40f Ignore ElfXX_Shdr if not CMD_COMPRESS; beware unpack when PT_DYNAMIC in other PT_LOAD
https://github.com/upx/upx/issues/200
	modified:   p_lx_elf.cpp
2018-04-26 08:34:58 -07:00
John Reiser 774c8c3fd4 Fix forgotten get_teXX() in canPack() and invert_pt_dynamic()
https://github.com/upx/upx/issues/200
	modified:   p_lx_elf.cpp
2018-04-25 23:05:17 -07:00
John Reiser b711d2f750 TLS callbacks: one entry only
https://github.com/upx/upx/issues/186  [partial, incomplete]
(Laszlo hints there is more, but meanwhile this does fix some.)
	modified:   pefile.cpp
2018-04-06 13:44:24 -07:00
John Reiser 8a793d5942 ELF shlib when no DT_INIT (especially --android-shlib)
https://github.com/upx/upx/issues/191
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-04-04 09:15:18 -07:00
John Reiser 99f52c60ed Merge branch 'Mattiwatti-offset-to-rva-fix' into devel
https://github.com/upx/upx/pull/193
2018-04-02 09:08:57 -07:00
Mattiwatti 2c2e108301 PE: fix comparison against a constant value
... due to size always being assigned to right before this comparison,
and instead check against the RVA and size of the export directory
from the header. (note: this is still stricter than the Windows loader
which ignores all of these except the directory RVA, but if the name RVA
is invalid the PE was probably tampered with).
Change 'offset' to 'RVA' in exception message; this field is always an RVA

  Author:    Mattiwatti <mattiwatti@gmail.com>
	modified:   pefile.cpp
2018-04-02 09:07:29 -07:00
John Reiser 563165e6ae Defensive patches from hints by Sean Williams <rootkit@google.com>
modified:   pefile.cpp
2018-03-29 16:55:21 -07:00
John Reiser f1a31b4793 ELf32::unpack; Elf64 parity with Elf32 for shlib with no DT_INIT
https://github.com/upx/upx/issues/191  [partial, not finished]
	modified:   p_lx_elf.cpp
2018-03-27 19:15:47 -07:00
John Reiser 5e9b6bd69d more ELF shlib when no DT_INIT (especially Android): hook DT_INIT_ARRAY[0]
https://github.com/upx/upx/issues/191  [partial, not finished]
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
2018-03-26 16:30:52 -07:00
John Reiser 9b990c4eae clarity
modified:   p_lx_elf.cpp
2018-03-24 13:52:29 -07:00
John Reiser 7a625a449a ELF shlib without DT_INIT: steal a DT_NULL from PT_DYNAMIC
https://github.com/upx/upx/issues/191  [partial, not finished]
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-03-24 09:41:58 -07:00
John Reiser c2b62359d5 arm32 stubs on linux: allow 0==user_DT_INIT as nop; somewhat expensive
modified:   stub/arm.v5a-linux.shlib-init.h
	modified:   stub/arm.v5t-linux.shlib-init.h
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
	modified:   stub/tmp/arm.v5a-linux.shlib-init.bin.dump
	modified:   stub/tmp/arm.v5t-linux.shlib-init.bin.dump
2018-03-24 08:55:04 -07:00
John Reiser 6722e8972e cleanup dead variables: is_big, all_pages
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-03-23 08:06:31 -07:00
John Reiser fefe7a3452 Fix segTEXT.vmsize and data for entry to shlib.
https://github.com/upx/upx/issues/57
	modified:   p_mach.cpp
2018-03-19 14:59:20 -07:00
John Reiser 90a1322929 Also check for wrap-around when checking oversize involving e_shoff and e_shnum.
raised by https://github.com/upx/upx/pull/190
	modified:   p_lx_elf.cpp
2018-03-15 21:25:20 -07:00
John Reiser d698eb69e2 Fix decompression stub for arm64 --lzma
https://github.com/upx/upx/issues/181
	modified:   stub/src/arch/arm64/v8/lzma_d.S
2018-02-24 13:04:15 -08:00
John Reiser 0ef00e9b82 Fix --lzma (and so --ultra-brute) for 32-bit ARM
https://github.com/upx/upx/issues/167  (comment #14)
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   ../.github/travis_testsuite_1.sh
2018-02-03 15:44:00 -08:00
John Reiser 95cedb6640 upgrade ::unpack for --android-shlib
modified:   p_elf_enum.h
    	modified:   p_lx_elf.cpp
    	modified:   p_lx_elf.h
    	modified:   stub/src/arm64-linux.shlib-init.S
    	modified:   stub/src/arm.v4t-linux.shlib-init.S
2018-02-02 14:50:56 -08:00
John Reiser d736da4208 Elf32, not shared lib: leave alone the hole between .text and .data
In theory Linux might put pages there (and that would be a problem),
but postpone closing the gap until more experience.
	modified:   p_lx_elf.cpp
2018-01-28 13:30:10 -08:00
John Reiser be83788666 --android-shlib for 32-bit ARM
Includes better handling of asl_delta in execution stub.

    	modified:   p_lx_elf.cpp
    	modified:   p_lx_elf.h
    	modified:   stub/src/arm.v4t-linux.shlib-init.S
    	modified:   stub/src/arm64-linux.shlib-init.S
2018-01-27 22:00:16 -08:00
John Reiser 5a28a51abc android shlib: better handling of asl_delta in execution stub
modified:   p_lx_elf.cpp
    	modified:   stub/src/arm64-linux.shlib-init.S
2018-01-26 12:35:06 -08:00
John Reiser 8a84df752c Compiler nit: ptr->ENUM is not always considered a constant
modified:   p_lx_elf.cpp
2018-01-26 11:54:33 -08:00
John Reiser 85f53b210d de-compression of arm64 --android-shlib
modified:   src/p_lx_elf.cpp
	modified:   src/p_lx_elf.h
	modified:   src/stub/src/arm64-linux.shlib-init.S
2018-01-24 15:39:46 -08:00
John Reiser 5d13c6cd01 elfout is unset for shlib in PackLinuxElf64::updateLoader
modified:   p_lx_elf.cpp
2018-01-22 16:15:53 -08:00
John Reiser 98a0d381e9 Merge branch 'devel' into jreiser-android
modified:   p_lx_elf.cpp
2018-01-22 13:55:45 -08:00
John Reiser e1d20fd0b5 Fix wobble in PackLinuxElf64::pack2
modified:   p_lx_elf.cpp
2018-01-22 13:48:26 -08:00
John Reiser d1035ecd8f Fix PLT for --android-shlib
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-22 13:05:18 -08:00
John Reiser 0e651facdd Fix PLT for --android-shlib
NYI: unpack of PLT, DT_INIT etc.  Also e_entry.
	modified:   p_lx_elf.cpp
2018-01-22 13:01:20 -08:00
John Reiser 9fdddfc332 work in progress: de-compression of --android-shlib
OK except for asl_delta not removed from DT_INIT, DT_INIT_ARRAY,
DT_FINI_ARRAY, DT_PREINIT_ARRAY
	modified:   ../p_lx_elf.cpp
2018-01-21 18:59:21 -08:00
John Reiser 7d2913709c MemBuffer lowmem; for shlib, especially android
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-21 14:03:52 -08:00
John Reiser 3623199e8d Merge branch 'devel' into jreiser-android 2018-01-21 10:55:56 -08:00
John Reiser e4b23f7a47 Merge branch 'devel' of https://github.com/upx/upx into devel 2018-01-21 10:30:42 -08:00
John Reiser f056ecdcd5 pefile: Allow overlap of MZ header and PE header (h.nexepos==0x10)
https://github.com/upx/upx/issues/169
This means .codebase is aliased to .nexepos, with both equal to 0x10.
	modified:   pefile.cpp
2018-01-21 10:29:17 -08:00
John Reiser 857a03a074 fix sh_offset for new Shdr[e_shstrndx]
modified:   p_lx_elf.cpp
2018-01-20 16:41:32 -08:00
John Reiser a34deee4f5 work in progress for --android-shlib
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-20 16:34:52 -08:00
John Reiser fc9c8ae482 fix updating of DT_INIT
modified:   p_lx_elf.cpp
2018-01-20 09:48:28 -08:00
John Reiser 08c63f06eb p_lx_elf.h: phdro for --android-shlib
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-19 22:01:56 -08:00
John Reiser bbff510ef1 Merge branch 'devel' into jreiser-android
Conflicts:
	src/p_lx_elf.cpp
	src/p_lx_elf.h

	modified:   ../.github/travis_testsuite_1.sh
	modified:   p_exe.cpp
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   pefile.cpp
2018-01-19 21:51:49 -08:00
Markus F.X.J. Oberhumer f747435952 For consistency, add missing "virtual". 2018-01-19 20:21:18 +01:00
Markus F.X.J. Oberhumer e6edad8f46 Clean up OptVar handling. 2018-01-19 19:50:28 +01:00
Markus F.X.J. Oberhumer 05e44b9644 Fix powerpc64 cross build. 2018-01-19 15:05:43 +01:00
Markus F.X.J. Oberhumer 16bb7ab841 clang-format files. 2018-01-19 14:18:47 +01:00
Markus F.X.J. Oberhumer 9248f02557 Silence some gcc-8-snapshot compiler warnings. 2018-01-19 14:13:58 +01:00
Markus F.X.J. Oberhumer 9485a56af1 Update Travis. 2018-01-19 11:30:34 +01:00
Markus F.X.J. Oberhumer 021c8db58a Welcome 2018. 2018-01-19 10:55:32 +01:00
John Reiser 8ab180edf8 MS-DOS .exe (not PE): default to file_size when ih.m512 and ih.p512 are zero
https://github.com/upx/upx/issues/169
	modified:   p_exe.cpp
2018-01-18 12:00:38 -08:00
John Reiser ab35b685d4 Fix pefile.cpp bad range checking for reloc type 3 and 10
modified:   pefile.cpp
2018-01-18 11:11:19 -08:00
John Reiser 86745721ee MSVC strikes again
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-15 16:27:00 -08:00
John Reiser c34fe09a79 Revamp --android-shlib
Android "Oreo" wants to deal with ElfXX_Shdr[].  So splice 4KiB into PT_LOAD[0]
with an "extra" copy of them.  This requires careful relocation processing.
It also costs a page at run time, and an average of a page in the file
(depending on fragmentation at the boundary between r-x and rw- .)

https://github.com/upx/upx/issues/124
https://github.com/upx/upx/issues/139
https://github.com/upx/upx/issues/142

	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
	modified:   stub/src/arm64-linux.shlib-init.S

	modified:   stub/arm.v5a-linux.shlib-init.h
	modified:   stub/arm.v5t-linux.shlib-init.h
	modified:   stub/arm64-linux.shlib-init.h

	modified:   ../.github/travis_testsuite_1.sh
2018-01-15 16:08:34 -08:00
John Reiser 1fa9ff2c05 --android-shlib handles implicit relocation in PLT
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2018-01-15 15:45:37 -08:00
John Reiser e8ef0cf63f Merge branch 'devel' into jreiser-android 2018-01-13 09:25:55 -08:00
John Reiser 8c84efb8fb --android-shlib for Android "Oreo"
Android "Oreo" wants to deal with ElfXX_Shdr[].  So splice 4KiB into PT_LOAD[0]
with an "extra" copy of them.  This requires careful relocation processing.
It also costs a page at run time.
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
	modified:   stub/src/arm64-linux.shlib-init.S
2018-01-13 09:20:04 -08:00
John Reiser f3a7620ae8 ARM: recognize R_ARM_CALL and R_ARM_JUMP24 as equivalent to R_ARM_PC24
modified:   linker.cpp
2018-01-12 08:42:34 -08:00
John Reiser c7969ed5a5 work in progress for --android-shlib
modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   stub/src/arm.v4a-linux.shlib-init.S
	modified:   stub/src/arm.v4t-linux.shlib-init.S
2018-01-12 08:32:24 -08:00
Markus F.X.J. Oberhumer 900926c0ed Avoid a MSVC warning. 2018-01-12 10:19:14 +01:00
John Reiser df94f4288a picky, picky
modified:   p_lx_elf.cpp
2018-01-11 12:09:43 -08:00
John Reiser 969efe687d MSVC pecadillos
modified:   p_lx_elf.cpp
	modified:   pefile.cpp
2018-01-11 12:01:00 -08:00
John Reiser ee3f1292d0 fix editing rot for mach-o .dylib
https://github.com/upx/upx/issues/57
	modified:   p_mach.cpp
2018-01-11 11:33:15 -08:00
John Reiser cacb239040 work in progress for --android-shlib
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   stub/src/arm64-linux.shlib-init.S
2018-01-11 09:39:26 -08:00
John Reiser 28d1789783 work in progress for --android-shlib
modified:   p_lx_elf.cpp
2018-01-08 14:04:38 -08:00
John Reiser 633eb98e34 Merge branch 'devel' into jreiser-android 2018-01-06 09:53:43 -08:00
John Reiser 4854c03096 uint64_t ==> upx_uint64_t
MSVC error C2065: 'uint64_t' : undeclared identifier
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_mach.cpp
2018-01-06 09:33:04 -08:00
John Reiser e853119c77 canonicalize bool in OR
MSVC error C4805: '|' : unsafe mix of type 'bool' and type 'unsigned int' in operation
	modified:   p_lx_elf.cpp
2018-01-06 09:20:46 -08:00
John Reiser 161a58bafb work in progress for --android-shlib
modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
2018-01-06 09:18:17 -08:00
John Reiser f5fd94e815 Android shlib: work in progress
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-12-31 22:40:57 -08:00
John Reiser edde6210f1 amd64 linux stack align
forgotten as part of 4a35bf32ea
	modified:   stub/src/amd64-linux.elf-fold.S

	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
	modified:   ../.github/travis_testsuite_1.sh
2017-12-31 10:36:14 -08:00
John Reiser 507e19945e more checking of PT_DYNAMIC
https://github.com/upx/upx/issues/166
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-12-30 22:31:50 -08:00
John Reiser 4a35bf32ea static uClibc on amd64 passes entry.%rdx to 'atexit'
https://github.com/upx/upx/issues/166
	modified:   ../.github/travis_testsuite_1.sh
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main.c
2017-12-30 17:20:01 -08:00
John Reiser e04bf9e4bc more checking of PT_DYNAMIC
https://github.com/upx/upx/issues/164
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-12-28 17:40:04 -08:00
John Reiser c384d224c0 Mach-o stubs turn off DEBUG
Branch jreiser-macho has DEBUG 1
	modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm.v5a-darwin.macho-fold.S
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-fold.S
2017-12-27 10:23:19 -08:00
John Reiser 35427f998e Mach-o stubs turn off SIMULATE_ON_LINUX_EABI4
modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm.v5a-darwin.macho-fold.S
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-fold.S
2017-12-27 09:12:38 -08:00
John Reiser 1174da2bc3 arm64 stubs use NBPW in TRACE etc
modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-fold.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.shlib-init.S
2017-12-26 16:39:51 -08:00
John Reiser 11e8a47030 DEBUG and TRACE for arm*-darwin.macho-* stubs
modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm.v5a-darwin.macho-fold.S
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-fold.S
2017-12-26 15:44:54 -08:00
John Reiser 8c4e9bcf0d typo
modified:   stub/src/arm.v4a-linux.elf-entry.S
2017-12-26 15:43:58 -08:00
John Reiser 9dfd624901 fix TRACE macro
modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
2017-12-26 15:43:01 -08:00
John Reiser 79e65503a9 Merge branch 'devel' into jreiser-macho 2017-12-26 10:41:26 -08:00
John Reiser 59f18b9d9f stash work-in-progress
modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm.v5a-darwin.macho-fold.S
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-fold.S
2017-12-22 23:07:03 -08:00
John Reiser fb3699fb89 stash work-in-progress
modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/amd64-darwin.macho-upxmain.c
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm.v5a-darwin.macho-fold.S
	modified:   stub/src/arm.v5a-darwin.macho-main.c
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-fold.S
	modified:   stub/src/i386-darwin.macho-upxmain.c
2017-12-22 10:20:32 -08:00
John Reiser 9d2d59b5d2 stash work-in-progress
modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/arm64-darwin.macho-fold.S
2017-12-19 21:19:53 -08:00
John Reiser aefb2fa3c3 bad logic for throwCantUnpack("cmdsize") [simple]
https://github.com/upx/upx/issues/161
	modified:   p_mach.cpp
2017-12-19 17:36:22 -08:00
John Reiser e8aa80f904 stash work-in-progress
modified:   linker.cpp
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   packmast.cpp
	modified:   stub/Makefile
	modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-fold.S
	modified:   stub/src/arm64-darwin.macho-main.c
2017-12-19 17:32:15 -08:00
John Reiser 990988f920 More checking of input Phdr and Shdr
https://github.com/upx/upx/issues/157
	modified:   p_lx_elf.cpp
2017-12-18 10:36:43 -08:00
John Reiser 576d9a4e7e stash work-in-progress
modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/arm.v5a-darwin.macho-entry.S
	modified:   stub/src/arm64-darwin.macho-entry.S
2017-12-17 15:02:57 -08:00
John Reiser 1d462ee424 MIPS shlib --lzma stub coding error: wrong register
https://github.com/upx/upx/issues/139 (part2)
	modified:   stub/src/mipsel.r3000-linux.shlib-init.S
2017-12-14 11:17:01 -08:00
John Reiser c9b09555c4 MH_PIE ASLR (Address-Space Layout Randomization)
modified:   stub/src/amd64-darwin.macho-main.c
2017-12-13 11:15:10 -08:00
John Reiser 860b5bf967 MH_EXECUTE diagnose syscall failure
modified:   stub/src/amd64-darwin.macho-fold.S
2017-12-13 10:53:22 -08:00
John Reiser 5063480a38 MH_EXECUTE runs under lldb, fails under shell
mmap  addr=0x100000000  len=0x3003  prot=0x3  flags=0x1012  fd=-1  off=0x0  reloc=0x0
maddr=0xffffffffffffffff  addr=0x100000000
	modified:   p_mach.cpp
	modified:   p_mach_enum.h
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-darwin.macho-fold.S
	modified:   stub/src/amd64-darwin.macho-main.c
2017-12-13 09:54:44 -08:00
John Reiser 3400ae9dbe MH_EXECUTE leave space for thread state command
modified:   p_mach.cpp
2017-12-12 10:53:19 -08:00
John Reiser 3385264eb2 new DPRINTF
modified:   stub/src/amd64-darwin.macho-main.c
2017-12-12 10:52:47 -08:00
John Reiser 34646f1c6a fix braces in comment after #elif
modified:   stub/src/amd64-linux.elf-main.c
2017-12-12 10:51:38 -08:00
John Reiser 50aa63a5a0 declare write()
modified:   stub/src/include/darwin.h
2017-12-12 10:50:50 -08:00
John Reiser 64557bee43 Mach-o MH_EXECUTE rewrite; work-in-progress
The stub for amd64 gets to upx_main()
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-darwin.macho-fold.S
	plus .h .bin.dump .map
2017-12-09 20:18:39 -08:00
John Reiser 7c21c4513e Android 64-bit ARM shared library stub: use 4Ki page size until more is known
https://github.com/upx/upx/issues/124
	modified:   p_lx_elf.cpp
	modified:   stub/arm64-linux.shlib-init.h
	modified:   stub/src/arm64-linux.shlib-init.S
	modified:   stub/tmp/arm64-linux.shlib-init.bin.dump
2017-12-08 20:05:21 -08:00
John Reiser c6d6378005 Mach-o MH_EXECUTE rewrite; work-in-progress
The stub for amd64 gets into the de-compressed folded code.
	modified:   p_mach.cpp
	modified:   stub/amd64-darwin.macho-entry.h
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-darwin.macho-upxmain.c
	modified:   stub/tmp/amd64-darwin.macho-entry.bin.dump
2017-12-06 17:04:47 -08:00
John Reiser 4f6979967d Mach-o MH_EXECUTE rewrite; work-in-progress
On amd64, otool and lldb accept the results.
The entry point points to the unfilter and uncompress routines.
Somehow _start has been lost.

	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
	modified:   stub/amd64-darwin.macho-entry.h
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-darwin.macho-upxmain.c
	modified:   stub/src/i386-darwin.macho-upxmain.c
	modified:   stub/src/powerpc-darwin.macho-upxmain.c
	modified:   stub/tmp/amd64-darwin.macho-entry.bin.dump
2017-12-03 23:17:55 -08:00
John Reiser e633c51b50 off_t_upx_stub typedef enables easier use of native #include
... but requires  #define __WORDSIZE
	modified:   p_mach.h
	modified:   stub/amd64-darwin.macho-fold.h
	modified:   stub/src/amd64-darwin.macho-main.c
	modified:   stub/src/arm.v5a-darwin.macho-main.c
	modified:   stub/src/arm64-darwin.macho-main.c
	modified:   stub/src/i386-darwin.macho-main.c
	modified:   stub/src/include/darwin.h
	modified:   stub/src/powerpc-darwin.macho-main.c
	modified:   stub/src/powerpc64le-darwin.macho-main.c
	modified:   stub/tmp/amd64-darwin.macho-fold.map
2017-11-28 14:49:46 -08:00
John Reiser 143f0accef PeFile check MZ offset to PE header
modified:   pefile.cpp
2017-11-21 13:07:42 -08:00
John Reiser b413f3da26 ELF shared library: PT_NOTE can prevent packing
Android build environment post-processing is adding a PT_NOTE
("Android", 21, "r16-beta1") at the high end of PT_LOAD[0],
above the stub; the runtime linker looks there before de-compression.
https://github.com/upx/upx/issues/124
	modified:   p_lx_elf.cpp
2017-11-20 10:08:24 -08:00
John Reiser 6eafa552bb Mach-o defend against bad crafted input
https://github.com/upx/upx/issues/146
	modified:   p_mach.cpp
2017-11-15 13:38:54 -08:00
John Reiser 7a0514d9b4 PeFile more checks for Section table
modified:   pefile.cpp
2017-11-12 21:47:47 -08:00
John Reiser 7e7565299e PeFile check Section table
https://github.com/upx/upx/issues/132
	modified:   pefile.cpp
2017-11-12 21:02:52 -08:00
László Molnár ed34a089c6 minor update for a memory derefencing check 2017-11-12 16:19:40 +01:00
John Reiser d14a2c5282 PeFile fix the recently-added interval checking.
https://github.com/upx/upx/issues/143
	modified:   pefile.cpp
2017-11-09 21:58:25 -08:00
John Reiser f014406b65 MemBuffer.subref(errfmt, skip, take) checks that a subinterval is inside
modified:   mem.cpp
	modified:   mem.h
2017-11-09 21:55:41 -08:00
John Reiser 58771ecca6 PeFile: better checking for import descriptors
modified:   pefile.cpp
2017-11-08 12:38:54 -08:00
John Reiser 5d9dcb634b PeFile: Defend against bad crafted import descriptors
https://github.com/upx/upx/issues/143
	modified:   pefile.cpp
	modified:   pefile.h
2017-11-08 11:07:46 -08:00
John Reiser 19c2c1edcf Android 8.0 (Oreo) wants 0!=.e_shstrndx in a shared library
https://github.com/upx/upx/issues/142
It should not matter what the .sh_name is; only the .sh_type matters.
	modified:   p_lx_elf.cpp
2017-11-07 11:12:23 -08:00
John Reiser 0430e7931e PowerPC64 stub: on syscall, real Linux trashes r13 and below
(except r1, r2, and input args!) So, r12 .e_entry for musl
must copy from a saved register.  [qemu-ppc64 doesn't trash registers!]
	modified:   ../.github/travis_testsuite_1.sh
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	also .h  .fold.map
2017-10-27 20:07:32 -07:00
John Reiser bb8e607442 PowerPC64 musl 1.1.16 wants r12= .e_entry
modified:   stub/src/powerpc64le-linux.elf-fold.S
	also .h  .fold.map
2017-10-27 13:19:03 -07:00
John Reiser e61ada944d debug info for shared library on stderr under "-D"
modified:   p_lx_elf.cpp
2017-10-25 21:32:17 -07:00
John Reiser 46730315e3 stub arm64-linux.shlib-init.S saves 1 instr and checks for assembly errors
modified:   arm64-linux.shlib-init.S
	also .h .bin.dump
2017-10-24 12:50:29 -07:00
John Reiser 4869142034 arm64 stub for shared library uses AT_PAGESZ
modified:   stub/src/arm64-linux.shlib-init.S
	also .h .bin.dump
2017-10-23 18:55:28 -07:00
John Reiser 8e42e17bbf typo
modified:   stub/src/amd64-linux.elf-entry.S
2017-10-23 18:53:42 -07:00
John Reiser 38c8b84a26 Align hatch_off.
modified:   p_lx_elf.cpp
2017-10-20 17:23:55 -07:00
John Reiser c652626a37 32-bit shared libs reduce Phdr[1].p_align to 4096, like 64-bit.
This saves space when PAGE_SIZE is larger than 4096: MIPS, etc.
	modified:   p_lx_elf.cpp
2017-10-20 16:35:27 -07:00
John Reiser 06f6e47ebf Fix stub for MIPS shared libraries
https://github.com/upx/upx/issues/135
	modified:   p_lx_elf.cpp
	modified:   stub/src/mipsel.r3000-linux.shlib-init.S
	also .h .bin.dump
2017-10-20 16:16:35 -07:00
John Reiser 403b180b1d Compress shared libraries for mips and mipsel in ELF on Linux
modified:   p_lx_elf.cpp
	modified:   stub/Makefile
	new file:   stub/mips.r3000-linux.shlib-init.h
	new file:   stub/mipsel.r3000-linux.shlib-init.h
	new file:   stub/src/mips.r3000-linux.shlib-init.S
	new file:   stub/src/mipsel.r3000-linux.shlib-init.S
	new file:   stub/tmp/mips.r3000-linux.shlib-init.bin.dump
	new file:   stub/tmp/mipsel.r3000-linux.shlib-init.bin.dump
2017-10-19 13:47:36 -07:00
John Reiser ee008acfbd amd64 implements --is_ptinterp
https://github.com/upx/upx/issues/121
	modified:   ../.github/travis_testsuite_1.sh
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main.c
	also .h, .map, .bin.dump
2017-10-18 13:10:49 -07:00
John Reiser d149092ac0 Reference to external documentation only.
modified:   stub/src/arch/mips/r3000/macros.ash
2017-10-17 14:11:06 -07:00
John Reiser eafa136c69 Appease error C4146 unary minus operator applied to unsigned type, result still unsigned
Microsoft Optimizing Compiler 16.00.40219.01, 19.00.24215.1, 19.11.25507.1; others
	modified:   p_lx_elf.cpp
2017-10-17 08:44:08 -07:00
John Reiser 402c885987 Merge branch 'jreiser-elfstub' into devel
New stub strategy on Linux:  Linux adds too many other segments
to the address space: [vdso], [sigpage], ...; and qemu might
arrange them differently.  Thus the only reliable mappings
are the PT_LOAD of the compressed file itself; all other
address space is unknown!  First, the compressed file uses
.bss to occupy all unused pages up to the original brk(0).
Then at run time, the stub gets another mapping of /proc/self/exe,
and uncompresses the user program on top of the original pages.
[*BSD unchanged for now?]

	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-main.c
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   p_unix.cpp
	modified:   p_mach.cpp
	modified:   p_lx_sh.cpp
	modified:   p_lx_interp.cpp
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_lx_interp.h
	modified:   p_lx_sh.h
	modified:   p_mach.h
	modified:   p_unix.h
	modified:   stub/src/arch/mips/r3000/macros.ash
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/include/linux.h
	modified:   stub/Makefile
	modified:   ../.github/travis_testsuite_1.sh
	also .h .map .bin.dump
2017-10-14 14:26:11 -07:00
John Reiser 5e7e0508b9 sync stubs for "make run-testsuite"
modified:   ../.github/travis_testsuite_1.sh
2017-10-14 14:19:24 -07:00
John Reiser ff1d5fb794 stub for 64-bit little-endian PowerPC also uses TOC
modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/powerpc64le-linux.elf-fold.S
2017-10-14 13:54:43 -07:00
John Reiser ad3f63b5c4 stubs *.elf-main.c: tighten input to first decompress of ELF headers
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-main.c
	also .h, .map
2017-10-14 06:21:44 -07:00
John Reiser a3e51e6dee stub for PowerPC 64-bit big endian: accommodate musl bare .func as .e_entry
modified:   stub/src/powerpc64le-linux.elf-fold.S
2017-10-14 06:18:00 -07:00
John Reiser c1b9c79f54 arm,armeb stubs need endian-neutral code to set mflg_subr
modified:   stub/src/arm.v4a-linux.elf-entry.S
	also .h, .bin.dump
2017-10-13 12:27:07 -07:00
John Reiser e0bc040b0a mips stub uses new strategy
modified:   p_lx_elf.cpp
	modified:   stub/src/arch/mips/r3000/macros.ash
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	also .h, .bin.dump, .map
2017-10-12 21:04:10 -07:00
John Reiser 85eb4c7537 powerpc stub: used wrong register
modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
2017-10-11 17:17:45 -07:00
John Reiser 1f929d47d0 x86_64 stub also needs make_hatch()
https://github.com/upx/upx/issues/133
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   ../.github/travis_testsuite_1.sh
	also .h and .map
2017-10-11 09:06:50 -07:00
John Reiser 608662d73b x86_64 stub also needs make_hatch()
https://github.com/upx/upx/issues/133
	modified:   stub/src/amd64-linux.elf-main.c
2017-10-11 08:45:21 -07:00
John Reiser 7841d23e77 arm64: folded stub uses 64-bit TRACEing under DEBUG
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
2017-10-10 21:39:50 -07:00
John Reiser b72dda4ada arm64 spills a few registers because syscall can trash x18
modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
2017-10-10 20:31:11 -07:00
John Reiser c59c8a1ea2 readability; no functional change
modified:   stub/src/powerpc64le-linux.elf-entry.S
2017-10-10 20:30:41 -07:00
John Reiser 1522293be0 arm64: stub uses new strategy
modified:   p_lx_elf.cpp
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-main.c
	also .h, .map, .bin.dump
2017-10-10 14:51:03 -07:00
John Reiser b37bc99330 PowerPC64: stub uses new strategy
Needed: expert on TOC for big-endian.  glibc, musl, gcc disagree
on layout (is the .func first?) and usage for .e_entry.
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/Makefile
	also .h, .bin.dump, .map
2017-10-07 13:43:12 -07:00
John Reiser 7f905724b1 amd64: stub uses new strategy
modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   p_lx_elf.cpp
	also .h, .bin.dump, .map
2017-10-06 11:15:34 -07:00
John Reiser 2bf5bb1625 arm: stub uses new strategy
modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   p_lx_elf.cpp
	plus .h, .bin.dump, .map
2017-10-05 17:07:30 -07:00
John Reiser 08d3376740 Elf i386 stub: get enough space when unfolded code requires another page
modified:   src/i386-linux.elf-entry.S
2017-10-03 11:48:27 -07:00
John Reiser 7bace76176 Protect against bad crafted input.
https://github.com/upx/upx/issues/129
	modified:   p_lx_elf.cpp
2017-10-03 09:55:34 -07:00
John Reiser ef336dbcc6 Protect against bad crafted input.
https://github.com/upx/upx/issues/128
	modified:   p_lx_elf.cpp
2017-10-02 21:47:40 -07:00
John Reiser ca7217e717 powerpc: stub uses new strategy
First mmap must reserve enough space to decompress folded stub.
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	also .h, .map, .dump
2017-10-02 20:03:47 -07:00
John Reiser 3931cb7871 off_t is signed and long; keep the long when discarding the signed.
https://github.com/upx/upx/issues/127
	modified:   p_vmlinx.cpp
2017-10-01 16:14:09 -07:00
John Reiser 9e8de4abe5 i386: new stub strategy to avoid problems with early mmap layout
The stub occupies the same region that execve() would create
for the original progam.  The stub copies everything to a new area,
erases the original region, replaces it with the de-compressed
program, and erases the copy of itself via the escape hatch.
The copy is inexpensive via mmap() of /proc/self/exe.

	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main.c

	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_lx_interp.cpp
	modified:   p_lx_interp.h
	modified:   p_lx_sh.cpp
	modified:   p_lx_sh.h
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_unix.cpp
	modified:   p_unix.h
	modified:   p_vmlinx.cpp

	plus .h, .map, .dump
2017-10-01 15:56:34 -07:00
John Reiser 26be845563 mips stubs: implement ET_DYN (-pie).
modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	plus associated *.h, *.bin.dump, and ../.github/travis_testsuite_1.sh
2017-09-26 10:05:22 -07:00
John Reiser 2f11a629fa Fix flub: "git --amend" after "git push" is not a good idea.
https://github.com/upx/upx/issues/126# Please enter the commit message for your changes. Lines starting
	modified:   arm64-linux.shlib-init.S
2017-09-25 11:43:38 -07:00
John Reiser a295437e11 Merge branch 'devel' of https://github.com/upx/upx into devel 2017-09-25 11:39:13 -07:00
John Reiser 04597fb804 Fix bug in unfilter for shlib on arm64.
https://github.com/upx/upx/issues/126
	modified:   stub/src/arm64-linux.shlib-init.S
	and associated *.h, *.bin.dump
2017-09-25 11:38:33 -07:00
John Reiser f2f002409b Fix bug in unfilter for shlib on arm64.
https://github.com/upx/upx/issues/126
	modified:   stub/src/arm64-linux.shlib-init.S
	and associated *.h, *.bin.dump
2017-09-25 11:31:44 -07:00
John Reiser 509de877ca Cleanup powerpc64 aux stub files.
modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/tmp/powerpc64-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2017-09-24 20:30:07 -07:00
John Reiser 63aea4a7dc 64-bit Power PC linux uses 64KiB page size, but qemu-ppc64{,le} uses 4KiB.
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/include/linux.h
	modified:   stub/src/powerpc64le-linux.elf-fold.S
2017-09-24 20:24:46 -07:00
John Reiser 6470c748db Flush ACC_UNUSED(adrc); and its predecessors from stub for MIPS.
modified:   p_lx_elf.cpp
2017-09-24 20:07:31 -07:00
John Reiser 25a6429e6a Merge branch 'devel' of https://github.com/upx/upx into devel 2017-09-23 10:43:14 -07:00
John Reiser 4fa1c2a97e Avoid the stack in stub for PowerPC, especially under qemu-ppc.
modified:   stub/src/powerpc-linux.elf-entry.S

	also travis_testsuite_1.sh, -entry.h, -entry.bin.dump
2017-09-23 10:41:40 -07:00
Markus F.X.J. Oberhumer 9ad39d77cc Update Travis. 2017-09-21 10:15:01 +02:00
John Reiser 92527126a8 Adapt around qemu-arm placement of ET_DYN and stack.
modified:   stub/src/arm.v4a-linux.elf-entry.S

	modified:   ../.github/travis_testsuite_1.sh
	plus arm*.elf-entry.h, arm*.elf-entry.bin.dump
2017-09-20 15:23:12 -07:00
John Reiser 02b4a4c974 Sync testsuite checksums.
modified:   ../.github/travis_testsuite_1.sh
2017-09-20 13:37:38 -07:00
John Reiser ede570be21 Spend 8 instructions to avoid modifying [0xf7000000, +) under qemu-arm.
modified:   src/arm.v4a-linux.elf-entry.S
	modified:   src/arm.v4a-linux.elf-fold.S

	plus arm*.h and tmp/arm*.{dump,map}
2017-09-20 13:31:38 -07:00
John Reiser 08627e9df5 Fix some AT_PHDR problems, at least on x86*.
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-main.c

	modified:   ../.github/travis_testsuite_1.sh
	plus many *.elf-fold.h and *.elf-fold.map
2017-09-18 19:54:27 -07:00
John Reiser 6d9f3adc86 Escape hatch for Thumb-mode shared library must reside at even address.
https://github.com/upx/upx/issues/122
	modified:   stub/src/arm.v4t-linux.shlib-init.S

	modified:   stub/arm.v5t-linux.shlib-init.h
	modified:   stub/tmp/arm.v5t-linux.shlib-init.bin.dump
2017-09-13 22:38:24 -07:00
John Reiser 96433b4e39 FILTER_ID was wrong for arm64-linux.shlib and arm64-darwin.macho.
https://github.com/upx/upx/issues/100  (partial)
	modified:   stub/src/arm64-darwin.macho-fold.S
	modified:   stub/src/arm64-linux.shlib-init.S
	modified:   p_mach.cpp

	modified:   stub/arm64-darwin.macho-fold.h
	modified:   stub/arm64-linux.shlib-init.h
2017-08-25 12:51:33 -07:00
John Reiser f4947cc2ae Work-around Ubuntu runtime bug loading shlib on ARM.
Use --android-shlib to activate the work-around.
https://bugs.launchpad.net/bugs/1712938
https://github.com/upx/upx/issues/116
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
2017-08-24 19:52:30 -07:00
John Reiser 7b554d4f72 ucl-1.03 needs help for recent gcc and for native on aarch64.
modified:   README.SRC
2017-08-23 05:47:16 -07:00
John Reiser 5b54544438 Fix powerpc64 (BIG_ENDIAN and comments)
modified:   stub/src/arch/powerpc/64/lzma_d.S
	modified:   stub/src/arch/powerpc/64le/lzma_d-common.S
	modified:   stub/src/powerpc64-linux.elf-main.c
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-main.c
	modified:   stub/src/powerpc64le-linux.kernel.vmlinux.S

	plus stub/powerpc64*entry.h and .dump
2017-07-26 11:16:02 -07:00
Markus F.X.J. Oberhumer ef78d23494 Update Travis and check_whitespace.sh. 2017-07-23 02:59:51 +02:00
Markus F.X.J. Oberhumer ef8a7f330d Silence some compiler warnings. 2017-07-23 02:59:51 +02:00
Markus F.X.J. Oberhumer b72e0f3060 Disable debugging section. 2017-07-23 02:59:51 +02:00
Markus F.X.J. Oberhumer 2a0bab938b Rebuild stubs. 2017-07-23 02:20:05 +02:00
Markus F.X.J. Oberhumer cd637629c4 Update stub/src/arch/powerpc Makefiles. 2017-07-23 02:18:39 +02:00
John Reiser b9adfd801d Compile powerpc64 using powerpc64-linux-gcc-4.9.2 from stubtools
modified:   src/arch/powerpc/64/Makefile.extra
2017-07-22 16:14:12 -07:00
Markus F.X.J. Oberhumer 69355514c9 Fix some misspellings. 2017-07-22 12:54:37 +02:00
Markus F.X.J. Oberhumer 33dc947c21 clang-format files. 2017-07-22 12:47:45 +02:00
John Reiser 6de021d8d8 Fix MIPS, at least ET_EXEC.
ET_DYN not tested.  Also /proc/self/exe is not proected [use getenv("   ")]
	modified:   p_lx_elf.cpp
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   ../.github/travis_testsuite_1.sh

	also .h .dump .map for mips
2017-06-27 20:53:44 -07:00
John Reiser 9be86621bf PowerPC64 unifies into amd64-linux.elf-main.c
Also reconcile ppc32 and ppc64, especially *.S
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-main.c
	modified:   ../.github/travis_testsuite_1.sh

	also corresponding *.h *.map *.dump
2017-06-27 14:58:13 -07:00
John Reiser a7a0876298 /proc/self/exe in powerpc64*.S stub; unify with powerpc*.S.
modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   .github/travis_testsuite_1.sh

	also corresponding *.h *.dump *.map files
2017-06-26 21:40:12 -07:00
John Reiser 31b42345c3 Fix nesting brace in comment on #endif.
modified:   i386-linux.elf-main.c
2017-06-26 21:31:36 -07:00
John Reiser 1b172e729e Fix stub for powerpc64, powerpc64le
modified:   src/powerpc64le-linux.elf-fold.S
2017-06-25 16:03:43 -07:00
John Reiser 3bf387a2d4 PowerPC stub unified with i386; including escape hatch [munmap all extras]
modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-main.c
	modified:   ../.github/travis_testsuite_1.sh

	{arm.*,i386,mips*.r3000,powerpc}-linux.elf-fold.{h,map}
	powerpc-*-entry.*
2017-06-24 18:37:16 -07:00
John Reiser 9f20bbb046 Fix merge 2017-06-19 16:01:35 -07:00
John Reiser 82af555974 Merge branch 'i386-VDSO' into devel 2017-06-19 15:58:22 -07:00
John Reiser 50638b5213 i386 VDSO may conflict on low side of -pie ET_DYN
https://github.com/upx/upx/issues/105
	modified:   stub/src/i386-linux.elf-entry.S

	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/tmp/i386-linux.elf-entry.bin.dump
2017-06-19 15:49:28 -07:00
John Reiser 650df95b72 Fix thinko in PackMachBase<T>::canUnpack(). Also detect more bad input values.
https://github.com/upx/upx/issues/109
	modified:   p_mach.cpp
2017-06-18 14:24:44 -07:00
John Reiser b2115a4162 i386: clear the stack when leaving (for buggy programs); align esp to 0 mod 8
modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S

	modified:   ../.github/travis_testsuite_1.sh
	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/tmp/i386-linux.elf-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf-fold.map
2017-06-16 21:36:21 -07:00
John Reiser d67bf16a08 i386: Separate PROT_EXEC and PROT_WRITE
Also affects some arm and mips (via sharing i386-linux.elf-main.c)
	modified:   i386-linux.elf-entry.S
	modified:   i386-linux.elf-main.c

	also .h, .map, .dump
2017-06-16 08:17:44 -07:00
John Reiser a4c9b64224 PowerPC: fix ET_EXEC [merge problems?] Next: -pie
modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-main.c

	modified:   stub/powerpc-linux.elf-entry.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/tmp/powerpc-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc-linux.elf-fold.map
2017-06-14 20:00:30 -07:00
John Reiser 8f572e5fe6 Rewrite stubs for 32-bit arm and i386 for -pie (Position-Independent Executable)
Coming next: MIPS and PowerPC.
	modified:   p_lx_elf.cpp
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   ../.github/travis_testsuite_1.sh

	also associated *.h *.map *.dump files
2017-06-14 09:57:19 -07:00
John Reiser e58873044b Remove unused and obsolete macros do_dcache_flush and do_icache_invalidate
modified:   stub/src/arch/arm64/v8/macros.S
2017-06-14 09:35:05 -07:00
John Reiser 8ada92a69f "Drive-by" typo fix
modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/arm64-darwin.macho-entry.h
2017-06-14 09:33:41 -07:00
John Reiser 3c8ed5c000 Fix typo under "#if 0"
modified:   packer.cpp
2017-06-10 22:11:04 -07:00
John Reiser c127d5b64a o_binfo got in the way
modified:   stub/src/i386-linux.elf-entry.S
2017-06-10 14:03:05 -07:00
John Reiser 2d3bd0809a i386-linux.elf-fold.S avoids mmap() into stack
modified:   stub/src/i386-linux.elf-fold.S
	modified:   ../.github/travis_testsuite_1.sh
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/tmp/i386-linux.elf-fold.map
2017-06-09 14:38:08 -07:00
John Reiser eef955a9dd Fix arm.v4a-linux.elf-entry.S
modified:   stub/src/arm.v4a-linux.elf-entry.S

	modified:   stub/arm.v4a-linux.elf-entry.h
	modified:   stub/arm.v5a-linux.elf-entry.h
	modified:   stub/armeb.v4a-linux.elf-entry.h
	modified:   stub/tmp/arm.v4a-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm.v5a-linux.elf-entry.bin.dump
	modified:   stub/tmp/armeb.v4a-linux.elf-entry.bin.dump
	modified:   ../.github/travis_testsuite_1.sh
2017-06-08 20:50:57 -07:00
John Reiser e59ce39dc6 Fix arm64-linux.elf-*
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-main.c

	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/tmp/arm64-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm64-linux.elf-fold.map
2017-06-08 17:23:19 -07:00
John Reiser 62815f5c3c Fix AT_PHDR and AT_ENTRY for amd64-linux.elf (-pie, libmusl)
modified:   stub/src/amd64-linux.elf-main.c

	modified:   ../.github/travis_testsuite_1.sh
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
2017-06-07 09:04:02 -07:00
John Reiser f496010273 Fix reloc of stub for amd64-linux.elf
modified:   stub/src/arm64-linux.elf-main.c

	modified:   stub/arm64-linux.elf-fold.h
	modified:   stub/tmp/arm64-linux.elf-fold.map
2017-06-07 09:01:37 -07:00
John Reiser 143c4e3322 Fix MH_EXECUTE for amd64-darwin.macho
modified:   p_mach.cpp
	modified:   stub/src/amd64-darwin.macho-entry.S

	modified:   stub/amd64-darwin.macho-entry.h
	modified:   stub/tmp/amd64-darwin.macho-entry.bin.dump
2017-06-07 08:58:20 -07:00
John Reiser e7f1e99a5e Merge branch 'jreiser' into devel
O_BINFO simplifies stubs on linux Elf;
PowerPC64 (big endian: Apple Macintosh G5) and PowerPC* cleanup;
-fpie simplification; shlib for arm64, amd64.

A big merge due to suspending activity on 'devel' branch
during stabilization for release of UPX-3.94.
There were intermediate merges with private branch 'jreiser',
and attempted rebase onto 'devel' did not go well.
Verfication of cases ({ET_EXEC, -fpie, shlib} x {$ARCH}) is in progress.

	modified:   ../.github/travis_testsuite_1.sh
	modified:   conf.h
	modified:   linker.cpp
	modified:   linker.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
	modified:   packmast.cpp
	modified:   stub/Makefile
	modified:   stub/scripts/xstrip.py

	modified:   stub/src/amd64-darwin.dylib-entry.S
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arch/powerpc/32/bxx.S
	modified:   stub/src/arch/powerpc/32/lzma_d.S
	modified:   stub/src/arch/powerpc/32/nrv2b_d.S
	modified:   stub/src/arch/powerpc/32/nrv2d_d.S
	modified:   stub/src/arch/powerpc/32/nrv2e_d.S
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
	new file:   stub/src/arch/powerpc/64/Makefile
	new file:   stub/src/arch/powerpc/64/Makefile.extra
	new file:   stub/src/arch/powerpc/64/bxx.S
	new file:   stub/src/arch/powerpc/64/lzma_d.S
	new file:   stub/src/arch/powerpc/64/lzma_d_cf.S
	new file:   stub/src/arch/powerpc/64/lzma_d_cs.S
	new file:   stub/src/arch/powerpc/64/macros.S
	new file:   stub/src/arch/powerpc/64/nrv2b_d.S
	new file:   stub/src/arch/powerpc/64/nrv2d_d.S
	new file:   stub/src/arch/powerpc/64/nrv2e_d.S
	new file:   stub/src/arch/powerpc/64/ppc_regs.h
	modified:   stub/src/arch/powerpc/64le/bxx.S
	copied:     stub/src/arch/powerpc/64le/lzma_d.S -> stub/src/arch/powerpc/64le/lzma_d-common.S
	modified:   stub/src/arch/powerpc/64le/lzma_d.S
	modified:   stub/src/arch/powerpc/64le/lzma_d_cs.S
	modified:   stub/src/arch/powerpc/64le/nrv2b_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2d_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2e_d.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm64-darwin.macho-entry.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/arm64-linux.shlib-init.S
	modified:   stub/src/i386-bsd.elf-entry.S
	modified:   stub/src/i386-darwin.macho-entry.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/mipsel.r3000-linux.elf-entry.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/powerpc-darwin.dylib-entry.S
	modified:   stub/src/powerpc-darwin.macho-entry.S
	modified:   stub/src/powerpc-darwin.macho-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-main.c
	new file:   stub/src/powerpc64-darwin.dylib-entry.S
	new file:   stub/src/powerpc64-darwin.macho-entry.S
	new file:   stub/src/powerpc64-darwin.macho-fold.S
	new file:   stub/src/powerpc64-darwin.macho-main.c
	new file:   stub/src/powerpc64-linux.elf-entry.S
	new file:   stub/src/powerpc64-linux.elf-fold.S
	new file:   stub/src/powerpc64-linux.elf-fold.lds
	new file:   stub/src/powerpc64-linux.elf-main.c
	modified:   stub/src/powerpc64-savegpr0.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-fold.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-main.c

	and most stub/*.h and stub/tmp/*.dump
2017-06-05 11:32:25 -07:00
John Reiser 140a031515 arm64-linux.shlib-init
modified:   p_lx_elf.cpp
	modified:   stub/src/arm64-linux.shlib-init.S

	modified:   stub/arm64-linux.shlib-init.h
	modified:   stub/tmp/arm64-linux.shlib-init.bin.dump
2017-06-04 16:52:43 -07:00
John Reiser b7c91941b8 --android-shlib fix Elf64_Shdr.sh_offset
https://github.com/upx/upx/issues/100
	modified:   ../p_lx_elf.cpp
	modified:   ../p_lx_elf.h
2017-05-31 11:04:56 -07:00
John Reiser 33f0b6da67 Merge branch 'devel' of https://github.com/upx/upx into devel 2017-05-31 10:57:19 -07:00
John Reiser ee18fe9bba DF_1_PIE and calls_crt1() to handle part of -pie,-fPIE
https://github.com/upx/upx/issues/106  [partial]
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-05-31 10:53:55 -07:00
John Reiser a51330cf07 DF_1_PIE and calls_crt1() to handle part of -pie,-fPIE
https://github.com/upx/upx/issues/106  [partial]
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-05-30 13:43:06 -07:00
John Reiser a67aed2744 Merge branch 'devel' of https://github.com/upx/upx into devel 2017-05-30 11:33:39 -07:00
John Reiser d979e19315 fpad8() for --android-shlib in PackLinuxElf64::pack4()
https://github.com/upx/upx/issues/100
	modified:   p_lx_elf.cpp
2017-05-30 11:32:05 -07:00
Markus F.X.J. Oberhumer 4c74d16795 Avoid a compilation warning. clang-format files. 2017-05-28 11:32:12 +02:00
John Reiser 6e541a432f amd64-linux: DF_1_PIE marks a main program; stub juggles AT_PHDR for same
https://github.com/upx/upx/issues/105
	modified:   p_elf_enum.h
	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c

	modified:   ../.github/travis_testsuite_1.sh
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
2017-05-27 19:54:12 -07:00
John Reiser d8f47e248a Handle old style 8-byte headers for version <= 11
https://github.com/upx/upx/issues/102
	modified:   p_unix.cpp
2017-05-26 13:05:12 -07:00
John Reiser d1a869496b More visibility for PackHeader when debug(-D)
modified:   packhead.cpp
	modified:   packmast.cpp
	modified:   pefile.h
2017-05-26 13:02:32 -07:00
John Reiser f42a37555d Merge branch 'devel' of https://github.com/upx/upx into devel 2017-05-21 20:48:05 -07:00
John Reiser d9e019bd87 amd64-darwin.dylib hacking
modified:   stub/src/amd64-darwin.dylib-entry.S

	modified:   stub/amd64-darwin.dylib-entry.h
	modified:   stub/tmp/amd64-darwin.dylib-entry.bin.dump
2017-05-17 21:36:40 -07:00
John Reiser ce194fa5d8 amd64-darwin.dylib hacking
modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   p_mach_enum.h
	modified:   stub/src/amd64-darwin.dylib-entry.S

	modified:   stub/amd64-darwin.dylib-entry.h
	modified:   stub/tmp/amd64-darwin.dylib-entry.bin.dump
2017-05-17 15:50:34 -07:00
Markus F.X.J. Oberhumer b5bdf57636 Minor cleanups. 2017-05-14 19:21:04 +02:00
Markus F.X.J. Oberhumer a3a81ce7c6 Update NEWS. 2017-05-13 20:44:02 +02:00
Markus F.X.J. Oberhumer 61f347401c Update testsuite checksums caused by version bump. 2017-05-12 15:35:24 +02:00
Markus F.X.J. Oberhumer d985a4c250 Post-release version bump. 2017-05-12 15:28:47 +02:00
John Reiser 8eabb9b02f i386 recover from merge
modified:   p_lx_elf.cpp
2017-05-08 18:54:41 -07:00
John Reiser 8a195a0b35 amd64 recover from merge
modified:   stub/src/amd64-linux.elf-fold.S

	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
2017-05-08 16:06:02 -07:00
John Reiser 955206aaf0 Merge branch 'devel' into jreiser
Conflicts:
	src/p_lx_elf.cpp
	src/stub/src/amd64-linux.elf-entry.S
	src/stub/src/amd64-linux.elf-main.c
	src/stub/src/arm.v4a-linux.elf-entry.S
	src/stub/src/arm.v4a-linux.elf-fold.S
	src/stub/src/arm64-linux.elf-entry.S
	src/stub/src/arm64-linux.elf-fold.S
	src/stub/src/i386-linux.elf-fold.S
	src/stub/src/powerpc-darwin.macho-entry.S
	src/stub/src/powerpc-linux.elf-fold.S
	src/stub/src/powerpc64le-darwin.macho-entry.S
	src/stub/src/powerpc64le-linux.elf-entry.S
	src/stub/src/powerpc64le-linux.elf-fold.S
	src/stub/src/powerpc64le-linux.elf-main.c

 Changes to be committed:
	modified:   ../.github/ISSUE_TEMPLATE.md
	modified:   ../.github/travis_build.sh
	modified:   ../.github/travis_deploy.sh
	modified:   ../.github/travis_init.sh
	modified:   ../.github/travis_testsuite_1.sh
	modified:   ../.gitignore
	modified:   ../.travis.yml
	modified:   ../NEWS
	modified:   c_screen.cpp
	modified:   file.cpp
	modified:   help.cpp
	modified:   linker.cpp
	modified:   main.cpp
	modified:   p_lx_elf.cpp
	modified:   packer.cpp
	modified:   s_djgpp2.cpp
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/arm64-linux.elf-fold.S
	modified:   stub/src/i386-linux.elf-main.c
	modified:   stub/src/powerpc-darwin.dylib-entry.S
	modified:   stub/src/powerpc-darwin.macho-entry.S
	modified:   stub/src/powerpc-darwin.macho-fold.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-fold.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-main.c
	modified:   ui.cpp
	modified:   util.cpp
	modified:   work.cpp
	[plus *.h, *.dump, *.map]
2017-05-08 14:21:31 -07:00
John Reiser 082dd7d5ee arm64 TRACE improvement
modified:   stub/src/arm64-linux.elf-entry.S

	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/tmp/arm64-linux.elf-entry.bin.dump
2017-05-07 12:07:51 -07:00
John Reiser 90714cf624 arm64 tracing in stub
modified:   ../../linker.cpp
	modified:   ../../p_lx_elf.cpp
	modified:   arm64-linux.elf-entry.S
2017-05-06 19:37:37 -07:00
John Reiser 6e2a41cb26 DPRINTF for amd64
modified:   Makefile
	modified:   src/amd64-linux.elf-fold.S
	modified:   src/amd64-linux.elf-main.c

	modified:   amd64-linux.elf-fold.h
	modified:   tmp/amd64-linux.elf-fold.map
2017-05-05 13:32:42 -07:00
John Reiser fe4a8f33b1 Start on darwin.macho-dylib
modified:   p_mach.cpp
	modified:   p_mach.h
	modified:   packmast.cpp
2017-05-03 08:30:21 -07:00
John Reiser 391f511094 powerpc-linux.elf-fold.S and -main.c handle /proc/self/exe
modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-main.c

	modified:   stub/tmp/amd64-linux.elf-fold.map
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/powerpc-linux.elf-entry.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/tmp/powerpc-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc-linux.elf-fold.map
2017-04-22 20:18:00 -07:00
John Reiser 9df4b6ea24 Sync SZ_FRAME with devel branch
modified:   src/arch/powerpc/32/ppc_regs.h
	modified:   src/arch/powerpc/64le/ppc_regs.h
	modified:   src/powerpc64le-linux.elf-entry.S
	modified:   src/powerpc64le-linux.elf-fold.S
2017-04-21 10:54:04 -07:00
John Reiser c4a921283a Revamp powerpc{,64le,64}.
Fix 64-bit stack frame (8*8 bytes for spilling a0-a7).  Avoid using r2 (t0).
Prepare for -pie executables.  Prepare for unified strategy in stubs.

	modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-main.c
	modified:   stub/src/arch/powerpc/32/bxx.S
	modified:   stub/src/arch/powerpc/32/lzma_d.S
	modified:   stub/src/arch/powerpc/32/nrv2b_d.S
	modified:   stub/src/arch/powerpc/32/nrv2d_d.S
	modified:   stub/src/arch/powerpc/32/nrv2e_d.S
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
	new file:   stub/src/arch/powerpc/64/Makefile
	new file:   stub/src/arch/powerpc/64/Makefile.extra
	new file:   stub/src/arch/powerpc/64/lzma_d.S
	new file:   stub/src/arch/powerpc/64/lzma_d_cf.S
	new file:   stub/src/arch/powerpc/64/lzma_d_cs.S
	modified:   stub/src/arch/powerpc/64le/bxx.S
	copied:     stub/src/arch/powerpc/64le/lzma_d.S -> stub/src/arch/powerpc/64le/lzma_d-common.S
	modified:   stub/src/arch/powerpc/64le/lzma_d.S
	modified:   stub/src/arch/powerpc/64le/lzma_d_cs.S
	modified:   stub/src/arch/powerpc/64le/nrv2b_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2d_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2e_d.S
	modified:   stub/src/arch/powerpc/64le/ppc_regs.h
	modified:   stub/src/i386-darwin.macho-entry.S
	modified:   stub/src/powerpc-darwin.dylib-entry.S
	modified:   stub/src/powerpc-darwin.macho-entry.S
	modified:   stub/src/powerpc-darwin.macho-fold.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-main.c
	modified:   stub/src/powerpc64-darwin.dylib-entry.S
	modified:   stub/src/powerpc64-darwin.macho-entry.S
	modified:   stub/src/powerpc64-darwin.macho-fold.S
	modified:   stub/src/powerpc64-darwin.macho-main.c
	modified:   stub/src/powerpc64-linux.elf-main.c
	modified:   stub/src/powerpc64-savegpr0.S
	modified:   stub/src/powerpc64le-darwin.dylib-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-darwin.macho-fold.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S

	modified:   stub/i386-darwin.macho-entry.h
	modified:   stub/powerpc-darwin.dylib-entry.h
	modified:   stub/powerpc-darwin.macho-entry.h
	modified:   stub/powerpc-darwin.macho-fold.h
	modified:   stub/powerpc-linux.elf-entry.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/powerpc-linux.kernel.vmlinux.h
	modified:   stub/powerpc64-linux.elf-entry.h
	modified:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-darwin.dylib-entry.h
	modified:   stub/powerpc64le-darwin.macho-entry.h
	modified:   stub/powerpc64le-darwin.macho-fold.h
	modified:   stub/powerpc64le-linux.elf-entry.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.kernel.vmlinux.h
	modified:   stub/tmp/i386-darwin.macho-entry.bin.dump
	modified:   stub/tmp/powerpc-darwin.dylib-entry.bin.dump
	modified:   stub/tmp/powerpc-darwin.macho-entry.bin.dump
	modified:   stub/tmp/powerpc-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-darwin.dylib-entry.bin.dump
	modified:   stub/tmp/powerpc64le-darwin.macho-entry.bin.dump
	modified:   stub/tmp/powerpc64le-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-linux.kernel.vmlinux.bin.dump
2017-04-19 19:25:05 -07:00
John Reiser 4e05f087f9 PowerPC 64-bit big-endian
modified:   conf.h
	modified:   linker.cpp
	modified:   linker.h
	modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
	modified:   packmast.cpp
	modified:   stub/Makefile
	modified:   stub/powerpc-linux.elf-entry.h
	new file:   stub/powerpc64-linux.elf-entry.h
	new file:   stub/powerpc64-linux.elf-fold.h
	modified:   stub/powerpc64le-linux.elf-entry.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/scripts/xstrip.py
	modified:   stub/src/arch/powerpc/64le/nrv2b_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2d_d.S
	modified:   stub/src/arch/powerpc/64le/nrv2e_d.S
	new file:   stub/src/powerpc64-darwin.dylib-entry.S
	new file:   stub/src/powerpc64-darwin.macho-entry.S
	new file:   stub/src/powerpc64-darwin.macho-fold.S
	new file:   stub/src/powerpc64-darwin.macho-main.c
	new file:   stub/src/powerpc64-linux.elf-entry.S
	new file:   stub/src/powerpc64-linux.elf-fold.S
	new file:   stub/src/powerpc64-linux.elf-fold.lds
	new file:   stub/src/powerpc64-linux.elf-main.c
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-main.c
	modified:   stub/tmp/powerpc64le-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2017-04-11 19:15:43 -07:00
John Reiser 40b506d2e0 Sync arm* stubs
modified:   ../arm.v4a-linux.elf-entry.h
	modified:   ../arm.v4a-linux.elf-fold.h
	modified:   ../arm.v5a-linux.elf-entry.h
	modified:   ../arm.v5a-linux.elf-fold.h
	modified:   ../arm64-darwin.macho-entry.h
	modified:   ../arm64-linux.elf-entry.h
	modified:   ../arm64-linux.elf-fold.h
	modified:   ../armeb.v4a-linux.elf-entry.h
	modified:   ../armeb.v4a-linux.elf-fold.h
	modified:   ../tmp/arm.v4a-linux.elf-entry.bin.dump
	modified:   ../tmp/arm.v4a-linux.elf-fold.map
	modified:   ../tmp/arm.v5a-linux.elf-entry.bin.dump
	modified:   ../tmp/arm.v5a-linux.elf-fold.map
	modified:   ../tmp/arm64-darwin.macho-entry.bin.dump
	modified:   ../tmp/arm64-linux.elf-entry.bin.dump
	modified:   ../tmp/armeb.v4a-linux.elf-entry.bin.dump
	modified:   ../tmp/armeb.v4a-linux.elf-fold.map
2017-04-11 19:13:11 -07:00
John Reiser 263f384810 o_binfo
modified:   arm64-darwin.macho-entry.S
2017-04-11 19:07:38 -07:00
John Reiser d80c145a18 PROT_EXEC for decompressed 'fold'
modified:   powerpc-linux.elf-entry.S
2017-04-10 15:36:43 -07:00
John Reiser 7a681bd20d Use saved registers for parameters to 'fold'; lzma can clobber others
modified:   arm64-linux.elf-entry.S
	modified:   arm64-linux.elf-fold.S
2017-04-09 21:33:29 -07:00
John Reiser ed31fb184b Replace crumb with b_info
modified:   stub/src/arm.v4a-linux.elf-entry.S
	modified:   stub/src/arm.v4a-linux.elf-fold.S
2017-04-09 18:06:16 -07:00
John Reiser 360b94dd6c i386-linux ET_EXEC working
modified:   stub/src/i386-linux.elf-fold.S

	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/tmp/i386-linux.elf-fold.map
2017-04-07 16:08:13 -07:00
John Reiser 8524e73f59 Always a 1-page crumb for i386
modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S

	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/tmp/i386-linux.elf-entry.bin.dump
2017-04-07 11:17:01 -07:00
John Reiser a4e47625ac Sync stubs
modified:   stub/arm64-darwin.macho-entry.h
	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/arm64-linux.shlib-init.h
	modified:   stub/tmp/arm64-darwin.macho-entry.bin.dump
	modified:   stub/tmp/arm64-linux.elf-entry.bin.dump
	modified:   stub/tmp/arm64-linux.shlib-init.bin.dump
2017-04-07 08:23:30 -07:00
John Reiser 7c16872a6e Merge branch 'devel' into jreiser 2017-04-07 08:22:08 -07:00
John Reiser 8bca8629be Preserve symlink /proc/self/exe by mapping one page into the stack.
modified:   stub/src/amd64-linux.elf-fold.S

	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-fold.map
2017-04-06 23:08:35 -07:00
John Reiser 85fdd579d6 Cleanup PackLinuxElf64amd::defineSymbols(): use is_pie; reduce symbols
modified:   p_lx_elf.cpp
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S

	modified:   stub/amd64-linux.elf-entry.h
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/tmp/amd64-linux.elf-entry.bin.dump
	modified:   stub/tmp/amd64-linux.elf-fold.map
2017-04-06 17:22:30 -07:00
John Reiser e88d2ff88c Merge branch 'devel' into jreiser
modified:   ../.appveyor.yml
	modified:   ../.github/travis_build.sh
	modified:   Makefile
	modified:   linker.cpp
	modified:   p_lx_elf.cpp
	modified:   packmast.cpp
2017-04-06 14:25:14 -07:00
John Reiser bdf08baebd O_BINFO
modified:   stub/amd64-darwin.macho-entry.h
	modified:   stub/amd64-linux.elf-entry.h
	modified:   stub/amd64-linux.elf-fold.h
	modified:   stub/arm64-linux.elf-entry.h
	modified:   stub/i386-bsd.elf-entry.h
	modified:   stub/i386-darwin.macho-entry.h
	modified:   stub/i386-linux.elf-entry.h
	modified:   stub/i386-linux.elf-fold.h
	modified:   stub/i386-netbsd.elf-entry.h
	modified:   stub/mips.r3000-linux.elf-fold.h
	modified:   stub/mipsel.r3000-linux.elf-fold.h
	modified:   stub/powerpc-darwin.macho-entry.h
	modified:   stub/powerpc-linux.elf-entry.h
	modified:   stub/powerpc-linux.elf-fold.h
	modified:   stub/powerpc64le-darwin.macho-entry.h
	modified:   stub/powerpc64le-linux.elf-entry.h
	modified:   stub/powerpc64le-linux.elf-fold.h
	modified:   stub/src/amd64-darwin.macho-entry.S
	modified:   stub/src/amd64-linux.elf-entry.S
	modified:   stub/src/amd64-linux.elf-fold.S
	modified:   stub/src/arch/powerpc/32/ppc_regs.h
	modified:   stub/src/arm64-linux.elf-entry.S
	modified:   stub/src/i386-bsd.elf-entry.S
	modified:   stub/src/i386-darwin.macho-entry.S
	modified:   stub/src/i386-linux.elf-entry.S
	modified:   stub/src/i386-linux.elf-fold.S
	modified:   stub/src/mipsel.r3000-linux.elf-fold.S
	modified:   stub/src/powerpc-darwin.macho-entry.S
	modified:   stub/src/powerpc-linux.elf-entry.S
	modified:   stub/src/powerpc-linux.elf-fold.S
	modified:   stub/src/powerpc-linux.elf-main.c
	modified:   stub/src/powerpc64le-darwin.macho-entry.S
	modified:   stub/src/powerpc64le-linux.elf-entry.S
	modified:   stub/src/powerpc64le-linux.elf-fold.S
	modified:   stub/src/powerpc64le-linux.elf-main.c
	modified:   stub/tmp/amd64-darwin.macho-entry.bin.dump
	modified:   stub/tmp/amd64-linux.elf-entry.bin.dump
	modified:   stub/tmp/amd64-linux.elf-fold.map
	modified:   stub/tmp/arm64-linux.elf-entry.bin.dump
	modified:   stub/tmp/i386-bsd.elf-entry.bin.dump
	modified:   stub/tmp/i386-darwin.macho-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf-entry.bin.dump
	modified:   stub/tmp/i386-linux.elf-fold.map
	modified:   stub/tmp/i386-netbsd.elf-entry.bin.dump
	modified:   stub/tmp/powerpc-darwin.macho-entry.bin.dump
	modified:   stub/tmp/powerpc-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc-linux.elf-fold.map
	modified:   stub/tmp/powerpc64le-darwin.macho-entry.bin.dump
	modified:   stub/tmp/powerpc64le-linux.elf-entry.bin.dump
	modified:   stub/tmp/powerpc64le-linux.elf-fold.map
2017-04-06 14:22:47 -07:00
John Reiser 3dcdd25177 re-work -fpie for amd64
modified:   stub/src/amd64-linux.elf-main.c
2017-04-06 14:22:05 -07:00
John Reiser 491e8640b2 is_pie; O_BINFO; remove LUNMP000, LUNMP001
modified:   p_lx_elf.cpp
	modified:   p_lx_elf.h
2017-04-06 14:15:07 -07:00
John Reiser b23b7ef85e DT_FLAGS_1, DF_1_PIE
modified:   p_elf_enum.h
2017-04-06 14:13:02 -07:00
John Reiser b167374f13 R_PPC64_ADDR32
modified:   linker.cpp
2017-04-06 14:12:29 -07:00
542 changed files with 59146 additions and 48071 deletions
-109
View File
@@ -1,109 +0,0 @@
# Support for AppVeyor CI -- https://www.appveyor.com/
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
os: Visual Studio 2015
environment:
global: { TRAVIS_OS_NAME: windows, CROSS: "", C: "", B: release, T: "", X: "" }
matrix:
- { C: msvc-10.0-x86, CL_VERSION: 16.00, VS_VERSION: 2010 }
### - { C: msvc-10.0-x64, CL_VERSION: 16.00, VS_VERSION: 2010 } # AppVeyor: x64 compiler is not installed
- { C: msvc-11.0-x86, CL_VERSION: 17.00, VS_VERSION: 2012 }
### - { C: msvc-11.0-x64, CL_VERSION: 17.00, VS_VERSION: 2012 } # AppVeyor: x64 compiler is not installed
- { C: msvc-12.0-x86, CL_VERSION: 18.00, VS_VERSION: 2013 }
- { C: msvc-12.0-x64, CL_VERSION: 18.00, VS_VERSION: 2013 }
- { C: msvc-14.0-x86, CL_VERSION: 19.00, VS_VERSION: 2015 }
- { C: msvc-14.0-x64, CL_VERSION: 19.00, VS_VERSION: 2015 }
- { C: msvc-15.0-x86, CL_VERSION: 19.10, VS_VERSION: 2017, APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 }
- { C: msvc-15.0-x64, CL_VERSION: 19.10, VS_VERSION: 2017, APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 }
# - { C: gcc-4.9-m32, T: SKIP }
# - { C: gcc-4.9-m64, T: SKIP }
UPX_AUTOMATIC_BUILDS_SSL_KEY:
secure: PZMpVeqnEYe39kK+Zu2/fnmZ6/HG6Lvls0hh9GMVU9vCWsr8xaU7kIbHBS01puUkb4bEWPILKYvSEDuhOhguDjd/P4QdXWipvV/F2GaVax0=
UPX_AUTOMATIC_BUILDS_SSL_IV:
secure: ZshjJ/78dbY60mVJjZJv9Si7rHY9VQb1tfQvFd4lqvY=
init:
- git config --global core.autocrlf input
- where bash & where cat & where chmod & where cmp & where cp & where curl & where date & where file & where git & where gzip & where mkdir & where mv & where openssl & where readlink & where rm & where rmdir & where sed & where sha256sum & where sort & where ssh & where ssh-add & where ssh-agent & where ssh-keyscan & where tar
# - bash --version & git --version & sed --version & tar --version
- git --version & bash --version
# - dir "c:\Program Files\Git\usr\bin"
# - dir "c:\cygwin\bin"
# - dir "c:\mingw\bin"
# - dir "c:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin"
install:
- cd c:\projects
- md build build\%C% deps
- cd c:\projects\upx
- git submodule update --init --recursive
- cd c:\projects\deps
- curl -q -L --retry 5 -o ucl-1.03.tar.gz "https://github.com/upx/upx/releases/download/v3.00/ucl-1.03.tar.gz"
- curl -q -L --retry 5 -o zlib-1.2.8.tar.gz "https://github.com/upx/upx/releases/download/v3.00/zlib-1.2.8.tar.gz"
- git clone https://github.com/upx/upx-testsuite
- tar -xzf ucl-1.03.tar.gz
- tar -xzf zlib-1.2.8.tar.gz
# patch UCL for msvc-14.0 (vsnprintf issue)
- sed -i '/# *define.*snprintf *_v*snprintf$/d' ucl-1.03/acc/acc_auto.h
##- curl -q -L --retry 5 -o config.guess "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD"
##- curl -q -L --retry 5 -o config.sub "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD"
##- cp config.guess config.sub ucl-1.03/acconfig/
# setup compiler
- if "%C%"=="msvc-10.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 )
- if "%C%"=="msvc-10.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" amd64 )
- if "%C%"=="msvc-11.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" x86 )
- if "%C%"=="msvc-11.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat" amd64 )
- if "%C%"=="msvc-12.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x86 )
- if "%C%"=="msvc-12.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 )
- if "%C%"=="msvc-14.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 )
- if "%C%"=="msvc-14.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64 )
- if "%C%"=="msvc-15.0-x86" ( call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86 )
- if "%C%"=="msvc-15.0-x64" ( call "c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64 )
build_script:
- cd c:\projects\upx
- if "%C%"=="gcc-4.9-m32" set PATH=c:\cygwin\bin;%PATH%
- if "%C%"=="gcc-4.9-m32" bash -x ./.github/travis_build.sh
- if "%C%"=="gcc-4.9-m32" exit
- if "%C%"=="gcc-4.9-m64" set PATH=c:\cygwin\bin;%PATH%
- if "%C%"=="gcc-4.9-m64" bash -x ./.github/travis_build.sh
- if "%C%"=="gcc-4.9-m64" exit
# setup directories following the VPATH build in travis_build.sh
- where cl & where link
- set BDIR=c:\projects\build\%C%\%B%
- md %BDIR% %BDIR%\ucl-1.03 %BDIR%\upx %BDIR%\upx-testsuite %BDIR%\zlib-1.2.8
- set DEFS=-D_CRT_SECURE_NO_WARNINGS
- git rev-parse --short=12 HEAD > %BDIR%\upx\.GITREV.txt
# build UCL
- cd %BDIR%\ucl-1.03
- set s=c:\projects\deps\ucl-1.03
- cl -MT -O2 -W4 %DEFS% -I%s%\include -I%s% -c %s%\src\*.c
- link -lib -out:ucl.lib *.obj
# build zlib
- cd %BDIR%\zlib-1.2.8
- cl -MT -O2 -W2 %DEFS% -c c:\projects\deps\zlib-1.2.8\*.c
- link -lib -out:zlib.lib *.obj
# build UPX
- cd %BDIR%\upx
- set s=c:\projects\upx\src
- cat .GITREV.txt
- set /p GITREV=<.GITREV.txt
- cl -MT -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -DWITH_LZMA=0x443 -DUCL_NO_ASM -I%s%\lzma-sdk -Ic:\projects\deps\ucl-1.03\include -Ic:\projects\deps\zlib-1.2.8 -Feupx.exe %s%\*.cpp %BDIR%\ucl-1.03\ucl.lib %BDIR%\zlib-1.2.8\zlib.lib
test_script:
- set UPX=--no-color --no-progress
- cd %BDIR%\upx
# basic tests
- .\upx.exe --version
- .\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
# now run the UPX testsuite using bash
- cd c:\projects\upx
- bash ./.github/travis_testsuite_1.sh
- bash ./.github/travis_deploy.sh
# vim:set ts=2 sw=2 et:
+28
View File
@@ -0,0 +1,28 @@
# "Gofmt's style is nobody's favourite, but gofmt is everybody's favourite." --Rob Pike
#
# for clang-format-10.0.1 from https://github.com/upx/upx-stubtools/releases
---
BasedOnStyle: LLVM
AccessModifierOffset: -4
#AlignConsecutiveAssignments: true
AlwaysBreakTemplateDeclarations: true
ColumnLimit: 100
IndentWidth: 4
SortIncludes: false
SpaceAfterCStyleCast: true
Standard: Cpp03
StatementMacros: [
ACCCHK_ASSERT,
ACCCHK_ASSERT_IS_SIGNED_T,
ACCCHK_ASSERT_IS_UNSIGNED_T,
ACCCHK_ASSERT_SIGN_T,
ACC_COMPILE_TIME_ASSERT,
ACC_COMPILE_TIME_ASSERT_HEADER,
ACC_CXX_DISABLE_NEW_DELETE,
ACC_CXX_TRIGGER_FUNCTION,
ACC_CXX_TRIGGER_FUNCTION_IMPL,
CLANG_FORMAT_DUMMY_STATEMENT,
COMPILE_TIME_ASSERT,
COMPILE_TIME_ASSERT_ALIGNED1,
]
...
+3 -3
View File
@@ -1,6 +1,6 @@
#
# see http://editorconfig.org/
#
# see https://editorconfig.org/
root = true
[*]
charset = utf-8
+10
View File
@@ -0,0 +1,10 @@
# make GitHub language detection more accurate, see https://github.com/github/linguist
src/*.h linguist-language=C++
src/*/*.h linguist-language=C++
src/stub/**/*.ash linguist-language=Assembly
src/stub/**/*.asm linguist-language=Assembly
src/stub/**/*.S linguist-language=Assembly
src/stub/tmp/** linguist-vendored
@@ -1,3 +1,15 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
This issue tracker is **ONLY** used for reporting bugs.
Please use [stackoverflow](https://stackoverflow.com) for supporting issues.
<!---
IF YOU REMOVE THIS TEMPLATE WE WILL CLOSE YOUR ISSUE WITHOUT RESPONSE.
+1
View File
@@ -0,0 +1 @@
blank_issues_enabled: false
+45
View File
@@ -0,0 +1,45 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
This issue tracker is **ONLY** used for requesting sensible features.
Please use [stackoverflow](https://stackoverflow.com) for supporting issues.
<!---
IF YOU REMOVE THIS TEMPLATE WE WILL CLOSE YOUR ISSUE WITHOUT RESPONSE.
Just read it and fill in the details we're asking, it saves so much of our time. Thanks!
-->
## What's the problem (or question)?
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
## What should have happened?
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
## Do you have an idea for a solution?
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
## How can we reproduce the issue?
<!--- Provide unambiguous set of steps to reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.
## Please tell us details about your environment.
<!--- Include as many relevant details about the environment you experienced the bug in -->
* UPX version used (`upx --version`):
* Host Operating System and version:
* Host CPU architecture:
* Target Operating System and version:
* Target CPU architecture:
+8
View File
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
# Check for updates to GitHub Actions every weekday
interval: 'daily'
+14
View File
@@ -0,0 +1,14 @@
UPX PULL REQUEST NOTES
======================
Handling pull requests is actually quite time consuming, so please
- if you want to contribute **a real C++ code bug-fix** then open an issue
on the main UPX issue tracker first
- if you want to contribute **a new feature** then by all means open an issue
on the main UPX issue tracker first before starting any coding!
- please refuse the temptation to "improve" the docs, scripts, CI, makefiles,
cmake build system, spelling errors, etc - we will NOT merge this; only open
an issue if you're sure there is a **real bug**
+15
View File
@@ -0,0 +1,15 @@
# Security Context
IMPORTANT NOTE: UPX inherits the security context of any files it handles.
This means that packing, unpacking, or even testing or listing a file requires
the same security considerations as actually executing the file.
Use UPX on trusted files only!
## Supported Versions
| Version | Supported |
| --------- | ------------------ |
| git HEAD | :white_check_mark: |
| any other | :x: |
+8 -84
View File
@@ -2,9 +2,10 @@
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
# ...lots of outdated/unneeded stuff from the old Travis/Circle/AppVeyor CI days...
if [[ $TRAVIS_OS_NAME == osx ]]; then
argv0=$0; argv0abs=$(greadlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
else
@@ -15,7 +16,7 @@ source "$argv0dir/travis_init.sh" || exit 1
# create dirs
cd / || exit 1
mkbuilddirs $upx_BUILDDIR $ucl_BUILDDIR $upx_testsuite_BUILDDIR $zlib_BUILDDIR
cd / && cd $upx_SRCDIR || exit 1
cd / && cd "$upx_SRCDIR" || exit 1
echo
print_settings
@@ -28,7 +29,7 @@ echo
if [[ $TRAVIS_OS_NAME == linux ]]; then
cd / && cd $upx_SRCDIR || exit 1
echo "Checking source code for whitespace violations..."
bash ./src/stub/scripts/check_whitespace.sh || exit 1
bash ./misc/scripts/check_whitespace.sh || exit 1
echo " Passed."
fi # linux
@@ -44,9 +45,9 @@ if [[ $BM_X =~ (^|\+)rebuild-stubs($|\+) ]]; then
elif [[ -f "$HOME/.local/bin/bin-upx/upx-stubtools-check-version" ]]; then
bin_upx=$(readlink -en -- "$HOME/.local/bin/bin-upx")
else
bin_upx=$(readlink -en -- "$upx_SRCDIR/../deps/bin-upx-20160918")
bin_upx=$(readlink -en -- "$upx_SRCDIR/../deps/bin-upx-20210104")
fi
cd / && cd $upx_SRCDIR || exit 1
cd / && cd "$upx_SRCDIR" || exit 1
extra_subdirs=()
extra_subdirs+=( src/stub/src/arch/amd64 )
extra_subdirs+=( src/stub/src/arch/arm/v4a )
@@ -57,6 +58,7 @@ if [[ $BM_X =~ (^|\+)rebuild-stubs($|\+) ]]; then
extra_subdirs+=( src/stub/src/arch/m68k/m68020 )
extra_subdirs+=( src/stub/src/arch/mips/r3000 )
extra_subdirs+=( src/stub/src/arch/powerpc/32 )
extra_subdirs+=( src/stub/src/arch/powerpc/64 )
extra_subdirs+=( src/stub/src/arch/powerpc/64le )
make -C src/stub maintainer-clean
for d in ${extra_subdirs[@]}; do
@@ -88,82 +90,4 @@ if [[ $BM_X =~ (^|\+)rebuild-stubs($|\+) ]]; then
unset bin_upx extra_subdirs d failed
fi
#
# build UCL
#
cd / && cd $ucl_BUILDDIR || exit 1
# patch UCL
sed 's/^#elif (ACC_ARCH_AMD64 || ACC_ARCH_IA64)$/& \&\& !defined(__ILP32__)/' $ucl_SRCDIR/acc/acc_chk.ch > a.tmp
if cmp -s a.tmp $ucl_SRCDIR/acc/acc_chk.ch; then rm a.tmp; else mv a.tmp $ucl_SRCDIR/acc/acc_chk.ch; fi
if [[ $BUILD_LOCAL_UCL == 1 ]]; then
# ucl-1.03/configure is too old - build manually
rm -f ./*.o libucl.a
$CC -O2 -I$ucl_SRCDIR/include -I$ucl_SRCDIR -c $ucl_SRCDIR/src/*.c
$AR rcs libucl.a *.o
mkdir -p src/.libs
cp libucl.a src/.libs
else
if [[ ! -f config.status ]]; then
$ucl_SRCDIR/configure --enable-static --disable-shared --disable-asm
fi
make
fi
#
# build zlib
#
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
cd / && cd $zlib_BUILDDIR || exit 1
# build manually
rm -f ./*.o libz.a
$CC -O2 -c $zlib_SRCDIR/*.c
$AR rcs libz.a *.o
fi
#
# build UPX
#
export UPX_UCLDIR="$ucl_SRCDIR"
cd / && cd $upx_BUILDDIR || exit 1
make="make -f $upx_SRCDIR/src/Makefile"
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DUCL_NO_ASM"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$ucl_BUILDDIR/src/.libs"
if [[ $BUILD_LOCAL_ZLIB == 1 ]]; then
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -I$zlib_SRCDIR"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -L$zlib_BUILDDIR"
fi
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then
EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -fprofile-arcs -ftest-coverage"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
fi
if [[ $BM_B =~ (^|\+)debug($|\+) ]]; then
make="$make BUILD_TYPE_DEBUG=1"
fi
if [[ $BM_B =~ (^|\+)sanitize($|\+) ]]; then
case $TRAVIS_OS_NAME-$CC in linux-gcc*) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fuse-ld=gold" ;; esac
make="$make BUILD_TYPE_SANITIZE=1"
fi
if [[ $BM_B =~ (^|\+)scan-build($|\+) ]]; then
make="$SCAN_BUILD $make"
fi
if [[ $BM_B =~ (^|\+)valgrind($|\+) ]]; then
EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS -DWITH_VALGRIND"
fi
if [[ $BM_B =~ (^|\+)ALLOW_FAIL($|\+) ]]; then
echo "ALLOW_FAIL"
set +e
fi
export EXTRA_CPPFLAGS EXTRA_CXXFLAGS EXTRA_LDFLAGS
[[ -z $upx_exeext ]] && upx_exeext=.out
$make exeext=$upx_exeext
pwd
ls -l upx${upx_exeext}
$SIZE upx${upx_exeext} || true
file upx${upx_exeext}
exit 0
exit 1
-194
View File
@@ -1,194 +0,0 @@
#! /bin/bash
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
if [[ $TRAVIS_OS_NAME == osx ]]; then
argv0=$0; argv0abs=$(greadlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
else
argv0=$0; argv0abs=$(readlink -en -- "$0"); argv0dir=$(dirname "$argv0abs")
fi
source "$argv0dir/travis_init.sh" || exit 1
set -x # debug
if [[ $BM_X == rebuild-stubs ]]; then exit 0; fi
# save space
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then exit 0; fi
if [[ $BM_B =~ (^|\+)debug($|\+) ]]; then exit 0; fi
if [[ $BM_B =~ (^|\+)sanitize($|\+) ]]; then exit 0; fi
if [[ $BM_B =~ (^|\+)scan-build($|\+) ]]; then exit 0; fi
if [[ $BM_B =~ (^|\+)valgrind($|\+) ]]; then exit 0; fi
# prepare $subdir and $branch
subdir=
branch=
if [[ -n $APPVEYOR_JOB_ID ]]; then
branch=$APPVEYOR_REPO_BRANCH
if [[ -n $APPVEYOR_PULL_REQUEST_NUMBER ]]; then exit 0; fi
elif [[ -n $GITLAB_CI ]]; then
subdir=$CI_BUILD_NAME
branch=$CI_BUILD_REF_NAME
else
branch=$TRAVIS_BRANCH
if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then exit 0; fi
fi
subdir=${subdir%%:*}; subdir=${subdir%%/*}; subdir=${subdir%%--*}
case $branch in
devel*) ;;
gitlab*) ;;
master*) ;;
travis*) ;;
*) exit 0;;
esac
# get $rev, $branch and $git_user
cd / && cd $upx_SRCDIR || exit 1
rev=$(git rev-parse --verify HEAD)
if [[ "$branch" == gitlab* ]]; then
if git fetch -v origin devel; then
git branch -a -v
rev=$(git merge-base origin/devel $rev || echo $rev)
fi
fi
timestamp=$(git log -n1 --format='%at' $rev)
date=$(TZ=UTC0 date -d "@$timestamp" '+%Y%m%d-%H%M%S')
#branch="$branch-$date-${rev:0:6}"
# make the branch name a little bit shorter so that it looks nice on GitHub
branch="$branch-${date:0:8}-${rev:0:7}"
if [[ -n $APPVEYOR_JOB_ID ]]; then
branch="$branch-appveyor"
git_user="AppVeyor CI"
elif [[ -n $GITLAB_CI ]]; then
branch="$branch-gitlab"
git_user="GitLab CI"
else
branch="$branch-travis"
git_user="Travis CI"
fi
unset timestamp date
# /***********************************************************************
# // prepare directory $d
# ************************************************************************/
cd / && cd $upx_BUILDDIR || exit 1
mkdir deploy || exit 1
chmod 700 deploy
cd deploy || exit 1
if [[ -n $BM_CROSS ]]; then
d=$BM_CROSS
else
cpu=unknown
case $BM_C in
clang*-m32 | gcc*-m32) cpu=i386;;
clang*-m64 | gcc*-m64) cpu=amd64;;
clang*-mx32 | gcc*-mx32) cpu=amd64;;
msvc*-x86) cpu=i386;;
msvc*-x64) cpu=amd64;;
esac
os=$TRAVIS_OS_NAME
if [[ $os == osx ]]; then
os=darwin
elif [[ $os == windows ]]; then
[[ $cpu == i386 ]] && os=win32
[[ $cpu == amd64 ]] && os=win64
fi
d=$cpu-$os
fi
d=$d-$BM_C-$BM_B
if [[ -n $subdir ]]; then
print_header "DEPLOY $subdir/$d"
else
print_header "DEPLOY $d"
fi
mkdir $d || exit 1
for exeext in .exe .out; do
f=$upx_BUILDDIR/upx$exeext
if [[ -f $f ]]; then
cp -p -i $f $d/upx-git-${rev:0:12}$exeext
sha256sum -b $d/upx-git-${rev:0:12}$exeext
fi
done
# /***********************************************************************
# // clone, add files & push
# ************************************************************************/
new_branch=0
if ! git clone -b "$branch" --single-branch https://github.com/upx/upx-automatic-builds.git; then
git clone -b master --single-branch https://github.com/upx/upx-automatic-builds.git
new_branch=1
fi
cd upx-automatic-builds || exit 1
chmod 700 .git
git config user.name "$git_user"
git config user.email "none@none"
if [[ $new_branch == 1 ]]; then
git checkout --orphan "$branch"
git reset --hard || true
fi
git ls-files -v
if [[ -n $subdir ]]; then
[[ -d $subdir ]] || mkdir $subdir
mv ../$d $subdir/
git add $subdir/$d
else
mv ../$d .
git add $d
fi
if git diff --cached --exit-code --quiet >/dev/null; then
# nothing to do ???
exit 0
fi
now=$(date '+%s')
##date=$(TZ=UTC0 date -d "@$now" '+%Y-%m-%d %H:%M:%S')
git commit --date="$now" -m "Automatic build $d"
git ls-files -v
#git log --pretty=fuller
umask 077
[[ -d ~/.ssh ]] || mkdir ~/.ssh
fix_home_ssh_perms
repo=$(git config remote.origin.url)
ssh_repo=${repo/https:\/\/github.com\//git@github.com:}
eval $(ssh-agent -s)
set +x # IMPORTANT
openssl aes-256-cbc -d -a -K "$UPX_AUTOMATIC_BUILDS_SSL_KEY" -iv "$UPX_AUTOMATIC_BUILDS_SSL_IV" -in "$upx_SRCDIR/.github/upx-automatic-builds@github.com.enc" -out .git/deploy.key
set -x
chmod 600 .git/deploy.key
ssh-add .git/deploy.key
fix_home_ssh_perms
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
fix_home_ssh_perms
let i=0 || true
while true; do
if [[ $i -ge 10 ]]; then
echo "ERROR: git push failed"
exit 1
fi
if [[ $new_branch == 1 ]]; then
if git push -u $ssh_repo "$branch"; then break; fi
else
if git push $ssh_repo "$branch"; then break; fi
fi
git branch -a -v
git fetch -v origin "$branch"
git branch -a -v
git rebase FETCH_HEAD
git branch -a -v
sleep $((RANDOM % 5 + 1))
let i+=1
done
exit 0
+37 -20
View File
@@ -1,8 +1,9 @@
## vim:set ts=4 sw=4 et:
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
# ...lots of outdated/unneeded stuff from the old Travis/Circle/AppVeyor CI days...
#set -x # debug
umask 022
export GIT_PAGER=
@@ -25,6 +26,9 @@ declare +x UPX_AUTOMATIC_BUILDS_SSL_KEY UPX_AUTOMATIC_BUILDS_SSL_IV
# compatibility wrappers
if [[ $TRAVIS_OS_NAME == osx ]]; then
# use GNU coreutils ("brew install coreutils")
chmod() {
gchmod "$@"
}
date() {
gdate "$@"
}
@@ -72,7 +76,7 @@ if [[ -n $BM_CROSS ]]; then
export upx_EXTRA_LDFLAGS="-static-libgcc -static-libstdc++"
fi
cat /etc/os-release || true
if egrep -q '^PRETTY_NAME="?Ubuntu .*12\.04' /etc/os-release; then
if grep -E -q '^PRETTY_NAME="?Ubuntu .*12\.04' /etc/os-release; then
case $BM_CROSS-$BM_C in
arm-linux-gnueabi-gcc | arm-linux-gnueabi-gcc-4.6)
[[ -z $upx_qemu ]] && upx_qemu="qemu-arm -L /usr/arm-linux-gnueabi"
@@ -89,7 +93,7 @@ if [[ -n $BM_CROSS ]]; then
[[ -z $upx_wine ]] && upx_wine="wine"
x=x86_64-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m64"; CXX="$x-g++ -m64" ;;
esac
elif egrep -q '^PRETTY_NAME="?Ubuntu 16\.04' /etc/os-release; then
elif grep -E -q '^PRETTY_NAME="?Ubuntu 16\.04' /etc/os-release; then
case $BM_CROSS-$BM_C in
aarch64-linux-gnu-gcc-5)
[[ -z $upx_qemu ]] && upx_qemu="qemu-aarch64 -L /usr/aarch64-linux-gnu"
@@ -127,23 +131,45 @@ if [[ -n $BM_CROSS ]]; then
[[ -z $upx_wine ]] && upx_wine="wine"
x=x86_64-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m64"; CXX="$x-g++ -m64" ;;
esac
elif grep -E -q '^PRETTY_NAME="?Ubuntu 20\.04' /etc/os-release; then
case $BM_CROSS-$BM_C in
x86_64-w64-mingw32-gcc-9)
export upx_EXTRA_CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1"
export upx_EXTRA_LDFLAGS="-static"
upx_exeext=.exe
[[ -z $upx_wine ]] && upx_wine="wine64"
x=x86_64-w64-mingw32; AR="$x-ar"; CC="$x-gcc -m64"; CXX="$x-g++ -m64" ;;
esac
fi
fi # BM_CROSS
if [[ "$CC" == "false" ]]; then # generic
if [[ $CC == "false" ]]; then # generic
if [[ -z $BM_CROSS ]]; then
if [[ $TRAVIS_OS_NAME == osx ]]; then
case $BM_C in
clang | clang-m?? | clang-3.4-m?? | clang-[678][0-9][0-9]-m??)
clang | clang-m?? | clang-[6789][0-9][0-9]-m?? | clang-1[0-1][0-9][0-9]-m??)
CC="clang"; CXX="clang++" ;; # standard system compiler
clang-[3].[0-9]-m??)
esac
else
case $BM_C in
clang | clang-m?? | clang-3.4-m??)
CC="clang"; CXX="clang++" ;; # standard system compiler
clang-[3456].[0-9]-m??)
v=${BM_C:6:3}; CC="clang-$v"; CXX="clang++-$v"; SCAN_BUILD="scan-build-$v" ;;
clang-[789]-m??)
v=${BM_C:6:1}; CC="clang-$v"; CXX="clang++-$v"; SCAN_BUILD="scan-build-$v" ;;
clang-1[0-9]-m??)
v=${BM_C:6:2}; CC="clang-$v"; CXX="clang++-$v"; SCAN_BUILD="scan-build-$v" ;;
gcc | gcc-m?? | gcc-mx32)
CC="gcc"; CXX="g++" ;; # standard system compiler
gcc-[34].[0-9]-m?? | gcc-[34].[0-9]-mx32)
v=${BM_C:4:3}; CC="gcc-$v"; CXX="g++-$v" ;;
gcc-[56]-m?? | gcc-[56]-mx32)
gcc-[56789]-m?? | gcc-[56789]-mx32)
v=${BM_C:4:1}; CC="gcc-$v"; CXX="g++-$v" ;;
gcc-1[0-9]-m?? | gcc-1[0-9]-mx32)
v=${BM_C:4:2}; CC="gcc-$v"; CXX="g++-$v" ;;
esac
fi
fi
fi # generic
case $BM_C in
clang*-m32) CC="$CC -m32"; CXX="$CXX -m32" ;;
@@ -163,7 +189,7 @@ fi # CC_OVERRIDE
[[ -z $upx_SRCDIR ]] && upx_SRCDIR=$(readlink -mn -- $argv0dir/..)
[[ -z $ucl_SRCDIR ]] && ucl_SRCDIR=$(readlink -mn -- $upx_SRCDIR/../deps/ucl-1.03)
[[ -z $upx_testsuite_SRCDIR ]] && upx_testsuite_SRCDIR=$(readlink -mn -- $upx_SRCDIR/../deps/upx-testsuite)
[[ -z $zlib_SRCDIR ]] && zlib_SRCDIR=$(readlink -mn -- $upx_SRCDIR/../deps/zlib-1.2.8)
[[ -z $zlib_SRCDIR ]] && zlib_SRCDIR=$(readlink -mn -- $upx_SRCDIR/../deps/zlib-1.2.11)
# build dirs
mkbuilddirs() {
@@ -176,7 +202,7 @@ mkbuilddirs() {
# search for an existing $toptop_builddir
if [[ -z $toptop_builddir ]]; then
for d in . ..; do
for subdir in "local" appveyor circle gitlab travis .; do
for subdir in "local" appveyor circle github gitlab travis .; do
dd=$d/build/$subdir
if [[ -d $dd ]]; then
toptop_builddir=$(readlink -en -- "$dd")
@@ -191,7 +217,7 @@ fi
[[ -z $upx_BUILDDIR ]] && upx_BUILDDIR=$(readlink -mn -- "$toptop_bdir/upx")
[[ -z $ucl_BUILDDIR ]] && ucl_BUILDDIR=$(readlink -mn -- "$toptop_bdir/ucl-1.03")
[[ -z $upx_testsuite_BUILDDIR ]] && upx_testsuite_BUILDDIR=$(readlink -mn -- "$toptop_bdir/upx-testsuite")
[[ -z $zlib_BUILDDIR ]] && zlib_BUILDDIR=$(readlink -mn -- "$toptop_bdir/zlib-1.2.8")
[[ -z $zlib_BUILDDIR ]] && zlib_BUILDDIR=$(readlink -mn -- "$toptop_bdir/zlib-1.2.11")
[[ -z $lcov_OUTPUTDIR ]] && lcov_OUTPUTDIR=$(readlink -mn -- "$toptop_bdir/.lcov-results")
unset toptop_builddir toptop_bdir
@@ -215,7 +241,7 @@ make_absolute lcov_OUTPUTDIR
unset var_prefix var_suffix
print_header() {
local x="==========="; x="$x$x$x$x$x$x$x"
local x='==========='; x="$x$x$x$x$x$x$x"
echo -e "\n${x}\n${1}\n${x}\n"
}
@@ -244,13 +270,4 @@ print_settings() {
##env | LC_ALL=C sort
}
fix_home_ssh_perms() {
if [[ -d ~/.ssh ]]; then
if [[ -x /usr/sbin/restorecon ]]; then
/usr/sbin/restorecon -v -R ~/.ssh || true
fi
chmod -c -R go-rwx ~/.ssh || true
fi
}
true
@@ -0,0 +1,209 @@
########## begin .sha256sums.recreate
expected_sha256sums__t010_decompressed="\
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
24808d572483f4cd713d66894b3da406755038737007a78b076528e6407e3132 *amd64-linux.elf/upx-3.95
d88eaad0528bcecec9f51cbe015a117c8cf350a3f6d8308f2b0517d4fd19d189 *amd64-win64.pe/upx-3.95.exe
f7279729eb975e4238f8b8ee56fefa41ccbeb35ef0ffe4c34f8047baab78fff5 *arm-linux.elf/upx-3.95
e09df2a69f88c692138447f274ba7f99cdd11f8696c71ac8d3761606c95ab5c5 *arm-wince.pe/upx-3.91.exe
ce81113f8a4ff1cd806811cb80ab8bea5c9c6fbced47451c7f07e50700f9817b *arm64-linux.elf/upx-3.95
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
84b90eb0d617571fe4885639925b35ca6a61060cb2616bb5bf729b4d701653e4 *armeb-linux.elf/upx-3.95
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
7d331e508449497f64cd47abdd3f00f70307f508ad3fd692d333feb97beccead *i386-dos32.djgpp2.coff/upx-3.95.exe
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
a1f3e5ffa7b2cfebe1e475ac1f4c7683b1b8b4e292aa0d04386cc0314dd162c9 *i386-linux.elf/upx-3.95
e90fb09a808334c2674996760d42c82f8352e3f671f6b66c11481e772785c4d2 *i386-win32.pe/upx-3.91.exe
07bd50c1d80f6ff651228e6fc0ba3a583a472915772244f232696b34156a9d27 *i386-win32.pe/upx-3.95.exe
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
8902f38ec3d95d8e077e3ab5fdbb5bad408859913a35deb87041f4f053cd6605 *mips-linux.elf/upx-3.95
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
dd1496bc4e9c32a5d5dd47e3eaabf7b134ca001d48807eebfd3d5e28c8a2ab58 *mipsel-linux.elf/upx-3.95
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
2bc00a51daa0bada19a8fa1bd2c227a8596844fa1b0aa3611087f195072700e2 *powerpc-linux.elf/upx-3.95
a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t020_canonicalized="\
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
24808d572483f4cd713d66894b3da406755038737007a78b076528e6407e3132 *amd64-linux.elf/upx-3.95
d88eaad0528bcecec9f51cbe015a117c8cf350a3f6d8308f2b0517d4fd19d189 *amd64-win64.pe/upx-3.95.exe
f7279729eb975e4238f8b8ee56fefa41ccbeb35ef0ffe4c34f8047baab78fff5 *arm-linux.elf/upx-3.95
e09df2a69f88c692138447f274ba7f99cdd11f8696c71ac8d3761606c95ab5c5 *arm-wince.pe/upx-3.91.exe
ce81113f8a4ff1cd806811cb80ab8bea5c9c6fbced47451c7f07e50700f9817b *arm64-linux.elf/upx-3.95
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
84b90eb0d617571fe4885639925b35ca6a61060cb2616bb5bf729b4d701653e4 *armeb-linux.elf/upx-3.95
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
7d331e508449497f64cd47abdd3f00f70307f508ad3fd692d333feb97beccead *i386-dos32.djgpp2.coff/upx-3.95.exe
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
a1f3e5ffa7b2cfebe1e475ac1f4c7683b1b8b4e292aa0d04386cc0314dd162c9 *i386-linux.elf/upx-3.95
e90fb09a808334c2674996760d42c82f8352e3f671f6b66c11481e772785c4d2 *i386-win32.pe/upx-3.91.exe
07bd50c1d80f6ff651228e6fc0ba3a583a472915772244f232696b34156a9d27 *i386-win32.pe/upx-3.95.exe
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
8902f38ec3d95d8e077e3ab5fdbb5bad408859913a35deb87041f4f053cd6605 *mips-linux.elf/upx-3.95
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
dd1496bc4e9c32a5d5dd47e3eaabf7b134ca001d48807eebfd3d5e28c8a2ab58 *mipsel-linux.elf/upx-3.95
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
2bc00a51daa0bada19a8fa1bd2c227a8596844fa1b0aa3611087f195072700e2 *powerpc-linux.elf/upx-3.95
a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\
e697578691a81e9d4bae7d32ea1f2e83c48956d6910d0306761e484dc3c07e18 *amd64-linux.elf/upx-3.91
6b54df3465da21601619d973b618cf45f695e8511f8d9c88d65f8efc1e347512 *amd64-linux.elf/upx-3.95
939e9058b5abec32f27588474ad334d8d05a9a8515e75dc417d397c6de74d02a *amd64-win64.pe/upx-3.95.exe
290cf727b3944db22fb1618d0e36d06659126d759a06fd0a5ffb397927d34f31 *arm-linux.elf/upx-3.95
4c488f100a589aace7e52a1f49982b618662ed2227e66a1e8c9699c9969ccedc *arm-wince.pe/upx-3.91.exe
b5da1b05cfe70c4d8dc169d8e27bfd8d95f92cc2c7307f907a7bc561e3523dab *arm64-linux.elf/upx-3.95
56abe47901f0e4fb207c3c19d21334664229081391d6df7e5e5c81b97c57419e *armeb-linux.elf/upx-3.91
d0712d61d08a6e7161a9ff2dc933888199705fcf194c9a96350d75774c5a6a62 *armeb-linux.elf/upx-3.95
bb56e464921ad806bc72308f85d42ea1b4f6715983ecdb9415b1d525f5e3ec9c *i386-dos32.djgpp2.coff/upx-3.91.exe
7adf07236d7a36099122edeba72534944f7f0cab36f110169f3b5755f48bad76 *i386-dos32.djgpp2.coff/upx-3.95.exe
590b4b75ad6fc076440bf7afc9261ff1e5e3efeec84c5cd81243aec2b0b5274d *i386-linux.elf/upx-3.91
0dfda4fbe5bd260f1592649eb564bb28ee768413e1c7fe3a678d8d7b025edcea *i386-linux.elf/upx-3.95
e3f98f4c2d0473b11fedd966e2fa184c0cf7e49a46fcbd5705387f9f2b191106 *i386-win32.pe/upx-3.91.exe
38c37ec2351783a48d4cce3f240bbf6a31331f9d9bd86f77cee468ff179cf58c *i386-win32.pe/upx-3.95.exe
ac331450fd0609f0f47a5012156a13d06dcabdc8ba58d5a7810dee6f17fda123 *m68k-atari.tos/upx-3.91.ttp
7483078331cbfc32f6150929c244f4cc0a34282f60332da37bcfdbe41c1014cb *mips-linux.elf/upx-3.95
23fe3c6320f3cebce8027ec5597c228b9f160407e1e0e8a810e2ae6be8dc0d43 *mipsel-linux.elf/upx-3.91
3279bdf38a14623c7a939df871f0efa5aafa4d4ed6a28c779a5d5213e6dfb7a1 *mipsel-linux.elf/upx-3.95
5fe46128190a2553c6219f6f998b31ff007a5692f44585bcec27566eb6bf6640 *powerpc-linux.elf/upx-3.91
c5ce8e7076d542a92205f98c8017fc9b6f97541a1e082ca2239c1138104001ef *powerpc-linux.elf/upx-3.95
21268d593853c2e724037ca0e0c832b89414c3c41e2a0cc9c5038ab162be710b *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
b8e4d487f79a5c097244793f0535b2cfc4587449f9cbc9a7e19f5171a7a05f8c *amd64-linux.elf/upx-3.91
ab4972d2fd8369c43337aa636060b881c65ca18942d46d7ea24392a771b07b30 *amd64-linux.elf/upx-3.95
f5380d57da37b4d5e1258f0d36e329a936c3976ac7f684baa20899c9cfc5f167 *amd64-win64.pe/upx-3.95.exe
024b27a1edf93da0efc93190c4b6d2003d76e43a80065b24a1aa5bf0143feb06 *arm-linux.elf/upx-3.95
0c588526f42f3f0931731fb01e1e257780c9a87a1701b2c3f4a7605b6911f618 *arm-wince.pe/upx-3.91.exe
2c12d439d9a24c532b6c41decd9b01d2774d03e34692129ee17b8448e3436e3e *arm64-linux.elf/upx-3.95
eb7436b949fd646500bf42f14abe2ea6d466cbda5cbfff36a4e71693611d6c9f *armeb-linux.elf/upx-3.91
3e0db5fc130ac5b08d9b4df0cdf0fb9a40fa299cd5e28b2550277845500fa729 *armeb-linux.elf/upx-3.95
fb7d8645e851534e4050efac23aff3fc0557f217d4fe2bb3715f8771845f5759 *i386-dos32.djgpp2.coff/upx-3.91.exe
12d2e9029826966caa38cf719757a055298c86d46e6bea7eef7a20a77a6902a9 *i386-dos32.djgpp2.coff/upx-3.95.exe
b10d190bb8c2aee25ed264051b1527649c5f6fa3f8dde46c7ddd9fb3caae8e94 *i386-linux.elf/upx-3.91
b6c3402266a0d798ffbdf5ed3c6bbd80cc25999cddf178ce65c8e5917cb60cd9 *i386-linux.elf/upx-3.95
1a353bff5e90a73664fb1366fcab3ddde11f9309a59cf0e58a9f6deb40170bff *i386-win32.pe/upx-3.91.exe
9fd5633d06eae78f683857fc90ebda7cad60395cc46751101190086f069e55c1 *i386-win32.pe/upx-3.95.exe
2df5dd59cabcd7c09293982cc4638a608c424e515f8040aa70473d30fd7373db *m68k-atari.tos/upx-3.91.ttp
771ee01c165aa0dac865f946dd4207680a723ef822f2ceda27c6c442978cb898 *mips-linux.elf/upx-3.95
f99b2e97c49e86cbe8141160de3b5196e78fe85776a159b745a78144c7fd29a9 *mipsel-linux.elf/upx-3.91
bad98328d8666b5f92b7210fa22920947fbfb38a86e788f1bcbb8ce1c8e64bcc *mipsel-linux.elf/upx-3.95
fc671351debd86f347f874e5a1cace099bbf388fd19f8ec2ac226ab22c84e46e *powerpc-linux.elf/upx-3.91
cb248465ee6fbf2aff427c9c015de65c547bab7ac3b84b5243980d707c3514ea *powerpc-linux.elf/upx-3.95
49e84bc28d7d80d828cf9298101468730dc1badc6e2f710884e2afc34d669391 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
037e9867bc52669e8f4869d64a41a8faaca3e57f6b226b79a894aa8854f0d73b *amd64-linux.elf/upx-3.91
54b9d627cbb8bf19a8b7e299af33fcfbf45287ee41de1fc3b7806f45cc9f0c4f *amd64-linux.elf/upx-3.95
c76b656a4e5c9d3f691d186b488e89401246395e05a4c571d8384826ec1afd7a *amd64-win64.pe/upx-3.95.exe
1099f092f803371ae60fe45d1210ed000fa011026a6e3a339119d30e7b533a3d *arm-linux.elf/upx-3.95
0fd539a9cf015e60f55cfe9a2cb735c39abcec4097a1d9dad14133817322f149 *arm-wince.pe/upx-3.91.exe
f74bcbafa912d4b60431744347562551efb3a4c738b33b54788702c9a04a2755 *arm64-linux.elf/upx-3.95
2159088afb2481c20bd3e46b22f135ea9a71fccf84cf8e3cd5288012bf499efb *armeb-linux.elf/upx-3.91
a4e1fb939ffd0dd4fba8d96332406475220439ee368c4445b715d723c14257f7 *armeb-linux.elf/upx-3.95
7832f40d5a2f4208c5a765a90758a75b8208ac5b4c01a78c276be2ff74d6be13 *i386-dos32.djgpp2.coff/upx-3.91.exe
e6bde12bead66eff48502e7944fe44a557db3f236b6d0155be5b9bf891c6beff *i386-dos32.djgpp2.coff/upx-3.95.exe
8306fa054b3281547f545b2ec1c5a059f0f29414fdeb4a5572f07c25bc8deff2 *i386-linux.elf/upx-3.91
75f6be5e52b89ac19f822ba9ed598c050078d9ec5530dd73144b5f0748dfe6e7 *i386-linux.elf/upx-3.95
61ea92bd711bcbf8c74e33054f320ab214dc1b2570e814a5d1f65001f7e1e507 *i386-win32.pe/upx-3.91.exe
ed5db8134d10a59b0dc1b973339823d20104ac3c1be0332fb55b1f2e220110c5 *i386-win32.pe/upx-3.95.exe
d381ff2c7115e3100daa567e49dbf36bd42ea7544039d8e7fb66ecc5009f88c0 *m68k-atari.tos/upx-3.91.ttp
6aa24a6661d322f60805406b87a5be605a5aee52d33e798328b7d118dfba4862 *mips-linux.elf/upx-3.95
04a1492fad74bc942216721a9e538638c9dc14f64272c5d90b54dc5a38c98b4d *mipsel-linux.elf/upx-3.91
31f6814a6964c9d5e44f1cc842742036747e95df2bdc4f4dddc8f05d4d9eac1a *mipsel-linux.elf/upx-3.95
5b1121a963ecec3e221e0b475f6cde7aad14d5cdd8cba43a4516dbdb92eb5a66 *powerpc-linux.elf/upx-3.91
c4f35cda7fdf64d9195115a82c806f084e2dbce0f80a31b34a882138d6d159c1 *powerpc-linux.elf/upx-3.95
ce70def8c58def3d548aa04f502c8279392eadcdb2c3d3cac8466cfcd3a6b7ab *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t140_compress_lzma_2_no_filter="\
38b58e0702763bd421f8940479a8545f39a2a8f27d90d2c276dc677d8a99846c *amd64-linux.elf/upx-3.91
5b34c95e9d636903b85b79b299d28f2aa6bd8d3a3d1696acf308d8cf8bfe99d4 *amd64-linux.elf/upx-3.95
dd10984767f9fe67900b64d63699ccaf858b9072272eef5ca373a7701d5057bb *amd64-win64.pe/upx-3.95.exe
4aff8b057429fcdac4f4b3691278c87280e247879ef07ea0291a1c56f999750d *arm-linux.elf/upx-3.95
9e5ad415bb42155a3c527fd259ac7ca1534a14bec888cb1ee8a7cc8e2ca0019c *arm-wince.pe/upx-3.91.exe
65facbcdbf7f79d88fce4af18629f8489510134005b3e490eb42fa112603e18e *arm64-linux.elf/upx-3.95
78d94d8209a443ae3c05f360c1086fe8bcad109e3a7d5267c571ad53ad38702e *armeb-linux.elf/upx-3.91
37242e5eb6ef64ed6dc862a791643d62cfc9c3b98a6f88556216a002101ef73f *armeb-linux.elf/upx-3.95
99209d2c5e6e7bf9edad472b181318f135a619f10d19ecde37158a80e186658b *i386-dos32.djgpp2.coff/upx-3.91.exe
f713b061cc6171d6fd467f6041618bf5c61179c406ccf6b79acb378e7fa1f3dd *i386-dos32.djgpp2.coff/upx-3.95.exe
48b554af082672ed3c5dab9ef5d78f561215f23ab98eb49904766e2801b70799 *i386-linux.elf/upx-3.91
9c1f8e34110030920684ee1276033bcaaa3cd2917d4cc001dad6efd865e8f2e8 *i386-linux.elf/upx-3.95
6d08ec9ab29b1d85bfcaebac1adeec1a5155c8b37a5c979e40f4e0fcae12cb45 *i386-win32.pe/upx-3.91.exe
1754e33c11034d09076c6a534532d5d9a13e967e4206221cc8a0c6d904bb6edc *i386-win32.pe/upx-3.95.exe
d044c35793adedbba31dee6adb4dbd1fcde183f2299d11b17e15aca83500217e *m68k-atari.tos/upx-3.91.ttp
f555a0e2444ec2d859609236c66f45b9984cbfcd9668d16dea5de0feb86a94ea *mips-linux.elf/upx-3.95
8a96d7674eb6754235d0e7cc2e72bae241a166e2d232e70ee97bd0382c5dba9f *mipsel-linux.elf/upx-3.91
40ddb03c43e5740b634aa05a915fbe5ec2fb1f7076b7a3553d236498f4830964 *mipsel-linux.elf/upx-3.95
262cf98e2533c38008b2a2273f5ee3ccdfb753b854c8afb836be5f1b1af56710 *powerpc-linux.elf/upx-3.91
20513f3e3f675b167ce74707f9b31c4e4885f5d7c3d8b050a4a7ea7221b1b6f2 *powerpc-linux.elf/upx-3.95
b8aca35fce8a1ceea2c7ba4f11cfcbb3549ac0e93b955a0c390f6a7063e865e3 *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t150_compress_ucl_2_all_filters="\
5033deb9509be51229a7fb9fff629547797bfff7046e413a3450892ab459c58e *amd64-linux.elf/upx-3.91
d92a21d5b25c4b367142859eb3f29d9754d54b151058475a81e5bda6e5093dcd *amd64-linux.elf/upx-3.95
870083b25a88a2ff5cb49dfa109e55fc082b11af39c352740bab65c551b40282 *amd64-win64.pe/upx-3.95.exe
152fbbeabd01c771d526a887ae6a8d92bc5a9dd92ad0779d9a40a036f4760309 *arm-linux.elf/upx-3.95
f88d160e5a3e7e323623dc5f1f6edabd6ed0ac477beb168bf754047c04531097 *arm-wince.pe/upx-3.91.exe
379a8eec659fd1a1bced32342b45e146333b3a257942d66f7a1062f9cba88f9c *arm64-linux.elf/upx-3.95
86f5d6d3f7b738e4e30157fb011720fbae61f52a6296e3dfeb445afeceb91e32 *armeb-linux.elf/upx-3.91
7cb7f1a18d00631decbbd73d56d4cb54a5402cb3784607406c258ce5af3f51ca *armeb-linux.elf/upx-3.95
4b34e1f0553937c3fb6b98b4cad7beff510d5f0c9bbfd2fd2cc6986bc569d579 *i386-dos32.djgpp2.coff/upx-3.91.exe
41332641b361c584763bfc149d3762bb4c337fe979af85f4b6cc03c3318ac9a9 *i386-dos32.djgpp2.coff/upx-3.95.exe
e3c7e93cddce54b2c044b23b2ce239e2373134212cd930ad700ab93178785941 *i386-linux.elf/upx-3.91
14827578a5bbcebcf02ab9754145a290cb06d0c2dc3d9c34da182c3a22071cb6 *i386-linux.elf/upx-3.95
f10fb96a4db81cde3f76f3499710c16accfb7c7b30bc3e5532ea3b0b5aa57d54 *i386-win32.pe/upx-3.91.exe
a83278c357fa81f565ee1f95edbfc0156318b9638a5934421ee9f2f1bae5479a *i386-win32.pe/upx-3.95.exe
f29d9bb67de28a5eddbd3153c616f8b840d019bed48dfc6cf99ffc0bc6146390 *m68k-atari.tos/upx-3.91.ttp
356630562c9b017d18e09373ca71e19e870ae10b25ffa7a0d6e3e5c1fb948d73 *mips-linux.elf/upx-3.95
336a1795b3675a8ee76fff35f6c9ea9c7fc8f48dd53224a990f1191b1cbbab65 *mipsel-linux.elf/upx-3.91
dbebbc932fc3caec6be1fe92d21eed379ed3bf7e55293c10c54dfba9c37229a9 *mipsel-linux.elf/upx-3.95
adb8d16a5a635cdb3ca12346c5317ce16431cc8ecb9a54a856ee9c2586f7911a *powerpc-linux.elf/upx-3.91
286c92ba6bb88c13c01fc932d1a742a2cc0d01b4c59731d72c7a91d0c7c6c9ef *powerpc-linux.elf/upx-3.95
9102d4d31572fc5b5244a6f7643e1d001cc3044836a25c6211f3117d4c2b1dac *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t160_compress_all_methods_1_no_filter="\
407f350965205d7ef3d860cd89ff1dbee74082a7a6777363deb64ac5676ef495 *amd64-linux.elf/upx-3.91
8d391e5a14922113c7b72a16728f497553fc834b02971c0ffe65a1efe461f240 *amd64-linux.elf/upx-3.95
867627ab2c87ffe1d82d5f131c0b05f73fc73d1e0a0011e369adb543be3b0deb *amd64-win64.pe/upx-3.95.exe
f9f39f443c419ffaf2a5d95f00144d56de4ca66f21d919272345cf360c947694 *arm-linux.elf/upx-3.95
9394653a9f6ca77c82916f06d402af45639815edc1eb06ba01e67510927f9d34 *arm-wince.pe/upx-3.91.exe
e22d64d16fe071c70e62e3c97701632a88a1568d8146e197df89f1bcc003041a *arm64-linux.elf/upx-3.95
61a18df8b91461fb6ffd9fbfff3d24549abe5a64ca512a063a9c09f2d8dbbf64 *armeb-linux.elf/upx-3.91
6866f745d8bfd1f60d3f7fb68e39238f80371e4dec6f42ee08193db13eb2c04e *armeb-linux.elf/upx-3.95
d8a099f8e4fd380b70f0cf8ef56cbebf232ea0c127529593c15fc34af7df32e7 *i386-dos32.djgpp2.coff/upx-3.91.exe
5b8d383bbd3594016b09f923f3e3d472649e3854abf9a4d695d67524d57debde *i386-dos32.djgpp2.coff/upx-3.95.exe
7116ee5cce8865154ab815eaf717f39b82265c5f88320799d01bea2d92799a3c *i386-linux.elf/upx-3.91
4f29bc1c53e9cd7047929b8ceb92cc9022cede80fd80afa1c23f48152789d4c7 *i386-linux.elf/upx-3.95
65e85f6944b98df0ac16d50af98f501f3f87b35c0432edc17244e768f0850a3a *i386-win32.pe/upx-3.91.exe
6414e7ed0bb0aedc4b027030f42d5d2e49f10cd9d98b9250015be88d708fa4eb *i386-win32.pe/upx-3.95.exe
1dc02f7ab54cd23da1ba3efaa3e3ca275cc23bcdcb2f5131bc9c643c87076d0d *m68k-atari.tos/upx-3.91.ttp
6b9269ee5709fd2a2bda88fa4d9198e4f163ee067cbd1faca12d17f906c5a2e0 *mips-linux.elf/upx-3.95
4424522044277c9ecfd3869c3746d4ac760b272a58157a8a7b49c1bc8bed6bbd *mipsel-linux.elf/upx-3.91
673f459fd6024a433d6a86245b569557d523f4f33a2bd1a31ff5ca590a19c663 *mipsel-linux.elf/upx-3.95
1e6d47f288f6e9ccdfee98bd3700771dd9cad47115909ec9192f10d7a87440a9 *powerpc-linux.elf/upx-3.91
203a33bb365a745a317a9292562cd80e0f82c7dbafb810fddb8a752d06159dcb *powerpc-linux.elf/upx-3.95
6bea6492b66df759ed13748b53b3d5058a1d3b9debf0b209c8b450e76e5fd29e *powerpc64le-linux.elf/upx-3.95
"
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
257a9f44da07e6eb423e651a8323a2b79d38c5d599a4ec1de8f62a7c103eedf4 *amd64-linux.elf/upx-3.91
4adc3488e71c834f28a0d9955b3959d7db19ff375720c02c433aae63ec847b67 *amd64-linux.elf/upx-3.95
47165d0a33de56cdcf5788773f3630b698bbdc68b8f2a383b348d4264406536b *amd64-win64.pe/upx-3.95.exe
4038aad4341b884dbe34aac6055391a78af540f368370b5b61bb45c40905160a *arm-linux.elf/upx-3.95
4f3f1dbdd225a72d37555d5f60a2eb8308b87ad1e641285f3f693e91cb430985 *arm-wince.pe/upx-3.91.exe
3c7b8a6813a446b05d6ea1d5b81155ac216fd847a3b456d01a5cdbe30a6b686d *arm64-linux.elf/upx-3.95
13c966e3377bac700e3e84d725dd8ff9ca949fb74d1ca7774a00af71112dfb7d *armeb-linux.elf/upx-3.91
2d542d14c90a530cf812c713740a0f1b2d73a81b91ef7efbc037c8d3507a714c *armeb-linux.elf/upx-3.95
9ea810301eda67e45eee400500d1c88969cd63bda1224446c86eef8a75657748 *i386-dos32.djgpp2.coff/upx-3.91.exe
688efbc1826e6bd0ccceb0462325d5e384f38b7d05dfa3b7901fa18536b6ea68 *i386-dos32.djgpp2.coff/upx-3.95.exe
294d5099c4794a2de49d264c0bd4bdf80c866041b7caac7f8420ed003ee18180 *i386-linux.elf/upx-3.91
8c40b35f36c8850aa481de5ab13a5cb0fbc8fc9593977dd438c08d55dadfa9fc *i386-linux.elf/upx-3.95
b5d3bbd9c5f3d376be43c75a32374b022adfb6566feeef14d30420c819566082 *i386-win32.pe/upx-3.91.exe
aa9d18c47e60a814d383a6778cf26654a2bea6a097520e7177d3c546a1421159 *i386-win32.pe/upx-3.95.exe
4ea046a2c8be33ed14531e30ccbd3440b9569e68abd76932a8837abf4abba553 *m68k-atari.tos/upx-3.91.ttp
eeb7ae0de5b423611989f948585a4fdb18926161927c8f99e137cb4ad5f464b0 *mips-linux.elf/upx-3.95
5f4433586e45651bacd01bca156090f06fa48e95a78077cc93d1b6bc9965e8d5 *mipsel-linux.elf/upx-3.91
d17b7488d441269f0427cf567fc6f5c43fbe32398860f0099d361b9d4672a2dc *mipsel-linux.elf/upx-3.95
eca17f5f26c878c3f5ffee569ce5eb3af19127685ceb0bf7a419d13537e774a2 *powerpc-linux.elf/upx-3.91
2ea98117f051c4f05292e2c5b71e9a1252ab32fe2dbb03e4f1106c765913cc4f *powerpc-linux.elf/upx-3.95
fecfda8d1c58bfe2fe7a0d9d3806258129e449b25e5bf65418c364758c693e94 *powerpc64le-linux.elf/upx-3.95
"
########## end .sha256sums.recreate
+47 -120
View File
@@ -2,7 +2,6 @@
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
#
@@ -23,20 +22,28 @@ fi
if [[ $BM_X == rebuild-stubs ]]; then
exit 0
fi
# convenience
[[ -f $upx_exe ]] && upx_exe=$(readlink -en -- "$upx_exe")
# create dirs
cd / || exit 1
mkbuilddirs $upx_testsuite_BUILDDIR
cd / && cd $upx_testsuite_BUILDDIR || exit 1
if [[ ! -d $upx_testsuite_SRCDIR/files/packed ]]; then exit 1; fi
if [[ ! -d "$upx_testsuite_SRCDIR/files/packed" ]]; then
echo 'invalid or missing $upx_testsuite_SRCDIR:'
echo ' please git clone https://github.com/upx/upx-testsuite'
echo ' and set (export) the envvar upx_testsuite_SRCDIR to the local file path'
exit 1
fi
mkbuilddirs "$upx_testsuite_BUILDDIR"
cd / && cd "$upx_testsuite_BUILDDIR" || exit 1
# /***********************************************************************
# // support functions
# ************************************************************************/
testsuite_header() {
print_header "$1"
local x='==========='; x="$x$x$x$x$x$x$x"
echo -e "\n${x}\n${1}\n${x}\n"
}
testsuite_split_f() {
@@ -44,7 +51,7 @@ testsuite_split_f() {
fb=$(basename "$1")
fsubdir=$(basename "$fd")
# sanity checks
if [[ ! -f "$1" || -z "$fsubdir" || -z "$fb" ]]; then
if [[ ! -f $1 || -z $fsubdir || -z $fb ]]; then
fd= fb= fsubdir=
fi
}
@@ -56,10 +63,10 @@ testsuite_check_sha() {
if ! cmp -s $1/.sha256sums.expected $1/.sha256sums.current; then
echo "UPX-ERROR: $1 FAILED: checksum mismatch"
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
exit_code=1
exit_code=99
let num_errors+=1 || true
all_errors="${all_errors} $1"
#exit 1
#exit 99
fi
echo
}
@@ -70,7 +77,7 @@ testsuite_check_sha_decompressed() {
cat $1/.sha256sums.current
echo "UPX-ERROR: FATAL: $1 FAILED: decompressed checksum mismatch"
diff -u $1/.sha256sums.expected $1/.sha256sums.current || true
exit 1
exit 98
fi
}
@@ -112,7 +119,7 @@ testsuite_run_compress() {
# ************************************************************************/
recreate_expected_sha256sums() {
local o="$1"
local o=$1
local files f d
echo "########## begin .sha256sums.recreate" > "$o"
files=*/.sha256sums.current
@@ -125,107 +132,7 @@ recreate_expected_sha256sums() {
echo "########## end .sha256sums.recreate" >> "$o"
}
########## begin .sha256sums.recreate
expected_sha256sums__t010_decompressed="\
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
28d7ca8f0dfca8159e637eaf2057230b6e6719e07751aca1d19a45b5efed817c *arm-wince.pe/upx-3.91.exe
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
0dbc3c267ca8cd35ee3ea138b59c8b1ae35872c918be6d17df1a892b75710f9b *i386-win32.pe/upx-3.91.exe
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t020_canonicalized="\
24158f78c34c4ef94bb7773a6dda7231d289be76c2f5f60e8b9ddb3f800c100e *amd64-linux.elf/upx-3.91
28d7ca8f0dfca8159e637eaf2057230b6e6719e07751aca1d19a45b5efed817c *arm-wince.pe/upx-3.91.exe
b1c1c38d50007616aaf8e942839648c80a6111023e0b411e5fa7a06c543aeb4a *armeb-linux.elf/upx-3.91
bcac77a287289301a45fde9a75e4e6c9ad7f8d57856bae6eafaae12ae4445a34 *i386-dos32.djgpp2.coff/upx-3.91.exe
730a513b72a094697f827e4ac1a4f8ef58a614fc7a7ad448fa58d60cd89af7ed *i386-linux.elf/upx-3.91
0dbc3c267ca8cd35ee3ea138b59c8b1ae35872c918be6d17df1a892b75710f9b *i386-win32.pe/upx-3.91.exe
8e5333ea040f5594d3e67d5b09e005d52b3a52ef55099a7c11d7e39ead38e66d *m68k-atari.tos/upx-3.91.ttp
c3f44b4d00a87384c03a6f9e7aec809c1addfe3e271244d38a474f296603088c *mipsel-linux.elf/upx-3.91
b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\
c82d400d99a78f21b594ad9900208ee89b3df5b67723c06dbb374dc3f42ca934 *amd64-linux.elf/upx-3.91
5b9ec916beae0eadc665235158a9ae5bce1309823a344503268a88e32e77824a *arm-wince.pe/upx-3.91.exe
a099aedddbaa960247209e08ed922b43f4bbd6559ad646a6ff801384e2f661eb *armeb-linux.elf/upx-3.91
960dc15876221832510142816605b9ef568c0de3050ca0a79f3553643c5d5e0f *i386-dos32.djgpp2.coff/upx-3.91.exe
43ec77282bbe73eb5d6f5471e9593127928bcfc2ebaedd93dd86969b12c9c61d *i386-linux.elf/upx-3.91
ca6925a15c1ab8931f0a8fe9ef87f5893403d6e46098f4cd1a5f6f6f0fbdeb44 *i386-win32.pe/upx-3.91.exe
14ff2a4e215a25ed7442b004bca3d82094f7c01784fc4876eb50d365441f35c3 *m68k-atari.tos/upx-3.91.ttp
4163afbb2475b669e131265c0f7ea179c35f19ccce66732feee08fe20c33775e *mipsel-linux.elf/upx-3.91
00c9d16157a734e1b386e5fe01dbae76c7f8ab7d6035dfa6975d656b43ef4e67 *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
27b530885ccb425cf14963feea677c4177cce5324821c277823b3262a7a6ced4 *amd64-linux.elf/upx-3.91
22216286b1bf3066d9022b921f37beff6712b5f3fc8c092f2dc1477638d9f8cc *arm-wince.pe/upx-3.91.exe
90e2960d01214b3e2f62f76effa2360fed655e72392acfa8096d1d9a729ade21 *armeb-linux.elf/upx-3.91
b6e98d36bd916fa63ec799e47dd7cac3674154370a9680492d84f1853bf14c3e *i386-dos32.djgpp2.coff/upx-3.91.exe
483e4a7eba0b88302658fcaacb7ee1de32fb514dac5dccb010a55a5202918c0c *i386-linux.elf/upx-3.91
d2692b3e4a278559456e299164714c4bb8ebbcf230ab12521619e2e94580597d *i386-win32.pe/upx-3.91.exe
cd1ae0f2781787bf7c61f3600cc889313e6027615d78e562d624d717671e55c3 *m68k-atari.tos/upx-3.91.ttp
26b30c10ba8980fa6fc564b79eb2931e07bb7b2f89f07a0656c28be71185a3ea *mipsel-linux.elf/upx-3.91
bbce9449d105e4ac7e9a04d56b286cbba3b34c1bf8ee928e9e97a4943ae3c5ac *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
81a528ed6f678bdbb1c18a9ee69b7d04169466e756a71baa98c7651ad1c40bec *amd64-linux.elf/upx-3.91
08c55815175ce0d34fca3b368336dd346a2354dbe4f046210c82f6961350a50f *arm-wince.pe/upx-3.91.exe
6dae3b18770e6af45e074b092c1f2f3632bef1996ce71af0f6e252caf34555a1 *armeb-linux.elf/upx-3.91
45f50d69e685f7ea752f76c05554d4c2ce023c0218465a4f8919138a76ae6c71 *i386-dos32.djgpp2.coff/upx-3.91.exe
f1db16f6be23b0bd96226e7e57f8b41ddfb93ede5ca0750ae680bbd615523083 *i386-linux.elf/upx-3.91
eb7c2f74979c11b35193a0a9d428596bda46420d9363666fe1b967f5cd1610c6 *i386-win32.pe/upx-3.91.exe
cefb13395220fb2e931d0fb32e27663c4a27035f9e79131bbabc44fa54e6336e *m68k-atari.tos/upx-3.91.ttp
602be188fca1dd63593a2ace68ea221d720fd2ddf9df85c1ab019feda69f1cad *mipsel-linux.elf/upx-3.91
2f299fdbc37bf6675559c5b1245aecf56de268bc074bd558bd7d9f84f7be5eae *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t140_compress_lzma_2_no_filter="\
12d2ec20370655396711fc794db41745c21f51c998b766e6aa96283feb00eb48 *amd64-linux.elf/upx-3.91
9759deb5aa8fb004c4b23bbe174042e45869aedeea1a1dd1b729be0e736814da *arm-wince.pe/upx-3.91.exe
9b25bcc69fcdbdf4b4adc54e5c6508749c918179644ff9fa34b437bc7e42eca5 *armeb-linux.elf/upx-3.91
a2a800d2ba5cfc1b6bb2b48c91adccb5d3c3b6c0b5c548affccac9244197a312 *i386-dos32.djgpp2.coff/upx-3.91.exe
1865bc9b76579e33df4038f3d0abf848993b0c865b687f4b4bd482099416ef80 *i386-linux.elf/upx-3.91
80aba41aad8268085e853ec872f885981838a625c14095d21ba70cb7abe045a5 *i386-win32.pe/upx-3.91.exe
bbed61e42fa7b330b5cde66e4614329f41e21facff1f3667edc03495219c29f9 *m68k-atari.tos/upx-3.91.ttp
57b47244a3a0d01725cbdc9af8572cbe20e2d173857015ad4d32245b52577dc2 *mipsel-linux.elf/upx-3.91
6b02b01fa48910a104b523b265503131e4259ef83765464d002614e1a4eba38f *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t150_compress_ucl_2_all_filters="\
3e0df832830a4a0cca77da16868a2655f85b2b36f783123b6f067f5586460704 *amd64-linux.elf/upx-3.91
c7b0f611e9941be58b700219e7a5d34cdbdbf972b6184b13dec5e98fe84de808 *arm-wince.pe/upx-3.91.exe
ef7c6febc18d5ecf7d846f38d75f398a92b5b21eb5d35b1eac4935d0e6de92ac *armeb-linux.elf/upx-3.91
425c9128285f49b41f9b736f48794f5bebba6981250f669e5a342016b89f2170 *i386-dos32.djgpp2.coff/upx-3.91.exe
d6cb6d50dfda98ff8efbab2d2c8751adfb67df58652313c630d45db1b89e921e *i386-linux.elf/upx-3.91
5565f8196d971feec261dc663ca7ec329fd82b1b18ad49593b865edbaa15765d *i386-win32.pe/upx-3.91.exe
78f24d77855034d467568f05c22cb5e3abd167c90a4d89f4e2059c3e6faa3e2b *m68k-atari.tos/upx-3.91.ttp
23d6856df8f31b9176e0f4709135ce81656ed94539bf909e873b787ce89821cd *mipsel-linux.elf/upx-3.91
8dbf63b21d3ced1cceec71e507d3086de2612b8ce8ba35ee2d75acd06435baf1 *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t160_compress_all_methods_1_no_filter="\
27a248133cd386332daa14ec25367b4f1ff5595df213a2d72c341bbb7f264033 *amd64-linux.elf/upx-3.91
6b2333719a4fe6c8d2067f682d57cf6fc5fd928bffad4e61aaffcc31287772a7 *arm-wince.pe/upx-3.91.exe
d094f3a0e80e579aa6afeac239aacb3d8210580acdb095c9fc5511d77da7aeaa *armeb-linux.elf/upx-3.91
d09af3652aa601650f9cd0f125d54e50dfe57b45b9871567140e62a04d032407 *i386-dos32.djgpp2.coff/upx-3.91.exe
110bb3344a27b2677085e130956371df43ca6c231c01070480bb3a9e519fed30 *i386-linux.elf/upx-3.91
c3c8b428f7e57a528db89f1365b4f3fda60f0dc03eadb30775ecdbadaa19f0aa *i386-win32.pe/upx-3.91.exe
53c77efbccf41072c4c206343ba3c838be04c47eab415d18c08f086d481612db *m68k-atari.tos/upx-3.91.ttp
616cefa819c0e516c554faac20e6aaf9350a2aacf0041a2641d5809c0da220df *mipsel-linux.elf/upx-3.91
04ad8f4a60de80bbba7953489d3ef4b74b89a3961ae764acee00bd6df814ed9a *powerpc-linux.elf/upx-3.91
"
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
c8f0808d9cd81ece5f04c33388e6c5a056e2ceeb03308a1aa390ea6afc22d6ba *amd64-linux.elf/upx-3.91
685b7e419b8b0fe3cabdf338a5cad17da55edc608c1bb91c13580b5988d38908 *arm-wince.pe/upx-3.91.exe
7344cf818e8a668c7364f47779742bf41b451ebb7db85abc917c463a5f9c9d9a *armeb-linux.elf/upx-3.91
fd0652470c19ebb4a2d1a49e02e71acf9fadab78e513bb4f75d1dc26a0caa7a3 *i386-dos32.djgpp2.coff/upx-3.91.exe
3b9dd7de613541f567b2573063399473deeaa015a1c3679fe0fb339d80724e0d *i386-linux.elf/upx-3.91
5b334db8debd2d59470cad25c7b45e38f6195cdafe92dc8281e4edc9c51385ef *i386-win32.pe/upx-3.91.exe
db1c6a70d990cb9a8e02db9b28054267658ce371b8a50e909efdd04cd3670279 *m68k-atari.tos/upx-3.91.ttp
19b801ace68ca0ff034dd557d3ef0a8340d8f17d7b97f120727f67ce098a7d7a *mipsel-linux.elf/upx-3.91
a0b3ba40848df9b3a8aac31bc20671992be179ec2d702337bd1addd15513c2e4 *powerpc-linux.elf/upx-3.91
"
########## end .sha256sums.recreate
source "$argv0dir/travis_testsuite_1-expected_sha256sums.sh" || exit 1
# /***********************************************************************
# // init
@@ -264,13 +171,15 @@ if [[ $BM_T =~ (^|\+)valgrind($|\+) ]]; then
fi
if [[ $BM_B =~ (^|\+)coverage($|\+) ]]; then
(cd / && cd $upx_BUILDDIR && lcov -d . --zerocounters)
(cd / && cd "$upx_BUILDDIR" && lcov -d . --zerocounters)
fi
export UPX="--prefer-ucl --no-color --no-progress"
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
export UPX_DEBUG_DOCTEST_VERBOSE=0
# let's go
if ! $upx_run --version; then echo "UPX-ERROR: FATAL: upx --version FAILED"; exit 1; fi
if ! $upx_run --version-short; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
if ! $upx_run -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
if ! $upx_run --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
rm -rf ./testsuite_1
@@ -285,7 +194,7 @@ testdir=t010_decompressed
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
testsuite_header $testdir
for f in $upx_testsuite_SRCDIR/files/packed/*/upx-3.91*; do
for f in $upx_testsuite_SRCDIR/files/packed/*/upx-3.9[15]*; do
testsuite_split_f $f
[[ -z $fb ]] && continue
echo "# $f"
@@ -294,7 +203,6 @@ for f in $upx_testsuite_SRCDIR/files/packed/*/upx-3.91*; do
done
testsuite_check_sha $testdir
# run one pack+unpack step to canonicalize the files
testdir=t020_canonicalized
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
@@ -316,52 +224,71 @@ testsuite_check_sha $testdir
# // test UPX and not the compression libraries
# ************************************************************************/
case $UPX_TESTSUITE_FAST in
[0-7]) ;;
*) UPX_TESTSUITE_FAST=999 ;;
esac
if [[ $UPX_TESTSUITE_FAST -ge 1 ]]; then
testdir=t110_compress_ucl_nrv2b_3_no_filter
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
time testsuite_run_compress --nrv2b -3 --no-filter
fi
if [[ $UPX_TESTSUITE_FAST -ge 2 ]]; then
testdir=t120_compress_ucl_nrv2d_3_no_filter
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
time testsuite_run_compress --nrv2d -3 --no-filter
fi
if [[ $UPX_TESTSUITE_FAST -ge 3 ]]; then
testdir=t130_compress_ucl_nrv2e_3_no_filter
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
time testsuite_run_compress --nrv2e -3 --no-filter
fi
if [[ $UPX_TESTSUITE_FAST -ge 4 ]]; then
testdir=t140_compress_lzma_2_no_filter
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
time testsuite_run_compress --lzma -2 --no-filter
fi
if [[ $UPX_TESTSUITE_FAST -ge 5 ]]; then
testdir=t150_compress_ucl_2_all_filters
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
time testsuite_run_compress -2 --all-filters
fi
if [[ $UPX_TESTSUITE_FAST -ge 6 ]]; then
testdir=t160_compress_all_methods_1_no_filter
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
time testsuite_run_compress --all-methods -1 --no-filter
fi
if [[ $UPX_TESTSUITE_FAST -ge 7 ]]; then
testdir=t170_compress_all_methods_no_lzma_5_no_filter
mkdir $testdir; v=expected_sha256sums__$testdir; echo -n "${!v}" >$testdir/.sha256sums.expected
time testsuite_run_compress --all-methods --no-lzma -5 --no-filter
fi
# /***********************************************************************
# // summary
# ************************************************************************/
# recreate checkums from current version for an easy update in case of changes
# recreate checksums from current version for an easy update in case of changes
recreate_expected_sha256sums .sha256sums.recreate
testsuite_header "UPX testsuite summary"
if ! $upx_run --version; then
echo "UPX-ERROR: upx --version FAILED"
if ! $upx_run --version-short; then
echo "UPX-ERROR: upx --version-short FAILED"
exit 1
fi
echo
echo "upx_exe='$upx_exe'"
if [[ "$upx_run" != "$upx_exe" ]]; then
if [[ $upx_run != "$upx_exe" ]]; then
echo "upx_run='$upx_run'"
fi
if [[ -f "$upx_exe" ]]; then
if [[ -f $upx_exe ]]; then
ls -l "$upx_exe"
file "$upx_exe" || true
fi
@@ -1,68 +0,0 @@
uqz4mAtKkF5Ex7Zt2tRP9mhQsAYn5+Xbupfuhee/s+2yVdBBdlXXRN2Q2AhMxF01
myhEuAtRNoQ4m7eyNgNU01pKb+dlyw2xiS+izm9+5fxuuEZfiuv76tQToQLltSdq
jP3Gt08MloJGcWraFiAXXji0S45MasJO3VOdygz09PbzIvGVp/NskGCMCU9lJlRt
2CsItWR+iHs6HNurWEKtEZz4qR8+HZ6RU5IquOnnHnI357lVUiC1w2qRcxmNVWuI
qS7GPvgisv0m4XMxe+l4L3b6a7laZr/hqHjFQqu/aO9Kmy5WmYRe3Bx4hTv5vqRi
OBDOUzwUcrdlUu2wqcvZhVxPaxxqA5u8G63Z3O30VCtWPZVU4yx9TRzcy/0lwxol
dw1b5t7Bl8uIzNyLsFMVS1MpnBspUrxBko6TqLAhv/DvUQmWGJRkP4Ar9naB4myS
vX6sim+Jn57Fr8aZMlvJbqlNindjxnX6+13u51C80GaYJBjHLkAIPaTTNLviOWpj
rbACDifaFloAsgJqz0KK/T7eohJBH2jVe2d9YxU6wZq6THDKJaeQ+nG5MWYvlkWa
K3N+jN8KI1GWqNpUtD8rbLPY1UZo05wQFZBCfdvEZoYdzJFVIS3t6kr0/gOIZu0D
AAIfIcopnpWpUk52MOEekzRRjJuF8fUMkiPX1oVs9HMKW+TU+yx/sFia+ke76w3i
1oiHKJJJNaoCjQXlAcT40rGLmSTLgL0ACCWIMGjK1QJYkpER8GCBCh9/whrJ3k1Q
0hm5hYiGty2ysRJFLIFPkYjangz7hIVzgOUSTYhVjJmIA62W2LmNKcixGX+sssCJ
/DK/Zs0uPiEX4gjkiomDksn7Dy8vAtHe7PzWpZA83mgPK+6zxoM6dgpM7FSe5q1/
tyf394l4nB7eayRUnx3NfK2/PTwrJcms5yAD9Hm2h72cp26TXh+RDVYWOgVX5/N0
dIsDRYo+/077pRTKwiCPrMxTxys53HHV7r5APd+FPmxikXvuszZvYTZ9K2MZB/1L
S2MCJ/u4GTTCwcbvfEjKVs3Fbqu7c2D/tVzakVEmMXloEAGPN/NrzOJsMMEDhWiw
g1wneAg5qF5nG+7R5WqstAeaRCYdXl46xay7iePZQ7viwHA8Zjuke18eHmh7J5jz
uzdh81rxCL3beoXb+BEr1/yKWfrJVTl33+m6c+zxdrV0B7O/ijlYxjke7Wo+ESac
WM2a4xU/WgXMi2+83XqcSZcRPdusZKA6bcTvAcYc/r8t7O1wjfPsTVj0WaM2DwL0
P1QTU4INmVn94zIV0+fGfyN0qI3YiS5iuOoPwLOVB13YECIyXnZz2/VJF7ZASOpS
701or4uF7GVEZxw19ow0AQttk6J/bEzbr7rZ5Um1yCMeQQ1TMHepJfuUbxle4W4S
8w8yC/Ytcy/e4rbiLG2/cY5b35LxtH1TCuaEtuiqa7vkmzr36qqD6fRWnXWC9QdR
0nWyJNj0xIIyMyilnBY2clAjDdT9qd2tMfpoz9hyBkTZPltzDw6Xd/IhhyL1URav
h0NCABGqXbpg8q7KCrIzIE6dJIh+7glfQuWkynmInntN4+fqk9Ked0haHkq5oGH5
vN5ZQNWPyQ67LaXQ4kW8iksgkgl7JEQsuie8oMuQZe13D4S3PWGFKchrBFGwN2xY
ut2+PCs5Al2BHU0qaCKdV7nCqv2tPC8G4uXNw081R2KwyoRlbKhowgFBYBTQIobJ
pc1GLU7HKm9tC61xIZ4u9oij/Bz1+gxx9vLxfx++EC/8UI23oMGygaYdda4gdEtm
v1wt8ldpzO4owI+9peFSolGLwKztwSPxln+5bvOsdsaZ6z5uW37N5ch/EwSwdmfo
Sm1i7fv/zQuZjmZkJXRJGvTd+sKdu7+IZUrTpu5W+jUfMAgmPc+AuYmSOn00K9dv
IJKY973ggNDaJKEw1uKzckl9uk/HRrgk+wgZPaWVRhOulj1npyFf+WmrZ2r3nTq0
koEI8UEselRuKJmojl4O0bz8fXZNgPtpLB/A0cdrj0Ist5TR+qRW9h3eSsybDYRS
GWP4UzFLAIwHflwNX0Q+9/u0uOxaXX6dKXzoddWksInBzh1pmQfrtUM3y7bHQYG5
zqnAMNMwm4WmtmF/mpjg0fKpiwFUU1geygkOwUsaK5Qcp5F0FPocdPRWVxUG0t3Y
QsmSpU5STb99YCs4TvhfUnQmdB2r+d0pZhlMte3v5lcpekSb2FxbUwdX3t9S2uGy
ho9CYmUj1+8ivUizjTLirOu/B8ohQT6kwvNqRSiQwU+YPa5DpxA1DYamIg6ehuX5
6u/dF4Eht+Cn6hasyzFviIUnV1y4ixLfSb0EGw+YoLbHgr8X4Uv4guaNQduKJyEu
g6p1v40fDhZ8AuQly+BOLL0yBlQoDrkY9+3HcIZAC5NmJFU5hle4Hz4gLzS6DwXo
2u8tqIELdtP9Zo4SKM7/yNy+rjl2RNRUEUNjidZsWuIC4bEeL3sUImP0Wt+zpdV0
y0RK1/wPW4dES5xFTCUp9xdP08dsSMtIrYJeBXbHrTZswnuOvk4MYGpmn/qy+qwc
GnkJtzJVm+uNspYuD0cW+JbJz5T+w1eNbejjZ+QVhqmE7ctSHndQUSueIyOcm79E
23jLzIoHMSHsiBJ8KeHN5bTfe66Gl8y3LIOpfchYd5XzkqxS7M01PxkWGZDWGYdl
6Gx64mg7ojPrSNaOzAu3da8oLvGi/YIf3wdJenZqiTzBnSzRsBnTpohQddHbB1Hj
uogDJSoad0ZSY0lLcvxncPB29hKpljFZ4IHO2UKOyO9+LFKsfK8/RbdSx/sHcUaH
hblVkVTSRReHmShxSw6abYZHivGNV0tXNXkY6uEzOMe+Vck9j9dTBSK0bFS/2Xdd
ZII/KFQH10+WEYyw+FurMUeVwU/FER4qpy+13r1PjxMSHfnJviEb8EjgvrcwAUDX
G9JNVtL4Vui6NMFV1u2qkbEMZK763YAIKYZC9UZYjbbhhgYTTMEfRcNvwVCix8nH
2TlWGhivuw5abE9QFduT1fHXJL+1uCn2GMhS8v3fxUrnGDQFit0YLlGEMm5/wVaM
PIZH5JDHlINUC0vbUrMXCz8Ztg3qhpOLiExlBHTD4vqYt9kniHLXOQfexegSC85C
AKiugEOdoHHYJGjNyXj6c0jTuMAe0CBwAKddUqPQztoKclNb02G2a9l5ColE29Uz
jXAb8PFANNqn4Nnm6oPPF1KxB45vLdT6+F1SRzXZunJ6p9N4E9KBtEOR+ixlcphL
InLJSg5iKTfWhXlSK6eldvVsP2GeoyjliERsKLgq1YGMiCW076dmoxR2Z5iPlD2V
G7Hz5nWjPBIoFhABEnONDxbrYB6ryeunILYcHpAaXSYq4OueRo6QGO8NRqFcNutG
WpwBfIlnu6rl9MDO053SJ1ah6D97n/D5aQa2JMMha0faZz84+MH3cnudAgpPjsG9
9G/2fEP08lQNAFiyY91wW3Mtj2No9+OJVYmwFORJm7IOu5nfuQZbzz9OFPcZLU5Y
DVo86icZgXayytW2XZtCKzVBDse+yi0xblGSNtwHlQIN8gKDVpa0I34DxUkIn1Cl
bk9S6+m6APF9ynN/kVCwMu9Nq3lwzmY6JCb/KX0d66uyVwYG3BN1UEWqJhDJjGep
a2JmHnG1aVhYaE/2EsOc+YP89Oub+KeuCj2dHJj2dH3QDCjr2xZUbLO7mw1tsATH
dPjNEBvxet9UU/RXqhhkfkv1XGr/umWrkjKbFqDNl5Tav/00+I59rboW7C/cWRxN
CVbadLPJlPNRR8+54G+VkDZgqaQprPwYih5a7d2MEzrMtZbU0uCJc839dqMgsf++
k4maampkcDLhxt8bBg43WoDgWxiQ+KVWyEBGmTOT2q4WYeLI9PZLseA9eNJbpt9J
oxtNNdqkU48YZWsq/3L1L0eXdGvv5TIMto4bH3SWuvQ2sepwMRxxwTg8qFrutk9K
OLOUbO1Z2ivh1g6+DAgs3RFmy9hPzzqPmJk8cL6F5tcd/VwGcow3UBJ1+Xn3SE5Y
UCHNrSfSrvDaA3N8jyvS/uPq0qRgp7LQRqrhh5cVPi67goDx/ku/fVbMbcrarO/e
Czv6CX7Id2QliOSMGGVId+ECXBvuIGAb2d4til+zTnfhBE2+uS5WQ7MjzH9PKZ7n
TDuV36mA1FDCX+WShPau7R0SGXSqKyeHJ8XSuFHbGwr1Zxwoq4GBYIcAxWjp9HA4
dhBE2x5WSTbnqh1sClxfOeE8MHxi+EUonCcvfvm30NOcC4zw1dCDc6SKLoMJYrFz
EdR3Kt1SJ9M0Jl3dD/gCTKG5kObJzqmo9BladIpQt6c=
+271
View File
@@ -0,0 +1,271 @@
# Support for GitHub Actions -- https://github.com/features/actions
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
# note: GitHub Actions runner images are frequently updated, and
# unfortunately this sometimes breaks builds in mysterious ways...
# see https://github.com/actions/runner-images.git
name: 'CI'
on:
push:
branches:
- '*'
- '!appveyor*'
- '!gitlab*'
- '!travis*'
workflow_dispatch:
env:
UPX_CMAKE_BUILD_FLAGS: --verbose
jobs:
job-rebuild-and-verify-stubs:
name: 'Rebuild stubs'
runs-on: ubuntu-20.04
steps:
- name: 'Install extra packages'
run: |
uname -a; pwd; id; umask
cd ..; mkdir -p deps; cd deps; mkdir packages
# for ubuntu-22.04: install python2
##export DEBIAN_FRONTEND=noninteractive
##sudo apt-get install -y --no-install-recommends python2-minimal
# manually install compat libs from Ubuntu 16.04
wget -q 'http://mirror.enzu.com/ubuntu/pool/main/g/gmp/libgmp10_6.1.0+dfsg-2_amd64.deb'
wget -q 'http://mirror.enzu.com/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb'
for f in *.deb; do dpkg -x $f ./packages; done
sudo mv -v -n ./packages/usr/lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/
sudo ldconfig
wget -q -O - https://github.com/upx/upx-stubtools/releases/download/v20210104/bin-upx-20210104.tar.xz | tar -xJ
- name: 'Check out code'
uses: actions/checkout@v3
with: { submodules: true }
- name: 'Rebuild and verify stubs'
run: |
env C=gcc X=rebuild-stubs TRAVIS_OS_NAME=linux bash ./.github/travis_build.sh
- name: 'Check source code formatting'
run: |
bash ./misc/scripts/check_whitespace_git.sh
env UPX_CLANG_FORMAT="$PWD/../deps/bin-upx-20210104/clang-format-10.0.1" make -C src clang-format
if ! git diff --quiet; then git diff; exit 1; fi
job-linux-cmake:
needs: [ job-rebuild-and-verify-stubs ]
name: ${{ format('{0} cmake', matrix.os) }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-20.04 }
- { os: ubuntu-22.04 }
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with: { submodules: true }
- name: 'Build cmake debug-gcc'
run: 'make build/debug-gcc'
- name: 'Build cmake release-gcc'
run: 'make build/release-gcc'
- name: 'Build cmake debug-clang'
run: 'make build/debug-clang'
- name: 'Build cmake release-clang'
run: 'make build/release-clang'
- name: 'Make artifact'
run: |
N=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}
mkdir -p "tmp/artifact/$N"
(cd build && cp -ai --parents */upx "../tmp/artifact/$N")
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
# GitHub Actions magic: set "artifact_name" environment value for use in next step
echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: tmp/artifact
- name: 'Run basic tests'
run: |
make -C build/debug-gcc test
make -C build/release-gcc test
make -C build/debug-clang test
make -C build/release-clang test
job-macos-cmake:
needs: [ job-rebuild-and-verify-stubs ]
name: ${{ format('{0} cmake', matrix.os) }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- { os: macos-11, gcc: gcc-10, gxx: 'g++-10' }
# { os: macos-12, gcc: gcc-11, gxx: 'g++-11' } # disable gcc - XCode 14.0 ld bug
- { os: macos-12 }
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with: { submodules: true }
- name: 'Build cmake debug-gcc'
if: ${{ matrix.gcc != '' }}
run: 'make build/debug-gcc CC=${{ matrix.gcc }} CXX=${{ matrix.gxx }}'
- name: 'Build cmake release-gcc'
if: ${{ matrix.gcc != '' }}
run: 'make build/release-gcc CC=${{ matrix.gcc }} CXX=${{ matrix.gxx }}'
- name: 'Build cmake debug-clang'
run: 'make build/debug-clang'
- name: 'Build cmake release-clang'
run: 'make build/release-clang'
- name: 'Make artifact'
run: |
N=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}
mkdir -p "tmp/artifact/$N"
(cd build && rsync -R -a */upx "../tmp/artifact/$N/")
(cd tmp/artifact && gtar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
# GitHub Actions magic: set "artifact_name" environment value for use in next step
echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: tmp/artifact
- name: 'Run basic tests'
run: |
make -C build/debug-clang test
make -C build/release-clang test
job-windows-cmake:
needs: [ job-rebuild-and-verify-stubs ]
name: ${{ format('{0} cmake', matrix.os) }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# windows-2019 used to work but got broken with the 20220821.1
# runner-image update; disable for now
# see https://github.com/actions/runner-images.git
####- { os: windows-2019 }
- { os: windows-2022 }
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with: { submodules: true }
- name: 'Inspect runner-image settings'
# see https://github.com/actions/runner-images.git
if: ${{ false }}
run: |
Get-Command bash; Get-Command cmake; Get-Command make
bash --version; cmake --version; make --version
Get-Command cl -ErrorAction SilentlyContinue
- name: 'Build cmake debug'
run: 'make build/debug'
- name: 'Build cmake release'
run: 'make build/release'
- name: 'Make artifact'
shell: bash
run: |
N=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}
mkdir -p "tmp/artifact/$N"
(cd build && cp -ai --parents */*/upx.exe "../tmp/artifact/$N")
# GitHub Actions magic: set "artifact_name" environment value for use in next step
echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: tmp/artifact
- name: 'Run basic tests'
run: |
cmake --build build/debug --config Debug --target RUN_TESTS
cmake --build build/release --config Release --target RUN_TESTS
job-windows-toolchains:
needs: [ job-rebuild-and-verify-stubs ]
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
env:
C: ${{ matrix.C }}
B: release
H: 'd:\a\upx'
strategy:
fail-fast: false
matrix:
include:
- { name: amd64-win64-msvc-14.2, os: windows-2019, C: msvc-14.2-x64, A: x64 }
- { name: amd64-win64-msvc-14.3, os: windows-2022, C: msvc-14.3-x64, A: x64 }
- { name: i386-win32-msvc-14.2, os: windows-2019, C: msvc-14.2-x86, A: x86 }
- { name: i386-win32-msvc-14.3, os: windows-2022, C: msvc-14.3-x86, A: x86 }
steps:
- name: 'Check out code'
uses: actions/checkout@v3
with: { submodules: true }
- name: 'Prepare sources'
shell: cmd
run: |
where bash & where cat & where chmod & where cmp & where cp & where curl & where date & where file & where git & where gzip & where mkdir & where mv & where openssl & where readlink & where rm & where rmdir & where sed & where sha256sum & where sort & where ssh & where ssh-add & where ssh-agent & where ssh-keyscan & where tar & where touch
git config --global core.autocrlf input
git --version & bash --version
cd %H%
md build build\%C% deps
cd deps
git clone --depth=1 https://github.com/upx/upx-testsuite
- name: 'Set up Developer Command Prompt'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.A }}
- name: 'Build'
shell: cmd
run: |
@REM setup directories following the VPATH build in travis_build.sh
where cl & where link
set BDIR=%H%\build\%C%\%B%
md %BDIR% %BDIR%\ucl %BDIR%\upx %BDIR%\upx-testsuite %BDIR%\zlib
set DEFS=-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS
git rev-parse --short=12 HEAD > %BDIR%\upx\.GITREV.txt
@REM ===== build UCL =====
cd %BDIR%\ucl
set s=%H%\upx\vendor\ucl
cl -MT -J -O2 -W4 %DEFS% -I%s%\include -I%s% -c %s%\src\*.c
link -lib -out:ucl.lib *.obj
@REM ===== build zlib =====
cd %BDIR%\zlib
cl -MT -J -O2 -W3 %DEFS% -c %H%\upx\vendor\zlib\*.c
link -lib -out:zlib.lib *.obj
@REM ===== build UPX =====
cd %BDIR%\upx
set s=%H%\upx\src
cat .GITREV.txt
set /p GITREV=<.GITREV.txt
cl -MT -EHsc -J -O2 -W4 -WX -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% -I%H%\upx\vendor -Feupx.exe %s%\*.cpp %s%\util\*.cpp %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib /link setargv.obj
- name: 'Make artifact'
shell: bash
run: |
N=upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.name }}
mkdir -p "tmp/artifact/$N/$B"
cp -ai ../build/$C/$B/upx/upx*.exe "tmp/artifact/$N/$B"
# GitHub Actions magic: set "artifact_name" environment value for use in next step
echo "artifact_name=$N" >> $GITHUB_ENV
- name: ${{ format('Upload artifact {0}', env.artifact_name) }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: tmp/artifact
- name: 'Run basic tests'
run: |
$ErrorActionPreference = 'stop'
$ErrorView = 'NormalView'
cd $Env:H\build\$Env:C\$Env:B\upx
$Env:UPX = "--no-color --no-progress"
.\upx.exe --version
.\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'
run: |
bash ./.github/travis_testsuite_1.sh
# vim:set ts=2 sw=2 et:
+35
View File
@@ -0,0 +1,35 @@
# see https://docs.github.com/en/actions/managing-issues-and-pull-requests/closing-inactive-issues
# see https://github.com/actions/stale
# Automatically closing issues is far from perfect, but then we only have
# limited resources and this approach favors issues that people
# actually care about.
#
# also see:
# "Should I Stale or Should I Close? An Analysis of a Bot that Closes
# Abandoned Issues and Pull Request".
# https://igorwiese.com/images/papers/Paper_BotSE_19.pdf
name: 'Close inactive issues'
on:
schedule:
- cron: "30 6 * * 4"
workflow_dispatch:
jobs:
close-issues:
name: 'Close inactive issues'
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v6
with:
# operations-per-run: 300
days-before-stale: 60
days-before-close: 30
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Please remove the stale label or add a comment or this issue will be closed in 30 days.'
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Please remove the stale label or add a comment or this PR will be closed in 30 days.'
close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity. Please feel free to reopen.'
close-pr-message: 'This PR was closed because it has been stalled for 30 days with no activity. Please feel free to reopen.'
repo-token: ${{ secrets.GITHUB_TOKEN }}
+38
View File
@@ -0,0 +1,38 @@
name: "CodeQL"
on:
push:
branches: [ "devel", "devel4", "devel5", "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "devel", "devel4", "devel5" ]
schedule:
- cron: '20 1 * * 3'
workflow_dispatch:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with: { submodules: true }
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
+16
View File
@@ -0,0 +1,16 @@
name: 'Close pull requests'
on:
#pull_request:
workflow_dispatch:
jobs:
close-pull-requests:
name: 'Close pull requests'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: 'Close pull requests'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr list --repo='${{ github.repository }}' --state=open --json=number | jq '.[].number' | xargs -r -n1 -- gh pr close --repo='${{ github.repository }}'
+8 -17
View File
@@ -1,9 +1,9 @@
/.bzr*
/.hg*
/.vscode*
/Makevars.global*
/build*
/maint*
/vendor*
.depend
GNUmakefile
@@ -12,32 +12,23 @@ Makevars.local*
tmp-testsuite*
*.a
*.d
*.dll
*.exe
*.lib
*.map
*.o
*.obj
*.out
*.py[cdo]
*.so
*.swp
*.ttp
doc/*.1
doc/*.doc
doc/*.html
doc/*.man
doc/*.ps
doc/*.tex
src/compress_nrv*
src/*.mft
src/*.rc
src/*.d
src/*.exe
src/*.map
src/*.o
src/*.obj
src/*.out
src/*.res
src/*.ttp
src/stub/**/.*-stamp
src/stub/**/MMakefile
src/stub/tmp*/*.bin
+20 -4
View File
@@ -1,4 +1,20 @@
[submodule "src/lzma-sdk"]
path = src/lzma-sdk
url = https://github.com/upx/upx-lzma-sdk.git
branch = master
[submodule "vendor/doctest"]
path = vendor/doctest
url = https://github.com/upx/upx-vendor-doctest.git
branch = upx-vendor
shallow = true
[submodule "vendor/lzma-sdk"]
path = vendor/lzma-sdk
url = https://github.com/upx/upx-vendor-lzma-sdk.git
branch = upx-vendor
shallow = true
[submodule "vendor/ucl"]
path = vendor/ucl
url = https://github.com/upx/upx-vendor-ucl.git
branch = upx-vendor
shallow = true
[submodule "vendor/zlib"]
path = vendor/zlib
url = https://github.com/upx/upx-vendor-zlib.git
branch = upx-vendor
shallow = true
-262
View File
@@ -1,262 +0,0 @@
# Support for Travis CI -- https://travis-ci.org/upx/upx/builds
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
sudo: false
language: cpp
notifications: { email: { on_success: never, on_failure: change } }
.ubuntu_toolchain_sources: &S
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.5
- llvm-toolchain-precise-3.6
- llvm-toolchain-precise-3.7
- llvm-toolchain-precise-3.8
- llvm-toolchain-precise-3.9
env:
global:
- CROSS= C= B= T= X=
- secure: "YXHLXK+CM5d8yELIUSSs+P0/CoefClO7/AUX1oBj5W75g+YzR5uS2doVsB8UH8S8/GdNxk4P9Jgn4EiEVnjfGgn2eAD9MVpDPIxyJs5vI+5G77asq3QNdSl6QFv3O9I/6yBoVCewgPFPqsMd7Yvs/Ea3LcQkqalVhrC8ybYtmfs6VL2w33gn2J3b3TCn/s21L0ijklM0xvP1GNMDtuUpTSish5wvGOHE/91rwtdUDbJR8u31QY7fTASDiNnL/7ihgEIZ5XxpDYXviX1GC+nemhX1fWpmVmuT8m30Ruodi0yJVGASw9i2SaKv/VX/fJ/w2vlCfspL5LMZKkVLlfpIo3mQGqmMHFxv7mNy+hRu50ptoWNSkWArcqifwveh2liHUpl4jTvWaVll5Tw5VUGJhAUdzCTnqLIbWFnKIgCedL3iRFi4+EbyWNxel8lFESMOTDZFfJG5yEiDJbgbLsUaT2GmrsOphwAG7zDcZzvYTdjg/lF4Wh0MUnQJ+0MhDpii8Ahjp49lAPdw8uRQyyY7d7ksYKXVIkbgl6dRCC5vZSPucJiFjq2BClqIoEmzZPvHveDbovzFkNhJX9tFLrHLcXbPPcegww1FGoQ3wBM6JwJ+TvSD6N4OdCmou05aDuuQeznHi3GxOScjGwxdMIU28fdJDCTDg2rOihm22kHVajo="
- secure: "JpSv3+QRmHcfN/bmT3mVkqET44NCPhM/qpcUssCVXnd2GW0qWURoyPHzVMn/gbeAkUjR6djtN3OzJ+M181QmlmTmE26pZC9Q6r1buNDWdkIH1FcpMCa67BBAjmq+yDwulDtvCMv0lbz60v57lzHBOLczF3yMxBVTjXxt1RsrzDLHzzVaDR5lEe+sQUNeRL7Vaq8crimPNTr4ZhMe59eweTO/3AWovuSPf250k1flfv7I8audZgrVZdbVKvj5C3Sziy1AGXcu8mDfET9/Ya2XBCQHWODjiKlnhSxqthhP3gQuacaLjpS2FjvQlamd+I9x6BBoLSeNbiXD9vgCydDUKvmUrU+zQs64U1hHk9WZWVC19kG7lTtTdanGDIUlIUtFZgqE4AQpJaIUWkUmHGyHi61JMvduzX21eL5c5j9DoJteX42FPb1n3xK/JSnUkLMpbFdQuy5inhzefhDfeNzaYxt8nPwHnJqrF73SW4PLDKeRyzvg/P+zqcou8nXrHfA1z9/FlnYzf7Qc9meai9Q/JARX3Q1ZKu5uyG+RuBLe2POq0192w6pflTr1ZlLJsKNSc1147PviKfmpla1lg3/6uVzMp5tgwbve/hx9SDXiRueGttKw/ymsY662+8G24NRKo4fxNklWFHaB4owM84edDzXDckPXbPgue8/HQT8BFio="
matrix:
fast_finish: true
include:
- os: linux
sudo: required
dist: trusty
compiler: gcc
env: X=rebuild-stubs
addons: { apt: { packages: [ "g++-multilib", "lib32z1" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.4-m32
addons: { apt: { sources: *S, packages: [ "g++-4.4-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.4-m64
addons: { apt: { sources: *S, packages: [ "g++-4.4" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.5-m32
addons: { apt: { sources: *S, packages: [ "g++-4.5-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.5-m64
addons: { apt: { sources: *S, packages: [ "g++-4.5" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.6-m32
addons: { apt: { packages: [ "g++-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.6-m64
- os: linux
compiler: gcc
env: C=gcc-4.7-m32
addons: { apt: { sources: *S, packages: [ "g++-4.7-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.7-m64
addons: { apt: { sources: *S, packages: [ "g++-4.7" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.8-m32
addons: { apt: { sources: *S, packages: [ "g++-4.8-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.8-m64
addons: { apt: { sources: *S, packages: [ "g++-4.8" ] } }
- os: linux
sudo: required
dist: trusty
compiler: gcc
env: C=gcc-4.8-mx32
addons: { apt: { packages: [ "g++-multilib", "libx32stdc++-4.8-dev" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.9-m32
addons: { apt: { sources: *S, packages: [ "g++-4.9-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-4.9-m64
addons: { apt: { sources: *S, packages: [ "g++-4.9" ] } }
- os: linux
compiler: gcc
env: C=gcc-5-m32
addons: { apt: { sources: *S, packages: [ "g++-5-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-5-m64
addons: { apt: { sources: *S, packages: [ "g++-5" ] } }
- os: linux
compiler: gcc
env: C=gcc-6-m32
addons: { apt: { sources: *S, packages: [ "g++-6-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-6-m64
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
- os: linux
compiler: gcc
env: C=gcc-6-m32 B=debug
addons: { apt: { sources: *S, packages: [ "g++-6-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: gcc
env: C=gcc-6-m64 B=debug
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
- os: linux
compiler: gcc
env: C=gcc-6-m64 B=debug+sanitize
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
- os: linux
compiler: gcc
env: C=gcc-6-m64 B=sanitize
addons: { apt: { sources: *S, packages: [ "g++-6" ] } }
- os: linux
compiler: gcc
env: C=gcc-6-m64 B=valgrind T=valgrind
addons: { apt: { sources: *S, packages: [ "g++-6", valgrind ] } }
- os: linux
compiler: clang
env: C=clang-3.4-m32
addons: { apt: { packages: [ "g++-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: clang
env: C=clang-3.4-m64
- os: linux
compiler: clang
env: C=clang-3.5-m32
addons: { apt: { sources: *S, packages: [ "clang-3.5", "g++-6-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: clang
env: C=clang-3.5-m64
addons: { apt: { sources: *S, packages: [ "clang-3.5" ] } }
- os: linux
compiler: clang
env: C=clang-3.6-m32
addons: { apt: { sources: *S, packages: [ "clang-3.6", "g++-6-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: clang
env: C=clang-3.6-m64
addons: { apt: { sources: *S, packages: [ "clang-3.6" ] } }
- os: linux
compiler: clang
env: C=clang-3.7-m32
addons: { apt: { sources: *S, packages: [ "clang-3.7", "g++-6-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: clang
env: C=clang-3.7-m64
addons: { apt: { sources: *S, packages: [ "clang-3.7" ] } }
- os: linux
compiler: clang
env: C=clang-3.8-m32
addons: { apt: { sources: *S, packages: [ "clang-3.8", "g++-6-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: clang
env: C=clang-3.8-m64
addons: { apt: { sources: *S, packages: [ "clang-3.8" ] } }
- os: linux
compiler: clang
env: C=clang-3.9-m32
addons: { apt: { sources: *S, packages: [ "clang-3.9", "g++-6-multilib", "zlib1g-dev:i386" ] } }
- os: linux
compiler: clang
env: C=clang-3.9-m64
addons: { apt: { sources: *S, packages: [ "clang-3.9" ] } }
- os: linux
compiler: clang
env: C=clang-3.9-m64 B=debug+sanitize
addons: { apt: { sources: *S, packages: [ "clang-3.9" ] } }
- os: linux
compiler: clang
env: C=clang-3.9-m64 B=sanitize
addons: { apt: { sources: *S, packages: [ "clang-3.9" ] } }
- os: linux
compiler: clang
env: C=clang-3.9-m64 B=debug+scan-build
addons: { apt: { sources: *S, packages: [ "clang-3.9" ] } }
- os: linux
compiler: clang
env: C=clang-3.9-m64 B=scan-build
addons: { apt: { sources: *S, packages: [ "clang-3.9" ] } }
- os: linux
compiler: gcc
env: CROSS=arm-linux-gnueabi C=gcc-4.6 T=SKIP
addons: { apt: { packages: [ "g++-arm-linux-gnueabi", "qemu-user" ] } }
- os: linux
compiler: gcc
env: CROSS=arm-linux-gnueabihf C=gcc-4.6 T=SKIP
addons: { apt: { packages: [ "g++-arm-linux-gnueabihf", "qemu-user" ] } }
- os: linux
compiler: gcc
env: CROSS=i386-w64-mingw32 C=gcc-4.6 T=wine
addons: { apt: { packages: [ "binutils-mingw-w64-i686", "g++-mingw-w64-i686", "wine" ] } }
- os: linux
compiler: gcc
env: CROSS=x86_64-w64-mingw32 C=gcc-4.6 T=wine
addons: { apt: { packages: [ "binutils-mingw-w64-x86-64", "g++-mingw-w64-x86-64", "wine" ] } }
- os: osx
osx_image: xcode6.4
compiler: clang
# must use debug build or else we get "ld: internal error: atom not found" when linking
env: C=clang-602-m32 B=debug
- os: osx
osx_image: xcode6.4
compiler: clang
# must use debug build or else we get "ld: internal error: atom not found" when linking
env: C=clang-602-m64 B=debug
- os: osx
osx_image: xcode7.3
compiler: clang
env: C=clang-703-m32
- os: osx
osx_image: xcode7.3
compiler: clang
env: C=clang-703-m64
- os: osx
osx_image: xcode8.3
compiler: clang
env: C=clang-802-m32
- os: osx
osx_image: xcode8.3
compiler: clang
env: C=clang-802-m64
install:
- uname -a; pwd; id; umask
- cat /etc/os-release || true
- |
cd /
if [[ $TRAVIS_OS_NAME == linux ]]; then
if [[ $B =~ (^|\+)coverage($|\+) ]]; then
travis_retry pip install --user cpp-coveralls
fi
fi
if [[ $TRAVIS_OS_NAME == osx ]]; then
if ! gsha256sum </bin/sh >/dev/null 2>/dev/null; then travis_retry brew install coreutils; fi
if [[ $B =~ (^|\+)coverage($|\+) ]]; then
travis_retry brew install lcov
travis_retry pip install --user cpp-coveralls
fi
fi
- git --version && bash --version
- umask 022; cd $TRAVIS_BUILD_DIR && mkdir -p ../deps ../build/travis
- cd ../deps && travis_retry wget -q -O - https://github.com/upx/upx/releases/download/v3.00/ucl-1.03.tar.xz | tar -xJ
- cd ../deps && travis_retry wget -q -O - https://github.com/upx/upx/releases/download/v3.00/zlib-1.2.8.tar.xz | tar -xJ
- cd ../deps && travis_retry git clone https://github.com/upx/upx-testsuite
- |
if [[ $X =~ (^|\+)rebuild-stubs($|\+) ]]; then
cd ../deps && travis_retry wget -q -O - https://github.com/upx/upx-stubtools/releases/download/v20160918/bin-upx-20160918.tar.xz | tar -xJ
fi
script:
- success=1
- cd $TRAVIS_BUILD_DIR || success=0
- test $success = 0 || bash ./.github/travis_build.sh || success=0
- test $success = 0 || bash ./.github/travis_testsuite_1.sh || success=0
- test $success = 0 || bash ./.github/travis_deploy.sh || success=0
- test $success = 1
# vim:set ts=2 sw=2 et:
+234
View File
@@ -0,0 +1,234 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
# config options
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info.")
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options.")
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option.")
#***********************************************************************
# init
#***********************************************************************
# Disallow in-source builds. Note that you will still have to manually
# clean up a few files if you accidentally try an in-source build.
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_BINARY_DIR},")
message(FATAL_ERROR "ERROR: In-source builds are not allowed, please use an extra build dir.")
endif()
# determine git revision
set(GITREV_SHORT "")
set(GITREV_PLUS "")
find_package(Git)
if(GIT_FOUND AND NOT UPX_CONFIG_DISABLE_GITREV)
execute_process(
RESULT_VARIABLE result
COMMAND "${GIT_EXECUTABLE}" rev-parse --short=12 HEAD
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE GITREV_SHORT
)
string(LENGTH "${GITREV_SHORT}" l)
if(${result} EQUAL 0 AND ${l} EQUAL 12)
execute_process(RESULT_VARIABLE result COMMAND "${GIT_EXECUTABLE}" diff --quiet)
if(NOT ${result} EQUAL 0)
set(GITREV_PLUS "+")
endif()
else()
set(GITREV_SHORT "")
endif()
endif()
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git") # extra check
set(GITREV_SHORT "")
endif()
if(GITREV_SHORT)
message(STATUS "UPX_VERSION_GITREV = \"${GITREV_SHORT}${GITREV_PLUS}\"")
else()
message(STATUS "UPX_VERSION_GITREV: not set")
endif()
project(upx VERSION 4.0.0 LANGUAGES C CXX)
# set default build type to "Release"
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(is_multi_config)
set(c "${CMAKE_CONFIGURATION_TYPES}")
list(INSERT c 0 "Release")
list(INSERT c 1 "Debug")
if (CMAKE_BUILD_TYPE)
list(INSERT c 0 "${CMAKE_BUILD_TYPE}")
endif()
list(REMOVE_DUPLICATES c)
set(CMAKE_CONFIGURATION_TYPES "${c}" CACHE STRING "List of supported configuration types." FORCE)
elseif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()
#***********************************************************************
# targets and compilation flags
#***********************************************************************
file(GLOB ucl_SOURCES "vendor/ucl/src/*.c")
list(SORT ucl_SOURCES)
add_library(upx_vendor_ucl STATIC ${ucl_SOURCES})
set_property(TARGET upx_vendor_ucl PROPERTY C_STANDARD 11)
file(GLOB zlib_SOURCES "vendor/zlib/*.c")
list(SORT zlib_SOURCES)
add_library(upx_vendor_zlib STATIC ${zlib_SOURCES})
set_property(TARGET upx_vendor_zlib PROPERTY C_STANDARD 11)
file(GLOB upx_SOURCES "src/*.cpp" "src/util/*.cpp")
list(SORT upx_SOURCES)
add_executable(upx ${upx_SOURCES})
set_property(TARGET upx PROPERTY CXX_STANDARD 14)
target_link_libraries(upx upx_vendor_ucl upx_vendor_zlib)
if(UPX_CONFIG_DISABLE_WERROR)
set(warn_Werror "")
set(warn_WX "")
else()
set(warn_Werror -Werror)
set(warn_WX -WX)
endif()
if(NOT MSVC)
# use -O2 instead of -O3 to reduce code size
string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" a "${CMAKE_C_FLAGS_RELEASE}")
string(REGEX REPLACE "(^| )-O3( |$$)" "\\1-O2\\2" b "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${a}" CACHE STRING "Flags used by the C compiler during RELEASE builds." FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${b}" CACHE STRING "Flags used by the CXX compiler during RELEASE builds." FORCE)
endif()
if(MSVC)
# disable silly warnings about using "deprecated" POSIX functions like fopen()
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
else()
# protect against security threats caused by misguided compiler "optimizations"
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
add_definitions(-fno-delete-null-pointer-checks)
endif()
add_definitions(-fno-strict-aliasing -fno-strict-overflow -funsigned-char)
# disable overambitious auto-vectorization until this actually gains something
add_definitions(-fno-tree-vectorize)
endif()
set(t upx_vendor_ucl)
target_include_directories(${t} PRIVATE vendor/ucl/include vendor/ucl)
if(MSVC)
target_compile_options(${t} PRIVATE -J -W4 ${warn_WX})
else()
target_compile_options(${t} PRIVATE -Wall -Wextra -Wvla ${warn_Werror})
endif()
set(t upx_vendor_zlib)
if(MSVC)
target_compile_options(${t} PRIVATE -DHAVE_STDARG_H -DHAVE_VSNPRINTF -J -W3 ${warn_WX})
else()
target_compile_options(${t} PRIVATE -DHAVE_STDARG_H -DHAVE_UNISTD_H -DHAVE_VSNPRINTF)
# clang-15: -Wno-strict-prototypes is needed to silence the new -Wdeprecated-non-prototype warning
target_compile_options(${t} PRIVATE -Wall -Wextra -Wvla -Wno-strict-prototypes ${warn_Werror})
endif()
set(t upx)
target_include_directories(${t} PRIVATE vendor)
target_compile_definitions(${t} PRIVATE $<$<CONFIG:Debug>:DEBUG=1>)
if(GITREV_SHORT)
target_compile_definitions(${t} PRIVATE UPX_VERSION_GITREV="${GITREV_SHORT}${GITREV_PLUS}")
endif()
if(NOT UPX_CONFIG_DISABLE_SANITIZE AND NOT MSVC)
# default sanitizer for Debug builds
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>)
# default sanitizer for Release builds
target_compile_options(${t} PRIVATE $<$<CONFIG:Release>:-fstack-protector>)
endif()
if(MSVC)
target_compile_options(${t} PRIVATE -EHsc -J -W4 ${warn_WX})
else()
target_compile_options(${t} PRIVATE
-Wall -Wextra -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith
-Wshadow -Wvla -Wwrite-strings ${warn_Werror}
)
endif()
#***********************************************************************
# "make test"
#***********************************************************************
if(NOT CMAKE_CROSSCOMPILING)
include(CTest)
set(exe ${CMAKE_EXECUTABLE_SUFFIX})
set(upx_self_exe "$<TARGET_FILE:upx>")
add_test(NAME upx-test-cleanup COMMAND rm -f ./upx.packed${exe} ./upx.unpacked${exe})
add_test(NAME upx-version COMMAND upx --version)
add_test(NAME upx-help COMMAND upx --help)
add_test(NAME upx-self-pack COMMAND upx -3 ${upx_self_exe} -o upx.packed${exe})
add_test(NAME upx-list COMMAND upx -l upx.packed${exe})
add_test(NAME upx-fileinfo COMMAND upx --fileinfo upx.packed${exe})
add_test(NAME upx-test COMMAND upx -t upx.packed${exe})
add_test(NAME upx-unpack COMMAND upx -d upx.packed${exe} -o upx.unpacked${exe})
add_test(NAME upx-run-unpacked COMMAND ./upx.unpacked${exe} --version)
add_test(NAME upx-run-packed COMMAND ./upx.packed${exe} --version)
endif()
# TODO: could add some more explicit test programs; but then, the integrated
# "doctest" is quite convenient and already covers a number of basic
# checks - and more complex cases better should be handled by an
# external test suite.
#***********************************************************************
# "make install"
#***********************************************************************
# installation prefix and directories
if(NOT CMAKE_INSTALL_PREFIX)
message(FATAL_ERROR "ERROR: CMAKE_INSTALL_PREFIX is not defined.")
endif()
include(GNUInstallDirs)
if(DEFINED CMAKE_INSTALL_FULL_BINDIR)
install(TARGETS upx DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
install(FILES
COPYING LICENSE NEWS README doc/upx-doc.html doc/upx-doc.txt
DESTINATION "${CMAKE_INSTALL_FULL_DOCDIR}"
)
install(FILES doc/upx.1 DESTINATION "${CMAKE_INSTALL_FULL_MANDIR}/man1")
endif()
#***********************************************************************
# finally print some info about the build configuration
#***********************************************************************
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/maint/src/CMakeLists.extra.txt")
include("${CMAKE_CURRENT_SOURCE_DIR}/maint/src/CMakeLists.extra.txt")
endif()
function(print_var v)
if(${v})
message(STATUS "${v} = ${${v}}")
endif()
endfunction()
print_var(CMAKE_BUILD_TYPE)
print_var(CMAKE_CONFIGURATION_TYPES)
print_var(CMAKE_INSTALL_PREFIX)
print_var(CMAKE_CROSSCOMPILING)
print_var(CMAKE_C_COMPILER_ID)
print_var(CMAKE_C_COMPILER_VERSION)
print_var(CMAKE_C_COMPILER_ARCHITECTURE_ID)
print_var(CMAKE_C_PLATFORM_ID)
print_var(CMAKE_C_COMPILER_ABI)
print_var(CMAKE_CXX_COMPILER_ID)
print_var(CMAKE_CXX_COMPILER_VERSION)
print_var(CMAKE_CXX_COMPILER_ARCHITECTURE_ID)
print_var(CMAKE_CXX_PLATFORM_ID)
print_var(CMAKE_CXX_COMPILER_ABI)
if (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$")
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
endif()
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
+76 -27
View File
@@ -1,36 +1,85 @@
#
# UPX toplevel Makefile - needs GNU make 3.81 or better
#
# Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
# UPX top-level Makefile - needs GNU make and CMake >= 3.13
#
MAKEFLAGS += -rR
.SUFFIXES:
export SHELL = /bin/sh
# NOTE: if you only have CMake 3.10 then you can invoke cmake manually like this:
# mkdir -p build/release
# cd build/release
# cmake ../..
# cmake --build .
srcdir = .
top_srcdir = .
include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
# info: src/stub needs special build tools from https://github.com/upx/upx-stubtools
BUILD_STUB = 0
ifneq ($(wildcard $(HOME)/local/bin/bin-upx/upx-stubtools-check-version),)
BUILD_STUB = 1
endif
ifneq ($(wildcard $(HOME)/bin/bin-upx/upx-stubtools-check-version),)
BUILD_STUB = 1
CMAKE = cmake
UPX_CMAKE_BUILD_FLAGS += --parallel
ifneq ($(VERBOSE),)
UPX_CMAKE_BUILD_FLAGS += --verbose
endif
default:
@echo "UPX info: please choose a target for 'make'"
all mostlyclean clean distclean maintainer-clean:
ifeq ($(BUILD_STUB),1)
$(MAKE) -C src/stub $@
# check git submodules
ifeq ($(wildcard ./vendor/doctest/doctest/.),)
$(error ERROR: missing git submodule; run 'git submodule update --init')
endif
ifeq ($(wildcard ./vendor/lzma-sdk/C/.),)
$(error ERROR: missing git submodule; run 'git submodule update --init')
endif
ifeq ($(wildcard ./vendor/ucl/include/.),)
$(error ERROR: missing git submodule; run 'git submodule update --init')
endif
ifeq ($(wildcard ./vendor/zlib/crc32.c),)
$(error ERROR: missing git submodule; run 'git submodule update --init')
endif
$(MAKE) -C src $@
$(MAKE) -C doc $@
.PHONY: default all mostlyclean clean distclean maintainer-clean
#***********************************************************************
# default
#***********************************************************************
# vim:set ts=8 sw=8 noet:
__check_cache = $(if $(wildcard $1/CMakeCache.txt),@true,)
run_config = $(call __check_cache,$1) $(CMAKE) -S . -B $1 $(UPX_CMAKE_CONFIG_FLAGS) -DCMAKE_BUILD_TYPE=$2
run_build = $(CMAKE) --build $1 $(UPX_CMAKE_BUILD_FLAGS) --config $2
default: build/release
build/debug: PHONY
$(call run_config,$@,Debug)
$(call run_build,$@,Debug)
build/release: PHONY
$(call run_config,$@,Release)
$(call run_build,$@,Release)
#***********************************************************************
# some pre-defined build configurations
#***********************************************************************
# force building with gcc/g++
build/%-gcc: export CC=gcc
build/%-gcc: export CXX=g++
build/debug-gcc: PHONY
$(call run_config,$@,Debug)
$(call run_build,$@,Debug)
build/release-gcc: PHONY
$(call run_config,$@,Release)
$(call run_build,$@,Release)
# force building with clang/clang++
build/%-clang: export CC=clang
build/%-clang: export CXX=clang++
build/debug-clang: PHONY
$(call run_config,$@,Debug)
$(call run_build,$@,Debug)
build/release-clang: PHONY
$(call run_config,$@,Release)
$(call run_build,$@,Release)
# cross compiler: Windows mingw-w64
build/%-cross-mingw64: export CC=x86_64-w64-mingw32-gcc
build/%-cross-mingw64: export CXX=x86_64-w64-mingw32-g++
# disable sanitize to avoid link errors on GitHub CI
build/%-cross-mingw64: UPX_CMAKE_CONFIG_FLAGS += -DUPX_CONFIG_DISABLE_SANITIZE=1
build/debug-cross-mingw64: PHONY
$(call run_config,$@,Debug)
$(call run_build,$@,Debug)
build/release-cross-mingw64: PHONY
$(call run_config,$@,Release)
$(call run_build,$@,Release)
.PHONY: default PHONY
+26 -4
View File
@@ -2,6 +2,27 @@
User visible changes for UPX
==================================================================
Changes in 4.0.0 (28 Oct 2022):
* Switch to semantic versioning
* SECURITY NOTES: emphasize the security context in the docs
* Support easy building from source code with CMake
* Support easy rebuilding the stubs from source with Podman/Docker
* Add integrated doctest C++ testing framework
* Add support for EFI files (PE x86; Kornel Pal)
* bug fixes - see https://github.com/upx/upx/milestone/6
* bug fixes - see https://github.com/upx/upx/milestone/7
Changes in 3.96 (23 Jan 2020):
* bug fixes - see https://github.com/upx/upx/milestone/5
Changes in 3.95 (26 Aug 2018):
* Flag --android-shlib to work around bad design in Android
* Flag --force-pie when ET_DYN main program is not marked as DF_1_PIE
* Better compatibility with varying layout of address space on Linux
* Support for 4 PT_LOAD layout in ELF generated by binutils-2.31
* bug fixes, particularly better diagnosis of malformed input
* bug fixes - see https://github.com/upx/upx/milestone/4
Changes in 3.94 (12 May 2017):
* Add support for arm64-linux (aka "aarch64").
* Add support for --lzma compression on 64-bit PowerPC (Thierry Fauck).
@@ -10,12 +31,11 @@ Changes in 3.94 (12 May 2017):
* bug fixes - see https://github.com/upx/upx/milestone/3
Changes in 3.93 (29 Jan 2017):
* UPX has moved to GitHub - the new home page is https://upx.github.io
* Fixed some win32/pe and win64/pe regressions introduced in 3.92
* bug fixes - see https://github.com/upx/upx/milestone/1
* bug fixes - see https://github.com/upx/upx/milestone/2
Changes in 3.92 (11 Dec 2016):
* UPX has moved to GitHub - the new home page is https://upx.github.io
* INFO: UPX has moved to GitHub - the new home page is https://upx.github.io
* IMPORTANT: all PE formats: internal changes: reunited the diverged source
files - please report all regressions into the bug tracker and try UPX 3.91
in case of problems.
@@ -111,7 +131,7 @@ Changes in 2.93 beta (08 Mar 2007):
you have to explicitly use '--lzma' even for '--ultra-brute' here
because runtime decompression is about 30 times slower than NRV -
which is really noticeable on old machines.
* dos/exe: fixed a rarely occuring bug in relocation handling
* dos/exe: fixed a rarely occurring bug in relocation handling
* win32/pe & arm/pe: better icon compression handling
Changes in 2.92 beta (23 Jan 2007):
@@ -344,6 +364,8 @@ Changes in 0.99 (25 Feb 2000)
* dos/com and dos/sys: fixed a bad decompressor problem
* linux/386: the counter for the progress indicator was off by one
==================================================================
Changes in 0.94 (06 Dec 1999)
* win32/pe: the stub now calls ExitProcess in case of import errors
* under DOS and Windows, the environment variable UPX now accepts
-88
View File
@@ -1,88 +0,0 @@
ooooo ooo ooooooooo. ooooooo ooooo
`888' `8' `888 `Y88. `8888 d8'
888 8 888 .d88' Y888..8P
888 8 888ooo88P' `8888'
888 8 888 .8PY888.
`88. .8' 888 d8' `888b
`YbodP' o888o o888o o88888o
The Ultimate Packer for eXecutables
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io
Here are some possible projects from which you can choose if you'd like to
contribute to UPX. Be sure to get in touch with us first to avoid
duplicate efforts.
User interface:
---------------
- Write a nifty Win32 GUI (in C++), but try to keep the size of the
final executable small. Compression should be in a separate
thread that calls do_one_file() [see src/work.cpp].
- Draw a nice UPX icon.
More formats:
-------------
- Amiga
- BeOS
- C64
- elks/8086 (this is a 16-bit linux-8086 kernel)
See http://www.elks.ecs.soton.ac.uk/
- freebsd/386 (generic), freebsd/elf386 (specialized).
Probably could share most of the linux code.
- add support for self-extracting HTML pages using a Javascript stub
(like the AlgART HTML Packer "AHP")
Existing formats:
-----------------
- djgpp2/coff: add support for DLX dynamic loading
(see SEAL http://www.home.sk/public/seal/ )
- dos/com: add support for very long files - convert to exe if necessary
- dos/exe: implement filter support
- linux/i386:
- use the new assembly preprocessor stuff (ie. process the file
headers internally)
- UPX uncompressor daemon
- rewrite the stub in assembly (not sure if this is a good idea...)
- watcom/le: add support for per section compression, LX support, VXD
- win32/pe: display a nice dialog box in the stub in case
of problems (like importing a DLL or function fails)
- win32/pe: per section compression
Compression ratio:
------------------
- invent more effective filters
- I (Markus) will continue to work on better compression algorithms,
so be sure to do better than me if you plan working on this ;-)
Other:
------
- anything else you think that could improve UPX...
Thanks for your contribution.
+34 -53
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
Copyright (c) 1996-2022 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io
@@ -18,10 +18,8 @@ WELCOME
Welcome to UPX !
Please don't forget to read the file LICENSE - UPX is distributed
under the GNU General Public License (GPL) with special exceptions
allowing the distribution of all compressed executables, including
commercial programs.
UPX is a free, secure, portable, extendable, high-performance
executable packer for several executable formats.
INTRODUCTION
@@ -37,86 +35,73 @@ and run exactly as before, with no runtime or memory penalty for most
of the supported formats.
UPX supports a number of different executable formats, including
Windows 95/98/ME/NT/2000/XP/CE programs and DLLs, DOS programs,
and Linux executables and kernels.
Windows programs and DLLs, macOS apps and Linux executables.
UPX is free software distributed under the term of the GNU General
Public License. Full source code is available.
UPX may be distributed and used freely, even with commercial applications.
See the UPX License Agreement for details.
See the UPX License Agreements for details.
UPX is rated number one in the well known Archive Comparison Test. Visit
http://compression.ca/ .
UPX aims to be Commercial Quality Freeware.
SECURITY CONTEXT
================
IMPORTANT NOTE: UPX inherits the security context of any files it handles.
This means that packing, unpacking, or even testing or listing a file requires
the same security considerations as actually executing the file.
Use UPX on trusted files only!
SHORT DOCUMENTATION
===================
'upx program.exe' will compress a program or DLL. For best compression
results try '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
NEWS and BUGS also contain various tidbits of information.
DISCLAIMER
==========
UPX comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.
Having said that, we think that UPX is quite stable now. Indeed we
have compressed lots of files without any problems. Also, the
current version has undergone several months of beta testing -
actually it's almost 8 years since our first public beta.
This is the first production quality release, and we plan that future
releases will be backward compatible with this version.
Please report all problems or suggestions to the authors. Thanks.
THE FUTURE
==========
- AArch64 (64-bit ARM) for Linux and iOS.
- Stay up-to-date with ongoing OS and executable format changes
- The Linux approach could probably get ported to a lot of other Unix
variants, at least for other i386 architectures it shouldn't be too
much work. If someone sends me a fresh hard disk and an official
FreeBSD/OpenBSD/NetBSD/Solaris/BeOS... CD I might take a look at it ;-)
- RISC-V 64 for Linux
- ARM64 for Windows (help wanted)
- We will *NOT* add any sort of protection and/or encryption.
This only gives people a false feeling of security because
by definition all protectors/compressors can be broken.
And don't trust any advertisement of authors of other executable
compressors about this topic - just do a websearch on "unpackers"...
all "protectors" can be broken by definition.
- Fix all remaining bugs - keep your reports coming ;-)
- See the file PROJECTS in the source code distribution if you want
to contribute.
- Fix all remaining bugs - please report any issues
https://github.com/upx/upx/issues
COPYRIGHT
=========
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 2000-2017 John F. Reiser
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
Copyright (C) 2000-2022 John F. Reiser
This program may be used freely, and you are welcome to
redistribute it under certain conditions.
UPX is distributed with full source code under the terms of the
GNU General Public License v2+; either under the pure GPLv2+ (see
the file COPYING), or (at your option) under the GPLv+2 with special
exceptions and restrictions granting the free usage for all binaries
including commercial programs (see the file LICENSE).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
UPX License Agreement for more details.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the UPX License Agreement along
with this program; see the file LICENSE. If not, visit the UPX home page.
You should have received a copy of the UPX License Agreements along
with this program; see the files COPYING and LICENSE. If not,
visit the UPX home page.
Share and enjoy,
@@ -133,7 +118,3 @@ Markus & Laszlo & John
[ The term UPX is a shorthand for the Ultimate Packer for eXecutables
and holds no connection with potential owners of registered trademarks
or other rights. ]
[ Feel free to contact us if you have commercial compression requirements
or interesting job offers. ]
-24
View File
@@ -1,24 +0,0 @@
ooooo ooo ooooooooo. ooooooo ooooo
`888' `8' `888 `Y88. `8888 d8'
888 8 888 .d88' Y888..8P
888 8 888ooo88P' `8888'
888 8 888 .8PY888.
`88. .8' 888 d8' `888b
`YbodP' o888o o888o o88888o
The Ultimate Packer for eXecutables
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io
MAJOR NEWS IN UPX 3
===================
The main news since UPX 2 are:
* new format: added support for linux elf/arm
* better compression using the LZMA algorithm (option '--lzma')
* better support for MacOS
+10 -54
View File
@@ -27,21 +27,6 @@ Foreword
Markus & Laszlo
Introduction
------------
Welcome to the UPX source code release!
UPX is not a toy for kids. Apart from basic knowledge about executables
and data compression you will need to be firm in C++, assembler,
Perl and Makefiles. Probably some other things as well.
If you can't manage to compile it then the sources are
probably not for you. Don't email us for help.
The authors use Linux for development. You might want to as well.
Short overview
--------------
@@ -56,48 +41,32 @@ Short overview
are #included by the individual executable format handlers.
Prerequisites
-------------
- first of all you need to build the UCL compression library
http://www.oberhumer.com/opensource/ucl/
Tools needed to build/modify the UPX sources
--------------------------------------------
- A C++ compiler: gcc >= 3.3 or clang.
- A C++ compiler that supports C++ 14: clang, gcc or msvc
- GNU make 3.81 or better
- GNU make
- zlib and zlib-devel [or zlib-dev] software packages for your
host environment
- LZMA SDK from https://github.com/upx/upx-lzma-sdk
When using git run 'git submodule update --init --recursive'.
- CMake 3.13 or better; see https://cmake.org/
To compile the packer sources
-----------------------------
Set the environment variable UPX_UCLDIR to point to your
UCL build directory, e.g.
set UPX_UCLDIR=c:\src\ucl-1.03 (DOS / Windows)
export UPX_UCLDIR=$HOME/local/src/ucl-1.03 (Unix)
Finally type
make
- just run "make" in the top-level source directory
If you want to modify the stub sources you'll also need
-------------------------------------------------------
- Perl & Python
- Podman/Docker: see misc/rebuild-stubs-with-podman - this
is the preferred way of rebuilding the stubs
- otherwise you will need:
- a Linux host system with Perl, Python2 and some older compat-libs
- upx-stubtools - a number of cross-assemblers and cross-compilers.
Precompiled binaries for i386-linux hosts are available from
Precompiled binaries for amd64-linux hosts are available from
https://github.com/upx/upx-stubtools/releases
@@ -114,9 +83,9 @@ Misc. notes
- Use gcc extensions and other compiler specific stuff only through
macros.
***
Some conventions:
-----------------
- follow our coding style
- indent level = 4
@@ -125,17 +94,4 @@ Some conventions:
- Use throwSomeException() functions instead of throw SomeException():
this makes the code shorter if used often.
***
Patches/Contributions
- Please send us bug fixes/contributions only using
diff -u oldfile newfile
or
diff -uNr olddirectory newdirectory
# vim:set ts=4 sw=4 et:
+1 -2
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
Copyright (c) 1996-2022 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io
@@ -58,4 +58,3 @@ Stefan Widmann
The WINE project (http://www.winehq.com/)
for lots of useful information found in their PE loader sources
Natascha
+4
View File
@@ -0,0 +1,4 @@
-Ivendor
-fno-strict-aliasing
-fno-strict-overflow
-funsigned-char
+1 -2
View File
@@ -8,7 +8,7 @@
The Ultimate Packer for eXecutables
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
Copyright (c) 1996-2022 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io
@@ -48,4 +48,3 @@ win32/pe
* certificates in the image
* compressing files which contain a big BSS requires lots of memory
during compression
+13 -8
View File
@@ -1,5 +1,5 @@
#
# UPX doc Makefile - needs GNU make 3.81 or better
# UPX doc Makefile - needs GNU make
#
MAKEFLAGS += -rR
@@ -26,8 +26,7 @@ VERSION := $(shell sed -n 's/^.*UPX_VERSION_STRING .*"\(.*\)".*/\1/p' $(top
RTRIM := sed -e 's/[ $(tab)]*$$//'
DETAB2 := sed -e 's/$(tab)/ /g'
BUILT_SOURCES = upx.1 upx.doc upx.html upx.man upx.ps upx.tex
BUILT_SOURCES = upx.1 upx.doc upx.html
BUILT_SOURCES = upx.1 upx-doc.html upx-doc.txt
###
@@ -46,26 +45,32 @@ mostlyclean clean distclean maintainer-clean:
### rules
###
.SUFFIXES: .1 .doc .html .man .pod .ps .tex
.SUFFIXES: .1 .html .man .pod .ps .tex .txt
%.1 : %.pod
pod2man --center=" " --release="$(PACKAGE) $(VERSION)" --date="$(VERSION_DATE)" $< | $(RTRIM) > $@
test -s $@
%.doc : %.pod
pod2text < $< | $(RTRIM) > $@
%.html : %.pod
%-doc.html : %.pod
pod2html --noindex $< | $(RTRIM) | $(DETAB2) > $@
@rm -f pod2htm*
test -s $@
%.man : %.1
nroff -man $< | $(RTRIM) > $@
test -s $@
%.ps : %.1
groff -man $< | $(RTRIM) > $@
test -s $@
%.tex : %.pod
pod2latex $<
test -s $@
%-doc.txt : %.pod
pod2text < $< | $(RTRIM) > $@
test -s $@
###
+1 -1
View File
@@ -1,5 +1,5 @@
Decompressing ELF Directly to Memory on Linux/x86
Copyright (C) 2000-2017 John F. Reiser jreiser@BitWagon.com
Copyright (C) 2000-2022 John F. Reiser jreiser@BitWagon.com
References:
<elf.h> definitions for the ELF file format
View File
+807
View File
@@ -0,0 +1,807 @@
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>upx - compress or expand executable files</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body>
<h1 id="NAME">NAME</h1>
<p>upx - compress or expand executable files</p>
<h1 id="SYNOPSIS">SYNOPSIS</h1>
<p><b>upx</b> <span style="white-space: nowrap;">[ <i>command</i> ]</span> <span style="white-space: nowrap;">[ <i>options</i> ]</span> <i>filename</i>...</p>
<h1 id="ABSTRACT">ABSTRACT</h1>
<pre><code> The Ultimate Packer for eXecutables
Copyright (c) 1996-2022 Markus Oberhumer, Laszlo Molnar &amp; John Reiser
https://upx.github.io</code></pre>
<p><b>UPX</b> is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers <i>*very*</i> fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported, because of in-place decompression.</p>
<h1 id="DISCLAIMER">DISCLAIMER</h1>
<p><b>UPX</b> comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING.</p>
<p>Please report all problems or suggestions to the authors. Thanks.</p>
<h1 id="SECURITY-CONTEXT">SECURITY CONTEXT</h1>
<p>IMPORTANT NOTE: <b>UPX</b> inherits the security context of any files it handles.</p>
<p>This means that packing, unpacking, or even testing or listing a file requires the same security considerations as actually executing the file.</p>
<p>Use <b>UPX</b> on trusted files only!</p>
<h1 id="DESCRIPTION">DESCRIPTION</h1>
<p><b>UPX</b> is a versatile executable packer with the following features:</p>
<pre><code>- secure: as UPX is documented Open Source since many years any relevant
Security/Antivirus software is able to peek inside UPX compressed
apps to verify them
- excellent compression ratio: typically compresses better than Zip,
use UPX to decrease the size of your distribution !
- very fast decompression: more than 500 MB/sec on any reasonably modern
machine
- no memory overhead for your compressed executables for most of the
supported formats because of in-place decompression
- safe: you can list, test and unpack your executables.
Also, a checksum of both the compressed and uncompressed file is
maintained internally.
- universal: UPX can pack a number of executable formats, including
Windows programs and DLLs, macOS apps and Linux executables
- portable: UPX is written in portable endian-neutral C++
- extendable: because of the class layout it&#39;s very easy to support
new executable formats or add new compression algorithms
- free: UPX is distributed with full source code under the GNU General
Public License v2+, with special exceptions granting the free usage
for commercial programs</code></pre>
<p>You probably understand now why we call <b>UPX</b> the &quot;<i>ultimate</i>&quot; executable packer.</p>
<h1 id="COMMANDS">COMMANDS</h1>
<h2 id="Compress">Compress</h2>
<p>This is the default operation, eg. <b>upx yourfile.exe</b> will compress the file specified on the command line.</p>
<h2 id="Decompress">Decompress</h2>
<p>All <b>UPX</b> supported file formats can be unpacked using the <b>-d</b> switch, eg. <b>upx -d yourfile.exe</b> will uncompress the file you&#39;ve just compressed.</p>
<h2 id="Test">Test</h2>
<p>The <b>-t</b> command tests the integrity of the compressed and uncompressed data, eg. <b>upx -t yourfile.exe</b> check whether your file can be safely decompressed. Note, that this command doesn&#39;t check the whole file, only the part that will be uncompressed during program execution. This means that you should not use this command instead of a virus checker.</p>
<h2 id="List">List</h2>
<p>The <b>-l</b> command prints out some information about the compressed files specified on the command line as parameters, eg <b>upx -l yourfile.exe</b> shows the compressed / uncompressed size and the compression ratio of <i>yourfile.exe</i>.</p>
<h1 id="OPTIONS">OPTIONS</h1>
<p><b>-q</b>: be quiet, suppress warnings</p>
<p><b>-q -q</b> (or <b>-qq</b>): be very quiet, suppress errors</p>
<p><b>-q -q -q</b> (or <b>-qqq</b>): produce no output at all</p>
<p><b>--help</b>: prints the help</p>
<p><b>--version</b>: print the version of <b>UPX</b></p>
<p><b>--exact</b>: when compressing, require to be able to get a byte-identical file after decompression with option <b>-d</b>. [NOTE: this is work in progress and is not supported for all formats yet. If you do care, as a workaround you can compress and then decompress your program a first time - any further compress-decompress steps should then yield byte-identical results as compared to the first decompressed version.]</p>
<p><b>-k</b>: keep backup files</p>
<p><b>-o file</b>: write output to file</p>
<p>[ ...more docs need to be written... - type `<b>upx --help</b>&#39; for now ]</p>
<h1 id="COMPRESSION-LEVELS-TUNING">COMPRESSION LEVELS &amp; TUNING</h1>
<p><b>UPX</b> offers ten different compression levels from <b>-1</b> to <b>-9</b>, and <b>--best</b>. The default compression level is <b>-8</b> for files smaller than 512 KiB, and <b>-7</b> otherwise.</p>
<ul>
<li><p>Compression levels 1, 2 and 3 are pretty fast.</p>
</li>
<li><p>Compression levels 4, 5 and 6 achieve a good time/ratio performance.</p>
</li>
<li><p>Compression levels 7, 8 and 9 favor compression ratio over speed.</p>
</li>
<li><p>Compression level <b>--best</b> may take a long time.</p>
</li>
</ul>
<p>Note that compression level <b>--best</b> can be somewhat slow for large files, but you definitely should use it when releasing a final version of your program.</p>
<p>Quick info for achieving the best compression ratio:</p>
<ul>
<li><p>Try <b>upx --brute --no-lzma myfile.exe</b> or even <b>upx --ultra-brute --no-lzma myfile.exe</b>.</p>
</li>
<li><p>The option <b>--lzma</b> enables LZMA compression, which compresses better but is *significantly slower* at decompression. You probably do not want to use it for large files.</p>
<p>(Note that <b>--lzma</b> is automatically enabled by <b>--all-methods</b> and <b>--brute</b>, use <b>--no-lzma</b> to override.)</p>
</li>
<li><p>Try if <b>--overlay=strip</b> works.</p>
</li>
<li><p>For win32/pe programs there&#39;s <b>--strip-relocs=0</b>. See notes below.</p>
</li>
</ul>
<h1 id="OVERLAY-HANDLING-OPTIONS">OVERLAY HANDLING OPTIONS</h1>
<p>Info: An &quot;overlay&quot; means auxiliary data attached after the logical end of an executable, and it often contains application specific data (this is a common practice to avoid an extra data file, though it would be better to use resource sections).</p>
<p><b>UPX</b> handles overlays like many other executable packers do: it simply copies the overlay after the compressed image. This works with some files, but doesn&#39;t work with others, depending on how an application actually accesses this overlayed data.</p>
<pre><code>--overlay=copy Copy any extra data attached to the file. [DEFAULT]
--overlay=strip Strip any overlay from the program instead of
copying it. Be warned, this may make the compressed
program crash or otherwise unusable.
--overlay=skip Refuse to compress any program which has an overlay.</code></pre>
<h1 id="ENVIRONMENT-VARIABLE">ENVIRONMENT VARIABLE</h1>
<p>The environment variable <b>UPX</b> can hold a set of default options for <b>UPX</b>. These options are interpreted first and can be overwritten by explicit command line parameters. For example:</p>
<pre><code>for DOS/Windows: set UPX=-9 --compress-icons#0
for sh/ksh/zsh: UPX=&quot;-9 --compress-icons=0&quot;; export UPX
for csh/tcsh: setenv UPX &quot;-9 --compress-icons=0&quot;</code></pre>
<p>Under DOS/Windows you must use &#39;#&#39; instead of &#39;=&#39; when setting the environment variable because of a COMMAND.COM limitation.</p>
<p>Not all of the options are valid in the environment variable - <b>UPX</b> will tell you.</p>
<p>You can explicitly use the <b>--no-env</b> option to ignore the environment variable.</p>
<h1 id="NOTES-FOR-THE-SUPPORTED-EXECUTABLE-FORMATS">NOTES FOR THE SUPPORTED EXECUTABLE FORMATS</h1>
<h2 id="NOTES-FOR-ATARI-TOS">NOTES FOR ATARI/TOS</h2>
<p>This is the executable format used by the Atari ST/TT, a Motorola 68000 based personal computer which was popular in the late &#39;80s. Support of this format is only because of nostalgic feelings of one of the authors and serves no practical purpose :-). See https://freemint.github.io for more info.</p>
<p>Packed programs will be byte-identical to the original after uncompression. All debug information will be stripped, though.</p>
<p>Extra options available for this executable format:</p>
<pre><code>--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.</code></pre>
<h2 id="NOTES-FOR-BVMLINUZ-I386">NOTES FOR BVMLINUZ/I386</h2>
<p>Same as vmlinuz/i386.</p>
<h2 id="NOTES-FOR-DOS-COM">NOTES FOR DOS/COM</h2>
<p>Obviously <b>UPX</b> won&#39;t work with executables that want to read data from themselves (like some commandline utilities that ship with Win95/98/ME).</p>
<p>Compressed programs only work on a 286+.</p>
<p>Packed programs will be byte-identical to the original after uncompression.</p>
<p>Maximum uncompressed size: ~65100 bytes.</p>
<p>Extra options available for this executable format:</p>
<pre><code>--8086 Create an executable that works on any 8086 CPU.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.</code></pre>
<h2 id="NOTES-FOR-DOS-EXE">NOTES FOR DOS/EXE</h2>
<p>dos/exe stands for all &quot;normal&quot; 16-bit DOS executables.</p>
<p>Obviously <b>UPX</b> won&#39;t work with executables that want to read data from themselves (like some command line utilities that ship with Win95/98/ME).</p>
<p>Compressed programs only work on a 286+.</p>
<p>Extra options available for this executable format:</p>
<pre><code>--8086 Create an executable that works on any 8086 CPU.
--no-reloc Use no relocation records in the exe header.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.</code></pre>
<h2 id="NOTES-FOR-DOS-SYS">NOTES FOR DOS/SYS</h2>
<p>Compressed programs only work on a 286+.</p>
<p>Packed programs will be byte-identical to the original after uncompression.</p>
<p>Maximum uncompressed size: ~65350 bytes.</p>
<p>Extra options available for this executable format:</p>
<pre><code>--8086 Create an executable that works on any 8086 CPU.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.</code></pre>
<h2 id="NOTES-FOR-DJGPP2-COFF">NOTES FOR DJGPP2/COFF</h2>
<p>First of all, it is recommended to use <b>UPX</b> *instead* of <b>strip</b>. strip has the very bad habit of replacing your stub with its own (outdated) version. Additionally <b>UPX</b> corrects a bug/feature in strip v2.8.x: it will fix the 4 KiB alignment of the stub.</p>
<p><b>UPX</b> includes the full functionality of stubify. This means it will automatically stubify your COFF files. Use the option <b>--coff</b> to disable this functionality (see below).</p>
<p><b>UPX</b> automatically handles Allegro packfiles.</p>
<p>The DLM format (a rather exotic shared library extension) is not supported.</p>
<p>Packed programs will be byte-identical to the original after uncompression. All debug information and trailing garbage will be stripped, though.</p>
<p>Extra options available for this executable format:</p>
<pre><code>--coff Produce COFF output instead of EXE. By default
UPX keeps your current stub.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.</code></pre>
<h2 id="NOTES-FOR-LINUX-general">NOTES FOR LINUX [general]</h2>
<p>Introduction</p>
<pre><code>Linux/386 support in UPX consists of 3 different executable formats,
one optimized for ELF executables (&quot;linux/elf386&quot;), one optimized
for shell scripts (&quot;linux/sh386&quot;), and one generic format
(&quot;linux/386&quot;).
We will start with a general discussion first, but please
also read the relevant docs for each of the individual formats.
Also, there is special support for bootable kernels - see the
description of the vmlinuz/386 format.</code></pre>
<p>General user&#39;s overview</p>
<pre><code>Running a compressed executable program trades less space on a
``permanent&#39;&#39; storage medium (such as a hard disk, floppy disk,
CD-ROM, flash memory, EPROM, etc.) for more space in one or more
``temporary&#39;&#39; storage media (such as RAM, swap space, /tmp, etc.).
Running a compressed executable also requires some additional CPU
cycles to generate the compressed executable in the first place,
and to decompress it at each invocation.
How much space is traded? It depends on the executable, but many
programs save 30% to 50% of permanent disk space. How much CPU
overhead is there? Again, it depends on the executable, but
decompression speed generally is at least many megabytes per second,
and frequently is limited by the speed of the underlying disk
or network I/O.
Depending on the statistics of usage and access, and the relative
speeds of CPU, RAM, swap space, /tmp, and file system storage, then
invoking and running a compressed executable can be faster than
directly running the corresponding uncompressed program.
The operating system might perform fewer expensive I/O operations
to invoke the compressed program. Paging to or from swap space
or /tmp might be faster than paging from the general file system.
``Medium-sized&#39;&#39; programs which access about 1/3 to 1/2 of their
stored program bytes can do particularly well with compression.
Small programs tend not to benefit as much because the absolute
savings is less. Big programs tend not to benefit proportionally
because each invocation may use only a small fraction of the program,
yet UPX decompresses the entire program before invoking it.
But in environments where disk or flash memory storage is limited,
then compression may win anyway.
Currently, executables compressed by UPX do not share RAM at runtime
in the way that executables mapped from a file system do. As a
result, if the same program is run simultaneously by more than one
process, then using the compressed version will require more RAM and/or
swap space. So, shell programs (bash, csh, etc.) and ``make&#39;&#39;
might not be good candidates for compression.
UPX recognizes three executable formats for Linux: Linux/elf386,
Linux/sh386, and Linux/386. Linux/386 is the most generic format;
it accommodates any file that can be executed. At runtime, the UPX
decompression stub re-creates in /tmp a copy of the original file,
and then the copy is (re-)executed with the same arguments.
ELF binary executables prefer the Linux/elf386 format by default,
because UPX decompresses them directly into RAM, uses only one
exec, does not use space in /tmp, and does not use /proc.
Shell scripts where the underlying shell accepts a ``-c&#39;&#39; argument
can use the Linux/sh386 format. UPX decompresses the shell script
into low memory, then maps the shell and passes the entire text of the
script as an argument with a leading ``-c&#39;&#39;.</code></pre>
<p>General benefits:</p>
<pre><code>- UPX can compress all executables, be it AOUT, ELF, libc4, libc5,
libc6, Shell/Perl/Python/... scripts, standalone Java .class
binaries, or whatever...
All scripts and programs will work just as before.
- Compressed programs are completely self-contained. No need for
any external program.
- UPX keeps your original program untouched. This means that
after decompression you will have a byte-identical version,
and you can use UPX as a file compressor just like gzip.
[ Note that UPX maintains a checksum of the file internally,
so it is indeed a reliable alternative. ]
- As the stub only uses syscalls and isn&#39;t linked against libc it
should run under any Linux configuration that can run ELF
binaries.
- For the same reason compressed executables should run under
FreeBSD and other systems which can run Linux binaries.
[ Please send feedback on this topic ]</code></pre>
<p>General drawbacks:</p>
<pre><code>- It is not advisable to compress programs which usually have many
instances running (like `sh&#39; or `make&#39;) because the common segments of
compressed programs won&#39;t be shared any longer between different
processes.
- `ldd&#39; and `size&#39; won&#39;t show anything useful because all they
see is the statically linked stub. Since version 0.82 the section
headers are stripped from the UPX stub and `size&#39; doesn&#39;t even
recognize the file format. The file patches/patch-elfcode.h has a
patch to fix this bug in `size&#39; and other programs which use GNU BFD.</code></pre>
<p>General notes:</p>
<pre><code>- As UPX leaves your original program untouched it is advantageous
to strip it before compression.
- If you compress a script you will lose platform independence -
this could be a problem if you are using NFS mounted disks.
- Compression of suid, guid and sticky-bit programs is rejected
because of possible security implications.
- For the same reason there is no sense in making any compressed
program suid.
- Obviously UPX won&#39;t work with executables that want to read data
from themselves. E.g., this might be a problem for Perl scripts
which access their __DATA__ lines.
- In case of internal errors the stub will abort with exitcode 127.
Typical reasons for this to happen are that the program has somehow
been modified after compression.
Running `strace -o strace.log compressed_file&#39; will tell you more.</code></pre>
<h2 id="NOTES-FOR-LINUX-ELF386">NOTES FOR LINUX/ELF386</h2>
<p>Please read the general Linux description first.</p>
<p>The linux/elf386 format decompresses directly into RAM, uses only one exec, does not use space in /tmp, and does not use /proc.</p>
<p>Linux/elf386 is automatically selected for Linux ELF executables.</p>
<p>Packed programs will be byte-identical to the original after uncompression.</p>
<p>How it works:</p>
<pre><code>For ELF executables, UPX decompresses directly to memory, simulating
the mapping that the operating system kernel uses during exec(),
including the PT_INTERP program interpreter (if any).
The brk() is set by a special PT_LOAD segment in the compressed
executable itself. UPX then wipes the stack clean except for
arguments, environment variables, and Elf_auxv entries (this is
required by bugs in the startup code of /lib/ld-linux.so as of
May 2000), and transfers control to the program interpreter or
the e_entry address of the original executable.
The UPX stub is about 1700 bytes long, partly written in assembler
and only uses kernel syscalls. It is not linked against any libc.</code></pre>
<p>Specific drawbacks:</p>
<pre><code>- For linux/elf386 and linux/sh386 formats, you will be relying on
RAM and swap space to hold all of the decompressed program during
the lifetime of the process. If you already use most of your swap
space, then you may run out. A system that is &quot;out of memory&quot;
can become fragile. Many programs do not react gracefully when
malloc() returns 0. With newer Linux kernels, the kernel
may decide to kill some processes to regain memory, and you
may not like the kernel&#39;s choice of which to kill. Running
/usr/bin/top is one way to check on the usage of swap space.</code></pre>
<p>Extra options available for this executable format:</p>
<pre><code>(none)</code></pre>
<h2 id="NOTES-FOR-LINUX-SH386">NOTES FOR LINUX/SH386</h2>
<p>Please read the general Linux description first.</p>
<p>Shell scripts where the underling shell accepts a ``-c&#39;&#39; argument can use the Linux/sh386 format. <b>UPX</b> decompresses the shell script into low memory, then maps the shell and passes the entire text of the script as an argument with a leading ``-c&#39;&#39;. It does not use space in /tmp, and does not use /proc.</p>
<p>Linux/sh386 is automatically selected for shell scripts that use a known shell.</p>
<p>Packed programs will be byte-identical to the original after uncompression.</p>
<p>How it works:</p>
<pre><code>For shell script executables (files beginning with &quot;#!/&quot; or &quot;#! /&quot;)
where the shell is known to accept &quot;-c &lt;command&gt;&quot;, UPX decompresses
the file into low memory, then maps the shell (and its PT_INTERP),
and passes control to the shell with the entire decompressed file
as the argument after &quot;-c&quot;. Known shells are sh, ash, bash, bsh, csh,
ksh, tcsh, pdksh. Restriction: UPX cannot use this method
for shell scripts which use the one optional string argument after
the shell name in the script (example: &quot;#! /bin/sh option3\n&quot;.)
The UPX stub is about 1700 bytes long, partly written in assembler
and only uses kernel syscalls. It is not linked against any libc.</code></pre>
<p>Specific drawbacks:</p>
<pre><code>- For linux/elf386 and linux/sh386 formats, you will be relying on
RAM and swap space to hold all of the decompressed program during
the lifetime of the process. If you already use most of your swap
space, then you may run out. A system that is &quot;out of memory&quot;
can become fragile. Many programs do not react gracefully when
malloc() returns 0. With newer Linux kernels, the kernel
may decide to kill some processes to regain memory, and you
may not like the kernel&#39;s choice of which to kill. Running
/usr/bin/top is one way to check on the usage of swap space.</code></pre>
<p>Extra options available for this executable format:</p>
<pre><code>(none)</code></pre>
<h2 id="NOTES-FOR-LINUX-386">NOTES FOR LINUX/386</h2>
<p>Please read the general Linux description first.</p>
<p>The generic linux/386 format decompresses to /tmp and needs /proc file system support. It starts the decompressed program via the execve() syscall.</p>
<p>Linux/386 is only selected if the specialized linux/elf386 and linux/sh386 won&#39;t recognize a file.</p>
<p>Packed programs will be byte-identical to the original after uncompression.</p>
<p>How it works:</p>
<pre><code>For files which are not ELF and not a script for a known &quot;-c&quot; shell,
UPX uses kernel execve(), which first requires decompressing to a
temporary file in the file system. Interestingly -
because of the good memory management of the Linux kernel - this
often does not introduce a noticeable delay, and in fact there
will be no disk access at all if you have enough free memory as
the entire process takes places within the file system buffers.
A compressed executable consists of the UPX stub and an overlay
which contains the original program in a compressed form.
The UPX stub is a statically linked ELF executable and does
the following at program startup:
1) decompress the overlay to a temporary location in /tmp
2) open the temporary file for reading
3) try to delete the temporary file and start (execve)
the uncompressed program in /tmp using /proc/&lt;pid&gt;/fd/X as
attained by step 2)
4) if that fails, fork off a subprocess to clean up and
start the program in /tmp in the meantime
The UPX stub is about 1700 bytes long, partly written in assembler
and only uses kernel syscalls. It is not linked against any libc.</code></pre>
<p>Specific drawbacks:</p>
<pre><code>- You need additional free disk space for the uncompressed program
in your /tmp directory. This program is deleted immediately after
decompression, but you still need it for the full execution time
of the program.
- You must have /proc file system support as the stub wants to open
/proc/&lt;pid&gt;/exe and needs /proc/&lt;pid&gt;/fd/X. This also means that you
cannot compress programs that are used during the boot sequence
before /proc is mounted.
- Utilities like `top&#39; will display numerical values in the process
name field. This is because Linux computes the process name from
the first argument of the last execve syscall (which is typically
something like /proc/&lt;pid&gt;/fd/3).
- Because of temporary decompression to disk the decompression speed
is not as fast as with the other executable formats. Still, I can see
no noticeable delay when starting programs like my ~3 MiB emacs (which
is less than 1 MiB when compressed :-).</code></pre>
<p>Extra options available for this executable format:</p>
<pre><code>--force-execve Force the use of the generic linux/386 &quot;execve&quot;
format, i.e. do not try the linux/elf386 and
linux/sh386 formats.</code></pre>
<h2 id="NOTES-FOR-PS1-EXE">NOTES FOR PS1/EXE</h2>
<p>This is the executable format used by the Sony PlayStation (PSone), a MIPS R3000 based gaming console which is popular since the late &#39;90s. Support of this format is very similar to the Atari one, because of nostalgic feelings of one of the authors.</p>
<p>Packed programs will be byte-identical to the original after uncompression, until further notice.</p>
<p>Maximum uncompressed size: ~1.89 / ~7.60 MiB.</p>
<p>Notes:</p>
<pre><code>- UPX creates as default a suitable executable for CD-Mastering
and console transfer. For a CD-Master main executable you could also try
the special option &quot;--boot-only&quot; as described below.
It has been reported that upx packed executables are fully compatible with
the Sony PlayStation 2 (PS2, PStwo) and Sony PlayStation Portable (PSP) in
Sony PlayStation (PSone) emulation mode.
- Normally the packed files use the same memory areas like the uncompressed
versions, so they will not override other memory areas while unpacking.
If this isn&#39;t possible UPX will abort showing a &#39;packed data overlap&#39;
error. With the &quot;--force&quot; option UPX will relocate the loading address
for the packed file, but this isn&#39;t a real problem if it is a single or
the main executable.</code></pre>
<p>Extra options available for this executable format:</p>
<pre><code>--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--8-bit Uses 8 bit size compression [default: 32 bit]
--8mib-ram PSone has 8 MiB ram available [default: 2 MiB]
--boot-only This format is for main exes and CD-Mastering only !
It may slightly improve the compression ratio,
decompression routines are faster than default ones.
But it cannot be used for console transfer !
--no-align This option disables CD mode 2 data sector format
alignment. May slightly improves the compression ratio,
but the compressed executable will not boot from a CD.
Use it for console transfer only !</code></pre>
<h2 id="NOTES-FOR-RTM32-PE-and-ARM-PE">NOTES FOR RTM32/PE and ARM/PE</h2>
<p>Same as win32/pe.</p>
<h2 id="NOTES-FOR-TMT-ADAM">NOTES FOR TMT/ADAM</h2>
<p>This format is used by the TMT Pascal compiler - see http://www.tmt.com/ .</p>
<p>Extra options available for this executable format:</p>
<pre><code>--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.</code></pre>
<h2 id="NOTES-FOR-VMLINUZ-386">NOTES FOR VMLINUZ/386</h2>
<p>The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed bootable Linux kernel image (&quot;vmlinuz&quot;, &quot;zImage&quot;, &quot;bzImage&quot;), gzip-decompress it and re-compress it with the <b>UPX</b> compression method.</p>
<p>vmlinuz/386 is completely unrelated to the other Linux executable formats, and it does not share any of their drawbacks.</p>
<p>Notes:</p>
<pre><code>- Be sure that &quot;vmlinuz/386&quot; or &quot;bvmlinuz/386&quot; is displayed
during compression - otherwise a wrong executable format
may have been used, and the kernel won&#39;t boot.</code></pre>
<p>Benefits:</p>
<pre><code>- Better compression (but note that the kernel was already compressed,
so the improvement is not as large as with other formats).
Still, the bytes saved may be essential for special needs like
boot disks.
For example, this is what I get for my 2.2.16 kernel:
1589708 vmlinux
641073 bzImage [original]
560755 bzImage.upx [compressed by &quot;upx -9&quot;]
- Much faster decompression at kernel boot time (but kernel
decompression speed is not really an issue these days).</code></pre>
<p>Drawbacks:</p>
<pre><code>(none)</code></pre>
<p>Extra options available for this executable format:</p>
<pre><code>--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.</code></pre>
<h2 id="NOTES-FOR-WATCOM-LE">NOTES FOR WATCOM/LE</h2>
<p><b>UPX</b> has been successfully tested with the following extenders: DOS4G, DOS4GW, PMODE/W, DOS32a, CauseWay. The WDOS/X extender is partly supported (for details see the file bugs BUGS).</p>
<p>DLLs and the LX format are not supported.</p>
<p>Extra options available for this executable format:</p>
<pre><code>--le Produce an unbound LE output instead of
keeping the current stub.</code></pre>
<h2 id="NOTES-FOR-WIN32-PE">NOTES FOR WIN32/PE</h2>
<p>The PE support in <b>UPX</b> is quite stable now, but probably there are still some incompatibilities with some files.</p>
<p>Because of the way <b>UPX</b> (and other packers for this format) works, you can see increased memory usage of your compressed files because the whole program is loaded into memory at startup. If you start several instances of huge compressed programs you&#39;re wasting memory because the common segments of the program won&#39;t get shared across the instances. On the other hand if you&#39;re compressing only smaller programs, or running only one instance of larger programs, then this penalty is smaller, but it&#39;s still there.</p>
<p>If you&#39;re running executables from network, then compressed programs will load faster, and require less bandwidth during execution.</p>
<p>DLLs are supported. But UPX compressed DLLs can not share common data and code when they got used by multiple applications. So compressing msvcrt.dll is a waste of memory, but compressing the dll plugins of a particular application may be a better idea.</p>
<p>Screensavers are supported, with the restriction that the filename must end with &quot;.scr&quot; (as screensavers are handled slightly different than normal exe files).</p>
<p>UPX compressed PE files have some minor memory overhead (usually in the 10 - 30 KiB range) which can be seen by specifying the &quot;-i&quot; command line switch during compression.</p>
<p>Extra options available for this executable format:</p>
<pre><code>--compress-exports=0 Don&#39;t compress the export section.
Use this if you plan to run the compressed
program under Wine.
--compress-exports=1 Compress the export section. [DEFAULT]
Compression of the export section can improve the
compression ratio quite a bit but may not work
with all programs (like winword.exe).
UPX never compresses the export section of a DLL
regardless of this option.
--compress-icons=0 Don&#39;t compress any icons.
--compress-icons=1 Compress all but the first icon.
--compress-icons=2 Compress all icons which are not in the
first icon directory. [DEFAULT]
--compress-icons=3 Compress all icons.
--compress-resources=0 Don&#39;t compress any resources at all.
--keep-resource=list Don&#39;t compress resources specified by the list.
The members of the list are separated by commas.
A list member has the following format: I&lt;type[/name]&gt;.
I&lt;Type&gt; is the type of the resource. Standard types
must be specified as decimal numbers, user types can be
specified by decimal IDs or strings. I&lt;Name&gt; is the
identifier of the resource. It can be a decimal number
or a string. For example:
--keep-resource=2/MYBITMAP,5,6/12345
UPX won&#39;t compress the named bitmap resource &quot;MYBITMAP&quot;,
it leaves every dialog (5) resource uncompressed, and
it won&#39;t touch the string table resource with identifier
12345.
--force Force compression even when there is an
unexpected value in a header field.
Use with care.
--strip-relocs=0 Don&#39;t strip relocation records.
--strip-relocs=1 Strip relocation records. [DEFAULT]
This option only works on executables with base
address greater or equal to 0x400000. Usually the
compressed files becomes smaller, but some files
may become larger. Note that the resulting file will
not work under Windows 3.x (Win32s).
UPX never strips relocations from a DLL
regardless of this option.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.</code></pre>
<h1 id="DIAGNOSTICS">DIAGNOSTICS</h1>
<p>Exit status is normally 0; if an error occurs, exit status is 1. If a warning occurs, exit status is 2.</p>
<p><b>UPX</b>&#39;s diagnostics are intended to be self-explanatory.</p>
<h1 id="BUGS">BUGS</h1>
<p>Please report all bugs immediately to the authors.</p>
<h1 id="AUTHORS">AUTHORS</h1>
<pre><code>Markus F.X.J. Oberhumer &lt;markus@oberhumer.com&gt;
http://www.oberhumer.com
Laszlo Molnar &lt;ezerotven+github@gmail.com&gt;
John F. Reiser &lt;jreiser@BitWagon.com&gt;
Jens Medoch &lt;jssg@users.sourceforge.net&gt;</code></pre>
<h1 id="COPYRIGHT">COPYRIGHT</h1>
<p>Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer</p>
<p>Copyright (C) 1996-2022 Laszlo Molnar</p>
<p>Copyright (C) 2000-2022 John F. Reiser</p>
<p>Copyright (C) 2002-2022 Jens Medoch</p>
<p><b>UPX</b> is distributed with full source code under the terms of the GNU General Public License v2+; either under the pure GPLv2+ (see the file COPYING), or (at your option) under the GPLv+2 with special exceptions and restrictions granting the free usage for all binaries including commercial programs (see the file LICENSE).</p>
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p>
<p>You should have received a copy of the UPX License Agreements along with this program; see the files COPYING and LICENSE. If not, visit the UPX home page.</p>
</body>
</html>
+842
View File
@@ -0,0 +1,842 @@
NAME
upx - compress or expand executable files
SYNOPSIS
upx [ *command* ] [ *options* ] *filename*...
ABSTRACT
The Ultimate Packer for eXecutables
Copyright (c) 1996-2022 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io
UPX is a portable, extendable, high-performance executable packer for
several different executable formats. It achieves an excellent
compression ratio and offers **very** fast decompression. Your
executables suffer no memory overhead or other drawbacks for most of the
formats supported, because of in-place decompression.
DISCLAIMER
UPX comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING.
Please report all problems or suggestions to the authors. Thanks.
SECURITY CONTEXT
IMPORTANT NOTE: UPX inherits the security context of any files it
handles.
This means that packing, unpacking, or even testing or listing a file
requires the same security considerations as actually executing the
file.
Use UPX on trusted files only!
DESCRIPTION
UPX is a versatile executable packer with the following features:
- secure: as UPX is documented Open Source since many years any relevant
Security/Antivirus software is able to peek inside UPX compressed
apps to verify them
- excellent compression ratio: typically compresses better than Zip,
use UPX to decrease the size of your distribution !
- very fast decompression: more than 500 MB/sec on any reasonably modern
machine
- no memory overhead for your compressed executables for most of the
supported formats because of in-place decompression
- safe: you can list, test and unpack your executables.
Also, a checksum of both the compressed and uncompressed file is
maintained internally.
- universal: UPX can pack a number of executable formats, including
Windows programs and DLLs, macOS apps and Linux executables
- portable: UPX is written in portable endian-neutral C++
- extendable: because of the class layout it's very easy to support
new executable formats or add new compression algorithms
- free: UPX is distributed with full source code under the GNU General
Public License v2+, with special exceptions granting the free usage
for commercial programs
You probably understand now why we call UPX the "*ultimate*" executable
packer.
COMMANDS
Compress
This is the default operation, eg. upx yourfile.exe will compress the
file specified on the command line.
Decompress
All UPX supported file formats can be unpacked using the -d switch, eg.
upx -d yourfile.exe will uncompress the file you've just compressed.
Test
The -t command tests the integrity of the compressed and uncompressed
data, eg. upx -t yourfile.exe check whether your file can be safely
decompressed. Note, that this command doesn't check the whole file, only
the part that will be uncompressed during program execution. This means
that you should not use this command instead of a virus checker.
List
The -l command prints out some information about the compressed files
specified on the command line as parameters, eg upx -l yourfile.exe
shows the compressed / uncompressed size and the compression ratio of
*yourfile.exe*.
OPTIONS
-q: be quiet, suppress warnings
-q -q (or -qq): be very quiet, suppress errors
-q -q -q (or -qqq): produce no output at all
--help: prints the help
--version: print the version of UPX
--exact: when compressing, require to be able to get a byte-identical
file after decompression with option -d. [NOTE: this is work in progress
and is not supported for all formats yet. If you do care, as a
workaround you can compress and then decompress your program a first
time - any further compress-decompress steps should then yield
byte-identical results as compared to the first decompressed version.]
-k: keep backup files
-o file: write output to file
[ ...more docs need to be written... - type `upx --help' for now ]
COMPRESSION LEVELS & TUNING
UPX offers ten different compression levels from -1 to -9, and --best.
The default compression level is -8 for files smaller than 512 KiB, and
-7 otherwise.
* Compression levels 1, 2 and 3 are pretty fast.
* Compression levels 4, 5 and 6 achieve a good time/ratio performance.
* Compression levels 7, 8 and 9 favor compression ratio over speed.
* Compression level --best may take a long time.
Note that compression level --best can be somewhat slow for large files,
but you definitely should use it when releasing a final version of your
program.
Quick info for achieving the best compression ratio:
* Try upx --brute --no-lzma myfile.exe or even upx --ultra-brute
--no-lzma myfile.exe.
* The option --lzma enables LZMA compression, which compresses better
but is *significantly slower* at decompression. You probably do not
want to use it for large files.
(Note that --lzma is automatically enabled by --all-methods and
--brute, use --no-lzma to override.)
* Try if --overlay=strip works.
* For win32/pe programs there's --strip-relocs=0. See notes below.
OVERLAY HANDLING OPTIONS
Info: An "overlay" means auxiliary data attached after the logical end
of an executable, and it often contains application specific data (this
is a common practice to avoid an extra data file, though it would be
better to use resource sections).
UPX handles overlays like many other executable packers do: it simply
copies the overlay after the compressed image. This works with some
files, but doesn't work with others, depending on how an application
actually accesses this overlayed data.
--overlay=copy Copy any extra data attached to the file. [DEFAULT]
--overlay=strip Strip any overlay from the program instead of
copying it. Be warned, this may make the compressed
program crash or otherwise unusable.
--overlay=skip Refuse to compress any program which has an overlay.
ENVIRONMENT VARIABLE
The environment variable UPX can hold a set of default options for UPX.
These options are interpreted first and can be overwritten by explicit
command line parameters. For example:
for DOS/Windows: set UPX=-9 --compress-icons#0
for sh/ksh/zsh: UPX="-9 --compress-icons=0"; export UPX
for csh/tcsh: setenv UPX "-9 --compress-icons=0"
Under DOS/Windows you must use '#' instead of '=' when setting the
environment variable because of a COMMAND.COM limitation.
Not all of the options are valid in the environment variable - UPX will
tell you.
You can explicitly use the --no-env option to ignore the environment
variable.
NOTES FOR THE SUPPORTED EXECUTABLE FORMATS
NOTES FOR ATARI/TOS
This is the executable format used by the Atari ST/TT, a Motorola 68000
based personal computer which was popular in the late '80s. Support of
this format is only because of nostalgic feelings of one of the authors
and serves no practical purpose :-). See https://freemint.github.io for
more info.
Packed programs will be byte-identical to the original after
uncompression. All debug information will be stripped, though.
Extra options available for this executable format:
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
NOTES FOR BVMLINUZ/I386
Same as vmlinuz/i386.
NOTES FOR DOS/COM
Obviously UPX won't work with executables that want to read data from
themselves (like some commandline utilities that ship with Win95/98/ME).
Compressed programs only work on a 286+.
Packed programs will be byte-identical to the original after
uncompression.
Maximum uncompressed size: ~65100 bytes.
Extra options available for this executable format:
--8086 Create an executable that works on any 8086 CPU.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.
NOTES FOR DOS/EXE
dos/exe stands for all "normal" 16-bit DOS executables.
Obviously UPX won't work with executables that want to read data from
themselves (like some command line utilities that ship with
Win95/98/ME).
Compressed programs only work on a 286+.
Extra options available for this executable format:
--8086 Create an executable that works on any 8086 CPU.
--no-reloc Use no relocation records in the exe header.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
NOTES FOR DOS/SYS
Compressed programs only work on a 286+.
Packed programs will be byte-identical to the original after
uncompression.
Maximum uncompressed size: ~65350 bytes.
Extra options available for this executable format:
--8086 Create an executable that works on any 8086 CPU.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.
NOTES FOR DJGPP2/COFF
First of all, it is recommended to use UPX *instead* of strip. strip has
the very bad habit of replacing your stub with its own (outdated)
version. Additionally UPX corrects a bug/feature in strip v2.8.x: it
will fix the 4 KiB alignment of the stub.
UPX includes the full functionality of stubify. This means it will
automatically stubify your COFF files. Use the option --coff to disable
this functionality (see below).
UPX automatically handles Allegro packfiles.
The DLM format (a rather exotic shared library extension) is not
supported.
Packed programs will be byte-identical to the original after
uncompression. All debug information and trailing garbage will be
stripped, though.
Extra options available for this executable format:
--coff Produce COFF output instead of EXE. By default
UPX keeps your current stub.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.
NOTES FOR LINUX [general]
Introduction
Linux/386 support in UPX consists of 3 different executable formats,
one optimized for ELF executables ("linux/elf386"), one optimized
for shell scripts ("linux/sh386"), and one generic format
("linux/386").
We will start with a general discussion first, but please
also read the relevant docs for each of the individual formats.
Also, there is special support for bootable kernels - see the
description of the vmlinuz/386 format.
General user's overview
Running a compressed executable program trades less space on a
``permanent'' storage medium (such as a hard disk, floppy disk,
CD-ROM, flash memory, EPROM, etc.) for more space in one or more
``temporary'' storage media (such as RAM, swap space, /tmp, etc.).
Running a compressed executable also requires some additional CPU
cycles to generate the compressed executable in the first place,
and to decompress it at each invocation.
How much space is traded? It depends on the executable, but many
programs save 30% to 50% of permanent disk space. How much CPU
overhead is there? Again, it depends on the executable, but
decompression speed generally is at least many megabytes per second,
and frequently is limited by the speed of the underlying disk
or network I/O.
Depending on the statistics of usage and access, and the relative
speeds of CPU, RAM, swap space, /tmp, and file system storage, then
invoking and running a compressed executable can be faster than
directly running the corresponding uncompressed program.
The operating system might perform fewer expensive I/O operations
to invoke the compressed program. Paging to or from swap space
or /tmp might be faster than paging from the general file system.
``Medium-sized'' programs which access about 1/3 to 1/2 of their
stored program bytes can do particularly well with compression.
Small programs tend not to benefit as much because the absolute
savings is less. Big programs tend not to benefit proportionally
because each invocation may use only a small fraction of the program,
yet UPX decompresses the entire program before invoking it.
But in environments where disk or flash memory storage is limited,
then compression may win anyway.
Currently, executables compressed by UPX do not share RAM at runtime
in the way that executables mapped from a file system do. As a
result, if the same program is run simultaneously by more than one
process, then using the compressed version will require more RAM and/or
swap space. So, shell programs (bash, csh, etc.) and ``make''
might not be good candidates for compression.
UPX recognizes three executable formats for Linux: Linux/elf386,
Linux/sh386, and Linux/386. Linux/386 is the most generic format;
it accommodates any file that can be executed. At runtime, the UPX
decompression stub re-creates in /tmp a copy of the original file,
and then the copy is (re-)executed with the same arguments.
ELF binary executables prefer the Linux/elf386 format by default,
because UPX decompresses them directly into RAM, uses only one
exec, does not use space in /tmp, and does not use /proc.
Shell scripts where the underlying shell accepts a ``-c'' argument
can use the Linux/sh386 format. UPX decompresses the shell script
into low memory, then maps the shell and passes the entire text of the
script as an argument with a leading ``-c''.
General benefits:
- UPX can compress all executables, be it AOUT, ELF, libc4, libc5,
libc6, Shell/Perl/Python/... scripts, standalone Java .class
binaries, or whatever...
All scripts and programs will work just as before.
- Compressed programs are completely self-contained. No need for
any external program.
- UPX keeps your original program untouched. This means that
after decompression you will have a byte-identical version,
and you can use UPX as a file compressor just like gzip.
[ Note that UPX maintains a checksum of the file internally,
so it is indeed a reliable alternative. ]
- As the stub only uses syscalls and isn't linked against libc it
should run under any Linux configuration that can run ELF
binaries.
- For the same reason compressed executables should run under
FreeBSD and other systems which can run Linux binaries.
[ Please send feedback on this topic ]
General drawbacks:
- It is not advisable to compress programs which usually have many
instances running (like `sh' or `make') because the common segments of
compressed programs won't be shared any longer between different
processes.
- `ldd' and `size' won't show anything useful because all they
see is the statically linked stub. Since version 0.82 the section
headers are stripped from the UPX stub and `size' doesn't even
recognize the file format. The file patches/patch-elfcode.h has a
patch to fix this bug in `size' and other programs which use GNU BFD.
General notes:
- As UPX leaves your original program untouched it is advantageous
to strip it before compression.
- If you compress a script you will lose platform independence -
this could be a problem if you are using NFS mounted disks.
- Compression of suid, guid and sticky-bit programs is rejected
because of possible security implications.
- For the same reason there is no sense in making any compressed
program suid.
- Obviously UPX won't work with executables that want to read data
from themselves. E.g., this might be a problem for Perl scripts
which access their __DATA__ lines.
- In case of internal errors the stub will abort with exitcode 127.
Typical reasons for this to happen are that the program has somehow
been modified after compression.
Running `strace -o strace.log compressed_file' will tell you more.
NOTES FOR LINUX/ELF386
Please read the general Linux description first.
The linux/elf386 format decompresses directly into RAM, uses only one
exec, does not use space in /tmp, and does not use /proc.
Linux/elf386 is automatically selected for Linux ELF executables.
Packed programs will be byte-identical to the original after
uncompression.
How it works:
For ELF executables, UPX decompresses directly to memory, simulating
the mapping that the operating system kernel uses during exec(),
including the PT_INTERP program interpreter (if any).
The brk() is set by a special PT_LOAD segment in the compressed
executable itself. UPX then wipes the stack clean except for
arguments, environment variables, and Elf_auxv entries (this is
required by bugs in the startup code of /lib/ld-linux.so as of
May 2000), and transfers control to the program interpreter or
the e_entry address of the original executable.
The UPX stub is about 1700 bytes long, partly written in assembler
and only uses kernel syscalls. It is not linked against any libc.
Specific drawbacks:
- For linux/elf386 and linux/sh386 formats, you will be relying on
RAM and swap space to hold all of the decompressed program during
the lifetime of the process. If you already use most of your swap
space, then you may run out. A system that is "out of memory"
can become fragile. Many programs do not react gracefully when
malloc() returns 0. With newer Linux kernels, the kernel
may decide to kill some processes to regain memory, and you
may not like the kernel's choice of which to kill. Running
/usr/bin/top is one way to check on the usage of swap space.
Extra options available for this executable format:
(none)
NOTES FOR LINUX/SH386
Please read the general Linux description first.
Shell scripts where the underling shell accepts a ``-c'' argument can
use the Linux/sh386 format. UPX decompresses the shell script into low
memory, then maps the shell and passes the entire text of the script as
an argument with a leading ``-c''. It does not use space in /tmp, and
does not use /proc.
Linux/sh386 is automatically selected for shell scripts that use a known
shell.
Packed programs will be byte-identical to the original after
uncompression.
How it works:
For shell script executables (files beginning with "#!/" or "#! /")
where the shell is known to accept "-c <command>", UPX decompresses
the file into low memory, then maps the shell (and its PT_INTERP),
and passes control to the shell with the entire decompressed file
as the argument after "-c". Known shells are sh, ash, bash, bsh, csh,
ksh, tcsh, pdksh. Restriction: UPX cannot use this method
for shell scripts which use the one optional string argument after
the shell name in the script (example: "#! /bin/sh option3\n".)
The UPX stub is about 1700 bytes long, partly written in assembler
and only uses kernel syscalls. It is not linked against any libc.
Specific drawbacks:
- For linux/elf386 and linux/sh386 formats, you will be relying on
RAM and swap space to hold all of the decompressed program during
the lifetime of the process. If you already use most of your swap
space, then you may run out. A system that is "out of memory"
can become fragile. Many programs do not react gracefully when
malloc() returns 0. With newer Linux kernels, the kernel
may decide to kill some processes to regain memory, and you
may not like the kernel's choice of which to kill. Running
/usr/bin/top is one way to check on the usage of swap space.
Extra options available for this executable format:
(none)
NOTES FOR LINUX/386
Please read the general Linux description first.
The generic linux/386 format decompresses to /tmp and needs /proc file
system support. It starts the decompressed program via the execve()
syscall.
Linux/386 is only selected if the specialized linux/elf386 and
linux/sh386 won't recognize a file.
Packed programs will be byte-identical to the original after
uncompression.
How it works:
For files which are not ELF and not a script for a known "-c" shell,
UPX uses kernel execve(), which first requires decompressing to a
temporary file in the file system. Interestingly -
because of the good memory management of the Linux kernel - this
often does not introduce a noticeable delay, and in fact there
will be no disk access at all if you have enough free memory as
the entire process takes places within the file system buffers.
A compressed executable consists of the UPX stub and an overlay
which contains the original program in a compressed form.
The UPX stub is a statically linked ELF executable and does
the following at program startup:
1) decompress the overlay to a temporary location in /tmp
2) open the temporary file for reading
3) try to delete the temporary file and start (execve)
the uncompressed program in /tmp using /proc/<pid>/fd/X as
attained by step 2)
4) if that fails, fork off a subprocess to clean up and
start the program in /tmp in the meantime
The UPX stub is about 1700 bytes long, partly written in assembler
and only uses kernel syscalls. It is not linked against any libc.
Specific drawbacks:
- You need additional free disk space for the uncompressed program
in your /tmp directory. This program is deleted immediately after
decompression, but you still need it for the full execution time
of the program.
- You must have /proc file system support as the stub wants to open
/proc/<pid>/exe and needs /proc/<pid>/fd/X. This also means that you
cannot compress programs that are used during the boot sequence
before /proc is mounted.
- Utilities like `top' will display numerical values in the process
name field. This is because Linux computes the process name from
the first argument of the last execve syscall (which is typically
something like /proc/<pid>/fd/3).
- Because of temporary decompression to disk the decompression speed
is not as fast as with the other executable formats. Still, I can see
no noticeable delay when starting programs like my ~3 MiB emacs (which
is less than 1 MiB when compressed :-).
Extra options available for this executable format:
--force-execve Force the use of the generic linux/386 "execve"
format, i.e. do not try the linux/elf386 and
linux/sh386 formats.
NOTES FOR PS1/EXE
This is the executable format used by the Sony PlayStation (PSone), a
MIPS R3000 based gaming console which is popular since the late '90s.
Support of this format is very similar to the Atari one, because of
nostalgic feelings of one of the authors.
Packed programs will be byte-identical to the original after
uncompression, until further notice.
Maximum uncompressed size: ~1.89 / ~7.60 MiB.
Notes:
- UPX creates as default a suitable executable for CD-Mastering
and console transfer. For a CD-Master main executable you could also try
the special option "--boot-only" as described below.
It has been reported that upx packed executables are fully compatible with
the Sony PlayStation 2 (PS2, PStwo) and Sony PlayStation Portable (PSP) in
Sony PlayStation (PSone) emulation mode.
- Normally the packed files use the same memory areas like the uncompressed
versions, so they will not override other memory areas while unpacking.
If this isn't possible UPX will abort showing a 'packed data overlap'
error. With the "--force" option UPX will relocate the loading address
for the packed file, but this isn't a real problem if it is a single or
the main executable.
Extra options available for this executable format:
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--8-bit Uses 8 bit size compression [default: 32 bit]
--8mib-ram PSone has 8 MiB ram available [default: 2 MiB]
--boot-only This format is for main exes and CD-Mastering only !
It may slightly improve the compression ratio,
decompression routines are faster than default ones.
But it cannot be used for console transfer !
--no-align This option disables CD mode 2 data sector format
alignment. May slightly improves the compression ratio,
but the compressed executable will not boot from a CD.
Use it for console transfer only !
NOTES FOR RTM32/PE and ARM/PE
Same as win32/pe.
NOTES FOR TMT/ADAM
This format is used by the TMT Pascal compiler - see http://www.tmt.com/
.
Extra options available for this executable format:
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.
NOTES FOR VMLINUZ/386
The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed bootable
Linux kernel image ("vmlinuz", "zImage", "bzImage"), gzip-decompress it
and re-compress it with the UPX compression method.
vmlinuz/386 is completely unrelated to the other Linux executable
formats, and it does not share any of their drawbacks.
Notes:
- Be sure that "vmlinuz/386" or "bvmlinuz/386" is displayed
during compression - otherwise a wrong executable format
may have been used, and the kernel won't boot.
Benefits:
- Better compression (but note that the kernel was already compressed,
so the improvement is not as large as with other formats).
Still, the bytes saved may be essential for special needs like
boot disks.
For example, this is what I get for my 2.2.16 kernel:
1589708 vmlinux
641073 bzImage [original]
560755 bzImage.upx [compressed by "upx -9"]
- Much faster decompression at kernel boot time (but kernel
decompression speed is not really an issue these days).
Drawbacks:
(none)
Extra options available for this executable format:
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.
NOTES FOR WATCOM/LE
UPX has been successfully tested with the following extenders: DOS4G,
DOS4GW, PMODE/W, DOS32a, CauseWay. The WDOS/X extender is partly
supported (for details see the file bugs BUGS).
DLLs and the LX format are not supported.
Extra options available for this executable format:
--le Produce an unbound LE output instead of
keeping the current stub.
NOTES FOR WIN32/PE
The PE support in UPX is quite stable now, but probably there are still
some incompatibilities with some files.
Because of the way UPX (and other packers for this format) works, you
can see increased memory usage of your compressed files because the
whole program is loaded into memory at startup. If you start several
instances of huge compressed programs you're wasting memory because the
common segments of the program won't get shared across the instances. On
the other hand if you're compressing only smaller programs, or running
only one instance of larger programs, then this penalty is smaller, but
it's still there.
If you're running executables from network, then compressed programs
will load faster, and require less bandwidth during execution.
DLLs are supported. But UPX compressed DLLs can not share common data
and code when they got used by multiple applications. So compressing
msvcrt.dll is a waste of memory, but compressing the dll plugins of a
particular application may be a better idea.
Screensavers are supported, with the restriction that the filename must
end with ".scr" (as screensavers are handled slightly different than
normal exe files).
UPX compressed PE files have some minor memory overhead (usually in the
10 - 30 KiB range) which can be seen by specifying the "-i" command line
switch during compression.
Extra options available for this executable format:
--compress-exports=0 Don't compress the export section.
Use this if you plan to run the compressed
program under Wine.
--compress-exports=1 Compress the export section. [DEFAULT]
Compression of the export section can improve the
compression ratio quite a bit but may not work
with all programs (like winword.exe).
UPX never compresses the export section of a DLL
regardless of this option.
--compress-icons=0 Don't compress any icons.
--compress-icons=1 Compress all but the first icon.
--compress-icons=2 Compress all icons which are not in the
first icon directory. [DEFAULT]
--compress-icons=3 Compress all icons.
--compress-resources=0 Don't compress any resources at all.
--keep-resource=list Don't compress resources specified by the list.
The members of the list are separated by commas.
A list member has the following format: I<type[/name]>.
I<Type> is the type of the resource. Standard types
must be specified as decimal numbers, user types can be
specified by decimal IDs or strings. I<Name> is the
identifier of the resource. It can be a decimal number
or a string. For example:
--keep-resource=2/MYBITMAP,5,6/12345
UPX won't compress the named bitmap resource "MYBITMAP",
it leaves every dialog (5) resource uncompressed, and
it won't touch the string table resource with identifier
12345.
--force Force compression even when there is an
unexpected value in a header field.
Use with care.
--strip-relocs=0 Don't strip relocation records.
--strip-relocs=1 Strip relocation records. [DEFAULT]
This option only works on executables with base
address greater or equal to 0x400000. Usually the
compressed files becomes smaller, but some files
may become larger. Note that the resulting file will
not work under Windows 3.x (Win32s).
UPX never strips relocations from a DLL
regardless of this option.
--all-methods Compress the program several times, using all
available compression methods. This may improve
the compression ratio in some cases, but usually
the default method gives the best results anyway.
--all-filters Compress the program several times, using all
available preprocessing filters. This may improve
the compression ratio in some cases, but usually
the default filter gives the best results anyway.
DIAGNOSTICS
Exit status is normally 0; if an error occurs, exit status is 1. If a
warning occurs, exit status is 2.
UPX's diagnostics are intended to be self-explanatory.
BUGS
Please report all bugs immediately to the authors.
AUTHORS
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberhumer.com
Laszlo Molnar <ezerotven+github@gmail.com>
John F. Reiser <jreiser@BitWagon.com>
Jens Medoch <jssg@users.sourceforge.net>
COPYRIGHT
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
Copyright (C) 2000-2022 John F. Reiser
Copyright (C) 2002-2022 Jens Medoch
UPX is distributed with full source code under the terms of the GNU
General Public License v2+; either under the pure GPLv2+ (see the file
COPYING), or (at your option) under the GPLv+2 with special exceptions
and restrictions granting the free usage for all binaries including
commercial programs (see the file LICENSE).
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the UPX License Agreements along with
this program; see the files COPYING and LICENSE. If not, visit the UPX
home page.
+1042
View File
File diff suppressed because it is too large Load Diff
+60 -60
View File
@@ -13,8 +13,8 @@ B<upx> S<[ I<command> ]> S<[ I<options> ]> I<filename>...
=head1 ABSTRACT
The Ultimate Packer for eXecutables
Copyright (c) 1996-2017 Markus Oberhumer, Laszlo Molnar & John Reiser
http://upx.sourceforge.net
Copyright (c) 1996-2022 Markus Oberhumer, Laszlo Molnar & John Reiser
https://upx.github.io
B<UPX> is a portable, extendable, high-performance executable packer for
@@ -23,75 +23,59 @@ ratio and offers I<*very*> fast decompression. Your executables suffer
no memory overhead or other drawbacks for most of the formats supported,
because of in-place decompression.
While you may use B<UPX> freely for both non-commercial and commercial
executables (for details see the file LICENSE), we would highly
appreciate if you credit B<UPX> and ourselves in the documentation,
possibly including a reference to the B<UPX> home page. Thanks.
[ Using B<UPX> in non-OpenSource applications without proper credits
is considered not politically correct ;-) ]
=head1 DISCLAIMER
B<UPX> comes with ABSOLUTELY NO WARRANTY; for details see the file LICENSE.
This is the first production quality release, and we plan that future 1.xx
releases will be backward compatible with this version.
B<UPX> comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING.
Please report all problems or suggestions to the authors. Thanks.
=head1 SECURITY CONTEXT
IMPORTANT NOTE: B<UPX> inherits the security context of any files it handles.
This means that packing, unpacking, or even testing or listing a file requires
the same security considerations as actually executing the file.
Use B<UPX> on trusted files only!
=head1 DESCRIPTION
B<UPX> is a versatile executable packer with the following features:
- excellent compression ratio: compresses better than zip/gzip,
- secure: as UPX is documented Open Source since many years any relevant
Security/Antivirus software is able to peek inside UPX compressed
apps to verify them
- excellent compression ratio: typically compresses better than Zip,
use UPX to decrease the size of your distribution !
- very fast decompression: about 10 MiB/sec on an ancient Pentium 133,
about 200 MiB/sec on an Athlon XP 2000+.
- very fast decompression: more than 500 MB/sec on any reasonably modern
machine
- no memory overhead for your compressed executables for most of the
supported formats
supported formats because of in-place decompression
- safe: you can list, test and unpack your executables
- safe: you can list, test and unpack your executables.
Also, a checksum of both the compressed and uncompressed file is
maintained internally.
- universal: UPX can pack a number of executable formats:
* atari/tos
* bvmlinuz/386 [bootable Linux kernel]
* djgpp2/coff
* dos/com
* dos/exe
* dos/sys
* linux/386
* linux/elf386
* linux/sh386
* ps1/exe
* rtm32/pe
* tmt/adam
* vmlinuz/386 [bootable Linux kernel]
* vmlinux/386
* watcom/le (supporting DOS4G, PMODE/W, DOS32a and CauseWay)
* win32/pe (exe and dll)
* win64/pe (exe and dll)
* arm/pe (exe and dll)
* linux/elfamd64
* linux/elfppc32
* mach/elfppc32
- universal: UPX can pack a number of executable formats, including
Windows programs and DLLs, macOS apps and Linux executables
- portable: UPX is written in portable endian-neutral C++
- extendable: because of the class layout it's very easy to support
new executable formats or add new compression algorithms
- free: UPX can be distributed and used freely. And from version 0.99
the full source code of UPX is released under the GNU General Public
License (GPL) !
- free: UPX is distributed with full source code under the GNU General
Public License v2+, with special exceptions granting the free usage
for commercial programs
You probably understand now why we call B<UPX> the "I<ultimate>"
executable packer.
@@ -146,7 +130,11 @@ compress and then decompress your program a first time - any further
compress-decompress steps should then yield byte-identical results
as compared to the first decompressed version.]
[ ...to be written... - type `B<upx --help>' for now ]
B<-k>: keep backup files
B<-o file>: write output to file
[ ...more docs need to be written... - type `B<upx --help>' for now ]
@@ -186,7 +174,17 @@ Quick info for achieving the best compression ratio:
=item *
Try B<upx --brute myfile.exe> or even B<upx --ultra-brute myfile.exe>.
Try B<upx --brute --no-lzma myfile.exe> or even
B<upx --ultra-brute --no-lzma myfile.exe>.
=item *
The option B<--lzma> enables LZMA compression, which compresses better but
is *significantly slower* at decompression. You probably do not want
to use it for large files.
(Note that B<--lzma> is automatically enabled by B<--all-methods> and
B<--brute>, use B<--no-lzma> to override.)
=item *
@@ -222,7 +220,7 @@ actually accesses this overlayed data.
=head1 ENVIRONMENT
=head1 ENVIRONMENT VARIABLE
The environment variable B<UPX> can hold a set of default
options for B<UPX>. These options are interpreted first and
@@ -252,7 +250,7 @@ This is the executable format used by the Atari ST/TT, a Motorola 68000
based personal computer which was popular in the late '80s. Support
of this format is only because of nostalgic feelings of one of
the authors and serves no practical purpose :-).
See http://www.freemint.de for more info.
See https://freemint.github.io for more info.
Packed programs will be byte-identical to the original after uncompression.
All debug information will be stripped, though.
@@ -675,7 +673,7 @@ Extra options available for this executable format:
=head2 NOTES FOR PS1/EXE
This is the executable format used by the Sony PlayStation (PSone),
a Mips R3000 based gaming console which is popular since the late '90s.
a MIPS R3000 based gaming console which is popular since the late '90s.
Support of this format is very similar to the Atari one, because of
nostalgic feelings of one of the authors.
@@ -934,22 +932,24 @@ Please report all bugs immediately to the authors.
=head1 COPYRIGHT
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Laszlo Molnar
Copyright (C) 2000-2017 John F. Reiser
Copyright (C) 2000-2022 John F. Reiser
Copyright (C) 2002-2017 Jens Medoch
Copyright (C) 2002-2022 Jens Medoch
This program may be used freely, and you are welcome to
redistribute it under certain conditions.
B<UPX> is distributed with full source code under the terms of the
GNU General Public License v2+; either under the pure GPLv2+ (see
the file COPYING), or (at your option) under the GPLv+2 with special
exceptions and restrictions granting the free usage for all binaries
including commercial programs (see the file LICENSE).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
B<UPX License Agreement> for more details.
You should have received a copy of the UPX License Agreement along
with this program; see the file LICENSE. If not, visit the UPX home page.
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the UPX License Agreements along
with this program; see the files COPYING and LICENSE. If not,
visit the UPX home page.
+14
View File
@@ -0,0 +1,14 @@
#! /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")"
# create the image from Dockerfile
# using a rootless Podman container
image=upx-stubtools-20210104-v5
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
podman image list "$image"
podman image tree "$image"
+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")"
# run an interactive shell in the image
# using a rootless Podman container
image=upx-stubtools-20210104-v5
flags=( -ti --read-only --rm )
flags+=( --cap-drop=all ) # drop all capabilities
flags+=( --network=none ) # no network needed
flags+=( -e TERM="$TERM" ) # pass $TERM
if [[ 1 == 1 ]]; then
# run as user upx 2000:2000
flags+=( --user 2000 )
# map container user 0 to subuid-user 1, and map container user 2000 to current host user
flags+=( --uidmap=0:1:1 --uidmap=2000:0:1 )
# map container group 0 to subgid-group 1, and map container group 2000 to current host group
flags+=( --gidmap=0:1:1 --gidmap=2000:0:1 )
# NOTE: we mount the upx top-level directory read-write under /home/upx/src/upx
# INFO: SELinux users *may* have to add ":z" to the volume mount flags; check the docs!
flags+=( -v "${argv0dir}/../..:/home/upx/src/upx" )
flags+=( -w /home/upx/src/upx ) # working directory
else
# run as user root 0:0
# ONLY FOR DEBUGGING THE IMAGE
# map container user/group 0 to current host user/group
flags+=( --user 0 )
fi
podman run "${flags[@]}" "$image" bash -l
# now we can rebuild the UPX stubs:
# cd /home/upx/src/upx/src/stub
# # make sure that git is clean:
# git status .
# # remove stub files and make sure that they got deleted:
# make maintainer-clean
# git status .
# # rebuild
# make all
# # make sure that the stub files did rebuild correctly:
# git status .
# git diff .
+66
View File
@@ -0,0 +1,66 @@
FROM docker.io/library/ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
ENV LANG=C.UTF-8
# install system packages
RUN dpkg --add-architecture i386 \
&& apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
aria2 ca-certificates git less libmpc3 libncurses5 make \
ncurses-term perl-base python2-minimal wget xz-utils \
libc6:i386 zlib1g:i386 \
# the following packages are not required for rebuilding the stubs,
# but they do make the image more convenient and also allow building
# the full UPX binary inside the container via CMake:
bzip2 cmake elfutils file g++ libzstd-dev lzop ninja-build patch \
patchelf pax-utils rsync unzip vim zip zlib1g-dev zsh zstd \
&& true
# manually install compat libs from Ubuntu 16.04
RUN cd /root \
&& aria2c --checksum=sha-256=2605f43f8047fc972855bb909f1dd7af761bbfd35ae559ad689b0d55a4236d69 \
'http://mirror.enzu.com/ubuntu/pool/main/g/gmp/libgmp10_6.1.0+dfsg-2_amd64.deb' \
&& aria2c --checksum=sha-256=3973a97387bbe0e8a775995c22861d8478edee2a594e8117970f635de25b2c8a \
'http://mirror.enzu.com/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb' \
&& mkdir packages \
&& for f in ./*.deb; do dpkg -x $f ./packages; done \
&& mv -v -n ./packages/usr/lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/ \
&& rm -rf ./*.deb ./packages \
&& ldconfig \
&& true
# install upx-stubtools into /usr/local/bin/bin-upx-20210104
RUN cd /root \
&& aria2c --checksum=sha-256=abcd8337cc656fe68d7bbb2ffe0f1e5ddce618688aa0e18c1ebcc40072843884 \
'https://github.com/upx/upx-stubtools/releases/download/v20210104/bin-upx-20210104.tar.xz' \
&& cd /usr/local/bin \
&& tar -xoaf /root/bin-upx-20210104.tar.xz \
&& rm /root/bin-upx-20210104.tar.xz \
&& true
# install previous UPX versions into /usr/local/bin
RUN cd /root \
&& wget -q https://github.com/upx/upx/releases/download/v3.91/upx-3.91-amd64_linux.tar.bz2 \
&& wget -q https://github.com/upx/upx/releases/download/v3.92/upx-3.92-amd64_linux.tar.xz \
&& wget -q https://github.com/upx/upx/releases/download/v3.93/upx-3.93-amd64_linux.tar.xz \
&& wget -q https://github.com/upx/upx/releases/download/v3.94/upx-3.94-amd64_linux.tar.xz \
&& wget -q https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz \
&& wget -q https://github.com/upx/upx/releases/download/v3.96/upx-3.96-amd64_linux.tar.xz \
&& for f in ./upx-*.tar.*; do tar -xoaf $f; done \
&& rm ./upx-*.tar.* \
&& d=upx-3.91-amd64_linux; ./$d/upx -d $d/upx -o /usr/local/bin/upx-3.91 \
&& d=upx-3.92-amd64_linux; ./$d/upx -d $d/upx -o /usr/local/bin/upx-3.92 \
&& d=upx-3.93-amd64_linux; ./$d/upx -d $d/upx -o /usr/local/bin/upx-3.93 \
&& d=upx-3.94-amd64_linux; ./$d/upx -d $d/upx -o /usr/local/bin/upx-3.94 \
&& d=upx-3.95-amd64_linux; ./$d/upx -d $d/upx -o /usr/local/bin/upx-3.95 \
&& d=upx-3.96-amd64_linux; ./$d/upx -d $d/upx -o /usr/local/bin/upx-3.96 \
&& rm -rf ./upx-*linux \
&& true
# create default user upx 2000:2000
RUN useradd upx -U --uid 2000 --shell /bin/bash -m \
&& mkdir -p /home/upx/.local/bin /home/upx/src/upx \
&& ln -s /usr/local/bin/bin-upx-20210104 /home/upx/.local/bin/bin-upx \
&& chown -R upx:upx /home/upx \
&& true
USER upx
@@ -11,14 +11,18 @@ find . \
-type d -name '.hg' -prune -o \
-type d -name 'build*' -prune -o \
-type d -name 'tmp*' -prune -o \
-type d -name 'vendor' -prune -o \
-type f -iname '*.bat' -prune -o \
-type f -iname '*.exe' -prune -o \
-type f -iname '*.o' -prune -o \
-type f -iname '*.obj' -prune -o \
-type f -iname '*.out' -prune -o \
-type f -iname '*.pdf' -prune -o \
-type f -iname '*.swp' -prune -o \
-type f -print0 | \
LC_ALL=C sort -z | xargs -0r perl -n -e '
#print("$ARGV\n");
if (m,[\x00\x01\x02\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
@@ -10,12 +10,13 @@ set -e; set -o pipefail
git ls-files --full-name -z | perl -0 -n -e '
s,^,./,;
if (m,^\./src/lzma-sdk(\0|$),) { }
elsif (m,^\./vendor/,) { }
elsif (m,\.bat(\0|$),) { }
elsif (m,\.exe(\0|$),) { }
else { print; }
' | LC_ALL=C sort -z | xargs -0r perl -n -e '
#print("$ARGV\n");
if (m,[\x00\x01\x02\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
if (m,[\x00\x01\x02\x7f\xfe\xff],) { print "ERROR: binary file detected $ARGV: $_"; exit(1); }
if (m,[\r\x1a],) { print "ERROR: DOS EOL detected $ARGV: $_"; exit(1); }
if (m,([ \t]+)$,) {
# allow exactly two trailing spaces for GitHub flavoured Markdown in .md files
+32
View File
@@ -0,0 +1,32 @@
#! /usr/bin/env bash
## vim:set ts=4 sw=4 et:
set -e; set -o pipefail
# "Gofmt's style is nobody's favourite, but gofmt is everybody's favourite." --Rob Pike
# NOTE: we are using clang-format-10.0.1 from upx-stubtools
# see https://github.com/upx/upx-stubtools/releases
# NOTE: we use .clang-format config from upx.git/.clang-format
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
UPX_CLANG_FORMAT="$HOME/local/bin/bin-upx/clang-format-10.0.1"
fi
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
UPX_CLANG_FORMAT="$HOME/.local/bin/bin-upx/clang-format-10.0.1"
fi
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
UPX_CLANG_FORMAT="$HOME/bin/bin-upx/clang-format-10.0.1"
fi
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
echo "ERROR: $0: cannot find clang-format-10.0.1"
echo "ERROR: $0: please visit https://github.com/upx/upx-stubtools"
exit 1
fi
# limit memory usage to 1 GiB (in case of clang-format problems with invalid files)
ulimit -v 1048576 || true
#echo $UPX_CLANG_FORMAT
exec "$UPX_CLANG_FORMAT" -style=file "$@"
exit 1
+54 -127
View File
@@ -1,18 +1,13 @@
#
# UPX Makefile - needs GNU make 3.81 or better
#
# Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
# UPX Makefile - needs GNU make
#
# build configuration options for this Makefile
BUILD_TYPE_DEBUG ?= 0
BUILD_TYPE_SANITIZE ?= 0
BUILD_USE_DEPEND ?= 1
# IMPORTANT NOTE: this Makefile is deprecated - please
# directly use the CMake build instead!
MAKEFLAGS += -r
.SUFFIXES:
export SHELL = /bin/sh
override ee = $($1) $(EXTRA_$1) $(upx_$1) $(upx_EXTRA_$1) $($(basename $(notdir $@)).$1)
ifndef srcdir
srcdir := $(dir $(lastword $(MAKEFILE_LIST)))
@@ -21,156 +16,88 @@ endif
ifndef top_srcdir
top_srcdir := $(srcdir)/..
endif
include $(wildcard $(top_srcdir)/Makevars.global ./Makevars.local)
ifneq ($(srcdir),.)
vpath %.cpp .:$(srcdir)
vpath %.h .:$(srcdir)
endif
# toolchain
CXX ?= g++
CXXLD = $(CXX)
exeext ?= .out
libext ?= .a
objext ?= .o
#
# redirect to top-level CMake build
#
upx_SOURCES := $(sort $(wildcard $(srcdir)/*.cpp))
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
default: debug
all: debug release
debug: $(top_srcdir)/build/debug/upx
release: $(top_srcdir)/build/release/upx
ifneq ($(wildcard $(top_srcdir)/.git/.),)
UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=12 HEAD || echo 'ERROR'))
ifneq ($(UPX_VERSION_GITREV),)
GITREV_PLUS := $(strip $(shell cd '$(top_srcdir)' && git diff --exit-code HEAD >/dev/null && echo '' || echo '+'))
DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)$(GITREV_PLUS)"'
endif
endif
$(top_srcdir)/build/debug/upx:
$(MAKE) -C $(top_srcdir) build/debug
$(top_srcdir)/build/release/upx:
$(MAKE) -C $(top_srcdir) build/release
# we need UCL and zlib - you can set envvar UPX_UCLDIR
ifneq ($(wildcard $(UPX_UCLDIR)/include/ucl/ucl.h),)
INCLUDES += -I$(UPX_UCLDIR)/include
LIBS += $(addprefix -L,$(dir $(wildcard $(UPX_UCLDIR)/libucl$(libext) $(UPX_UCLDIR)/src/.libs/libucl$(libext))))
endif
LIBS += -lucl -lz
# LZMA from https://github.com/upx/upx-lzma-sdk
include $(top_srcdir)/src/stub/src/c/Makevars.lzma
CPPFLAGS += $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)
ifeq ($(BUILD_TYPE_DEBUG),1)
CXXFLAGS_OPTIMIZE ?= -O0 -g
else
CXXFLAGS_OPTIMIZE ?= -O2
endif
CXXFLAGS += $(CXXFLAGS_OPTIMIZE)
# protect against security threats caused by misguided C++ compiler "optimizations"
ifeq ($(findstring clang,$(CXX)),)
CXXFLAGS += -fno-delete-null-pointer-checks
endif
CXXFLAGS += -fno-strict-aliasing -fwrapv
CXXFLAGS += -funsigned-char
CXXFLAGS += -Wall -W -Wcast-align -Wcast-qual -Wmissing-declarations -Wpointer-arith -Wshadow -Wvla -Wwrite-strings
CXXFLAGS_WERROR ?= -Werror
CXXFLAGS += $(CXXFLAGS_WERROR)
ifeq ($(BUILD_TYPE_SANITIZE),1)
CXXFLAGS_SANITIZE ?= -fsanitize=address,undefined -fno-omit-frame-pointer -DACC_CFG_NO_UNALIGNED
CXXFLAGS += $(CXXFLAGS_SANITIZE)
# these are the only 2 objects that are actually speed-sensitive
compress_lzma$(objext) filteri$(objext) : override CXXFLAGS_SANITIZE =
endif
# rules
all: upx$(exeext) | ./.depend
.DELETE_ON_ERROR: upx$(exeext) $(upx_OBJECTS) ./.depend
upx$(exeext): $(upx_OBJECTS) $(upx_DEPENDENCIES)
$($(notdir $@).PRE_LINK_STEP)
$(strip $(CXXLD) $(call ee,CXXFLAGS) $(call ee,LDFLAGS) -o $@ $(upx_OBJECTS) $(call ee,LDADD) $(call ee,LIBS))
$($(notdir $@).POST_LINK_STEP)
$(CHECK_WHITESPACE)
%.o : %.cpp | ./.depend
$(strip $(CXX) $(call ee,CPPFLAGS) $(call ee,CXXFLAGS) -o $@ -c $<)
%.cpp.ii : %.cpp
$(strip $(CXX) $(call ee,CPPFLAGS) $(call ee,CXXFLAGS) -o $@ -E $<)
ifeq ($(BUILD_USE_DEPEND),1)
./.depend: $(sort $(wildcard $(srcdir)/*.cpp $(srcdir)/*.h)) $(MAKEFILE_LIST)
@rm -f $@
@echo "Updating $@"
@$(strip $(CXX) $(call ee,CPPFLAGS) $(call ee,CXXFLAGS) -MM) $(filter %.cpp,$^) > $@
else
./.depend:
.PHONY: ./.depend
endif
CHECK_WHITESPACE =
ifeq ($(shell uname),Linux)
CHECK_WHITESPACE = $(top_srcdir)/src/stub/scripts/check_whitespace.sh $(top_srcdir)
ifneq ($(wildcard $(top_srcdir)/.git/.),)
CHECK_WHITESPACE = $(top_srcdir)/src/stub/scripts/check_whitespace_git.sh $(top_srcdir)
endif
check-whitespace : ; $(CHECK_WHITESPACE)
endif
.PHONY: check-whitespace
mostlyclean clean distclean maintainer-clean:
rm -f *.d *.ii *.map *.o *.obj *.res ./.depend upx.exe upx.out upx.ttp upx$(exeext)
./.depend compress_lzma$(objext) : INCLUDES += -I$(UPX_LZMADIR)
compress_lzma$(objext) : CXXFLAGS += -Wno-shadow
p_mach$(objext) : CXXFLAGS += -Wno-cast-align
.PHONY: all mostlyclean clean distclean maintainer-clean
ifeq ($(MAKECMDGOALS),mostlyclean)
else ifeq ($(MAKECMDGOALS),clean)
else ifeq ($(MAKECMDGOALS),distclean)
else ifeq ($(MAKECMDGOALS),maintainer-clean)
else ifeq ($(MAKECMDGOALS),clang-format)
else ifeq ($(MAKECMDGOALS),check-whitespace)
else
ifeq ($(BUILD_USE_DEPEND),1)
-include ./.depend
endif
help$(objext): $(MAKEFILE_LIST)
endif
.PHONY: default all debug release
.PHONY: $(top_srcdir)/build/debug/upx
.PHONY: $(top_srcdir)/build/release/upx
#
# "make run-testsuite"
#
# search for the UPX testsuite -- git clone https://github.com/upx/upx-testsuite.git
# you also can override upx_testsuite_SRCDIR
ifndef upx_testsuite_SRCDIR
# search standard locations below $(top_srcdir)
ifneq ($(wildcard $(top_srcdir)/../upx-testsuite.git/files/packed/.),)
ifneq ($(wildcard $(top_srcdir)/../upx--upx-testsuite.git/files/packed/.),)
upx_testsuite_SRCDIR := $(top_srcdir)/../upx--upx-testsuite.git
else ifneq ($(wildcard $(top_srcdir)/../upx-testsuite.git/files/packed/.),)
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite.git
else ifneq ($(wildcard $(top_srcdir)/../upx-testsuite/files/packed/.),)
upx_testsuite_SRCDIR := $(top_srcdir)/../upx-testsuite
endif
endif
# run the UPX testsuite
# The expected (old) checksums are in $(top_srcdir)/.github/travis_testsuite_1.sh
# The expected (old) checksums are in $(top_srcdir)/.github/travis_testsuite_1-expected_sha256sums.sh
# The actual (new) checksums are in tmp-testsuite/testsuite_1/.sha256sums.recreate
ifneq ($(wildcard $(upx_testsuite_SRCDIR)/files/packed/.),)
ifneq ($(wildcard $(top_srcdir)/.github/travis_testsuite_1.sh),)
run-testsuite: export upx_exe := ./upx$(exeext)
run-testsuite: export upx_exe := $(top_srcdir)/build/release/upx
run-testsuite: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
run-testsuite: export upx_testsuite_BUILDDIR := ./tmp-testsuite
run-testsuite: ./upx$(exeext)
run-testsuite: $(top_srcdir)/build/release/upx
time -p bash $(top_srcdir)/.github/travis_testsuite_1.sh
.PHONY: run-testsuite
endif
endif
#
# "make clang-format"
#
# automatically format some C++ source code files
ifeq ($(shell uname),Linux)
CLANG_FORMAT_FILES += linker.cpp linker.h packhead.cpp packmast.cpp
CLANG_FORMAT_FILES += bele.h bele_policy.h
CLANG_FORMAT_FILES += except.cpp except.h
CLANG_FORMAT_FILES += file.cpp file.h
CLANG_FORMAT_FILES += linker.cpp linker.h packhead.cpp packmast.cpp packmast.h
CLANG_FORMAT_FILES += main.cpp options.cpp options.h packer.cpp packer.h
CLANG_FORMAT_FILES += p_tos.cpp p_tos.h
CLANG_FORMAT_FILES += s_djgpp2.cpp s_object.cpp s_vcsa.cpp s_win32.cpp screen.h
CLANG_FORMAT_FILES += snprintf.cpp
CLANG_FORMAT_FILES += stdcxx.cpp stdcxx.h
CLANG_FORMAT_FILES += ui.cpp ui.h util.h
CLANG_FORMAT_FILES += ui.cpp ui.h work.cpp
CLANG_FORMAT_FILES += $(wildcard util/[a-ln-z]*.[ch]* util/mem*.[ch]*)
clang-format:
$(top_srcdir)/src/stub/scripts/upx-clang-format -i $(addprefix $(top_srcdir)/src/,$(CLANG_FORMAT_FILES))
$(top_srcdir)/misc/scripts/upx-clang-format -i $(addprefix $(top_srcdir)/src/,$(sort $(CLANG_FORMAT_FILES)))
.PHONY: clang-format
endif
#
# "make check-whitespace"
#
CHECK_WHITESPACE =
ifeq ($(shell uname),Linux)
CHECK_WHITESPACE = $(top_srcdir)/misc/scripts/check_whitespace.sh $(top_srcdir)
ifneq ($(wildcard $(top_srcdir)/.git/.),)
CHECK_WHITESPACE = $(top_srcdir)/misc/scripts/check_whitespace_git.sh $(top_srcdir)
endif
check-whitespace : ; $(CHECK_WHITESPACE)
endif
.PHONY: check-whitespace
# vim:set ts=8 sw=8 noet:
+485 -356
View File
File diff suppressed because it is too large Load Diff
+74 -103
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -25,12 +25,10 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_BELE_H
#ifndef UPX_BELE_H__
#error "this is an internal include file"
#endif
/*************************************************************************
//
**************************************************************************/
@@ -49,10 +47,8 @@
#error
#endif
#if defined(BELE_RTP)
struct AbstractPolicy
{
struct AbstractPolicy {
inline AbstractPolicy() {}
virtual inline ~AbstractPolicy() {}
V bool isBE() C = 0;
@@ -68,10 +64,10 @@ struct AbstractPolicy
V void set32(void *p, unsigned v) C = 0;
V void set64(void *p, upx_uint64_t v) C = 0;
V unsigned get16_signed(const void *p) C = 0;
V unsigned get24_signed(const void *p) C = 0;
V unsigned get32_signed(const void *p) C = 0;
V upx_uint64_t get64_signed(const void *p) C = 0;
V int get16_signed(const void *p) C = 0;
V int get24_signed(const void *p) C = 0;
V int get32_signed(const void *p) C = 0;
V upx_int64_t get64_signed(const void *p) C = 0;
S u16_compare(const void *a, const void *b) C = 0;
S u24_compare(const void *a, const void *b) C = 0;
@@ -83,15 +79,24 @@ struct AbstractPolicy
S u32_compare_signed(const void *a, const void *b) C = 0;
S u64_compare_signed(const void *a, const void *b) C = 0;
private:
// disable copy, assignment and move assignment
AbstractPolicy(const AbstractPolicy &) = delete;
AbstractPolicy &operator=(const AbstractPolicy &) = delete;
AbstractPolicy &operator=(AbstractPolicy &&) = delete;
// disable dynamic allocation
DISABLE_NEW_DELETE
ACC_CXX_DISABLE_NEW_DELETE
};
#endif
#if defined(BELE_RTP)
#undef C
#define C const override
#endif
struct BEPolicy
#if defined(BELE_RTP)
: public AbstractPolicy
final : public AbstractPolicy
#endif
{
inline BEPolicy() {}
@@ -107,50 +112,30 @@ struct BEPolicy
typedef BE32 U32;
typedef BE64 U64;
V unsigned get16(const void *p) C
{ return get_be16(p); }
V unsigned get24(const void *p) C
{ return get_be24(p); }
V unsigned get32(const void *p) C
{ return get_be32(p); }
V upx_uint64_t get64(const void *p) C
{ return get_be64(p); }
V unsigned get16(const void *p) C { return get_be16(p); }
V unsigned get24(const void *p) C { return get_be24(p); }
V unsigned get32(const void *p) C { return get_be32(p); }
V upx_uint64_t get64(const void *p) C { return get_be64(p); }
V void set16(void *p, unsigned v) C
{ set_be16(p, v); }
V void set24(void *p, unsigned v) C
{ set_be24(p, v); }
V void set32(void *p, unsigned v) C
{ set_be32(p, v); }
V void set64(void *p, upx_uint64_t v) C
{ set_be64(p, v); }
V void set16(void *p, unsigned v) C { set_be16(p, v); }
V void set24(void *p, unsigned v) C { set_be24(p, v); }
V void set32(void *p, unsigned v) C { set_be32(p, v); }
V void set64(void *p, upx_uint64_t v) C { set_be64(p, v); }
V unsigned get16_signed(const void *p) C
{ return get_be16_signed(p); }
V unsigned get24_signed(const void *p) C
{ return get_be24_signed(p); }
V unsigned get32_signed(const void *p) C
{ return get_be32_signed(p); }
V upx_uint64_t get64_signed(const void *p) C
{ return get_be64_signed(p); }
V int get16_signed(const void *p) C { return get_be16_signed(p); }
V int get24_signed(const void *p) C { return get_be24_signed(p); }
V int get32_signed(const void *p) C { return get_be32_signed(p); }
V upx_int64_t get64_signed(const void *p) C { return get_be64_signed(p); }
S u16_compare(const void *a, const void *b) C
{ return be16_compare(a, b); }
S u24_compare(const void *a, const void *b) C
{ return be24_compare(a, b); }
S u32_compare(const void *a, const void *b) C
{ return be32_compare(a, b); }
S u64_compare(const void *a, const void *b) C
{ return be64_compare(a, b); }
S u16_compare(const void *a, const void *b) C { return be16_compare(a, b); }
S u24_compare(const void *a, const void *b) C { return be24_compare(a, b); }
S u32_compare(const void *a, const void *b) C { return be32_compare(a, b); }
S u64_compare(const void *a, const void *b) C { return be64_compare(a, b); }
S u16_compare_signed(const void *a, const void *b) C
{ return be16_compare_signed(a, b); }
S u24_compare_signed(const void *a, const void *b) C
{ return be24_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 u16_compare_signed(const void *a, const void *b) C { return be16_compare_signed(a, b); }
S u24_compare_signed(const void *a, const void *b) C { return be24_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); }
static void compileTimeAssertions() {
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
@@ -161,14 +146,18 @@ struct BEPolicy
COMPILE_TIME_ASSERT_ALIGNED1(U64)
}
private:
// disable copy, assignment and move assignment
BEPolicy(const BEPolicy &) = delete;
BEPolicy &operator=(const BEPolicy &) = delete;
BEPolicy &operator=(BEPolicy &&) = delete;
// disable dynamic allocation
DISABLE_NEW_DELETE
ACC_CXX_DISABLE_NEW_DELETE
};
struct LEPolicy
#if defined(BELE_RTP)
: public AbstractPolicy
final : public AbstractPolicy
#endif
{
inline LEPolicy() {}
@@ -184,50 +173,30 @@ struct LEPolicy
typedef LE32 U32;
typedef LE64 U64;
V unsigned get16(const void *p) C
{ return get_le16(p); }
V unsigned get24(const void *p) C
{ return get_le24(p); }
V unsigned get32(const void *p) C
{ return get_le32(p); }
V upx_uint64_t get64(const void *p) C
{ return get_le64(p); }
V unsigned get16(const void *p) C { return get_le16(p); }
V unsigned get24(const void *p) C { return get_le24(p); }
V unsigned get32(const void *p) C { return get_le32(p); }
V upx_uint64_t get64(const void *p) C { return get_le64(p); }
V void set16(void *p, unsigned v) C
{ set_le16(p, v); }
V void set24(void *p, unsigned v) C
{ set_le24(p, v); }
V void set32(void *p, unsigned v) C
{ set_le32(p, v); }
V void set64(void *p, upx_uint64_t v) C
{ set_le64(p, v); }
V void set16(void *p, unsigned v) C { set_le16(p, v); }
V void set24(void *p, unsigned v) C { set_le24(p, v); }
V void set32(void *p, unsigned v) C { set_le32(p, v); }
V void set64(void *p, upx_uint64_t v) C { set_le64(p, v); }
V unsigned get16_signed(const void *p) C
{ return get_le16_signed(p); }
V unsigned get24_signed(const void *p) C
{ return get_le24_signed(p); }
V unsigned get32_signed(const void *p) C
{ return get_le32_signed(p); }
V upx_uint64_t get64_signed(const void *p) C
{ return get_le64_signed(p); }
V int get16_signed(const void *p) C { return get_le16_signed(p); }
V int get24_signed(const void *p) C { return get_le24_signed(p); }
V int get32_signed(const void *p) C { return get_le32_signed(p); }
V upx_int64_t get64_signed(const void *p) C { return get_le64_signed(p); }
S u16_compare(const void *a, const void *b) C
{ return le16_compare(a, b); }
S u24_compare(const void *a, const void *b) C
{ return le24_compare(a, b); }
S u32_compare(const void *a, const void *b) C
{ return le32_compare(a, b); }
S u64_compare(const void *a, const void *b) C
{ return le64_compare(a, b); }
S u16_compare(const void *a, const void *b) C { return le16_compare(a, b); }
S u24_compare(const void *a, const void *b) C { return le24_compare(a, b); }
S u32_compare(const void *a, const void *b) C { return le32_compare(a, b); }
S u64_compare(const void *a, const void *b) C { return le64_compare(a, b); }
S u16_compare_signed(const void *a, const void *b) C
{ return le16_compare_signed(a, b); }
S u24_compare_signed(const void *a, const void *b) C
{ return le24_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 u16_compare_signed(const void *a, const void *b) C { return le16_compare_signed(a, b); }
S u24_compare_signed(const void *a, const void *b) C { return le24_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); }
static void compileTimeAssertions() {
COMPILE_TIME_ASSERT(sizeof(U16) == 2)
@@ -238,11 +207,16 @@ struct LEPolicy
COMPILE_TIME_ASSERT_ALIGNED1(U64)
}
private:
// disable copy, assignment and move assignment
LEPolicy(const LEPolicy &) = delete;
LEPolicy &operator=(const LEPolicy &) = delete;
LEPolicy &operator=(LEPolicy &&) = delete;
// disable dynamic allocation
DISABLE_NEW_DELETE
ACC_CXX_DISABLE_NEW_DELETE
};
// native policy (aka host policy)
#if (ACC_ABI_BIG_ENDIAN)
typedef BEPolicy HostPolicy;
#elif (ACC_ABI_LITTLE_ENDIAN)
@@ -251,10 +225,8 @@ typedef LEPolicy HostPolicy;
#error "ACC_ABI_ENDIAN"
#endif
#if 0 /* UNUSED */
struct HostAlignedPolicy
{
struct HostAlignedPolicy {
#if defined(BELE_CTP)
enum { isBE = HostPolicy::isBE, isLE = HostPolicy::isLE };
#endif
@@ -271,7 +243,6 @@ struct HostAlignedPolicy
};
#endif
#undef V
#undef S
#undef C
-106
View File
@@ -1,106 +0,0 @@
/* bptr.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_BPTR_H
#define __UPX_BPTR_H 1
/*************************************************************************
// BoundedPtr
**************************************************************************/
template <class T>
class BoundedPtr
{
public:
//typedef T* StoredType;
//typedef T* PointerType;
//typedef T& ReferenceType;
~BoundedPtr() { }
explicit BoundedPtr(void* base, size_t size_in_bytes, T* ptr=0)
: ptr_(ptr), base_(base), size_in_bytes_(0)
{
assert(base_ != NULL);
size_in_bytes_ = mem_size(1, size_in_bytes);
check();
}
// assignment
BoundedPtr& operator= (const BoundedPtr& other) {
assert(base_ == other.base_);
assert(size_in_bytes_ == other.size_in_bytes_);
ptr_ = other.ptr_; check(); return *this;
}
BoundedPtr& operator= (T* other) {
ptr_ = other; check(); return *this;
}
operator T* () { return ptr_; }
operator const T* () const { return ptr_; }
BoundedPtr& operator += (size_t n) {
checkNULL(); ptr_ += n; checkRange(); return *this;
}
BoundedPtr& operator -= (size_t n) {
checkNULL(); ptr_ -= n; checkRange(); return *this;
}
BoundedPtr& operator ++ (void) {
checkNULL(); ptr_ += 1; checkRange(); return *this;
}
private:
void checkNULL() const {
if __acc_very_unlikely(!ptr_)
throwCantUnpack("unexpected NULL pointer; take care!");
}
void checkRange() const {
size_t off = (const char *) ptr_ - (const char *) base_;
if __acc_very_unlikely(off > size_in_bytes_)
throwCantUnpack("pointer out of range; take care!");
}
void check() const { // check ptr_ invariant: either NULL or valid checkRange()
if (ptr_ != NULL)
checkRange();
}
T* ptr_;
void* base_;
size_t size_in_bytes_;
// disable copy
BoundedPtr(const BoundedPtr&); // {}
// disable dynamic allocation
DISABLE_NEW_DELETE
};
#endif /* already included */
/* vim:set ts=4 sw=4 et: */
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+7 -7
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -28,7 +28,7 @@
#include "conf.h"
FILE *con_term = NULL;
FILE *con_term = nullptr;
#if (USE_CONSOLE)
@@ -60,7 +60,7 @@ static void try_init(console_t *c, FILE *f)
{
con_mode = k;
con = c;
con->init = 0;
con->init = nullptr;
if (!con->set_fg)
con->set_fg = console_none.set_fg;
if (!con->print0)
@@ -137,18 +137,18 @@ console_t console_init =
{
init,
set_fg,
0,
nullptr,
intro
};
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
void con_fprintf(FILE *f, const char *format, ...)
{
va_list args;
char buf[80*25];
va_start(args, format);
upx_vsnprintf(buf, sizeof(buf), format,args);
upx_safe_vsnprintf(buf, sizeof(buf), format,args);
va_end(args);
if (con == me)
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+7 -7
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -72,11 +72,11 @@ static int do_init(screen_t *s, int fd)
static screen_t *do_construct(screen_t *s, int fd)
{
if (!s)
return NULL;
return nullptr;
if (do_init(s,fd) != 0)
{
s->destroy(s);
return NULL;
return nullptr;
}
return s;
}
@@ -86,7 +86,7 @@ static screen_t *do_construct(screen_t *s, int fd)
//
**************************************************************************/
static screen_t *screen = NULL;
static screen_t *screen = nullptr;
static void __acc_cdecl_atexit do_destroy(void)
{
@@ -95,7 +95,7 @@ static void __acc_cdecl_atexit do_destroy(void)
if (screen->atExit)
screen->atExit();
screen->destroy(screen);
screen = NULL;
screen = nullptr;
}
}
@@ -113,7 +113,7 @@ static int init(FILE *f, int o, int now)
int n;
UNUSED(now);
assert(screen == NULL);
assert(screen == nullptr);
if (o == CON_SCREEN)
n = CON_SCREEN;
+7 -7
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -28,7 +28,7 @@
#include "conf.h"
#include "compress.h"
#include "mem.h"
#include "util/membuffer.h"
/*************************************************************************
@@ -39,7 +39,7 @@ unsigned upx_adler32(const void *buf, unsigned len, unsigned adler)
{
if (len == 0)
return adler;
assert(buf != NULL);
assert(buf != nullptr);
#if 1
return upx_ucl_adler32(buf, len, adler);
#else
@@ -53,7 +53,7 @@ unsigned upx_crc32(const void *buf, unsigned len, unsigned crc)
{
if (len == 0)
return crc;
assert(buf != NULL);
assert(buf != nullptr);
#if 1
return upx_ucl_crc32(buf, len, crc);
#else
@@ -145,7 +145,7 @@ int upx_decompress ( const upx_bytep src, unsigned src_len,
assert(src_len < *dst_len); // must be compressed
if (cresult && cresult->method == 0)
cresult = NULL;
cresult = nullptr;
if __acc_cte(0) {
}
@@ -187,7 +187,7 @@ int upx_test_overlap ( const upx_bytep buf,
int r = UPX_E_ERROR;
if (cresult && cresult->method == 0)
cresult = NULL;
cresult = nullptr;
assert(*dst_len > 0);
assert(src_len < *dst_len); // must be compressed
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+49 -37
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -28,8 +28,14 @@
#include "conf.h"
#include "compress.h"
#include "mem.h"
#include "util/membuffer.h"
#if (ACC_CC_CLANG)
# pragma clang diagnostic ignored "-Wshadow"
#endif
#if (ACC_CC_GNUC >= 0x040200)
# pragma GCC diagnostic ignored "-Wshadow"
#endif
#if (ACC_CC_MSC)
# pragma warning(disable: 4456) // -Wno-shadow
#endif
@@ -43,8 +49,6 @@
void lzma_compress_config_t::reset()
{
memset(this, 0, sizeof(*this));
pos_bits.reset();
lit_pos_bits.reset();
lit_context_bits.reset();
@@ -111,11 +115,11 @@ static int prepare(lzma_compress_result_t *res,
res->num_fast_bytes = 64; // 5 .. 273
res->match_finder_cycles = 0;
// UPX overrides
res->pos_bits = lzma_compress_config_t::pos_bits_t::default_value_c;
res->lit_pos_bits = lzma_compress_config_t::lit_pos_bits_t::default_value_c;
res->lit_context_bits = lzma_compress_config_t::lit_context_bits_t::default_value_c;
res->dict_size = lzma_compress_config_t::dict_size_t::default_value_c;
res->num_fast_bytes = lzma_compress_config_t::num_fast_bytes_t::default_value_c;
res->pos_bits = lzma_compress_config_t::pos_bits_t::default_value;
res->lit_pos_bits = lzma_compress_config_t::lit_pos_bits_t::default_value;
res->lit_context_bits = lzma_compress_config_t::lit_context_bits_t::default_value;
res->dict_size = lzma_compress_config_t::dict_size_t::default_value;
res->num_fast_bytes = lzma_compress_config_t::num_fast_bytes_t::default_value;
// method overrides
if (method >= 0x100) {
res->pos_bits = (method >> 16) & 15;
@@ -183,7 +187,7 @@ static int prepare(lzma_compress_result_t *res,
{
for (;;)
{
unsigned n = 1846 + (768 << (res->lit_context_bits + res->lit_pos_bits));
unsigned n = 1846 + (768u << (res->lit_context_bits + res->lit_pos_bits));
if (n <= lcconf->max_num_probs)
break;
if (res->lit_pos_bits > res->lit_context_bits)
@@ -201,7 +205,13 @@ static int prepare(lzma_compress_result_t *res,
}
}
res->num_probs = 1846 + (768 << (res->lit_context_bits + res->lit_pos_bits));
lzma_compress_config_t::pos_bits_t::assertValue(res->pos_bits);
lzma_compress_config_t::lit_pos_bits_t::assertValue(res->lit_pos_bits);
lzma_compress_config_t::lit_context_bits_t::assertValue(res->lit_context_bits);
lzma_compress_config_t::dict_size_t::assertValue(res->dict_size);
lzma_compress_config_t::num_fast_bytes_t::assertValue(res->num_fast_bytes);
res->num_probs = 1846 + (768u << (res->lit_context_bits + res->lit_pos_bits));
//printf("\nlzma_compress config: %u %u %u %u %u\n", res->pos_bits, res->lit_pos_bits, res->lit_context_bits, res->dict_size, res->num_probs);
return 0;
@@ -220,9 +230,11 @@ error:
#undef _WIN32_WCE
#undef COMPRESS_MF_MT
#undef _NO_EXCEPTIONS
#include "C/Common/MyInitGuid.h"
//#include "C/7zip/Compress/LZMA/LZMADecoder.h"
#include "C/7zip/Compress/LZMA/LZMAEncoder.h"
#undef NULL
#define NULL nullptr
#include <lzma-sdk/C/Common/MyInitGuid.h>
//#include <lzma-sdk/C/7zip/Compress/LZMA/LZMADecoder.h>
#include <lzma-sdk/C/7zip/Compress/LZMA/LZMAEncoder.h>
namespace MyLzma {
@@ -234,7 +246,7 @@ struct InStream: public ISequentialInStream, public CMyUnknownImp
void Init(const Byte *data, size_t size) {
b_buf = data; b_size = size; b_pos = 0;
}
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) override;
};
STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
@@ -243,7 +255,7 @@ STDMETHODIMP InStream::Read(void *data, UInt32 size, UInt32 *processedSize)
if (size > remain) size = (UInt32) remain;
memmove(data, b_buf + b_pos, size);
b_pos += size;
if (processedSize != NULL) *processedSize = size;
if (processedSize != nullptr) *processedSize = size;
return S_OK;
}
@@ -260,7 +272,7 @@ struct OutStream : public ISequentialOutStream, public CMyUnknownImp
b_buf[b_pos++] = c;
return S_OK;
}
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize);
STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) override;
};
STDMETHODIMP OutStream::Write(const void *data, UInt32 size, UInt32 *processedSize)
@@ -269,7 +281,7 @@ STDMETHODIMP OutStream::Write(const void *data, UInt32 size, UInt32 *processedSi
if (size > remain) size = (UInt32) remain, overflow = true;
memmove(b_buf + b_pos, data, size);
b_pos += size;
if (processedSize != NULL) *processedSize = size;
if (processedSize != nullptr) *processedSize = size;
return overflow ? E_FAIL : S_OK;
}
@@ -277,7 +289,7 @@ struct ProgressInfo : public ICompressProgressInfo, public CMyUnknownImp
{
virtual ~ProgressInfo() { }
MY_UNKNOWN_IMP
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize);
STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize) override;
upx_callback_p cb;
};
@@ -290,16 +302,16 @@ STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outS
} // namespace
#include "C/Common/Alloc.cpp"
#include "C/Common/CRC.cpp"
//#include "C/7zip/Common/InBuffer.cpp"
#include "C/7zip/Common/OutBuffer.cpp"
#include "C/7zip/Common/StreamUtils.cpp"
#include "C/7zip/Compress/LZ/LZInWindow.cpp"
//#include "C/7zip/Compress/LZ/LZOutWindow.cpp"
//#include "C/7zip/Compress/LZMA/LZMADecoder.cpp"
#include "C/7zip/Compress/LZMA/LZMAEncoder.cpp"
#include "C/7zip/Compress/RangeCoder/RangeCoderBit.cpp"
#include <lzma-sdk/C/Common/Alloc.cpp>
#include <lzma-sdk/C/Common/CRC.cpp>
//#include <lzma-sdk/C/7zip/Common/InBuffer.cpp>
#include <lzma-sdk/C/7zip/Common/OutBuffer.cpp>
#include <lzma-sdk/C/7zip/Common/StreamUtils.cpp>
#include <lzma-sdk/C/7zip/Compress/LZ/LZInWindow.cpp>
//#include <lzma-sdk/C/7zip/Compress/LZ/LZOutWindow.cpp>
//#include <lzma-sdk/C/7zip/Compress/LZMA/LZMADecoder.cpp>
#include <lzma-sdk/C/7zip/Compress/LZMA/LZMAEncoder.cpp>
#include <lzma-sdk/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp>
#undef RC_NORMALIZE
@@ -311,11 +323,11 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
upx_compress_result_t *cresult )
{
assert(M_IS_LZMA(method));
assert(level > 0); assert(cresult != NULL);
assert(level > 0); assert(cresult != nullptr);
int r = UPX_E_ERROR;
HRESULT rh;
const lzma_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_lzma : NULL;
const lzma_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_lzma : nullptr;
lzma_compress_result_t *res = &cresult->result_lzma;
MyLzma::InStream is; is.AddRef();
@@ -372,7 +384,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
os.WriteByte(Byte((t << 3) | res->pos_bits));
os.WriteByte(Byte((res->lit_pos_bits << 4) | (res->lit_context_bits)));
rh = enc.Code(&is, &os, NULL, NULL, &progress);
rh = enc.Code(&is, &os, nullptr, nullptr, &progress);
} catch (...) {
rh = E_OUTOFMEMORY;
@@ -410,8 +422,8 @@ error:
#undef _LZMA_OUT_READ
#undef _LZMA_PROB32
#undef _LZMA_LOC_OPT
#include "C/7zip/Compress/LZMA_C/LzmaDecode.h"
#include "C/7zip/Compress/LZMA_C/LzmaDecode.c"
#include <lzma-sdk/C/7zip/Compress/LZMA_C/LzmaDecode.h>
#include <lzma-sdk/C/7zip/Compress/LZMA_C/LzmaDecode.c>
int upx_lzma_decompress ( const upx_bytep src, unsigned src_len,
upx_bytep dst, unsigned* dst_len,
@@ -499,7 +511,7 @@ int upx_lzma_test_overlap ( const upx_bytep buf,
// NOTE: there is a very tiny possibility that decompression has
// succeeded but the data is not restored correctly because of
// in-place buffer overlapping, so we use an extra memcmp().
if (tbuf != NULL && memcmp(tbuf, b, *dst_len) != 0)
if (tbuf != nullptr && memcmp(tbuf, b, *dst_len) != 0)
return UPX_E_ERROR;
return UPX_E_OK;
}
@@ -520,7 +532,7 @@ const char *upx_lzma_version_string(void)
return "4.43";
#else
# error "unknown WITH_LZMA version"
return NULL;
return nullptr;
#endif
}
+79 -55
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -28,34 +28,6 @@
#include "conf.h"
#include "compress.h"
#if !(WITH_UCL)
extern int compress_ucl_dummy;
int compress_ucl_dummy = 0;
#else
#if 1 && !(UCL_USE_ASM) && (ACC_ARCH_I386)
# if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_INTELC || ACC_CC_MSC || ACC_CC_WATCOMC)
# define UCL_USE_ASM 1
# endif
#endif
#if (UCL_NO_ASM)
# undef UCL_USE_ASM
#endif
#if (ACC_CFG_NO_UNALIGNED)
# undef UCL_USE_ASM
#endif
#if 1 && (UCL_USE_ASM)
# include <ucl/ucl_asm.h>
# define ucl_nrv2b_decompress_safe_8 ucl_nrv2b_decompress_asm_safe_8
# define ucl_nrv2b_decompress_safe_le16 ucl_nrv2b_decompress_asm_safe_le16
# define ucl_nrv2b_decompress_safe_le32 ucl_nrv2b_decompress_asm_safe_le32
# define ucl_nrv2d_decompress_safe_8 ucl_nrv2d_decompress_asm_safe_8
# define ucl_nrv2d_decompress_safe_le16 ucl_nrv2d_decompress_asm_safe_le16
# define ucl_nrv2d_decompress_safe_le32 ucl_nrv2d_decompress_asm_safe_le32
# define ucl_nrv2e_decompress_safe_8 ucl_nrv2e_decompress_asm_safe_8
# define ucl_nrv2e_decompress_safe_le16 ucl_nrv2e_decompress_asm_safe_le16
# define ucl_nrv2e_decompress_safe_le32 ucl_nrv2e_decompress_asm_safe_le32
#endif
/*************************************************************************
@@ -106,13 +78,13 @@ int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
upx_compress_result_t *cresult )
{
int r;
assert(level > 0); assert(cresult != NULL);
assert(level > 0); assert(cresult != nullptr);
COMPILE_TIME_ASSERT(sizeof(ucl_compress_config_t) == sizeof(REAL_ucl_compress_config_t))
ucl_progress_callback_t cb;
cb.callback = 0;
cb.user = NULL;
cb.callback = nullptr;
cb.user = nullptr;
if (cb_parm && cb_parm->nprogress) {
cb.callback = wrap_nprogress_ucl;
cb.user = cb_parm;
@@ -188,31 +160,31 @@ int upx_ucl_decompress ( const upx_bytep src, unsigned src_len,
switch (method)
{
case M_NRV2B_8:
r = ucl_nrv2b_decompress_safe_8(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2b_decompress_safe_8(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2B_LE16:
r = ucl_nrv2b_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2b_decompress_safe_le16(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2B_LE32:
r = ucl_nrv2b_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2b_decompress_safe_le32(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2D_8:
r = ucl_nrv2d_decompress_safe_8(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2d_decompress_safe_8(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2D_LE16:
r = ucl_nrv2d_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2d_decompress_safe_le16(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2D_LE32:
r = ucl_nrv2d_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2d_decompress_safe_le32(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2E_8:
r = ucl_nrv2e_decompress_safe_8(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2e_decompress_safe_8(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2E_LE16:
r = ucl_nrv2e_decompress_safe_le16(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2e_decompress_safe_le16(src,src_len,dst,dst_len,nullptr);
break;
case M_NRV2E_LE32:
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,NULL);
r = ucl_nrv2e_decompress_safe_le32(src,src_len,dst,dst_len,nullptr);
break;
default:
throwInternalError("unknown decompression method");
@@ -241,31 +213,31 @@ int upx_ucl_test_overlap ( const upx_bytep buf,
switch (method)
{
case M_NRV2B_8:
r = ucl_nrv2b_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2b_test_overlap_8(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2B_LE16:
r = ucl_nrv2b_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2b_test_overlap_le16(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2B_LE32:
r = ucl_nrv2b_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2b_test_overlap_le32(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2D_8:
r = ucl_nrv2d_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2d_test_overlap_8(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2D_LE16:
r = ucl_nrv2d_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2d_test_overlap_le16(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2D_LE32:
r = ucl_nrv2d_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2d_test_overlap_le32(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2E_8:
r = ucl_nrv2e_test_overlap_8(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2e_test_overlap_8(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2E_LE16:
r = ucl_nrv2e_test_overlap_le16(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2e_test_overlap_le16(buf,src_off,src_len,dst_len,nullptr);
break;
case M_NRV2E_LE32:
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,NULL);
r = ucl_nrv2e_test_overlap_le32(buf,src_off,src_len,dst_len,nullptr);
break;
default:
throwInternalError("unknown decompression method");
@@ -290,10 +262,8 @@ int upx_ucl_init(void)
{
if (ucl_init() != UCL_E_OK)
return -1;
#if defined(UPX_OFFICIAL_BUILD)
if (UCL_VERSION != ucl_version())
if (UCL_VERSION != ucl_version() || strcmp(UCL_VERSION_STRING, ucl_version_string()) != 0)
return -2;
#endif
ucl_set_malloc_hooks(my_malloc, my_free);
return 0;
}
@@ -315,6 +285,60 @@ unsigned upx_ucl_crc32(const void *buf, unsigned len, unsigned crc)
}
#endif
#endif /* WITH_UCL */
/*************************************************************************
// Debug checks
**************************************************************************/
#if DEBUG && 1
#include "util/membuffer.h"
static bool check_ucl(const int method, const unsigned expected_c_len) {
const unsigned u_len = 16384;
const unsigned c_extra = 4096;
MemBuffer u_buf, c_buf, d_buf;
unsigned c_len, d_len;
upx_compress_result_t cresult;
int r;
const int level = 3; // don't waste time
u_buf.alloc(u_len);
memset(u_buf, 0, u_len);
c_buf.allocForCompression(u_len, c_extra);
d_buf.allocForDecompression(u_len);
c_len = c_buf.getSize() - c_extra;
r = upx_ucl_compress(u_buf, u_len, c_buf + c_extra, &c_len, nullptr, method, level, NULL_cconf, &cresult);
if (r != 0 || c_len != expected_c_len) return false;
d_len = d_buf.getSize();
r = upx_ucl_decompress(c_buf + c_extra, c_len, d_buf, &d_len, method, nullptr);
if (r != 0 || d_len != u_len) return false;
if (memcmp(u_buf, d_buf, u_len) != 0) return false;
d_len = u_len - 1;
r = upx_ucl_decompress(c_buf + c_extra, c_len, d_buf, &d_len, method, nullptr);
if (r == 0) return false;
// TODO: rewrite Packer::findOverlapOverhead() so that we can test it here
//unsigned x_len = d_len;
//r = upx_ucl_test_overlap(c_buf, u_buf, c_extra, c_len, &x_len, method, nullptr);
return true;
}
TEST_CASE("compress_ucl") {
CHECK(check_ucl(M_NRV2B_8, 34));
CHECK(check_ucl(M_NRV2B_LE16, 34));
CHECK(check_ucl(M_NRV2B_LE32, 34));
CHECK(check_ucl(M_NRV2D_8, 32));
CHECK(check_ucl(M_NRV2D_LE16, 32));
CHECK(check_ucl(M_NRV2D_LE32, 34));
CHECK(check_ucl(M_NRV2E_8, 32));
CHECK(check_ucl(M_NRV2E_LE16, 32));
CHECK(check_ucl(M_NRV2E_LE32, 34));
}
#endif // DEBUG
/* vim:set ts=4 sw=4 et: */
+62 -23
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -28,12 +28,14 @@
#include "conf.h"
#include "compress.h"
#include "mem.h"
#include "util/membuffer.h"
#include <zlib/zlib.h>
#include <zlib/deflate.h>
void zlib_compress_config_t::reset()
{
memset(this, 0, sizeof(*this));
mem_clear(this, sizeof(*this));
mem_level.reset();
window_bits.reset();
@@ -41,14 +43,6 @@ void zlib_compress_config_t::reset()
}
#if !(WITH_ZLIB)
extern int compress_zlib_dummy;
int compress_zlib_dummy = 0;
#else
#include <zlib.h>
static int convert_errno_from_zlib(int zr)
{
switch (zr)
@@ -73,11 +67,11 @@ int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
upx_compress_result_t *cresult )
{
assert(method == M_DEFLATE);
assert(level > 0); assert(cresult != NULL);
assert(level > 0); assert(cresult != nullptr);
UNUSED(cb_parm);
int r = UPX_E_ERROR;
int zr;
const zlib_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_zlib : NULL;
const zlib_compress_config_t *lcconf = cconf_parm ? &cconf_parm->conf_zlib : nullptr;
zlib_compress_result_t *res = &cresult->result_zlib;
if (level == 10)
@@ -97,18 +91,19 @@ int upx_zlib_compress ( const upx_bytep src, unsigned src_len,
res->dummy = 0;
z_stream s;
s.zalloc = (alloc_func) 0;
s.zfree = (free_func) 0;
s.zalloc = (alloc_func) nullptr;
s.zfree = (free_func) nullptr;
s.next_in = ACC_UNCONST_CAST(upx_bytep, src);
s.avail_in = src_len;
s.next_out = dst;
s.avail_out = *dst_len;
s.total_in = s.total_out = 0;
zr = deflateInit2(&s, level, Z_DEFLATED, 0 - (int)window_bits,
zr = (int)deflateInit2(&s, level, Z_DEFLATED, 0 - (int)window_bits,
mem_level, strategy);
if (zr != Z_OK)
goto error;
assert(s.state->level == level);
zr = deflate(&s, Z_FINISH);
if (zr != Z_STREAM_END)
goto error;
@@ -151,8 +146,8 @@ int upx_zlib_decompress ( const upx_bytep src, unsigned src_len,
int zr;
z_stream s;
s.zalloc = (alloc_func) 0;
s.zfree = (free_func) 0;
s.zalloc = (alloc_func) nullptr;
s.zfree = (free_func) nullptr;
s.next_in = ACC_UNCONST_CAST(upx_bytep, src);
s.avail_in = src_len;
s.next_out = dst;
@@ -212,7 +207,7 @@ int upx_zlib_test_overlap ( const upx_bytep buf,
// NOTE: there is a very tiny possibility that decompression has
// succeeded but the data is not restored correctly because of
// in-place buffer overlapping, so we use an extra memcmp().
if (tbuf != NULL && memcmp(tbuf, b, *dst_len) != 0)
if (tbuf != nullptr && memcmp(tbuf, b, *dst_len) != 0)
return UPX_E_ERROR;
return UPX_E_OK;
}
@@ -224,10 +219,8 @@ int upx_zlib_test_overlap ( const upx_bytep buf,
int upx_zlib_init(void)
{
#if defined(UPX_OFFICIAL_BUILD)
if (strcmp(ZLIB_VERSION, zlibVersion()) != 0)
return -2;
#endif
return 0;
}
@@ -250,7 +243,53 @@ unsigned upx_zlib_crc32(const void *buf, unsigned len, unsigned crc)
}
#endif
/*************************************************************************
// Debug checks
**************************************************************************/
#if DEBUG && 1
#include "util/membuffer.h"
static bool check_zlib(const int method, const int level, const unsigned expected_c_len) {
const unsigned u_len = 16384;
const unsigned c_extra = 4096;
MemBuffer u_buf, c_buf, d_buf;
unsigned c_len, d_len;
upx_compress_result_t cresult;
int r;
u_buf.alloc(u_len);
memset(u_buf, 0, u_len);
c_buf.allocForCompression(u_len, c_extra);
d_buf.allocForDecompression(u_len);
c_len = c_buf.getSize() - c_extra;
r = upx_zlib_compress(u_buf, u_len, c_buf + c_extra, &c_len, nullptr, method, level, NULL_cconf, &cresult);
if (r != 0 || c_len != expected_c_len) return false;
d_len = d_buf.getSize();
r = upx_zlib_decompress(c_buf + c_extra, c_len, d_buf, &d_len, method, nullptr);
if (r != 0 || d_len != u_len) return false;
if (memcmp(u_buf, d_buf, u_len) != 0) return false;
d_len = u_len - 1;
r = upx_zlib_decompress(c_buf + c_extra, c_len, d_buf, &d_len, method, nullptr);
if (r == 0) return false;
// TODO: rewrite Packer::findOverlapOverhead() so that we can test it here
//unsigned x_len = d_len;
//r = upx_zlib_test_overlap(c_buf, u_buf, c_extra, c_len, &x_len, method, nullptr);
return true;
}
TEST_CASE("compress_zlib") {
CHECK(check_zlib(M_DEFLATE, 1, 89));
CHECK(check_zlib(M_DEFLATE, 3, 89));
CHECK(check_zlib(M_DEFLATE, 5, 33));
}
#endif // DEBUG
#endif /* WITH_ZLIB */
/* vim:set ts=4 sw=4 et: */
+208 -109
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -25,15 +25,29 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#pragma once
#ifndef UPX_CONF_H__
#define UPX_CONF_H__ 1
#ifndef __UPX_CONF_H
#define __UPX_CONF_H 1
#if defined(__cplusplus)
# if (__cplusplus >= 201402L)
# elif defined(_MSC_VER) && defined(_MSVC_LANG) && (_MSVC_LANG+0 >= 201402L)
# else
# error "C++ 14 is required"
# endif
#endif
#include "version.h"
#if !defined(_FILE_OFFSET_BITS)
# define _FILE_OFFSET_BITS 64
#endif
#if defined(_WIN32) && defined(__MINGW32__) && defined(__GNUC__)
# if !defined(_USE_MINGW_ANSI_STDIO)
# define _USE_MINGW_ANSI_STDIO 1
# endif
#endif
#undef NDEBUG
@@ -49,17 +63,41 @@
#include "miniacc.h"
#if !(ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_MSC)
// other compilers may work, but we're NOT interested into supporting them
# error "only clang and gcc are officially supported"
# error "only clang, gcc and msvc are officially supported"
#endif
// UPX sanity checks for a sane compiler
#if !defined(UINT_MAX) || (UINT_MAX != 0xffffffffL)
# error "UINT_MAX"
#endif
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_BIT == 8)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4)
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(long long) == 8)
// check sane compiler mandatory flags
ACC_COMPILE_TIME_ASSERT_HEADER(-1 == ~0) // two's complement - see http://wg21.link/P0907R4
ACC_COMPILE_TIME_ASSERT_HEADER(0u-1 == ~0u) // two's complement - see http://wg21.link/P0907R4
ACC_COMPILE_TIME_ASSERT_HEADER((1u << 31) << 1 == 0)
ACC_COMPILE_TIME_ASSERT_HEADER(((int)(1u << 31)) >> 31 == -1) // arithmetic right shift
ACC_COMPILE_TIME_ASSERT_HEADER((-1) >> 31 == -1) // arithmetic right shift
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_MAX == 255) // -funsigned-char
ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char
ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) == 255) // -funsigned-char
// enable/disable some warnings
#if (ACC_CC_CLANG >= 0x0b0000)
# pragma clang diagnostic error "-Wsuggest-override"
#elif (ACC_CC_GNUC >= 0x0a0000)
// don't enable before gcc-10 because of gcc bug #78010
# pragma GCC diagnostic error "-Wsuggest-override"
#endif
// Some non-GLIBC toolchains do not use 'nullptr' everywhere when C++:
// openwrt-sdk-x86-64_gcc-11.2.0_musl.Linux-x86_64/staging_dir/
// toolchain-x86_64_gcc-11.2.0_musl/include/fortify/stdlib.h:
// 51:32: error: zero as null pointer constant
#if (ACC_CC_CLANG >= 0x050000)
# pragma clang diagnostic error "-Wzero-as-null-pointer-constant"
#elif (ACC_CC_GNUC >= 0x040700) && defined(__GLIBC__)
# pragma GCC diagnostic error "-Wzero-as-null-pointer-constant"
#endif
#if (ACC_CC_MSC)
# pragma warning(error: 4127)
@@ -71,14 +109,9 @@ ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) > 0) // -funsigned-char
# pragma warning(disable: 4820) // padding added after data member
#endif
// FIXME - quick hack for arm-wince-gcc-3.4 (Debian pocketpc-*.deb packages)
#if 1 && (ACC_ARCH_ARM) && defined(__pe__) && !defined(__CEGCC__) && !defined(_WIN32)
# undef HAVE_CHMOD
# undef HAVE_CHOWN
# undef HAVE_LSTAT
# undef HAVE_UTIME
#endif
#undef snprintf
#undef vsnprintf
#define HAVE_STDINT_H 1
#define ACC_WANT_ACC_INCD_H 1
#define ACC_WANT_ACC_INCE_H 1
#define ACC_WANT_ACC_LIB_H 1
@@ -95,12 +128,6 @@ typedef acc_uint32_t upx_uint32_t;
typedef acc_int64_t upx_int64_t;
typedef acc_uint64_t upx_uint64_t;
typedef acc_uintptr_t upx_uintptr_t;
#define UPX_INT16_C ACC_INT16_C
#define UPX_UINT16_C ACC_UINT16_C
#define UPX_INT32_C ACC_INT32_C
#define UPX_UINT32_C ACC_UINT32_C
#define UPX_INT64_C ACC_INT64_C
#define UPX_UINT64_C ACC_UINT64_C
typedef unsigned char upx_byte;
#define upx_bytep upx_byte *
@@ -134,11 +161,8 @@ typedef unsigned char upx_byte;
#define WITH_ZLIB 1
#if (WITH_UCL)
# define ucl_compress_config_t REAL_ucl_compress_config_t
# include <ucl/uclconf.h>
# include <ucl/ucl.h>
# if !defined(UCL_VERSION) || (UCL_VERSION < 0x010300L)
# error "please upgrade your UCL installation"
# endif
# include <ucl/include/ucl/uclconf.h>
# include <ucl/include/ucl/ucl.h>
# undef ucl_compress_config_t
# undef ucl_compress_config_p
#endif
@@ -165,9 +189,19 @@ typedef unsigned char upx_byte;
// see C 11 standard, Annex K
typedef size_t upx_rsize_t;
#define UPX_RSIZE_MAX UPX_RSIZE_MAX_MEM
#define UPX_RSIZE_MAX_MEM (768 * 1024 * 1024) // DO NOT CHANGE
#define UPX_RSIZE_MAX_MEM (768 * 1024 * 1024) // DO NOT CHANGE !!!
#define UPX_RSIZE_MAX_STR (1024 * 1024)
// using the system off_t was a bad idea even back in 199x...
typedef upx_int64_t upx_off_t;
#undef off_t
#if 0
// at some future point we can do this...
#define off_t DO_NOT_USE_off_t
#else
#define off_t upx_off_t
#endif
/*************************************************************************
// portab
@@ -183,10 +217,10 @@ typedef size_t upx_rsize_t;
# define STDERR_FILENO (fileno(stderr))
#endif
#if !(HAVE_STRCASECMP) && (HAVE_STRICMP)
#if !(HAVE_STRCASECMP) && (HAVE_STRICMP) && !defined(strcasecmp)
# define strcasecmp stricmp
#endif
#if !(HAVE_STRNCASECMP) && (HAVE_STRNICMP)
#if !(HAVE_STRNCASECMP) && (HAVE_STRNICMP) && !defined(strncasecmp)
# define strncasecmp strnicmp
#endif
@@ -230,7 +264,9 @@ typedef size_t upx_rsize_t;
#endif
// avoid warnings about shadowing global functions
#undef basename
#undef index
#undef outp
#define basename upx_basename
#define index upx_index
#define outp upx_outp
@@ -256,32 +292,53 @@ typedef size_t upx_rsize_t;
//
**************************************************************************/
#if (ACC_CC_MSC)
#define __packed_struct(s) struct s {
#define __packed_struct_end() };
#define CLANG_FORMAT_DUMMY_STATEMENT /*empty*/
#if defined(_WIN32) && defined(__MINGW32__) && defined(__GNUC__) && !defined(__clang__)
# define attribute_format(a,b) __attribute__((__format__(__gnu_printf__,a,b)));
#elif (ACC_CC_CLANG || ACC_CC_GNUC)
# define attribute_format(a,b) __attribute__((__format__(__printf__,a,b)));
#else
#define __packed_struct(s) __acc_struct_packed(s)
#define __packed_struct_end() __acc_struct_packed_end()
# define attribute_format(a,b) /*empty*/
#endif
inline void NO_printf(const char *, ...) attribute_format(1, 2);
inline void NO_fprintf(FILE *, const char *, ...) attribute_format(2, 3);
inline void NO_printf(const char *, ...) {}
inline void NO_fprintf(FILE *, const char *, ...) {}
#if !defined(__has_builtin)
# define __has_builtin(x) 0
#endif
#if __has_builtin(__builtin_memcpy_inline)
# define upx_memcpy_inline __builtin_memcpy_inline
#elif __has_builtin(__builtin_memcpy)
# define upx_memcpy_inline __builtin_memcpy
#elif defined(__GNUC__)
# define upx_memcpy_inline __builtin_memcpy
#else
# define upx_memcpy_inline memcpy
#endif
#define UNUSED(var) ACC_UNUSED(var)
#define COMPILE_TIME_ASSERT(e) ACC_COMPILE_TIME_ASSERT(e)
#define __COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) { \
// TODO cleanup: we now require C++14, so remove all __packed_struct usage
#define __packed_struct(s) struct alignas(1) s {
#define __packed_struct_end() };
#define COMPILE_TIME_ASSERT_ALIGNOF_USING_SIZEOF__(a,b) { \
typedef a acc_tmp_a_t; typedef b acc_tmp_b_t; \
__packed_struct(acc_tmp_t) acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z; __packed_struct_end() \
struct alignas(1) acc_tmp_t { acc_tmp_b_t x; acc_tmp_a_t y; acc_tmp_b_t z; }; \
COMPILE_TIME_ASSERT(sizeof(struct acc_tmp_t) == 2*sizeof(b)+sizeof(a)) \
COMPILE_TIME_ASSERT(sizeof(((acc_tmp_t*)0)->x)+sizeof(((acc_tmp_t*)0)->y)+sizeof(((acc_tmp_t*)0)->z) == 2*sizeof(b)+sizeof(a)) \
COMPILE_TIME_ASSERT(sizeof(((acc_tmp_t*)nullptr)->x)+sizeof(((acc_tmp_t*)nullptr)->y)+sizeof(((acc_tmp_t*)nullptr)->z) == 2*sizeof(b)+sizeof(a)) \
}
#if defined(__acc_alignof)
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b) \
COMPILE_TIME_ASSERT(__acc_alignof(a) == sizeof(b))
#else
# define __COMPILE_TIME_ASSERT_ALIGNOF(a,b) \
__COMPILE_TIME_ASSERT_ALIGNOF_SIZEOF(a,b)
#endif
#define COMPILE_TIME_ASSERT_ALIGNED1(a) __COMPILE_TIME_ASSERT_ALIGNOF(a,char)
#define COMPILE_TIME_ASSERT_ALIGNOF__(a,b) \
COMPILE_TIME_ASSERT_ALIGNOF_USING_SIZEOF__(a,b) \
COMPILE_TIME_ASSERT(__acc_alignof(a) == sizeof(b)) \
COMPILE_TIME_ASSERT(alignof(a) == sizeof(b))
#define COMPILE_TIME_ASSERT_ALIGNED1(a) COMPILE_TIME_ASSERT_ALIGNOF__(a,char)
#define TABLESIZE(table) ((sizeof(table)/sizeof((table)[0])))
@@ -299,7 +356,7 @@ template <class T>
inline const T& UPX_MIN(const T& a, const T& b) { if (a < b) return a; return b; }
// An Array allocates memory on the heap, but automatically
// An Array allocates memory on the heap, and automatically
// gets destructed when leaving scope or on exceptions.
#define Array(type, var, size) \
MemBuffer var ## _membuf(mem_size(sizeof(type), size)); \
@@ -307,6 +364,7 @@ inline const T& UPX_MIN(const T& a, const T& b) { if (a < b) return a; return b;
#define ByteArray(var, size) Array(unsigned char, var, size)
class noncopyable
{
protected:
@@ -318,6 +376,27 @@ private:
};
namespace compile_time {
constexpr bool string_eq(const char *a, const char *b) {
return *a == *b && (*a == '\0' || string_eq(a + 1, b + 1));
}
constexpr bool string_lt(const char *a, const char *b) {
return (unsigned char)*a < (unsigned char)*b || (*a != '\0' && *a == *b && string_lt(a + 1, b + 1));
}
constexpr bool string_ne(const char *a, const char *b) {
return !string_eq(a, b);
}
constexpr bool string_gt(const char *a, const char *b) {
return string_lt(b, a);
}
constexpr bool string_le(const char *a, const char *b) {
return !string_lt(b, a);
}
constexpr bool string_ge(const char *a, const char *b) {
return !string_lt(a, b);
}
}
/*************************************************************************
// constants
**************************************************************************/
@@ -398,10 +477,10 @@ private:
#define UPX_F_MACH_ARM64EL 37
#define UPX_F_MACH_PPC64LE 38
//#define UPX_F_MACH_PPC64LE 38 // DOES NOT EXIST
#define UPX_F_LINUX_ELFPPC64LE 39
#define UPX_F_VMLINUX_PPC64LE 40
#define UPX_F_DYLIB_PPC64LE 41
//#define UPX_F_DYLIB_PPC64LE 41 // DOES NOT EXIST
#define UPX_F_LINUX_ELF64_ARM 42
@@ -416,13 +495,11 @@ private:
#define UPX_F_LINUX_ELF32_MIPSEB 137
#define UPX_F_DYLIB_PPC32 138
#define UPX_F_MACH_PPC64 139
#define UPX_F_LINUX_ELFPPC64 140
#define UPX_F_VMLINUX_PPC64 141
#define UPX_F_DYLIB_PPC64 142
// compression methods
#define M_ALL (-1)
#define M_END (-2)
#define M_NONE (-3)
#define M_SKIP (-4)
#define M_ULTRA_BRUTE (-5)
// compression methods - DO NOT CHANGE
#define M_NRV2B_LE32 2
#define M_NRV2B_8 3
@@ -438,6 +515,12 @@ private:
//#define M_CL1B_LE16 13
#define M_LZMA 14
#define M_DEFLATE 15 /* zlib */
// compression methods internal usage
#define M_ALL (-1)
#define M_END (-2)
#define M_NONE (-3)
#define M_SKIP (-4)
#define M_ULTRA_BRUTE (-5)
#define M_IS_NRV2B(x) ((x) >= M_NRV2B_LE32 && (x) <= M_NRV2B_LE16)
#define M_IS_NRV2D(x) ((x) >= M_NRV2D_LE32 && (x) <= M_NRV2D_LE16)
@@ -476,24 +559,27 @@ struct upx_callback_t
// compression - config_t
**************************************************************************/
template <class T, T default_value, T min_value, T max_value>
template <class T, T default_value_, T min_value_, T max_value_>
struct OptVar
{
typedef T value_type;
static const T default_value_c = default_value;
static const T min_value_c = min_value;
static const T max_value_c = max_value;
static const T default_value = default_value_;
static const T min_value = min_value_;
static const T max_value = max_value_;
void assertValue() const {
static void assertValue(const T &v) {
// info: this generates annoying warnings "unsigned >= 0 is always true"
//assert(v >= min_value_c);
assert(v == min_value_c || v >= min_value_c + 1);
assert(v <= max_value_c);
//assert(v >= min_value);
assert(v == min_value || v >= min_value + 1);
assert(v <= max_value);
}
void assertValue() const {
assertValue(v);
}
OptVar() : v(default_value), is_set(0) { }
OptVar& operator= (const T other) {
v = other; is_set += 1;
OptVar& operator= (const T &other) {
v = other; is_set = 1;
assertValue();
return *this;
}
@@ -509,10 +595,10 @@ struct OptVar
// optional assignments
template <class T, T a, T b, T c>
inline void oassign(OptVar<T,a,b,c> &self, const OptVar<T,a,b,c> &other) {
if (other.is_set) { self.v = other.v; self.is_set += 1; }
if (other.is_set) { self.v = other.v; self.is_set = 1; }
}
template <class T, T a, T b, T c>
inline void oassign(unsigned &v, const OptVar<T,a,b,c> &other) {
inline void oassign(T &v, const OptVar<T,a,b,c> &other) {
if (other.is_set) { v = other.v; }
}
@@ -567,7 +653,7 @@ struct upx_compress_config_t
void reset() { conf_lzma.reset(); conf_ucl.reset(); conf_zlib.reset(); }
};
#define NULL_cconf ((upx_compress_config_t *) NULL)
#define NULL_cconf ((upx_compress_config_t *) nullptr)
/*************************************************************************
@@ -626,74 +712,70 @@ struct upx_compress_result_t
// globals
**************************************************************************/
#include "snprintf.h" // must get included first!
#include "stdcxx.h"
#include "util/snprintf.h" // must get included first!
#include <exception>
#include <new>
#include <type_traits>
#include <typeinfo>
#include "options.h"
#include "except.h"
#include "bele.h"
#include "util.h"
#include "console.h"
#include "util/util.h"
// classes
class ElfLinker;
typedef ElfLinker Linker;
// util/membuffer.h
class MemBuffer;
void *membuffer_get_void_ptr(MemBuffer &mb);
unsigned membuffer_get_size(MemBuffer &mb);
#include "util/xspan.h"
//#define DOCTEST_CONFIG_DISABLE 1
#include <doctest/doctest/parts/doctest_fwd.h>
// util/dt_check.cpp
void upx_compiler_sanity_check();
int upx_doctest_check();
int upx_doctest_check(int argc, char **argv);
// main.cpp
extern const char *progname;
bool set_exit_code(int ec);
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
void e_exit(int ec) __attribute__((__noreturn__));
#else
void e_exit(int ec);
#endif
bool main_set_exit_code(int ec);
int main_get_options(int argc, char **argv);
void main_get_envoptions();
int upx_main(int argc, char *argv[]);
// msg.cpp
void printSetNl(int need_nl);
void printClearLine(FILE *f = NULL);
void printClearLine(FILE *f = nullptr);
void printErr(const char *iname, const Throwable *e);
void printUnhandledException(const char *iname, const std::exception *e);
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
__attribute__((__format__(__printf__,2,3)));
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
__attribute__((__format__(__printf__,2,3)));
#else
void __acc_cdecl_va printErr(const char *iname, const char *format, ...);
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
#endif
void printErr(const char *iname, const char *format, ...) attribute_format(2, 3);
void printWarn(const char *iname, const char *format, ...) attribute_format(2, 3);
#if (ACC_CC_CLANG || ACC_CC_GNUC || ACC_CC_LLVM || ACC_CC_PATHSCALE)
void __acc_cdecl_va infoWarning(const char *format, ...)
__attribute__((__format__(__printf__,1,2)));
void __acc_cdecl_va infoHeader(const char *format, ...)
__attribute__((__format__(__printf__,1,2)));
void __acc_cdecl_va info(const char *format, ...)
__attribute__((__format__(__printf__,1,2)));
#else
void __acc_cdecl_va infoWarning(const char *format, ...);
void __acc_cdecl_va infoHeader(const char *format, ...);
void __acc_cdecl_va info(const char *format, ...);
#endif
void infoWarning(const char *format, ...) attribute_format(1, 2);
void infoHeader(const char *format, ...) attribute_format(1, 2);
void info(const char *format, ...) attribute_format(1, 2);
void infoHeader();
void infoWriting(const char *what, long size);
// work.cpp
void do_one_file(const char *iname, char *oname);
void do_files(int i, int argc, char *argv[]);
int do_files(int i, int argc, char *argv[]);
// help.cpp
extern const char gitrev[];
void show_head(void);
void show_head();
void show_help(int verbose=0);
void show_license(void);
void show_usage(void);
void show_version(int);
void show_license();
void show_usage();
void show_version(bool one_line=false);
// compress.cpp
unsigned upx_adler32(const void *buf, unsigned len, unsigned adler=1);
@@ -716,6 +798,24 @@ int upx_test_overlap ( const upx_bytep buf,
int method,
const upx_compress_result_t *cresult );
/*************************************************************************
// raw_bytes() - get underlying memory from checked buffers/pointers.
// This is overloaded by various utility classes like BoundedPtr,
// MemBuffer and Span.
//
// Note that the pointer type is retained, the "_bytes" hints size_in_bytes
**************************************************************************/
// default: for any regular pointer, raw_bytes() is just the pointer itself
template <class T>
inline T *raw_bytes(T *ptr, size_t size_in_bytes) {
if (size_in_bytes > 0) {
if __acc_very_unlikely (ptr == nullptr)
throwInternalError("raw_bytes unexpected NULL ptr");
}
return ptr;
}
#if (ACC_OS_CYGWIN || ACC_OS_DOS16 || ACC_OS_DOS32 || ACC_OS_EMX || ACC_OS_OS2 || ACC_OS_OS216 || ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
# if defined(INVALID_HANDLE_VALUE) || defined(MAKEWORD) || defined(RT_CURSOR)
@@ -723,7 +823,6 @@ int upx_test_overlap ( const upx_bytep buf,
# endif
#endif
#endif /* already included */
/* vim:set ts=4 sw=4 et: */
+3 -8
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -122,12 +122,7 @@ typedef struct
console_t;
#if defined(__GNUC__)
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
__attribute__((__format__(printf,2,3)));
#else
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
#endif
void con_fprintf(FILE *f, const char *format, ...) attribute_format(2, 3);
#define FG_BLACK 0x00
+34 -80
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -25,19 +25,18 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#include "conf.h"
/*************************************************************************
//
**************************************************************************/
unsigned long Throwable::counter = 0;
Throwable::Throwable(const char *m, int e, bool w) NOTHROW
: super(), msg(NULL), err(e), is_warning(w)
{
Throwable::Throwable(const char *m, int e, bool w) noexcept : super(),
msg(nullptr),
err(e),
is_warning(w) {
if (m)
msg = strdup(m);
#if 0
@@ -46,10 +45,10 @@ Throwable::Throwable(const char *m, int e, bool w) NOTHROW
#endif
}
Throwable::Throwable(const Throwable &other) NOTHROW
: super(other), msg(NULL), err(other.err), is_warning(other.is_warning)
{
Throwable::Throwable(const Throwable &other) noexcept : super(other),
msg(nullptr),
err(other.err),
is_warning(other.is_warning) {
if (other.msg)
msg = strdup(other.msg);
#if 0
@@ -58,9 +57,7 @@ Throwable::Throwable(const Throwable &other) NOTHROW
#endif
}
Throwable::~Throwable() NOTHROW
{
Throwable::~Throwable() noexcept {
#if 0
counter--;
fprintf(stderr, "destruct exception: %s %lu\n", msg, counter);
@@ -69,13 +66,11 @@ Throwable::~Throwable() NOTHROW
free(msg);
}
/*************************************************************************
// compression
**************************************************************************/
void throwCantPack(const char *msg)
{
void throwCantPack(const char *msg) {
// UGLY, but makes things easier
if (opt->cmd == CMD_COMPRESS)
throw CantPackException(msg);
@@ -85,114 +80,73 @@ void throwCantPack(const char *msg)
throw CantUnpackException(msg);
}
void throwCantPackExact()
{
throwCantPack("option '--exact' does not work with this file");
}
void throwCantPackExact() { throwCantPack("option '--exact' does not work with this file"); }
void throwFilterException()
{
throwCantPack("filter problem");
}
void throwFilterException() { throwCantPack("filter problem"); }
void throwUnknownExecutableFormat(const char *msg, bool warn)
{
void throwUnknownExecutableFormat(const char *msg, bool warn) {
throw UnknownExecutableFormatException(msg, warn);
}
void throwNotCompressible(const char *msg)
{
throw NotCompressibleException(msg);
}
void throwNotCompressible(const char *msg) { throw NotCompressibleException(msg); }
void throwAlreadyPacked(const char *msg)
{
throw AlreadyPackedException(msg);
}
void throwAlreadyPacked(const char *msg) { throw AlreadyPackedException(msg); }
void throwAlreadyPackedByUPX(const char *msg)
{
if (msg == NULL)
void throwAlreadyPackedByUPX(const char *msg) {
if (msg == nullptr)
msg = "already packed by UPX";
throwAlreadyPacked(msg);
}
/*************************************************************************
// decompression
**************************************************************************/
void throwCantUnpack(const char *msg)
{
void throwCantUnpack(const char *msg) {
// UGLY, but makes things easier
throwCantPack(msg);
}
void throwNotPacked(const char *msg)
{
if (msg == NULL)
void throwNotPacked(const char *msg) {
if (msg == nullptr)
msg = "not packed by UPX";
throw NotPackedException(msg);
}
void throwChecksumError()
{
throw Exception("checksum error");
}
void throwCompressedDataViolation()
{
throw Exception("compressed data violation");
}
void throwChecksumError() { throw Exception("checksum error"); }
void throwCompressedDataViolation() { throw Exception("compressed data violation"); }
/*************************************************************************
// other
**************************************************************************/
void throwInternalError(const char *msg)
{
throw InternalError(msg);
}
void throwInternalError(const char *msg) { throw InternalError(msg); }
void throwBadLoader()
{
throwInternalError("bad loader");
}
void throwBadLoader() { throwInternalError("bad loader"); }
void throwOutOfMemoryException(const char *msg)
{
if (msg == NULL)
void throwOutOfMemoryException(const char *msg) {
if (msg == nullptr)
msg = "out of memory";
throw OutOfMemoryException(msg);
}
void throwIOException(const char *msg, int e) { throw IOException(msg, e); }
void throwIOException(const char *msg, int e)
{
throw IOException(msg, e);
}
void throwEOFException(const char *msg, int e)
{
if (msg == NULL && e == 0)
void throwEOFException(const char *msg, int e) {
if (msg == nullptr && e == 0)
msg = "premature end of file";
throw EOFException(msg, e);
}
/*************************************************************************
//
**************************************************************************/
const char *prettyName(const char *n) NOTHROW
{
if (n == NULL)
const char *prettyName(const char *n) noexcept {
if (n == nullptr)
return "(null)";
while (*n)
{
while (*n) {
if (*n >= '0' && *n <= '9') // Linux ABI
n++;
else if (*n == ' ')
+93 -102
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -25,175 +25,167 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_EXCEPT_H
#define __UPX_EXCEPT_H 1
#pragma once
#ifndef UPX_EXCEPT_H__
#define UPX_EXCEPT_H__ 1
#ifdef __cplusplus
const char *prettyName(const char *n) NOTHROW;
const char *prettyName(const char *n) noexcept;
/*************************************************************************
// exceptions
**************************************************************************/
class Throwable : public std::exception
{
class Throwable : public std::exception {
typedef std::exception super;
protected:
Throwable(const char *m = 0, int e = 0, bool w = false) NOTHROW;
Throwable(const char *m = nullptr, int e = 0, bool w = false) noexcept;
public:
Throwable(const Throwable &) NOTHROW;
virtual ~Throwable() NOTHROW;
const char *getMsg() const NOTHROW { return msg; }
int getErrno() const NOTHROW { return err; }
bool isWarning() const NOTHROW { return is_warning; }
Throwable(const Throwable &) noexcept;
virtual ~Throwable() noexcept;
const char *getMsg() const noexcept { return msg; }
int getErrno() const noexcept { return err; }
bool isWarning() const noexcept { return is_warning; }
private:
char *msg;
int err;
char *msg = nullptr;
int err = 0;
protected:
bool is_warning; // can be set by subclasses
bool is_warning = false; // can be set by subclasses
private:
// disable assignment
Throwable& operator= (const Throwable &);
// disable dynamic allocation
DISABLE_NEW_DELETE
Throwable &operator=(const Throwable &) = delete;
// disable dynamic allocation => force throwing by value
ACC_CXX_DISABLE_NEW_DELETE
private:
static unsigned long counter; // for debugging
};
// Exceptions can/should be caught
class Exception : public Throwable
{
class Exception : public Throwable {
typedef Throwable super;
public:
Exception(const char *m = 0, int e = 0, bool w = false) NOTHROW : super(m,e,w) { }
};
public:
Exception(const char *m = nullptr, int e = 0, bool w = false) noexcept : super(m, e, w) {}
};
// Errors should not be caught (or re-thrown)
class Error : public Throwable
{
class Error : public Throwable {
typedef Throwable super;
public:
Error(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
};
public:
Error(const char *m = nullptr, int e = 0) noexcept : super(m, e) {}
};
/*************************************************************************
// system exception
**************************************************************************/
class OutOfMemoryException : public Exception
{
class OutOfMemoryException : public Exception {
typedef Exception super;
public:
OutOfMemoryException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
OutOfMemoryException(const char *m = nullptr, int e = 0) noexcept : super(m, e) {}
};
class IOException : public Exception
{
class IOException : public Exception {
typedef Exception super;
public:
IOException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
IOException(const char *m = nullptr, int e = 0) noexcept : super(m, e) {}
};
class EOFException : public IOException
{
class EOFException : public IOException {
typedef IOException super;
public:
EOFException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
EOFException(const char *m = nullptr, int e = 0) noexcept : super(m, e) {}
};
class FileNotFoundException : public IOException
{
class FileNotFoundException : public IOException {
typedef IOException super;
public:
FileNotFoundException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
FileNotFoundException(const char *m = nullptr, int e = 0) noexcept : super(m, e) {}
};
class FileAlreadyExistsException : public IOException
{
class FileAlreadyExistsException : public IOException {
typedef IOException super;
public:
FileAlreadyExistsException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { }
};
public:
FileAlreadyExistsException(const char *m = nullptr, int e = 0) noexcept : super(m, e) {}
};
/*************************************************************************
// application execptions
// application exceptions
**************************************************************************/
class OverlayException : public Exception
{
class OverlayException : public Exception {
typedef Exception super;
public:
OverlayException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { }
OverlayException(const char *m = nullptr, bool w = false) noexcept : super(m, 0, w) {}
};
class CantPackException : public Exception
{
class CantPackException : public Exception {
typedef Exception super;
public:
CantPackException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { }
CantPackException(const char *m = nullptr, bool w = false) noexcept : super(m, 0, w) {}
};
class UnknownExecutableFormatException : public CantPackException
{
class UnknownExecutableFormatException : public CantPackException {
typedef CantPackException super;
public:
UnknownExecutableFormatException(const char *m = 0, bool w = false) NOTHROW : super(m,w) { }
UnknownExecutableFormatException(const char *m = nullptr, bool w = false) noexcept
: super(m, w) {}
};
class AlreadyPackedException : public CantPackException
{
class AlreadyPackedException : public CantPackException {
typedef CantPackException super;
public:
AlreadyPackedException(const char *m = 0) NOTHROW : super(m) { is_warning = true; }
AlreadyPackedException(const char *m = nullptr) noexcept : super(m) { is_warning = true; }
};
class NotCompressibleException : public CantPackException
{
class NotCompressibleException : public CantPackException {
typedef CantPackException super;
public:
NotCompressibleException(const char *m = 0) NOTHROW : super(m) { }
NotCompressibleException(const char *m = nullptr) noexcept : super(m) {}
};
class CantUnpackException : public Exception
{
class CantUnpackException : public Exception {
typedef Exception super;
public:
CantUnpackException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { }
CantUnpackException(const char *m = nullptr, bool w = false) noexcept : super(m, 0, w) {}
};
class NotPackedException : public CantUnpackException
{
class NotPackedException : public CantUnpackException {
typedef CantUnpackException super;
public:
NotPackedException(const char *m = 0) NOTHROW : super(m,true) { }
};
public:
NotPackedException(const char *m = nullptr) noexcept : super(m, true) {}
};
/*************************************************************************
// errors
**************************************************************************/
class InternalError : public Error
{
class InternalError : public Error {
typedef Error super;
public:
InternalError(const char *m = 0) NOTHROW : super(m,0) { }
};
public:
InternalError(const char *m = nullptr) noexcept : super(m, 0) {}
};
/*************************************************************************
// util
@@ -201,31 +193,30 @@ public:
#undef NORET
#if 1 && defined(__GNUC__)
#define NORET __attribute__((__noreturn__))
#define NORET __acc_noinline __attribute__((__noreturn__))
#else
#define NORET /*empty*/
#define NORET __acc_noinline
#endif
void throwCantPack(const char *msg) NORET;
void throwCantPackExact() NORET;
void throwUnknownExecutableFormat(const char *msg = NULL, bool warn = false) NORET;
void throwNotCompressible(const char *msg = NULL) NORET;
void throwAlreadyPacked(const char *msg = NULL) NORET;
void throwAlreadyPackedByUPX(const char *msg = NULL) NORET;
void throwCantUnpack(const char *msg) NORET;
void throwNotPacked(const char *msg = NULL) NORET;
void throwFilterException() NORET;
void throwBadLoader() NORET;
void throwChecksumError() NORET;
void throwCompressedDataViolation() NORET;
void throwInternalError(const char *msg) NORET;
void throwOutOfMemoryException(const char *msg = NULL) NORET;
void throwIOException(const char *msg = NULL, int e = 0) NORET;
void throwEOFException(const char *msg = NULL, int e = 0) NORET;
NORET void throwCantPack(const char *msg);
NORET void throwCantPackExact();
NORET void throwUnknownExecutableFormat(const char *msg = nullptr, bool warn = false);
NORET void throwNotCompressible(const char *msg = nullptr);
NORET void throwAlreadyPacked(const char *msg = nullptr);
NORET void throwAlreadyPackedByUPX(const char *msg = nullptr);
NORET void throwCantUnpack(const char *msg);
NORET void throwNotPacked(const char *msg = nullptr);
NORET void throwFilterException();
NORET void throwBadLoader();
NORET void throwChecksumError();
NORET void throwCompressedDataViolation();
NORET void throwInternalError(const char *msg);
NORET void throwOutOfMemoryException(const char *msg = nullptr);
NORET void throwIOException(const char *msg = nullptr, int e = 0);
NORET void throwEOFException(const char *msg = nullptr, int e = 0);
#undef NORET
#endif /* __cplusplus */
#endif /* already included */
+71 -224
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -25,29 +25,24 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#include "conf.h"
#include "file.h"
#include "mem.h"
/*************************************************************************
//
// static functions
**************************************************************************/
void File::chmod(const char *name, int mode)
{
void FileBase::chmod(const char *name, int mode) {
#if (HAVE_CHMOD)
if (::chmod(name, mode) != 0)
throwIOException(name, errno);
#else
UNUSED(name); UNUSED(mode);
UNUSED(name);
UNUSED(mode);
#endif
}
void File::rename(const char *old_, const char *new_)
{
void FileBase::rename(const char *old_, const char *new_) {
#if (ACC_OS_DOS32) && defined(__DJGPP__)
if (::_rename(old_, new_) != 0)
#else
@@ -56,27 +51,21 @@ void File::rename(const char *old_, const char *new_)
throwIOException("rename error", errno);
}
void File::unlink(const char *name)
{
void FileBase::unlink(const char *name) {
if (::unlink(name) != 0)
throwIOException(name, errno);
}
/*************************************************************************
//
**************************************************************************/
FileBase::FileBase() :
_fd(-1), _flags(0), _shflags(0), _mode(0), _name(NULL), _offset(0), _length(0)
{
FileBase::FileBase()
: _fd(-1), _flags(0), _shflags(0), _mode(0), _name(nullptr), _offset(0), _length(0) {
memset(&st, 0, sizeof(st));
}
FileBase::~FileBase()
{
FileBase::~FileBase() {
#if 0 && defined(__GNUC__) // debug
if (isOpen())
fprintf(stderr,"%s: %s\n", _name, __PRETTY_FUNCTION__);
@@ -87,13 +76,10 @@ FileBase::~FileBase()
closex();
}
bool FileBase::do_sopen()
{
bool FileBase::do_sopen() {
if (_shflags < 0)
_fd = ::open(_name, _flags, _mode);
else
{
else {
#if (ACC_OS_DOS32) && defined(__DJGPP__)
_fd = ::open(_name, _flags | _shflags, _mode);
#elif defined(__MINT__)
@@ -112,9 +98,7 @@ bool FileBase::do_sopen()
return true;
}
bool FileBase::close()
{
bool FileBase::close() {
bool ok = true;
if (isOpen() && _fd != STDIN_FILENO && _fd != STDOUT_FILENO && _fd != STDERR_FILENO)
if (::close(_fd) == -1)
@@ -122,58 +106,21 @@ bool FileBase::close()
_fd = -1;
_flags = 0;
_mode = 0;
_name = NULL;
_name = nullptr;
_offset = 0;
_length = 0;
return ok;
}
void FileBase::closex()
{
void FileBase::closex() {
if (!close())
throwIOException("close failed", errno);
}
int FileBase::read(void *buf, int len)
{
if (!isOpen() || len < 0)
throwIOException("bad read");
errno = 0;
long l = acc_safe_hread(_fd, buf, len);
if (errno)
throwIOException("read error",errno);
return (int) l;
}
int FileBase::readx(void *buf, int len)
{
int l = this->read(buf, len);
if (l != len)
throwEOFException();
return l;
}
void FileBase::write(const void *buf, int len)
{
if (!isOpen() || len < 0)
throwIOException("bad write");
errno = 0;
long l = acc_safe_hwrite(_fd, buf, len);
if (l != len)
throwIOException("write error",errno);
}
off_t FileBase::seek(upx_int64_t off64, int whence)
{
mem_size_assert(1, off64 >= 0 ? off64 : -off64); // sanity check
off_t off = ACC_ICONV(off_t, off64);
upx_off_t FileBase::seek(upx_off_t off, int whence) {
if (!isOpen())
throwIOException("bad seek 1");
mem_size_assert(1, off >= 0 ? off : -off); // sanity check
if (whence == SEEK_SET) {
if (off < 0)
throwIOException("bad seek 2");
@@ -190,46 +137,29 @@ off_t FileBase::seek(upx_int64_t off64, int whence)
return off - _offset;
}
off_t FileBase::tell() const
{
upx_off_t FileBase::tell() const {
if (!isOpen())
throwIOException("bad tell");
off_t l = ::lseek(_fd, 0, SEEK_CUR);
upx_off_t l = ::lseek(_fd, 0, SEEK_CUR);
if (l < 0)
throwIOException("tell error", errno);
return l - _offset;
}
void FileBase::set_extent(off_t offset, off_t length)
{
void FileBase::set_extent(upx_off_t offset, upx_off_t length) {
_offset = offset;
_length = length;
}
off_t FileBase::st_size() const
{
return _length;
}
upx_off_t FileBase::st_size() const { return _length; }
/*************************************************************************
//
**************************************************************************/
InputFile::InputFile()
{
}
InputFile::InputFile() {}
InputFile::~InputFile()
{
}
void InputFile::sopen(const char *name, int flags, int shflags)
{
void InputFile::sopen(const char *name, int flags, int shflags) {
close();
_name = name;
_flags = flags;
@@ -237,8 +167,7 @@ void InputFile::sopen(const char *name, int flags, int shflags)
_mode = 0;
_offset = 0;
_length = 0;
if (!FileBase::do_sopen())
{
if (!super::do_sopen()) {
if (errno == ENOENT)
throw FileNotFoundException(_name, errno);
else if (errno == EEXIST)
@@ -249,80 +178,40 @@ void InputFile::sopen(const char *name, int flags, int shflags)
_length_orig = _length;
}
int InputFile::read(void *buf, int len)
{
return super::read(buf, len);
int InputFile::read(SPAN_P(void) buf, int len) {
if (!isOpen() || len < 0)
throwIOException("bad read");
mem_size_assert(1, len); // sanity check
errno = 0;
long l = acc_safe_hread(_fd, raw_bytes(buf, len), len);
if (errno)
throwIOException("read error", errno);
return (int) l;
}
int InputFile::readx(void *buf, int len)
{
return super::readx(buf, len);
int InputFile::readx(SPAN_P(void) buf, int len) {
int l = this->read(buf, len);
if (l != len)
throwEOFException();
return l;
}
int InputFile::read(MemBuffer *buf, int len)
{
buf->checkState();
assert((unsigned)len <= buf->getSize());
return read(buf->getVoidPtr(), len);
}
int InputFile::readx(MemBuffer *buf, int len)
{
buf->checkState();
assert((unsigned)len <= buf->getSize());
return read(buf->getVoidPtr(), len);
}
int InputFile::read(MemBuffer &buf, int len)
{
return read(&buf, len);
}
int InputFile::readx(MemBuffer &buf, int len)
{
return readx(&buf, len);
}
off_t InputFile::seek(upx_int64_t off64, int whence)
{
off_t pos = super::seek(off64, whence);
upx_off_t InputFile::seek(upx_off_t off, int whence) {
upx_off_t pos = super::seek(off, whence);
if (_length < pos)
throwIOException("bad seek 4");
return pos;
}
off_t InputFile::tell() const
{
return super::tell();
}
off_t InputFile::st_size_orig() const
{
return _length_orig;
}
upx_off_t InputFile::st_size_orig() const { return _length_orig; }
/*************************************************************************
//
**************************************************************************/
OutputFile::OutputFile() :
bytes_written(0)
{
}
OutputFile::OutputFile() : bytes_written(0) {}
OutputFile::~OutputFile()
{
}
void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
{
void OutputFile::sopen(const char *name, int flags, int shflags, int mode) {
close();
_name = name;
_flags = flags;
@@ -330,8 +219,7 @@ void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
_mode = mode;
_offset = 0;
_length = 0;
if (!FileBase::do_sopen())
{
if (!super::do_sopen()) {
#if 0
// don't throw FileNotFound here -- this is confusing
if (errno == ENOENT)
@@ -345,9 +233,7 @@ void OutputFile::sopen(const char *name, int flags, int shflags, int mode)
}
}
bool OutputFile::openStdout(int flags, bool force)
{
bool OutputFile::openStdout(int flags, bool force) {
close();
int fd = STDOUT_FILENO;
if (!force && acc_isatty(fd))
@@ -364,15 +250,25 @@ bool OutputFile::openStdout(int flags, bool force)
return true;
}
void OutputFile::write(const void *buf, int len)
{
super::write(buf, len);
void OutputFile::write(SPAN_0(const void) buf, int len) {
if (!isOpen() || len < 0)
throwIOException("bad write");
// allow nullptr if len == 0
if (len == 0)
return;
mem_size_assert(1, len); // sanity check
errno = 0;
#if 0
fprintf(stderr, "write %p %zd (%p) %d\n", buf.raw_ptr(), buf.raw_size_in_bytes(),
buf.raw_base(), len);
#endif
long l = acc_safe_hwrite(_fd, raw_bytes(buf, len), len);
if (l != len)
throwIOException("write error", errno);
bytes_written += len;
}
off_t OutputFile::st_size() const
{
upx_off_t OutputFile::st_size() const {
if (opt->to_stdout) { // might be a pipe ==> .st_size is invalid
return bytes_written; // too big if seek()+write() instead of rewrite()
}
@@ -383,31 +279,14 @@ off_t OutputFile::st_size() const
return my_st.st_size;
}
void OutputFile::write(const MemBuffer *buf, int len)
{
buf->checkState();
assert((unsigned)len <= buf->getSize());
write(buf->getVoidPtr(), len);
}
void OutputFile::write(const MemBuffer &buf, int len)
{
write(&buf, len);
}
void OutputFile::rewrite(const void *buf, int len)
{
void OutputFile::rewrite(SPAN_P(const void) buf, int len) {
assert(!opt->to_stdout);
write(buf, len);
bytes_written -= len; // restore
}
off_t OutputFile::seek(upx_int64_t off64, int whence)
{
mem_size_assert(1, off64 >= 0 ? off64 : -off64); // sanity check
off_t off = ACC_ICONV(off_t, off64);
upx_off_t OutputFile::seek(upx_off_t off, int whence) {
mem_size_assert(1, off >= 0 ? off : -off); // sanity check
assert(!opt->to_stdout);
switch (whence) {
case SEEK_SET: {
@@ -434,20 +313,18 @@ off_t OutputFile::seek(upx_int64_t off64, int whence)
// return infile.read(buf, len);
//}
void OutputFile::set_extent(off_t offset, off_t length)
{
void OutputFile::set_extent(upx_off_t offset, upx_off_t length) {
super::set_extent(offset, length);
bytes_written = 0;
if (0==offset && (off_t)~0u==length) {
if (0 == offset && (upx_off_t) ~0u == length) {
if (::fstat(_fd, &st) != 0)
throwIOException(_name, errno);
_length = st.st_size - offset;
}
}
off_t OutputFile::unset_extent()
{
off_t l = ::lseek(_fd, 0, SEEK_END);
upx_off_t OutputFile::unset_extent() {
upx_off_t l = ::lseek(_fd, 0, SEEK_END);
if (l < 0)
throwIOException("lseek error", errno);
_offset = 0;
@@ -456,44 +333,14 @@ off_t OutputFile::unset_extent()
return _length;
}
void OutputFile::dump(const char *name, const void *buf, int len, int flags)
{
void OutputFile::dump(const char *name, SPAN_P(const void) buf, int len, int flags) {
if (flags < 0)
flags = O_CREAT | O_TRUNC;
flags |= O_WRONLY | O_BINARY;
OutputFile f;
f.open(name, flags, 0600);
f.write(buf, len);
f.write(raw_bytes(buf, len), len);
f.closex();
}
/*************************************************************************
//
**************************************************************************/
#if 0
MemoryOutputFile::MemoryOutputFile() :
b(NULL), b_size(0), b_pos(0), bytes_written(0)
{
}
void MemoryOutputFile::write(const void *buf, int len)
{
if (!isOpen() || len < 0)
throwIOException("bad write");
if (len == 0)
return;
if (b_pos + len > b_size)
throwIOException("write error",ENOSPC);
memcpy(b + b_pos, buf, len);
b_pos += len;
bytes_written += len;
}
#endif /* if 0 */
/* vim:set ts=4 sw=4 et: */
+58 -112
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -25,164 +25,110 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_FILE_H
#define __UPX_FILE_H 1
class MemBuffer;
#pragma once
#ifndef UPX_FILE_H__
#define UPX_FILE_H__ 1
/*************************************************************************
//
**************************************************************************/
class File
{
protected:
File() { }
virtual ~File() { }
public:
static void chmod(const char *name, int mode);
static void rename(const char *old_, const char *new_);
static void unlink(const char *name);
};
class FileBase : public File
{
class FileBase {
protected:
FileBase();
virtual ~FileBase();
public:
virtual bool close();
virtual void closex();
virtual bool isOpen() const { return _fd >= 0; }
bool close();
void closex();
bool isOpen() const { return _fd >= 0; }
int getFd() const { return _fd; }
const char *getName() const { return _name; }
virtual off_t st_size() const; // { return _length; }
virtual void set_extent(off_t offset, off_t length);
virtual upx_off_t seek(upx_off_t off, int whence);
upx_off_t tell() const;
virtual upx_off_t st_size() const; // { return _length; }
virtual void set_extent(upx_off_t offset, upx_off_t length);
public:
// static file-related util functions
static void chmod(const char *name, int mode);
static void rename(const char *old_, const char *new_);
static void unlink(const char *name);
protected:
bool do_sopen();
virtual int read(void *buf, int len);
virtual int readx(void *buf, int len);
virtual void write(const void *buf, int len);
virtual off_t seek(upx_int64_t off, int whence);
virtual off_t tell() const;
int _fd = -1;
int _flags = 0;
int _shflags = 0;
int _mode = 0;
const char *_name = nullptr;
upx_off_t _offset = 0;
upx_off_t _length = 0;
int _fd;
int _flags;
int _shflags;
int _mode;
const char *_name;
off_t _offset;
off_t _length;
public:
struct stat st;
struct stat st = {};
};
/*************************************************************************
//
**************************************************************************/
class InputFile : public FileBase
{
class InputFile final : public FileBase {
typedef FileBase super;
public:
InputFile();
virtual ~InputFile();
virtual ~InputFile() {}
virtual void sopen(const char *name, int flags, int shflags);
virtual void open(const char *name, int flags)
{
sopen(name, flags, -1);
}
void sopen(const char *name, int flags, int shflags);
void open(const char *name, int flags) { sopen(name, flags, -1); }
virtual int read(void *buf, int len);
virtual int readx(void *buf, int len);
virtual int read(MemBuffer *buf, int len);
virtual int readx(MemBuffer *buf, int len);
virtual int read(MemBuffer &buf, int len);
virtual int readx(MemBuffer &buf, int len);
int read(SPAN_P(void) buf, int len);
int readx(SPAN_P(void) buf, int len);
virtual upx_off_t seek(upx_off_t off, int whence) override;
upx_off_t st_size_orig() const;
virtual off_t seek(upx_int64_t off, int whence);
virtual off_t tell() const;
virtual off_t st_size_orig() const;
protected:
off_t _length_orig;
upx_off_t _length_orig = 0;
};
/*************************************************************************
//
**************************************************************************/
class OutputFile : public FileBase
{
class OutputFile final : public FileBase {
typedef FileBase super;
public:
OutputFile();
virtual ~OutputFile();
virtual ~OutputFile() {}
virtual void sopen(const char *name, int flags, int shflags, int mode);
virtual void open(const char *name, int flags, int mode)
{
sopen(name, flags, -1, mode);
}
virtual bool openStdout(int flags=0, bool force=false);
void sopen(const char *name, int flags, int shflags, int mode);
void open(const char *name, int flags, int mode) { sopen(name, flags, -1, mode); }
bool openStdout(int flags = 0, bool force = false);
virtual void write(const void *buf, int len);
virtual void write(const MemBuffer *buf, int len);
virtual void write(const MemBuffer &buf, int len);
virtual void set_extent(off_t offset, off_t length);
virtual off_t unset_extent(); // returns actual length
// info: allow nullptr if len == 0
void write(SPAN_0(const void) buf, int len);
off_t getBytesWritten() const { return bytes_written; }
virtual off_t st_size() const; // { return _length; }
virtual upx_off_t seek(upx_off_t off, int whence) override;
virtual upx_off_t st_size() const override; // { return _length; }
virtual void set_extent(upx_off_t offset, upx_off_t length) override;
upx_off_t unset_extent(); // returns actual length
upx_off_t getBytesWritten() const { return bytes_written; }
// FIXME - these won't work when using the '--stdout' option
virtual off_t seek(upx_int64_t off, int whence);
virtual void rewrite(const void *buf, int len);
void rewrite(SPAN_P(const void) buf, int len);
// util
static void dump(const char *name, const void *buf, int len, int flags=-1);
static void dump(const char *name, SPAN_P(const void) buf, int len, int flags = -1);
protected:
off_t bytes_written;
upx_off_t bytes_written = 0;
};
/*************************************************************************
//
**************************************************************************/
#if 0 /* NOT USED */
class MemoryOutputFile : public FileBase
{
typedef FileBase super;
public:
MemoryOutputFile();
virtual ~MemoryOutputFile() { b = NULL; }
virtual bool close() { b = NULL; return true; }
virtual bool isOpen() const { return b != NULL; }
virtual void open(void *buf, unsigned size)
{ b = (upx_bytep) buf; b_size = size; }
virtual void write(const void *buf, int len);
off_t getBytesWritten() const { return bytes_written; }
protected:
upx_bytep b;
unsigned b_size;
unsigned b_pos;
off_t bytes_written;
};
#endif /* if 0 */
#endif /* already included */
#endif
/* vim:set ts=4 sw=4 et: */
+11 -11
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -70,10 +70,10 @@ const FilterImp::FilterEntry *FilterImp::getFilter(int id)
}
if (id < 0 || id > 255)
return NULL;
return nullptr;
unsigned index = filter_map[id];
if (index == 0xff) // empty slot
return NULL;
return nullptr;
assert(filters[index].id == id);
return &filters[index];
}
@@ -82,7 +82,7 @@ const FilterImp::FilterEntry *FilterImp::getFilter(int id)
bool Filter::isValidFilter(int filter_id)
{
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(filter_id);
return fe != NULL;
return fe != nullptr;
}
bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
@@ -91,7 +91,7 @@ bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
return false;
if (filter_id == 0)
return true;
if (allowed_filters == NULL)
if (allowed_filters == nullptr)
return false;
while (*allowed_filters != FT_END)
if (*allowed_filters++ == filter_id)
@@ -107,10 +107,10 @@ bool Filter::isValidFilter(int filter_id, const int *allowed_filters)
void Filter::init(int id_, unsigned addvalue_)
{
this->id = id_;
initFilter(this, NULL, 0);
initFilter(this, nullptr, 0);
// clear input parameters
this->addvalue = addvalue_;
this->preferred_ctos = NULL;
this->preferred_ctos = nullptr;
// clear input/output parameters
this->cto = 0;
this->n_mru = 0;
@@ -122,7 +122,7 @@ bool Filter::filter(upx_byte *buf_, unsigned buf_len_)
initFilter(this, buf_, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id);
if (fe == NULL)
if (fe == nullptr)
throwInternalError("filter-1");
if (fe->id == 0)
return true;
@@ -155,7 +155,7 @@ void Filter::unfilter(upx_byte *buf_, unsigned buf_len_, bool verify_checksum)
initFilter(this, buf_, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id);
if (fe == NULL)
if (fe == nullptr)
throwInternalError("unfilter-1");
if (fe->id == 0)
return;
@@ -207,7 +207,7 @@ bool Filter::scan(const upx_byte *buf_, unsigned buf_len_)
initFilter(this, b, buf_len_);
const FilterImp::FilterEntry * const fe = FilterImp::getFilter(id);
if (fe == NULL)
if (fe == nullptr)
throwInternalError("scan-1");
if (fe->id == 0)
return true;
+5 -5
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -67,8 +67,8 @@ public:
public:
// Will be set by each call to filter()/unfilter().
// Read-only afterwards.
upx_byte *buf;
unsigned buf_len;
upx_byte *buf = nullptr;
unsigned buf_len = 0;
// Checksum of the buffer before applying the filter
// or after un-applying the filter.
@@ -76,7 +76,7 @@ public:
// Input parameters used by various filters.
unsigned addvalue;
const int *preferred_ctos;
const int *preferred_ctos = nullptr;
// Input/output parameters used by various filters
unsigned char cto; // call trick offset
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -129,6 +129,7 @@ static int F(Filter *f)
#if 0 || defined(TESTING)
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
#endif
UNUSED(noncalls2);
return 0;
}
+4 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 2000-2017 John F. Reiser
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
Copyright (C) 2000-2022 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -128,6 +128,7 @@ static int F(Filter *f)
#if 0 || defined(TESTING)
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
#endif
UNUSED(noncalls2);
return 0;
}
+4 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 2000-2017 John F. Reiser
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
Copyright (C) 2000-2022 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -254,6 +254,7 @@ static int F(Filter *f)
calls,noncalls,noncalls2,size,cto8);
printf("CALL/JMP/JCC %d %d %d\n",wtally[0],wtally[1],wtally[2]);
#endif
UNUSED(noncalls2);
return 0;
}
+4 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 2000-2017 John F. Reiser
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
Copyright (C) 2000-2022 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -129,6 +129,7 @@ static int F(Filter *f)
#if 0 || defined(TESTING)
printf("\ncalls=%d noncalls=%d noncalls2=%d text_size=%x calltrickoffset=%x\n",calls,noncalls,noncalls2,size,cto);
#endif
UNUSED(noncalls2);
return 0;
}
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,9 +2,9 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 2004-2017 John F. Reiser
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
Copyright (C) 2004-2022 John F. Reiser
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+2 -2
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
+3 -3
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -170,7 +170,7 @@ umin(unsigned const a, unsigned const b)
const FilterImp::FilterEntry FilterImp::filters[] = {
// no filter
{ 0x00, 0, 0, NULL, NULL, NULL },
{ 0x00, 0, 0, nullptr, nullptr, nullptr },
// 16-bit calltrick
{ 0x01, 4, 0, f_ct16_e8, u_ct16_e8, s_ct16_e8 },
+33 -40
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -53,7 +53,6 @@ void show_head(void)
return;
head_done = 1;
#define V(x) (strcmp(UPX_VERSION_STRING, UPX_VERSION_STRING4) ? UPX_VERSION_STRING : UPX_VERSION_STRING x)
fg = con_fg(f,FG_GREEN);
con_fprintf(f,
" Ultimate Packer for eXecutables\n"
@@ -67,10 +66,6 @@ void show_head(void)
#if defined(UPX_VERSION_GITREV)
gitrev,
(sizeof(gitrev)-1 > 6 && gitrev[sizeof(gitrev)-2] == '+') ? '+' : ' ',
#elif (ACC_OS_DOS16 || ACC_OS_DOS32)
V("d"),
#elif (ACC_OS_WIN16 || ACC_OS_WIN32 || ACC_OS_WIN64)
V("w"),
#else
UPX_VERSION_STRING,
#endif
@@ -112,7 +107,7 @@ struct PackerNames
Entry names[64];
size_t names_count;
const options_t *o;
PackerNames() : names_count(0), o(NULL) { }
PackerNames() : names_count(0), o(nullptr) { }
void add(const Packer *p)
{
p->assertPacker();
@@ -125,8 +120,8 @@ struct PackerNames
{
PackerNames *self = (PackerNames *) user;
self->add(p);
delete p; p = NULL;
return NULL;
delete p; p = nullptr;
return nullptr;
}
static int __acc_cdecl_qsort cmp_fname(const void *a, const void *b) {
return strcmp(((const Entry *) a)->fname, ((const Entry *) b)->fname);
@@ -140,7 +135,7 @@ static void show_all_packers(FILE *f, int verbose)
{
options_t o; o.reset();
PackerNames pn; pn.o = &o;
PackMaster::visitAllPackers(PackerNames::visit, NULL, &o, &pn);
PackMaster::visitAllPackers(PackerNames::visit, nullptr, &o, &pn);
qsort(pn.names, pn.names_count, sizeof(PackerNames::Entry), PackerNames::cmp_fname);
size_t pos = 0;
for (size_t i = 0; i < pn.names_count; ++i)
@@ -219,6 +214,7 @@ void show_help(int verbose)
con_fprintf(f,"\nCompression tuning options:\n");
fg = con_fg(f,fg);
con_fprintf(f,
" --lzma try LZMA [slower but tighter than NRV]\n"
" --brute try all available compression methods & filters [slow]\n"
" --ultra-brute try even more compression variants [very slow]\n"
"\n");
@@ -262,15 +258,6 @@ void show_help(int verbose)
con_fprintf(f,
" --8086 make compressed sys work on any 8086\n"
"\n");
#if 0
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options for linux/386\n");
fg = con_fg(f,fg);
con_fprintf(f,
" --script use /usr/local/lib/upx/upx[bd] as decompressor\n"
" --script=/path/upxX use path/upxX as decompressor\n"
"\n");
#endif
fg = con_fg(f,FG_YELLOW);
con_fprintf(f,"Options for ps1/exe:\n");
fg = con_fg(f,fg);
@@ -327,13 +314,13 @@ void show_help(int verbose)
// "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type 'upx -L'.\n"
"");
#if (DEBUG) || (TESTING)
#if DEBUG || TESTING
fg = con_fg(f,FG_RED);
con_fprintf(f,"\nWARNING: this version is compiled with"
#if (DEBUG)
#if DEBUG
" -DDEBUG"
#endif
#if (TESTING)
#if TESTING
" -DTESTING"
#endif
"\n");
@@ -361,17 +348,17 @@ void show_license(void)
" This program is distributed in the hope that it will be useful,\n"
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
" UPX License Agreement for more details.\n"
" UPX License Agreements for more details.\n"
"\n"
" You should have received a copy of the UPX License Agreement\n"
" along with this program; see the file LICENSE.\n"
" You should have received a copy of the UPX License Agreements\n"
" along with this program; see the files COPYING and LICENSE.\n"
" If not, visit one of the following pages:\n"
"\n"
);
int fg = con_fg(f,FG_CYAN);
con_fprintf(f,
" http://upx.sourceforge.net\n"
" http://www.oberhumer.com/opensource/upx/\n"
" https://upx.github.io\n"
" https://www.oberhumer.com/opensource/upx/\n"
);
(void)con_fg(f,FG_ORANGE);
con_fprintf(f,
@@ -389,47 +376,53 @@ void show_license(void)
//
**************************************************************************/
void show_version(int x)
void show_version(bool one_line)
{
FILE *fp = stdout;
const char *v;
UNUSED(x);
UNUSED(v);
fprintf(fp, "upx %s\n", UPX_VERSION_STRING
#if defined(UPX_VERSION_GITREV)
"-git-" UPX_VERSION_GITREV
#endif
);
if (one_line)
return;
#if (WITH_NRV)
v = upx_nrv_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "NRV data compression library %s\n", v);
#endif
#if (WITH_UCL)
v = upx_ucl_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "UCL data compression library %s\n", v);
#endif
#if (WITH_ZLIB)
v = upx_zlib_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "zlib data compression library %s\n", v);
#endif
#if (WITH_LZMA)
v = upx_lzma_version_string();
if (v != NULL && v[0])
if (v != nullptr && v[0])
fprintf(fp, "LZMA SDK version %s\n", v);
#endif
fprintf(fp, "Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(fp, "Copyright (C) 1996-2017 Laszlo Molnar\n");
fprintf(fp, "Copyright (C) 2000-2017 John F. Reiser\n");
fprintf(fp, "Copyright (C) 2002-2017 Jens Medoch\n");
#if !defined(DOCTEST_CONFIG_DISABLE)
fprintf(fp, "doctest C++ testing framework version %s\n", DOCTEST_VERSION_STR);
#endif
fprintf(fp, "Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer\n");
fprintf(fp, "Copyright (C) 1996-2022 Laszlo Molnar\n");
fprintf(fp, "Copyright (C) 2000-2022 John F. Reiser\n");
fprintf(fp, "Copyright (C) 2002-2022 Jens Medoch\n");
#if (WITH_ZLIB)
fprintf(fp, "Copyright (C) 1995" "-2005 Jean-loup Gailly and Mark Adler\n");
fprintf(fp, "Copyright (C) 1995" "-2022 Jean-loup Gailly and Mark Adler\n");
#endif
#if (WITH_LZMA)
fprintf(fp, "Copyright (C) 1999" "-2006 Igor Pavlov\n");
#endif
#if !defined(DOCTEST_CONFIG_DISABLE)
fprintf(fp, "Copyright (C) 2016" "-2021 Viktor Kirilov\n");
#endif
fprintf(fp, "UPX comes with ABSOLUTELY NO WARRANTY; for details type '%s -L'.\n", progname);
}
+29 -23
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -28,12 +28,12 @@
#include "conf.h"
#include "file.h"
#include "mem.h"
#include "util/membuffer.h"
#include "lefile.h"
LeFile::LeFile(InputFile *f) :
fif(f), fof(NULL),
fif(f), fof(nullptr),
le_offset(0), exe_offset(0)
{
COMPILE_TIME_ASSERT(sizeof(le_header_t) == 196);
@@ -41,13 +41,13 @@ LeFile::LeFile(InputFile *f) :
COMPILE_TIME_ASSERT(sizeof(le_pagemap_entry_t) == 4);
memset(&ih,0,sizeof ih);
memset(&oh,0,sizeof oh);
iobject_table = oobject_table = NULL;
ifpage_table = ofpage_table = NULL;
ipm_entries = opm_entries = NULL;
ires_names = ores_names = NULL;
ifixups = ofixups = NULL;
inonres_names = ononres_names = NULL;
ientries = oentries = NULL;
iobject_table = oobject_table = nullptr;
ifpage_table = ofpage_table = nullptr;
ipm_entries = opm_entries = nullptr;
ires_names = ores_names = nullptr;
ifixups = ofixups = nullptr;
inonres_names = ononres_names = nullptr;
ientries = oentries = nullptr;
}
@@ -77,7 +77,8 @@ LeFile::~LeFile()
void LeFile::readObjectTable()
{
iobject_table = new le_object_table_entry_t[soobject_table = objects];
soobject_table = objects;
iobject_table = New(le_object_table_entry_t, soobject_table);
fif->seek(le_offset + ih.object_table_offset,SEEK_SET);
fif->readx(iobject_table,sizeof(*iobject_table)*objects);
}
@@ -92,7 +93,8 @@ void LeFile::writeObjectTable()
void LeFile::readPageMap()
{
ipm_entries = new le_pagemap_entry_t[sopm_entries = pages];
sopm_entries = pages;
ipm_entries = New(le_pagemap_entry_t, sopm_entries);
fif->seek(le_offset + ih.object_pagemap_offset,SEEK_SET);
fif->readx(ipm_entries,sizeof(*ipm_entries)*pages);
@@ -112,7 +114,7 @@ void LeFile::writePageMap()
void LeFile::readResidentNames()
{
sores_names = ih.entry_table_offset - ih.resident_names_offset;
ires_names = new upx_byte[sores_names];
ires_names = New(upx_byte, sores_names);
fif->seek(le_offset+ih.resident_names_offset,SEEK_SET);
fif->readx(ires_names,sores_names);
}
@@ -129,7 +131,7 @@ void LeFile::readEntryTable()
{
soentries = ih.fixup_page_table_offset - ih.entry_table_offset;
fif->seek(le_offset + ih.entry_table_offset,SEEK_SET);
ientries = new upx_byte[soentries];
ientries = New(upx_byte, soentries);
fif->readx(ientries,soentries);
}
@@ -143,7 +145,8 @@ void LeFile::writeEntryTable()
void LeFile::readFixupPageTable()
{
ifpage_table = new unsigned[sofpage_table = 1+pages];
sofpage_table = 1+pages;
ifpage_table = New(unsigned, sofpage_table);
fif->seek(le_offset + ih.fixup_page_table_offset,SEEK_SET);
fif->readx(ifpage_table,4*sofpage_table);
}
@@ -159,7 +162,7 @@ void LeFile::writeFixupPageTable()
void LeFile::readFixups()
{
sofixups = get_le32(ifpage_table+pages)-get_le32(ifpage_table);
ifixups = new upx_byte[sofixups];
ifixups = New(upx_byte, sofixups);
fif->seek(le_offset + ih.fixup_record_table_offset,SEEK_SET);
fif->readx(ifixups,sofixups);
}
@@ -187,8 +190,9 @@ unsigned LeFile::getImageSize() const
void LeFile::readImage()
{
soimage = pages*mps;
iimage.alloc(soimage);
memset(iimage,0,soimage);
mb_iimage.alloc(soimage);
mb_iimage.clear();
iimage = mb_iimage;
unsigned ic,jc;
for (ic = jc = 0; ic < pages; ic++)
@@ -197,7 +201,8 @@ void LeFile::readImage()
{
fif->seek(ih.data_pages_offset + exe_offset +
(ipm_entries[ic].m*0x100 + ipm_entries[ic].l-1) * mps,SEEK_SET);
fif->readx(iimage+jc,ic != pages-1 ? mps : ih.bytes_on_last_page);
auto bytes = ic != pages-1 ? mps : ih.bytes_on_last_page;
fif->readx(raw_bytes(iimage+jc, bytes), bytes);
}
jc += mps;
}
@@ -206,8 +211,8 @@ void LeFile::readImage()
void LeFile::writeImage()
{
if (fof && oimage != NULL)
fof->write(oimage, soimage);
if (fof && oimage != nullptr)
fof->write(raw_bytes(oimage, soimage), soimage);
}
@@ -215,7 +220,8 @@ void LeFile::readNonResidentNames()
{
if (ih.non_resident_name_table_length)
{
inonres_names = new upx_byte[sononres_names = ih.non_resident_name_table_length];
sononres_names = ih.non_resident_name_table_length;
inonres_names = New(upx_byte, sononres_names);
fif->seek(exe_offset+ih.non_resident_name_table_offset,SEEK_SET);
fif->readx(inonres_names,sononres_names);
}
+18 -16
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -39,7 +39,7 @@ class OutputFile;
class LeFile
{
public:
protected:
LeFile(InputFile *);
virtual ~LeFile();
@@ -112,7 +112,7 @@ protected:
LE32 extra_heap_alloc;
char reserved[12];
LE32 versioninfo;
LE32 unkown;
LE32 unknown;
// 0xC0
LE16 device_id;
LE16 ddk_version;
@@ -137,42 +137,42 @@ protected:
virtual void readObjectTable();
virtual void writeObjectTable();
//virtual void encodeObjectTable(){oobject_table = iobject_table; iobject_table = NULL;}
//virtual void encodeObjectTable(){oobject_table = iobject_table; iobject_table = nullptr;}
//virtual void decodeObjectTable(){encodeObjectTable();}
virtual void readFixupPageTable();
virtual void writeFixupPageTable();
//virtual void encodeFixupPageTable(){ofpage_table = ifpage_table; ifpage_table = NULL;}
//virtual void encodeFixupPageTable(){ofpage_table = ifpage_table; ifpage_table = nullptr;}
//virtual void decodeFixupPageTable(){encodeFixupPageTable();}
virtual void readPageMap();
virtual void writePageMap();
virtual void encodePageMap(){opm_entries = ipm_entries; ipm_entries = NULL;}
virtual void encodePageMap(){opm_entries = ipm_entries; ipm_entries = nullptr;}
virtual void decodePageMap(){encodePageMap();}
virtual void readResidentNames();
virtual void writeResidentNames();
virtual void encodeResidentNames(){ores_names = ires_names; ires_names = NULL;}
virtual void encodeResidentNames(){ores_names = ires_names; ires_names = nullptr;}
virtual void decodeResidentNames(){encodeResidentNames();}
virtual void readNonResidentNames();
virtual void writeNonResidentNames();
virtual void encodeNonResidentNames(){ononres_names = inonres_names; inonres_names = NULL;}
virtual void encodeNonResidentNames(){ononres_names = inonres_names; inonres_names = nullptr;}
virtual void decodeNonResidentNames(){encodeNonResidentNames();}
virtual void readEntryTable();
virtual void writeEntryTable();
//virtual void encodeEntryTable(){oentries = ientries; ientries = NULL;}
//virtual void encodeEntryTable(){oentries = ientries; ientries = nullptr;}
//virtual void decodeEntryTable(){encodeEntryTable();}
virtual void readFixups();
virtual void writeFixups();
//virtual void encodeFixups(){ofixups = ifixups; ifixups = NULL;}
//virtual void encodeFixups(){ofixups = ifixups; ifixups = nullptr;}
//virtual void decodeFixups(){encodeFixups();}
virtual void readImage();
virtual void writeImage();
//virtual void encodeImage(){oimage = iimage; iimage = NULL;}
//virtual void encodeImage(){oimage = iimage; iimage = nullptr;}
//virtual void decodeImage(){encodeImage();}
void countFixups(unsigned *) const;
@@ -198,8 +198,10 @@ protected:
upx_byte *ofixups;
upx_byte *inonres_names;
upx_byte *ononres_names;
MemBuffer iimage;
MemBuffer oimage;
MemBuffer mb_iimage;
SPAN_0(upx_byte) iimage = nullptr;
MemBuffer mb_oimage;
SPAN_0(upx_byte) oimage = nullptr;
upx_byte *ientries;
upx_byte *oentries;
@@ -214,8 +216,8 @@ protected:
private:
// disable copy and assignment
LeFile(const LeFile &); // {}
LeFile& operator= (const LeFile &); // { return *this; }
LeFile(const LeFile &) = delete;
LeFile& operator= (const LeFile &) = delete;
};
+138 -91
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -40,12 +40,13 @@ static bool update_capacity(unsigned size, unsigned *capacity) {
return true;
}
static void __acc_cdecl_va internal_error(const char *format, ...) {
static void internal_error(const char *format, ...) attribute_format(1, 2);
static void internal_error(const char *format, ...) {
static char buf[1024];
va_list ap;
va_start(ap, format);
vsnprintf(buf, sizeof(buf), format, ap);
upx_safe_vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
throwInternalError(buf);
@@ -56,11 +57,11 @@ static void __acc_cdecl_va internal_error(const char *format, ...) {
**************************************************************************/
ElfLinker::Section::Section(const char *n, const void *i, unsigned s, unsigned a)
: name(NULL), output(NULL), size(s), offset(0), p2align(a), next(NULL) {
: name(nullptr), output(nullptr), size(s), offset(0), p2align(a), next(nullptr) {
name = strdup(n);
assert(name != NULL);
assert(name != nullptr);
input = malloc(s + 1);
assert(input != NULL);
assert(input != nullptr);
if (s != 0)
memcpy(input, i, s);
((char *) input)[s] = 0;
@@ -76,10 +77,10 @@ ElfLinker::Section::~Section() {
**************************************************************************/
ElfLinker::Symbol::Symbol(const char *n, Section *s, upx_uint64_t o)
: name(NULL), section(s), offset(o) {
: name(nullptr), section(s), offset(o) {
name = strdup(n);
assert(name != NULL);
assert(section != NULL);
assert(name != nullptr);
assert(section != nullptr);
}
ElfLinker::Symbol::~Symbol() { free(name); }
@@ -91,7 +92,7 @@ ElfLinker::Symbol::~Symbol() { free(name); }
ElfLinker::Relocation::Relocation(const Section *s, unsigned o, const char *t, const Symbol *v,
upx_uint64_t a)
: section(s), offset(o), type(t), value(v), add(a) {
assert(section != NULL);
assert(section != nullptr);
}
/*************************************************************************
@@ -99,10 +100,10 @@ ElfLinker::Relocation::Relocation(const Section *s, unsigned o, const char *t, c
**************************************************************************/
ElfLinker::ElfLinker()
: bele(&N_BELE_RTP::le_policy), input(NULL), output(NULL), head(NULL), tail(NULL),
sections(NULL), symbols(NULL), relocations(NULL), nsections(0), nsections_capacity(0),
nsymbols(0), nsymbols_capacity(0), nrelocations(0), nrelocations_capacity(0),
reloc_done(false) {}
: bele(&N_BELE_RTP::le_policy), input(nullptr), output(nullptr), head(nullptr), tail(nullptr),
sections(nullptr), symbols(nullptr), relocations(nullptr), nsections(0),
nsections_capacity(0), nsymbols(0), nsymbols_capacity(0), nrelocations(0),
nrelocations_capacity(0), reloc_done(false) {}
ElfLinker::~ElfLinker() {
delete[] input;
@@ -120,7 +121,7 @@ ElfLinker::~ElfLinker() {
free(relocations);
}
void ElfLinker::init(const void *pdata_v, int plen) {
void ElfLinker::init(const void *pdata_v, int plen, unsigned pxtra) {
const upx_byte *pdata = (const upx_byte *) pdata_v;
if (plen >= 16 && memcmp(pdata, "UPX#", 4) == 0) {
// decompress pre-compressed stub-loader
@@ -143,7 +144,7 @@ void ElfLinker::init(const void *pdata_v, int plen) {
inputlen = u_len;
input = new upx_byte[inputlen + 1];
unsigned new_len = u_len;
int r = upx_decompress(pdata, c_len, input, &new_len, method, NULL);
int r = upx_decompress(pdata, c_len, input, &new_len, method, nullptr);
if (r == UPX_E_OUT_OF_MEMORY)
throwOutOfMemoryException();
if (r != UPX_E_OK || new_len != u_len)
@@ -156,34 +157,38 @@ void ElfLinker::init(const void *pdata_v, int plen) {
}
input[inputlen] = 0; // NUL terminate
output = new upx_byte[inputlen ? inputlen : 0x4000];
output = new upx_byte[inputlen ? (inputlen + pxtra) : 0x4000];
outputlen = 0;
// FIXME: bad compare when either symbols or relocs are absent
if ((int) strlen("Sections:\n"
"SYMBOL TABLE:\n"
"RELOCATION RECORDS FOR ") < inputlen) {
char const *const eof = (char const *) &input[inputlen];
int pos = find(input, inputlen, "Sections:\n", 10);
assert(pos != -1);
char *psections = (char *) input + pos;
char *const psections = (char *) input + pos;
char *psymbols = strstr(psections, "SYMBOL TABLE:\n");
assert(psymbols != NULL);
char *const psymbols = strstr(psections, "SYMBOL TABLE:\n");
// assert(psymbols != nullptr);
char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR ");
assert(prelocs != NULL);
char *const prelocs = strstr((psymbols ? psymbols : psections), "RELOCATION RECORDS FOR ");
// assert(prelocs != nullptr);
preprocessSections(psections, psymbols);
preprocessSymbols(psymbols, prelocs);
preprocessRelocations(prelocs, (char *) input + inputlen);
preprocessSections(psections, (psymbols ? psymbols : (prelocs ? prelocs : eof)));
if (psymbols)
preprocessSymbols(psymbols, (prelocs ? prelocs : eof));
if (prelocs)
preprocessRelocations(prelocs, eof);
addLoader("*UND*");
}
}
void ElfLinker::preprocessSections(char *start, char *end) {
void ElfLinker::preprocessSections(char *start, char const *end) {
char *nextl;
for (nsections = 0; start < end; start = 1 + nextl) {
nextl = strchr(start, '\n');
assert(nextl != NULL);
assert(nextl != nullptr);
*nextl = '\0'; // a record is a line
unsigned offset, size, align;
@@ -197,15 +202,15 @@ void ElfLinker::preprocessSections(char *start, char *end) {
// printf("section %s preprocessed\n", n);
}
}
addSection("*ABS*", NULL, 0, 0);
addSection("*UND*", NULL, 0, 0);
addSection("*ABS*", nullptr, 0, 0);
addSection("*UND*", nullptr, 0, 0);
}
void ElfLinker::preprocessSymbols(char *start, char *end) {
void ElfLinker::preprocessSymbols(char *start, char const *end) {
char *nextl;
for (nsymbols = 0; start < end; start = 1 + nextl) {
nextl = strchr(start, '\n');
assert(nextl != NULL);
assert(nextl != nullptr);
*nextl = '\0'; // a record is a line
unsigned value, offset;
@@ -237,12 +242,12 @@ void ElfLinker::preprocessSymbols(char *start, char *end) {
}
}
void ElfLinker::preprocessRelocations(char *start, char *end) {
Section *section = NULL;
void ElfLinker::preprocessRelocations(char *start, char const *end) {
Section *section = nullptr;
char *nextl;
for (nrelocations = 0; start < end; start = 1 + nextl) {
nextl = strchr(start, '\n');
assert(nextl != NULL);
assert(nextl != nullptr);
*nextl = '\0'; // a record is a line
{
@@ -261,7 +266,7 @@ void ElfLinker::preprocessRelocations(char *start, char *end) {
upx_uint64_t add = 0;
char *p = strstr(symbol, "+0x");
if (p == NULL)
if (p == nullptr)
p = strstr(symbol, "-0x");
if (p) {
char sign = *p;
@@ -275,7 +280,7 @@ void ElfLinker::preprocessRelocations(char *start, char *end) {
else
add = a;
#else
char *endptr = NULL;
char *endptr = nullptr;
add = strtoull(p, &endptr, 16);
assert(endptr && *endptr == '\0');
#endif
@@ -298,7 +303,7 @@ ElfLinker::Section *ElfLinker::findSection(const char *name, bool fatal) const {
return sections[ic];
if (fatal)
internal_error("unknown section %s\n", name);
return NULL;
return nullptr;
}
ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const {
@@ -307,12 +312,14 @@ ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const {
return symbols[ic];
if (fatal)
internal_error("unknown symbol %s\n", name);
return NULL;
return nullptr;
}
ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata, int slen,
unsigned p2align) {
// printf("addSection: %s len=%d align=%d\n", sname, slen, p2align);
if (!sdata && (!strcmp("ABS*", sname) || !strcmp("UND*", sname)))
return nullptr;
if (update_capacity(nsections, &nsections_capacity))
sections =
static_cast<Section **>(realloc(sections, nsections_capacity * sizeof(Section *)));
@@ -320,7 +327,7 @@ ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata,
assert(sname);
assert(sname[0]);
assert(sname[strlen(sname) - 1] != ':');
assert(findSection(sname, false) == NULL);
assert(findSection(sname, false) == nullptr);
Section *sec = new Section(sname, sdata, slen, p2align);
sections[nsections++] = sec;
return sec;
@@ -331,11 +338,11 @@ ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section,
// printf("addSymbol: %s %s 0x%x\n", name, section, offset);
if (update_capacity(nsymbols, &nsymbols_capacity))
symbols = static_cast<Symbol **>(realloc(symbols, nsymbols_capacity * sizeof(Symbol *)));
assert(symbols != NULL);
assert(symbols != nullptr);
assert(name);
assert(name[0]);
assert(name[strlen(name) - 1] != ':');
assert(findSymbol(name, false) == NULL);
assert(findSymbol(name, false) == nullptr);
Symbol *sym = new Symbol(name, findSection(section), offset);
symbols[nsymbols++] = sym;
return sym;
@@ -346,7 +353,7 @@ ElfLinker::Relocation *ElfLinker::addRelocation(const char *section, unsigned of
if (update_capacity(nrelocations, &nrelocations_capacity))
relocations = static_cast<Relocation **>(
realloc(relocations, (nrelocations_capacity) * sizeof(Relocation *)));
assert(relocations != NULL);
assert(relocations != nullptr);
Relocation *rel = new Relocation(findSection(section), off, type, findSymbol(symbol), add);
relocations[nrelocations++] = rel;
return rel;
@@ -361,7 +368,7 @@ void ElfLinker::setLoaderAlignOffset(int phase)
#endif
int ElfLinker::addLoader(const char *sname) {
assert(sname != NULL);
assert(sname != nullptr);
if (!sname[0])
return outputlen;
@@ -420,13 +427,13 @@ int ElfLinker::addLoader(const char *sname) {
}
void ElfLinker::addLoader(const char *s, va_list ap) {
while (s != NULL) {
while (s != nullptr) {
addLoader(s);
s = va_arg(ap, const char *);
}
}
void __acc_cdecl_va ElfLinker::addLoaderVA(const char *s, ...) {
void ElfLinker::addLoaderVA(const char *s, ...) {
va_list ap;
va_start(ap, s);
addLoader(s, ap);
@@ -458,14 +465,14 @@ void ElfLinker::relocate() {
const Relocation *rel = relocations[ic];
upx_uint64_t value = 0;
if (rel->section->output == NULL)
if (rel->section->output == nullptr)
continue;
if (strcmp(rel->value->section->name, "*ABS*") == 0) {
value = rel->value->offset;
} else if (strcmp(rel->value->section->name, "*UND*") == 0 &&
rel->value->offset == 0xdeaddead)
internal_error("undefined symbol '%s' referenced\n", rel->value->name);
else if (rel->value->section->output == NULL)
else if (rel->value->section->output == nullptr)
internal_error("can not apply reloc '%s:%x' without section '%s'\n", rel->section->name,
rel->offset, rel->value->section->name);
else {
@@ -500,21 +507,21 @@ void ElfLinker::defineSymbol(const char *name, upx_uint64_t value) {
// debugging support
void ElfLinker::dumpSymbol(const Symbol *symbol, unsigned flags, FILE *fp) const {
if ((flags & 1) && symbol->section->output == NULL)
if ((flags & 1) && symbol->section->output == nullptr)
return;
char d0[16 + 1], d1[16 + 1];
upx_snprintf(d0, sizeof(d0), "%016llx", (upx_uint64_t) symbol->offset);
upx_snprintf(d1, sizeof(d1), "%016llx", (upx_uint64_t) symbol->section->offset);
upx_safe_snprintf(d0, sizeof(d0), "%016llx", (upx_uint64_t) symbol->offset);
upx_safe_snprintf(d1, sizeof(d1), "%016llx", (upx_uint64_t) symbol->section->offset);
fprintf(fp, "%-28s 0x%-16s | %-28s 0x%-16s\n", symbol->name, d0, symbol->section->name, d1);
}
void ElfLinker::dumpSymbols(unsigned flags, FILE *fp) const {
if (fp == NULL)
if (fp == nullptr)
fp = stdout;
if ((flags & 2) == 0) {
// default: dump symbols in used section order
for (const Section *section = head; section; section = section->next) {
char d1[16 + 1];
upx_snprintf(d1, sizeof(d1), "%016llx", (upx_uint64_t) section->offset);
upx_safe_snprintf(d1, sizeof(d1), "%016llx", (upx_uint64_t) section->offset);
fprintf(fp, "%-42s%-28s 0x%-16s\n", "", section->name, d1);
for (unsigned ic = 0; ic < nsymbols; ic++) {
const Symbol *symbol = symbols[ic];
@@ -531,7 +538,7 @@ void ElfLinker::dumpSymbols(unsigned flags, FILE *fp) const {
upx_uint64_t ElfLinker::getSymbolOffset(const char *name) const {
const Symbol *symbol = findSymbol(name);
if (symbol->section->output == NULL)
if (symbol->section->output == nullptr)
return 0xdeaddead;
return symbol->section->offset + symbol->offset;
}
@@ -592,38 +599,10 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location, upx_ui
super::relocate1(rel, location, value, type);
}
void ElfLinkerARM64::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (strncmp(type, "R_AARCH64_", 10))
return super::relocate1(rel, location, value, type);
type += 10;
if (!strncmp(type, "PREL", 4)) {
value -= rel->section->offset + rel->offset;
type += 4;
if (!strcmp(type, "16"))
set_le16(location, get_le16(location) + value);
else if (!strncmp(type, "32", 2)) // for "32" and "32S"
set_le32(location, get_le32(location) + value);
else if (!strcmp(type, "64"))
set_le64(location, get_le64(location) + value);
} else if (!strcmp(type, "ABS32")) {
set_le32(location, get_le32(location) + value);
} else if (!strcmp(type, "ABS64")) {
set_le64(location, get_le64(location) + value);
} else if (!strcmp(type, "CONDBR19")) {
value -= rel->section->offset + rel->offset;
upx_uint32_t const m19 = ~(~0u << 19);
upx_uint32_t w = get_le32(location);
set_le32(location, (w & ~(m19 << 5)) | ((((w >> 5) + (value >> 2)) & m19) << 5));
} else
super::relocate1(rel, location, value, type);
}
void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (strcmp(type, "R_ARM_PC24") == 0) {
if (!strcmp(type, "R_ARM_PC24") || !strcmp(type, "R_ARM_CALL") ||
!strcmp(type, "R_ARM_JUMP24")) {
value -= rel->section->offset + rel->offset;
set_be24(1 + location, get_be24(1 + location) + value / 4);
} else if (strcmp(type, "R_ARM_ABS32") == 0) {
@@ -647,7 +626,8 @@ void ElfLinkerArmBE::relocate1(const Relocation *rel, upx_byte *location, upx_ui
void ElfLinkerArmLE::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (strcmp(type, "R_ARM_PC24") == 0) {
if (!strcmp(type, "R_ARM_PC24") || !strcmp(type, "R_ARM_CALL") ||
!strcmp(type, "R_ARM_JUMP24")) {
value -= rel->section->offset + rel->offset;
set_le24(location, get_le24(location) + value / 4);
} else if (strcmp(type, "R_ARM_ABS32") == 0) {
@@ -671,11 +651,40 @@ void ElfLinkerArmLE::relocate1(const Relocation *rel, upx_byte *location, upx_ui
void ElfLinkerArm64LE::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (strcmp(type, "R_AARCH64_CALL26") == 0) {
if (strncmp(type, "R_AARCH64_", 10))
return super::relocate1(rel, location, value, type);
type += 10;
if (!strncmp(type, "PREL", 4)) {
value -= rel->section->offset + rel->offset;
set_le24(location, get_le24(location) + value / 4); // FIXME set_le26
} else if (strcmp(type, "R_AARCH64_ABS32") == 0) {
type += 4;
if (!strcmp(type, "16"))
set_le16(location, get_le16(location) + value);
else if (!strncmp(type, "32", 2)) // for "32" and "32S"
set_le32(location, get_le32(location) + value);
else if (!strcmp(type, "64"))
set_le64(location, get_le64(location) + value);
} else if (!strcmp(type, "ADR_PREL_LO21")) {
value -= rel->section->offset + rel->offset;
upx_uint32_t const m19 = ~(~0u << 19);
upx_uint32_t w = get_le32(location);
set_le32(location, (w & ~((3u << 29) | (m19 << 5))) | ((3u & value) << 29) |
((m19 & (value >> 2)) << 5));
} else if (!strcmp(type, "ABS32")) {
set_le32(location, get_le32(location) + value);
} else if (!strcmp(type, "ABS64")) {
set_le64(location, get_le64(location) + value);
} else if (!strcmp(type, "CONDBR19")) {
value -= rel->section->offset + rel->offset;
upx_uint32_t const m19 = ~(~0u << 19);
upx_uint32_t w = get_le32(location);
set_le32(location, (w & ~(m19 << 5)) | ((((w >> 5) + (value >> 2)) & m19) << 5));
} else if (!strcmp(type, "CALL26")) {
value -= rel->section->offset + rel->offset;
upx_uint32_t const m26 = ~(~0u << 26);
upx_uint32_t w = get_le32(location);
set_le32(location, (w & ~m26) | (m26 & (value >> 2)));
} else
super::relocate1(rel, location, value, type);
}
@@ -797,6 +806,14 @@ void ElfLinkerPpc32::relocate1(const Relocation *rel, upx_byte *location, upx_ui
void ElfLinkerPpc64le::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (!strcmp(type, "R_PPC64_ADDR64")) {
set_le64(location, get_le64(location) + value);
return;
}
if (!strcmp(type, "R_PPC64_ADDR32")) {
set_le32(location, get_le32(location) + value);
return;
}
if (strncmp(type, "R_PPC64_REL", 11))
return super::relocate1(rel, location, value, type);
type += 11;
@@ -816,11 +833,11 @@ void ElfLinkerPpc64le::relocate1(const Relocation *rel, upx_byte *location, upx_
internal_error("target out of range (%d) in reloc %s:%x\n", displ, rel->section->name,
rel->offset);
*location += value;
} else if (strncmp(type, "14", 2) == 0) // for "32" and "32S"
} else if (strncmp(type, "14", 2) == 0) // for "14" and "14S"
set_le16(location, get_le16(location) + value);
else if (strcmp(type, "16") == 0)
set_le16(location, get_le16(location) + value);
else if (strncmp(type, "24", 2) == 0) // for "32" and "32S"
else if (strncmp(type, "24", 2) == 0) // for "24" and "24S"
set_le24(location, get_le24(location) + value);
else if (strncmp(type, "32", 2) == 0) // for "32" and "32S"
set_le32(location, get_le32(location) + value);
@@ -830,6 +847,36 @@ void ElfLinkerPpc64le::relocate1(const Relocation *rel, upx_byte *location, upx_
super::relocate1(rel, location, value, type);
}
void ElfLinkerPpc64::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (!strcmp(type, "R_PPC64_ADDR32")) {
set_be32(location, get_be32(location) + value);
return;
}
if (!strcmp(type, "R_PPC64_ADDR64")) {
set_be64(location, get_be64(location) + value);
return;
}
if (strncmp(type, "R_PPC64_REL", 11))
return super::relocate1(rel, location, value, type);
type += 11;
if (strncmp(type, "PC", 2) == 0) {
type += 2;
}
// We have "R_PPC64_REL" or "R_PPC64_RELPC" as a prefix.
/* value will hold relative displacement */
value -= rel->section->offset + rel->offset;
if (strncmp(type, "14", 2) == 0) // for "14" and "14S"
set_be16(2 + location, get_be16(2 + location) + value);
else if (strncmp(type, "24", 2) == 0) // for "24" and "24S"
set_be24(1 + location, get_be24(1 + location) + value);
else
super::relocate1(rel, location, value, type);
}
void ElfLinkerX86::relocate1(const Relocation *rel, upx_byte *location, upx_uint64_t value,
const char *type) {
if (strncmp(type, "R_386_", 6))
@@ -846,7 +893,7 @@ void ElfLinkerX86::relocate1(const Relocation *rel, upx_byte *location, upx_uint
if (strcmp(type, "8") == 0) {
int displ = (signed char) *location + (int) value;
if (range_check && (displ < -128 || displ > 127))
internal_error("target out of range (%d,%d,%d) in reloc %s:%x\n", displ, *location,
internal_error("target out of range (%d,%d,%llu) in reloc %s:%x\n", displ, *location,
value, rel->section->name, rel->offset);
*location += value;
} else if (strcmp(type, "16") == 0)
+93 -75
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -36,37 +36,37 @@ class ElfLinker : private noncopyable {
friend class Packer;
public:
const N_BELE_RTP::AbstractPolicy *bele; // target endianness
const N_BELE_RTP::AbstractPolicy *bele = nullptr; // target endianness
protected:
struct Section;
struct Symbol;
struct Relocation;
upx_byte *input;
int inputlen;
upx_byte *output;
int outputlen;
upx_byte *input = nullptr;
int inputlen = 0;
upx_byte *output = nullptr;
int outputlen = 0;
Section *head;
Section *tail;
Section *head = nullptr;
Section *tail = nullptr;
Section **sections;
Symbol **symbols;
Relocation **relocations;
Section **sections = nullptr;
Symbol **symbols = nullptr;
Relocation **relocations = nullptr;
unsigned nsections;
unsigned nsections_capacity;
unsigned nsymbols;
unsigned nsymbols_capacity;
unsigned nrelocations;
unsigned nrelocations_capacity;
unsigned nsections = 0;
unsigned nsections_capacity = 0;
unsigned nsymbols = 0;
unsigned nsymbols_capacity = 0;
unsigned nrelocations = 0;
unsigned nrelocations_capacity = 0;
bool reloc_done;
bool reloc_done = false;
protected:
void preprocessSections(char *start, char *end);
void preprocessSymbols(char *start, char *end);
void preprocessRelocations(char *start, char *end);
void preprocessSections(char *start, char const *end);
void preprocessSymbols(char *start, char const *end);
void preprocessRelocations(char *start, char const *end);
Section *findSection(const char *name, bool fatal = true) const;
Symbol *findSymbol(const char *name, bool fatal = true) const;
@@ -78,31 +78,38 @@ public:
ElfLinker();
virtual ~ElfLinker();
virtual void init(const void *pdata, int plen);
void init(const void *pdata, int plen, unsigned pxtra = 0);
// virtual void setLoaderAlignOffset(int phase);
virtual int addLoader(const char *sname);
int addLoader(const char *sname);
void addLoader(const char *s, va_list ap);
#if 1 && (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x040100))
void __acc_cdecl_va addLoaderVA(const char *s, ...) __attribute__((__sentinel__));
#if (ACC_CC_CLANG || ACC_CC_GNUC)
void addLoaderVA(const char *s, ...) __attribute__((__sentinel__));
#else
void __acc_cdecl_va addLoaderVA(const char *s, ...);
void addLoaderVA(const char *s, ...);
#endif
virtual Section *addSection(const char *sname, const void *sdata, int slen, unsigned p2align);
virtual int getSection(const char *sname, int *slen = NULL) const;
virtual int getSectionSize(const char *sname) const;
virtual upx_byte *getLoader(int *llen = NULL) const;
virtual void defineSymbol(const char *name, upx_uint64_t value);
virtual upx_uint64_t getSymbolOffset(const char *) const;
Section *addSection(const char *sname, const void *sdata, int slen, unsigned p2align);
int getSection(const char *sname, int *slen = nullptr) const;
int getSectionSize(const char *sname) const;
upx_byte *getLoader(int *llen = nullptr) const;
void defineSymbol(const char *name, upx_uint64_t value);
upx_uint64_t getSymbolOffset(const char *) const;
virtual void dumpSymbol(const Symbol *, unsigned flags, FILE *fp) const;
virtual void dumpSymbols(unsigned flags = 0, FILE *fp = NULL) const;
void dumpSymbol(const Symbol *, unsigned flags, FILE *fp) const;
void dumpSymbols(unsigned flags = 0, FILE *fp = nullptr) const;
void alignWithByte(unsigned len, unsigned char b);
virtual void alignCode(unsigned len) { alignWithByte(len, 0); }
virtual void alignData(unsigned len) { alignWithByte(len, 0); }
// provide overloads to pacify GitHub CodeQL
void defineSymbol(const char *name, int value) { defineSymbol(name, upx_uint64_t(value)); }
void defineSymbol(const char *name, unsigned value) { defineSymbol(name, upx_uint64_t(value)); }
void defineSymbol(const char *name, unsigned long value) {
defineSymbol(name, upx_uint64_t(value));
}
protected:
virtual void relocate();
void relocate();
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
@@ -116,32 +123,32 @@ protected:
};
struct ElfLinker::Section : private noncopyable {
char *name;
void *input;
upx_byte *output;
unsigned size;
upx_uint64_t offset;
unsigned p2align; // log2
Section *next;
char *name = nullptr;
void *input = nullptr;
upx_byte *output = nullptr;
unsigned size = 0;
upx_uint64_t offset = 0;
unsigned p2align = 0; // log2
Section *next = nullptr;
Section(const char *n, const void *i, unsigned s, unsigned a = 0);
~Section();
};
struct ElfLinker::Symbol : private noncopyable {
char *name;
Section *section;
upx_uint64_t offset;
char *name = nullptr;
Section *section = nullptr;
upx_uint64_t offset = 0;
Symbol(const char *n, Section *s, upx_uint64_t o);
~Symbol();
};
struct ElfLinker::Relocation : private noncopyable {
const Section *section;
unsigned offset;
const char *type;
const Symbol *value;
const Section *section = nullptr;
unsigned offset = 0;
const char *type = nullptr;
const Symbol *value = nullptr;
upx_uint64_t add; // used in .rela relocations
Relocation(const Section *s, unsigned o, const char *t, const Symbol *v, upx_uint64_t a);
@@ -155,21 +162,21 @@ class ElfLinkerAMD64 : public ElfLinker {
typedef ElfLinker super;
protected:
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
virtual void alignCode(unsigned len) override { alignWithByte(len, 0x90); }
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerARM64 : public ElfLinker {
class ElfLinkerARM64 final : public ElfLinker {
typedef ElfLinker super;
protected:
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
virtual void alignCode(unsigned len) override { alignWithByte(len, 0x90); }
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerArmBE : public ElfLinker {
class ElfLinkerArmBE final : public ElfLinker {
typedef ElfLinker super;
public:
@@ -177,38 +184,38 @@ public:
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerArmLE : public ElfLinker {
class ElfLinkerArmLE final : public ElfLinker {
typedef ElfLinker super;
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerArm64LE : public ElfLinker {
class ElfLinkerArm64LE final : public ElfLinker {
typedef ElfLinker super;
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerM68k : public ElfLinker {
class ElfLinkerM68k final : public ElfLinker {
typedef ElfLinker super;
public:
ElfLinkerM68k() { bele = &N_BELE_RTP::be_policy; }
protected:
virtual void alignCode(unsigned len);
virtual void alignCode(unsigned len) override;
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerMipsBE : public ElfLinker {
class ElfLinkerMipsBE final : public ElfLinker {
typedef ElfLinker super;
public:
@@ -216,18 +223,18 @@ public:
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerMipsLE : public ElfLinker {
class ElfLinkerMipsLE final : public ElfLinker {
typedef ElfLinker super;
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerPpc32 : public ElfLinker {
class ElfLinkerPpc32 final : public ElfLinker {
typedef ElfLinker super;
public:
@@ -235,24 +242,35 @@ public:
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerPpc64le : public ElfLinker {
class ElfLinkerPpc64le final : public ElfLinker {
typedef ElfLinker super;
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
class ElfLinkerX86 : public ElfLinker {
class ElfLinkerPpc64 final : public ElfLinker {
typedef ElfLinker super;
public:
ElfLinkerPpc64() { bele = &N_BELE_RTP::be_policy; }
protected:
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type) override;
};
class ElfLinkerX86 final : public ElfLinker {
typedef ElfLinker super;
protected:
virtual void alignCode(unsigned len) { alignWithByte(len, 0x90); }
virtual void alignCode(unsigned len) override { alignWithByte(len, 0x90); }
virtual void relocate1(const Relocation *, upx_byte *location, upx_uint64_t value,
const char *type);
const char *type) override;
};
#endif /* already included */
Submodule src/lzma-sdk deleted from 426fe82d12
+387 -612
View File
File diff suppressed because it is too large Load Diff
-201
View File
@@ -1,201 +0,0 @@
/* mem.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#include "conf.h"
#include "mem.h"
/*************************************************************************
// bool use_simple_mcheck()
**************************************************************************/
#if defined(__SANITIZE_ADDRESS__)
__acc_static_forceinline bool use_simple_mcheck() { return false; }
#elif (WITH_VALGRIND) && defined(RUNNING_ON_VALGRIND)
static int use_simple_mcheck_flag = -1;
__acc_static_noinline void use_simple_mcheck_init()
{
use_simple_mcheck_flag = 1;
if (RUNNING_ON_VALGRIND) {
use_simple_mcheck_flag = 0;
//fprintf(stderr, "upx: detected RUNNING_ON_VALGRIND\n");
}
}
__acc_static_forceinline bool use_simple_mcheck()
{
if __acc_unlikely(use_simple_mcheck_flag < 0)
use_simple_mcheck_init();
return (bool) use_simple_mcheck_flag;
}
#else
__acc_static_forceinline bool use_simple_mcheck() { return true; }
#endif
/*************************************************************************
//
**************************************************************************/
MemBuffer::MemBuffer(upx_uint64_t size) :
b(NULL), b_size(0)
{
alloc(size);
}
MemBuffer::~MemBuffer()
{
this->dealloc();
}
void MemBuffer::dealloc()
{
if (b != NULL)
{
checkState();
if (use_simple_mcheck())
{
// remove magic constants
set_be32(b - 8, 0);
set_be32(b - 4, 0);
set_be32(b + b_size, 0);
set_be32(b + b_size + 4, 0);
//
::free(b - 16);
}
else
::free(b);
b = NULL;
b_size = 0;
}
else
assert(b_size == 0);
}
unsigned MemBuffer::getSizeForCompression(unsigned uncompressed_size, unsigned extra)
{
size_t bytes = mem_size(1, uncompressed_size, extra);
bytes += uncompressed_size/8 + 256;
return ACC_ICONV(unsigned, bytes);
}
unsigned MemBuffer::getSizeForUncompression(unsigned uncompressed_size, unsigned extra)
{
size_t bytes = mem_size(1, uncompressed_size, extra);
// INFO: 3 bytes are the allowed overrun for the i386 asm_fast decompressors
#if (ACC_ARCH_I386)
bytes += 3;
#endif
return ACC_ICONV(unsigned, bytes);
}
void MemBuffer::allocForCompression(unsigned uncompressed_size, unsigned extra)
{
unsigned size = getSizeForCompression(uncompressed_size, extra);
alloc(size);
}
void MemBuffer::allocForUncompression(unsigned uncompressed_size, unsigned extra)
{
unsigned size = getSizeForUncompression(uncompressed_size, extra);
alloc(size);
}
void MemBuffer::fill(unsigned off, unsigned len, int value)
{
checkState();
assert((int)off >= 0);
assert((int)len >= 0);
assert(off <= b_size);
assert(len <= b_size);
assert(off + len <= b_size);
if (len > 0)
memset(b + off, value, len);
}
/*************************************************************************
//
**************************************************************************/
#define PTR(p) ((unsigned) ((upx_uintptr_t)(p) & 0xffffffff))
#define MAGIC1(p) (PTR(p) ^ 0xfefdbeeb)
#define MAGIC2(p) (PTR(p) ^ 0xfefdbeeb ^ 0x80024001)
unsigned MemBuffer::global_alloc_counter = 0;
void MemBuffer::checkState() const
{
if (!b)
throwInternalError("block not allocated");
if (use_simple_mcheck())
{
if (get_be32(b - 4) != MAGIC1(b))
throwInternalError("memory clobbered before allocated block 1");
if (get_be32(b - 8) != b_size)
throwInternalError("memory clobbered before allocated block 2");
if (get_be32(b + b_size) != MAGIC2(b))
throwInternalError("memory clobbered past end of allocated block");
}
assert((int)b_size > 0);
}
void MemBuffer::alloc(upx_uint64_t size)
{
// NOTE: we don't automatically free a used buffer
assert(b == NULL);
assert(b_size == 0);
//
assert(size > 0);
size_t bytes = mem_size(1, size, use_simple_mcheck() ? 32 : 0);
unsigned char *p = (unsigned char *) malloc(bytes);
if (!p)
throwOutOfMemoryException();
b_size = ACC_ICONV(unsigned, size);
if (use_simple_mcheck())
{
b = p + 16;
// store magic constants to detect buffer overruns
set_be32(b - 8, b_size);
set_be32(b - 4, MAGIC1(b));
set_be32(b + b_size, MAGIC2(b));
set_be32(b + b_size + 4, global_alloc_counter++);
}
else
b = p ;
//fill(0, b_size, (rand() & 0xff) | 1); // debug
}
/* vim:set ts=4 sw=4 et: */
-83
View File
@@ -1,83 +0,0 @@
/* mem.h --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_MEM_H
#define __UPX_MEM_H 1
/*************************************************************************
//
**************************************************************************/
class MemBuffer
{
public:
MemBuffer() : b(NULL), b_size(0) { }
explicit MemBuffer(upx_uint64_t size);
~MemBuffer();
static unsigned getSizeForCompression(unsigned uncompressed_size, unsigned extra=0);
static unsigned getSizeForUncompression(unsigned uncompressed_size, unsigned extra=0);
void alloc(upx_uint64_t size);
void allocForCompression(unsigned uncompressed_size, unsigned extra=0);
void allocForUncompression(unsigned uncompressed_size, unsigned extra=0);
void dealloc();
void checkState() const;
unsigned getSize() const { return b_size; }
operator unsigned char * () { return b; }
operator const unsigned char * () const { return b; }
void *getVoidPtr() { return (void *) b; }
const void *getVoidPtr() const { return (const void *) b; }
void fill(unsigned off, unsigned len, int value);
void clear(unsigned off, unsigned len) { fill(off, len, 0); }
void clear() { fill(0, b_size, 0); }
private:
unsigned char *b;
unsigned b_size;
static unsigned global_alloc_counter;
// disable copy and assignment
MemBuffer(const MemBuffer &); // {}
MemBuffer& operator= (const MemBuffer &); // { return *this; }
// disable dynamic allocation
DISABLE_NEW_DELETE
};
#endif /* already included */
/* vim:set ts=4 sw=4 et: */
+129 -76
View File
@@ -2,7 +2,7 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -27,7 +27,7 @@
#ifndef __ACC_H_INCLUDED
#define __ACC_H_INCLUDED 1
#define ACC_VERSION 20170301L
#define ACC_VERSION 20220904L
#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
# define __CYGWIN__ __CYGWIN32__
#endif
@@ -52,6 +52,8 @@
# error "__cplusplus"
# elif (__cplusplus < 199711L)
# define ACC_LANG_CXX 1
# elif (__cplusplus >= 201402L)
# define ACC_LANG_CXX __cplusplus
# elif defined(_MSC_VER) && defined(_MSVC_LANG) && (_MSVC_LANG+0 >= 201402L) && 1
# define ACC_LANG_CXX _MSVC_LANG
# else
@@ -66,6 +68,33 @@
# endif
#endif
#endif
#if defined(ACC_CFG_ASSERT_LANG_ASSEMBLER) && (ACC_CFG_ASSERT_LANG_ASSEMBLER+0)
# if !(ACC_LANG_ASSEMBLER)
# error "ACC_CFG_ASSERT_LANG_ASSEMBLER"
# endif
# if (ACC_CFG_ASSERT_LANG_ASSEMBLER > 1) && (ACC_CFG_ASSERT_LANG_ASSEMBLER < ACC_LANG_ASSEMBLER)
# error "ACC_CFG_ASSERT_LANG_ASSEMBLER standard min version"
# endif
#endif
#if defined(ACC_CFG_ASSERT_LANG_C) && (ACC_CFG_ASSERT_LANG_C+0)
# if !(ACC_LANG_C)
# error "ACC_CFG_ASSERT_LANG_C"
# endif
# if (ACC_CFG_ASSERT_LANG_C > 1) && (ACC_CFG_ASSERT_LANG_C < ACC_LANG_C)
# error "ACC_CFG_ASSERT_LANG_C standard min version"
# endif
#endif
#if defined(ACC_CFG_ASSERT_LANG_CXX) && (ACC_CFG_ASSERT_LANG_CXX+0)
# if !(ACC_LANG_CXX)
# error "ACC_CFG_ASSERT_LANG_CXX"
# endif
# if !defined(__cplusplus)
# error "ACC_CFG_ASSERT_LANG_CXX __cplusplus"
# endif
# if (ACC_CFG_ASSERT_LANG_CXX > 1) && (ACC_CFG_ASSERT_LANG_CXX < ACC_LANG_CXX)
# error "ACC_CFG_ASSERT_LANG_CXX standard min version"
# endif
#endif
#if !defined(ACC_CFG_NO_DISABLE_WUNDEF)
#if defined(__ARMCC_VERSION)
# pragma diag_suppress 193
@@ -406,6 +435,14 @@
# define ACC_EXTERN_C_BEGIN /*empty*/
# define ACC_EXTERN_C_END /*empty*/
#endif
#if !defined(ACC_nullptr)
#if defined(__cplusplus) && (__cplusplus-0 >= 201103L)
# define ACC_nullptr nullptr
#endif
#endif
#if !defined(ACC_nullptr)
# define ACC_nullptr NULL
#endif
#if !defined(__ACC_OS_OVERRIDE)
#if (ACC_OS_FREESTANDING)
# define ACC_INFO_OS "freestanding"
@@ -523,6 +560,9 @@
# if defined(_AIX) || defined(__AIX__) || defined(__aix__)
# define ACC_OS_POSIX_AIX 1
# define ACC_INFO_OS_POSIX "aix"
# elif defined(__DragonFly__)
# define ACC_OS_POSIX_DRAGONFLY 1
# define ACC_INFO_OS_POSIX "dragonfly"
# elif defined(__FreeBSD__)
# define ACC_OS_POSIX_FREEBSD 1
# define ACC_INFO_OS_POSIX "freebsd"
@@ -965,6 +1005,9 @@
#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
# define ACC_ARCH_MCS51 1
# define ACC_INFO_ARCH "mcs51"
#elif defined(__microblaze__) || defined(__MICROBLAZE__)
# define ACC_ARCH_MICROBLAZE 1
# define ACC_INFO_ARCH "microblaze"
#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
# define ACC_ARCH_MIPS 1
# define ACC_INFO_ARCH "mips"
@@ -1563,7 +1606,7 @@ extern "C" {
#endif
#if !defined(ACC_UNUSED_LABEL)
# if (ACC_CC_CLANG >= 0x020800ul)
# define ACC_UNUSED_LABEL(l) (__acc_gnuc_extension__ ((void) ((const void *) &&l)))
# define ACC_UNUSED_LABEL(l) (__acc_gnuc_extension__ ((void) ACC_STATIC_CAST(const void *, &&l)))
# elif (ACC_CC_ARMCC || ACC_CC_CLANG || ACC_CC_INTELC || ACC_CC_WATCOMC)
# define ACC_UNUSED_LABEL(l) if __acc_cte(0) goto l
# else
@@ -1639,7 +1682,11 @@ extern "C" {
# define __acc_forceinline __acc_inline
#endif
#if !defined(__acc_noinline)
#if 1 && (ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x040000ul) && (ACC_CC_GNUC < 0x040003ul)
#if (ACC_CC_GNUC >= 0x080000ul)
# define __acc_noinline __attribute__((__noinline__,__noipa__))
#elif (ACC_CC_GNUC >= 0x050000ul)
# define __acc_noinline __attribute__((__noinline__,__noclone__,__no_icf__))
#elif 1 && (ACC_ARCH_I386) && (ACC_CC_GNUC >= 0x040000ul) && (ACC_CC_GNUC < 0x040003ul)
# define __acc_noinline __attribute__((__noinline__,__used__))
#elif (ACC_CC_GNUC >= 0x030200ul)
# define __acc_noinline __attribute__((__noinline__))
@@ -2040,7 +2087,11 @@ extern "C" {
#endif
#endif
#if !defined(ACC_COMPILE_TIME_ASSERT_HEADER)
# if (ACC_CC_AZTECC || ACC_CC_ZORTECHC)
# if (ACC_LANG_CXX >= 201103L)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) static_assert(e, #e);
# elif (ACC_LANG_C >= 201112L)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) _Static_assert(e, #e);
# elif (ACC_CC_AZTECC || ACC_CC_ZORTECHC)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) ACC_EXTERN_C_BEGIN extern int __ACC_CTA_NAME(acc_cta__)[1-!(e)]; ACC_EXTERN_C_END
# elif (ACC_CC_DMC || ACC_CC_SYMANTECC)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) ACC_EXTERN_C_BEGIN extern int __ACC_CTA_NAME(acc_cta__)[1u-2*!(e)]; ACC_EXTERN_C_END
@@ -2055,7 +2106,11 @@ extern "C" {
# endif
#endif
#if !defined(ACC_COMPILE_TIME_ASSERT)
# if (ACC_CC_AZTECC)
# if (ACC_LANG_CXX >= 201103L)
# define ACC_COMPILE_TIME_ASSERT(e) {static_assert(e, #e);}
# elif (ACC_LANG_C >= 201112L)
# define ACC_COMPILE_TIME_ASSERT(e) {_Static_assert(e, #e);}
# elif (ACC_CC_AZTECC)
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __ACC_CTA_NAME(acc_cta_t__)[1-!(e)];}
# elif (ACC_CC_CLANG && (ACC_CC_CLANG >= 0x030000ul))
# define ACC_COMPILE_TIME_ASSERT(e) {typedef int __ACC_CTA_NAME(acc_cta_t__)[1-2*!(e)] __attribute__((__unused__));}
@@ -2378,7 +2433,9 @@ ACC_COMPILE_TIME_ASSERT_HEADER(ACC_SIZEOF_LONG == sizeof(long))
# define ACC_WORDSIZE 4
#elif (ACC_ARCH_Z80)
# define ACC_WORDSIZE 1
#elif (ACC_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
#elif (ACC_ARCH_MIPS) && (ACC_SIZEOF_LONG == 8) && (defined(__R5900) || defined(__MIPS_PSX2__))
# define ACC_WORDSIZE 8
#elif (ACC_ARCH_MIPS) && (ACC_SIZEOF_LONG == 4) && defined(__mips64) && defined(_MIPS_SIM) && defined(_ABIN32) && (_MIPS_SIM+0 == _ABIN32+0)
# define ACC_WORDSIZE 8
#elif (ACC_OS_OS400 || defined(__OS400__))
# define ACC_WORDSIZE 8
@@ -2780,6 +2837,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER(ACC_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# endif
#elif (ACC_ARCH_RISCV)
# define ACC_OPT_AVOID_UINT_INDEX 1
# if 0
# ifndef ACC_OPT_UNALIGNED16
# define ACC_OPT_UNALIGNED16 1
# endif
@@ -2791,6 +2849,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER(ACC_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
# define ACC_OPT_UNALIGNED64 1
# endif
# endif
# endif
#elif (ACC_ARCH_S390)
# ifndef ACC_OPT_UNALIGNED16
# define ACC_OPT_UNALIGNED16 1
@@ -3377,7 +3436,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(acc_int_fast64_t) == sizeof(acc_uint_fast6
#if (ACC_OS_POSIX)
# if (ACC_OS_POSIX_AIX)
# define HAVE_SYS_RESOURCE_H 1
# elif (ACC_OS_POSIX_DARWIN || ACC_OS_POSIX_FREEBSD || ACC_OS_POSIX_NETBSD || ACC_OS_POSIX_OPENBSD)
# elif (ACC_OS_POSIX_DARWIN || ACC_OS_POSIX_DRAGONFLY || ACC_OS_POSIX_FREEBSD || ACC_OS_POSIX_NETBSD || ACC_OS_POSIX_OPENBSD)
# define HAVE_STRINGS_H 1
# undef HAVE_MALLOC_H
# elif (ACC_OS_POSIX_HPUX || ACC_OS_POSIX_INTERIX)
@@ -3793,7 +3852,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(acc_int_fast64_t) == sizeof(acc_uint_fast6
# if (ACC_CC_GNUC < 0x025f00ul)
# undef HAVE_SNPRINTF
# undef HAVE_VSNPRINTF
# else
# elif 0
# define snprintf _snprintf
# define vsnprintf _vsnprintf
# endif
@@ -4735,6 +4794,8 @@ void __ACC_UA_SET_LE32(__acc_ua_volatile void* pp, unsigned long v) {
#define __ACC_FALLBACK_STDDEF_H_INCLUDED 1
#if defined(__PTRDIFF_TYPE__)
typedef __PTRDIFF_TYPE__ acc_fallback_ptrdiff_t;
#elif defined(_WIN64)
typedef long long acc_fallback_ptrdiff_t;
#elif defined(__MIPS_PSX2__)
typedef int acc_fallback_ptrdiff_t;
#else
@@ -4742,8 +4803,10 @@ typedef long acc_fallback_ptrdiff_t;
#endif
#if defined(__SIZE_TYPE__)
typedef __SIZE_TYPE__ acc_fallback_size_t;
#elif defined(_WIN64)
typedef unsigned long long acc_fallback_ptrdiff_t;
#elif defined(__MIPS_PSX2__)
typedef unsigned int acc_fallback_size_t;
typedef unsigned acc_fallback_size_t;
#else
typedef unsigned long acc_fallback_size_t;
#endif
@@ -4766,7 +4829,9 @@ typedef unsigned short wchar_t;
#endif
#endif
#ifndef NULL
#if defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ >= 4)
#if defined(__cplusplus) && (__cplusplus-0 >= 201103L)
#define NULL nullptr
#elif defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ >= 4)
#define NULL __null
#elif defined(__cplusplus)
#define NULL 0
@@ -4775,7 +4840,7 @@ typedef unsigned short wchar_t;
#endif
#endif
#ifndef offsetof
#define offsetof(s,m) ((size_t)((ptrdiff_t)&(((s*)0)->m)))
#define offsetof(s,m) ((size_t)((ptrdiff_t)&(((s*)NULL)->m)))
#endif
#endif
#elif (ACC_LIBC_FREESTANDING)
@@ -5489,7 +5554,7 @@ ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * a
#if defined(ACC_CXX_TRIGGER_FUNCTION_IMPL)
#else
# define ACC_CXX_TRIGGER_FUNCTION_IMPL(klass) \
const void* klass::acc_cxx_trigger_function() const { return ACC_STATIC_CAST(const void *, 0); }
const void* klass::acc_cxx_trigger_function() const { return ACC_STATIC_CAST(const void *, ACC_nullptr); }
#endif
#endif
#endif
@@ -5689,8 +5754,8 @@ ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * a
ACCCHK_ASSERT(sizeof(short) == ACC_SIZEOF_SHORT)
#endif
ACCCHK_ASSERT_IS_SIGNED_T(int)
ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned int)
ACCCHK_ASSERT(sizeof(int) == sizeof(unsigned int))
ACCCHK_ASSERT_IS_UNSIGNED_T(unsigned)
ACCCHK_ASSERT(sizeof(int) == sizeof(unsigned))
#if !(ACC_ABI_I8LP16)
ACCCHK_ASSERT(sizeof(int) >= 2)
#endif
@@ -5724,7 +5789,11 @@ ACCLIB_EXTERN(int, acc_spawnve) (int mode, const char* fn, const char* const * a
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(int))
ACCCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t))
#if !(ACC_BROKEN_SIZEOF)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(ACC_STATIC_CAST(char*, 0) - ACC_STATIC_CAST(char*, 0)))
#if (ACC_CC_CLANG) && !defined(__cplusplus)
ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(ACC_REINTERPRET_CAST(char*, 1) - ACC_REINTERPRET_CAST(char*, 1)))
#else
ACCCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(ACC_STATIC_CAST(char*, ACC_nullptr) - ACC_STATIC_CAST(char*, ACC_nullptr)))
#endif
# if (ACC_HAVE_MM_HUGE_PTR)
ACCCHK_ASSERT(4 == sizeof(ACC_STATIC_CAST(char __huge*, 0) - ACC_STATIC_CAST(char __huge*, 0)))
# endif
@@ -6269,13 +6338,13 @@ ACCLIB_PUBLIC(void, acc_ua_set_le64) (acc_hvoid_p p, acc_uint64l_t v)
#endif
extern void* volatile acc_vget_ptr__;
#if (ACC_CC_CLANG || (ACC_CC_GNUC >= 0x030400ul) || ACC_CC_LLVM)
void* volatile __attribute__((__used__)) acc_vget_ptr__ = ACC_STATIC_CAST(void *, 0);
void* volatile __attribute__((__used__)) acc_vget_ptr__ = ACC_STATIC_CAST(void *, ACC_nullptr);
#else
void* volatile acc_vget_ptr__ = ACC_STATIC_CAST(void *, 0);
void* volatile acc_vget_ptr__ = ACC_STATIC_CAST(void *, ACC_nullptr);
#endif
#ifndef __ACCLIB_VGET_BODY
#define __ACCLIB_VGET_BODY(T) \
if __acc_unlikely(acc_vget_ptr__) { \
if __acc_very_unlikely(acc_vget_ptr__) { \
typedef T __acc_may_alias TT; \
unsigned char e; expr &= 255; e = ACC_STATIC_CAST(unsigned char, expr); \
* ACC_STATIC_CAST(TT *, acc_vget_ptr__) = v; \
@@ -6690,33 +6759,29 @@ static int __ACCLIB_FUNCNAME(acc_getopt_rotate) (char** p, int first, int middle
{
int i = middle, n = middle - first;
if (first >= middle || middle >= last) return 0;
for (;;)
{
char* t = p[first]; p[first] = p[i]; p[i] = t;
if (++first == middle)
{
if (++i == last) break;
for (;;) {
char *t = p[first]; p[first++] = p[i]; p[i++] = t;
if (first == middle) {
if (i == last) break;
middle = i;
}
else if (++i == last)
} else if (i == last)
i = middle;
}
return n;
}
static int __ACCLIB_FUNCNAME(acc_getopt_perror) (acc_getopt_p g, int ret, const char *f, ...)
{
if (g->opterr)
{
#if (HAVE_STDARG_H)
++g->errcount;
if (g->opterr) {
#if defined(HAVE_STDARG_H) && (HAVE_STDARG_H)
struct { va_list ap; } s;
va_start(s.ap, f);
g->opterr(g, f, &s);
va_end(s.ap);
#else
g->opterr(g, f, NULL);
g->opterr(g, f, ACC_nullptr);
#endif
}
++g->errcount;
return ret;
}
ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
@@ -6728,14 +6793,13 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
int ordering = ACC_GETOPT_PERMUTE;
int missing_arg_ret = g->bad_option;
char *a;
if (shortopts)
{
if (shortopts) {
if (*shortopts == '-' || *shortopts == '+')
ordering = *shortopts++ == '-' ? ACC_GETOPT_RETURN_IN_ORDER : ACC_GETOPT_REQUIRE_ORDER;
if (*shortopts == ':')
missing_arg_ret = *shortopts++;
}
g->optarg = NULL;
g->optarg = ACC_nullptr;
if (g->optopt == -1)
g->optopt = g->bad_option;
if (longind)
@@ -6746,36 +6810,34 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
goto acc_label_next_shortopt;
g->optind -= __ACCLIB_FUNCNAME(acc_getopt_rotate)(g->argv, g->pending_rotate_first, g->pending_rotate_middle, g->optind);
g->pending_rotate_first = g->pending_rotate_middle = g->optind;
if (ordering == ACC_GETOPT_PERMUTE)
{
if (ordering == ACC_GETOPT_PERMUTE) {
while (g->optind < g->argc && !(g->argv[g->optind][0] == '-' && g->argv[g->optind][1]))
++g->optind;
g->pending_rotate_middle = g->optind;
}
if (g->optind >= g->argc)
{
if (g->optind >= g->argc) {
g->optind = g->pending_rotate_first;
goto acc_label_eof;
}
a = g->argv[g->optind];
if (a[0] == '-' && a[1] == '-')
{
if (a[0] == '-' && a[1] == '-') {
size_t l = 0;
const acc_getopt_longopt_p o;
const acc_getopt_longopt_p o1 = NULL;
const acc_getopt_longopt_p o2 = NULL;
const acc_getopt_longopt_p o1 = ACC_nullptr;
const acc_getopt_longopt_p o2 = ACC_nullptr;
int need_exact = 0;
++g->optind;
if (!a[2])
goto acc_label_eof;
for (a += 2; a[l] && a[l] != '=' && a[l] != '#'; )
++l;
for (o = longopts; l && o && o->name; ++o)
{
for (o = longopts; l && o && o->name; ++o) {
if (strncmp(a, o->name, l) != 0)
continue;
if (!o->name[l])
goto acc_label_found_o;
if ((o->has_arg & (ACC_GETOPT_EXACT_ARG | 0x80)) == (ACC_GETOPT_EXACT_ARG | 0x80))
continue;
need_exact |= o->has_arg & ACC_GETOPT_EXACT_ARG;
if (o1) o2 = o;
else o1 = o;
@@ -6787,8 +6849,7 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
o = o1;
acc_label_found_o:
a += l;
switch (o->has_arg & 0x2f)
{
switch (o->has_arg & 0x2f) {
case ACC_GETOPT_OPTIONAL_ARG:
if (a[0])
g->optarg = a + 1;
@@ -6798,7 +6859,7 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
g->optarg = a + 1;
else if (g->optind < g->argc)
g->optarg = g->argv[g->optind++];
if (!g->optarg)
if (!g->optarg || (!g->optarg[0] && (o->has_arg & 0x40)))
return pe(g, missing_arg_ret, "option '--%s' requires an argument", o->name);
break;
case ACC_GETOPT_REQUIRED_ARG | 0x20:
@@ -6814,43 +6875,35 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
}
if (longind)
*longind = (int) (o - longopts);
if (o->flag)
{
if (o->flag) {
*o->flag = o->val;
return 0;
}
return o->val;
}
if (a[0] == '-' && a[1])
{
if (a[0] == '-' && a[1]) {
unsigned char c;
const char *s;
acc_label_next_shortopt:
a = g->argv[g->optind] + ++g->shortpos;
c = (unsigned char) *a++; s = NULL;
c = (unsigned char) *a++; s = ACC_nullptr;
if (c != ':' && shortopts)
s = strchr(shortopts, c);
if (!s || s[1] != ':')
{
if (!s || s[1] != ':') {
if (!a[0])
{ ++g->optind; g->shortpos = 0; }
if (!s)
{
if (!s) {
g->optopt = c;
return pe(g, g->bad_option, "invalid option '-%c'", c);
}
}
else
{
} else {
++g->optind; g->shortpos = 0;
if (a[0])
g->optarg = a;
else if (s[2] != ':')
{
else if (s[2] != ':') {
if (g->optind < g->argc)
g->optarg = g->argv[g->optind++];
else
{
else {
g->optopt = c;
return pe(g, missing_arg_ret, "option '-%c' requires an argument", c);
}
@@ -6858,10 +6911,9 @@ ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
}
return c;
}
if (ordering == ACC_GETOPT_RETURN_IN_ORDER)
{
++g->optind;
if (ordering == ACC_GETOPT_RETURN_IN_ORDER) {
g->optarg = a;
++g->optind;
return 1;
}
acc_label_eof:
@@ -6913,13 +6965,13 @@ ACC_EXTERN_C int __far __pascal GlobalUnlock(const void __near*);
#endif
ACCLIB_PUBLIC(acc_hvoid_p, acc_halloc) (acc_hsize_t size)
{
acc_hvoid_p p = ACC_STATIC_CAST(acc_hvoid_p, 0);
acc_hvoid_p p = ACC_STATIC_CAST(acc_hvoid_p, ACC_nullptr);
if (!(size > 0))
return p;
#if 0 && defined(__palmos__)
p = MemPtrNew(size);
#elif !(ACC_HAVE_MM_HUGE_PTR)
if (size < ACC_STATIC_CAST(size_t, -1))
if (size < (~(ACC_STATIC_CAST(size_t, 0)) & ~(ACC_STATIC_CAST(acc_hsize_t, 0))))
p = malloc(ACC_STATIC_CAST(size_t, size));
#else
if (ACC_STATIC_CAST(long, size) <= 0)
@@ -7169,6 +7221,7 @@ ACCLIB_PUBLIC(long, acc_safe_hwrite) (int fd, const acc_hvoid_p buf, long size)
__acc_static_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
{
unsigned long r = 228;
ACC_COMPILE_TIME_ASSERT(sizeof(*ts) == 16);
__asm__ __volatile__("syscall\n" : "=a" (r), "=m" (*ts) : "0" (r), "D" (clockid), "S" (ts) __ACC_ASM_CLOBBER_LIST_CC);
return ACC_ICAST(long, r);
}
@@ -7179,7 +7232,7 @@ __acc_static_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct
#endif
__acc_static_noinline long acc_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
{
unsigned long r = 265;
unsigned long r = 265 + ((sizeof(*ts) > 8) * (403 - 265));
__asm__ __volatile__("pushl %%ebx\n pushl %%edx\n popl %%ebx\n int $0x80\n popl %%ebx\n": "=a" (r), "=m" (*ts) : "0" (r), "d" (clockid), "c" (ts) __ACC_ASM_CLOBBER_LIST_CC);
return ACC_ICAST(long, r);
}
@@ -7205,7 +7258,7 @@ static int acc_pclock_read_clock_gettime_r_syscall(acc_pclock_handle_p h, acc_pc
static int acc_pclock_read_gettimeofday(acc_pclock_handle_p h, acc_pclock_p c)
{
struct timeval tv;
if (gettimeofday(&tv, NULL) != 0)
if (gettimeofday(&tv, ACC_nullptr) != 0)
return -1;
#if defined(acc_int64l_t)
c->tv_sec = tv.tv_sec;
@@ -7352,7 +7405,7 @@ static int acc_pclock_read_clock_gettime_t_libc(acc_pclock_handle_p h, acc_pcloc
if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0)
return -1;
c->tv_sec = ts.tv_sec;
c->tv_nsec = (acc_uint32l_t) ts.tv_nsec;
c->tv_nsec = ACC_STATIC_CAST(acc_uint32l_t, ts.tv_nsec);
ACC_UNUSED(h); return 0;
}
#endif
@@ -7398,8 +7451,8 @@ ACCLIB_PUBLIC(int, acc_pclock_open) (acc_pclock_handle_p h, int mode)
h->h = ACC_STATIC_CAST(acclib_handle_t, 0);
h->mode = -1;
h->read_error = 2;
h->name = NULL;
h->gettime = ACC_STATIC_CAST(acc_pclock_gettime_t, 0);
h->name = ACC_nullptr;
h->gettime = ACC_STATIC_CAST(acc_pclock_gettime_t, ACC_nullptr);
#if defined(acc_int64l_t)
h->ticks_base = 0;
#endif
@@ -7526,8 +7579,8 @@ ACCLIB_PUBLIC(int, acc_pclock_close) (acc_pclock_handle_p h)
{
h->h = ACC_STATIC_CAST(acclib_handle_t, 0);
h->mode = -1;
h->name = NULL;
h->gettime = ACC_STATIC_CAST(acc_pclock_gettime_t, 0);
h->name = ACC_nullptr;
h->gettime = ACC_STATIC_CAST(acc_pclock_gettime_t, ACC_nullptr);
return 0;
}
ACCLIB_PUBLIC(void, acc_pclock_read) (acc_pclock_handle_p h, acc_pclock_p c)
+18 -18
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -55,7 +55,7 @@ void printClearLine(FILE *f)
}
fflush(stdout); fflush(stderr);
if (f == NULL)
if (f == nullptr)
f = stdout;
con_fprintf(f, "%s", clear_line_msg);
fflush(f);
@@ -91,10 +91,10 @@ static void pr_error(const char *iname, const char *msg, bool is_warning)
bool c = acc_isatty(STDERR_FILENO) ? 1 : 0;
int fg = con_fg(stderr,FG_BRTRED);
upx_snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"%s: ", progname);
snprintf(buf+strlen(buf),sizeof(buf)-strlen(buf),"%s: ", progname);
pr_print(c,buf);
//(void)con_fg(stderr,FG_RED);
upx_snprintf(buf,sizeof(buf),"%s: ", iname);
snprintf(buf,sizeof(buf),"%s: ", iname);
pr_print(c,buf);
//(void)con_fg(stderr,FG_BRTRED);
pr_print(c,msg);
@@ -112,13 +112,13 @@ void printErr(const char *iname, const Throwable *e)
char buf[1024];
size_t l;
upx_snprintf(buf, sizeof(buf), "%s", prettyName(typeid(*e).name()));
snprintf(buf, sizeof(buf), "%s", prettyName(typeid(*e).name()));
l = strlen(buf);
if (l < sizeof(buf) && e->getMsg())
upx_snprintf(buf+l, sizeof(buf)-l, ": %s", e->getMsg());
snprintf(buf+l, sizeof(buf)-l, ": %s", e->getMsg());
l = strlen(buf);
if (l < sizeof(buf) && e->getErrno()) {
upx_snprintf(buf+l, sizeof(buf)-l, ": %s", strerror(e->getErrno()));
snprintf(buf+l, sizeof(buf)-l, ": %s", strerror(e->getErrno()));
#if 1
// some compilers (e.g. Borland C++) put a trailing '\n'
// into strerror() result
@@ -131,26 +131,26 @@ void printErr(const char *iname, const Throwable *e)
}
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
void printErr(const char *iname, const char *format, ...)
{
va_list args;
char buf[1024];
va_start(args,format);
upx_vsnprintf(buf,sizeof(buf),format,args);
upx_safe_vsnprintf(buf,sizeof(buf),format,args);
va_end(args);
pr_error(iname,buf,false);
}
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
void printWarn(const char *iname, const char *format, ...)
{
va_list args;
char buf[1024];
va_start(args,format);
upx_vsnprintf(buf,sizeof(buf),format,args);
upx_safe_vsnprintf(buf,sizeof(buf),format,args);
va_end(args);
pr_error(iname,buf,true);
@@ -201,21 +201,21 @@ void infoHeader()
info_header = 0;
}
void __acc_cdecl_va infoHeader(const char *format, ...)
void infoHeader(const char *format, ...)
{
if (opt->info_mode <= 0)
return;
va_list args;
char buf[1024];
va_start(args,format);
upx_vsnprintf(buf,sizeof(buf),format,args);
upx_safe_vsnprintf(buf,sizeof(buf),format,args);
va_end(args);
info_print(buf);
info_header = 1;
}
void __acc_cdecl_va info(const char *format, ...)
void info(const char *format, ...)
{
if (opt->info_mode <= 0)
return;
@@ -224,13 +224,13 @@ void __acc_cdecl_va info(const char *format, ...)
const int n = 4 * info_header;
memset(buf, ' ', n);
va_start(args,format);
upx_vsnprintf(buf+n,sizeof(buf)-n,format,args);
upx_safe_vsnprintf(buf+n,sizeof(buf)-n,format,args);
va_end(args);
info_print(buf);
}
void __acc_cdecl_va infoWarning(const char *format, ...)
void infoWarning(const char *format, ...)
{
if (opt->info_mode <= 0)
{
@@ -240,7 +240,7 @@ void __acc_cdecl_va infoWarning(const char *format, ...)
va_list args;
char buf[1024];
va_start(args,format);
upx_vsnprintf(buf,sizeof(buf),format,args);
upx_safe_vsnprintf(buf,sizeof(buf),format,args);
va_end(args);
info("[WARNING] %s\n", buf);
}
+148
View File
@@ -0,0 +1,148 @@
/* options.cpp --
This file is part of the UPX executable compressor.
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
and/or modify them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer Laszlo Molnar
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#include "conf.h"
/*************************************************************************
// options
**************************************************************************/
void options_t::reset() {
options_t *o = this;
mem_clear(o, sizeof(*o));
o->crp.reset();
o->cmd = CMD_NONE;
o->method = M_NONE;
o->level = -1;
o->filter = FT_NONE;
o->backup = -1;
o->overlay = -1;
o->preserve_mode = true;
o->preserve_ownership = true;
o->preserve_timestamp = true;
o->console = CON_FILE;
#if (ACC_OS_DOS32) && defined(__DJGPP__)
o->console = CON_INIT;
#elif (USE_SCREEN_WIN32)
o->console = CON_INIT;
#elif 1 && defined(__linux__)
o->console = CON_INIT;
#endif
o->verbose = 2;
opt->o_unix.osabi0 = 3; // 3 == ELFOSABI_LINUX
o->win32_pe.compress_exports = 1;
o->win32_pe.compress_icons = 2;
o->win32_pe.compress_resources = -1;
for (unsigned i = 0; i < TABLESIZE(o->win32_pe.compress_rt); i++)
o->win32_pe.compress_rt[i] = -1;
o->win32_pe.compress_rt[24] = false; // 24 == RT_MANIFEST
o->win32_pe.strip_relocs = -1;
o->win32_pe.keep_resource = "";
}
static options_t global_options;
options_t *opt = &global_options;
/*************************************************************************
//
**************************************************************************/
template <size_t N>
static inline void test_options(const char *(&a)[N]) {
(void) main_get_options((int) (N - 1), ACC_UNCONST_CAST(char **, a));
}
TEST_CASE("getopt") {
options_t *saved_opt = opt;
options_t local_options;
opt = &local_options;
opt->reset();
opt->debug.getopt_throw_instead_of_exit = true;
static const char a0[] = "<argv0>";
SUBCASE("issue 587") {
const char *a[] = {a0, "--brute", "--lzma", nullptr};
test_options(a);
CHECK(opt->all_methods);
CHECK(opt->all_methods_use_lzma == 1);
}
SUBCASE("issue 587") {
const char *a[] = {a0, "--lzma", "--brute", nullptr};
test_options(a);
CHECK(opt->all_methods);
CHECK(opt->all_methods_use_lzma == 1);
}
SUBCASE("issue 587") {
const char *a[] = {a0, "--brute", "--no-lzma", nullptr};
test_options(a);
CHECK(opt->all_methods);
CHECK(opt->all_methods_use_lzma == -1);
}
SUBCASE("issue 587") {
const char *a[] = {a0, "--no-lzma", "--brute", nullptr};
test_options(a);
CHECK(opt->all_methods);
CHECK(opt->all_methods_use_lzma == -1);
}
SUBCASE("issue 587") {
const char *a[] = {a0, "--no-lzma", "--lzma", nullptr};
test_options(a);
CHECK(!opt->all_methods);
CHECK(opt->all_methods_use_lzma == 1);
CHECK(opt->method == M_LZMA);
}
SUBCASE("issue 587") {
const char *a[] = {a0, "--no-lzma", "--lzma", "--brute", nullptr};
test_options(a);
CHECK(opt->all_methods);
CHECK(opt->all_methods_use_lzma == 1);
CHECK(opt->method == -1);
}
SUBCASE("issue 587") {
const char *a[] = {a0, "--lzma", "--no-lzma", nullptr};
test_options(a);
CHECK(!opt->all_methods);
CHECK(opt->all_methods_use_lzma == -1);
CHECK(opt->method == -1);
}
SUBCASE("issue 587") {
const char *a[] = {a0, "--lzma", "--no-lzma", "--brute", nullptr};
test_options(a);
CHECK(opt->all_methods);
CHECK(opt->all_methods_use_lzma == -1);
CHECK(opt->method == -1);
}
opt = saved_opt;
}
/* vim:set ts=4 sw=4 et: */
+22 -22
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -25,10 +25,9 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
#ifndef __UPX_OPTIONS_H
#define __UPX_OPTIONS_H 1
#pragma once
#ifndef UPX_OPTIONS_H__
#define UPX_OPTIONS_H__ 1
/*************************************************************************
// globals
@@ -37,19 +36,19 @@
// options - command
enum {
CMD_NONE,
CMD_COMPRESS, CMD_DECOMPRESS, CMD_TEST, CMD_LIST, CMD_FILEINFO,
CMD_HELP, CMD_LICENSE, CMD_VERSION
CMD_COMPRESS,
CMD_DECOMPRESS,
CMD_TEST,
CMD_LIST,
CMD_FILEINFO,
CMD_HELP,
CMD_LICENSE,
CMD_VERSION
};
struct options_t {
int cmd;
// mp (meta) options
int mp_compress_task;
bool mp_query_format;
bool mp_query_num_tasks;
// compression options
int method;
bool method_lzma_seen;
@@ -60,7 +59,7 @@ struct options_t {
int filter; // preferred filter from Packer::getFilters()
bool ultra_brute;
bool all_methods; // try all available compression methods ?
bool all_methods_use_lzma;
int all_methods_use_lzma;
bool all_filters; // try all available filters ?
bool no_filter; // force no filter
bool prefer_ucl; // prefer UCL
@@ -89,14 +88,11 @@ struct options_t {
const char *dump_stub_loader;
char fake_stub_version[4 + 1]; // for internal debugging
char fake_stub_year[4 + 1]; // for internal debugging
bool getopt_throw_instead_of_exit; // for doctest
} debug;
// overlay handling
enum {
SKIP_OVERLAY = 0,
COPY_OVERLAY = 1,
STRIP_OVERLAY = 2
};
enum { SKIP_OVERLAY = 0, COPY_OVERLAY = 1, STRIP_OVERLAY = 2 };
int overlay;
// compression runtime parameters - see struct XXX_compress_config_t
@@ -104,7 +100,11 @@ struct options_t {
lzma_compress_config_t crp_lzma;
ucl_compress_config_t crp_ucl;
zlib_compress_config_t crp_zlib;
void reset() { crp_lzma.reset(); crp_ucl.reset(); crp_zlib.reset(); }
void reset() {
crp_lzma.reset();
crp_ucl.reset();
crp_zlib.reset();
}
};
crp_t crp;
@@ -147,6 +147,7 @@ struct options_t {
unsigned char osabi0; // replacement if 0==.e_ident[EI_OSABI]
bool preserve_build_id; // copy the build-id to the compressed binary
bool android_shlib; // keep some ElfXX_Shdr for dlopen()
bool force_pie; // choose DF_1_PIE instead of is_shlib
} o_unix;
struct {
bool le;
@@ -165,7 +166,6 @@ struct options_t {
extern struct options_t *opt;
#endif /* already included */
/* vim:set ts=4 sw=4 et: */
+19 -28
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -92,15 +92,6 @@ void PackArmPe::processImports2(unsigned myimport, unsigned iat_off) // pass 2
{
PeFile::processImports2(myimport, iat_off);
__packed_struct(import_desc)
LE32 oft; // orig first thunk
char _[8];
LE32 dllname;
LE32 iat; // import address table
__packed_struct_end()
COMPILE_TIME_ASSERT(sizeof(import_desc) == 20);
// adjust import data
for (import_desc *im = (import_desc*) oimpdlls; im->dllname; im++)
{
@@ -154,38 +145,38 @@ void PackArmPe::buildLoader(const Filter *ft)
initLoader(loader, size);
if (isdll)
addLoader("DllStart", NULL);
addLoader("ExeStart", NULL);
addLoader("DllStart", nullptr);
addLoader("ExeStart", nullptr);
if (ph.method == M_NRV2E_8)
addLoader("Call2E", NULL);
addLoader("Call2E", nullptr);
else if (ph.method == M_NRV2B_8)
addLoader("Call2B", NULL);
addLoader("Call2B", nullptr);
else if (ph.method == M_NRV2D_8)
addLoader("Call2D", NULL);
addLoader("Call2D", nullptr);
else if (M_IS_LZMA(ph.method))
addLoader("+40C,CallLZMA", NULL);
addLoader("+40C,CallLZMA", nullptr);
if (ft->id == 0x50)
addLoader("+40C,Unfilter_0x50", NULL);
addLoader("+40C,Unfilter_0x50", nullptr);
if (sorelocs)
addLoader("+40C,Relocs", NULL);
addLoader("+40C,Relocs", nullptr);
addLoader("+40C,Imports", NULL);
addLoader("ProcessEnd", NULL);
addLoader("+40C,Imports", nullptr);
addLoader("ProcessEnd", nullptr);
if (ph.method == M_NRV2E_8)
addLoader(".ucl_nrv2e_decompress_8", NULL);
addLoader(".ucl_nrv2e_decompress_8", nullptr);
else if (ph.method == M_NRV2B_8)
addLoader(".ucl_nrv2b_decompress_8", NULL);
addLoader(".ucl_nrv2b_decompress_8", nullptr);
else if (ph.method == M_NRV2D_8)
addLoader(".ucl_nrv2d_decompress_8", NULL);
addLoader(".ucl_nrv2d_decompress_8", nullptr);
else if (M_IS_LZMA(ph.method))
addLoader("+40C,LZMA_DECODE,LZMA_DEC10", NULL);
addLoader("+40C,LZMA_DECODE,LZMA_DEC10", nullptr);
addLoader("IDENTSTR,UPX1HEAD", NULL);
addLoader("IDENTSTR,UPX1HEAD", nullptr);
}
bool PackArmPe::handleForceOption()
@@ -206,7 +197,7 @@ void PackArmPe::callCompressWithFilters(Filter &ft, int filter_strategy, unsigne
upx_compress_config_t cconf; cconf.reset();
cconf.conf_lzma.max_num_probs = 1846 + (768 << 4); // ushort: ~28 KiB stack
compressWithFilters(&ft, 2048, &cconf, filter_strategy,
ih_codebase, rvamin, 0, NULL, 0);
ih_codebase, rvamin, 0, nullptr, 0);
}
void PackArmPe::addNewRelocations(Reloc &rel, unsigned upxsection)
@@ -256,7 +247,7 @@ void PackArmPe::setOhHeaderSize(const pe_section_t *osection)
void PackArmPe::pack(OutputFile *fo)
{
super::pack0(fo, 1U << 9, 0x10000, true);
super::pack0(fo, (1u<<IMAGE_SUBSYSTEM_WINDOWS_CE_GUI), 0x10000, true);
}
/* vim:set ts=4 sw=4 et: */
+23 -23
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -41,36 +41,36 @@ class PackArmPe : public PeFile32
public:
PackArmPe(InputFile *f);
virtual ~PackArmPe();
virtual int getFormat() const { return UPX_F_WINCE_ARM_PE; }
virtual const char *getName() const { return "arm/pe"; }
virtual const char *getFullName(const options_t *) const { return "arm-wince.pe"; }
virtual const int *getCompressionMethods(int method, int level) const;
virtual const int *getFilters() const;
virtual void defineFilterSymbols(const Filter *) {}
virtual int getFormat() const override { return UPX_F_WINCE_ARM_PE; }
virtual const char *getName() const override { return "arm/pe"; }
virtual const char *getFullName(const options_t *) const override { return "arm-wince.pe"; }
virtual const int *getCompressionMethods(int method, int level) const override;
virtual const int *getFilters() const override;
virtual void defineFilterSymbols(const Filter *) override {}
virtual bool handleForceOption();
virtual bool handleForceOption() override;
virtual void callCompressWithFilters(Filter &, int filter_strategy,
unsigned ih_codebase);
unsigned ih_codebase) override;
virtual void defineSymbols(unsigned ncsection, unsigned upxsection,
unsigned sizeof_oh, unsigned isize_isplit,
unsigned s1addr);
virtual void addNewRelocations(Reloc &, unsigned upxsection);
virtual unsigned getProcessImportParam(unsigned upxsection);
virtual void setOhDataBase(const pe_section_t *osection);
virtual void setOhHeaderSize(const pe_section_t *osection);
virtual void pack(OutputFile *fo);
unsigned s1addr) override;
virtual void addNewRelocations(Reloc &, unsigned upxsection) override;
virtual unsigned getProcessImportParam(unsigned upxsection) override;
virtual void setOhDataBase(const pe_section_t *osection) override;
virtual void setOhHeaderSize(const pe_section_t *osection) override;
virtual void pack(OutputFile *fo) override;
virtual bool canPack();
virtual bool canPack() override;
protected:
virtual void buildLoader(const Filter *ft);
virtual Linker* newLinker() const;
virtual void buildLoader(const Filter *ft) override;
virtual Linker* newLinker() const override;
virtual const char *kernelDll() const { return "COREDLL.dll"; }
virtual void processImports2(unsigned, unsigned);
virtual void addStubImports();
virtual const char *kernelDll() const override { return "COREDLL.dll"; }
virtual void processImports2(unsigned, unsigned) override;
virtual void addStubImports() override;
virtual void processTls(Interval *);
virtual void processTls(Interval *) override;
bool use_thumb_stub;
};
+9 -9
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -143,7 +143,7 @@ void PackCom::buildLoader(const Filter *ft)
"NRVDECO1",
ph.max_offset_found <= 0xd00 ? "NRVLED00" : "NRVGTD00",
"NRVDECO2",
NULL
nullptr
);
if (ft->id)
{
@@ -164,7 +164,7 @@ void PackCom::addFilter16(int filter_id)
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I086" : "CT16I286,CT16SUB0"),
"CALLTRI2",
getFormat() == UPX_F_DOS_COM ? "CORETURN" : "",
NULL
nullptr
);
else
addLoader(filter_id%3 == 1 ? "CT16E800" : "CT16E900",
@@ -173,7 +173,7 @@ void PackCom::addFilter16(int filter_id)
filter_id < 4 ? "CT16SUB1" : "",
filter_id < 4 ? "" : (opt->cpu == opt->CPU_8086 ? "CT16I087" : "CT16I287,CT16SUB1"),
"CALLTRI6",
NULL
nullptr
);
}
@@ -223,7 +223,7 @@ int PackCom::canUnpack()
{
if (!readPackHeader(128))
return false;
if (file_size <= (off_t) ph.c_len)
if (file_size_u <= ph.c_len)
return false;
return true;
}
@@ -236,15 +236,15 @@ int PackCom::canUnpack()
void PackCom::unpack(OutputFile *fo)
{
ibuf.alloc(file_size);
obuf.allocForUncompression(ph.u_len);
obuf.allocForDecompression(ph.u_len);
// read whole file
fi->seek(0,SEEK_SET);
fi->readx(ibuf,file_size);
// get compressed data offset
int e_len = ph.buf_offset + ph.getPackHeaderSize();
if (file_size <= e_len + (off_t)ph.c_len)
unsigned e_len = ph.buf_offset + ph.getPackHeaderSize();
if (file_size_u <= e_len + ph.c_len)
throwCantUnpack("file damaged");
// decompress
+15 -15
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -39,26 +39,26 @@ class PackCom : public Packer
typedef Packer super;
public:
PackCom(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
virtual int getVersion() const { return 13; }
virtual int getFormat() const { return UPX_F_DOS_COM; }
virtual const char *getName() const { return "dos/com"; }
//virtual const char *getFullName(const options_t *o) const { return o && o->cpu == o->CPU_8086 ? "i086-dos16.com" : "i286-dos16.com"; }
virtual const char *getFullName(const options_t *) const { return "i086-dos16.com"; }
virtual const int *getCompressionMethods(int method, int level) const;
virtual const int *getFilters() const;
virtual int getVersion() const override { return 13; }
virtual int getFormat() const override { return UPX_F_DOS_COM; }
virtual const char *getName() const override { return "dos/com"; }
//virtual const char *getFullName(const options_t *o) const override { return o && o->cpu == o->CPU_8086 ? "i086-dos16.com" : "i286-dos16.com"; }
virtual const char *getFullName(const options_t *) const override { return "i086-dos16.com"; }
virtual const int *getCompressionMethods(int method, int level) const override;
virtual const int *getFilters() const override;
virtual void pack(OutputFile *fo);
virtual void unpack(OutputFile *fo);
virtual void pack(OutputFile *fo) override;
virtual void unpack(OutputFile *fo) override;
virtual bool canPack();
virtual int canUnpack();
virtual bool canPack() override;
virtual int canUnpack() override;
protected:
virtual unsigned getCallTrickOffset() const { return 0x100; }
virtual Linker* newLinker() const;
virtual Linker* newLinker() const override;
protected:
virtual void buildLoader(const Filter *ft);
virtual void buildLoader(const Filter *ft) override;
virtual void patchLoader(OutputFile *fo, upx_byte *, int, unsigned);
virtual void addFilter16(int filter_id);
};
+31 -18
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -103,15 +103,15 @@ void PackDjgpp2::buildLoader(const Filter *ft)
getDecompressorSections(),
M_IS_LZMA(ph.method) ? "LZMA_DONE_STACK" : "",
"DJ2BSS00",
NULL
nullptr
);
if (ft->id)
{
assert(ft->calls > 0);
addLoader("DJCALLT2", NULL);
addLoader("DJCALLT2", nullptr);
addFilter32(ft->id);
}
addLoader("DJRETURN,+40C,UPX1HEAD", NULL);
addLoader("DJRETURN,+40C,UPX1HEAD", nullptr);
}
@@ -161,24 +161,25 @@ static bool is_dlm(InputFile *fi, unsigned coff_offset)
static void handle_allegropak(InputFile *fi, OutputFile *fo)
{
unsigned char buf[0x4000];
unsigned char b[8];
int pfsize = 0;
try {
fi->seek(-8, SEEK_END);
fi->readx(buf, 8);
if (memcmp(buf, "slh+", 4) != 0)
fi->readx(b, 8);
if (memcmp(b, "slh+", 4) != 0)
return;
pfsize = get_be32_signed(buf+4);
if (pfsize <= 8 || pfsize >= (off_t) fi->st.st_size)
pfsize = get_be32_signed(b+4);
if (pfsize <= 8 || pfsize >= fi->st.st_size)
return;
fi->seek(-(off_t)pfsize, SEEK_END);
fi->seek(-pfsize, SEEK_END);
} catch (const IOException&) {
return;
}
MemBuffer buf(0x4000);
while (pfsize > 0)
{
const int len = UPX_MIN(pfsize, (int)sizeof(buf));
const int len = UPX_MIN(pfsize, (int)buf.getSize());
fi->readx(buf, len);
fo->write(buf, len);
pfsize -= len;
@@ -250,14 +251,25 @@ bool PackDjgpp2::canPack()
if (opt->force == 0)
if (text->size != coff_hdr.a_tsize || data->size != coff_hdr.a_dsize)
throwAlreadyPacked();
// Check for gap in vaddr between text and data, or between data and bss.
if (text->vaddr + text->size != data->vaddr
|| data->vaddr + data->size != bss->vaddr)
{
if (text->vaddr + text->size < data->vaddr &&
data->vaddr - text->vaddr == data->scnptr - text->scnptr)
// "Non-standard" layout of text,data,bss: not contiguous in vaddr.
// But should be OK if no overlap.
// Check for no overlap of text and data:
// neither by vaddr, nor by image data
if (text->vaddr + text->size <= data->vaddr &&
data->scnptr - text->scnptr <= data->vaddr - text->vaddr)
{
// This hack is needed to compress Quake 1!
text->size = coff_hdr.a_tsize = data->vaddr - text->vaddr;
// Examples: Quake1; FreePascal(DOS) install.exe (github-issue45)
// Hack: enlarge text image data to eliminate the gap.
text->size = coff_hdr.a_tsize = data->scnptr - text->scnptr;
// But complain if this causes overlap in vaddr
if (text->vaddr + text->size > data->vaddr)
throwAlreadyPacked();
}
else
throwAlreadyPacked();
@@ -325,7 +337,8 @@ void PackDjgpp2::pack(OutputFile *fo)
linker->defineSymbol("original_entry", coff_hdr.a_entry);
linker->defineSymbol("length_of_bss", ph.overlap_overhead / 4);
defineDecompressorSymbols();
assert(bss->vaddr == ((size + 0x1ff) &~ 0x1ff) + (text->vaddr &~ 0x1ff));
// Just need no overlap; non-contiguous (gap length > 0)) is OK
assert(bss->vaddr >= ((size + 0x1ff) &~ 0x1ff) + (text->vaddr &~ 0x1ff));
linker->defineSymbol("stack_for_lzma", bss->vaddr + bss->size);
linker->defineSymbol("start_of_uncompressed", text->vaddr - hdrsize);
linker->defineSymbol("start_of_compressed", data->vaddr);
@@ -403,7 +416,7 @@ void PackDjgpp2::unpack(OutputFile *fo)
handleStub(fo);
ibuf.alloc(ph.c_len);
obuf.allocForUncompression(ph.u_len);
obuf.allocForDecompression(ph.u_len);
fi->seek(coff_offset + ph.buf_offset + ph.getPackHeaderSize(), SEEK_SET);
fi->readx(ibuf, ph.c_len);
+18 -18
View File
@@ -2,8 +2,8 @@
This file is part of the UPX executable compressor.
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2017 Laszlo Molnar
Copyright (C) 1996-2022 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996-2022 Laszlo Molnar
All Rights Reserved.
UPX and the UCL library are free software; you can redistribute them
@@ -34,35 +34,35 @@
// djgpp2/coff
**************************************************************************/
class PackDjgpp2 : public Packer
class PackDjgpp2 final : public Packer
{
typedef Packer super;
public:
PackDjgpp2(InputFile *f);
virtual int getVersion() const { return 14; }
virtual int getFormat() const { return UPX_F_DJGPP2_COFF; }
virtual const char *getName() const { return "djgpp2/coff"; }
virtual const char *getFullName(const options_t *) const { return "i386-dos32.djgpp2.coff"; }
virtual const int *getCompressionMethods(int method, int level) const;
virtual const int *getFilters() const;
virtual int getVersion() const override { return 14; }
virtual int getFormat() const override { return UPX_F_DJGPP2_COFF; }
virtual const char *getName() const override { return "djgpp2/coff"; }
virtual const char *getFullName(const options_t *) const override { return "i386-dos32.djgpp2.coff"; }
virtual const int *getCompressionMethods(int method, int level) const override;
virtual const int *getFilters() const override;
virtual void pack(OutputFile *fo);
virtual void unpack(OutputFile *fo);
virtual void pack(OutputFile *fo) override;
virtual void unpack(OutputFile *fo) override;
virtual bool canPack();
virtual int canUnpack();
virtual bool canPack() override;
virtual int canUnpack() override;
protected:
virtual void handleStub(OutputFile *fo);
virtual int readFileHeader();
void handleStub(OutputFile *fo);
int readFileHeader();
virtual unsigned findOverlapOverhead(const upx_bytep buf,
const upx_bytep tbuf,
unsigned range = 0,
unsigned upper_limit = ~0u) const;
virtual void buildLoader(const Filter *ft);
virtual Linker* newLinker() const;
unsigned upper_limit = ~0u) const override;
virtual void buildLoader(const Filter *ft) override;
virtual Linker* newLinker() const override;
unsigned coff_offset;

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