Compare commits
125 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3757579ffc | |||
| 2962dc351b | |||
| c04c685469 | |||
| 72c9769953 | |||
| 42759b94bd | |||
| aa9e69f03e | |||
| 0f3939df15 | |||
| 62265a1bc9 | |||
| 76b2cec8ee | |||
| 3d82f0cfe1 | |||
| e5546bc8b0 | |||
| 6fc0a00ac8 | |||
| 3e5ba5c064 | |||
| 4c32a8e3d4 | |||
| 2ea316d754 | |||
| 548227a55b | |||
| a831a20910 | |||
| 811f66de84 | |||
| 84d806328b | |||
| 285d4c4c65 | |||
| 8506f5b17c | |||
| a87fd56b3e | |||
| f0cb30e2b9 | |||
| 038743c694 | |||
| 0e6cef99a0 | |||
| 92c925fe95 | |||
| 4562d5459d | |||
| 8393ded1b3 | |||
| b0dc483165 | |||
| 3c0ca81311 | |||
| 157a63a023 | |||
| 80e22a7e38 | |||
| ddf2da3d76 | |||
| 0e6478a60f | |||
| aed2c085b8 | |||
| a7592b2ca2 | |||
| 265c100845 | |||
| 84e8288f61 | |||
| c69b4561fb | |||
| 6db0af8d04 | |||
| 842d2cbb0d | |||
| 9fb64ded10 | |||
| 9d26713b1a | |||
| eb3c55b5cb | |||
| 896596f672 | |||
| e4de14612f | |||
| 1d2b276425 | |||
| 35c6a200ad | |||
| 90a7faa15e | |||
| 91f5fe1c0e | |||
| d48a7d303d | |||
| bb816f0c74 | |||
| 93abe97ea5 | |||
| 97cf29ffbb | |||
| ed35613d64 | |||
| f5ec8363b4 | |||
| 87956de092 | |||
| 0f9315383c | |||
| 3538d796a7 | |||
| 24f3824524 | |||
| 70b20d7d89 | |||
| 7b21a0620b | |||
| 3949af6d3c | |||
| d1f62e3ab4 | |||
| 6e644fa480 | |||
| 5bef968068 | |||
| 543cfe0a73 | |||
| 3ba91b8072 | |||
| a27a9e6000 | |||
| 7e839e6962 | |||
| 809a1b3dae | |||
| 9b80628f84 | |||
| a21a006fe9 | |||
| 54d16a458a | |||
| cfc5f42ef2 | |||
| e3d24238e4 | |||
| 56e7b36959 | |||
| f29791470f | |||
| 52d9b53b74 | |||
| 839a78f2e0 | |||
| 680ce0a7af | |||
| 06b0de9c77 | |||
| 76b0b7b1ae | |||
| fabda4df3a | |||
| fdcdaf596a | |||
| be44cefbe7 | |||
| c1050e624b | |||
| ae6d3b9bff | |||
| 25aa0e2e46 | |||
| 8f7578eef1 | |||
| 29ce4807fb | |||
| 41f6945be1 | |||
| 718ec468ff | |||
| d429801498 | |||
| 024091e6b5 | |||
| d849e9de98 | |||
| c0e40da2ab | |||
| dff3766501 | |||
| 2767ec54e1 | |||
| ac72c02793 | |||
| 69c51eee4d | |||
| ff5a4eeb96 | |||
| b48f870701 | |||
| 10807ebdc2 | |||
| 5d649f83ec | |||
| 65b25adceb | |||
| d615985b8a | |||
| b019440980 | |||
| 38ed4b2017 | |||
| 2ad0d51226 | |||
| e4a611bcae | |||
| f3728d99b9 | |||
| b87f60a917 | |||
| 28f26da6ab | |||
| d3e780d617 | |||
| d549c2b5c9 | |||
| f310ce376e | |||
| 553fc9b1fb | |||
| 6dde9f7dc0 | |||
| 3dca1175e5 | |||
| 09c5e38322 | |||
| fe6f1f0bb6 | |||
| 250c656b9e | |||
| 9a0b5b65b8 | |||
| 57b2fb4c62 |
+6
-2
@@ -1,11 +1,14 @@
|
||||
# "Gofmt's style is nobody's favourite, but gofmt is everybody's favourite." --Rob Pike
|
||||
#
|
||||
# vim:set ft=yaml ts=2 sw=2 et:
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# for clang-format-15.0.6 from https://github.com/upx/upx-stubtools/releases
|
||||
#
|
||||
# "Gofmt's style is nobody's favourite, but gofmt is everybody's favourite." --Rob Pike
|
||||
---
|
||||
BasedOnStyle: LLVM
|
||||
ColumnLimit: 100
|
||||
IndentWidth: 4
|
||||
---
|
||||
# settings for C and C++
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignConsecutiveMacros: AcrossComments
|
||||
@@ -15,6 +18,7 @@ AttributeMacros:
|
||||
- XSPAN_DELETED_FUNCTION
|
||||
- may_throw
|
||||
EmptyLineBeforeAccessModifier: Leave
|
||||
# IndentPPDirectives: AfterHash # TODO later
|
||||
SortIncludes: false
|
||||
SpaceAfterCStyleCast: true
|
||||
Standard: Cpp03
|
||||
|
||||
+9
-2
@@ -1,13 +1,17 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
# vim:set ft=yaml ts=2 sw=2 et:
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# for clang-tidy from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-branch-clone,
|
||||
-bugprone-casting-through-void,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-empty-catch,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-inc-dec-in-conditions,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-reserved-identifier,
|
||||
@@ -19,10 +23,13 @@ Checks: >
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-optin.performance.Padding,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
-clang-analyzer-security.insecureAPI.rand,
|
||||
-clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-diagnostics-*',
|
||||
clang-diagnostic-*,
|
||||
performance-*,
|
||||
-performance-avoid-endl,
|
||||
-performance-enum-size,
|
||||
-performance-no-int-to-ptr,
|
||||
-performance-unnecessary-value-param,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
# vim:set ft=yaml ts=2 sw=2 et:
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# for clangd from https://clangd.llvm.org/
|
||||
---
|
||||
# treat *.h files as C++ source code
|
||||
If:
|
||||
PathMatch: src/.*\.h
|
||||
PathExclude: vendor/.*
|
||||
CompileFlags:
|
||||
Add:
|
||||
- -xc++
|
||||
---
|
||||
# C++ flags
|
||||
If:
|
||||
PathMatch: [ src/.*\.h, src/.*\.cpp ]
|
||||
PathExclude: vendor/.*
|
||||
CompileFlags:
|
||||
Add:
|
||||
- -std=gnu++17
|
||||
# -std=gnu++20 # requires clangd >= 11.0
|
||||
# -std=gnu++23 # requires clangd >= 18.0
|
||||
---
|
||||
# common flags for all C/C++ files
|
||||
If:
|
||||
PathMatch: [ src/.*\.h, src/.*\.c, src/.*\.cpp ]
|
||||
PathExclude: vendor/.*
|
||||
CompileFlags:
|
||||
Add:
|
||||
# see https://github.com/clangd/clangd/issues/1038 : Support deterministic relative include path
|
||||
- -Ivendor
|
||||
- -I../vendor
|
||||
- -I../../vendor
|
||||
- -DDEBUG
|
||||
- -fno-strict-aliasing
|
||||
- -fno-strict-overflow
|
||||
- -funsigned-char
|
||||
Diagnostics:
|
||||
Includes:
|
||||
# IgnoreHeader: A list of regexes. Include Cleaner will not produce diagnostics
|
||||
# for headers whose path is a suffix match for any of these.
|
||||
IgnoreHeader:
|
||||
- src/.*\.h
|
||||
UnusedIncludes: None
|
||||
...
|
||||
+3
-2
@@ -1,3 +1,4 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# see https://editorconfig.org/
|
||||
|
||||
root = true
|
||||
@@ -14,8 +15,8 @@ trim_trailing_whitespace = true
|
||||
indent_size = 8
|
||||
indent_style = tab
|
||||
|
||||
[*.S]
|
||||
[{*.asm,*.S}]
|
||||
indent_size = 8
|
||||
|
||||
[*.yml]
|
||||
[{*.yaml,*.yml}]
|
||||
indent_size = 2
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# see https://github.com/github-linguist/linguist
|
||||
#
|
||||
# HINT: check settings with
|
||||
# git ls-files | git check-attr --stdin --all
|
||||
# git ls-files --eol
|
||||
|
||||
# disable all line ending conversions
|
||||
* -text
|
||||
|
||||
#
|
||||
# tell diff tools that these files are generated automatically
|
||||
|
||||
+302
-239
@@ -4,7 +4,7 @@
|
||||
# unfortunately this sometimes breaks builds in mysterious ways...
|
||||
# see https://github.com/actions/runner-images.git
|
||||
|
||||
name: 'CI'
|
||||
name: CI
|
||||
|
||||
on: [push, workflow_dispatch]
|
||||
|
||||
@@ -15,150 +15,176 @@ env:
|
||||
DEBIAN_FRONTEND: noninteractive
|
||||
UPX_CMAKE_BUILD_FLAGS: --verbose
|
||||
UPX_CMAKE_CONFIG_FLAGS: -Wdev --warn-uninitialized
|
||||
# 2023-11-08
|
||||
ZIG_DIST_VERSION: 0.12.0-dev.1502+b3462b7ce
|
||||
UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO: 1
|
||||
UPX_DEBUG_TEST_LIBC_QSORT: 1
|
||||
# 2024-04-20
|
||||
ZIG_DIST_VERSION: 0.12.0
|
||||
|
||||
jobs:
|
||||
job-rebuild-and-verify-stubs:
|
||||
name: 'Rebuild stubs'
|
||||
runs-on: ubuntu-20.04
|
||||
name: Rebuild stubs
|
||||
runs-on: ubuntu-latest
|
||||
container: ubuntu:24.04 # glibc-2.39
|
||||
#container: debian:12-slim # also works; glibc-2.36
|
||||
#container: debian:testing-slim # also works
|
||||
steps:
|
||||
- name: 'Install extra packages'
|
||||
- name: Install packages
|
||||
run: |
|
||||
uname -a; pwd; id; umask
|
||||
mkdir ../deps; cd ../deps; mkdir packages
|
||||
if ! test -e /usr/bin/python2; then
|
||||
####sudo apt-get update && sudo apt-get install -y --no-install-recommends python2-minimal
|
||||
dpkg --add-architecture i386
|
||||
apt-get update && apt-get upgrade -y
|
||||
# install system packages
|
||||
apt-get install -y --no-install-recommends bash ca-certificates curl git libmpc3 make perl-base xz-utils libc6:i386 zlib1g:i386
|
||||
# install python2-minimal packages from Debian-11
|
||||
wget -q 'https://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb'
|
||||
wget -q 'https://ftp.debian.org/debian/pool/main/p/python2.7/python2.7-minimal_2.7.18-8+deb11u1_amd64.deb'
|
||||
sudo dpkg -i ./*python2*.deb && rm ./*python2*.deb && sudo ldconfig
|
||||
sudo ln -s -v python2.7 /usr/bin/python2
|
||||
fi
|
||||
mkdir ../deps; cd ../deps; mkdir packages
|
||||
curl -sS -L -O https://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb
|
||||
curl -sS -L -O https://ftp.debian.org/debian/pool/main/p/python2.7/python2.7-minimal_2.7.18-8+deb11u1_amd64.deb
|
||||
dpkg -i ./*python2*.deb && rm ./*python2*.deb && ldconfig
|
||||
ln -s -v python2.7 /usr/bin/python2
|
||||
# manually unpack and install compat libs from Ubuntu-16.04
|
||||
wget -q 'https://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb'
|
||||
curl -sS -L -O https://archive.kernel.org/ubuntu-archive/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.6-1_amd64.deb
|
||||
for f in ./*.deb; do dpkg -x $f ./packages; done
|
||||
sudo mv -v -n ./packages/usr/lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/
|
||||
rm -rf ./*.deb ./packages
|
||||
sudo ldconfig
|
||||
mv -v -n ./packages/usr/lib/x86_64-linux-gnu/lib* /usr/lib/x86_64-linux-gnu/
|
||||
rm -rf ./*.deb ./packages && ldconfig
|
||||
# install upx-stubtools
|
||||
wget -q -O - https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz | tar -xJ
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Rebuild and verify stubs'
|
||||
curl -sS -L https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz | tar -xJ
|
||||
- name: Check out code
|
||||
run: |
|
||||
git config --global --add safe.directory '*' # needed when running in a container
|
||||
git clone --branch "$GITHUB_REF_NAME" --depth 1 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" .
|
||||
git submodule update --init -- vendor/lzma-sdk
|
||||
- name: Rebuild and verify stubs
|
||||
run: |
|
||||
export PATH="$(readlink -en ../deps/bin-upx-20221212):$PATH"
|
||||
make -C src/stub maintainer-clean extra-clean
|
||||
git status || true
|
||||
make -C src/stub extra-all all
|
||||
if ! git diff --quiet; then git diff; exit 1; fi
|
||||
- name: 'Check source code formatting'
|
||||
- run: bash ./misc/scripts/check_whitespace_git.sh
|
||||
- name: Check source code formatting
|
||||
run: |
|
||||
bash ./misc/scripts/check_whitespace_git.sh
|
||||
UPX_CLANG_FORMAT="$PWD/../deps/bin-upx-20221212/clang-format-15.0.6" make -C src clang-format
|
||||
export UPX_CLANG_FORMAT="$PWD/../deps/bin-upx-20221212/clang-format-15.0.6"
|
||||
make -C src clang-format
|
||||
if ! git diff --quiet; then git diff; exit 1; fi
|
||||
- name: Rebuild docs
|
||||
run: |
|
||||
make -C doc clean all
|
||||
if ! git diff --quiet; then git diff || true; fi # ignore diff error
|
||||
|
||||
job-linux-cmake: # uses cmake + make
|
||||
if: true
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('{0} cmake', matrix.os) }}
|
||||
name: ${{ format('{0}', matrix.os) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { os: ubuntu-22.04, use_m32: true }
|
||||
- { os: ubuntu-20.04, use_m32: true } # use_m32 also works here, but save some CI time
|
||||
env:
|
||||
UPX_CONFIG_EXPECT_THREADS: 'ON'
|
||||
- { os: ubuntu-22.04, use_extra: true, use_wine: true }
|
||||
- { os: ubuntu-20.04, use_extra: true }
|
||||
steps:
|
||||
- name: 'Install extra 32-bit and Windows packages'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
- name: Install extra 32-bit and MinGW packages
|
||||
if: ${{ matrix.use_extra }}
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
sudo apt-get update
|
||||
sudo apt-get update && sudo apt-get upgrade -y
|
||||
sudo apt-get install -y g++-multilib g++-mingw-w64-i686 g++-mingw-w64-x86-64
|
||||
# make sure that we use posix-threads (pthread/winpthreads) and NOT win32-threads
|
||||
for f in i686-w64-mingw32-g++ i686-w64-mingw32-gcc x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc; do
|
||||
if test -f /usr/bin/$f-posix; then sudo update-alternatives --set $f /usr/bin/$f-posix; fi
|
||||
ls -l /usr/bin/${f}*
|
||||
done
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
ls -l /etc/alternatives/*mingw* || true
|
||||
sudo apt-get install -y libc6-dbg:i386 valgrind
|
||||
- name: Install Wine
|
||||
if: ${{ matrix.use_extra && matrix.use_wine }}
|
||||
run: |
|
||||
sudo apt-get install -y wine wine32:i386 wine64
|
||||
ls -l /usr/bin/wine*
|
||||
mkdir -p -v ~/.wine && wineboot --init
|
||||
- uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Check out test suite'
|
||||
run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite'
|
||||
- name: 'Build cmake extra/gcc/debug'
|
||||
run: 'make build/extra/gcc/debug'
|
||||
- name: 'Build cmake extra/gcc/release'
|
||||
run: 'make build/extra/gcc/release'
|
||||
- name: 'Build cmake extra/clang/debug'
|
||||
run: 'make build/extra/clang/debug'
|
||||
- name: 'Build cmake extra/clang/release'
|
||||
run: 'make build/extra/clang/release'
|
||||
- name: 'Build cmake extra/gcc-m32/debug'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
run: 'make build/extra/gcc-m32/debug'
|
||||
- name: 'Build cmake extra/gcc-m32/release'
|
||||
if: ${{ matrix.use_m32 && (success() || failure()) }} # run this step even if the previous step failed
|
||||
run: 'make build/extra/gcc-m32/release'
|
||||
- name: 'Build cmake extra/cross-windows-mingw32/release'
|
||||
if: ${{ matrix.use_m32 && (success() || failure()) }} # run this step even if the previous step failed
|
||||
run: 'make build/extra/cross-windows-mingw32/release'
|
||||
- name: 'Build cmake extra/cross-windows-mingw64/release'
|
||||
if: ${{ matrix.use_m32 && (success() || failure()) }} # run this step even if the previous step failed
|
||||
run: 'make build/extra/cross-windows-mingw64/release'
|
||||
- name: 'Make artifact'
|
||||
- name: Check out test suite
|
||||
run: git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite
|
||||
- run: make build/extra/gcc/all
|
||||
- run: make build/extra/clang/all
|
||||
- run: make build/extra/gcc-m32/all
|
||||
if: ${{ matrix.use_extra }}
|
||||
- run: make build/extra/gcc-mx32/all
|
||||
if: ${{ matrix.use_extra }}
|
||||
- run: make build/extra/cross-windows-mingw32/all
|
||||
if: ${{ matrix.use_extra }}
|
||||
- run: make build/extra/cross-windows-mingw64/all
|
||||
if: ${{ matrix.use_extra }}
|
||||
- name: Make artifact
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
|
||||
(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@v4
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
|
||||
- name: Run install tests
|
||||
run: |
|
||||
(cd build/extra/gcc/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/extra/gcc/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
- name: 'Run ctest tests'
|
||||
(cd build/extra/gcc/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
|
||||
(cd build/extra/gcc/release && DESTDIR="$PWD/Install with make" make install)
|
||||
- name: Run ctest tests
|
||||
run: |
|
||||
make -C build/extra/gcc/debug test
|
||||
make -C build/extra/gcc/release test
|
||||
make -C build/extra/clang/debug test
|
||||
make -C build/extra/clang/release test
|
||||
- name: 'Run ctest tests 32-bit'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
jobs="gcc/debug gcc/release clang/debug clang/release"
|
||||
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
|
||||
command -v wine >/dev/null && jobs="$jobs cross-windows-mingw32/debug cross-windows-mingw32/release"
|
||||
command -v wine >/dev/null && jobs="$jobs cross-windows-mingw64/debug cross-windows-mingw64/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
CTEST_JOBS=2 parallel -kv --lb 'make build/extra/{}+test' ::: $jobs
|
||||
- name: Mimic ctest tests
|
||||
run: |
|
||||
make -C build/extra/gcc-m32/debug test
|
||||
make -C build/extra/gcc-m32/release test
|
||||
- name: 'Mimic ctest tests'
|
||||
jobs="gcc/debug gcc/release clang/debug clang/release"
|
||||
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
|
||||
- name: Mimic ctest tests with Valgrind
|
||||
if: true # note: valgrind is SLOW
|
||||
run: |
|
||||
env -C build/extra/gcc/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
env -C build/extra/clang/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
env -C build/extra/clang/release bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
- name: 'Mimic ctest tests 32-bit'
|
||||
if: ${{ matrix.use_m32 }}
|
||||
if command -v valgrind >/dev/null; then
|
||||
export UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS=ON # valgrind is SLOW
|
||||
export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet --gen-suppressions=all"
|
||||
# clang/debug does not work before valgrind-3.20, see https://bugs.kde.org/show_bug.cgi?id=452758
|
||||
jobs="gcc/debug gcc/release clang/release"
|
||||
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
|
||||
fi
|
||||
- name: Run file system test suite
|
||||
run: |
|
||||
env -C build/extra/gcc-m32/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
env -C build/extra/gcc-m32/release bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
- name: 'Run file system test suite'
|
||||
jobs="gcc/debug gcc/release clang/debug clang/release"
|
||||
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/test_symlinks.sh' ::: $jobs
|
||||
- name: Run file system test suite with Valgrind
|
||||
if: false # note: valgrind is SLOW
|
||||
run: |
|
||||
env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/test_symlinks.sh
|
||||
- name: 'Run test suite build/extra/gcc/release'
|
||||
if command -v valgrind >/dev/null; then
|
||||
export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet --gen-suppressions=all"
|
||||
# clang/debug does not work before valgrind-3.20, see https://bugs.kde.org/show_bug.cgi?id=452758
|
||||
jobs="gcc/debug gcc/release clang/release"
|
||||
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/test_symlinks.sh' ::: $jobs
|
||||
fi
|
||||
- name: Run test suite
|
||||
run: |
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
env -C build/extra/gcc/release bash "$PWD"/misc/testsuite/upx_testsuite_1.sh
|
||||
jobs="gcc/debug gcc/release clang/debug clang/release"
|
||||
test "${{ matrix.use_extra }}" = "true" && jobs="$jobs gcc-m32/debug gcc-m32/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/upx_testsuite_1.sh' ::: $jobs
|
||||
|
||||
job-macos-cmake: # uses cmake + make
|
||||
if: true
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('{0} cmake', matrix.os) }}
|
||||
name: ${{ format('{0} {1}{2}', matrix.os, matrix.xcode_version && 'xcode-' || '', matrix.xcode_version) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -166,135 +192,135 @@ jobs:
|
||||
include:
|
||||
# NOTE: macos does not have "env -C"; only with brew coreutils
|
||||
# NOTE: macos-11 does not have "readlink -f"; only on macos >= 12 or with brew coreutils
|
||||
- { os: macos-11, gcc: gcc-10, gxx: 'g++-10', testsuite: true }
|
||||
- { os: macos-12, gcc: gcc-11, gxx: 'g++-11', testsuite: true }
|
||||
- { os: macos-13, gcc: gcc-12, gxx: 'g++-12', testsuite: true }
|
||||
env:
|
||||
UPX_CONFIG_EXPECT_THREADS: 'ON'
|
||||
- { os: macos-11, gcc: gcc-10, gxx: g++-10, testsuite: true }
|
||||
- { os: macos-12, gcc: gcc-11, gxx: g++-11, testsuite: true }
|
||||
- { os: macos-13, testsuite: true } # use default Xcode-15; NOTE: gcc-12 on macos-13 does not work with Xcode-15
|
||||
- { os: macos-13, gcc: gcc-12, gxx: g++-12, testsuite: true, xcode_version: 14.3.1 }
|
||||
# { os: macos-14, gcc: gcc-13, gxx: g++-13, testsuite: true } # gcc-13: INTERNAL ERROR in ld64
|
||||
# { os: macos-14, gcc: gcc-13, gxx: g++-13, testsuite: true, xcode_version: 14.3.1 } # gcc-13: MISSING HEADER FILES
|
||||
- { os: macos-14, gcc: gcc-12, gxx: g++-12, testsuite: true } # => use gcc-12 for now
|
||||
steps:
|
||||
- name: 'Install brew packages'
|
||||
- uses: maxim-lobanov/setup-xcode@v1
|
||||
if: ${{ matrix.xcode_version }}
|
||||
with: { xcode-version: '${{ matrix.xcode_version }}' }
|
||||
- name: Install brew packages
|
||||
if: ${{ matrix.testsuite }}
|
||||
run: |
|
||||
test -z "$HOMEBREW_PREFIX" && HOMEBREW_PREFIX="$(brew --prefix)"
|
||||
echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX" >> $GITHUB_ENV
|
||||
# testsuite needs working "readlink -en" and "sha256sum -b"
|
||||
if ! test -e /usr/local/opt/coreutils/libexec/gnubin/readlink; then
|
||||
packages="ninja parallel"
|
||||
test -e "$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin/readlink" || packages="$packages coreutils"
|
||||
if test -n "$packages"; then
|
||||
echo "===== brew leaves:"; brew leaves; echo "===== brew list:"; brew list --versions
|
||||
# only run "brew update" if needed
|
||||
if ! brew install coreutils; then brew update && brew install coreutils; fi
|
||||
if ! brew install $packages; then brew update && brew install $packages; fi
|
||||
fi
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi)
|
||||
echo "UPX_DEBUG_FORCE_PACK_MACOS=1" >> $GITHUB_ENV
|
||||
case "${{ matrix.os }}" in
|
||||
# TODO FIXME: UPX on macos-13+ is broken => disable run-packed for now
|
||||
macos-13 | macos-14) echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV ;;
|
||||
esac
|
||||
- uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Check out test suite'
|
||||
- name: Check out test suite
|
||||
if: ${{ matrix.testsuite }}
|
||||
run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite'
|
||||
- name: 'Build cmake extra/clang/debug'
|
||||
run: 'make build/extra/clang/debug'
|
||||
- name: 'Build cmake extra/clang/release'
|
||||
run: 'make build/extra/clang/release'
|
||||
- name: 'Build cmake extra/gcc/debug'
|
||||
if: ${{ matrix.gcc != '' }}
|
||||
run: 'make build/extra/gcc/debug CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"'
|
||||
- name: 'Build cmake extra/gcc/release'
|
||||
if: ${{ matrix.gcc != '' }}
|
||||
run: 'make build/extra/gcc/release CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"'
|
||||
- name: 'Build cmake xtarget/cross-darwin-arm64/debug'
|
||||
run: git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite
|
||||
- run: make build/extra/clang/all
|
||||
- name: Build extra/gcc/all
|
||||
if: ${{ matrix.gcc }}
|
||||
run: make build/extra/gcc/all CC="${{ matrix.gcc }} -static-libgcc" CXX="${{ matrix.gxx }} -static-libgcc -static-libstdc++"
|
||||
- name: Build xtarget/cross-darwin-arm64/all
|
||||
run: |
|
||||
CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" \
|
||||
make UPX_XTARGET=cross-darwin-arm64 xtarget/debug
|
||||
- name: 'Build cmake xtarget/cross-darwin-arm64/release'
|
||||
make UPX_XTARGET=xtarget/cross-darwin-arm64 xtarget/all \
|
||||
CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin"
|
||||
- name: Make artifact
|
||||
run: |
|
||||
CC="clang -target arm64-apple-darwin" CXX="clang++ -target arm64-apple-darwin" \
|
||||
make UPX_XTARGET=cross-darwin-arm64 xtarget/release
|
||||
- name: 'Make artifact'
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
X="${{ matrix.xcode_version }}"; test -n "$X" && X="-xcode-$X"
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}$X" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
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@v4
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
|
||||
- name: Run install tests
|
||||
run: |
|
||||
(cd build/extra/clang/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/extra/clang/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
- name: 'Run ctest tests'
|
||||
if: ${{ !contains(matrix.os, 'macos-13') }} # FIXME: UPX on macos-13 is broken => disable self-test for now
|
||||
(cd build/extra/clang/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
|
||||
(cd build/extra/clang/release && DESTDIR="$PWD/Install with make" make install)
|
||||
- name: Run ctest tests
|
||||
run: |
|
||||
make -C build/extra/clang/debug test
|
||||
#make -C build/extra/clang/release test
|
||||
for f in ./build/extra/*/*/upx; do echo "===== $f"; $f --sysinfo -v; done
|
||||
- name: 'Mimic ctest tests'
|
||||
if: ${{ !contains(matrix.os, 'macos-13') }} # FIXME: UPX on macos-13 is broken => disable self-test for now
|
||||
for f in ./build/extra/*/*/upx; do file $f; done
|
||||
jobs="clang/debug clang/release"
|
||||
test -n "${{ matrix.gcc }}" && jobs="$jobs gcc/debug gcc/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
CTEST_JOBS=2 parallel -kv --lb 'make build/extra/{}+test' ::: $jobs
|
||||
- name: Mimic ctest tests
|
||||
run: |
|
||||
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
|
||||
env -C build/extra/clang/debug bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
#env -C build/extra/clang/release bash "$PWD"/misc/testsuite/mimic_ctest.sh
|
||||
- name: 'Run file system test suite'
|
||||
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
|
||||
jobs="clang/debug clang/release"
|
||||
test -n "${{ matrix.gcc }}" && jobs="$jobs gcc/debug gcc/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
|
||||
- name: Run file system test suite
|
||||
if: ${{ matrix.testsuite }} # for coreutils readlink
|
||||
run: |
|
||||
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
|
||||
env -C build/extra/clang/release bash "$PWD"/misc/testsuite/test_symlinks.sh
|
||||
- name: 'Run test suite build/extra/clang/release'
|
||||
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
|
||||
export upx_test_file="$PWD"/build/extra/clang/release/upx
|
||||
jobs="clang/debug clang/release"
|
||||
test -n "${{ matrix.gcc }}" && jobs="$jobs gcc/debug gcc/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/test_symlinks.sh' ::: $jobs
|
||||
- name: Run test suite
|
||||
if: ${{ matrix.testsuite }}
|
||||
run: |
|
||||
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
|
||||
export PATH="$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin:$PATH"
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
env -C build/extra/clang/release bash "$PWD"/misc/testsuite/upx_testsuite_1.sh
|
||||
jobs="clang/debug clang/release"
|
||||
test -n "${{ matrix.gcc }}" && jobs="$jobs gcc/debug gcc/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/extra/{} && bash ../../../../misc/testsuite/upx_testsuite_1.sh' ::: $jobs
|
||||
|
||||
job-windows-cmake: # uses cmake + msbuild
|
||||
if: true
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('{0} cmake', matrix.name) }}
|
||||
name: ${{ format('{0}', matrix.name) }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { name: windows-2019-amd64, os: windows-2019, vsversion: 2019, arch: amd64 }
|
||||
- { name: windows-2022-amd64, os: windows-2022, vsversion: 2022, arch: amd64 }
|
||||
env:
|
||||
UPX_CONFIG_EXPECT_THREADS: 'ON'
|
||||
- { name: windows-2019-amd64, os: windows-2019, vsversion: 2019, vsarch: amd64 }
|
||||
- { name: windows-2022-amd64, os: windows-2022, vsversion: 2022, vsarch: amd64 }
|
||||
steps:
|
||||
- run: git config --global core.autocrlf false
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Check out test suite'
|
||||
run: 'git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite'
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: ${{ matrix.vsversion }}
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: 'Build cmake debug'
|
||||
run: 'make build/debug'
|
||||
- name: 'Build cmake release'
|
||||
run: 'make build/release'
|
||||
- name: 'Make artifact'
|
||||
- name: Check out test suite
|
||||
run: git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with: { vsversion: '${{ matrix.vsversion }}', arch: '${{ matrix.vsarch }}' }
|
||||
- run: make build/debug
|
||||
- run: make build/release
|
||||
- name: Make artifact
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-${{ matrix.os }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
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@v4
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run ctest tests'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
|
||||
- name: Run ctest tests
|
||||
if: ${{ matrix.vsarch != 'amd64_arm64' }}
|
||||
run: |
|
||||
ctest --test-dir build/debug -C Debug
|
||||
ctest --test-dir build/release -C Release
|
||||
- name: 'Run test suite build/release'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
ctest --test-dir build/debug --parallel 8 -C Debug
|
||||
ctest --test-dir build/release --parallel 8 -C Release
|
||||
- name: Run test suite build/release
|
||||
if: ${{ matrix.vsarch != 'amd64_arm64' }}
|
||||
shell: bash
|
||||
run: |
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
@@ -312,32 +338,28 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- { name: amd64-win64-vs2019, os: windows-2019, vsversion: 2019, arch: amd64 }
|
||||
- { name: amd64-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64 }
|
||||
- { name: arm64-win64-vs2019, os: windows-2019, vsversion: 2019, arch: amd64_arm64 }
|
||||
- { name: arm64-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_arm64 }
|
||||
- { name: arm64ec-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64ec' }
|
||||
# { name: arm64x-win64-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64x' }
|
||||
- { name: i386-win32-vs2019, os: windows-2019, vsversion: 2019, arch: amd64_x86 }
|
||||
- { name: i386-win32-vs2022, os: windows-2022, vsversion: 2022, arch: amd64_x86 }
|
||||
- { name: amd64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64 }
|
||||
- { name: amd64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64 }
|
||||
- { name: arm64-win64-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64_arm64 }
|
||||
- { name: arm64-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64 }
|
||||
- { name: arm64ec-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64ec' }
|
||||
# { name: arm64x-win64-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_arm64, cl_machine_flags: -arm64EC, link_machine_flags: '/machine:arm64x' }
|
||||
- { name: i386-win32-vs2019, os: windows-2019, vsversion: 2019, vsarch: amd64_x86 }
|
||||
- { name: i386-win32-vs2022, os: windows-2022, vsversion: 2022, vsarch: amd64_x86 }
|
||||
steps:
|
||||
- run: git config --global core.autocrlf false
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: 'Prepare sources and Check out test suite'
|
||||
- name: Prepare sources and Check out test suite
|
||||
shell: bash
|
||||
run: |
|
||||
git clone --depth=1 https://github.com/upx/upx-testsuite ../deps/upx-testsuite
|
||||
mkdir -p -v build/$C/$B/{bzip2,ucl,upx,zlib,zstd}
|
||||
repository_name="${GITHUB_REPOSITORY##*/}" # basename
|
||||
echo "H=d:\\a\\$repository_name\\$repository_name" >> $GITHUB_ENV
|
||||
- name: 'Set up Developer Command Prompt'
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
vsversion: ${{ matrix.vsversion }}
|
||||
arch: ${{ matrix.arch }}
|
||||
- name: 'Build by hand'
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with: { vsversion: '${{ matrix.vsversion }}', arch: '${{ matrix.vsarch }}' }
|
||||
- name: Build by hand
|
||||
shell: cmd
|
||||
run: |
|
||||
@REM ===== set vars =====
|
||||
@@ -345,7 +367,7 @@ jobs:
|
||||
set RUN_CL=cl ${{ matrix.cl_machine_flags }} -MT
|
||||
set RUN_LIB=link -lib ${{ matrix.link_machine_flags }}
|
||||
@rem UPX only uses the very basic Windows API
|
||||
set DEFS=-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0400
|
||||
set DEFS=-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0501
|
||||
set BDIR=%H%\build\%C%\%B%
|
||||
git rev-parse --short=12 HEAD > %BDIR%\upx\.GITREV.txt
|
||||
@REM ===== build bzip2 =====
|
||||
@@ -376,21 +398,18 @@ jobs:
|
||||
@rem set UPX_LIBS=%BDIR%\bzip2\bzip2.lib %BDIR%\ucl\ucl.lib %BDIR%\zlib\zlib.lib %BDIR%\zstd\zstd.lib
|
||||
set sources=%s%\*.cpp %s%\check\*.cpp %s%\compress\*.cpp %s%\console\*.cpp %s%\filter\*.cpp %s%\util\*.cpp
|
||||
%RUN_CL% -J -O2 -W4 -WX -std:c++17 -Zc:__cplusplus -EHsc -DUPX_VERSION_GITREV="""%GITREV%""" %DEFS% %UPX_DEFS% -I%H%\vendor -Feupx.exe %sources% %UPX_LIBS% /link ${{ matrix.link_machine_flags }} setargv.obj
|
||||
- name: 'Make artifact'
|
||||
- name: Make artifact
|
||||
shell: bash
|
||||
run: |
|
||||
N=$(echo "upx-${GITHUB_REF_NAME}-${GITHUB_SHA:0:7}-windows-${{ matrix.name }}" | sed 's/[^0-9a-zA-Z_.-]/-/g')
|
||||
mkdir -p "tmp/artifact/$N/$B"
|
||||
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@v4
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run basic tests'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
|
||||
- name: Run basic tests
|
||||
if: ${{ matrix.vsarch != 'amd64_arm64' }}
|
||||
run: |
|
||||
$ErrorActionPreference = 'stop'
|
||||
$ErrorView = 'NormalView'
|
||||
@@ -403,8 +422,8 @@ jobs:
|
||||
.\upx.exe -l upx_packed.exe
|
||||
.\upx.exe -t upx_packed.exe
|
||||
.\upx_packed.exe --version
|
||||
- name: 'Run test suite'
|
||||
if: ${{ matrix.arch != 'amd64_arm64' }}
|
||||
- name: Run test suite
|
||||
if: ${{ matrix.vsarch != 'amd64_arm64' }}
|
||||
shell: bash
|
||||
run: |
|
||||
export upx_testsuite_SRCDIR="$(readlink -en ../deps/upx-testsuite)"
|
||||
@@ -415,62 +434,70 @@ jobs:
|
||||
needs: [ job-rebuild-and-verify-stubs ]
|
||||
name: ${{ format('zigcc {0} {1}', matrix.zig_target, matrix.zig_pic) }}
|
||||
runs-on: ubuntu-latest
|
||||
container: 'alpine:3.19' # older versions such as alpine:3.12 also work; no-container also works
|
||||
container: alpine:3.19
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
# only build a few targets => more targets are tested in the Weekly CI
|
||||
- { zig_target: aarch64-linux-musl }
|
||||
# { zig_target: aarch64-linux-musl, zig_pic: -fPIE }
|
||||
- { zig_target: aarch64-linux-musl, qemu: qemu-aarch64 }
|
||||
# { zig_target: aarch64-linux-musl, qemu: qemu-aarch64, zig_pic: -fPIE }
|
||||
# { zig_target: aarch64-macos-none }
|
||||
- { zig_target: aarch64-macos.11.0-none }
|
||||
# { zig_target: aarch64-macos.12.0-none }
|
||||
# { zig_target: aarch64-macos.13.0-none }
|
||||
- { zig_target: aarch64-windows-gnu }
|
||||
- { zig_target: arm-linux-musleabihf }
|
||||
# { zig_target: arm-linux-musleabihf, zig_pic: -fPIE }
|
||||
- { zig_target: i386-linux-musl }
|
||||
# { zig_target: i386-linux-musl, zig_pic: -fPIE }
|
||||
- { zig_target: arm-linux-musleabihf, qemu: qemu-arm }
|
||||
# { zig_target: arm-linux-musleabihf, qemu: qemu-arm, zig_pic: -fPIE }
|
||||
- { zig_target: i386-linux-gnu.2.3.4, zig_flags: -march=i586 }
|
||||
- { zig_target: i386-linux-musl, zig_flags: -march=i586, qemu: qemu-i386 }
|
||||
# { zig_target: i386-linux-musl, zig_flags: -march=i586, qemu: qemu-i386, zig_pic: -fPIE }
|
||||
- { zig_target: i386-windows-gnu }
|
||||
# { zig_target: mips-linux-musl }
|
||||
# { zig_target: mipsel-linux-musl }
|
||||
# { zig_target: powerpc-linux-musl }
|
||||
# { zig_target: powerpc64-linux-musl }
|
||||
# { zig_target: powerpc64le-linux-musl }
|
||||
- { zig_target: x86_64-linux-musl }
|
||||
# { zig_target: x86_64-linux-musl, zig_pic: -fPIE }
|
||||
# mips and mipsel: bad hard-float code generation(??); or QEMU bug; or UPX bug; see https://github.com/upx/upx/issues/788
|
||||
- { zig_target: mips-linux-musl, zig_flags: -msoft-float, qemu: qemu-mips }
|
||||
- { zig_target: mipsel-linux-musl, zig_flags: -msoft-float, qemu: qemu-mipsel }
|
||||
- { zig_target: powerpc-linux-musl, qemu: qemu-ppc }
|
||||
# powerpc64: obscure problem with C++ exceptions in UPX doctest checks; use -fPIC to work-around
|
||||
- { zig_target: powerpc64-linux-musl, zig_flags: -fPIC, qemu: qemu-ppc64 }
|
||||
- { zig_target: powerpc64le-linux-musl, qemu: qemu-ppc64le }
|
||||
- { zig_target: x86_64-linux-gnu.2.3.4, qemu: qemu-x86_64 } # can use QEMU because of gcompat
|
||||
- { zig_target: x86_64-linux-musl, qemu: qemu-x86_64 }
|
||||
# { zig_target: x86_64-linux-musl, qemu: qemu-x86_64, zig_pic: -fPIE }
|
||||
# { zig_target: x86_64-macos-none }
|
||||
- { zig_target: x86_64-macos.11.0-none }
|
||||
# { zig_target: x86_64-macos.12.0-none }
|
||||
# { zig_target: x86_64-macos.13.0-none }
|
||||
- { zig_target: x86_64-windows-gnu }
|
||||
env:
|
||||
UPX_CONFIG_EXPECT_THREADS: 'ON'
|
||||
# zig is currently missing winpthreads; see https://github.com/ziglang/zig/issues/10989
|
||||
UPX_CONFIG_EXPECT_THREADS: ${{ contains(matrix.zig_target, '-windows-') && 'OFF' || 'ON' }}
|
||||
# for zig-cc wrapper scripts (see below):
|
||||
ZIG_CPPFLAGS: -DUPX_DOCTEST_CONFIG_MULTITHREADING
|
||||
ZIG_FLAGS: ${{ matrix.zig_flags }}
|
||||
ZIG_PIC: ${{ matrix.zig_pic }}
|
||||
ZIG_TARGET: ${{ matrix.zig_target }}
|
||||
steps:
|
||||
- name: 'Install Alpine Linux container packages'
|
||||
- name: Install Alpine Linux container packages
|
||||
if: ${{ job.container }}
|
||||
shell: sh
|
||||
run: |
|
||||
apk update && apk upgrade && apk add bash cmake file git make tar xz
|
||||
apk update && apk upgrade && apk add bash cmake curl file git make parallel tar xz
|
||||
mkdir -p ~/.parallel && : > ~/.parallel/$(echo 6305-4721 | tr 0-7 leticlwi)
|
||||
# set PATH like in Ubuntu
|
||||
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
|
||||
# this seems to be needed when running in a container (beause of UID mismatch??)
|
||||
git config --global --add safe.directory '*'
|
||||
- name: 'Check out code'
|
||||
uses: actions/checkout@v4
|
||||
git config --global --add safe.directory '*' # needed when running in a container
|
||||
- uses: actions/checkout@v4
|
||||
with: { submodules: true }
|
||||
- name: ${{ format('Install Zig {0}', env.ZIG_DIST_VERSION) }}
|
||||
shell: bash
|
||||
run: |
|
||||
# GitHub Actions magic: set "UPX_GITREV_SHORT" environment value for use in steps below
|
||||
rev=$(git rev-parse --short=7 HEAD)
|
||||
echo "UPX_GITREV_SHORT=$rev" >> $GITHUB_ENV
|
||||
if [[ "${{ matrix.zig_target }}" == x86_64-linux-gnu.2.3.4 ]]; then
|
||||
echo "NEED_GCOMPAT=1" >> $GITHUB_ENV
|
||||
# TODO FIXME: problem with self-packed upx and musl+gcompat: "Not a valid dynamic program"
|
||||
echo "UPX_CONFIG_DISABLE_RUN_PACKED_TEST=ON" >> $GITHUB_ENV
|
||||
fi
|
||||
# update ZIG_TARGET (i386 => x86)
|
||||
ZIG_TARGET=${ZIG_TARGET/i386-/x86-}
|
||||
echo "ZIG_TARGET=$ZIG_TARGET" >> $GITHUB_ENV
|
||||
@@ -478,7 +505,7 @@ jobs:
|
||||
mkdir -p -v ~/.local/bin
|
||||
cd ~/.local/bin
|
||||
ZIG_DIST_NAME=zig-linux-x86_64-${ZIG_DIST_VERSION}
|
||||
wget -q https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz
|
||||
curl -sS -L -O https://ziglang.org/builds/${ZIG_DIST_NAME}.tar.xz
|
||||
ls -l ${ZIG_DIST_NAME}.tar.xz
|
||||
tar -xoJf ${ZIG_DIST_NAME}.tar.xz
|
||||
rm ${ZIG_DIST_NAME}.tar.xz
|
||||
@@ -494,18 +521,14 @@ jobs:
|
||||
ls -la; head zig-ar zig-cc zig-cxx zig-ranlib
|
||||
- name: ${{ format('Build Release with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
|
||||
run: |
|
||||
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/release
|
||||
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release
|
||||
cmake ../../../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_RELEASE
|
||||
cmake --build . --config Release --parallel --verbose
|
||||
file ./upx*
|
||||
make UPX_XTARGET=zig/${ZIG_TARGET}${ZIG_PIC} xtarget/release \
|
||||
CC="zig-cc" CXX="zig-cxx" CMAKE_AR="$HOME/.local/bin/zig-ar" CMAKE_RANLIB="$HOME/.local/bin/zig-ranlib"
|
||||
file build/zig/${ZIG_TARGET}${ZIG_PIC}/release/upx*
|
||||
- name: ${{ format('Build Debug with zig-cc -target {0} {1}', env.ZIG_TARGET, env.ZIG_PIC) }}
|
||||
run: |
|
||||
mkdir -p build/zig/${ZIG_TARGET}${ZIG_PIC}/debug
|
||||
cd build/zig/${ZIG_TARGET}${ZIG_PIC}/debug
|
||||
cmake ../../../.. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_AR=$HOME/.local/bin/zig-ar -DCMAKE_C_COMPILER=zig-cc -DCMAKE_CXX_COMPILER=zig-cxx -DCMAKE_RANLIB=$HOME/.local/bin/zig-ranlib $EXTRA_CMAKE_CONFIG_FLAGS_DEBUG
|
||||
cmake --build . --config Debug --parallel --verbose
|
||||
file ./upx*
|
||||
make UPX_XTARGET=zig/${ZIG_TARGET}${ZIG_PIC} xtarget/debug \
|
||||
CC="zig-cc" CXX="zig-cxx" CMAKE_AR="$HOME/.local/bin/zig-ar" CMAKE_RANLIB="$HOME/.local/bin/zig-ranlib"
|
||||
file build/zig/${ZIG_TARGET}${ZIG_PIC}/debug/upx*
|
||||
- name: ${{ format('Make artifact from upx-{0}-{1}', github.ref_name, env.UPX_GITREV_SHORT) }}
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -513,15 +536,55 @@ jobs:
|
||||
mkdir -p "tmp/artifact/$N"
|
||||
(cd build && shopt -s nullglob && cp -ai --parents */upx{,.exe} */*/*/upx{,.exe} "../tmp/artifact/$N")
|
||||
(cd tmp/artifact && tar --sort=name -czf "$N.tar.gz" "$N" && rm -rf "./$N")
|
||||
# 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@v4
|
||||
with:
|
||||
name: ${{ env.artifact_name }}
|
||||
path: tmp/artifact
|
||||
- name: 'Run install tests'
|
||||
with: { name: '${{ env.artifact_name }}', path: tmp/artifact }
|
||||
- name: Run install tests
|
||||
if: ${{ contains(matrix.zig_target, '-linux') }}
|
||||
run: |
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-cmake cmake --install .)
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR=$PWD/Install-with-make make install)
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR="$PWD/Install with cmake" cmake --install .)
|
||||
(cd build/zig/${ZIG_TARGET}${ZIG_PIC}/release && DESTDIR="$PWD/Install with make" make install)
|
||||
- name: Run ctest tests
|
||||
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }}
|
||||
run: |
|
||||
test -n "$NEED_GCOMPAT" && apk add gcompat
|
||||
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'make build/zig/{}+test' ::: $jobs
|
||||
- name: Mimic ctest tests
|
||||
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }}
|
||||
run: |
|
||||
test -n "$NEED_GCOMPAT" && apk add gcompat
|
||||
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
|
||||
- name: ${{ format('Mimic ctest tests with QEMU {0}', matrix.qemu) }}
|
||||
if: ${{ matrix.qemu }}
|
||||
run: |
|
||||
qemu="${{ matrix.qemu }}"
|
||||
apk add coreutils "${qemu%% *}"
|
||||
test -n "$NEED_GCOMPAT" && apk add gcompat
|
||||
export upx_exe_runner="$qemu"
|
||||
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
|
||||
- name: Mimic ctest tests with Valgrind
|
||||
if: ${{ matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }}
|
||||
run: |
|
||||
export UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS=ON # valgrind is SLOW
|
||||
apk add coreutils valgrind
|
||||
test -n "$NEED_GCOMPAT" && apk add gcompat
|
||||
export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet --gen-suppressions=all"
|
||||
upx_exe_runner="$upx_exe_runner --suppressions=$PWD/misc/valgrind/musl.supp"
|
||||
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/zig/{} && bash ../../../../misc/testsuite/mimic_ctest.sh' ::: $jobs
|
||||
- name: Run file system test suite
|
||||
if: ${{ matrix.zig_target == 'i386-linux-musl' || matrix.zig_target == 'x86_64-linux-musl' || matrix.zig_target == 'x86_64-linux-gnu.2.3.4' }}
|
||||
run: |
|
||||
apk add coreutils sudo
|
||||
test -n "$NEED_GCOMPAT" && apk add gcompat
|
||||
jobs="${ZIG_TARGET}${ZIG_PIC}/debug ${ZIG_TARGET}${ZIG_PIC}/release"
|
||||
echo "===== parallel jobs: $jobs"
|
||||
parallel -kv --lb 'cd build/zig/{} && chmod a+w . && sudo -u nobody bash ../../../../misc/testsuite/test_symlinks.sh' ::: $jobs
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
# 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: GitHub - Close stale issues
|
||||
on:
|
||||
schedule: [cron: "50 0 * * 1"] # run weekly Monday 00:50 UTC
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
job-close-stale-issues:
|
||||
if: github.repository_owner == 'upx' && github.repository == 'upx/upx'
|
||||
name: Close stale issues
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
operations-per-run: 300
|
||||
exempt-all-milestones: true
|
||||
exempt-issue-labels: 'blocker,bug,enhancement,help wanted,regression'
|
||||
days-before-stale: 90
|
||||
days-before-close: 30
|
||||
stale-issue-message: 'This issue is stale because it has been open for 90 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 for 90 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 }}
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
/.hg*
|
||||
/.vscode*
|
||||
/Makevars.global*
|
||||
/Makevars[.-]global*
|
||||
/Testing*
|
||||
/build*
|
||||
/maint*
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
GNUmakefile*
|
||||
MMakefile*
|
||||
Makevars.local*
|
||||
Makevars[.-]local*
|
||||
compile_flags*.txt
|
||||
Tmp*
|
||||
tmp*
|
||||
@@ -16,6 +16,7 @@ tmp*
|
||||
*.a
|
||||
*.bz2
|
||||
*.d
|
||||
*.diff
|
||||
*.dll
|
||||
*.dylib
|
||||
*.exe
|
||||
|
||||
+60
-64
@@ -25,7 +25,7 @@ else()
|
||||
cmake_minimum_required(VERSION "3.8" FATAL_ERROR) # CMake >= 3.8 is needed for CXX_STANDARD 17
|
||||
endif()
|
||||
|
||||
# support functions
|
||||
# support functions and some utility
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/functions.cmake")
|
||||
|
||||
#***********************************************************************
|
||||
@@ -35,30 +35,31 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/functions.cmake")
|
||||
upx_cmake_include_hook(1_options)
|
||||
|
||||
# compilation config options
|
||||
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git" OR NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/use_strict_defaults.cmake")
|
||||
if(NOT USE_STRICT_DEFAULTS)
|
||||
# permissive config defaults when building from source code tarball
|
||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." ON)
|
||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." ON)
|
||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with Git version info." ON)
|
||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with sanitize options." ON)
|
||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with -Werror option." ON)
|
||||
option(UPX_CONFIG_DISABLE_WSTRICT "Do not compile with strict compiler warnings." ON)
|
||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." ON)
|
||||
else()
|
||||
# strict config defaults for Git developer builds
|
||||
message(STATUS "===== UPX info: strict config defaults enabled")
|
||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with default Git version info." OFF)
|
||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with default sanitize options." OFF)
|
||||
option(UPX_CONFIG_DISABLE_GITREV "Do not compile with Git version info." OFF)
|
||||
option(UPX_CONFIG_DISABLE_SANITIZE "Do not compile with sanitize options." OFF)
|
||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with -Werror option." OFF)
|
||||
option(UPX_CONFIG_DISABLE_WSTRICT "Do not compile with strict compiler warnings." OFF)
|
||||
option(UPX_CONFIG_DISABLE_WERROR "Do not compile with default -Werror option." OFF)
|
||||
endif()
|
||||
|
||||
# test config options (see below)
|
||||
# IMPORTANT NOTE: self-pack test can only work if the host executable format is supported by UPX!
|
||||
option(UPX_CONFIG_DISABLE_SELF_PACK_TEST "Do not test packing UPX with itself" OFF)
|
||||
option(UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS "Do not run exhaustive tests" OFF)
|
||||
|
||||
#***********************************************************************
|
||||
# init
|
||||
#***********************************************************************
|
||||
|
||||
set(UPX_VERSION_STRING "4.3.0")
|
||||
set(UPX_VERSION_STRING "4.2.4") # this should match src/version.h
|
||||
|
||||
upx_cmake_include_hook(2_init)
|
||||
|
||||
@@ -78,13 +79,16 @@ upx_cache_bool_vars(ON
|
||||
CMAKE_C_STANDARD_REQUIRED CMAKE_CXX_STANDARD_REQUIRED
|
||||
CMAKE_EXPORT_COMPILE_COMMANDS CMAKE_REQUIRED_QUIET
|
||||
)
|
||||
# internal UPX settings that default to OFF
|
||||
# internal UPX settings
|
||||
upx_cache_bool_vars(OFF
|
||||
UPX_CONFIG_CMAKE_DISABLE_TEST UPX_CONFIG_CMAKE_DISABLE_INSTALL
|
||||
UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK
|
||||
UPX_CONFIG_DISABLE_C_STANDARD UPX_CONFIG_DISABLE_CXX_STANDARD
|
||||
UPX_CONFIG_EXPECT_THREADS UPX_CONFIG_REQUIRE_THREADS
|
||||
UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST UPX_CONFIG_DISABLE_RUN_PACKED_TEST
|
||||
UPX_CONFIG_REQUIRE_THREADS
|
||||
)
|
||||
upx_cache_bool_vars(ON UPX_CONFIG_EXPECT_THREADS)
|
||||
upx_print_env_var(CC CXX)
|
||||
|
||||
# determine Git revision
|
||||
set(GITREV_SHORT "")
|
||||
@@ -129,13 +133,15 @@ else()
|
||||
endif()
|
||||
|
||||
# CMake init
|
||||
upx_default_build_type(Release)
|
||||
upx_set_default_build_type(Release) # default is CMAKE_BUILD_TYPE=Release
|
||||
project(upx VERSION "${UPX_VERSION_STRING}" LANGUAGES C CXX)
|
||||
upx_apply_build_type()
|
||||
|
||||
# set MSVC_FRONTEND and MINGW
|
||||
# set MSVC_FRONTEND, GNU_FRONTEND and MINGW
|
||||
if(NOT DEFINED MSVC_FRONTEND AND (MSVC OR CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^MSVC"))
|
||||
set(MSVC_FRONTEND 1)
|
||||
elseif (NOT DEFINED GNU_FRONTEND AND (CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "^GNU" OR CMAKE_C_COMPILER_ID MATCHES "(Clang|GNU)"))
|
||||
set(GNU_FRONTEND 1)
|
||||
endif()
|
||||
if(NOT DEFINED MINGW AND CMAKE_C_PLATFORM_ID MATCHES "^MinGW")
|
||||
set(MINGW 1)
|
||||
@@ -231,8 +237,9 @@ if(NOT CMAKE_C_COMPILER_ID MATCHES "^MSVC")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# examine MinGW/Cygwin compiler configuration
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
# examine compiler configuration
|
||||
if(NOT UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO)
|
||||
upx_print_common_symbols()
|
||||
upx_print_mingw_symbols()
|
||||
endif()
|
||||
|
||||
@@ -252,14 +259,20 @@ if(NOT UPX_CONFIG_DISABLE_THREADS)
|
||||
endif()
|
||||
# make sure that threads are indeed fully supported in C++
|
||||
if(Threads_FOUND)
|
||||
foreach(f std_lock_guard.cpp)
|
||||
foreach(f std_lock_guard.cpp types_abi.cpp)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE "EXECUTABLE")
|
||||
if(NOT UPX_CONFIG_DISABLE_CXX_STANDARD)
|
||||
try_compile(result "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/try_compile/${f}"
|
||||
OUTPUT_VARIABLE output CXX_STANDARD 17)
|
||||
else()
|
||||
try_compile(result "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/try_compile/${f}"
|
||||
OUTPUT_VARIABLE output)
|
||||
endif()
|
||||
if(NOT result)
|
||||
# failed; under MinGW be sure to use the posix-threads and NOT the win32-threads version
|
||||
#message(STATUS "Threads FAILED: ${output}") # debug output from try_compile
|
||||
#message(STATUS "Threads FAILED ${f}: ${output}") # debug output from try_compile
|
||||
set(Threads_FOUND OFF)
|
||||
break()
|
||||
endif()
|
||||
@@ -323,9 +336,10 @@ upx_sanitize_target(${t})
|
||||
target_compile_definitions(${t} PRIVATE BZ_NO_STDIO=1)
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_WN} -wd4127 -wd4244 -wd4267 ${warn_WX})
|
||||
else()
|
||||
elseif(GNU_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||
endif()
|
||||
upx_add_target_extra_compile_options(${t} UPX_CONFIG_EXTRA_COMPILE_OPTIONS_BZIP2)
|
||||
endif() # UPX_CONFIG_DISABLE_BZIP2
|
||||
|
||||
set(t upx_vendor_ucl)
|
||||
@@ -334,9 +348,10 @@ upx_compile_target_debug_with_O2(${t})
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_WN} ${warn_WX})
|
||||
else()
|
||||
elseif(GNU_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||
endif()
|
||||
upx_add_target_extra_compile_options(${t} UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UCL)
|
||||
|
||||
set(t upx_vendor_zlib)
|
||||
upx_compile_target_debug_with_O2(${t})
|
||||
@@ -347,10 +362,10 @@ if(HAVE_UNISTD_H)
|
||||
endif()
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE -W3 ${warn_WX})
|
||||
else()
|
||||
##target_compile_options(${t} PRIVATE -Wall ${warn_Werror})
|
||||
elseif(GNU_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} -Wno-cast-align -Wno-cast-qual ${warn_Werror})
|
||||
endif()
|
||||
upx_add_target_extra_compile_options(${t} UPX_CONFIG_EXTRA_COMPILE_OPTIONS_ZLIB)
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_ZSTD)
|
||||
set(t upx_vendor_zstd)
|
||||
@@ -359,9 +374,10 @@ upx_sanitize_target(${t})
|
||||
target_compile_definitions(${t} PRIVATE DYNAMIC_BMI2=0 ZSTD_DISABLE_ASM=1)
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_WN} ${warn_WX})
|
||||
else()
|
||||
elseif(GNU_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||
endif()
|
||||
upx_add_target_extra_compile_options(${t} UPX_CONFIG_EXTRA_COMPILE_OPTIONS_ZSTD)
|
||||
endif() # UPX_CONFIG_DISABLE_ZSTD
|
||||
|
||||
set(t upx)
|
||||
@@ -401,9 +417,10 @@ upx_compile_source_debug_with_O2(src/filter/filter_impl.cpp)
|
||||
upx_sanitize_target(${t})
|
||||
if(MSVC_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE -EHsc ${warn_WN} ${warn_WX})
|
||||
else()
|
||||
elseif(GNU_FRONTEND)
|
||||
target_compile_options(${t} PRIVATE ${warn_Wall} ${warn_Werror})
|
||||
endif()
|
||||
upx_add_target_extra_compile_options(${t} UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UPX)
|
||||
|
||||
#***********************************************************************
|
||||
# test
|
||||
@@ -418,30 +435,20 @@ if(NOT UPX_CONFIG_CMAKE_DISABLE_TEST)
|
||||
|
||||
include(CTest)
|
||||
if(NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
add_test(NAME upx-version COMMAND upx --version)
|
||||
add_test(NAME upx-help COMMAND upx --help)
|
||||
add_test(NAME upx-sysinfo COMMAND upx --sysinfo -v)
|
||||
if(NOT UPX_CONFIG_DISABLE_SELF_PACK_TEST)
|
||||
# IMPORTANT NOTE: these tests can only work if the host executable format is supported by UPX!
|
||||
set(emu "")
|
||||
if(DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
set(emu "${CMAKE_CROSSCOMPILING_EMULATOR}")
|
||||
upx_add_test(upx-version upx --version)
|
||||
upx_add_test(upx-version-short upx --version-short)
|
||||
upx_add_test(upx-license upx --license)
|
||||
upx_add_test(upx-help-1 upx --help)
|
||||
upx_add_test(upx-help-2 upx --help-short)
|
||||
upx_add_test(upx-help-3 upx --help-verbose)
|
||||
upx_add_test(upx-sysinfo-1 upx --sysinfo)
|
||||
upx_add_test(upx-sysinfo-2 upx --sysinfo -v)
|
||||
upx_add_test(upx-sysinfo-3 upx --sysinfo -vv)
|
||||
if(NOT UPX_CONFIG_DISABLE_SELF_PACK_TEST)
|
||||
# IMPORTANT NOTE: these tests can only work if the host executable format
|
||||
# is supported by UPX!
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/self_pack_test.cmake")
|
||||
endif()
|
||||
set(exe "${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
set(upx_self_exe "$<TARGET_FILE:upx>")
|
||||
set(fo "--force-overwrite")
|
||||
upx_add_serial_test(upx-self-pack upx -3 "${upx_self_exe}" ${fo} -o upx-packed${exe})
|
||||
upx_add_serial_test(upx-self-pack-n2b upx -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-n2b${exe})
|
||||
upx_add_serial_test(upx-self-pack-n2d upx -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-n2d${exe})
|
||||
upx_add_serial_test(upx-self-pack-n2e upx -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-n2e${exe})
|
||||
upx_add_serial_test(upx-self-pack-lzma upx -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe})
|
||||
upx_add_serial_test(upx-list upx -l upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_serial_test(upx-fileinfo upx --fileinfo upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_serial_test(upx-test upx -t upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_serial_test(upx-unpack upx -d upx-packed${exe} ${fo} -o upx-unpacked${exe})
|
||||
upx_add_serial_test(upx-run-unpacked ${emu} ./upx-unpacked${exe} --version-short)
|
||||
upx_add_serial_test(upx-run-packed ${emu} ./upx-packed${exe} --version-short)
|
||||
endif() # UPX_CONFIG_DISABLE_SELF_PACK_TEST
|
||||
endif()
|
||||
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_TEST
|
||||
@@ -486,20 +493,15 @@ upx_cmake_include_hook(8_summary)
|
||||
|
||||
upx_print_var(CMAKE_VERSION UPX_CONFIG_CMAKE_MINIMUM_REQUIRED_VERSION CMAKE_GENERATOR)
|
||||
if(NOT UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO)
|
||||
upx_print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION)
|
||||
upx_print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_CROSSCOMPILING CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
upx_print_var(CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_VERSION CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_C_COMPILER_ARCHITECTURE_ID CMAKE_C_PLATFORM_ID CMAKE_C_COMPILER_ABI)
|
||||
upx_print_var(CMAKE_CXX_COMPILER_ID CMAKE_CXX_COMPILER_VERSION CMAKE_CXX_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_ARCHITECTURE_ID CMAKE_CXX_PLATFORM_ID CMAKE_CXX_COMPILER_ABI)
|
||||
upx_print_var(CMAKE_INTERPROCEDURAL_OPTIMIZATION CMAKE_POSITION_INDEPENDENT_CODE CMAKE_TRY_COMPILE_CONFIGURATION)
|
||||
upx_print_var(CYGWIN GNUC MINGW MSVC MSVC_FRONTEND MSVC_IDE WIN32 WIN64)
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_PRINT_INFO
|
||||
upx_print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_BUILD_TYPE)
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/print_info.cmake")
|
||||
endif()
|
||||
upx_print_var(CMAKE_INSTALL_PREFIX CMAKE_CONFIGURATION_TYPES CMAKE_TRY_COMPILE_CONFIGURATION CMAKE_BUILD_TYPE)
|
||||
if(Threads_FOUND)
|
||||
message(STATUS "WITH_THREADS = 1")
|
||||
elseif(UPX_CONFIG_REQUIRE_THREADS)
|
||||
message(FATAL_ERROR "ERROR: WITH_THREADS required")
|
||||
elseif(UPX_CONFIG_EXPECT_THREADS AND NOT UPX_CONFIG_DISABLE_THREADS)
|
||||
message(FATAL_ERROR "ERROR: WITH_THREADS expected")
|
||||
message(FATAL_ERROR "ERROR: WITH_THREADS expected; set UPX_CONFIG_EXPECT_THREADS=OFF")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|None|Release)$")
|
||||
message(WARNING "WARNING: unsupported CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}; please use \"Debug\" or \"Release\"")
|
||||
@@ -507,16 +509,10 @@ endif()
|
||||
|
||||
# extra sanity checks to detect incompatible C vs CXX settings
|
||||
if(NOT UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK)
|
||||
if(NOT ",${CMAKE_C_PLATFORM_ID}," STREQUAL ",${CMAKE_CXX_PLATFORM_ID},")
|
||||
message(FATAL_ERROR "ERROR: CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID mismatch")
|
||||
upx_platform_check_mismatch(CMAKE_C_PLATFORM_ID CMAKE_CXX_PLATFORM_ID)
|
||||
upx_platform_check_mismatch(CMAKE_C_COMPILER_ABI CMAKE_CXX_COMPILER_ABI)
|
||||
upx_platform_check_mismatch(CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_FRONTEND_VARIANT)
|
||||
endif()
|
||||
if(NOT ",${CMAKE_C_COMPILER_ABI}," STREQUAL ",${CMAKE_CXX_COMPILER_ABI},")
|
||||
message(FATAL_ERROR "ERROR: CMAKE_C_COMPILER_ABI CMAKE_CXX_COMPILER_ABI mismatch")
|
||||
endif()
|
||||
if(NOT ",${CMAKE_C_COMPILER_FRONTEND_VARIANT}," STREQUAL ",${CMAKE_CXX_COMPILER_FRONTEND_VARIANT},")
|
||||
message(FATAL_ERROR "ERROR: CMAKE_C_COMPILER_FRONTEND_VARIANT CMAKE_CXX_COMPILER_FRONTEND_VARIANT mismatch")
|
||||
endif()
|
||||
endif() # UPX_CONFIG_CMAKE_DISABLE_PLATFORM_CHECK
|
||||
|
||||
upx_cmake_include_hook(9_finish)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/.upx_cmake_config_done.txt" "")
|
||||
|
||||
@@ -46,29 +46,43 @@ build/release: PHONY
|
||||
.SUFFIXES:
|
||||
|
||||
# shortcuts (all => debug + release)
|
||||
debug: build/debug
|
||||
release: build/release
|
||||
all build/all: build/debug build/release
|
||||
build/%/all: $$(dir $$@)debug $$(dir $$@)release ;
|
||||
debug: build/debug PHONY
|
||||
release: build/release PHONY
|
||||
all build/all: build/debug build/release PHONY
|
||||
build/%/all: $$(dir $$@)debug $$(dir $$@)release PHONY ;
|
||||
|
||||
#***********************************************************************
|
||||
# test
|
||||
#***********************************************************************
|
||||
|
||||
CTEST = ctest
|
||||
CTEST_JOBS ?= 8
|
||||
CTEST_FLAGS = --output-on-failure --parallel $(CTEST_JOBS)
|
||||
|
||||
build/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST) $(CTEST_FLAGS) -C Debug
|
||||
build/%/debug+test: $$(dir $$@)debug PHONY; cd "$(dir $@)debug" && $(CTEST) $(CTEST_FLAGS) -C Debug
|
||||
build/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST) $(CTEST_FLAGS) -C Release
|
||||
build/%/release+test: $$(dir $$@)release PHONY; cd "$(dir $@)release" && $(CTEST) $(CTEST_FLAGS) -C Release
|
||||
build/%/all+test: $$(dir $$@)debug+test $$(dir $$@)release+test PHONY ;
|
||||
|
||||
# shortcuts
|
||||
debug+test: build/debug+test PHONY
|
||||
release+test: build/release+test PHONY
|
||||
all+test build/all+test: build/debug+test build/release+test PHONY
|
||||
|
||||
test: $$(patsubst %+test,%,$$(.DEFAULT_GOAL))+test PHONY
|
||||
|
||||
#
|
||||
# END of Makefile
|
||||
#
|
||||
|
||||
# extra pre-defined build configurations and some utility; optional
|
||||
ifneq ($(MAKEFILE_LIST),)
|
||||
include $(dir $(lastword $(MAKEFILE_LIST)))/misc/make/Makefile-extra.mk
|
||||
else
|
||||
include ./misc/make/Makefile-extra.mk
|
||||
endif
|
||||
|
||||
# developer convenience
|
||||
CTEST = ctest
|
||||
test:: $(.DEFAULT_GOAL) PHONY
|
||||
cd $(.DEFAULT_GOAL) && $(CTEST)
|
||||
ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc.
|
||||
ifneq ($(wildcard ./misc/scripts/.),)
|
||||
check-whitespace clang-format run-testsuite run-testsuite-debug run-testsuite-release: src/Makefile PHONY
|
||||
check-whitespace clang-format run-testsuite run-testsuite-all run-testsuite-debug run-testsuite-release: src/Makefile PHONY
|
||||
$(MAKE) -C src $@
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
User visible changes for UPX
|
||||
==================================================================
|
||||
|
||||
Changes in 4.2.4 (09 May 2024):
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/17
|
||||
|
||||
Changes in 4.2.3 (27 Mar 2024):
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/16
|
||||
|
||||
Changes in 4.2.2 (03 Jan 2024):
|
||||
* bug fixes - see https://github.com/upx/upx/milestone/15
|
||||
|
||||
|
||||
+4
-1
@@ -3,7 +3,7 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
BUILT_SOURCES = upx.1 upx-doc.html upx-doc.txt
|
||||
BUILT_SOURCES := upx.1 upx-doc.html upx-doc.txt
|
||||
|
||||
top_srcdir ?= ..
|
||||
|
||||
@@ -25,6 +25,7 @@ DETAB2 := sed -e 's/$(tab)/ /g'
|
||||
#***********************************************************************
|
||||
|
||||
.DEFAULT_GOAL = all
|
||||
|
||||
.PHONY: PHONY
|
||||
.SECONDEXPANSION:
|
||||
.SUFFIXES:
|
||||
@@ -43,6 +44,8 @@ mostlyclean clean distclean maintainer-clean: PHONY
|
||||
%.1 : %.pod
|
||||
pod2man --center=" " --release="$(PACKAGE) $(VERSION)" --date="$(VERSION_DATE)" $< | $(RTRIM) > $@
|
||||
test -s $@
|
||||
# # strip version number from "Pod::Man" comment
|
||||
sed -i -e 's/^\(\.\\" Automatically generated by Pod::Man\).*/\1/' $@
|
||||
|
||||
%-doc.html : %.pod
|
||||
pod2html --noindex $< | $(RTRIM) | $(DETAB2) > $@
|
||||
|
||||
@@ -37,6 +37,8 @@ Charles W. Sandmann <sandmann@clio.rice.edu>
|
||||
for the idea with the stubless decompressor in djgpp2/coff
|
||||
Ice
|
||||
for debugging the PE headersize problem down
|
||||
Jens Medoch <jssg@users.sourceforge.net>
|
||||
for the ps1/exe format
|
||||
Joergen Ibsen <jibz@hotmail.com> and d'b
|
||||
for the relocation & address optimization ideas
|
||||
John S. Fine <johnfine@erols.com>
|
||||
|
||||
Generated
+1
-5
@@ -779,9 +779,7 @@ http://www.oberhumer.com
|
||||
|
||||
Laszlo Molnar <ezerotven+github@gmail.com>
|
||||
|
||||
John F. Reiser <jreiser@BitWagon.com>
|
||||
|
||||
Jens Medoch <jssg@users.sourceforge.net></code></pre>
|
||||
John F. Reiser <jreiser@BitWagon.com></code></pre>
|
||||
|
||||
<h1 id="COPYRIGHT">COPYRIGHT</h1>
|
||||
|
||||
@@ -791,8 +789,6 @@ Jens Medoch <jssg@users.sourceforge.net></code></pre>
|
||||
|
||||
<p>Copyright (C) 2000-2024 John F. Reiser</p>
|
||||
|
||||
<p>Copyright (C) 2002-2024 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>
|
||||
|
||||
Generated
-4
@@ -815,8 +815,6 @@ AUTHORS
|
||||
|
||||
John F. Reiser <jreiser@BitWagon.com>
|
||||
|
||||
Jens Medoch <jssg@users.sourceforge.net>
|
||||
|
||||
COPYRIGHT
|
||||
Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
@@ -824,8 +822,6 @@ COPYRIGHT
|
||||
|
||||
Copyright (C) 2000-2024 John F. Reiser
|
||||
|
||||
Copyright (C) 2002-2024 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
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
|
||||
.\" -*- mode: troff; coding: utf-8 -*-
|
||||
.\" Automatically generated by Pod::Man
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
@@ -15,29 +16,12 @@
|
||||
.ft R
|
||||
.fi
|
||||
..
|
||||
.\" Set up some character translations and predefined strings. \*(-- will
|
||||
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
|
||||
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
|
||||
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
|
||||
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
|
||||
.\" nothing in troff, for use with C<>.
|
||||
.tr \(*W-
|
||||
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
|
||||
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
|
||||
.ie n \{\
|
||||
. ds -- \(*W-
|
||||
. ds PI pi
|
||||
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
|
||||
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
|
||||
. ds L" ""
|
||||
. ds R" ""
|
||||
. ds C` ""
|
||||
. ds C' ""
|
||||
'br\}
|
||||
.el\{\
|
||||
. ds -- \|\(em\|
|
||||
. ds PI \(*p
|
||||
. ds L" ``
|
||||
. ds R" ''
|
||||
. ds C`
|
||||
. ds C'
|
||||
'br\}
|
||||
@@ -68,82 +52,20 @@
|
||||
. \}
|
||||
.\}
|
||||
.rr rF
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
. \" fudge factors for nroff and troff
|
||||
.if n \{\
|
||||
. ds #H 0
|
||||
. ds #V .8m
|
||||
. ds #F .3m
|
||||
. ds #[ \f1
|
||||
. ds #] \fP
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
|
||||
. ds #V .6m
|
||||
. ds #F 0
|
||||
. ds #[ \&
|
||||
. ds #] \&
|
||||
.\}
|
||||
. \" simple accents for nroff and troff
|
||||
.if n \{\
|
||||
. ds ' \&
|
||||
. ds ` \&
|
||||
. ds ^ \&
|
||||
. ds , \&
|
||||
. ds ~ ~
|
||||
. ds /
|
||||
.\}
|
||||
.if t \{\
|
||||
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
|
||||
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
|
||||
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
|
||||
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
|
||||
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
|
||||
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
|
||||
.\}
|
||||
. \" troff and (daisy-wheel) nroff accents
|
||||
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
|
||||
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
|
||||
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
|
||||
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
|
||||
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
|
||||
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
|
||||
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
|
||||
.ds ae a\h'-(\w'a'u*4/10)'e
|
||||
.ds Ae A\h'-(\w'A'u*4/10)'E
|
||||
. \" corrections for vroff
|
||||
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
|
||||
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
|
||||
. \" for low resolution devices (crt and lpr)
|
||||
.if \n(.H>23 .if \n(.V>19 \
|
||||
\{\
|
||||
. ds : e
|
||||
. ds 8 ss
|
||||
. ds o a
|
||||
. ds d- d\h'-1'\(ga
|
||||
. ds D- D\h'-1'\(hy
|
||||
. ds th \o'bp'
|
||||
. ds Th \o'LP'
|
||||
. ds ae ae
|
||||
. ds Ae AE
|
||||
.\}
|
||||
.rm #[ #] #H #V #F C
|
||||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "UPX 1"
|
||||
.TH UPX 1 "2024-01-03" "upx 4.2.2" " "
|
||||
.TH UPX 1 2024-05-09 "upx 4.2.4" " "
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
.nh
|
||||
.SH "NAME"
|
||||
.SH NAME
|
||||
upx \- compress or expand executable files
|
||||
.SH "SYNOPSIS"
|
||||
.SH SYNOPSIS
|
||||
.IX Header "SYNOPSIS"
|
||||
\&\fBupx\fR [\ \fIcommand\fR\ ] [\ \fIoptions\fR\ ] \fIfilename\fR...
|
||||
.SH "ABSTRACT"
|
||||
.SH ABSTRACT
|
||||
.IX Header "ABSTRACT"
|
||||
.Vb 3
|
||||
\& The Ultimate Packer for eXecutables
|
||||
@@ -151,27 +73,27 @@ upx \- compress or expand executable files
|
||||
\& https://upx.github.io
|
||||
.Ve
|
||||
.PP
|
||||
\&\fB\s-1UPX\s0\fR is a portable, extendable, high-performance executable packer for
|
||||
\&\fBUPX\fR is a portable, extendable, high-performance executable packer for
|
||||
several different executable formats. It achieves an excellent compression
|
||||
ratio and offers \fI*very*\fR fast decompression. Your executables suffer
|
||||
no memory overhead or other drawbacks for most of the formats supported,
|
||||
because of in-place decompression.
|
||||
.SH "DISCLAIMER"
|
||||
.SH DISCLAIMER
|
||||
.IX Header "DISCLAIMER"
|
||||
\&\fB\s-1UPX\s0\fR comes with \s-1ABSOLUTELY NO WARRANTY\s0; for details see the file \s-1COPYING.\s0
|
||||
\&\fBUPX\fR comes with ABSOLUTELY NO WARRANTY; for details see the file COPYING.
|
||||
.PP
|
||||
Please report all problems or suggestions to the authors. Thanks.
|
||||
.SH "SECURITY CONTEXT"
|
||||
.IX Header "SECURITY CONTEXT"
|
||||
\&\s-1IMPORTANT NOTE:\s0 \fB\s-1UPX\s0\fR inherits the security context of any files it handles.
|
||||
IMPORTANT NOTE: \fBUPX\fR inherits the security context of any files it handles.
|
||||
.PP
|
||||
This means that packing, unpacking, or even testing or listing a file requires
|
||||
the same security considerations as actually executing the file.
|
||||
.PP
|
||||
Use \fB\s-1UPX\s0\fR on trusted files only!
|
||||
.SH "DESCRIPTION"
|
||||
Use \fBUPX\fR on trusted files only!
|
||||
.SH DESCRIPTION
|
||||
.IX Header "DESCRIPTION"
|
||||
\&\fB\s-1UPX\s0\fR is a versatile executable packer with the following features:
|
||||
\&\fBUPX\fR is a versatile executable packer with the following features:
|
||||
.PP
|
||||
.Vb 3
|
||||
\& \- secure: as UPX is documented Open Source since many years any relevant
|
||||
@@ -204,32 +126,32 @@ Use \fB\s-1UPX\s0\fR on trusted files only!
|
||||
\& for commercial programs
|
||||
.Ve
|
||||
.PP
|
||||
You probably understand now why we call \fB\s-1UPX\s0\fR the "\fIultimate\fR"
|
||||
You probably understand now why we call \fBUPX\fR the "\fIultimate\fR"
|
||||
executable packer.
|
||||
.SH "COMMANDS"
|
||||
.SH COMMANDS
|
||||
.IX Header "COMMANDS"
|
||||
.SS "Compress"
|
||||
.SS Compress
|
||||
.IX Subsection "Compress"
|
||||
This is the default operation, eg. \fBupx yourfile.exe\fR will compress the file
|
||||
specified on the command line.
|
||||
.SS "Decompress"
|
||||
.SS Decompress
|
||||
.IX Subsection "Decompress"
|
||||
All \fB\s-1UPX\s0\fR supported file formats can be unpacked using the \fB\-d\fR switch, eg.
|
||||
All \fBUPX\fR supported file formats can be unpacked using the \fB\-d\fR switch, eg.
|
||||
\&\fBupx \-d yourfile.exe\fR will uncompress the file you've just compressed.
|
||||
.SS "Test"
|
||||
.SS Test
|
||||
.IX Subsection "Test"
|
||||
The \fB\-t\fR command tests the integrity of the compressed and uncompressed
|
||||
data, eg. \fBupx \-t yourfile.exe\fR 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.
|
||||
.SS "List"
|
||||
.SS List
|
||||
.IX Subsection "List"
|
||||
The \fB\-l\fR command prints out some information about the compressed files
|
||||
specified on the command line as parameters, eg \fBupx \-l yourfile.exe\fR
|
||||
shows the compressed / uncompressed size and the compression ratio of
|
||||
\&\fIyourfile.exe\fR.
|
||||
.SH "OPTIONS"
|
||||
.SH OPTIONS
|
||||
.IX Header "OPTIONS"
|
||||
\&\fB\-q\fR: be quiet, suppress warnings
|
||||
.PP
|
||||
@@ -239,10 +161,10 @@ shows the compressed / uncompressed size and the compression ratio of
|
||||
.PP
|
||||
\&\fB\-\-help\fR: prints the help
|
||||
.PP
|
||||
\&\fB\-\-version\fR: print the version of \fB\s-1UPX\s0\fR
|
||||
\&\fB\-\-version\fR: print the version of \fBUPX\fR
|
||||
.PP
|
||||
\&\fB\-\-exact\fR: when compressing, require to be able to get a byte-identical file
|
||||
after decompression with option \fB\-d\fR. [\s-1NOTE:\s0 this is work in progress and is
|
||||
after decompression with option \fB\-d\fR. [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
|
||||
@@ -255,16 +177,16 @@ as compared to the first decompressed version.]
|
||||
[ ...more docs need to be written... \- type `\fBupx \-\-help\fR' for now ]
|
||||
.SH "COMPRESSION LEVELS & TUNING"
|
||||
.IX Header "COMPRESSION LEVELS & TUNING"
|
||||
\&\fB\s-1UPX\s0\fR offers ten different compression levels from \fB\-1\fR to \fB\-9\fR,
|
||||
\&\fBUPX\fR offers ten different compression levels from \fB\-1\fR to \fB\-9\fR,
|
||||
and \fB\-\-best\fR. The default compression level is \fB\-8\fR for files
|
||||
smaller than 512 KiB, and \fB\-7\fR otherwise.
|
||||
.IP "\(bu" 4
|
||||
.IP \(bu 4
|
||||
Compression levels 1, 2 and 3 are pretty fast.
|
||||
.IP "\(bu" 4
|
||||
.IP \(bu 4
|
||||
Compression levels 4, 5 and 6 achieve a good time/ratio performance.
|
||||
.IP "\(bu" 4
|
||||
.IP \(bu 4
|
||||
Compression levels 7, 8 and 9 favor compression ratio over speed.
|
||||
.IP "\(bu" 4
|
||||
.IP \(bu 4
|
||||
Compression level \fB\-\-best\fR may take a long time.
|
||||
.PP
|
||||
Note that compression level \fB\-\-best\fR can be somewhat slow for large
|
||||
@@ -272,28 +194,28 @@ files, but you definitely should use it when releasing a final version
|
||||
of your program.
|
||||
.PP
|
||||
Quick info for achieving the best compression ratio:
|
||||
.IP "\(bu" 4
|
||||
.IP \(bu 4
|
||||
Try \fBupx \-\-brute \-\-no\-lzma myfile.exe\fR or even
|
||||
\&\fBupx \-\-ultra\-brute \-\-no\-lzma myfile.exe\fR.
|
||||
.IP "\(bu" 4
|
||||
The option \fB\-\-lzma\fR enables \s-1LZMA\s0 compression, which compresses better but
|
||||
.IP \(bu 4
|
||||
The option \fB\-\-lzma\fR enables LZMA compression, which compresses better but
|
||||
is *significantly slower* at decompression. You probably do not want
|
||||
to use it for large files.
|
||||
.Sp
|
||||
(Note that \fB\-\-lzma\fR is automatically enabled by \fB\-\-all\-methods\fR and
|
||||
\&\fB\-\-brute\fR, use \fB\-\-no\-lzma\fR to override.)
|
||||
.IP "\(bu" 4
|
||||
.IP \(bu 4
|
||||
Try if \fB\-\-overlay=strip\fR works.
|
||||
.IP "\(bu" 4
|
||||
.IP \(bu 4
|
||||
For win32/pe programs there's \fB\-\-strip\-relocs=0\fR. See notes below.
|
||||
.SH "OVERLAY HANDLING OPTIONS"
|
||||
.IX Header "OVERLAY HANDLING OPTIONS"
|
||||
Info: An \*(L"overlay\*(R" means auxiliary data attached after the logical end of
|
||||
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).
|
||||
.PP
|
||||
\&\fB\s-1UPX\s0\fR handles overlays like many other executable packers do: it simply
|
||||
\&\fBUPX\fR 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 overlaid data.
|
||||
@@ -309,8 +231,8 @@ actually accesses this overlaid data.
|
||||
.Ve
|
||||
.SH "ENVIRONMENT VARIABLE"
|
||||
.IX Header "ENVIRONMENT VARIABLE"
|
||||
The environment variable \fB\s-1UPX\s0\fR can hold a set of default
|
||||
options for \fB\s-1UPX\s0\fR. These options are interpreted first and
|
||||
The environment variable \fBUPX\fR can hold a set of default
|
||||
options for \fBUPX\fR. These options are interpreted first and
|
||||
can be overwritten by explicit command line parameters.
|
||||
For example:
|
||||
.PP
|
||||
@@ -321,18 +243,18 @@ For example:
|
||||
.Ve
|
||||
.PP
|
||||
Under DOS/Windows you must use '#' instead of '=' when setting the
|
||||
environment variable because of a \s-1COMMAND.COM\s0 limitation.
|
||||
environment variable because of a COMMAND.COM limitation.
|
||||
.PP
|
||||
Not all of the options are valid in the environment variable \-
|
||||
\&\fB\s-1UPX\s0\fR will tell you.
|
||||
\&\fBUPX\fR will tell you.
|
||||
.PP
|
||||
You can explicitly use the \fB\-\-no\-env\fR option to ignore the
|
||||
environment variable.
|
||||
.SH "NOTES FOR THE SUPPORTED EXECUTABLE FORMATS"
|
||||
.IX Header "NOTES FOR THE SUPPORTED EXECUTABLE FORMATS"
|
||||
.SS "\s-1NOTES FOR ATARI/TOS\s0"
|
||||
.SS "NOTES FOR ATARI/TOS"
|
||||
.IX Subsection "NOTES FOR ATARI/TOS"
|
||||
This is the executable format used by the Atari \s-1ST/TT,\s0 a Motorola 68000
|
||||
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 :\-).
|
||||
@@ -349,12 +271,12 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default method gives the best results anyway.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR BVMLINUZ/I386\s0"
|
||||
.SS "NOTES FOR BVMLINUZ/I386"
|
||||
.IX Subsection "NOTES FOR BVMLINUZ/I386"
|
||||
Same as vmlinuz/i386.
|
||||
.SS "\s-1NOTES FOR DOS/COM\s0"
|
||||
.SS "NOTES FOR DOS/COM"
|
||||
.IX Subsection "NOTES FOR DOS/COM"
|
||||
Obviously \fB\s-1UPX\s0\fR won't work with executables that want to read data from
|
||||
Obviously \fBUPX\fR won't work with executables that want to read data from
|
||||
themselves (like some commandline utilities that ship with Win95/98/ME).
|
||||
.PP
|
||||
Compressed programs only work on a 286+.
|
||||
@@ -378,11 +300,11 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default filter gives the best results anyway.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR DOS/EXE\s0"
|
||||
.SS "NOTES FOR DOS/EXE"
|
||||
.IX Subsection "NOTES FOR DOS/EXE"
|
||||
dos/exe stands for all \*(L"normal\*(R" 16\-bit \s-1DOS\s0 executables.
|
||||
dos/exe stands for all "normal" 16\-bit DOS executables.
|
||||
.PP
|
||||
Obviously \fB\s-1UPX\s0\fR won't work with executables that want to read data from
|
||||
Obviously \fBUPX\fR won't work with executables that want to read data from
|
||||
themselves (like some command line utilities that ship with Win95/98/ME).
|
||||
.PP
|
||||
Compressed programs only work on a 286+.
|
||||
@@ -399,7 +321,7 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default method gives the best results anyway.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR DOS/SYS\s0"
|
||||
.SS "NOTES FOR DOS/SYS"
|
||||
.IX Subsection "NOTES FOR DOS/SYS"
|
||||
Compressed programs only work on a 286+.
|
||||
.PP
|
||||
@@ -422,20 +344,20 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default filter gives the best results anyway.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR DJGPP2/COFF\s0"
|
||||
.SS "NOTES FOR DJGPP2/COFF"
|
||||
.IX Subsection "NOTES FOR DJGPP2/COFF"
|
||||
First of all, it is recommended to use \fB\s-1UPX\s0\fR *instead* of \fBstrip\fR. strip has
|
||||
First of all, it is recommended to use \fBUPX\fR *instead* of \fBstrip\fR. strip has
|
||||
the very bad habit of replacing your stub with its own (outdated) version.
|
||||
Additionally \fB\s-1UPX\s0\fR corrects a bug/feature in strip v2.8.x: it
|
||||
Additionally \fBUPX\fR corrects a bug/feature in strip v2.8.x: it
|
||||
will fix the 4 KiB alignment of the stub.
|
||||
.PP
|
||||
\&\fB\s-1UPX\s0\fR includes the full functionality of stubify. This means it will
|
||||
automatically stubify your \s-1COFF\s0 files. Use the option \fB\-\-coff\fR to
|
||||
\&\fBUPX\fR includes the full functionality of stubify. This means it will
|
||||
automatically stubify your COFF files. Use the option \fB\-\-coff\fR to
|
||||
disable this functionality (see below).
|
||||
.PP
|
||||
\&\fB\s-1UPX\s0\fR automatically handles Allegro packfiles.
|
||||
\&\fBUPX\fR automatically handles Allegro packfiles.
|
||||
.PP
|
||||
The \s-1DLM\s0 format (a rather exotic shared library extension) is not supported.
|
||||
The DLM format (a rather exotic shared library extension) is not supported.
|
||||
.PP
|
||||
Packed programs will be byte-identical to the original after uncompression.
|
||||
All debug information and trailing garbage will be stripped, though.
|
||||
@@ -456,7 +378,7 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default filter gives the best results anyway.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR LINUX\s0 [general]"
|
||||
.SS "NOTES FOR LINUX [general]"
|
||||
.IX Subsection "NOTES FOR LINUX [general]"
|
||||
Introduction
|
||||
.PP
|
||||
@@ -593,15 +515,15 @@ General notes:
|
||||
\& been modified after compression.
|
||||
\& Running \`strace \-o strace.log compressed_file\*(Aq will tell you more.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR LINUX/ELF386\s0"
|
||||
.SS "NOTES FOR LINUX/ELF386"
|
||||
.IX Subsection "NOTES FOR LINUX/ELF386"
|
||||
Please read the general Linux description first.
|
||||
.PP
|
||||
The linux/elf386 format decompresses directly into \s-1RAM,\s0
|
||||
The linux/elf386 format decompresses directly into RAM,
|
||||
uses only one exec, does not use space in /tmp,
|
||||
and does not use /proc.
|
||||
.PP
|
||||
Linux/elf386 is automatically selected for Linux \s-1ELF\s0 executables.
|
||||
Linux/elf386 is automatically selected for Linux ELF executables.
|
||||
.PP
|
||||
Packed programs will be byte-identical to the original after uncompression.
|
||||
.PP
|
||||
@@ -641,12 +563,12 @@ Extra options available for this executable format:
|
||||
.Vb 1
|
||||
\& (none)
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR LINUX/SH386\s0"
|
||||
.SS "NOTES FOR LINUX/SH386"
|
||||
.IX Subsection "NOTES FOR LINUX/SH386"
|
||||
Please read the general Linux description first.
|
||||
.PP
|
||||
Shell scripts where the underling shell accepts a ``\-c'' argument
|
||||
can use the Linux/sh386 format. \fB\s-1UPX\s0\fR decompresses the shell script
|
||||
can use the Linux/sh386 format. \fBUPX\fR 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.
|
||||
@@ -691,7 +613,7 @@ Extra options available for this executable format:
|
||||
.Vb 1
|
||||
\& (none)
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR LINUX/386\s0"
|
||||
.SS "NOTES FOR LINUX/386"
|
||||
.IX Subsection "NOTES FOR LINUX/386"
|
||||
Please read the general Linux description first.
|
||||
.PP
|
||||
@@ -764,10 +686,10 @@ Extra options available for this executable format:
|
||||
\& format, i.e. do not try the linux/elf386 and
|
||||
\& linux/sh386 formats.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR PS1/EXE\s0"
|
||||
.SS "NOTES FOR PS1/EXE"
|
||||
.IX Subsection "NOTES FOR PS1/EXE"
|
||||
This is the executable format used by the Sony PlayStation (PSone),
|
||||
a \s-1MIPS R3000\s0 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.
|
||||
.PP
|
||||
@@ -816,12 +738,12 @@ Extra options available for this executable format:
|
||||
\& but the compressed executable will not boot from a CD.
|
||||
\& Use it for console transfer only !
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR RTM32/PE\s0 and \s-1ARM/PE\s0"
|
||||
.SS "NOTES FOR RTM32/PE and ARM/PE"
|
||||
.IX Subsection "NOTES FOR RTM32/PE and ARM/PE"
|
||||
Same as win32/pe.
|
||||
.SS "\s-1NOTES FOR TMT/ADAM\s0"
|
||||
.SS "NOTES FOR TMT/ADAM"
|
||||
.IX Subsection "NOTES FOR TMT/ADAM"
|
||||
This format is used by the \s-1TMT\s0 Pascal compiler \- see http://www.tmt.com/ .
|
||||
This format is used by the TMT Pascal compiler \- see http://www.tmt.com/ .
|
||||
.PP
|
||||
Extra options available for this executable format:
|
||||
.PP
|
||||
@@ -836,11 +758,11 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default filter gives the best results anyway.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR VMLINUZ/386\s0"
|
||||
.SS "NOTES FOR VMLINUZ/386"
|
||||
.IX Subsection "NOTES FOR VMLINUZ/386"
|
||||
The vmlinuz/386 and bvmlinuz/386 formats take a gzip-compressed
|
||||
bootable Linux kernel image (\*(L"vmlinuz\*(R", \*(L"zImage\*(R", \*(L"bzImage\*(R"),
|
||||
gzip-decompress it and re-compress it with the \fB\s-1UPX\s0\fR compression method.
|
||||
bootable Linux kernel image ("vmlinuz", "zImage", "bzImage"),
|
||||
gzip-decompress it and re-compress it with the \fBUPX\fR compression method.
|
||||
.PP
|
||||
vmlinuz/386 is completely unrelated to the other Linux executable
|
||||
formats, and it does not share any of their drawbacks.
|
||||
@@ -889,14 +811,14 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default filter gives the best results anyway.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR WATCOM/LE\s0"
|
||||
.SS "NOTES FOR WATCOM/LE"
|
||||
.IX Subsection "NOTES FOR WATCOM/LE"
|
||||
\&\fB\s-1UPX\s0\fR has been successfully tested with the following extenders:
|
||||
\s-1DOS4G, DOS4GW, PMODE/W,\s0 DOS32a, CauseWay.
|
||||
The \s-1WDOS/X\s0 extender is partly supported (for details
|
||||
see the file bugs \s-1BUGS\s0).
|
||||
\&\fBUPX\fR 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).
|
||||
.PP
|
||||
DLLs and the \s-1LX\s0 format are not supported.
|
||||
DLLs and the LX format are not supported.
|
||||
.PP
|
||||
Extra options available for this executable format:
|
||||
.PP
|
||||
@@ -904,12 +826,12 @@ Extra options available for this executable format:
|
||||
\& \-\-le Produce an unbound LE output instead of
|
||||
\& keeping the current stub.
|
||||
.Ve
|
||||
.SS "\s-1NOTES FOR WIN32/PE\s0"
|
||||
.SS "NOTES FOR WIN32/PE"
|
||||
.IX Subsection "NOTES FOR WIN32/PE"
|
||||
The \s-1PE\s0 support in \fB\s-1UPX\s0\fR is quite stable now, but probably there are
|
||||
The PE support in \fBUPX\fR is quite stable now, but probably there are
|
||||
still some incompatibilities with some files.
|
||||
.PP
|
||||
Because of the way \fB\s-1UPX\s0\fR (and other packers for this format) works, you
|
||||
Because of the way \fBUPX\fR (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
|
||||
@@ -922,17 +844,17 @@ 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.
|
||||
.PP
|
||||
DLLs are supported. But \s-1UPX\s0 compressed DLLs can not share common data and
|
||||
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.
|
||||
.PP
|
||||
Screensavers are supported, with the restriction that the filename
|
||||
must end with \*(L".scr\*(R" (as screensavers are handled slightly different
|
||||
must end with ".scr" (as screensavers are handled slightly different
|
||||
than normal exe files).
|
||||
.PP
|
||||
\&\s-1UPX\s0 compressed \s-1PE\s0 files have some minor memory overhead (usually in the
|
||||
10 \- 30 KiB range) which can be seen by specifying the \*(L"\-i\*(R" command
|
||||
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.
|
||||
.PP
|
||||
Extra options available for this executable format:
|
||||
@@ -996,16 +918,16 @@ Extra options available for this executable format:
|
||||
\& the compression ratio in some cases, but usually
|
||||
\& the default filter gives the best results anyway.
|
||||
.Ve
|
||||
.SH "DIAGNOSTICS"
|
||||
.SH DIAGNOSTICS
|
||||
.IX Header "DIAGNOSTICS"
|
||||
Exit status is normally 0; if an error occurs, exit status
|
||||
is 1. If a warning occurs, exit status is 2.
|
||||
.PP
|
||||
\&\fB\s-1UPX\s0\fR's diagnostics are intended to be self-explanatory.
|
||||
.SH "BUGS"
|
||||
\&\fBUPX\fR's diagnostics are intended to be self-explanatory.
|
||||
.SH BUGS
|
||||
.IX Header "BUGS"
|
||||
Please report all bugs immediately to the authors.
|
||||
.SH "AUTHORS"
|
||||
.SH AUTHORS
|
||||
.IX Header "AUTHORS"
|
||||
.Vb 2
|
||||
\& Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
@@ -1014,10 +936,8 @@ Please report all bugs immediately to the authors.
|
||||
\& Laszlo Molnar <ezerotven+github@gmail.com>
|
||||
\&
|
||||
\& John F. Reiser <jreiser@BitWagon.com>
|
||||
\&
|
||||
\& Jens Medoch <jssg@users.sourceforge.net>
|
||||
.Ve
|
||||
.SH "COPYRIGHT"
|
||||
.SH COPYRIGHT
|
||||
.IX Header "COPYRIGHT"
|
||||
Copyright (C) 1996\-2024 Markus Franz Xaver Johannes Oberhumer
|
||||
.PP
|
||||
@@ -1025,18 +945,16 @@ Copyright (C) 1996\-2024 Laszlo Molnar
|
||||
.PP
|
||||
Copyright (C) 2000\-2024 John F. Reiser
|
||||
.PP
|
||||
Copyright (C) 2002\-2024 Jens Medoch
|
||||
.PP
|
||||
\&\fB\s-1UPX\s0\fR is distributed with full source code under the terms of the
|
||||
\&\s-1GNU\s0 General Public License v2+; either under the pure GPLv2+ (see
|
||||
the file \s-1COPYING\s0), or (at your option) under the GPLv+2 with special
|
||||
\&\fBUPX\fR 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 \s-1LICENSE\s0).
|
||||
including commercial programs (see the file LICENSE).
|
||||
.PP
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but \s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of
|
||||
\&\s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE.\s0
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
.PP
|
||||
You should have received a copy of the \s-1UPX\s0 License Agreements along
|
||||
with this program; see the files \s-1COPYING\s0 and \s-1LICENSE.\s0 If not,
|
||||
visit the \s-1UPX\s0 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.
|
||||
|
||||
@@ -926,8 +926,6 @@ Please report all bugs immediately to the authors.
|
||||
|
||||
John F. Reiser <jreiser@BitWagon.com>
|
||||
|
||||
Jens Medoch <jssg@users.sourceforge.net>
|
||||
|
||||
|
||||
|
||||
=head1 COPYRIGHT
|
||||
@@ -938,8 +936,6 @@ Copyright (C) 1996-2024 Laszlo Molnar
|
||||
|
||||
Copyright (C) 2000-2024 John F. Reiser
|
||||
|
||||
Copyright (C) 2002-2024 Jens Medoch
|
||||
|
||||
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
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
# vim:set ft=yaml ts=2 sw=2 et:
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# for clang-tidy from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
@@ -14,7 +16,7 @@ Checks: >
|
||||
-clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
-clang-analyzer-core.uninitialized.Assign,
|
||||
-clang-analyzer-security.insecureAPI.strcpy,
|
||||
clang-diagnostics-*',
|
||||
clang-diagnostic-*,
|
||||
performance-*,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
# vim:set ft=yaml ts=2 sw=2 et:
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# for clang-tidy from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-casting-through-void,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-inc-dec-in-conditions,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-reserved-identifier,
|
||||
-bugprone-sizeof-expression,
|
||||
-bugprone-suspicious-include,
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-diagnostics-*',
|
||||
clang-diagnostic-*,
|
||||
performance-*,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
# vim:set ft=yaml ts=2 sw=2 et:
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# for clang-tidy from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
@@ -6,6 +8,7 @@ Checks: >
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-inc-dec-in-conditions,
|
||||
-bugprone-macro-parentheses,
|
||||
-bugprone-narrowing-conversions,
|
||||
-bugprone-reserved-identifier,
|
||||
@@ -13,7 +16,7 @@ Checks: >
|
||||
clang-analyzer-*,
|
||||
-clang-analyzer-optin.performance.Padding,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-diagnostics-*',
|
||||
clang-diagnostic-*,
|
||||
performance-*,
|
||||
FormatStyle: file
|
||||
HeaderFilterRegex: '.*'
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
# for clang-tidy-16 from https://clang.llvm.org/extra/clang-tidy/
|
||||
# vim:set ft=yaml ts=2 sw=2 et:
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# for clang-tidy from https://clang.llvm.org/extra/clang-tidy/
|
||||
---
|
||||
Checks: >
|
||||
-*,
|
||||
bugprone-*,
|
||||
-bugprone-assignment-in-if-condition,
|
||||
-bugprone-branch-clone,
|
||||
-bugprone-casting-through-void,
|
||||
-bugprone-easily-swappable-parameters,
|
||||
-bugprone-implicit-widening-of-multiplication-result,
|
||||
-bugprone-macro-parentheses,
|
||||
@@ -16,7 +19,7 @@ Checks: >
|
||||
-clang-analyzer-core.UndefinedBinaryOperatorResult,
|
||||
-clang-analyzer-deadcode.DeadStores,
|
||||
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,
|
||||
clang-diagnostics-*',
|
||||
clang-diagnostic-*,
|
||||
performance-*,
|
||||
-performance-no-int-to-ptr,
|
||||
FormatStyle: file
|
||||
|
||||
+145
-18
@@ -3,6 +3,15 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# set USE_STRICT_DEFAULTS
|
||||
if(NOT DEFINED USE_STRICT_DEFAULTS AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/.git")
|
||||
include("${CMAKE_CURRENT_SOURCE_DIR}/misc/cmake/use_strict_defaults.cmake" OPTIONAL)
|
||||
endif()
|
||||
if(NOT DEFINED USE_STRICT_DEFAULTS)
|
||||
# use permissive config defaults when building from source code tarball
|
||||
set(USE_STRICT_DEFAULTS FALSE CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
#***********************************************************************
|
||||
# macros
|
||||
#***********************************************************************
|
||||
@@ -27,7 +36,7 @@ macro(upx_disallow_in_source_build)
|
||||
endmacro()
|
||||
|
||||
# set the default build type; must be called before project() cmake init
|
||||
macro(upx_default_build_type type)
|
||||
macro(upx_set_default_build_type type)
|
||||
set(upx_global_default_build_type "${type}")
|
||||
get_property(upx_global_is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT upx_global_is_multi_config AND NOT CMAKE_BUILD_TYPE)
|
||||
@@ -56,10 +65,38 @@ macro(upx_apply_build_type)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# ternary conditional operator
|
||||
macro(upx_ternary result_var_name condition true_value false_value)
|
||||
if(${condition})
|
||||
set(${result_var_name} "${true_value}")
|
||||
else()
|
||||
set(${result_var_name} "${false_value}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
#***********************************************************************
|
||||
# util
|
||||
#***********************************************************************
|
||||
|
||||
# convert to CMake bool
|
||||
function(upx_make_bool_var result_var_name var_name default_value)
|
||||
set(result "${default_value}")
|
||||
# only query $var_name if it is defined and not empty
|
||||
if(NOT ",${var_name}," STREQUAL ",,")
|
||||
if(DEFINED ${var_name})
|
||||
if(NOT ",${${var_name}}," STREQUAL ",,")
|
||||
set(result "${${var_name}}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(${result})
|
||||
set(result ON)
|
||||
else()
|
||||
set(result OFF)
|
||||
endif()
|
||||
set(${result_var_name} "${result}" PARENT_SCOPE) # return value
|
||||
endfunction()
|
||||
|
||||
function(upx_print_var) # ARGV
|
||||
foreach(var_name ${ARGV})
|
||||
if(DEFINED ${var_name})
|
||||
@@ -72,22 +109,41 @@ function(upx_print_var) # ARGV
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(upx_print_have_symbol) # ARGV; needs include(CheckSymbolExists)
|
||||
foreach(symbol ${ARGV})
|
||||
set(cache_var_name "HAVE_symbol_${symbol}")
|
||||
check_symbol_exists(${symbol} "limits.h;stddef.h;stdint.h" ${cache_var_name})
|
||||
if(${cache_var_name})
|
||||
message(STATUS "HAVE ${symbol}")
|
||||
function(upx_print_env_var) # ARGV
|
||||
foreach(var_name ${ARGV})
|
||||
if(DEFINED ENV{${var_name}})
|
||||
if(NOT ",$ENV{${var_name}}," STREQUAL ",,")
|
||||
message(STATUS "ENV{${var_name}} = '$ENV{${var_name}}'")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(upx_print_have_symbol) # ARGV; needs include(CheckSymbolExists)
|
||||
set(rq "${CMAKE_REQUIRED_QUIET}")
|
||||
set(CMAKE_REQUIRED_QUIET ON)
|
||||
foreach(symbol ${ARGV})
|
||||
set(cache_var_name "HAVE_symbol_${symbol}")
|
||||
check_symbol_exists("${symbol}" "limits.h;stddef.h;stdint.h" "${cache_var_name}")
|
||||
if(${cache_var_name})
|
||||
message(STATUS "HAVE_symbol ${symbol}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(CMAKE_REQUIRED_QUIET "${rq}")
|
||||
endfunction()
|
||||
|
||||
# examine compiler configuration
|
||||
function(upx_print_common_symbols)
|
||||
upx_print_have_symbol(__FAST_MATH__)
|
||||
upx_print_have_symbol(__PIC__ __pic__ __PIE__ __pie__)
|
||||
endfunction()
|
||||
|
||||
# examine MinGW/Cygwin compiler configuration
|
||||
function(upx_print_mingw_symbols)
|
||||
if(WIN32 OR MINGW OR CYGWIN)
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "(Clang|GNU)")
|
||||
# runtime library: msvcrt vs ucrt vs cygwin
|
||||
upx_print_have_symbol(__CRTDLL__ __CYGWIN__ __CYGWIN32__ __CYGWIN64__ __MINGW32__ __MINGW64__ __MINGW64_VERSION_MAJOR __MSVCRT__ _UCRT _WIN32 _WIN64)
|
||||
upx_print_have_symbol(__CRTDLL__ __CYGWIN__ __CYGWIN32__ __CYGWIN64__ __MINGW32__ __MINGW64__ __MINGW64_VERSION_MAJOR __MSVCRT__ __MSVCRT_VERSION__ _UCRT _WIN32 _WIN32_WINNT _WIN64)
|
||||
# exception handing: SJLJ (setjmp/longjmp) vs DWARF vs SEH
|
||||
upx_print_have_symbol(__GCC_HAVE_DWARF2_CFI_ASM __SEH__ __USING_SJLJ_EXCEPTIONS__)
|
||||
# threads: win32 vs posix/pthread/winpthreads vs mcfgthread
|
||||
@@ -100,7 +156,11 @@ endfunction()
|
||||
function(upx_add_glob_files) # ARGV
|
||||
set(var_name ${ARGV0})
|
||||
list(REMOVE_AT ARGV 0)
|
||||
if(${CMAKE_VERSION} VERSION_LESS "3.3")
|
||||
file(GLOB files ${ARGV})
|
||||
else()
|
||||
file(GLOB files LIST_DIRECTORIES false ${ARGV})
|
||||
endif()
|
||||
set(result "")
|
||||
if(DEFINED ${var_name})
|
||||
set(result "${${var_name}}")
|
||||
@@ -108,7 +168,25 @@ function(upx_add_glob_files) # ARGV
|
||||
list(APPEND result "${files}")
|
||||
list(SORT result)
|
||||
list(REMOVE_DUPLICATES result)
|
||||
##message(STATUS "upx_add_glob_files: ${var_name} = ${result}")
|
||||
#message(STATUS "upx_add_glob_files: ${var_name} = ${result}")
|
||||
set(${var_name} "${result}" PARENT_SCOPE) # return value
|
||||
endfunction()
|
||||
|
||||
# remove wildcard expansions from a variable
|
||||
function(upx_remove_glob_files) # ARGV
|
||||
set(var_name ${ARGV0})
|
||||
list(REMOVE_AT ARGV 0)
|
||||
file(GLOB files ${ARGV})
|
||||
set(result "")
|
||||
if(DEFINED ${var_name})
|
||||
set(result "${${var_name}}")
|
||||
foreach(file ${files})
|
||||
list(REMOVE_ITEM result "${file}")
|
||||
endforeach()
|
||||
list(SORT result)
|
||||
list(REMOVE_DUPLICATES result)
|
||||
endif()
|
||||
#message(STATUS "upx_remove_glob_files: ${var_name} = ${result}")
|
||||
set(${var_name} "${result}" PARENT_SCOPE) # return value
|
||||
endfunction()
|
||||
|
||||
@@ -122,10 +200,10 @@ function(upx_cache_bool_vars) # ARGV
|
||||
set(value "${UPX_CACHE_VALUE_${var_name}}")
|
||||
elseif(DEFINED ${var_name}) # defined via "cmake -DXXX=YYY"
|
||||
set(value "${${var_name}}")
|
||||
elseif(DEFINED ENV{${var_name}})
|
||||
if("$ENV{${var_name}}" MATCHES "^(0|1|OFF|ON|FALSE|TRUE)$") # check environment
|
||||
elseif(DEFINED ENV{${var_name}}) # check environment
|
||||
if("$ENV{${var_name}}" MATCHES "^(0|1|OFF|ON|FALSE|TRUE|off|on|false|true)$")
|
||||
set(value "$ENV{${var_name}}")
|
||||
set(UPX_CACHE_ORIGIN_FROM_ENV_${var_name} TRUE CACHE INTERNAL "" FORCE) # for info below
|
||||
set(UPX_CACHE_ORIGIN_FROM_ENV_${var_name} TRUE CACHE INTERNAL "" FORCE) # for status message below
|
||||
endif()
|
||||
endif()
|
||||
# convert to bool
|
||||
@@ -143,13 +221,25 @@ function(upx_cache_bool_vars) # ARGV
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(upx_platform_check_mismatch var_name_1 var_name_2)
|
||||
if(DEFINED ${var_name_1} OR DEFINED ${var_name_2})
|
||||
if(NOT ",${${var_name_1}}," STREQUAL ",${${var_name_2}},")
|
||||
if(UPX_CONFIG_DISABLE_WERROR)
|
||||
message(WARNING "WARNING: '${var_name_1}' '${var_name_2}' mismatch")
|
||||
else()
|
||||
message(FATAL_ERROR "FATAL ERROR: '${var_name_1}' '${var_name_2}' mismatch")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
#***********************************************************************
|
||||
# compilation flags
|
||||
#***********************************************************************
|
||||
|
||||
function(upx_internal_add_definitions_with_prefix) # ARGV; needs include(CheckCCompilerFlag)
|
||||
set(flag_prefix "${ARGV0}")
|
||||
if(flag_prefix MATCHES "^empty$") # need "empty" to work around bug in old CMake versions
|
||||
if("${flag_prefix}" MATCHES "^empty$") # need "empty" to work around bug in old CMake versions
|
||||
set(flag_prefix "")
|
||||
endif()
|
||||
list(REMOVE_AT ARGV 0)
|
||||
@@ -179,6 +269,27 @@ function(upx_add_definitions) # ARGV; needs include(CheckCCompilerFlag)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# useful for CI jobs: allow target extra compile options
|
||||
function(upx_add_target_extra_compile_options) # ARGV
|
||||
set(t "${ARGV0}")
|
||||
list(REMOVE_AT ARGV 0)
|
||||
foreach(var_name ${ARGV})
|
||||
if(NOT DEFINED ${var_name})
|
||||
elseif(",${${var_name}}," STREQUAL ",,")
|
||||
else()
|
||||
set(flags "${${var_name}}")
|
||||
if(NOT flags MATCHES ";") # NOTE: split into list from string only if not already a list
|
||||
if(${CMAKE_VERSION} VERSION_GREATER "3.8.99")
|
||||
separate_arguments(flags NATIVE_COMMAND "${flags}")
|
||||
else()
|
||||
separate_arguments(flags)
|
||||
endif()
|
||||
endif()
|
||||
target_compile_options(${t} PRIVATE "${flags}")
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# compile a target with -O2 optimization even in Debug build
|
||||
function(upx_compile_target_debug_with_O2) # ARGV
|
||||
foreach(t ${ARGV})
|
||||
@@ -209,7 +320,7 @@ function(upx_compile_source_debug_with_O2) # ARGV
|
||||
# MSVC uses some Debug compilation options like -RTC1 that are incompatible with -O2
|
||||
else()
|
||||
get_source_file_property(prop "${source}" COMPILE_FLAGS)
|
||||
if(prop MATCHES "^(NOTFOUND)?$")
|
||||
if("${prop}" MATCHES "^(NOTFOUND)?$")
|
||||
set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${flags}")
|
||||
else()
|
||||
set_source_files_properties("${source}" PROPERTIES COMPILE_FLAGS "${prop} ${flags}")
|
||||
@@ -218,18 +329,24 @@ function(upx_compile_source_debug_with_O2) # ARGV
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# sanitize a target: this needs proper support from your compiler AND toolchain
|
||||
# sanitize a target; note that this may require special run-time support libs from your toolchain
|
||||
function(upx_sanitize_target) # ARGV
|
||||
foreach(t ${ARGV})
|
||||
if(UPX_CONFIG_DISABLE_SANITIZE)
|
||||
# no-op
|
||||
elseif(MSVC_FRONTEND)
|
||||
# MSVC uses -GS (similar to -fstack-protector) by default
|
||||
elseif(NOT GNU_FRONTEND)
|
||||
# unknown compiler
|
||||
elseif(MINGW OR CYGWIN)
|
||||
# avoid link errors with current MinGW-w64 versions
|
||||
# see https://www.mingw-w64.org/contribute/#sanitizers-asan-tsan-usan
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "^Clang$" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "9.0")
|
||||
# unreliable/broken sanitize implementation before clang-9 (Sep 2019)
|
||||
message(WARNING "WARNING: ignoring SANITIZE for target '${t}'")
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "^GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "8.0")
|
||||
# unsupported compiler; unreliable/broken sanitize implementation
|
||||
# unsupported compiler; unreliable/broken sanitize implementation before gcc-8 (May 2018)
|
||||
message(WARNING "WARNING: ignoring SANITIZE for target '${t}'")
|
||||
else()
|
||||
# default sanitizer for Debug builds
|
||||
target_compile_options(${t} PRIVATE $<$<CONFIG:Debug>:-fsanitize=undefined -fsanitize-undefined-trap-on-error -fstack-protector-all>)
|
||||
@@ -245,11 +362,21 @@ endfunction()
|
||||
# test
|
||||
#***********************************************************************
|
||||
|
||||
function(upx_add_serial_test) # ARGV
|
||||
function(upx_add_test) # ARGV
|
||||
set(name "${ARGV0}")
|
||||
list(REMOVE_AT ARGV 0)
|
||||
add_test(NAME "${name}" COMMAND ${ARGV})
|
||||
set_tests_properties("${name}" PROPERTIES RUN_SERIAL TRUE) # run these tests sequentially
|
||||
endfunction()
|
||||
|
||||
function(upx_test_depends) # ARGV
|
||||
set(name "${ARGV0}")
|
||||
list(REMOVE_AT ARGV 0)
|
||||
get_property(prop TEST "${name}" PROPERTY DEPENDS)
|
||||
if("${prop}" MATCHES "^(NOTFOUND)?$")
|
||||
set_tests_properties("${name}" PROPERTIES DEPENDS "${ARGV}")
|
||||
else()
|
||||
set_tests_properties("${name}" PROPERTIES DEPENDS "${prop};${ARGV}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# UPX "CMake" build file; see https://cmake.org/
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
#***********************************************************************
|
||||
# summary section
|
||||
# print some info about the build configuration
|
||||
#***********************************************************************
|
||||
|
||||
# generator
|
||||
upx_print_var(CMAKE_GENERATOR_TOOLSET CMAKE_GENERATOR_PLATFORM)
|
||||
|
||||
# directories
|
||||
if(NOT ",${CMAKE_BINARY_DIR}," STREQUAL ",${CMAKE_CURRENT_BINARY_DIR}," OR NOT ",${CMAKE_SOURCE_DIR}," STREQUAL ",${CMAKE_CURRENT_SOURCE_DIR},")
|
||||
upx_print_var(CMAKE_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_SOURCE_DIR)
|
||||
endif()
|
||||
|
||||
# system
|
||||
upx_print_var(CMAKE_HOST_SYSTEM_NAME CMAKE_HOST_SYSTEM_VERSION CMAKE_HOST_SYSTEM_PROCESSOR)
|
||||
upx_print_var(CMAKE_SYSTEM_NAME CMAKE_SYSTEM_VERSION CMAKE_SYSTEM_PROCESSOR)
|
||||
upx_print_var(CMAKE_ANDROID_NDK CMAKE_ANDROID_NDK_VERSION CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
|
||||
upx_print_var(CMAKE_APPLE_SILICON_PROCESSOR CMAKE_OSX_DEPLOYMENT_TARGET CMAKE_OSX_SYSROOT)
|
||||
upx_print_Var(CMAKE_CROSSCOMPILING CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
|
||||
# binutils
|
||||
upx_print_var(CMAKE_AR CMAKE_RANLIB)
|
||||
|
||||
# compilers
|
||||
foreach(lang IN ITEMS ASM C CXX)
|
||||
upx_print_var(CMAKE_${lang}_COMPILER_LAUNCHER)
|
||||
upx_print_var(CMAKE_${lang}_COMPILER)
|
||||
upx_print_var(CMAKE_${lang}_COMPILER_ID)
|
||||
upx_print_var(CMAKE_${lang}_COMPILER_VERSION)
|
||||
upx_print_var(CMAKE_${lang}_COMPILER_FRONTEND_VARIANT )
|
||||
upx_print_var(CMAKE_${lang}_COMPILER_ARCHITECTURE_ID)
|
||||
upx_print_var(CMAKE_${lang}_PLATFORM_ID)
|
||||
upx_print_var(CMAKE_${lang}_COMPILER_ABI)
|
||||
upx_print_var(CMAKE_${lang}_COMPILER_TARGET)
|
||||
endforeach()
|
||||
|
||||
# misc
|
||||
upx_print_var(CMAKE_INTERPROCEDURAL_OPTIMIZATION CMAKE_POSITION_INDEPENDENT_CODE)
|
||||
|
||||
# shortcuts
|
||||
upx_print_var(APPLE CLANG CYGWIN GNU_FRONTEND GNUC MINGW MSVC MSVC_FRONTEND MSVC_IDE MSVC_TOOLSET_VERSION MSVC_VERSION MSYS UNIX WIN32 WIN64)
|
||||
|
||||
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
|
||||
@@ -0,0 +1,148 @@
|
||||
#
|
||||
# UPX "CMake" build file; see https://cmake.org/
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
#***********************************************************************
|
||||
# test section: self-pack tests
|
||||
#
|
||||
# IMPORTANT NOTE: these tests can only work if the host executable format
|
||||
# is supported by UPX!
|
||||
#***********************************************************************
|
||||
|
||||
set(emu "")
|
||||
if(DEFINED CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
set(emu "${CMAKE_CROSSCOMPILING_EMULATOR}")
|
||||
endif()
|
||||
set(exe "${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
set(upx_self_exe "$<TARGET_FILE:upx>")
|
||||
set(fo "--force-overwrite")
|
||||
|
||||
#
|
||||
# basic tests
|
||||
#
|
||||
|
||||
upx_add_test(upx-self-pack upx -3 "${upx_self_exe}" ${fo} -o upx-packed${exe})
|
||||
upx_add_test(upx-self-pack-fa upx -3 --all-filters "${upx_self_exe}" ${fo} -o upx-packed-fa${exe})
|
||||
upx_add_test(upx-self-pack-fn upx -3 --no-filter "${upx_self_exe}" ${fo} -o upx-packed-fn${exe})
|
||||
upx_add_test(upx-self-pack-fr upx -3 --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-fr${exe})
|
||||
upx_add_test(upx-self-pack-nrv2b upx -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-nrv2b${exe})
|
||||
upx_add_test(upx-self-pack-nrv2d upx -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-nrv2d${exe})
|
||||
upx_add_test(upx-self-pack-nrv2e upx -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-nrv2e${exe})
|
||||
upx_add_test(upx-self-pack-lzma upx -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe})
|
||||
|
||||
upx_add_test(upx-list upx -l upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_test(upx-fileinfo upx --fileinfo upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
|
||||
upx_add_test(upx-test upx -t upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe})
|
||||
|
||||
upx_add_test(upx-unpack upx -d upx-packed${exe} ${fo} -o upx-unpacked${exe})
|
||||
upx_add_test(upx-unpack-fa upx -d upx-packed-fa${exe} ${fo} -o upx-unpacked-fa${exe})
|
||||
upx_add_test(upx-unpack-fn upx -d upx-packed-fn${exe} ${fo} -o upx-unpacked-fn${exe})
|
||||
upx_add_test(upx-unpack-fr upx -d upx-packed-fr${exe} ${fo} -o upx-unpacked-fr${exe})
|
||||
upx_add_test(upx-unpack-nrv2b upx -d upx-packed-nrv2b${exe} ${fo} -o upx-unpacked-nrv2b${exe})
|
||||
upx_add_test(upx-unpack-nrv2d upx -d upx-packed-nrv2d${exe} ${fo} -o upx-unpacked-nrv2d${exe})
|
||||
upx_add_test(upx-unpack-nrv2e upx -d upx-packed-nrv2e${exe} ${fo} -o upx-unpacked-nrv2e${exe})
|
||||
upx_add_test(upx-unpack-lzma upx -d upx-packed-lzma${exe} ${fo} -o upx-unpacked-lzma${exe})
|
||||
|
||||
# all unpacked files must be identical
|
||||
upx_add_test(upx-compare-fa "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fa${exe})
|
||||
upx_add_test(upx-compare-fn "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fn${exe})
|
||||
upx_add_test(upx-compare-fr "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-fr${exe})
|
||||
upx_add_test(upx-compare-nrv2b "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2b${exe})
|
||||
upx_add_test(upx-compare-nrv2d "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2d${exe})
|
||||
upx_add_test(upx-compare-nrv2e "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-nrv2e${exe})
|
||||
upx_add_test(upx-compare-lzma "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-lzma${exe})
|
||||
|
||||
# test dependencies
|
||||
upx_test_depends(upx-list "upx-self-pack;upx-self-pack-fa;upx-self-pack-fn;upx-self-pack-fr;upx-self-pack-nrv2b;upx-self-pack-nrv2d;upx-self-pack-nrv2e;upx-self-pack-lzma")
|
||||
upx_test_depends(upx-fileinfo "upx-self-pack;upx-self-pack-fa;upx-self-pack-fn;upx-self-pack-fr;upx-self-pack-nrv2b;upx-self-pack-nrv2d;upx-self-pack-nrv2e;upx-self-pack-lzma")
|
||||
upx_test_depends(upx-test "upx-self-pack;upx-self-pack-fa;upx-self-pack-fn;upx-self-pack-fr;upx-self-pack-nrv2b;upx-self-pack-nrv2d;upx-self-pack-nrv2e;upx-self-pack-lzma")
|
||||
upx_test_depends(upx-unpack upx-self-pack)
|
||||
upx_test_depends(upx-unpack-fa upx-self-pack-fa)
|
||||
upx_test_depends(upx-unpack-fn upx-self-pack-fn)
|
||||
upx_test_depends(upx-unpack-fr upx-self-pack-fr)
|
||||
upx_test_depends(upx-unpack-nrv2b upx-self-pack-nrv2b)
|
||||
upx_test_depends(upx-unpack-nrv2d upx-self-pack-nrv2d)
|
||||
upx_test_depends(upx-unpack-nrv2e upx-self-pack-nrv2e)
|
||||
upx_test_depends(upx-unpack-lzma upx-self-pack-lzma)
|
||||
upx_test_depends(upx-compare-fa "upx-unpack;upx-unpack-fa")
|
||||
upx_test_depends(upx-compare-fn "upx-unpack;upx-unpack-fn")
|
||||
upx_test_depends(upx-compare-fr "upx-unpack;upx-unpack-fr")
|
||||
upx_test_depends(upx-compare-nrv2b "upx-unpack;upx-unpack-nrv2b")
|
||||
upx_test_depends(upx-compare-nrv2d "upx-unpack;upx-unpack-nrv2d")
|
||||
upx_test_depends(upx-compare-nrv2e "upx-unpack;upx-unpack-nrv2e")
|
||||
upx_test_depends(upx-compare-lzma "upx-unpack;upx-unpack-lzma")
|
||||
# tests with higher COST values will run first
|
||||
set_tests_properties(upx-self-pack PROPERTIES COST 90)
|
||||
set_tests_properties(upx-self-pack-fa PROPERTIES COST 20)
|
||||
set_tests_properties(upx-self-pack-fn PROPERTIES COST 20)
|
||||
set_tests_properties(upx-self-pack-fr PROPERTIES COST 20)
|
||||
set_tests_properties(upx-self-pack-nrv2b PROPERTIES COST 20)
|
||||
set_tests_properties(upx-self-pack-nrv2d PROPERTIES COST 20)
|
||||
set_tests_properties(upx-self-pack-nrv2e PROPERTIES COST 20)
|
||||
set_tests_properties(upx-self-pack-lzma PROPERTIES COST 30)
|
||||
set_tests_properties(upx-unpack PROPERTIES COST 10)
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST)
|
||||
upx_add_test(upx-run-unpacked ${emu} ./upx-unpacked${exe} --version-short)
|
||||
upx_test_depends(upx-run-unpacked upx-unpack)
|
||||
endif()
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST)
|
||||
upx_add_test(upx-run-packed ${emu} ./upx-packed${exe} --version-short)
|
||||
upx_add_test(upx-run-packed-fa ${emu} ./upx-packed-fa${exe} --version-short)
|
||||
upx_add_test(upx-run-packed-fn ${emu} ./upx-packed-fn${exe} --version-short)
|
||||
upx_add_test(upx-run-packed-fr ${emu} ./upx-packed-fr${exe} --version-short)
|
||||
upx_add_test(upx-run-packed-nrv2b ${emu} ./upx-packed-nrv2b${exe} --version-short)
|
||||
upx_add_test(upx-run-packed-nrv2d ${emu} ./upx-packed-nrv2d${exe} --version-short)
|
||||
upx_add_test(upx-run-packed-nrv2e ${emu} ./upx-packed-nrv2e${exe} --version-short)
|
||||
upx_add_test(upx-run-packed-lzma ${emu} ./upx-packed-lzma${exe} --version-short)
|
||||
upx_test_depends(upx-run-packed upx-self-pack)
|
||||
upx_test_depends(upx-run-packed-fa upx-self-pack-fa)
|
||||
upx_test_depends(upx-run-packed-fn upx-self-pack-fn)
|
||||
upx_test_depends(upx-run-packed-fr upx-self-pack-fr)
|
||||
upx_test_depends(upx-run-packed-nrv2b upx-self-pack-nrv2b)
|
||||
upx_test_depends(upx-run-packed-nrv2d upx-self-pack-nrv2d)
|
||||
upx_test_depends(upx-run-packed-nrv2e upx-self-pack-nrv2e)
|
||||
upx_test_depends(upx-run-packed-lzma upx-self-pack-lzma)
|
||||
endif()
|
||||
|
||||
#
|
||||
# exhaustive tests
|
||||
#
|
||||
|
||||
if(NOT UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS)
|
||||
foreach(method IN ITEMS nrv2b nrv2d nrv2e lzma)
|
||||
foreach(level IN ITEMS 1 2 3 4 5 6 7)
|
||||
set(s "${method}-${level}")
|
||||
upx_add_test(upx-self-pack-${s} upx --${method} -${level} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe})
|
||||
upx_add_test(upx-list-${s} upx -l upx-packed-${s}${exe})
|
||||
upx_add_test(upx-fileinfo-${s} upx --fileinfo upx-packed-${s}${exe})
|
||||
upx_add_test(upx-test-${s} upx -t upx-packed-${s}${exe})
|
||||
upx_add_test(upx-unpack-${s} upx -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe})
|
||||
upx_add_test(upx-compare-${s} "${CMAKE_COMMAND}" -E compare_files upx-unpacked${exe} upx-unpacked-${s}${exe})
|
||||
upx_test_depends(upx-list-${s} upx-self-pack-${s})
|
||||
upx_test_depends(upx-fileinfo-${s} upx-self-pack-${s})
|
||||
upx_test_depends(upx-test-${s} upx-self-pack-${s})
|
||||
upx_test_depends(upx-unpack-${s} upx-self-pack-${s})
|
||||
upx_test_depends(upx-compare-${s} "upx-unpack;upx-unpack-${s}")
|
||||
if(method MATCHES "lzma")
|
||||
set_tests_properties(upx-self-pack-${s} PROPERTIES COST "3${level}")
|
||||
else()
|
||||
set_tests_properties(upx-self-pack-${s} PROPERTIES COST "2${level}")
|
||||
endif()
|
||||
if(NOT UPX_CONFIG_DISABLE_RUN_PACKED_TEST)
|
||||
upx_add_test(upx-run-packed-${s} ${emu} ./upx-packed-${s}${exe} --version-short)
|
||||
upx_test_depends(upx-run-packed-${s} upx-self-pack-${s})
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif () # UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS
|
||||
|
||||
# clean up
|
||||
set(emu "")
|
||||
set(exe "")
|
||||
set(upx_self_exe "")
|
||||
set(fo "")
|
||||
|
||||
# vim:set ft=cmake ts=4 sw=4 tw=0 et:
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// check ABI - require proper alignment of fundamental types for use in atomics
|
||||
static_assert(alignof(char) == sizeof(char), "");
|
||||
static_assert(alignof(signed char) == sizeof(signed char), "");
|
||||
static_assert(alignof(unsigned char) == sizeof(unsigned char), "");
|
||||
static_assert(alignof(short) == sizeof(short), "");
|
||||
static_assert(alignof(unsigned short) == sizeof(unsigned short), "");
|
||||
static_assert(alignof(int) == sizeof(int), "");
|
||||
static_assert(alignof(unsigned int) == sizeof(unsigned int), "");
|
||||
static_assert(alignof(long) == sizeof(long), "");
|
||||
static_assert(alignof(unsigned long) == sizeof(unsigned long), "");
|
||||
static_assert(alignof(ptrdiff_t) == sizeof(ptrdiff_t), "");
|
||||
static_assert(alignof(size_t) == sizeof(size_t), "");
|
||||
static_assert(alignof(intptr_t) == sizeof(intptr_t), "");
|
||||
static_assert(alignof(uintptr_t) == sizeof(uintptr_t), "");
|
||||
static_assert(alignof(void *) == sizeof(void *), "");
|
||||
|
||||
int main() { return 0; }
|
||||
+101
-58
@@ -6,15 +6,30 @@
|
||||
ifeq ($(UPX_MAKEFILE_EXTRA_MK_INCLUDED),)
|
||||
override UPX_MAKEFILE_EXTRA_MK_INCLUDED := 1
|
||||
|
||||
#***********************************************************************
|
||||
# support functions
|
||||
#***********************************************************************
|
||||
|
||||
override check_defined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),$(error ERROR: variable '$1' is not defined),))
|
||||
override check_undefined = $(foreach 1,$1,$(if $(filter undefined,$(origin $1)),,$(error ERROR: variable '$1' is already defined)))
|
||||
$(call check_defined,run_config run_build)
|
||||
$(call check_undefined,run_config_and_build)
|
||||
|
||||
# return "1" or empty-string
|
||||
override eq = $(if $(subst x$1,,x$2)$(subst x$2,,x$1),,1)
|
||||
override ne = $(if $(subst x$1,,x$2)$(subst x$2,,x$1),1,)
|
||||
|
||||
override tolower = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
|
||||
override toupper = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
|
||||
|
||||
# canonicalize case of CMAKE_BUILD_TYPE to "Debug" and "Release"
|
||||
override cm_build_type = $(if $(call eq,$1,),$(error EMPTY-build-type),$(if $(call eq,$(call tolower,$1),debug),Debug,$(if $(call eq,$(call tolower,$1),release),Release,$(if $(call eq,$(call tolower,$1),none),None,$1))))
|
||||
|
||||
#***********************************************************************
|
||||
# extra builds: some pre-defined build configurations
|
||||
#***********************************************************************
|
||||
|
||||
$(call check_defined,run_config run_build)
|
||||
$(call check_undefined,run_config_and_build)
|
||||
|
||||
define run_config_and_build
|
||||
$(call run_config,$1,$2)
|
||||
$(call run_build,$1,$2)
|
||||
@@ -50,6 +65,12 @@ build/extra/clang-static/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-static/%: export CC = clang -static
|
||||
build/extra/clang-static/%: export CXX = clang++ -static
|
||||
|
||||
# force building with clang/clang++ -static-pie
|
||||
build/extra/clang-static-pie/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-static-pie/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/clang-static-pie/%: export CC = clang -static-pie -fPIE -Wno-unused-command-line-argument
|
||||
build/extra/clang-static-pie/%: export CXX = clang++ -static-pie -fPIE -Wno-unused-command-line-argument
|
||||
|
||||
# force building with clang/clang++ -static -flto
|
||||
build/extra/clang-static-lto/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/clang-static-lto/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
@@ -102,6 +123,12 @@ build/extra/gcc-static/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-static/%: export CC = gcc -static
|
||||
build/extra/gcc-static/%: export CXX = g++ -static
|
||||
|
||||
# force building with gcc/g++ -static-pie
|
||||
build/extra/gcc-static-pie/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-static-pie/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/gcc-static-pie/%: export CC = gcc -static-pie -fPIE
|
||||
build/extra/gcc-static-pie/%: export CXX = g++ -static-pie -fPIE
|
||||
|
||||
# force building with gcc/g++ -static -flto
|
||||
build/extra/gcc-static-lto/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/gcc-static-lto/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
@@ -143,18 +170,20 @@ build/extra/cross-linux-gnu-arm-eabihf/%: CMAKE_CROSSCOMPILING_EMULATOR ?= qemu-
|
||||
# cross compiler: Windows x86 win32 MinGW (i386)
|
||||
build/extra/cross-windows-mingw32/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-windows-mingw32/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-windows-mingw32/%: export CC = i686-w64-mingw32-gcc -static -D_WIN32_WINNT=0x0400
|
||||
build/extra/cross-windows-mingw32/%: export CXX = i686-w64-mingw32-g++ -static -D_WIN32_WINNT=0x0400
|
||||
build/extra/cross-windows-mingw32/%: export CC = i686-w64-mingw32-gcc -static -D_WIN32_WINNT=0x0501
|
||||
build/extra/cross-windows-mingw32/%: export CXX = i686-w64-mingw32-g++ -static -D_WIN32_WINNT=0x0501
|
||||
build/extra/cross-windows-mingw32/%: CMAKE_SYSTEM_NAME ?= Windows
|
||||
build/extra/cross-windows-mingw32/%: CMAKE_SYSTEM_PROCESSOR ?= X86
|
||||
build/extra/cross-windows-mingw32/%: CMAKE_CROSSCOMPILING_EMULATOR ?= wine
|
||||
|
||||
# cross compiler: Windows x64 win64 MinGW (amd64)
|
||||
build/extra/cross-windows-mingw64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/extra/cross-windows-mingw64/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/extra/cross-windows-mingw64/%: export CC = x86_64-w64-mingw32-gcc -static -D_WIN32_WINNT=0x0400
|
||||
build/extra/cross-windows-mingw64/%: export CXX = x86_64-w64-mingw32-g++ -static -D_WIN32_WINNT=0x0400
|
||||
build/extra/cross-windows-mingw64/%: export CC = x86_64-w64-mingw32-gcc -static -D_WIN32_WINNT=0x0501
|
||||
build/extra/cross-windows-mingw64/%: export CXX = x86_64-w64-mingw32-g++ -static -D_WIN32_WINNT=0x0501
|
||||
build/extra/cross-windows-mingw64/%: CMAKE_SYSTEM_NAME ?= Windows
|
||||
build/extra/cross-windows-mingw64/%: CMAKE_CROSSCOMPILING_EMULATOR ?= wine64
|
||||
build/extra/cross-windows-mingw64/%: CMAKE_SYSTEM_PROCESSOR ?= AMD64
|
||||
build/extra/cross-windows-mingw64/%: CMAKE_CROSSCOMPILING_EMULATOR ?= wine
|
||||
|
||||
# cross compiler: macOS arm64 (aarch64)
|
||||
build/extra/cross-darwin-arm64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
@@ -162,6 +191,7 @@ build/extra/cross-darwin-arm64/release: PHONY; $(call run_config_and_build,$@,Re
|
||||
build/extra/cross-darwin-arm64/%: export CC = clang -target arm64-apple-darwin
|
||||
build/extra/cross-darwin-arm64/%: export CXX = clang++ -target arm64-apple-darwin
|
||||
build/extra/cross-darwin-arm64/%: CMAKE_SYSTEM_NAME ?= Darwin
|
||||
build/extra/cross-darwin-arm64/%: CMAKE_SYSTEM_PROCESSOR ?= arm64
|
||||
|
||||
# cross compiler: macOS x86_64 (amd64)
|
||||
build/extra/cross-darwin-x86_64/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
@@ -169,6 +199,7 @@ build/extra/cross-darwin-x86_64/release: PHONY; $(call run_config_and_build,$@,R
|
||||
build/extra/cross-darwin-x86_64/%: export CC = clang -target x86_64-apple-darwin
|
||||
build/extra/cross-darwin-x86_64/%: export CXX = clang++ -target x86_64-apple-darwin
|
||||
build/extra/cross-darwin-x86_64/%: CMAKE_SYSTEM_NAME ?= Darwin
|
||||
build/extra/cross-darwin-x86_64/%: CMAKE_SYSTEM_PROCESSOR ?= x86_64
|
||||
|
||||
#***********************************************************************
|
||||
# C/C++ static analyzers
|
||||
@@ -182,19 +213,20 @@ build/analyze/clang-analyzer/%: override CMAKE := $(SCAN_BUILD) $(CMAKE)
|
||||
build/analyze/clang-analyzer/%: export CCC_CC ?= clang
|
||||
build/analyze/clang-analyzer/%: export CCC_CXX ?= clang++
|
||||
|
||||
# run clang-tidy: uses file compile_commands.json from an existing clang build
|
||||
# run clang-tidy: uses file compile_commands.json from an existing clang build;
|
||||
# does not create any actual files, so purely PHONY
|
||||
CLANG_TIDY_BUILD_BASE = build/extra/clang
|
||||
RUN_CLANG_TIDY = time python3 ./misc/analyze/clang-tidy/run-clang-tidy.py -p $<
|
||||
RUN_CLANG_TIDY_WERROR = $(RUN_CLANG_TIDY) '-warnings-as-errors=*'
|
||||
build/analyze/clang-tidy-upx/debug build/analyze/clang-tidy-upx/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
build/analyze/clang-tidy-upx/debug build/analyze/clang-tidy-upx/release: $$(CLANG_TIDY_BUILD_BASE)/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY_WERROR) -config-file ./.clang-tidy '/src/.*\.cpp'
|
||||
build/analyze/clang-tidy-bzip2/debug build/analyze/clang-tidy-bzip2/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
build/analyze/clang-tidy-bzip2/debug build/analyze/clang-tidy-bzip2/release: $$(CLANG_TIDY_BUILD_BASE)/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY) -config-file ./misc/analyze/clang-tidy/clang-tidy-bzip2.yml /vendor/bzip2/
|
||||
build/analyze/clang-tidy-ucl/debug build/analyze/clang-tidy-ucl/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
build/analyze/clang-tidy-ucl/debug build/analyze/clang-tidy-ucl/release: $$(CLANG_TIDY_BUILD_BASE)/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY_WERROR) -config-file ./misc/analyze/clang-tidy/clang-tidy-ucl.yml /vendor/ucl/
|
||||
build/analyze/clang-tidy-zlib/debug build/analyze/clang-tidy-zlib/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY_WERROR) -config-file ./misc/analyze/clang-tidy/clang-tidy-zlib.yml /vendor/zlib/
|
||||
build/analyze/clang-tidy-zstd/debug build/analyze/clang-tidy-zstd/release: build/extra/clang/$$(notdir $$@) PHONY
|
||||
build/analyze/clang-tidy-zlib/debug build/analyze/clang-tidy-zlib/release: $$(CLANG_TIDY_BUILD_BASE)/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY) -config-file ./misc/analyze/clang-tidy/clang-tidy-zlib.yml /vendor/zlib/
|
||||
build/analyze/clang-tidy-zstd/debug build/analyze/clang-tidy-zstd/release: $$(CLANG_TIDY_BUILD_BASE)/$$(notdir $$@) PHONY
|
||||
$(RUN_CLANG_TIDY) -config-file ./misc/analyze/clang-tidy/clang-tidy-zstd.yml /vendor/zstd/
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-upx/$$(notdir $$@)
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-bzip2/$$(notdir $$@)
|
||||
@@ -203,8 +235,8 @@ build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/c
|
||||
build/analyze/clang-tidy/debug build/analyze/clang-tidy/release: build/analyze/clang-tidy-zstd/$$(notdir $$@)
|
||||
|
||||
# OLD names [deprecated]
|
||||
build/extra/scan-build/debug: build/analyze/clang-analyzer/debug
|
||||
build/extra/scan-build/release: build/analyze/clang-analyzer/release
|
||||
build/extra/scan-build/debug: build/analyze/clang-analyzer/debug PHONY
|
||||
build/extra/scan-build/release: build/analyze/clang-analyzer/release PHONY
|
||||
|
||||
#***********************************************************************
|
||||
# advanced: generic eXtra target
|
||||
@@ -219,16 +251,19 @@ ifneq ($(CC),)
|
||||
ifneq ($(CXX),)
|
||||
|
||||
UPX_XTARGET := $(UPX_XTARGET)
|
||||
build/xtarget/$(UPX_XTARGET)/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/xtarget/$(UPX_XTARGET)/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/xtarget/$(UPX_XTARGET)/%: export CC := $(CC)
|
||||
build/xtarget/$(UPX_XTARGET)/%: export CXX := $(CXX)
|
||||
build/$(UPX_XTARGET)/debug: PHONY; $(call run_config_and_build,$@,Debug)
|
||||
build/$(UPX_XTARGET)/release: PHONY; $(call run_config_and_build,$@,Release)
|
||||
build/$(UPX_XTARGET)/%: export CC := $(CC)
|
||||
build/$(UPX_XTARGET)/%: export CXX := $(CXX)
|
||||
# shortcuts
|
||||
xtarget/all: xtarget/debug xtarget/release
|
||||
xtarget/debug: build/xtarget/$(UPX_XTARGET)/debug
|
||||
xtarget/release: build/xtarget/$(UPX_XTARGET)/release
|
||||
xtarget/all: xtarget/debug xtarget/release PHONY
|
||||
xtarget/debug: build/$(UPX_XTARGET)/debug PHONY
|
||||
xtarget/release: build/$(UPX_XTARGET)/release PHONY
|
||||
xtarget/all+test: xtarget/debug+test xtarget/release+test PHONY
|
||||
xtarget/debug+test: build/$(UPX_XTARGET)/debug+test PHONY
|
||||
xtarget/release+test: build/$(UPX_XTARGET)/release+test PHONY
|
||||
# set new default
|
||||
.DEFAULT_GOAL = build/xtarget/$(UPX_XTARGET)/release
|
||||
.DEFAULT_GOAL := build/$(UPX_XTARGET)/release
|
||||
|
||||
endif
|
||||
endif
|
||||
@@ -236,43 +271,51 @@ endif
|
||||
|
||||
#***********************************************************************
|
||||
# assemble cmake config flags; useful for CI jobs
|
||||
#***********************************************************************
|
||||
|
||||
ifneq ($(origin UPX_CMAKE_CONFIG_FLAGS),command line) # needed to work around a GNU make bug
|
||||
|
||||
#
|
||||
# info: by default CMake only honors the CC and CXX environment variables; make
|
||||
# it easy to set other variables like CMAKE_AR or CMAKE_RANLIB
|
||||
__add_cmake_config = $(and $($1),-D$1="$($1)")
|
||||
# pass common CMake settings from environment/make to cmake
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_VERBOSE_MAKEFILE)
|
||||
# pass common CMake toolchain settings from environment/make to cmake
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_ADDR2LINE)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_AR)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_DLLTOOL)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_LINKER)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_NM)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJCOPY)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJDUMP)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_RANLIB)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_READELF)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_STRIP)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_TAPI)
|
||||
# pass common CMake LTO toolchain settings from environment/make to cmake (for use with "-flto")
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_C_COMPILER_AR)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_C_COMPILER_RANLIB)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CXX_COMPILER_AR)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CXX_COMPILER_RANLIB)
|
||||
# pass common CMake cross compilation settings from environment/make to cmake
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_SYSTEM_NAME)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
# pass UPX config options from environment/make to cmake; see CMakeLists.txt
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_GITREV)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_SANITIZE)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_WSTRICT)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_WERROR)
|
||||
build/%: UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_SELF_PACK_TEST)
|
||||
#***********************************************************************
|
||||
|
||||
endif # bug work-around
|
||||
$(call check_undefined,__add_cmake_config)
|
||||
# promote an environment or Make variable to a CMake cache entry:
|
||||
__add_cmake_config = $(and $($1),-D$1="$($1)")
|
||||
|
||||
# pass common CMake settings
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_VERBOSE_MAKEFILE)
|
||||
# pass common CMake toolchain settings
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_ADDR2LINE)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_AR)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_DLLTOOL)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_LINKER)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_NM)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJCOPY)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_OBJDUMP)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_RANLIB)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_READELF)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_STRIP)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_TAPI)
|
||||
# pass common CMake LTO toolchain settings
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_C_COMPILER_AR)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_C_COMPILER_RANLIB)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CXX_COMPILER_AR)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CXX_COMPILER_RANLIB)
|
||||
# pass common CMake cross compilation settings
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_SYSTEM_NAME)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_SYSTEM_PROCESSOR)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,CMAKE_CROSSCOMPILING_EMULATOR)
|
||||
# pass UPX config options; see CMakeLists.txt
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_GITREV)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_SANITIZE)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_WERROR)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_WSTRICT)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_SELF_PACK_TEST)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS)
|
||||
# pass UPX extra compile options; see CMakeLists.txt
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_EXTRA_COMPILE_OPTIONS_BZIP2)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UCL)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UPX)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_EXTRA_COMPILE_OPTIONS_ZLIB)
|
||||
UPX_CMAKE_CONFIG_FLAGS += $(call __add_cmake_config,UPX_CONFIG_EXTRA_COMPILE_OPTIONS_ZSTD)
|
||||
|
||||
#***********************************************************************
|
||||
# check git submodules
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#! /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
|
||||
|
||||
# NOTE: this image is based on rebuild-stubs/upx-stubtools-20221212-v7,
|
||||
# so you have to create that image first
|
||||
# WARNING: we install many packages, so the resulting image needs A LOT of disk space!
|
||||
image=upx-cross-compile-ubuntu2204-20230721-v3
|
||||
[[ $1 == --print-image ]] && echo "$image" && exit 0
|
||||
|
||||
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
||||
@@ -1,40 +0,0 @@
|
||||
#! /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")"
|
||||
|
||||
# list all system packages that are installed in the image
|
||||
# using a rootless Podman container
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
podman image list "$image"
|
||||
echo
|
||||
podman image tree "$image"
|
||||
|
||||
echo 'Packages:'
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
podman run "${flags[@]}" "$image" bash -c $'dpkg -l | sed \'s/ *$//\' | LC_ALL=C sort'
|
||||
|
||||
echo
|
||||
echo 'Packages sorted by Installed-Size:'
|
||||
podman run "${flags[@]}" "$image" bash -c $'awk \'
|
||||
BEGIN {
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
{
|
||||
if ($1 == "Architecture:") arch = $2;
|
||||
if ($1 == "Installed-Size:") size = $2;
|
||||
if ($1 == "Package:") package = $2;
|
||||
if ($1 == "") {
|
||||
printf("%9d %-40s %s\\n", size, package, arch);
|
||||
count += 1; total += size;
|
||||
arch = "UNKNOWN"; size = 0; package = "UNKNOWN";
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("%9d ===== TOTAL (%d packages)\\n", total, count);
|
||||
}
|
||||
\' /var/lib/dpkg/status | LC_ALL=C sort -rn'
|
||||
@@ -1,60 +0,0 @@
|
||||
#! /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="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
flags+=( -ti -e TERM="$TERM" ) # allocate an interactive pseudo-tty and pass $TERM
|
||||
if [[ 1 == 1 ]]; then
|
||||
# run as user upx 2000:2000
|
||||
flags+=( --user 2000 )
|
||||
# map container users 0..999 to subuid-users 1..1000, and map container user 2000 to current host user
|
||||
flags+=( --uidmap=0:1:1000 --uidmap=2000:0:1 )
|
||||
# map container groups 0..999 to subgid-groups 1..1000, and map container group 2000 to current host group
|
||||
flags+=( --gidmap=0:1:1000 --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 ) # set working directory
|
||||
flags+=( --tmpfs /home/upx/.cache:rw,exec ) # mount a writeable tmpfs
|
||||
flags+=( --tmpfs /home/upx/.local:rw,exec ) # mount a writeable tmpfs
|
||||
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
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
podman run "${flags[@]}" "$image" bash -l
|
||||
else
|
||||
podman run "${flags[@]}" "$image" "$@"
|
||||
fi
|
||||
|
||||
# now we can cross-compile UPX for Windows:
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/cross-windows-mingw64/release
|
||||
# make build/extra/cross-windows-mingw64/release
|
||||
|
||||
# and we can run the clang Static Analyzer (scan-build)
|
||||
# cd /home/upx/src/upx
|
||||
# rm -rf ./build/extra/scan-build/release
|
||||
# make build/extra/scan-build/release
|
||||
|
||||
# and lots of other cross-compilers are installed; see "ls /usr/bin/*g++*"
|
||||
|
||||
# and finally see
|
||||
# ./misc/podman/cross-compile-upx-ubuntu/build-all-inside-container.sh
|
||||
# after running that script we can do cool things like:
|
||||
# cd /home/upx/src/upx/build/cross-compile-upx-ubuntu2204/alpha-linux-gnu/debug
|
||||
# qemu-alpha -L /usr/alpha-linux-gnu ./upx --version
|
||||
# cd /home/upx/src/upx/build/cross-compile-upx-ubuntu2204/hppa-linux-gnu/debug
|
||||
# qemu-hppa -L /usr/hppa-linux-gnu ./upx --version
|
||||
# (similar for many other architectures/builds)
|
||||
@@ -1,56 +0,0 @@
|
||||
# NOTE: this image is based on rebuild-stubs/upx-stubtools-20221212-v7,
|
||||
# so you have to create that image first
|
||||
# WARNING: we install many packages, so the resulting image needs A LOT of disk space!
|
||||
FROM localhost/upx-stubtools-20221212-v7
|
||||
ENV UPX_CONTAINER_IMAGE_NAME=upx-cross-compile-ubuntu2204-20230721-v3
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
USER root
|
||||
|
||||
# Ubuntu 22.04
|
||||
RUN apt-get update && apt-get upgrade -y \
|
||||
&& apt-get install -y \
|
||||
# Linux glibc cross compilers
|
||||
g++-aarch64-linux-gnu \
|
||||
g++-alpha-linux-gnu \
|
||||
g++-arm-linux-gnueabi \
|
||||
g++-arm-linux-gnueabihf \
|
||||
g++-hppa-linux-gnu \
|
||||
g++-i686-linux-gnu \
|
||||
g++-m68k-linux-gnu \
|
||||
g++-mips-linux-gnu \
|
||||
g++-mipsel-linux-gnu \
|
||||
g++-mips64-linux-gnuabi64 \
|
||||
g++-mips64el-linux-gnuabi64 \
|
||||
g++-powerpc-linux-gnu \
|
||||
g++-powerpc64-linux-gnu \
|
||||
g++-powerpc64le-linux-gnu \
|
||||
g++-riscv64-linux-gnu \
|
||||
g++-s390x-linux-gnu \
|
||||
g++-sh4-linux-gnu \
|
||||
g++-sparc64-linux-gnu \
|
||||
# Linux glibc cross compilers - ILP32 on 64-bit CPUs
|
||||
g++-x86-64-linux-gnux32 \
|
||||
# Windows cross compilers
|
||||
g++-mingw-w64-i686 \
|
||||
g++-mingw-w64-x86-64 \
|
||||
# make sure that we use posix-threads (pthread/winpthreads) and NOT win32-threads
|
||||
&& for f in i686-w64-mingw32-g++ i686-w64-mingw32-gcc x86_64-w64-mingw32-g++ x86_64-w64-mingw32-gcc; do update-alternatives --set $f /usr/bin/$f-posix; done \
|
||||
&& true
|
||||
RUN apt-get install -y \
|
||||
# clang-14 and tools
|
||||
clang-14 clang-format-14 clang-tidy-14 clang-tools-14 lldb-14 llvm-14 \
|
||||
# QEMU and Wine
|
||||
qemu-system qemu-user wine wine32:i386 wine64 \
|
||||
# misc
|
||||
gdb lsb-release valgrind \
|
||||
&& true
|
||||
RUN cd /usr/bin \
|
||||
# create unversioned clang symlinks in /usr/local/bin
|
||||
&& for f in clang*-14 llvm-*-14 scan-*-14; do ln -s -v ../../bin/$f /usr/local/bin/${f%-14}; done \
|
||||
&& ln -s -v ../../bin/obj2yaml-14 /usr/local/bin/llvm-obj2yaml \
|
||||
&& ln -s -v ../../bin/yaml2obj-14 /usr/local/bin/llvm-yaml2obj \
|
||||
&& true
|
||||
|
||||
# switch back to default user upx:upx 2000:2000
|
||||
USER upx
|
||||
@@ -1,99 +0,0 @@
|
||||
#! /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")"
|
||||
|
||||
# build UPX for 21 targets; must be run inside the container!
|
||||
# using a rootless Podman container
|
||||
|
||||
# simple sanity check that we are indeed running inside the container
|
||||
if [[ $UPX_CONTAINER_IMAGE_NAME != upx-cross-compile-* ]]; then
|
||||
echo "$argv0: NOTE: please run this script *inside* the container"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# go to upx top-level directory
|
||||
cd "$argv0dir/../../.." || exit 1
|
||||
pwd
|
||||
test -f doc/upx.pod || exit 1 # sanity check
|
||||
test -f src/version.h || exit 1 # sanity check
|
||||
|
||||
function run_config_and_build {
|
||||
# requires: AR CC CXX RANLIB
|
||||
local toolchain=$1
|
||||
local cmake_config_flags build_type bdir
|
||||
# cmake flags
|
||||
cmake_config_flags=
|
||||
case $toolchain in
|
||||
# these old architectures do not support sanitize
|
||||
alpha-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;;
|
||||
hppa-linux-gnu) cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON ;;
|
||||
# avoid sanitize link errors with current MinGW-w64 versions; link libstdc++ statically
|
||||
i686-w64-mingw32)
|
||||
cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON
|
||||
CC="$CC -static"; CXX="$CXX -static" ;;
|
||||
x86_64-w64-mingw32)
|
||||
cmake_config_flags=-DUPX_CONFIG_DISABLE_SANITIZE=ON
|
||||
CC="$CC -static"; CXX="$CXX -static" ;;
|
||||
# avoid warnings about arm libstdc++ ABI change in gcc-7
|
||||
arm-linux-*) CXX="$CXX -Wno-psabi" ;;
|
||||
esac
|
||||
if [[ 1 == 1 ]]; then
|
||||
# prefer building with Ninja (ninja-build)
|
||||
cmake_config_flags="$cmake_config_flags -G Ninja -DUPX_CONFIG_CMAKE_DISABLE_INSTALL=ON"
|
||||
fi
|
||||
# for all build types
|
||||
for build_type in Debug Release; do
|
||||
bdir="build/cross-compile-upx-ubuntu2204/$toolchain/${build_type,,}"
|
||||
mkdir -p "$bdir"
|
||||
# run_config
|
||||
if [[ ! -f $bdir/CMakeCache.txt ]]; then
|
||||
export CMAKE_REQUIRED_QUIET=OFF
|
||||
cmake -S . -B "$bdir" -DCMAKE_BUILD_TYPE=$build_type -DCMAKE_AR="$AR" -DCMAKE_RANLIB="$RANLIB" $cmake_config_flags
|
||||
fi
|
||||
# run_build
|
||||
cmake --build "$bdir" --config $build_type --parallel
|
||||
done
|
||||
}
|
||||
|
||||
# see Dockerfile for packages
|
||||
for package in \
|
||||
g++-aarch64-linux-gnu \
|
||||
g++-alpha-linux-gnu \
|
||||
g++-arm-linux-gnueabi \
|
||||
g++-arm-linux-gnueabihf \
|
||||
g++-hppa-linux-gnu \
|
||||
g++-i686-linux-gnu \
|
||||
g++-m68k-linux-gnu \
|
||||
g++-mips-linux-gnu \
|
||||
g++-mipsel-linux-gnu \
|
||||
g++-mips64-linux-gnuabi64 \
|
||||
g++-mips64el-linux-gnuabi64 \
|
||||
g++-powerpc-linux-gnu \
|
||||
g++-powerpc64-linux-gnu \
|
||||
g++-powerpc64le-linux-gnu \
|
||||
g++-riscv64-linux-gnu \
|
||||
g++-s390x-linux-gnu \
|
||||
g++-sh4-linux-gnu \
|
||||
g++-sparc64-linux-gnu \
|
||||
g++-x86-64-linux-gnux32 \
|
||||
g++-mingw-w64-i686 \
|
||||
g++-mingw-w64-x86-64
|
||||
do
|
||||
# setup toolchain and environment variables
|
||||
toolchain=$package
|
||||
toolchain=${toolchain/-x86-64/-x86_64}
|
||||
toolchain=${toolchain/g++-/}
|
||||
case $toolchain in
|
||||
mingw-w64-i686) toolchain=i686-w64-mingw32 ;;
|
||||
mingw-w64-x86_64) toolchain=x86_64-w64-mingw32 ;;
|
||||
esac
|
||||
echo "========== $toolchain"
|
||||
export AR=/usr/bin/${toolchain}-ar
|
||||
export CC=/usr/bin/${toolchain}-gcc
|
||||
export CXX=/usr/bin/${toolchain}-g++
|
||||
export RANLIB=/usr/bin/${toolchain}-ranlib
|
||||
ls -l "$AR" "$CC" "$CXX" "$RANLIB"
|
||||
run_config_and_build $toolchain
|
||||
unset AR CC CXX RANLIB
|
||||
done
|
||||
-2459
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,9 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# create the image from Dockerfile
|
||||
# using a rootless Podman container
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
image=upx-stubtools-20221212-v7
|
||||
image=upx-stubtools-20240405-v1
|
||||
[[ $1 == --print-image ]] && echo "$image" && exit 0
|
||||
|
||||
podman build -t "$image" -f "$argv0dir/Dockerfile" "$argv0dir"
|
||||
|
||||
@@ -5,6 +5,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# list all system packages that are installed in the image
|
||||
# using a rootless Podman container
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ argv0=$0; argv0abs="$(readlink -fn "$argv0")"; argv0dir="$(dirname "$argv0abs")"
|
||||
|
||||
# run an interactive shell in the image
|
||||
# using a rootless Podman container
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
@@ -24,6 +25,7 @@ if [[ 1 == 1 ]]; then
|
||||
flags+=( -v "${argv0dir}/../../..:/home/upx/src/upx" )
|
||||
flags+=( -w /home/upx/src/upx ) # set working directory
|
||||
flags+=( --tmpfs /home/upx/.cache:rw,exec ) # mount a writeable tmpfs
|
||||
flags+=( --tmpfs /home/upx/.config:rw,exec ) # mount a writeable tmpfs
|
||||
flags+=( --tmpfs /home/upx/.local:rw,exec ) # mount a writeable tmpfs
|
||||
else
|
||||
# run as user root 0:0
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#! /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")"
|
||||
|
||||
# rebuild stubs from source code
|
||||
# (also see 20-image-run-shell.sh for more container usage examples)
|
||||
# using a rootless Podman container
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
image="$("$argv0dir/10-create-image.sh" --print-image)"
|
||||
|
||||
flags=( --read-only --rm --pull=never )
|
||||
flags+=( --cap-drop=all ) # drop all capabilities
|
||||
flags+=( --network=none ) # no network needed
|
||||
if [[ 1 == 1 ]]; then
|
||||
# run as user upx 2000:2000
|
||||
flags+=( --user 2000 )
|
||||
# map container users 0..999 to subuid-users 1..1000, and map container user 2000 to current host user
|
||||
flags+=( --uidmap=0:1:1000 --uidmap=2000:0:1 )
|
||||
# map container groups 0..999 to subgid-groups 1..1000, and map container group 2000 to current host group
|
||||
flags+=( --gidmap=0:1:1000 --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" )
|
||||
fi
|
||||
|
||||
podman run "${flags[@]}" "$image" bash -c $'
|
||||
set -ex; set -o pipefail
|
||||
cd /home/upx/src/upx
|
||||
# check whitespace
|
||||
[[ -d .git ]] && bash ./misc/scripts/check_whitespace_git.sh
|
||||
# rebuild docs
|
||||
make -C doc clean all
|
||||
# rebuild stubs
|
||||
cd /home/upx/src/upx/src/stub
|
||||
make maintainer-clean extra-clean
|
||||
git status . || true # make sure the stub files got deleted
|
||||
make extra-all all
|
||||
echo "===== Rebuilt stubs. All done. ====="
|
||||
exit 0
|
||||
'
|
||||
@@ -1,5 +1,6 @@
|
||||
FROM docker.io/library/ubuntu:22.04
|
||||
ENV UPX_CONTAINER_IMAGE_NAME=upx-stubtools-20221212-v6
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
FROM docker.io/library/ubuntu:24.04
|
||||
ENV UPX_CONTAINER_IMAGE_NAME=upx-stubtools-20240405-v1
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
ENV LANG=C.UTF-8
|
||||
|
||||
@@ -7,21 +8,35 @@ ENV LANG=C.UTF-8
|
||||
RUN dpkg --add-architecture i386 \
|
||||
&& apt-get update && apt-get upgrade -y \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
aria2 bash bash-completion ca-certificates dash git less libmpc3 libncurses5 \
|
||||
make ncurses-term perl-base python2-minimal time wget xz-utils \
|
||||
aria2 bash bash-completion ca-certificates curl git less libmpc3 \
|
||||
make ncurses-term perl-base tar time wget xz-utils \
|
||||
libc6:i386 zlib1g:i386 \
|
||||
# the following packages are not required for rebuilding the stubs, but
|
||||
# they do make the image *much* more convenient and also allow building
|
||||
# the full UPX binary inside the container via CMake:
|
||||
7zip bfs busybox bzip2 cabextract ccache chrpath cmake cpio curl elfutils fd-find file fzf \
|
||||
g++ gawk gdb gojq ht htop hyperfine jq libzstd-dev lsb-release lz4 lzip lzop \
|
||||
mksh moreutils ninja-build p7zip parallel patch patchelf patchutils pax-utils paxctl \
|
||||
python3 python3-pyasn1 python3-pycryptodome python3-zstd \
|
||||
re2c ripgrep rsync screen universal-ctags unzip vim yash zip zlib1g-dev zsh zstd \
|
||||
# extra packages for compiling with "gcc -m32" and and "gcc -mx32":
|
||||
7zip bfs bubblewrap busybox bzip2 bzip3 cabextract ccache chrpath cmake cpio dash diffstat \
|
||||
elfutils execstack fd-find file fish fzf g++ gawk gdb gojq ht htop hyperfine jq ksh \
|
||||
libzstd-dev lsb-release lz4 lzip lzop minify mksh moreutils musl neovim ninja-build \
|
||||
p7zip parallel patch patchelf patchutils pax-utils proot \
|
||||
python3 python3-pyasn1 python3-pycryptodome python3-pycurl python3-toml python3-yaml python3-zstd \
|
||||
re2c ripgrep rsync screen strace universal-ctags unzip valgrind yash yq \
|
||||
zip zlib1g-dev zoxide zsh zstd \
|
||||
# extra packages for compiling with "gcc -m32" and "gcc -mx32":
|
||||
g++-multilib gcc-multilib \
|
||||
&& true
|
||||
|
||||
# install python2-minimal packages from Debian-11; REQUIRED
|
||||
RUN cd /root \
|
||||
&& aria2c --checksum=sha-256=85833c92314011b89bbead6f9a5a7a360b5ee4f9b95e001225afead4ebf9f7d3 \
|
||||
'https://ftp.debian.org/debian/pool/main/p/python2.7/libpython2.7-minimal_2.7.18-8+deb11u1_amd64.deb' \
|
||||
&& aria2c --checksum=sha-256=44f0cdc1a343303d31c55fcb3a6402cfe326adf749ec30e375e6e0c0c5f7c1f7 \
|
||||
'https://ftp.debian.org/debian/pool/main/p/python2.7/python2.7-minimal_2.7.18-8+deb11u1_amd64.deb' \
|
||||
&& dpkg -i ./*.deb \
|
||||
&& rm ./*.deb \
|
||||
&& if ! test -f /usr/bin/python2; then ln -s -v python2.7 /usr/bin/python2; fi \
|
||||
&& ldconfig \
|
||||
&& true
|
||||
|
||||
# manually unpack and install compat libs from Ubuntu-16.04; REQUIRED
|
||||
RUN cd /root \
|
||||
&& aria2c --checksum=sha-256=de22baf3dd851a10e16fbf66a243e70149ca46e06b2939fdc79429196cefc090 \
|
||||
@@ -45,22 +60,39 @@ RUN cd /root \
|
||||
# install official UPX release binaries into /usr/local/bin; not required but convenient for testing
|
||||
RUN cd /root \
|
||||
&& wget -q https://github.com/upx/upx/releases/download/v3.91/upx-3.91-amd64_linux.tar.bz2 \
|
||||
&& xzlist="3.92 3.93 3.94 3.95 3.96 4.0.0 4.0.1 4.0.2 4.1.0 4.2.0 4.2.1" \
|
||||
&& for v in $xzlist; do wget -q https://github.com/upx/upx/releases/download/v${v}/upx-${v}-amd64_linux.tar.xz; done \
|
||||
&& xzversions="3.92 3.93 3.94 3.95 3.96 4.0.0 4.0.1 4.0.2 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3" \
|
||||
&& for v in $xzversions; do wget -q https://github.com/upx/upx/releases/download/v${v}/upx-${v}-amd64_linux.tar.xz; done \
|
||||
&& for f in ./upx-*.tar.*; do tar -xoaf $f; done \
|
||||
&& for v in 3.91 $xzlist; do d=upx-${v}-amd64_linux; ./$d/upx -qq -d $d/upx -o /usr/local/bin/upx-${v}; done \
|
||||
&& for v in 3.91 $xzversions; do d=upx-${v}-amd64_linux; ./$d/upx -qq -d $d/upx -o /usr/local/bin/upx-${v}; done \
|
||||
&& rm -r ./upx-*.tar.* ./upx-*linux \
|
||||
&& true
|
||||
|
||||
# create default user upx:upx 2000:2000
|
||||
# create default container user upx:upx 2000:2000
|
||||
RUN useradd upx -U --uid 2000 --shell /bin/bash -m \
|
||||
&& cd /home/upx && chmod 00700 . \
|
||||
# prepare ~/.cache and ~/.local for possible tmpfs mounts
|
||||
# prepare ~/.cache, ~/.config and ~/.local for possible tmpfs mounts
|
||||
&& mkdir -p .cache/tmp .local/bin src/upx \
|
||||
&& for d in ccache fontconfig go-build mesa_shader_cache tmp wine zig; do mkdir -p .cache/$d; done \
|
||||
&& for d in ccache fontconfig go-build mesa_shader_cache parallel tmp wine zig; do mkdir -p .cache/$d; done \
|
||||
&& for d in fish git helix kak nvim; do mkdir -p .config/$d; done \
|
||||
&& for d in bin include lib share state; do mkdir -p .local/$d; done \
|
||||
&& ln -s .cache/wine .wine && ln -s .cache/tmp tmp \
|
||||
# symlink upx-stubtools
|
||||
&& ln -s /usr/local/bin/bin-upx-20221212 .local/bin/bin-upx \
|
||||
# some convenience settings according to upx developer preferences
|
||||
&& echo "alias md=mkdir" >> .bashrc \
|
||||
&& echo "alias rd=rmdir" >> .bashrc \
|
||||
&& echo 'mdd() { mkdir "$1" && cd "$1"; }' >> .bashrc \
|
||||
&& echo 'm() { make "$@"; }' >> .bashrc \
|
||||
&& echo 'tn() { time nice "$@"; }' >> .bashrc \
|
||||
&& echo 'tnm() { time nice make "$@"; }' >> .bashrc \
|
||||
&& echo 'tnmm() { time nice make -j "$@"; }' >> .bashrc \
|
||||
&& echo 'source /usr/share/bash-completion/completions/make' >> .bashrc \
|
||||
&& echo 'complete -F _make m tnm tnmm' >> .bashrc \
|
||||
&& echo 'eval "$(zoxide init bash)"' >> .bashrc \
|
||||
&& echo "alias zz=zi\nalias y=z\nalias yy=zi" >> .bashrc \
|
||||
&& echo "alias cd..='cd ..'" >> .bashrc \
|
||||
&& echo "alias ..='cd ..'" >> .bashrc \
|
||||
&& echo "alias .='cd ..'" >> .bashrc \
|
||||
&& chown -R upx:upx . \
|
||||
&& true
|
||||
USER upx
|
||||
|
||||
Generated
+692
-632
File diff suppressed because it is too large
Load Diff
@@ -1,149 +0,0 @@
|
||||
#! /bin/sh
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e
|
||||
|
||||
#
|
||||
# build UPX "by hand", using a POSIX-compliant shell and
|
||||
# a minimal number of compilation flags
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# uses optional environment variables: AR, CC, CXX, OPTIMIZE, VERBOSE
|
||||
# and optional settings for top_srcdir, obj_suffix and XXX_extra_flags
|
||||
|
||||
# shell init
|
||||
### set -x # enable logging
|
||||
DUALCASE=1; export DUALCASE # for MKS sh
|
||||
test -n "${ZSH_VERSION+set}" && emulate sh # for zsh
|
||||
my_argv0="$0"
|
||||
|
||||
# toolchain settings and compilation flags
|
||||
AR="${AR:-ar}"
|
||||
CC="${CC:-cc}"
|
||||
CXX="${CXX:-c++ -std=gnu++17}"
|
||||
# HINT: use "export AR=false" if "$AR rcs" does not work on your system; see below
|
||||
if test "x$AR" = "x0" || test "x$AR" = "xfalse" || test "x$AR" = "x/bin/false"; then
|
||||
AR="" # do not use $AR
|
||||
fi
|
||||
if test -z "${mandatory_flags+set}"; then
|
||||
# protect against security threats caused by misguided compiler "optimizations"
|
||||
mandatory_flags="-fno-strict-aliasing -fno-strict-overflow -funsigned-char"
|
||||
fi
|
||||
if test -z "${sensible_flags+set}"; then
|
||||
# not mandatory but good practice when using <windows.h>:
|
||||
sensible_flags="-DWIN32_LEAN_AND_MEAN"
|
||||
if test "x$OPTIMIZE" != "x" && test "x$OPTIMIZE" != "x0"; then
|
||||
# not mandatory and not minimal, but usually a good idea:
|
||||
sensible_flags="-Wall -O2 $sensible_flags"
|
||||
fi
|
||||
fi
|
||||
CC="$CC $sensible_flags $mandatory_flags"
|
||||
CXX="$CXX $sensible_flags $mandatory_flags"
|
||||
|
||||
# go to upx top-level directory
|
||||
# HINT: set "top_srcdir" manually if your system does not have "readlink -f"
|
||||
if test "x$top_srcdir" = "x"; then
|
||||
my_argv0abs="$(readlink -fn "$my_argv0")"
|
||||
test "x$my_argv0abs" = "x" && exit 1
|
||||
my_argv0dir="$(dirname "$my_argv0abs")"
|
||||
test "x$my_argv0dir" = "x" && exit 1
|
||||
cd "$my_argv0dir/../.." || exit 1
|
||||
else
|
||||
cd "$top_srcdir" || exit 1
|
||||
fi
|
||||
top_srcdir="$(pwd)" # absolute
|
||||
rel_top_srcdir=. # relative top_srcdir
|
||||
echo "# current directory: '$(pwd)'"
|
||||
test -f doc/upx.pod || exit 1 # sanity check
|
||||
test -f src/version.h || exit 1 # sanity check
|
||||
rm -rf ./build/by-hand # WARNING: existing build-directory gets deleted!
|
||||
|
||||
# helper function
|
||||
run() {
|
||||
if test 0 = 1; then
|
||||
# DEBUG dry-run: print command, but don't actually run unless $1 is "+"
|
||||
if test "x$1" = "x+"; then
|
||||
shift; echo "$@"; "$@"; return
|
||||
fi
|
||||
shift; echo "$@"; return
|
||||
fi
|
||||
# print short info and run command
|
||||
test "x$1" != "x" && test "x$1" != "x+" && echo "$1"
|
||||
shift
|
||||
if test "x$VERBOSE" != "x" && test "x$VERBOSE" != "x0"; then
|
||||
# print full command
|
||||
echo " $@"
|
||||
fi
|
||||
"$@"
|
||||
}
|
||||
|
||||
# helper function
|
||||
check_submodule() {
|
||||
#local ff # "local" seems unsupported by some versions of ksh
|
||||
for ff in COPYING LICENSE LICENSE.txt; do
|
||||
if test -f "$rel_top_srcdir/vendor/$1/$ff"; then
|
||||
# create and enter build directory; updates global $rel_top_srcdir
|
||||
run "+" cd "$rel_top_srcdir" || exit 1
|
||||
rel_top_srcdir=.
|
||||
echo "#===== build $1 ====="
|
||||
run "+" mkdir "build/by-hand/$1"
|
||||
run "+" cd "build/by-hand/$1" || exit 1
|
||||
rel_top_srcdir=../../..
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
# build
|
||||
upx_submodule_defs=
|
||||
run "+" mkdir -p "build/by-hand"
|
||||
if check_submodule bzip2; then
|
||||
upx_submodule_defs="$upx_submodule_defs -DWITH_BZIP2"
|
||||
test -z "${bzip2_extra_flags+set}" && bzip2_extra_flags="-DBZ_NO_STDIO"
|
||||
for f in "$rel_top_srcdir"/vendor/bzip2/*.c; do
|
||||
run "CC $f" $CC $bzip2_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule ucl; then
|
||||
#upx_submodule_defs="$upx_submodule_defs -DWITH_UCL"
|
||||
test -z "${ucl_extra_flags+set}" && ucl_extra_flags=
|
||||
for f in "$rel_top_srcdir"/vendor/ucl/src/*.c; do
|
||||
run "CC $f" $CC -I"$rel_top_srcdir"/vendor/ucl/include -I"$rel_top_srcdir"/vendor/ucl $ucl_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule zlib; then
|
||||
#upx_submodule_defs="$upx_submodule_defs -DWITH_ZLIB"
|
||||
test -z "${zlib_extra_flags+set}" && zlib_extra_flags="-DHAVE_UNISTD_H -DHAVE_VSNPRINTF"
|
||||
for f in "$rel_top_srcdir"/vendor/zlib/*.c; do
|
||||
run "CC $f" $CC $zlib_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
if check_submodule zstd; then
|
||||
upx_submodule_defs="$upx_submodule_defs -DWITH_ZSTD"
|
||||
test -z "${zstd_extra_flags+set}" && zstd_extra_flags="-DDYNAMIC_BMI2=0 -DZSTD_DISABLE_ASM"
|
||||
for f in "$rel_top_srcdir"/vendor/zstd/lib/*/*.c; do
|
||||
run "CC $f" $CC $zstd_extra_flags -c "$f"
|
||||
done
|
||||
fi
|
||||
run "+" cd "$rel_top_srcdir" || exit 1
|
||||
rel_top_srcdir=.
|
||||
echo "#===== build UPX ====="
|
||||
run "+" cd "build/by-hand" || exit 1
|
||||
rel_top_srcdir=../..
|
||||
for f in "$rel_top_srcdir"/src/*.cpp "$rel_top_srcdir"/src/*/*.cpp; do
|
||||
run "CXX $f" $CXX -I"$rel_top_srcdir"/vendor $upx_submodule_defs -c "$f"
|
||||
done
|
||||
# echo "#===== link UPX ====="
|
||||
test "x$obj_suffix" = "x" && obj_suffix=.o
|
||||
if test "x$AR" = "x"; then
|
||||
# link without using $AR
|
||||
run "CXX upx" $CXX -o upx *${obj_suffix} */*${obj_suffix}
|
||||
else
|
||||
run "AR libupx" $AR rcs ${AR_LIBFILE:-libupx_submodules.a} */*${obj_suffix}
|
||||
run "CXX upx" $CXX -o upx *${obj_suffix} -L. -lupx_submodules
|
||||
fi
|
||||
echo "# current directory: '$(pwd)'"
|
||||
ls -l upx*
|
||||
|
||||
echo "# All done."
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#! /usr/bin/env python3
|
||||
## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*-
|
||||
|
||||
# simulate "readlink -en FILE"
|
||||
# - result may differ from actual readlink(1) for edge cases
|
||||
# - works with Python2 and Python3
|
||||
#
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
import os, sys
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(1)
|
||||
real_path = os.path.realpath(sys.argv[1])
|
||||
if not os.path.exists(real_path):
|
||||
sys.exit(1)
|
||||
sys.stdout.write(real_path)
|
||||
sys.stdout.flush()
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#! /usr/bin/env python3
|
||||
## vim:set ts=4 sw=4 et: -*- coding: utf-8 -*-
|
||||
|
||||
# simulate "readlink -fn FILE" for systems that lack it (e.g. macOS-11)
|
||||
# - result may differ from actual readlink(1) for edge cases
|
||||
# - works with Python2 and Python3
|
||||
#
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
import os, sys
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit(1)
|
||||
real_path = os.path.realpath(sys.argv[1])
|
||||
sys.stdout.write(real_path)
|
||||
sys.stdout.flush()
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#! /usr/bin/env bash
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
# assemble cmake config flags; useful for CI jobs
|
||||
# also see misc/make/Makefile-extra.mk
|
||||
|
||||
cmake_config_flags=()
|
||||
|
||||
# promote an environment variable to a CMake cache entry:
|
||||
__add_cmake_config() {
|
||||
[[ -z "${!1}" ]] || cmake_config_flags+=( -D$1="${!1}" )
|
||||
}
|
||||
|
||||
# pass common CMake settings
|
||||
for v in CMAKE_VERBOSE_MAKEFILE; do
|
||||
__add_cmake_config $v
|
||||
done
|
||||
# pass common CMake toolchain settings
|
||||
for v in CMAKE_ADDR2LINE CMAKE_AR CMAKE_DLLTOOL CMAKE_LINKER CMAKE_NM CMAKE_OBJCOPY CMAKE_OBJDUMP CMAKE_RANLIB CMAKE_READELF CMAKE_STRIP CMAKE_TAPI; do
|
||||
__add_cmake_config $v
|
||||
done
|
||||
# pass common CMake LTO toolchain settings
|
||||
for v in CMAKE_C_COMPILER_AR CMAKE_C_COMPILER_RANLIB CMAKE_CXX_COMPILER_AR CMAKE_CXX_COMPILER_RANLIB; do
|
||||
__add_cmake_config $v
|
||||
done
|
||||
# pass common CMake cross compilation settings
|
||||
for v in CMAKE_SYSTEM_NAME CMAKE_SYSTEM_PROCESSOR CMAKE_CROSSCOMPILING_EMULATOR; do
|
||||
__add_cmake_config $v
|
||||
done
|
||||
# pass UPX config options; see CMakeLists.txt
|
||||
for v in UPX_CONFIG_DISABLE_GITREV UPX_CONFIG_DISABLE_SANITIZE UPX_CONFIG_DISABLE_WERROR UPX_CONFIG_DISABLE_WSTRICT UPX_CONFIG_DISABLE_SELF_PACK_TEST UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS; do
|
||||
__add_cmake_config $v
|
||||
done
|
||||
# pass UPX extra compile options; see CMakeLists.txt
|
||||
for v in UPX_CONFIG_EXTRA_COMPILE_OPTIONS_BZIP2 UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UCL UPX_CONFIG_EXTRA_COMPILE_OPTIONS_UPX UPX_CONFIG_EXTRA_COMPILE_OPTIONS_ZLIB UPX_CONFIG_EXTRA_COMPILE_OPTIONS_ZSTD; do
|
||||
__add_cmake_config $v
|
||||
done
|
||||
|
||||
exec "${CMAKE:-cmake}" $UPX_CMAKE_CONFIG_FLAGS "${cmake_config_flags[@]}" "$@"
|
||||
exit 99
|
||||
@@ -2,13 +2,14 @@
|
||||
## vim:set ts=4 sw=4 et:
|
||||
set -e; set -o pipefail
|
||||
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
# "Gofmt's style is nobody's favourite, but gofmt is everybody's favourite." --Rob Pike
|
||||
#
|
||||
# NOTE: we are using clang-format-15.0.6 from upx-stubtools
|
||||
# see https://github.com/upx/upx-stubtools/releases
|
||||
#
|
||||
# NOTE: we use .clang-format config from upx.git/.clang-format
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
|
||||
if [[ ! -f $UPX_CLANG_FORMAT ]]; then
|
||||
UPX_CLANG_FORMAT="$HOME/local/bin/bin-upx/clang-format-15.0.6"
|
||||
|
||||
+117
-26
@@ -7,6 +7,7 @@ argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs")
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
# mimic running "ctest", i.e. the "test" section of CMakeLists.txt; does not redirect stdout
|
||||
# (allows freely setting $upx_exe_runner, while CMake is restricted to configure-time settings)
|
||||
#
|
||||
# requires:
|
||||
# $upx_exe (required, but with convenience fallback "./upx")
|
||||
@@ -24,52 +25,142 @@ if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi
|
||||
if [[ ! -f $upx_exe ]]; then echo "UPX-ERROR: file '$upx_exe' does not exist"; exit 1; fi
|
||||
upx_exe=$(readlink -fn "$upx_exe") # make absolute
|
||||
[[ -f $upx_exe ]] || exit 1
|
||||
upx_run=()
|
||||
|
||||
# set emu and run_upx
|
||||
emu=()
|
||||
if [[ -n $upx_exe_runner ]]; then
|
||||
# usage examples:
|
||||
# export upx_exe_runner="qemu-x86_64 -cpu Nehalem"
|
||||
# export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet"
|
||||
# export upx_exe_runner="wine"
|
||||
IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array
|
||||
IFS=' ' read -r -a emu <<< "$upx_exe_runner" # split at spaces into array
|
||||
elif [[ -n $CMAKE_CROSSCOMPILING_EMULATOR ]]; then
|
||||
IFS=';' read -r -a upx_run <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
|
||||
IFS=';' read -r -a emu <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
|
||||
fi
|
||||
upx_runner=( "${upx_run[@]}" )
|
||||
upx_run+=( "$upx_exe" )
|
||||
echo "upx_run='${upx_run[*]}'"
|
||||
run_upx=( "${emu[@]}" "$upx_exe" )
|
||||
echo "run_upx='${run_upx[*]}'"
|
||||
|
||||
# upx_run sanity check
|
||||
if ! "${upx_run[@]}" --version-short >/dev/null; 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
|
||||
# run_upx sanity check
|
||||
if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
|
||||
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
#***********************************************************************
|
||||
# see CMakeLists.txt
|
||||
#
|
||||
# IDEA: create a Makefile and use "make -j" so that these tests can
|
||||
# run in parallel much like "ctest --parallel 8"
|
||||
#***********************************************************************
|
||||
|
||||
export UPX="--no-color --no-progress"
|
||||
# similar to cmake function upx_cache_bool_vars()
|
||||
set_cmake_bool_vars() {
|
||||
local default_value="$1"; shift
|
||||
local var_name
|
||||
for var_name do
|
||||
case "${!var_name}" in
|
||||
0 | FALSE | OFF | false | off) eval "export $var_name=OFF" ;;
|
||||
1 | TRUE | ON | true | on) eval "export $var_name=ON" ;;
|
||||
*) eval "export $var_name=$default_value" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
"${upx_run[@]}" --version
|
||||
"${upx_run[@]}" --help
|
||||
"${upx_run[@]}" --sysinfo -v
|
||||
set -x
|
||||
set_cmake_bool_vars OFF UPX_CONFIG_DISABLE_SELF_PACK_TEST
|
||||
set_cmake_bool_vars OFF UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST
|
||||
set_cmake_bool_vars OFF UPX_CONFIG_DISABLE_RUN_PACKED_TEST
|
||||
if [[ "${emu[0]}" == *valgrind* ]]; then # valgrind is SLOW
|
||||
set_cmake_bool_vars ON UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS
|
||||
else
|
||||
set_cmake_bool_vars OFF UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS
|
||||
fi
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_DISABLE=1 # already checked above
|
||||
|
||||
"${run_upx[@]}" --version
|
||||
"${run_upx[@]}" --version-short
|
||||
"${run_upx[@]}" --license
|
||||
"${run_upx[@]}" --help
|
||||
"${run_upx[@]}" --help-short
|
||||
"${run_upx[@]}" --help-verbose
|
||||
"${run_upx[@]}" --sysinfo
|
||||
"${run_upx[@]}" --sysinfo -v
|
||||
"${run_upx[@]}" --sysinfo -vv
|
||||
|
||||
if [[ $UPX_CONFIG_DISABLE_SELF_PACK_TEST == ON ]]; then
|
||||
echo "Self-pack test disabled. All done."; exit 0
|
||||
fi
|
||||
|
||||
exe=".out"
|
||||
upx_self_exe=$upx_exe
|
||||
fo="--force-overwrite"
|
||||
|
||||
"${upx_run[@]}" -3 "${upx_self_exe}" ${fo} -o upx-packed${exe}
|
||||
"${upx_run[@]}" -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-n2b${exe}
|
||||
"${upx_run[@]}" -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-n2d${exe}
|
||||
"${upx_run[@]}" -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-n2e${exe}
|
||||
"${upx_run[@]}" -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe}
|
||||
"${run_upx[@]}" -3 "${upx_self_exe}" ${fo} -o upx-packed${exe}
|
||||
"${run_upx[@]}" -3 --all-filters "${upx_self_exe}" ${fo} -o upx-packed-fa${exe}
|
||||
"${run_upx[@]}" -3 --no-filter "${upx_self_exe}" ${fo} -o upx-packed-fn${exe}
|
||||
"${run_upx[@]}" -3 --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-fr${exe}
|
||||
"${run_upx[@]}" -3 --nrv2b "${upx_self_exe}" ${fo} -o upx-packed-nrv2b${exe}
|
||||
"${run_upx[@]}" -3 --nrv2d "${upx_self_exe}" ${fo} -o upx-packed-nrv2d${exe}
|
||||
"${run_upx[@]}" -3 --nrv2e "${upx_self_exe}" ${fo} -o upx-packed-nrv2e${exe}
|
||||
"${run_upx[@]}" -1 --lzma "${upx_self_exe}" ${fo} -o upx-packed-lzma${exe}
|
||||
|
||||
"${upx_run[@]}" -l upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe}
|
||||
"${upx_run[@]}" --fileinfo upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe}
|
||||
"${upx_run[@]}" -t upx-packed${exe} upx-packed-n2b${exe} upx-packed-n2d${exe} upx-packed-n2e${exe} upx-packed-lzma${exe}
|
||||
"${upx_run[@]}" -d upx-packed${exe} ${fo} -o upx-unpacked${exe}
|
||||
"${run_upx[@]}" -l upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe}
|
||||
"${run_upx[@]}" --fileinfo upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe}
|
||||
"${run_upx[@]}" -t upx-packed${exe} upx-packed-fa${exe} upx-packed-fn${exe} upx-packed-fr${exe} upx-packed-nrv2b${exe} upx-packed-nrv2d${exe} upx-packed-nrv2e${exe} upx-packed-lzma${exe}
|
||||
|
||||
set -x
|
||||
"${upx_runner[@]}" ./upx-unpacked${exe} --version-short
|
||||
"${upx_runner[@]}" ./upx-packed${exe} --version-short
|
||||
"${run_upx[@]}" -d upx-packed${exe} ${fo} -o upx-unpacked${exe}
|
||||
"${run_upx[@]}" -d upx-packed-fa${exe} ${fo} -o upx-unpacked-fa${exe}
|
||||
"${run_upx[@]}" -d upx-packed-fn${exe} ${fo} -o upx-unpacked-fn${exe}
|
||||
"${run_upx[@]}" -d upx-packed-fr${exe} ${fo} -o upx-unpacked-fr${exe}
|
||||
"${run_upx[@]}" -d upx-packed-nrv2b${exe} ${fo} -o upx-unpacked-nrv2b${exe}
|
||||
"${run_upx[@]}" -d upx-packed-nrv2d${exe} ${fo} -o upx-unpacked-nrv2d${exe}
|
||||
"${run_upx[@]}" -d upx-packed-nrv2e${exe} ${fo} -o upx-unpacked-nrv2e${exe}
|
||||
"${run_upx[@]}" -d upx-packed-lzma${exe} ${fo} -o upx-unpacked-lzma${exe}
|
||||
|
||||
# all unpacked files must be identical
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-fa${exe}
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-fn${exe}
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-fr${exe}
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-nrv2b${exe}
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-nrv2d${exe}
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-nrv2e${exe}
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-lzma${exe}
|
||||
|
||||
if [[ $UPX_CONFIG_DISABLE_RUN_UNPACKED_TEST != ON ]]; then
|
||||
"${emu[@]}" ./upx-unpacked${exe} --version-short
|
||||
fi
|
||||
|
||||
if [[ $UPX_CONFIG_DISABLE_RUN_PACKED_TEST != ON ]]; then
|
||||
"${emu[@]}" ./upx-packed${exe} --version-short
|
||||
"${emu[@]}" ./upx-packed-fa${exe} --version-short
|
||||
"${emu[@]}" ./upx-packed-fn${exe} --version-short
|
||||
"${emu[@]}" ./upx-packed-fr${exe} --version-short
|
||||
"${emu[@]}" ./upx-packed-nrv2b${exe} --version-short
|
||||
"${emu[@]}" ./upx-packed-nrv2d${exe} --version-short
|
||||
"${emu[@]}" ./upx-packed-nrv2e${exe} --version-short
|
||||
"${emu[@]}" ./upx-packed-lzma${exe} --version-short
|
||||
fi
|
||||
|
||||
if [[ $UPX_CONFIG_DISABLE_EXHAUSTIVE_TESTS != ON ]]; then
|
||||
set +x
|
||||
for method in nrv2b nrv2d nrv2e lzma; do
|
||||
for level in 1 2 3 4 5 6 7; do
|
||||
s="${method}-${level}"
|
||||
echo "========== $s =========="
|
||||
"${run_upx[@]}" -qq --${method} -${level} --all-filters --debug-use-random-filter "${upx_self_exe}" ${fo} -o upx-packed-${s}${exe}
|
||||
"${run_upx[@]}" -qq -l upx-packed-${s}${exe}
|
||||
"${run_upx[@]}" -qq --fileinfo upx-packed-${s}${exe}
|
||||
"${run_upx[@]}" -qq -t upx-packed-${s}${exe}
|
||||
"${run_upx[@]}" -qq -d upx-packed-${s}${exe} ${fo} -o upx-unpacked-${s}${exe}
|
||||
cmp -s upx-unpacked${exe} upx-unpacked-${s}${exe}
|
||||
if [[ $UPX_CONFIG_DISABLE_RUN_PACKED_TEST != ON ]]; then
|
||||
"${emu[@]}" ./upx-packed-${s}${exe} --version-short
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
echo "run_upx='${run_upx[*]}'"
|
||||
echo "All done."
|
||||
|
||||
+173
-148
@@ -10,16 +10,18 @@ argv0=$0; argv0abs=$(readlink -fn "$argv0"); argv0dir=$(dirname "$argv0abs")
|
||||
# $upx_exe (required, but with convenience fallback "./upx")
|
||||
# optional settings:
|
||||
# $upx_exe_runner (e.g. "qemu-x86_64 -cpu Nehalem" or "valgrind")
|
||||
# $upx_test_file
|
||||
#
|
||||
|
||||
# IMPORTANT NOTE: do NOT run as user root!!
|
||||
# IMPORTANT NOTE: this script only works on Unix!!
|
||||
# IMPORTANT NOTE: this script only works on Unix
|
||||
# IMPORTANT NOTE: do NOT run as user root!
|
||||
umask 0022
|
||||
|
||||
# disable on macOS for now, see https://github.com/upx/upx/issues/612
|
||||
if [[ "$(uname)" == Darwin ]]; then
|
||||
echo "$0: SKIPPED"
|
||||
exit 0
|
||||
case "$UPX_DEBUG_FORCE_PACK_MACOS" in
|
||||
"" | "0") echo "$0: SKIPPED"; exit 0 ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
id || true
|
||||
@@ -39,26 +41,28 @@ if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi
|
||||
if [[ ! -f $upx_exe ]]; then echo "UPX-ERROR: file '$upx_exe' does not exist"; exit 1; fi
|
||||
upx_exe=$(readlink -fn "$upx_exe") # make absolute
|
||||
[[ -f $upx_exe ]] || exit 1
|
||||
upx_run=()
|
||||
|
||||
# set emu and run_upx
|
||||
emu=()
|
||||
if [[ -n $upx_exe_runner ]]; then
|
||||
# usage examples:
|
||||
# export upx_exe_runner="qemu-x86_64 -cpu Nehalem"
|
||||
# export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet"
|
||||
# export upx_exe_runner="wine"
|
||||
IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array
|
||||
IFS=' ' read -r -a emu <<< "$upx_exe_runner" # split at spaces into array
|
||||
elif [[ -n $CMAKE_CROSSCOMPILING_EMULATOR ]]; then
|
||||
IFS=';' read -r -a upx_run <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
|
||||
IFS=';' read -r -a emu <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
|
||||
fi
|
||||
upx_run+=( "$upx_exe" )
|
||||
echo "upx_run='${upx_run[*]}'"
|
||||
run_upx=( "${emu[@]}" "$upx_exe" )
|
||||
echo "run_upx='${run_upx[*]}'"
|
||||
|
||||
# upx_run sanity check
|
||||
if ! "${upx_run[@]}" --version-short >/dev/null; 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
|
||||
# run_upx sanity check
|
||||
if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
|
||||
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
#***********************************************************************
|
||||
# util
|
||||
# util functions
|
||||
#***********************************************************************
|
||||
|
||||
exit_code=0
|
||||
@@ -159,18 +163,7 @@ create_files() {
|
||||
chmod -R a-w z_dir_4
|
||||
}
|
||||
|
||||
#***********************************************************************
|
||||
#
|
||||
#***********************************************************************
|
||||
|
||||
#set -x # debug
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_VERBOSE=0
|
||||
export NO_COLOR=1
|
||||
|
||||
testsuite_header() {
|
||||
print_header() {
|
||||
local x='==========='; x="$x$x$x$x$x$x$x"
|
||||
echo -e "\n${x}\n${1}\n${x}\n"
|
||||
}
|
||||
@@ -185,206 +178,238 @@ leave_dir() {
|
||||
cd ..
|
||||
}
|
||||
|
||||
# create a tmpdir in current directory
|
||||
#***********************************************************************
|
||||
# setup
|
||||
#***********************************************************************
|
||||
|
||||
#set -x # debug
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_DISABLE=1 # already checked above
|
||||
|
||||
# get $test_file
|
||||
if [[ -f $upx_test_file ]]; then
|
||||
test_file="$(readlink -fn "$upx_test_file")"
|
||||
else
|
||||
for test_file in /usr/bin/gmake /usr/bin/make /usr/bin/env /bin/ls; do
|
||||
if [[ -f $test_file ]]; then
|
||||
test_file="$(readlink -fn "$test_file")"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
ls -l "$test_file"
|
||||
file "$test_file" || true
|
||||
|
||||
# create and enter a tmpdir in the current directory
|
||||
tmpdir="$(mktemp -d tmp-upx-test-XXXXXX)"
|
||||
cd "./$tmpdir" || exit 1
|
||||
|
||||
if [[ -f /bin/ls ]]; then
|
||||
test_file="$(readlink -fn /bin/ls)"
|
||||
else
|
||||
test_file="$(readlink -fn /usr/bin/env)"
|
||||
fi
|
||||
#***********************************************************************
|
||||
# default
|
||||
#***********************************************************************
|
||||
|
||||
testsuite_header "default"
|
||||
flags="-qq -1 --no-filter"
|
||||
print_header "default"
|
||||
flags="-qq -2 --no-filter"
|
||||
mkdir default
|
||||
cd default
|
||||
create_files
|
||||
enter_dir z_dir_1
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_2
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_3
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_4
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file && failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link && failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
cd ..
|
||||
|
||||
testsuite_header "force-overwrite"
|
||||
flags="-qq -1 --no-filter --force-overwrite"
|
||||
#***********************************************************************
|
||||
# force-overwrite
|
||||
#***********************************************************************
|
||||
|
||||
print_header "force-overwrite"
|
||||
flags="-qq -2 --no-filter --force-overwrite"
|
||||
mkdir force-overwrite
|
||||
cd force-overwrite
|
||||
create_files
|
||||
enter_dir z_dir_1
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_2
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_3
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_4
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
cd ..
|
||||
|
||||
if [[ 1 == 1 ]]; then
|
||||
testsuite_header "link"
|
||||
flags="-qq -1 --no-filter --link"
|
||||
#***********************************************************************
|
||||
# link
|
||||
#***********************************************************************
|
||||
|
||||
print_header "link"
|
||||
flags="-qq -2 --no-filter --link"
|
||||
mkdir link
|
||||
cd link
|
||||
create_files
|
||||
enter_dir z_dir_1
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_2
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new || failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir || failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling || failed 18
|
||||
assert_file z_symlink_file z_symlink_file_link
|
||||
assert_file z_symlink_dir
|
||||
assert_file z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_3
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file || failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 || failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
enter_dir z_dir_4
|
||||
"${upx_run[@]}" $flags z_symlink_file && failed 10
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${upx_run[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
"${run_upx[@]}" $flags z_symlink_file && failed 10
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_new && failed 11
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_dir && failed 12
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file && failed 13
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_file_link_1 && failed 14
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file || failed 15
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_file_link || failed 16
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dir && failed 17
|
||||
"${run_upx[@]}" $flags "$test_file" -o z_symlink_dangling && failed 18
|
||||
assert_symlink_to_file z_symlink_file z_symlink_file_link
|
||||
assert_symlink_to_dir z_symlink_dir
|
||||
assert_symlink_dangling z_symlink_dangling
|
||||
leave_dir
|
||||
cd ..
|
||||
fi
|
||||
|
||||
#***********************************************************************
|
||||
# done
|
||||
#***********************************************************************
|
||||
|
||||
# clean up
|
||||
cd ..
|
||||
|
||||
+147
-147
@@ -46,164 +46,164 @@ b8c35fa2956da17ca505956e9f5017bb5f3a746322647e24ccb8ff28059cafa4 *powerpc-linux.
|
||||
a0950546dc17fca9437219431d8ddb0249ce5b08e899e0c799a87ac982adee70 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t110_compress_ucl_nrv2b_3_no_filter="\
|
||||
d11ff80ef4e663679699d92bfd5d9ed8421dc2def0a91b104697cdb2ef0a1ffe *amd64-linux.elf/upx-3.91
|
||||
14d9ecc398a3b1863b19371387cadc434b8bb9a7da9225c58d3df2ab624cbf9e *amd64-linux.elf/upx-3.95
|
||||
3c161ae654b290be806a38be271a4e9498404e038d5ef163543b072077b29859 *amd64-win64.pe/upx-3.95.exe
|
||||
dc1927ca0317cdefe2c07b0a76f0c2d45cf02079ee163c1ced26688277a22be3 *arm-linux.elf/upx-3.95
|
||||
c5a65ebda6db5f619afad9a0c0e9ece6cb025c5fdfdec57affa26120255b5e73 *arm-wince.pe/upx-3.91.exe
|
||||
4a76cf662f29ef93cb674d9dd8ec144e2388d3b05d33abd89cb0416f760330c5 *arm64-linux.elf/upx-3.95
|
||||
bfca960388f228846091c7124d49e9bb1504c7696ee0b359278009fa17dfa9a7 *armeb-linux.elf/upx-3.91
|
||||
35b09fdbd0f9977172ebaff8231d8e00f68a8475dcba2f75b6d05c36a39f4bb4 *armeb-linux.elf/upx-3.95
|
||||
5434fa28036a14abf19e4c24fe1f8bdc4cff132ed9080cb34ef1dd3c596ebce8 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
a194bd54d3058fd97871b96a14ede16b337241e912cd51456d2a8e5b3dfa6a39 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
a57e4e0d72e8e5ace0e045192150c4b4e9889c0ac7630c885f8cecab8280ecda *i386-linux.elf/upx-3.91
|
||||
b150460b6061cfca7ec76e868626bb33a92e2558fe1f1fc8baab8c528cd1dde4 *i386-linux.elf/upx-3.95
|
||||
c9a92aa8099262b5174b50f37c4f2995ceff79a8c9ba4c755a4fd1dc98bb0f23 *i386-win32.pe/upx-3.91.exe
|
||||
4f15940af27173ee18aa4fdf96b79ed4c5b563141b7362b398424366e3f51dca *i386-win32.pe/upx-3.95.exe
|
||||
81539760603ca5abbc5f6f0e9f0df922129fad624643d6cfc10d820205519650 *m68k-atari.tos/upx-3.91.ttp
|
||||
648378e19d72bc85950e6244d837475e21008dbf470a4cb3484fda10677b8afd *mips-linux.elf/upx-3.95
|
||||
3eb9a06b68617499a0c7994b6b300e4fbe9ca3cf0c3601948ab129d9e181b345 *mipsel-linux.elf/upx-3.91
|
||||
5a188e4aa04e98def8294e21a587a5e958fdd745cafa52fe584976c8b62a96e9 *mipsel-linux.elf/upx-3.95
|
||||
557a255deb0250ea1d0db01b07b40603817b97b9e645328bc01aaf1c51742cae *powerpc-linux.elf/upx-3.91
|
||||
0751e651da9809deea7926c4125527677d7034fbbbb4d5ae10dd692c37a47074 *powerpc-linux.elf/upx-3.95
|
||||
08a46dffd447f0b1f723613bfb31d14154c1a31cc3e7982263ec4b242724410c *powerpc64le-linux.elf/upx-3.95
|
||||
ef49d1c9617dbb3dc1bb36ab70df8a263cd816cc5e91ad28cc62f91ccc77afa7 *amd64-linux.elf/upx-3.91
|
||||
253b1542cdcd5d554eb442e263eb44e400f00e63cfd4d0d727eacec5fcdbbd00 *amd64-linux.elf/upx-3.95
|
||||
d96c42d14684e7248de5712310364eafa28b337695bc0d8c37f91d593b869250 *amd64-win64.pe/upx-3.95.exe
|
||||
c1d3b9ec3157f068097f5deffddce4fc4d3d95602daa539992e0accff6af0de8 *arm-linux.elf/upx-3.95
|
||||
9ca862c0c92d7e4068145024486bb85a6031bf06f9a37c6af543234e08e8ab36 *arm-wince.pe/upx-3.91.exe
|
||||
9173b4e4b1ac0b92e63dc51168dbd41d38208520b0f4c17b91d22e584ad55ae4 *arm64-linux.elf/upx-3.95
|
||||
8c6c5f1678fb74d2f65a1e6c28e3089a4b99b49939fabac3ca1f71183bc73ffa *armeb-linux.elf/upx-3.91
|
||||
13caa682f323a0438a651f53768af9b7fb1208980d46d94c6fb984ecf4422599 *armeb-linux.elf/upx-3.95
|
||||
55f30818e45da393628aa80c3518f3cf099666ae3af5014bded2196ea28ddaea *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
6b80b2be79ec38af3071fcaf8f0d0ec524e4523e7e52e2f10111862ab93ec793 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
9bb71da401ae398ca42cde73afffe0c0db29fff24f22196c4116636ab6385170 *i386-linux.elf/upx-3.91
|
||||
c2375a808f989c0f8290fcd9760db0033413323d8597deb796f182f8ac38afa2 *i386-linux.elf/upx-3.95
|
||||
892695e1abdc0fbbd110ee30c317fde56947f4a8b3dfe413507ee7665f109986 *i386-win32.pe/upx-3.91.exe
|
||||
f76ec227836388da3174007e2c5e27fb6cb397a83297872e78befb298a65796d *i386-win32.pe/upx-3.95.exe
|
||||
8f7c5b3d67c78c117c02bec8b30ec5fca7baa79a35d250a4d981cb7137f8635d *m68k-atari.tos/upx-3.91.ttp
|
||||
745ac3afd263f3a653165bd229e35c817a58c9b894a8d6fbd4e5aaf6c38c1264 *mips-linux.elf/upx-3.95
|
||||
a11da76425bc3bb308de3c19e6df22f56bf12c95afcf96ee8c2d4aaeda07ac8a *mipsel-linux.elf/upx-3.91
|
||||
76c458e8e9b94eceb60d8c51f602a5dec44b2617886ea0b5b7b8802c61d962e9 *mipsel-linux.elf/upx-3.95
|
||||
cec277d9e6e0cbf551f697c1d52e5d29b48533efbe4269df0aafbc12731a93ed *powerpc-linux.elf/upx-3.91
|
||||
92c6cec7bf40d1aa5a62a55fce95bb99d94c5b477edbea127ee0468471ddbdb3 *powerpc-linux.elf/upx-3.95
|
||||
df2f12597c901196e8f10782e72fb4c294955f03a66cc4e8bf3c24414929f717 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t120_compress_ucl_nrv2d_3_no_filter="\
|
||||
c7b05335f178c5c550e3d1d0d90fb6d921a4c0c66c16e215114483ade78d9b5f *amd64-linux.elf/upx-3.91
|
||||
9cedd104b3bdd11c6933ecb21e0c47bda7362909905e7e63e950984825650950 *amd64-linux.elf/upx-3.95
|
||||
d96be2f6f5fb0088736ff7a83a8854844ae41d61aff7862e91f09222755a56b0 *amd64-win64.pe/upx-3.95.exe
|
||||
cf7c02b78bb85e9426b01aaf31a99c65944822d65eaac461de1b3db0c718625d *arm-linux.elf/upx-3.95
|
||||
c05c9d17f6d74f760d0c9cdbf7c8d0f29b9059ec0048a160579d9d40ee6dde46 *arm-wince.pe/upx-3.91.exe
|
||||
91c4f7d3485e53a5b9cfadc2dda610ad5507c02b2d75f70d9628e336eaf154c8 *arm64-linux.elf/upx-3.95
|
||||
e4b2f54fcacc320e4a7e45b49a499b58ebf8c4ad35232e4982144c817dee19a5 *armeb-linux.elf/upx-3.91
|
||||
2a0b9e1cf234ed0746b74f8e63e15bd52f74082705ee74647899da238c7cebb3 *armeb-linux.elf/upx-3.95
|
||||
0d16d4489ba249636541134471ac6dca6c78874c9201dc12a7825747cd095767 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
49671cdfa344b6d259ba339e764f0a196b190eb7a3979771b83704d26766ed63 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
f9bde637fa12497a02d38e52fd7acba5b7220eaa3888434fc18dcbf224c14af9 *i386-linux.elf/upx-3.91
|
||||
11ef9a08ea0aba3ed8d2043be6b2297e0b41f10fc5d73f9b9299fea00eb36426 *i386-linux.elf/upx-3.95
|
||||
48984390e36e8b6dd133a372570d215a49e1bf2b5d8304ba060e1088149eb603 *i386-win32.pe/upx-3.91.exe
|
||||
0f9d2325e0d8930b72629c37dbb333a3ac1e3d0be0f00245a376fceb287dfff6 *i386-win32.pe/upx-3.95.exe
|
||||
e87f9d09fdd313c3cf552030e9596dea67cdd6178bdf6cefb0b33f1fc893339f *m68k-atari.tos/upx-3.91.ttp
|
||||
d31a35f3fae92984df28dd26c90a525038be74a54714948b96914af885902fdb *mips-linux.elf/upx-3.95
|
||||
26de609a6eda26fcf93273d6a95abfe211b7080abdbbdc6fd4f793ea59bb8aa6 *mipsel-linux.elf/upx-3.91
|
||||
0bd931fa89c1cc5b6f0c2425f0d564808caf5223e3214fd718b6a6df2c42ca2b *mipsel-linux.elf/upx-3.95
|
||||
98dc5a8995b36bca8873a41414245db7a608d644b7a75d43bdecf9d6c8660817 *powerpc-linux.elf/upx-3.91
|
||||
42d0fce35d881b90986b6de32b6dd231c310023c1e3a33f16affe5b36503b663 *powerpc-linux.elf/upx-3.95
|
||||
e5db79bd3323df67afc53eed8621cae8de8c57522230cb18463d0a38ef8e0e2b *powerpc64le-linux.elf/upx-3.95
|
||||
f7e51450a373cb49f88e3e17c268f4198429f7ad06bed57dda28161b5383196a *amd64-linux.elf/upx-3.91
|
||||
15c57828824d18604519fd43349f0340ccebfddf246ab355f8f30253123132ea *amd64-linux.elf/upx-3.95
|
||||
728b2feceda3cfdd849aef4402d5d4e61aa6fa6d56266e7730b148dc66f4a7b0 *amd64-win64.pe/upx-3.95.exe
|
||||
188a3581ed2bac5fdfd50e08267e2e9cf4cf3ddbfc9f5ae15643298bda4bf11c *arm-linux.elf/upx-3.95
|
||||
0711f0b8531de9659f099f43f2a883d628bee8de67f927e7137c19c6d23a30bd *arm-wince.pe/upx-3.91.exe
|
||||
ae6fa69b1242bdfe808d64b7bbefddfe9c1c96302627ee8c65fa2851102fc502 *arm64-linux.elf/upx-3.95
|
||||
7586b4029355eff2edf25141835ee2405ab9f936956e56420315c3d3fecc8bda *armeb-linux.elf/upx-3.91
|
||||
e37875b1a91ef3c88bdba113649a061b72239dbfe77b77077c51254037a982b6 *armeb-linux.elf/upx-3.95
|
||||
536e5a6bb18378f3eea81be12f218f4da60ea81eddf480434aaf418610e4e52d *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
386f3037b26b8b2ce49a527028d738956e7ef649b29a0ef15e32acef4a3b291a *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
5761d8e12b01163c2bf378bef813df9a621da08c4508773db992a1cce067c70c *i386-linux.elf/upx-3.91
|
||||
8afc2b549e2f78987641045697afaac0378b48e84c3e946334c9e4f1a7e693fa *i386-linux.elf/upx-3.95
|
||||
1cc6663f3d9e847f9fec39a52c8efe38b39a66074c0ad77a880a84dde7c68d3f *i386-win32.pe/upx-3.91.exe
|
||||
edf158ec6064e9b11b677a73239a70e414fa8c4f3b8950f74e81514ccb28ef4f *i386-win32.pe/upx-3.95.exe
|
||||
faa36b6601743dcc5eaedb57187a893006652b6c68acecff179ce2cd123e6209 *m68k-atari.tos/upx-3.91.ttp
|
||||
6c76928b5914b5c2e072bf2f90a2c95049cc41aec6b98b1f0b3c4f84df069f02 *mips-linux.elf/upx-3.95
|
||||
029c2a47f1f613c538d2f39674167489a9d1bbbb6649a06d51d2b5ea983b4924 *mipsel-linux.elf/upx-3.91
|
||||
4d837edcaf344505ad1a3721ec8e5db35ddaa273a747201e460b946c0a89d6ea *mipsel-linux.elf/upx-3.95
|
||||
0e24a9e58939f7aacd3482db24e04bdac406a658dbb8d5e65d71d76d455e5aa5 *powerpc-linux.elf/upx-3.91
|
||||
04bd4885f37c77a34b39e76cca2fd363f794ed1611093d7fffe1ee19920ce1dd *powerpc-linux.elf/upx-3.95
|
||||
3b6be5bff0e435a8dbd8529562912c58dafdcb9694d75564238f3d086048abd2 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t130_compress_ucl_nrv2e_3_no_filter="\
|
||||
bb7df16340f56a859b10b5c591e69435b72443c4b9387b4c0afc4f3362217c5c *amd64-linux.elf/upx-3.91
|
||||
bf45e190f7dfce9eec13163ccc7da85c51420736b15ef679290af7f4662e5850 *amd64-linux.elf/upx-3.95
|
||||
cedb3c199f6b37c2993c2f6beaff327bebfcef0d1dd904b655f79c7261e374f6 *amd64-win64.pe/upx-3.95.exe
|
||||
6887322866a5b77058c1b7ecc229fb43c80ea4d88e965dd34ad8a562604f5f4c *arm-linux.elf/upx-3.95
|
||||
8b12ec425233a4f2e00769f2106a804d64100ac3d32f38db2383a0f51ab0c8fb *arm-wince.pe/upx-3.91.exe
|
||||
13410a318f80b193f75b26388c45f603e62ab7e30392b248f89409f73f59dcc3 *arm64-linux.elf/upx-3.95
|
||||
bf60d3e917be3abe66f15d8e61c93e2451f241e5b7e55de8c68d0a5eea4ab474 *armeb-linux.elf/upx-3.91
|
||||
8b0ae4260e24398e479a6e220625f50158ab3142c565cc4929350a298437e6a8 *armeb-linux.elf/upx-3.95
|
||||
8b5739273e1565e031c4335ceb76e5efc00830074093f092ab3ac2942b1f756e *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
27875bd06a68b56d4ecf4b1aac7cd088f6fd3c358970b0c0fe881026b83a4603 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
018137b520e22511d67d6768ec57a9bc053bc7927a87fd51d60521042d2a26f2 *i386-linux.elf/upx-3.91
|
||||
b9f6b51798e239c881174a9a93391ea27020fb6632f9cbf6040d2c7c43798f74 *i386-linux.elf/upx-3.95
|
||||
38229e4a2d830568ed2b25f3d23cb20b7b78e912227da45fe1bae57e131470df *i386-win32.pe/upx-3.91.exe
|
||||
f55a0c8f3197977bfe9bca325fb86e1a3f5effe82f4efaa062554b8dc7093e10 *i386-win32.pe/upx-3.95.exe
|
||||
e08fb4722915ea11259084c1483e2f40f0a047be600e7a9f2607c44582849ef0 *m68k-atari.tos/upx-3.91.ttp
|
||||
e452be5c3f9310879626387cbe60a7bd4465f0efc9b31e711733b964ab9286b8 *mips-linux.elf/upx-3.95
|
||||
bca2e642253157d4e004a53cb393cecf34df82f2072bedf4c46bf32f1302da74 *mipsel-linux.elf/upx-3.91
|
||||
849469774baf909c7470f5306f75e91fbed4664475d4f7d60910ce07101a0ce8 *mipsel-linux.elf/upx-3.95
|
||||
59a21be192ac75bdf5ed882a53c3e2560380dd46c1af36d256c6329bbed7c2b7 *powerpc-linux.elf/upx-3.91
|
||||
fa8f8f063ae7eedb936d0774485451b785387b435b9bcbe2fc0c9fbe7ed4eced *powerpc-linux.elf/upx-3.95
|
||||
64ade3a0badb4357bf7714e5192be73ef03678260ac31ac729fc68d639495c56 *powerpc64le-linux.elf/upx-3.95
|
||||
715de64e0911c959d0ea208db13bf23a5e635e97e73feb9e04ac9d32117e6a3f *amd64-linux.elf/upx-3.91
|
||||
da805c93ffea03da2f0c0dbb1b313cf0d88ef2c0cb0ad77b0be792210106cd6c *amd64-linux.elf/upx-3.95
|
||||
213e6d3c80b4d741e8c78da915d32c1a2b74072d31e86ec46a10ac2535cf8f6f *amd64-win64.pe/upx-3.95.exe
|
||||
3a66e868147347208935c042517b9f0e2e30d2dbb5c004ec8df6a9ab1e42ecd5 *arm-linux.elf/upx-3.95
|
||||
8d295980b1e6a8240bf75b86a9b8e4561424cbabeab01246f51e553d84b40839 *arm-wince.pe/upx-3.91.exe
|
||||
194947a439c1348570e45343e404c409be3f10feb70fdd87d9bca0addc772c44 *arm64-linux.elf/upx-3.95
|
||||
a01384f43803428e0bfc5f8152304eb8618ef862e4e996a4a4fa4dd9c4576833 *armeb-linux.elf/upx-3.91
|
||||
f2fdba359d52bb82fbab093176a3fbf37b9cb13e8d297523ed57051c3bd401e3 *armeb-linux.elf/upx-3.95
|
||||
582030394a570f92be2d31b3862ab7fb0a6f08982c793a4d41c1471d2cabb939 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
f60dc2f332f58b7fa08f551f8c33d645d71d9ee79e2a719130d10ea4091373ef *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
13887e5466a7d0fc2652aedcef44e33e6ee9b8d6f0ac21dbc4ec90fcc0613bfa *i386-linux.elf/upx-3.91
|
||||
636759f884399ff05e8493a759f60ea52cd4640eb5e9760f12fc25fbf730b1ed *i386-linux.elf/upx-3.95
|
||||
c4a5d27ce7d8f0f326e49489223eda188a9be61971a88758a559efb9f854611a *i386-win32.pe/upx-3.91.exe
|
||||
4ca9a3dd0e0ec38cc1aa3720d9c666f86df4fbe9dcb87ef0dad56d0a47dc327a *i386-win32.pe/upx-3.95.exe
|
||||
f34a020e6325d213052d9f09c775c4d292c34c51380b1ab1b22c6663645167f0 *m68k-atari.tos/upx-3.91.ttp
|
||||
3006af1262a29173c46340f1ee4526fba41145f7476841d5bf6b499aa6dea0fd *mips-linux.elf/upx-3.95
|
||||
6af81d3c7cb6f1388925fe2d78ea96313d91d5e17249268739de4d56857f27bd *mipsel-linux.elf/upx-3.91
|
||||
9d3849cd0037ef550703c574e0ccb3032b0d27217ec02c90a0ad8592d2a229f1 *mipsel-linux.elf/upx-3.95
|
||||
704b6eb2033cf3eab30cbc53c35fc85bf0cb17f904528792de33967a1406091d *powerpc-linux.elf/upx-3.91
|
||||
b89b2f3b250ddd156cb857717c86a0c0325a26dd084717c64f3022277ad02be4 *powerpc-linux.elf/upx-3.95
|
||||
d52f201ab041fa64a4ee4234bd0e443e883e402bb93ced9e22554bd3ef3cc9ab *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t140_compress_lzma_2_no_filter="\
|
||||
ba01763526328e15b34441891b4bfbfded4488cfc0221bd923fc33c17cd94f26 *amd64-linux.elf/upx-3.91
|
||||
401dba7e1d660d732006a7b3b39d0b8806ac90530090141c583ad7037482b637 *amd64-linux.elf/upx-3.95
|
||||
0afff19522cd3480f13170f6f56ad1df918ff6427fdd1f76e0014adbc492112c *amd64-win64.pe/upx-3.95.exe
|
||||
a7d7457b0dc5105297f070db66bac8e581c3901efa5b4c89c991cc652edd1c58 *arm-linux.elf/upx-3.95
|
||||
a2178a2be4b595adb32e11c0dcdcf6af701a3f1fc41cc4019dee00a96c997860 *arm-wince.pe/upx-3.91.exe
|
||||
2e45b63d7a9897c8316436cd73ea30c788b9cc873374f572ab4119ccd4585f62 *arm64-linux.elf/upx-3.95
|
||||
c77b62df69a4e0e712e7ceab519bb5e8760b6dde3b609be5422258fe8c5464a3 *armeb-linux.elf/upx-3.91
|
||||
abe0d09a0e3aa9b483ba652face53718480c3a928d0cb0be183e41eb2c64f1aa *armeb-linux.elf/upx-3.95
|
||||
46c1aceafa1e3a2fcf224bf6e50d1dfac2dc1519671387cb066e3454b3207635 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
170c70a9fb257ca845bbbef5f8da0062b4197a8b3f5cf9a29f472751ab38879a *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
3a5d6531b1f1ce021282592dd645fe66affd86b36ccb72c3a4f43976fb150606 *i386-linux.elf/upx-3.91
|
||||
c073fe95891b83015e7d778a44562d057d5b3bc787e37f794f0e2b9867d83d76 *i386-linux.elf/upx-3.95
|
||||
3e1fcbdb6267e99c50c20c3d0e6ca7795b3c35282bd127e3f09c13ae4a9ef6d0 *i386-win32.pe/upx-3.91.exe
|
||||
7618f249a922b7e504a389eb1c5c640b3bc5678ca1b4575900a778453c2666fc *i386-win32.pe/upx-3.95.exe
|
||||
b1a481020f6afc2601dac02bba1582f47719c964fbb3e63090cd2ae19caf2c28 *m68k-atari.tos/upx-3.91.ttp
|
||||
64574681a2cbef2e5ecd4c290e8c4ed482a1a34438e3b7151eda097c593195df *mips-linux.elf/upx-3.95
|
||||
0a9f789949135858acebd4da834a2d904bbc722adc599d59ae41382475988d6a *mipsel-linux.elf/upx-3.91
|
||||
69faa554496af25239a5fea6f7941c0424d8f40d8078a7e40012ba284bf7b678 *mipsel-linux.elf/upx-3.95
|
||||
224cc6a5336f768457c92a317a4f7e47188779ff459b821f49d2ef2188b5674b *powerpc-linux.elf/upx-3.91
|
||||
8da438605f0be0e9a00c4f169d66b4639468f8e3922ed63320f33b91d0a6b099 *powerpc-linux.elf/upx-3.95
|
||||
efa063be5c8a488b16f0d03598b96e144a0c0d317c462a58a3e32585b68403a7 *powerpc64le-linux.elf/upx-3.95
|
||||
af8536d70ecb8c0680c1c9dc45ef60dcb13fab99f0e4644d9f86216a9cf003e2 *amd64-linux.elf/upx-3.91
|
||||
004a705f4981a19f35767b33bdb70b942717a701ad8635bd56ba33e347c6ed69 *amd64-linux.elf/upx-3.95
|
||||
cf07c202497ab38417ec3ccb65cbb0eb9b87f6c6df40d7dc4b44616282c8e0f8 *amd64-win64.pe/upx-3.95.exe
|
||||
da153c1747e0e242cc8b90c04362f67caa0aa638562bc12fcc7fe08ebb1b4fcb *arm-linux.elf/upx-3.95
|
||||
9755110ebc951c9767e376155d9c6fee9789b009ce82ae47276664f5c832557e *arm-wince.pe/upx-3.91.exe
|
||||
bb9e92b577ace19da295032c294063d724655cf5b97d014053c3fb05ce478884 *arm64-linux.elf/upx-3.95
|
||||
a3c639403fd7b2f035315773c1aa3f68cc0532cf5cd075defd34fa44c4bbbb7a *armeb-linux.elf/upx-3.91
|
||||
3f9604a69a945d86b93f2182ee82f754881331c7ef566d0cd4dc36d7acfa1aa0 *armeb-linux.elf/upx-3.95
|
||||
e6518528d60861e37cb8429376628a7f3d1d5fc90f0933facd70b4e9e0b50709 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
53280a22c34ee1733007ccf858e1f5416c0f7043a4361799087e19a4b2a7eaf4 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
a51ce8993b3577fc2ee45b52174aaadc66c2f90ff53a0148ed096a65d99d24a2 *i386-linux.elf/upx-3.91
|
||||
d018260f04d1efc2b46c8b7ff5b132358e58cb062c158b08a7179fbb561b0e48 *i386-linux.elf/upx-3.95
|
||||
121e4acc3fbad4954cb2d2b957d229b042beaf4b68749c4f85ebfc60fcc80d43 *i386-win32.pe/upx-3.91.exe
|
||||
d604523130da29af35705d9008098ae8b4bb9e7d4743357674470252dd68b8d3 *i386-win32.pe/upx-3.95.exe
|
||||
4d26f0be2b6b6c4802515a7f0dfd97998c6d23e696ae6c0393c9ac0893885a9b *m68k-atari.tos/upx-3.91.ttp
|
||||
4d3b0c7b4dabb5a7a193a0a2899f086f5dfc555106188131389678ecc137378a *mips-linux.elf/upx-3.95
|
||||
be2e9fb66c087f37b58f203b406b618526296dd8c9c53e73bb622740f1e377ba *mipsel-linux.elf/upx-3.91
|
||||
9da821fac44f787875727cf001ca33ed87e02c5fe477f0ebb965c5e0eb62c26c *mipsel-linux.elf/upx-3.95
|
||||
98d7c0214663ae47f59244a90aabbb72a798a4ad0c74ce79d448013f5cad6893 *powerpc-linux.elf/upx-3.91
|
||||
c58266817c4e38982c66e4b75e0002c6e7a51710864f930987b8670ee121ee0b *powerpc-linux.elf/upx-3.95
|
||||
7fecab59271c9d4596bd79978e112a5fea72e33bd7c53c1985d187009d807724 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t150_compress_ucl_2_all_filters="\
|
||||
19d81859acc5322e7610e44aee84eed65974650d7a7afb5fb9731d11dad70144 *amd64-linux.elf/upx-3.91
|
||||
9663a26ee5367181ad8d8cc0d8df0573d4cfcff0aa5c8f014e56963b80007146 *amd64-linux.elf/upx-3.95
|
||||
1e2dd8689c3e7d4bd484eb53490ab0a9764c1ba4022145e309873537d63765f5 *amd64-win64.pe/upx-3.95.exe
|
||||
4bf9b45b89d5668e41caf176f34b32336cbd4f858b71ed03385f69b722192796 *arm-linux.elf/upx-3.95
|
||||
b94e8887f7901239b1fb4aa926c96d4dd5d935a653e619c3ab4c4124dad7380c *arm-wince.pe/upx-3.91.exe
|
||||
6138f52201f283e64816f77380da10dc422d1689031fb6c72054647e48f55188 *arm64-linux.elf/upx-3.95
|
||||
72c31db3472141f44f6034c9eaec3352c4f4391560a3d81fc63cb2fe45778d32 *armeb-linux.elf/upx-3.91
|
||||
8cfb3a15c6d795e0be95c92791081573d5987633b52c51e044ab3baa7436c8d5 *armeb-linux.elf/upx-3.95
|
||||
ef96852c3865b3e6682e345954568acdf7ef2e3f59f3aaec5477142097b029b7 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
c2c11ca8450b0cf61eb2e4d5ee54692ca0f308be4b61c544e03bfc108a79cb0d *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
a595b6d76204351340a2f6eff0cfb7b3f64c40866fc11e6bb7ff9d534f097bee *i386-linux.elf/upx-3.91
|
||||
8b1929b7753b56274c136648359a01a862ae994f291b2f511fdb1d2268bccbbc *i386-linux.elf/upx-3.95
|
||||
10f32132ca0a218c069185834ace32447d4cf33c4ab7766141c4c08d967606a1 *i386-win32.pe/upx-3.91.exe
|
||||
c1146e9c9b1c4e755822fbd5486c53e905b9d16028b97c55d0430bbcec467793 *i386-win32.pe/upx-3.95.exe
|
||||
e217c1613fe848e6126f6a05b32aceaeda777e4d4a3755405118e3586b1bd93d *m68k-atari.tos/upx-3.91.ttp
|
||||
e2ef44ac8519d9aadf99469c8c387503d8737827f840ef5e5b5695529d4de8f6 *mips-linux.elf/upx-3.95
|
||||
23ebde2dc0d11ab32c056683edca55b8ece7f429cea28520653ed367f16a8b26 *mipsel-linux.elf/upx-3.91
|
||||
354c349f1504b3403ca922fb275f25835a173268a58a2ca5b17b0632220bb6c8 *mipsel-linux.elf/upx-3.95
|
||||
6f3197a3e460b23dde39522a12d734d3dddb1515645931e4fad622d8ffbe37b8 *powerpc-linux.elf/upx-3.91
|
||||
66bc0f51d3a2905cdf39d599ec609565fbee3afc962cdb74caa431b71a0f5ee6 *powerpc-linux.elf/upx-3.95
|
||||
f47a2f1d67f37af7087c94fc7a3fd3cd81ec3ed8149df79774250a4ace793768 *powerpc64le-linux.elf/upx-3.95
|
||||
977380191b474f5a7fa78e8015a279bfaa77626bc56d83185fec8761531b3029 *amd64-linux.elf/upx-3.91
|
||||
4f94c9bee7a2f7deed245dc767c215654a41373be978123c3f1ef9074454c59d *amd64-linux.elf/upx-3.95
|
||||
00aa338efc865f720a901afb1c19064cf137abb71d361be9b19192b0ff8a9479 *amd64-win64.pe/upx-3.95.exe
|
||||
c1908a58fcc23a9a964f2cd5f76f805a7cc9ca39480d129c6bdb8db30033840b *arm-linux.elf/upx-3.95
|
||||
78ffa99aa69e2f66f864dce88e787e3b1c0c056009e0f863986d65aabd186107 *arm-wince.pe/upx-3.91.exe
|
||||
245c6bb22ae2b39671503244329f1e4498277b06d600447ad81c7d41ebc872d6 *arm64-linux.elf/upx-3.95
|
||||
9e359728cdb9bf6ea21a864b2c9da56809eda27d6b88828b85ab815311bf77b6 *armeb-linux.elf/upx-3.91
|
||||
86edb5959b5cabad270d7c77e750bc710424b92cfb2ebaeedf3ba403382f4e93 *armeb-linux.elf/upx-3.95
|
||||
b65db2766ffdd45657a07edd57426c55acce2a73a1e3559ab43903ae77574131 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
e827d64700b14e8c19de2882e66d0df0fca4cda0255ae41a66810e4c86583a93 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
c95a7ad9a5015abb1b8a163afe46b4f1529c70ca4ef9353cfb6e5c7eef60245c *i386-linux.elf/upx-3.91
|
||||
21ef65f5c756f216c0f9db9475a7514e10b8e003c30bc22416ec8156cba65252 *i386-linux.elf/upx-3.95
|
||||
6db34f6cdc626c4857fc7b188910562909e571eed3be2116448e244ca82eaa64 *i386-win32.pe/upx-3.91.exe
|
||||
68a08dd3995681af594c66df4b94559e5900f0a09fcf822e3fc2522c3133ad69 *i386-win32.pe/upx-3.95.exe
|
||||
1546ce426b3cfe38bdea18fafadee409253d5d2b452aae5476e073b29e17bb58 *m68k-atari.tos/upx-3.91.ttp
|
||||
6ecc64d1fb9fb2a675980ce939b0b8142e802e7218b8ea45f2bb82205ed9242e *mips-linux.elf/upx-3.95
|
||||
eb3c90f8f775e70cb2cc187b7e55d66a3bb28fa760e14a17353acd1130fd122a *mipsel-linux.elf/upx-3.91
|
||||
b47964dbe65e9975d6bddfbfdd321a5e6c96b6eba79b30d0f94ec4323b796991 *mipsel-linux.elf/upx-3.95
|
||||
c32a2deaa707eafaed36a4ab8fb26bb8d8c63a9743b19ad207e305553d14c7fe *powerpc-linux.elf/upx-3.91
|
||||
c4dbfbd0f5021d50f1addc68273f20b49204bf26ae8c8896a0aacc7d2c5a2d47 *powerpc-linux.elf/upx-3.95
|
||||
bb96ea8a29500893b729dad4afe90b09186641c32c42a70a3d2380a771f896d9 *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t160_compress_all_methods_1_no_filter="\
|
||||
a4e92543a5cf5e692823d0bc2a75a995570358ba899e273d67c1df0709d5f41d *amd64-linux.elf/upx-3.91
|
||||
77e7f8b07304c8acbf55a4755854c51f5d1582558f15ec74585fc471379c81f3 *amd64-linux.elf/upx-3.95
|
||||
c8c19d2e24cd9c5b416888cff1828ef7a5b09236b0c423adbc3d2215977d4756 *amd64-win64.pe/upx-3.95.exe
|
||||
0aa2cd95ed88fd3e220d14e429068269556ad7dc22ef740d07faf5288fc10189 *arm-linux.elf/upx-3.95
|
||||
876f3e8c159f744db0ec8bc9d9afe51be7dac4c18da744c82550d9cc8abfae64 *arm-wince.pe/upx-3.91.exe
|
||||
0853acc0af2991a5c87d54215cabc46db588d2626b468559b052418fa90b40f9 *arm64-linux.elf/upx-3.95
|
||||
af0cef4cd954d3eed8218c92434ab351c4d071293223361b12f10381117798c8 *armeb-linux.elf/upx-3.91
|
||||
6fb686656901a4db12cdf6ffd050be225d74e1123aecea3e45d7604f0eb1104d *armeb-linux.elf/upx-3.95
|
||||
f2e94193758f32cab6b11e7d72d6c35339170e7db7f2fffb828e528a2a8a9611 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
4ff2bbd08158a94f2d3e7aff2b681b9314704aa9724319c4ea3f2ad554b97edc *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
49e38b822d774cfe637a61a36d18ce0d6b402a80cfbfe2ca16f2d63d0ea05cdf *i386-linux.elf/upx-3.91
|
||||
2ffc13b1515ad20846cca5b2d1c7d5ae0d2b3410fe14ea97fbeb9da46332b7c9 *i386-linux.elf/upx-3.95
|
||||
76b29c91e9429d4587192584ee8b15a2fc40f00ae6a3c83c220c245a780e31a2 *i386-win32.pe/upx-3.91.exe
|
||||
5c5b5148f679341301776689d41205d746ea96c530721a64edf8c10e8876ae35 *i386-win32.pe/upx-3.95.exe
|
||||
cacdad81fb8a39c08f656f07a370c2c21e0c2aa7b3a81bcac22bb114078c478a *m68k-atari.tos/upx-3.91.ttp
|
||||
d9cbddf0e48f870dca28ccb394f2077d49fb7da3c7244a4c132627bc7b2c1a89 *mips-linux.elf/upx-3.95
|
||||
27fad7afdbf8fdce8b9729ed9bac4e2a1fe501ebd9dda00630c7717c504eccbb *mipsel-linux.elf/upx-3.91
|
||||
b11fa6e0a609bbf3222f342951cbb77b214602168bd37ddadae23afa479c2ade *mipsel-linux.elf/upx-3.95
|
||||
b7e4c9b02c30dc7436ef6cc133342b93c75ba71779b564e21dc2cb88749bc113 *powerpc-linux.elf/upx-3.91
|
||||
920090c1e5147f10e1be0de3ea99a8a3140a6271c260cb90eeff6549e2855828 *powerpc-linux.elf/upx-3.95
|
||||
29c6854869fd0a4e95cb3d434f8b93e7728c126ce2a8f9d7163506f1271b2af0 *powerpc64le-linux.elf/upx-3.95
|
||||
de00c3bcb56d78c3fd1d1e633b3f64b884b3611abc305b9e79f4f14385178418 *amd64-linux.elf/upx-3.91
|
||||
eb5aea4d780711dd59e3f86d34a49f16d3669acc6569292bf9ea445d406c5c80 *amd64-linux.elf/upx-3.95
|
||||
2fae12ccc55eeac6c05ff2c6b27539c66816080647283ac2e1b22576242b6bb5 *amd64-win64.pe/upx-3.95.exe
|
||||
14120b8348172a08cd7651184941820ed1c69b7a8d859e375390eee529f5c94e *arm-linux.elf/upx-3.95
|
||||
a6690508c1acdaa07ce97feec0f330182c24206d8e9133949d2a42fccc1cbf27 *arm-wince.pe/upx-3.91.exe
|
||||
4f30adcd3d047fad15344bf6cf3cf4f91cfbacbb121af889df8634fa4c888247 *arm64-linux.elf/upx-3.95
|
||||
f85f0a70b024a050999d476420b9db88206e340b2ffff3781c491b538ae03e37 *armeb-linux.elf/upx-3.91
|
||||
e1b2dc75427212dc268c6921aa2059adf5709b21f230432a4725b16e1c64b238 *armeb-linux.elf/upx-3.95
|
||||
fcf64cfce9e9762e03740d2bf9e2e86d873ade1b6f4a68eb07625f516426810d *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
9188a6f911b79fb8629880836b2f5787eb4d938872ba4f1a64c93e70cde9f428 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
8369ff8112aeb55a1684ce0ec16e13e6bc524b734557b49b292f9aae60edccb6 *i386-linux.elf/upx-3.91
|
||||
c4e16cc1a64db618d9038ea9ba6032b7fe5aac05c0d7731b91373094a6a0f6e4 *i386-linux.elf/upx-3.95
|
||||
b21cf7756542b3bab5f4a59d4036cd3176e297dceb744dec96ac365be6568dcd *i386-win32.pe/upx-3.91.exe
|
||||
b1bc0d360918d51ca7b7f32f5083845e4566c7fa7a425d0451f4b10f227d1eac *i386-win32.pe/upx-3.95.exe
|
||||
c40af5d1ba0531abb92587cbcbe604d4f562b685d6e7bbb40ec4d879fddf1267 *m68k-atari.tos/upx-3.91.ttp
|
||||
0865d2f1d65e2693d801b3c28d64910a009707be65598772df655c640469a4e5 *mips-linux.elf/upx-3.95
|
||||
4cf108686c2419c6d82eecb2473a6d0ca0a0b47096cc01ea2b55113f84762cc7 *mipsel-linux.elf/upx-3.91
|
||||
0a90a99e0ebb1e9c86e0bdf6a3eec6ca116e65b235ba1ee9029694b84cadc438 *mipsel-linux.elf/upx-3.95
|
||||
4d8f85d254b1fd87bebe2fd732afd6214c98b869cda17ff0c4c566358446038a *powerpc-linux.elf/upx-3.91
|
||||
bbc6179756637db10b636d7383226cb1d685866e8e9191069107725365b42f38 *powerpc-linux.elf/upx-3.95
|
||||
52d7db1d6d6611d4a064c036b57044fd93d4c5762452be07188ee2ff6b1e42bc *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
expected_sha256sums__t170_compress_all_methods_no_lzma_5_no_filter="\
|
||||
f11151a8eea22872544062dcab0190e26d63073c0e0b9e1356f31a336e7a56e4 *amd64-linux.elf/upx-3.91
|
||||
047ad308483a6f2789de768f8de86a35b9a9c92d9ec4d04efeae55c7ea5c643c *amd64-linux.elf/upx-3.95
|
||||
bd559454e3c5ad2e4afd145c2e366aed0e6bb6e8e059e7bd0bc72962cfd1f2ad *amd64-win64.pe/upx-3.95.exe
|
||||
e1966d2e2056dc0af5bd18b880039cca83c70b5c370f3869e013384bdf8c853a *arm-linux.elf/upx-3.95
|
||||
ef0a4b9341aacd4b9962f9e77c019c5e641616f4f5d713af93263cbf67e32a0f *arm-wince.pe/upx-3.91.exe
|
||||
45700ca243888ec22cf84018d7b4ec47f2ee6e36edfc4a16056ea81e99eee9d0 *arm64-linux.elf/upx-3.95
|
||||
fd5697370dca17662f271530af4a164790c63b164cc3160d7d8be317e624af8d *armeb-linux.elf/upx-3.91
|
||||
c09ecb409692d91fc4710896f6fe934066d4bdff778c675c99e27b5c624d1d63 *armeb-linux.elf/upx-3.95
|
||||
4766485709641cbbe06b09e64d0c77b66afa45eadf3ee11c0e92e5a0a97e5bc1 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
f4de30c9fb6b695264db098790d189b01f1df950c75e34f8f445d8fa49b69755 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
a25c10adb376e932191aeb2e11d1020e71b56a9c82ea0d7f8af71b4e05cffbf1 *i386-linux.elf/upx-3.91
|
||||
4dca2d0bdc78d5d8fc582f6638c4595ee45c03ee2523e1da0cd914576ba7a5dd *i386-linux.elf/upx-3.95
|
||||
f4500b64adb382552152c737880a3cd55c172d023437c996ccae5b07414dcb0e *i386-win32.pe/upx-3.91.exe
|
||||
8922ab742e9641ca533af2693c85fd5121bbac677b12a2c67a33a49b6e4eb939 *i386-win32.pe/upx-3.95.exe
|
||||
f95d3a1811be7665fc6cb9479eeb4e94b64d4b1f16187b06fa6c9f0c54782564 *m68k-atari.tos/upx-3.91.ttp
|
||||
e637eb6b7c4c9c06488e79c26f8910cc8c40196a962339c849457e6b6a59b964 *mips-linux.elf/upx-3.95
|
||||
8c1c4fe3430f1524e70c68f2c10ab67f356c94ea79cf7726a24931d29388458c *mipsel-linux.elf/upx-3.91
|
||||
572283b261f90bd2b13f5a65c94f065f7a7e40ed32c2d048f314ec8a9656e365 *mipsel-linux.elf/upx-3.95
|
||||
0a7c32c5b3cda6e7c90e21227f1b5af14d169d56d074644c431dbf367b308cdb *powerpc-linux.elf/upx-3.91
|
||||
fe6e2d1c1b8e9119713863997f52735a4814d35c3bfba0a6ef1cd9e218510383 *powerpc-linux.elf/upx-3.95
|
||||
cbeb988b78e3edd3f0d9526998b700c0b1c3c4bb29ef9e2591c4083a40126c50 *powerpc64le-linux.elf/upx-3.95
|
||||
ee887f19ee6a5d5f0a0ce7116a41570e106c10bc0bb25acf7eb3ee254c1ed560 *amd64-linux.elf/upx-3.91
|
||||
9bd019e6442b219825f19082a20e4e73c49b24a4dee39e9e2cf0fc907ecdb46f *amd64-linux.elf/upx-3.95
|
||||
382fe4b3e4f575322b746d7d45e4553ba3cf47cb4351b9900508fb52a00118ad *amd64-win64.pe/upx-3.95.exe
|
||||
ae71103c2e105099ab345a648abf109b9aec3039137c90af30710dd4a4b51736 *arm-linux.elf/upx-3.95
|
||||
9150f49be3fcb03a5f23b209e5db443c9b96fa4d8e20d3730195f9eafff5d8e8 *arm-wince.pe/upx-3.91.exe
|
||||
100d9cee849b7996cbde2dc82df766e5104ae030055ae9b286c53b60e9e51405 *arm64-linux.elf/upx-3.95
|
||||
43ded21db5b7b8355bc371e39cd3b1be05e91635e3cb6d64f9a8aea16127e157 *armeb-linux.elf/upx-3.91
|
||||
b0ac3a36871630af80bb9b6ba94604b3ebc1fe05fdb6d095a7c461916fb3d231 *armeb-linux.elf/upx-3.95
|
||||
36b6a947567386e325f1d3ff84a55ecbd37687e3264cfb0a57aa5e3be5ff85f9 *i386-dos32.djgpp2.coff/upx-3.91.exe
|
||||
ad02fcac751563d49cb0711d818231c1030bad9ef2b12fd54e60e2bc6510e9d6 *i386-dos32.djgpp2.coff/upx-3.95.exe
|
||||
d1b4e2c81a0baf4ad273dd96722783e9219e69049a78d536757f39761a7cfe8b *i386-linux.elf/upx-3.91
|
||||
6e509d556ccd2af102d43924bd4eb1e9bed9d557e44387769032df4ede525f0d *i386-linux.elf/upx-3.95
|
||||
2138186fb26cc7983ec4a4ead290573f2e8226fea4a0b9b6d668d86fb21d1573 *i386-win32.pe/upx-3.91.exe
|
||||
5f286eaf28bab252a0f4f069b7b88910b9ce62327c4d15837b91ce65e4f9030e *i386-win32.pe/upx-3.95.exe
|
||||
0ab25c2cd8cf53a31323464080991344479998f45fd9b215caba003f96e9e11c *m68k-atari.tos/upx-3.91.ttp
|
||||
ba14b6b4e846d29bd4211fbcdb2a641f55f8a5700806af64c52182736b757f46 *mips-linux.elf/upx-3.95
|
||||
40c23e16bfe68ec0a59f9651ac747db1e81f07deabc4c22a732e40e03e2b1100 *mipsel-linux.elf/upx-3.91
|
||||
7d353d8381c3401c3c9765fa6091c634791ae9b7338ca5b769f63c38f8f418e7 *mipsel-linux.elf/upx-3.95
|
||||
b43bd16efb19081fe0945948231486cdd1b1157d193ab7cbbd470594f46c57ca *powerpc-linux.elf/upx-3.91
|
||||
7a8a24fa57d17f99b11133a0822a5e499681d09695525b80f8c61d90d06c4ac8 *powerpc-linux.elf/upx-3.95
|
||||
0339ffc1d99f5b5ad12e8492b6a9dc707f705a120494a6bc453fb8617808d10a *powerpc64le-linux.elf/upx-3.95
|
||||
"
|
||||
########## end .sha256sums.recreate
|
||||
|
||||
@@ -29,23 +29,25 @@ if [[ -z $upx_exe ]]; then echo "UPX-ERROR: please set \$upx_exe"; exit 1; fi
|
||||
if [[ ! -f $upx_exe ]]; then echo "UPX-ERROR: file '$upx_exe' does not exist"; exit 1; fi
|
||||
upx_exe=$(readlink -fn "$upx_exe") # make absolute
|
||||
[[ -f $upx_exe ]] || exit 1
|
||||
upx_run=()
|
||||
|
||||
# set emu and run_upx
|
||||
emu=()
|
||||
if [[ -n $upx_exe_runner ]]; then
|
||||
# usage examples:
|
||||
# export upx_exe_runner="qemu-x86_64 -cpu Nehalem"
|
||||
# export upx_exe_runner="valgrind --leak-check=no --error-exitcode=1 --quiet"
|
||||
# export upx_exe_runner="wine"
|
||||
IFS=' ' read -r -a upx_run <<< "$upx_exe_runner" # split at spaces into array
|
||||
IFS=' ' read -r -a emu <<< "$upx_exe_runner" # split at spaces into array
|
||||
elif [[ -n $CMAKE_CROSSCOMPILING_EMULATOR ]]; then
|
||||
IFS=';' read -r -a upx_run <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
|
||||
IFS=';' read -r -a emu <<< "$CMAKE_CROSSCOMPILING_EMULATOR" # split at semicolons into array
|
||||
fi
|
||||
upx_run+=( "$upx_exe" )
|
||||
echo "upx_run='${upx_run[*]}'"
|
||||
run_upx=( "${emu[@]}" "$upx_exe" )
|
||||
echo "run_upx='${run_upx[*]}'"
|
||||
|
||||
# upx_run sanity check, part1
|
||||
if ! "${upx_run[@]}" --version-short >/dev/null; 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
|
||||
# run_upx sanity check
|
||||
if ! "${run_upx[@]}" --version-short >/dev/null; then echo "UPX-ERROR: FATAL: upx --version-short FAILED"; exit 1; fi
|
||||
if ! "${run_upx[@]}" -L >/dev/null 2>&1; then echo "UPX-ERROR: FATAL: upx -L FAILED"; exit 1; fi
|
||||
if ! "${run_upx[@]}" --help >/dev/null; then echo "UPX-ERROR: FATAL: upx --help FAILED"; exit 1; fi
|
||||
|
||||
# upx_testsuite_SRCDIR
|
||||
if [[ -z $upx_testsuite_SRCDIR ]]; then
|
||||
@@ -74,19 +76,30 @@ fi
|
||||
mkdir -p "$upx_testsuite_BUILDDIR" || exit 1
|
||||
upx_testsuite_BUILDDIR=$(readlink -fn "$upx_testsuite_BUILDDIR") # make absolute
|
||||
[[ -d $upx_testsuite_BUILDDIR ]] || exit 1
|
||||
|
||||
cd / && cd "$upx_testsuite_BUILDDIR" || exit 1
|
||||
: > ./.mfxnobackup
|
||||
|
||||
# upx_run sanity check, part2
|
||||
if ! "${upx_run[@]}" --version-short >/dev/null; then
|
||||
# run_upx sanity check after "cd"
|
||||
if ! "${run_upx[@]}" --version-short >/dev/null; then
|
||||
echo "UPX-ERROR: FATAL: upx --version-short FAILED"
|
||||
echo "please make sure that \$upx_exe contains ABSOLUTE file paths and can be run from any directory"
|
||||
echo "INFO: upx_run='${upx_run[*]}'"
|
||||
echo "INFO: run_upx='${run_upx[*]}'"
|
||||
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
|
||||
|
||||
#***********************************************************************
|
||||
# setup
|
||||
#***********************************************************************
|
||||
|
||||
#set -x # debug
|
||||
|
||||
exit_code=0
|
||||
num_errors=0
|
||||
all_errors=
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_DISABLE=1 # already checked above
|
||||
|
||||
case $UPX_TESTSUITE_LEVEL in
|
||||
[0-8]) ;;
|
||||
@@ -97,19 +110,6 @@ if [[ $UPX_TESTSUITE_LEVEL == 0 ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#***********************************************************************
|
||||
# setup
|
||||
#***********************************************************************
|
||||
|
||||
#set -x # debug
|
||||
exit_code=0
|
||||
num_errors=0
|
||||
all_errors=
|
||||
|
||||
export UPX="--prefer-ucl --no-color --no-progress"
|
||||
export UPX_DEBUG_DISABLE_GITREV_WARNING=1
|
||||
export UPX_DEBUG_DOCTEST_VERBOSE=0
|
||||
|
||||
rm -rf ./testsuite_1
|
||||
mkdir testsuite_1 || exit 1
|
||||
cd testsuite_1 || exit 1
|
||||
@@ -121,11 +121,11 @@ cd testsuite_1 || exit 1
|
||||
run_upx() {
|
||||
local ec=0
|
||||
if [[ $UPX_TESTSUITE_VERBOSE == 1 ]]; then
|
||||
echo "LOG: '${upx_run[*]}' $*"
|
||||
echo "LOG: '${run_upx[*]}' $*"
|
||||
fi
|
||||
"${upx_run[@]}" "$@" || ec=$?
|
||||
"${run_upx[@]}" "$@" || ec=$?
|
||||
if [[ $ec != 0 ]]; then
|
||||
echo "FATAL: '${upx_run[*]}' $*"
|
||||
echo "FATAL: '${run_upx[*]}' $*"
|
||||
echo " (exit code was $ec)"
|
||||
exit 42
|
||||
fi
|
||||
@@ -319,7 +319,7 @@ ls -l "$upx_exe"
|
||||
if command -v file >/dev/null; then
|
||||
file "$upx_exe" || true
|
||||
fi
|
||||
echo "upx_run='${upx_run[*]}'"
|
||||
echo "run_upx='${run_upx[*]}'"
|
||||
echo "upx_testsuite_SRCDIR='$upx_testsuite_SRCDIR'"
|
||||
echo "upx_testsuite_BUILDDIR='$upx_testsuite_BUILDDIR'"
|
||||
echo ".sha256sums.{expected,current} counts:"
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#
|
||||
# valgrind suppressions for musl libc
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# musl malloc
|
||||
{
|
||||
musl-malloc-enframe
|
||||
Memcheck:Cond
|
||||
fun:enframe
|
||||
}
|
||||
|
||||
# these are only needed for older musl versions
|
||||
|
||||
{
|
||||
musl-malloc-mal0_clear
|
||||
Memcheck:Cond
|
||||
fun:mal0_clear
|
||||
fun:calloc
|
||||
}
|
||||
|
||||
{
|
||||
musl-string-memchr
|
||||
Memcheck:Cond
|
||||
fun:memchr
|
||||
}
|
||||
{
|
||||
musl-string-stpcpy
|
||||
Memcheck:Cond
|
||||
fun:stpcpy
|
||||
}
|
||||
{
|
||||
musl-string-strchrnul
|
||||
Memcheck:Cond
|
||||
fun:strchrnul
|
||||
}
|
||||
{
|
||||
musl-string-strlen
|
||||
Memcheck:Cond
|
||||
fun:strlen
|
||||
}
|
||||
+37
-40
@@ -3,8 +3,8 @@
|
||||
# Copyright (C) Markus Franz Xaver Johannes Oberhumer
|
||||
#
|
||||
|
||||
# NOTE: this Makefile is deprecated - please directly use
|
||||
# the top-level CMake build instead.
|
||||
# NOTE: this Makefile is intended for developers - please use
|
||||
# the top-level Makefile instead
|
||||
|
||||
ifndef srcdir
|
||||
srcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
|
||||
@@ -13,42 +13,32 @@ ifndef top_srcdir
|
||||
top_srcdir := $(srcdir)/..
|
||||
endif
|
||||
|
||||
#
|
||||
# redirect to top-level CMake build
|
||||
#
|
||||
#***********************************************************************
|
||||
# redirect to top-level Makefile
|
||||
#***********************************************************************
|
||||
|
||||
# NOTE that top-level Makefile .DEFAULT_GOAL is build/release
|
||||
# NOTE that the top-level Makefile .DEFAULT_GOAL is build/release
|
||||
.DEFAULT_GOAL = build/all
|
||||
|
||||
build/debug: $(top_srcdir)/build/debug
|
||||
build/release: $(top_srcdir)/build/release
|
||||
|
||||
.NOTPARALLEL: # because the actual builds use "cmake --parallel"
|
||||
.PHONY: PHONY
|
||||
.SECONDEXPANSION:
|
||||
.SUFFIXES:
|
||||
|
||||
# shortcuts (all => debug + release)
|
||||
debug: build/debug
|
||||
release: build/release
|
||||
all build/all: build/debug build/release
|
||||
build/debug build/release build/all: PHONY; $(MAKE) -C $(top_srcdir) $@
|
||||
build/debug+test build/release+test build/all+test: PHONY; $(MAKE) -C $(top_srcdir) $@
|
||||
# shortcuts
|
||||
debug release all: PHONY; $(MAKE) -C $(top_srcdir) $@
|
||||
debug+test release+test all+test: PHONY; $(MAKE) -C $(top_srcdir) $@
|
||||
|
||||
# actual rules - redirect to top-level
|
||||
$(top_srcdir)/build/debug: PHONY; $(MAKE) -C $(top_srcdir) build/debug
|
||||
$(top_srcdir)/build/release: PHONY; $(MAKE) -C $(top_srcdir) build/release
|
||||
test: $$(patsubst %+test,%,$$(.DEFAULT_GOAL))+test PHONY
|
||||
|
||||
# convenience
|
||||
CTEST = ctest
|
||||
test:: $(top_srcdir)/build/debug PHONY; cd $< && $(CTEST)
|
||||
test:: $(top_srcdir)/build/release PHONY; cd $< && $(CTEST)
|
||||
|
||||
#
|
||||
# "make run-testsuite"
|
||||
#***********************************************************************
|
||||
# make run-testsuite
|
||||
# git clone https://github.com/upx/upx-testsuite.git
|
||||
#
|
||||
#***********************************************************************
|
||||
|
||||
# search for the UPX testsuite
|
||||
# you also can override upx_testsuite_SRCDIR
|
||||
# search for the UPX testsuite; you can override by setting "upx_testsuite_SRCDIR"
|
||||
ifndef upx_testsuite_SRCDIR
|
||||
# search standard locations below $(top_srcdir)
|
||||
ifneq ($(wildcard $(top_srcdir)/../upx--upx-testsuite.git/files/packed/.),)
|
||||
@@ -65,47 +55,54 @@ endif
|
||||
# The actual (new) checksums are in ./tmp-upx-testsuite-*/testsuite_1/.sha256sums.recreate
|
||||
ifneq ($(wildcard $(upx_testsuite_SRCDIR)/files/packed/.),)
|
||||
ifneq ($(wildcard $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh),)
|
||||
run-testsuite: run-testsuite-release
|
||||
run-testsuite: run-testsuite-release PHONY
|
||||
run-testsuite-all: run-testsuite-debug run-testsuite-release PHONY
|
||||
run-testsuite-%: export upx_testsuite_SRCDIR := $(upx_testsuite_SRCDIR)
|
||||
run-testsuite-debug: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite-debug
|
||||
run-testsuite-debug: export upx_exe := $(top_srcdir)/build/debug/upx
|
||||
run-testsuite-debug: $(top_srcdir)/build/debug PHONY
|
||||
run-testsuite-debug: build/debug PHONY
|
||||
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh
|
||||
run-testsuite-release: export upx_testsuite_BUILDDIR := ./tmp-upx-testsuite-release
|
||||
run-testsuite-release: export upx_exe := $(top_srcdir)/build/release/upx
|
||||
run-testsuite-release: $(top_srcdir)/build/release PHONY
|
||||
run-testsuite-release: build/release PHONY
|
||||
time -p bash $(top_srcdir)/misc/testsuite/upx_testsuite_1.sh
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# "make check-whitespace"
|
||||
#
|
||||
#***********************************************************************
|
||||
# make check-whitespace
|
||||
#***********************************************************************
|
||||
|
||||
ifneq ($(wildcard /usr/bin/env),) # need Unix utils like bash, perl, sed, xargs, etc.
|
||||
|
||||
CHECK_WHITESPACE = bash $(top_srcdir)/misc/scripts/check_whitespace.sh $(top_srcdir)
|
||||
ifneq ($(wildcard $(top_srcdir)/.git/.),)
|
||||
CHECK_WHITESPACE = bash $(top_srcdir)/misc/scripts/check_whitespace_git.sh $(top_srcdir)
|
||||
endif
|
||||
check-whitespace: PHONY; $(CHECK_WHITESPACE)
|
||||
endif
|
||||
|
||||
#
|
||||
# "make clang-format"
|
||||
#
|
||||
endif # /usr/bin/env
|
||||
|
||||
#***********************************************************************
|
||||
# make clang-format
|
||||
#***********************************************************************
|
||||
|
||||
# automatically format some C++ source code files
|
||||
ifneq ($(wildcard /usr/bin/env),)
|
||||
ifeq ($(shell uname),Linux)
|
||||
|
||||
# Markus loves clang-format, but John hates it; find a compromise
|
||||
CLANG_FORMAT_EXCLUDE_FILES += miniacc.h stub/%.h
|
||||
CLANG_FORMAT_EXCLUDE_FILES += stub/%.h util/miniacc.h
|
||||
CLANG_FORMAT_EXCLUDE_FILES += p_lx_% p_mach% p_unix% p_vmlin%
|
||||
CLANG_FORMAT_FILES := $(sort $(wildcard *.[ch]* ../maint/src/*.[ch]* */*.[ch]*))
|
||||
CLANG_FORMAT_FILES += $(sort $(wildcard stub/tools/*/*.[ch]*))
|
||||
CLANG_FORMAT_FILES += $(sort $(wildcard ../misc/cmake/try_compile/*.[ch]*))
|
||||
CLANG_FORMAT_FILES := $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES))
|
||||
CLANG_FORMAT_FILES := $(sort $(filter-out $(CLANG_FORMAT_EXCLUDE_FILES),$(CLANG_FORMAT_FILES)))
|
||||
clang-format: $(CLANG_FORMAT_FILES) PHONY
|
||||
@echo "running upx-clang-format"
|
||||
@$(top_srcdir)/misc/scripts/upx-clang-format.sh -i $(CLANG_FORMAT_FILES)
|
||||
endif
|
||||
@bash $(top_srcdir)/misc/scripts/upx-clang-format.sh -i $(CLANG_FORMAT_FILES)
|
||||
|
||||
endif # Linux
|
||||
endif # /usr/bin/env
|
||||
|
||||
# vim:set ts=8 sw=8 noet:
|
||||
|
||||
+81
-45
@@ -47,8 +47,9 @@
|
||||
// try to detect XX16 vs XX32 vs XX64 size mismatches
|
||||
**************************************************************************/
|
||||
|
||||
#if 0 // permissive version using "void *"
|
||||
#if !(DEBUG)
|
||||
|
||||
// permissive version using "void *"
|
||||
#define REQUIRE_XE16 /*empty*/
|
||||
#define REQUIRE_XE24 /*empty*/
|
||||
#define REQUIRE_XE32 /*empty*/
|
||||
@@ -68,20 +69,22 @@ struct LE16;
|
||||
struct LE32;
|
||||
struct LE64;
|
||||
|
||||
namespace bele_detail {
|
||||
|
||||
// Note:
|
||||
// void is explicitly allowed (but there is no automatic pointer conversion because of template!)
|
||||
// char is explicitly allowed
|
||||
// byte is explicitly allowed
|
||||
template <class T>
|
||||
static inline constexpr bool is_xe16_type =
|
||||
inline constexpr bool is_xe16_type =
|
||||
upx::is_same_any_v<T, void, char, byte, upx_int16_t, upx_uint16_t, BE16, LE16>;
|
||||
template <class T>
|
||||
static inline constexpr bool is_xe24_type = upx::is_same_any_v<T, void, char, byte>;
|
||||
inline constexpr bool is_xe24_type = upx::is_same_any_v<T, void, char, byte>;
|
||||
template <class T>
|
||||
static inline constexpr bool is_xe32_type =
|
||||
inline constexpr bool is_xe32_type =
|
||||
upx::is_same_any_v<T, void, char, byte, upx_int32_t, upx_uint32_t, BE32, LE32>;
|
||||
template <class T>
|
||||
static inline constexpr bool is_xe64_type =
|
||||
inline constexpr bool is_xe64_type =
|
||||
upx::is_same_any_v<T, void, char, byte, upx_int64_t, upx_uint64_t, BE64, LE64>;
|
||||
|
||||
template <class T>
|
||||
@@ -93,10 +96,12 @@ using enable_if_xe32 = std::enable_if_t<is_xe32_type<T>, T>;
|
||||
template <class T>
|
||||
using enable_if_xe64 = std::enable_if_t<is_xe64_type<T>, T>;
|
||||
|
||||
#define REQUIRE_XE16 template <class XE16, class = enable_if_xe16<XE16> >
|
||||
#define REQUIRE_XE24 template <class XE24, class = enable_if_xe24<XE24> >
|
||||
#define REQUIRE_XE32 template <class XE32, class = enable_if_xe32<XE32> >
|
||||
#define REQUIRE_XE64 template <class XE64, class = enable_if_xe64<XE64> >
|
||||
} // namespace bele_detail
|
||||
|
||||
#define REQUIRE_XE16 template <class XE16, class = bele_detail::enable_if_xe16<XE16> >
|
||||
#define REQUIRE_XE24 template <class XE24, class = bele_detail::enable_if_xe24<XE24> >
|
||||
#define REQUIRE_XE32 template <class XE32, class = bele_detail::enable_if_xe32<XE32> >
|
||||
#define REQUIRE_XE64 template <class XE64, class = bele_detail::enable_if_xe64<XE64> >
|
||||
|
||||
#endif // permissive version
|
||||
|
||||
@@ -152,11 +157,15 @@ static forceinline void set_ne64(XE64 *p, upx_uint64_t vv) noexcept {
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4)
|
||||
|
||||
// unfortunately *not* constexpr with current MSVC
|
||||
static forceinline unsigned bswap16(unsigned v) noexcept {
|
||||
static forceinline /*constexpr*/ unsigned bswap16(unsigned v) noexcept {
|
||||
return (unsigned) _byteswap_ulong(v << 16);
|
||||
}
|
||||
static forceinline unsigned bswap32(unsigned v) noexcept { return (unsigned) _byteswap_ulong(v); }
|
||||
static forceinline upx_uint64_t bswap64(upx_uint64_t v) noexcept { return _byteswap_uint64(v); }
|
||||
static forceinline /*constexpr*/ unsigned bswap32(unsigned v) noexcept {
|
||||
return (unsigned) _byteswap_ulong(v);
|
||||
}
|
||||
static forceinline /*constexpr*/ upx_uint64_t bswap64(upx_uint64_t v) noexcept {
|
||||
return _byteswap_uint64(v);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
@@ -266,21 +275,27 @@ inline void set_le24(XE24 *p, unsigned v) noexcept {
|
||||
b[2] = ACC_ICONV(byte, (v >> 16) & 0xff);
|
||||
}
|
||||
|
||||
inline unsigned get_le26(const void *p) noexcept { return get_le32(p) & 0x03ffffff; }
|
||||
inline unsigned get_le19_5(const void *p) noexcept { return (get_le32(p) >> 5) & 0x0007ffff; }
|
||||
inline unsigned get_le14_5(const void *p) noexcept { return (get_le32(p) >> 5) & 0x00003fff; }
|
||||
REQUIRE_XE32
|
||||
inline unsigned get_le26(const XE32 *p) noexcept { return get_le32(p) & 0x03ffffff; }
|
||||
REQUIRE_XE32
|
||||
inline unsigned get_le19_5(const XE32 *p) noexcept { return (get_le32(p) >> 5) & 0x0007ffff; }
|
||||
REQUIRE_XE32
|
||||
inline unsigned get_le14_5(const XE32 *p) noexcept { return (get_le32(p) >> 5) & 0x00003fff; }
|
||||
|
||||
inline void set_le26(void *p, unsigned v) noexcept {
|
||||
REQUIRE_XE32
|
||||
inline void set_le26(XE32 *p, unsigned v) noexcept {
|
||||
// preserve the top 6 bits
|
||||
// set_le32(p, (get_le32(p) & 0xfc000000) | (v & 0x03ffffff));
|
||||
// optimized version, saving a runtime bswap32
|
||||
set_ne32(p, (get_ne32(p) & ne32_to_le32(0xfc000000)) |
|
||||
(ne32_to_le32(v) & ne32_to_le32(0x03ffffff)));
|
||||
}
|
||||
inline void set_le19_5(void *p, unsigned v) noexcept {
|
||||
REQUIRE_XE32
|
||||
inline void set_le19_5(XE32 *p, unsigned v) noexcept {
|
||||
set_le32(p, (get_le32(p) & 0xff00001f) | ((v & 0x0007ffff) << 5));
|
||||
}
|
||||
inline void set_le14_5(void *p, unsigned v) noexcept {
|
||||
REQUIRE_XE32
|
||||
inline void set_le14_5(XE32 *p, unsigned v) noexcept {
|
||||
set_le32(p, (get_le32(p) & 0xfff8001f) | ((v & 0x00003fff) << 5));
|
||||
}
|
||||
|
||||
@@ -289,17 +304,21 @@ inline void set_le14_5(void *p, unsigned v) noexcept {
|
||||
**************************************************************************/
|
||||
|
||||
static forceinline constexpr int sign_extend(unsigned v, unsigned bits) noexcept {
|
||||
#if (ACC_ARCH_M68K) // no barrel shifter
|
||||
const unsigned sign_bit = 1u << (bits - 1);
|
||||
v &= sign_bit | (sign_bit - 1);
|
||||
v |= 0u - (v & sign_bit);
|
||||
return ACC_ICAST(int, v);
|
||||
return ACC_ICAST(int, (v & (sign_bit - 1)) - (v & sign_bit));
|
||||
#else
|
||||
return ACC_ICAST(int, v << (32 - bits)) >> (32 - bits);
|
||||
#endif
|
||||
}
|
||||
|
||||
static forceinline constexpr upx_int64_t sign_extend(upx_uint64_t v, unsigned bits) noexcept {
|
||||
#if (ACC_ARCH_M68K) // no barrel shifter
|
||||
const upx_uint64_t sign_bit = 1ull << (bits - 1);
|
||||
v &= sign_bit | (sign_bit - 1);
|
||||
v |= 0ull - (v & sign_bit);
|
||||
return ACC_ICAST(upx_int64_t, v);
|
||||
return ACC_ICAST(upx_int64_t, (v & (sign_bit - 1)) - (v & sign_bit));
|
||||
#else
|
||||
return ACC_ICAST(upx_int64_t, v << (64 - bits)) >> (64 - bits);
|
||||
#endif
|
||||
}
|
||||
|
||||
REQUIRE_XE16
|
||||
@@ -714,10 +733,27 @@ T *operator+(T *ptr, const LE64 &v) noexcept DELETED_FUNCTION;
|
||||
template <class T>
|
||||
T *operator-(T *ptr, const LE64 &v) noexcept DELETED_FUNCTION;
|
||||
|
||||
#if !ALLOW_INT_PLUS_MEMBUFFER
|
||||
template <class T>
|
||||
T *operator+(const BE16 &v, T *ptr) noexcept DELETED_FUNCTION;
|
||||
template <class T>
|
||||
T *operator+(const BE32 &v, T *ptr) noexcept DELETED_FUNCTION;
|
||||
template <class T>
|
||||
T *operator+(const LE16 &v, T *ptr) noexcept DELETED_FUNCTION;
|
||||
template <class T>
|
||||
T *operator+(const LE32 &v, T *ptr) noexcept DELETED_FUNCTION;
|
||||
#endif // ALLOW_INT_PLUS_MEMBUFFER
|
||||
|
||||
template <class T>
|
||||
T *operator+(const BE64 &v, T *ptr) noexcept DELETED_FUNCTION;
|
||||
template <class T>
|
||||
T *operator+(const LE64 &v, T *ptr) noexcept DELETED_FUNCTION;
|
||||
|
||||
/*************************************************************************
|
||||
// global overloads
|
||||
**************************************************************************/
|
||||
|
||||
// TODO later: move these to upx namespace in util/cxxlib.h; see conf.h
|
||||
inline unsigned ALIGN_DOWN(unsigned a, const BE32 &b) { return ALIGN_DOWN(a, unsigned(b)); }
|
||||
inline unsigned ALIGN_DOWN(const BE32 &a, unsigned b) { return ALIGN_DOWN(unsigned(a), b); }
|
||||
inline unsigned ALIGN_UP(unsigned a, const BE32 &b) { return ALIGN_UP(a, unsigned(b)); }
|
||||
@@ -728,7 +764,7 @@ inline unsigned ALIGN_DOWN(const LE32 &a, unsigned b) { return ALIGN_DOWN(unsign
|
||||
inline unsigned ALIGN_UP(unsigned a, const LE32 &b) { return ALIGN_UP(a, unsigned(b)); }
|
||||
inline unsigned ALIGN_UP(const LE32 &a, unsigned b) { return ALIGN_UP(unsigned(a), b); }
|
||||
|
||||
// TODO: introduce upx::umax() and upx::umin()
|
||||
// TODO later: introduce upx::umax() and upx::umin()
|
||||
inline unsigned UPX_MAX(unsigned a, const BE16 &b) { return UPX_MAX(a, unsigned(b)); }
|
||||
inline unsigned UPX_MAX(const BE16 &a, unsigned b) { return UPX_MAX(unsigned(a), b); }
|
||||
inline unsigned UPX_MIN(unsigned a, const BE16 &b) { return UPX_MIN(a, unsigned(b)); }
|
||||
@@ -753,6 +789,26 @@ inline unsigned UPX_MIN(const LE32 &a, unsigned b) { return UPX_MIN(unsigned(a),
|
||||
// misc support
|
||||
**************************************************************************/
|
||||
|
||||
// for use with qsort()
|
||||
extern "C" {
|
||||
int __acc_cdecl_qsort be16_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be24_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be32_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be64_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le16_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le24_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le32_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le64_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be16_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort be24_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort be32_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort be64_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le16_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le24_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le32_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
||||
} // extern "C"
|
||||
|
||||
// <type_traits> upx_is_integral; see conf.h
|
||||
#define TT_UPX_IS_INTEGRAL(T) \
|
||||
template <> \
|
||||
@@ -794,26 +850,6 @@ typedef LE64 NE64;
|
||||
#define ne64_compare_signed le64_compare_signed
|
||||
#endif
|
||||
|
||||
// for use with qsort()
|
||||
extern "C" {
|
||||
int __acc_cdecl_qsort be16_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be24_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be32_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be64_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le16_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le24_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le32_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort le64_compare(const void *, const void *);
|
||||
int __acc_cdecl_qsort be16_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort be24_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort be32_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort be64_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le16_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le24_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le32_compare_signed(const void *, const void *);
|
||||
int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
|
||||
} // extern "C"
|
||||
|
||||
/*************************************************************************
|
||||
// Provide namespaces and classes to abstract endianness policies.
|
||||
//
|
||||
|
||||
+11
-8
@@ -34,11 +34,13 @@
|
||||
#if defined(BELE_CTP)
|
||||
// CTP - Compile-Time Polymorphism (templates)
|
||||
#define V static inline
|
||||
#define VV static forceinline_constexpr
|
||||
#define S static int __acc_cdecl_qsort
|
||||
#define C noexcept
|
||||
#elif defined(BELE_RTP)
|
||||
// RTP - Run-Time Polymorphism (virtual functions)
|
||||
#define V virtual
|
||||
#define VV virtual
|
||||
#define S virtual int
|
||||
#define C const noexcept
|
||||
#else
|
||||
@@ -90,9 +92,9 @@ private:
|
||||
#define C const noexcept override
|
||||
#endif
|
||||
|
||||
struct BEPolicy
|
||||
struct BEPolicy final
|
||||
#if defined(BELE_RTP)
|
||||
final : public AbstractPolicy
|
||||
: public AbstractPolicy
|
||||
#endif
|
||||
{
|
||||
explicit inline BEPolicy() noexcept {}
|
||||
@@ -101,8 +103,8 @@ struct BEPolicy
|
||||
#elif defined(BELE_RTP)
|
||||
typedef N_BELE_CTP::BEPolicy CTP_Policy;
|
||||
#endif
|
||||
V bool isBE() C { return true; }
|
||||
V bool isLE() C { return false; }
|
||||
VV bool isBE() C { return true; }
|
||||
VV bool isLE() C { return false; }
|
||||
|
||||
typedef BE16 U16;
|
||||
typedef BE32 U32;
|
||||
@@ -149,9 +151,9 @@ private:
|
||||
UPX_CXX_DISABLE_NEW_DELETE(BEPolicy)
|
||||
};
|
||||
|
||||
struct LEPolicy
|
||||
struct LEPolicy final
|
||||
#if defined(BELE_RTP)
|
||||
final : public AbstractPolicy
|
||||
: public AbstractPolicy
|
||||
#endif
|
||||
{
|
||||
explicit inline LEPolicy() noexcept {}
|
||||
@@ -160,8 +162,8 @@ struct LEPolicy
|
||||
#elif defined(BELE_RTP)
|
||||
typedef N_BELE_CTP::LEPolicy CTP_Policy;
|
||||
#endif
|
||||
V bool isBE() C { return false; }
|
||||
V bool isLE() C { return true; }
|
||||
VV bool isBE() C { return false; }
|
||||
VV bool isLE() C { return true; }
|
||||
|
||||
typedef LE16 U16;
|
||||
typedef LE32 U32;
|
||||
@@ -220,6 +222,7 @@ typedef LEPolicy HostPolicy;
|
||||
#endif
|
||||
|
||||
#undef V
|
||||
#undef VV
|
||||
#undef S
|
||||
#undef C
|
||||
|
||||
|
||||
+210
-38
@@ -24,6 +24,11 @@
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
// doctest checks, and various tests to catch toolchain/qemu/sanitizer/valgrind/wine/etc
|
||||
// problems; grown historically
|
||||
|
||||
#include "../util/system_headers.h"
|
||||
#include <cmath> // std::isinf std::isnan
|
||||
#include "../conf.h"
|
||||
|
||||
/*************************************************************************
|
||||
@@ -42,10 +47,7 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
UNUSED(argv);
|
||||
return 0;
|
||||
#else
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE");
|
||||
if (!e)
|
||||
e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling
|
||||
if (e && e[0] && strcmp(e, "0") != 0)
|
||||
if (is_envvar_true("UPX_DEBUG_DOCTEST_DISABLE", "UPX_DEBUG_DISABLE_DOCTEST"))
|
||||
return 0;
|
||||
bool minimal = true; // don't show summary
|
||||
bool duration = false; // don't show timings
|
||||
@@ -54,7 +56,7 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
// default for debug builds: do show the [doctest] summary
|
||||
minimal = false;
|
||||
#endif
|
||||
e = getenv("UPX_DEBUG_DOCTEST_VERBOSE");
|
||||
const char *e = upx_getenv("UPX_DEBUG_DOCTEST_VERBOSE");
|
||||
if (e && e[0]) {
|
||||
if (strcmp(e, "0") == 0) {
|
||||
minimal = true;
|
||||
@@ -76,7 +78,7 @@ int upx_doctest_check(int argc, char **argv) {
|
||||
context.setOption("dt-duration", true);
|
||||
if (success)
|
||||
context.setOption("dt-success", true);
|
||||
// this requires that main_get_options() understands "--dt-XXX" options
|
||||
// this requires that main_get_options() understands/ignores doctest "--dt-XXX" options
|
||||
if (argc > 0 && argv != nullptr)
|
||||
context.applyCommandLine(argc, argv);
|
||||
int r = context.run();
|
||||
@@ -125,6 +127,8 @@ ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 257, 8) == 1)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 383, 8) == 127)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 384, 8) == -128)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0u + 511, 8) == -1)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0ull + 0, 1) == 0)
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sign_extend(0ull + 1, 1) == -1)
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(CHAR_BIT == 8)
|
||||
#if 0 // does not work with MSVC
|
||||
@@ -321,6 +325,17 @@ struct TestIntegerWrap {
|
||||
static inline bool neg_eq(const T x) noexcept { return T(0) - x == x; }
|
||||
};
|
||||
|
||||
//
|
||||
// basic exception handling checks to early catch toolchain/qemu/wine/etc problems
|
||||
//
|
||||
|
||||
struct TestDestructor {
|
||||
explicit TestDestructor(int *pp, int vv) noexcept : p(pp), v(vv) {}
|
||||
virtual noinline ~TestDestructor() noexcept { *p = (*p << 2) + v; }
|
||||
int *p;
|
||||
int v;
|
||||
};
|
||||
|
||||
static noinline void throwSomeValue(int x) may_throw {
|
||||
if (x < 0)
|
||||
throw int(x);
|
||||
@@ -328,40 +343,129 @@ static noinline void throwSomeValue(int x) may_throw {
|
||||
throw size_t(x);
|
||||
}
|
||||
|
||||
static noinline void check_exceptions_2(void (*func)(int), int *x) may_throw {
|
||||
TestDestructor d(x, *x);
|
||||
func(*x);
|
||||
}
|
||||
|
||||
static noinline void check_basic_cxx_exception_handling(void (*func)(int)) noexcept {
|
||||
bool cxx_exception_handling_works = false;
|
||||
int x = 1;
|
||||
try {
|
||||
func(42);
|
||||
TestDestructor d(&x, 3);
|
||||
check_exceptions_2(func, &x);
|
||||
} catch (const size_t &e) {
|
||||
if (e == 42)
|
||||
if (e == 1 && x == 23)
|
||||
cxx_exception_handling_works = true;
|
||||
} catch (...) {
|
||||
}
|
||||
assert_noexcept(cxx_exception_handling_works);
|
||||
}
|
||||
|
||||
//
|
||||
// basic floating point checks to early catch toolchain/qemu/wine/etc problems
|
||||
//
|
||||
|
||||
static noinline float i64_f32_add_div(upx_int64_t a, upx_int64_t b) { return (a + b) / 1000000.0f; }
|
||||
static noinline float u64_f32_add_div(upx_uint64_t a, upx_uint64_t b) {
|
||||
return (a + b) / 1000000.0f;
|
||||
}
|
||||
static noinline float i64_f32_sub_div(upx_int64_t a, upx_int64_t b) { return (a - b) / 1000000.0f; }
|
||||
static noinline float u64_f32_sub_div(upx_uint64_t a, upx_uint64_t b) {
|
||||
return (a - b) / 1000000.0f;
|
||||
}
|
||||
|
||||
static noinline double i64_f64_add_div(upx_int64_t a, upx_int64_t b) { return (a + b) / 1000000.0; }
|
||||
static noinline double u64_f64_add_div(upx_uint64_t a, upx_uint64_t b) {
|
||||
return (a + b) / 1000000.0;
|
||||
}
|
||||
static noinline double i64_f64_sub_div(upx_int64_t a, upx_int64_t b) { return (a - b) / 1000000.0; }
|
||||
static noinline double u64_f64_sub_div(upx_uint64_t a, upx_uint64_t b) {
|
||||
return (a - b) / 1000000.0;
|
||||
}
|
||||
|
||||
template <class Int, class Float>
|
||||
struct TestFloat {
|
||||
static constexpr Int X = 1000000;
|
||||
static noinline Float div(Int a, Float f) { return a / f; }
|
||||
static noinline Float add_div(Int a, Int b, Float f) { return Float(a + b) / f; }
|
||||
static noinline Float sub_div(Int a, Int b, Float f) { return Float(a - b) / f; }
|
||||
static noinline Float add_div_x(Int a, Int b) { return Float(a + b) / Float(X); }
|
||||
static noinline Float sub_div_x(Int a, Int b) { return Float(a - b) / Float(X); }
|
||||
static noinline void check() noexcept {
|
||||
assert_noexcept(div(2 * X, Float(X)) == Float(2));
|
||||
assert_noexcept(add_div(X, X, Float(X)) == Float(2));
|
||||
assert_noexcept(add_div_x(X, X) == Float(2));
|
||||
assert_noexcept(sub_div(3 * X, X, Float(X)) == Float(2));
|
||||
assert_noexcept(sub_div_x(3 * X, X) == Float(2));
|
||||
// extra debugging; floating point edge cases cause portability problems in practice
|
||||
static const char envvar[] = "UPX_DEBUG_TEST_FLOAT_DIVISION_BY_ZERO";
|
||||
if (is_envvar_true(envvar)) {
|
||||
#if defined(__FAST_MATH__)
|
||||
// warning: comparison with NaN always evaluates to false in fast floating point modes
|
||||
fprintf(stderr, "upx: WARNING: ignoring %s: __FAST_MATH__\n", envvar);
|
||||
#else
|
||||
assert_noexcept(std::isnan(div(0, Float(0))));
|
||||
assert_noexcept(std::isinf(div(1, Float(0))));
|
||||
assert_noexcept(std::isinf(div(Int(-1), Float(0))));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static noinline void check_basic_floating_point(void) noexcept {
|
||||
assert_noexcept(i64_f32_add_div(1000000, 1000000) == 2.0f);
|
||||
assert_noexcept(u64_f32_add_div(1000000, 1000000) == 2.0f);
|
||||
assert_noexcept(i64_f32_sub_div(3000000, 1000000) == 2.0f);
|
||||
assert_noexcept(u64_f32_sub_div(3000000, 1000000) == 2.0f);
|
||||
assert_noexcept(i64_f64_add_div(1000000, 1000000) == 2.0);
|
||||
assert_noexcept(u64_f64_add_div(1000000, 1000000) == 2.0);
|
||||
assert_noexcept(i64_f64_sub_div(3000000, 1000000) == 2.0);
|
||||
assert_noexcept(u64_f64_sub_div(3000000, 1000000) == 2.0);
|
||||
TestFloat<upx_int32_t, float>::check();
|
||||
TestFloat<upx_uint32_t, float>::check();
|
||||
TestFloat<upx_int64_t, float>::check();
|
||||
TestFloat<upx_uint64_t, float>::check();
|
||||
TestFloat<upx_int32_t, double>::check();
|
||||
TestFloat<upx_uint32_t, double>::check();
|
||||
TestFloat<upx_int64_t, double>::check();
|
||||
TestFloat<upx_uint64_t, double>::check();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#define ACC_WANT_ACC_CHK_CH 1
|
||||
#undef ACCCHK_ASSERT
|
||||
#include "../miniacc.h"
|
||||
#include "../util/miniacc.h"
|
||||
|
||||
void upx_compiler_sanity_check(void) noexcept {
|
||||
const char *e = getenv("UPX_DEBUG_DOCTEST_DISABLE");
|
||||
if (!e)
|
||||
e = getenv("UPX_DEBUG_DISABLE_DOCTEST"); // allow alternate spelling
|
||||
if (e && e[0] && strcmp(e, "0") != 0) {
|
||||
check_basic_floating_point();
|
||||
|
||||
if (is_envvar_true("UPX_DEBUG_DOCTEST_DISABLE", "UPX_DEBUG_DISABLE_DOCTEST")) {
|
||||
// If UPX_DEBUG_DOCTEST_DISABLE is set then we don't want to throw any
|
||||
// exceptions in order to improve debugging experience.
|
||||
} else {
|
||||
// check working C++ exception handling to catch toolchain/qemu/wine/etc problems
|
||||
// check working C++ exception handling to early catch toolchain/qemu/wine/etc problems
|
||||
check_basic_cxx_exception_handling(throwSomeValue);
|
||||
}
|
||||
|
||||
// check_basic_decltype()
|
||||
{
|
||||
auto a = +0;
|
||||
constexpr auto b = -0;
|
||||
const auto &c = -1;
|
||||
COMPILE_TIME_ASSERT((std::is_same<int, decltype(a)>::value))
|
||||
COMPILE_TIME_ASSERT((std::is_same<const int, decltype(b)>::value))
|
||||
COMPILE_TIME_ASSERT((std::is_same<const int &, decltype(c)>::value))
|
||||
UNUSED(a);
|
||||
UNUSED(b);
|
||||
UNUSED(c);
|
||||
}
|
||||
|
||||
#define ACC_WANT_ACC_CHK_CH 1
|
||||
#undef ACCCHK_ASSERT
|
||||
#define ACCCHK_ASSERT(expr) ACC_COMPILE_TIME_ASSERT(expr)
|
||||
#include "../miniacc.h"
|
||||
#include "../util/miniacc.h"
|
||||
#undef ACCCHK_ASSERT
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(char) == 1)
|
||||
@@ -400,13 +504,25 @@ void upx_compiler_sanity_check(void) noexcept {
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(upx_charptr_unit_type)
|
||||
COMPILE_TIME_ASSERT(sizeof(*((charptr) nullptr)) == 1)
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_STRING4) == 4 + 1)
|
||||
assert_noexcept(strlen(UPX_VERSION_STRING4) == 4);
|
||||
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_YEAR) == 4 + 1)
|
||||
assert_noexcept(strlen(UPX_VERSION_YEAR) == 4);
|
||||
assert_noexcept(memcmp(UPX_VERSION_DATE_ISO, UPX_VERSION_YEAR, 4) == 0);
|
||||
assert_noexcept(
|
||||
memcmp(&UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE) - 1 - 4], UPX_VERSION_YEAR, 4) == 0);
|
||||
// check UPX_VERSION_xxx
|
||||
{
|
||||
using upx::compile_time::mem_eq;
|
||||
using upx::compile_time::string_len;
|
||||
static_assert(string_len(UPX_VERSION_STRING4) == 4);
|
||||
static_assert(string_len(UPX_VERSION_YEAR) == 4);
|
||||
static_assert(string_len(UPX_VERSION_DATE_ISO) == 10);
|
||||
static_assert(string_len(UPX_VERSION_DATE) == 12 || string_len(UPX_VERSION_DATE) == 13);
|
||||
static_assert(mem_eq(UPX_VERSION_STRING4, UPX_VERSION_STRING, 3));
|
||||
static_assert(mem_eq(UPX_VERSION_YEAR, UPX_VERSION_DATE_ISO, 4));
|
||||
static_assert(mem_eq(UPX_VERSION_YEAR, &UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE) - 5], 4));
|
||||
char buf[16];
|
||||
constexpr long long v = UPX_VERSION_HEX;
|
||||
upx_safe_snprintf(buf, sizeof(buf), "%lld.%lld.%lld", (v >> 16), (v >> 8) & 255, v & 255);
|
||||
assert_noexcept(strcmp(buf, UPX_VERSION_STRING) == 0);
|
||||
upx_safe_snprintf(buf, sizeof(buf), "%lld.%lld%lld", (v >> 16), (v >> 8) & 255, v & 255);
|
||||
assert_noexcept(strcmp(buf, UPX_VERSION_STRING4) == 0);
|
||||
}
|
||||
|
||||
if (gitrev[0]) {
|
||||
size_t revlen = strlen(gitrev);
|
||||
if (strncmp(gitrev, "ERROR", 5) == 0) {
|
||||
@@ -468,6 +584,38 @@ void upx_compiler_sanity_check(void) noexcept {
|
||||
assert_noexcept(get_be32_signed(d) == 2138996092);
|
||||
assert_noexcept(get_be64_signed(d) == 9186918263483431288LL);
|
||||
}
|
||||
#if DEBUG >= 1
|
||||
{
|
||||
for (int i = 0; i < 256; i++) {
|
||||
{
|
||||
const unsigned u = i;
|
||||
assert_noexcept(sign_extend(u, 1) == ((i & 1) ? -1 : 0));
|
||||
assert_noexcept(sign_extend(u, 2) == ((i & 2) ? -2 + (i & 1) : (i & 1)));
|
||||
assert_noexcept(sign_extend(u, 3) == ((i & 4) ? -4 + (i & 3) : (i & 3)));
|
||||
assert_noexcept(sign_extend(u, 4) == ((i & 8) ? -8 + (i & 7) : (i & 7)));
|
||||
assert_noexcept(sign_extend(u, 5) == ((i & 16) ? -16 + (i & 15) : (i & 15)));
|
||||
assert_noexcept(sign_extend(u, 6) == ((i & 32) ? -32 + (i & 31) : (i & 31)));
|
||||
assert_noexcept(sign_extend(u, 7) == ((i & 64) ? -64 + (i & 63) : (i & 63)));
|
||||
assert_noexcept(sign_extend(u, 8) == ((i & 128) ? -128 + (i & 127) : (i & 127)));
|
||||
assert_noexcept(sign_extend(u, 32) == i);
|
||||
assert_noexcept(sign_extend(0u - u, 32) == -i);
|
||||
}
|
||||
{
|
||||
const upx_uint64_t u = i;
|
||||
assert_noexcept(sign_extend(u, 1) == ((i & 1) ? -1 : 0));
|
||||
assert_noexcept(sign_extend(u, 2) == ((i & 2) ? -2 + (i & 1) : (i & 1)));
|
||||
assert_noexcept(sign_extend(u, 3) == ((i & 4) ? -4 + (i & 3) : (i & 3)));
|
||||
assert_noexcept(sign_extend(u, 4) == ((i & 8) ? -8 + (i & 7) : (i & 7)));
|
||||
assert_noexcept(sign_extend(u, 5) == ((i & 16) ? -16 + (i & 15) : (i & 15)));
|
||||
assert_noexcept(sign_extend(u, 6) == ((i & 32) ? -32 + (i & 31) : (i & 31)));
|
||||
assert_noexcept(sign_extend(u, 7) == ((i & 64) ? -64 + (i & 63) : (i & 63)));
|
||||
assert_noexcept(sign_extend(u, 8) == ((i & 128) ? -128 + (i & 127) : (i & 127)));
|
||||
assert_noexcept(sign_extend(u, 64) == i);
|
||||
assert_noexcept(sign_extend(0ull - u, 64) == -i);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
unsigned dd;
|
||||
void *const d = ⅆ
|
||||
@@ -540,7 +688,7 @@ void upx_compiler_sanity_check(void) noexcept {
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("assert_noexcept") {
|
||||
// just to make sure that our own assert() macros don't generate any warnings
|
||||
// just to make sure that our own assert() macros do not trigger any compiler warnings
|
||||
byte dummy = 0;
|
||||
byte *ptr1 = &dummy;
|
||||
const byte *const ptr2 = &dummy;
|
||||
@@ -562,19 +710,27 @@ TEST_CASE("acc_vget") {
|
||||
CHECK_EQ(acc_vget_long(1, -1), 1);
|
||||
CHECK_EQ(acc_vget_acc_int64l_t(2, 1), 2);
|
||||
CHECK_EQ(acc_vget_acc_hvoid_p(nullptr, 0), nullptr);
|
||||
if (acc_vget_int(1, 0) > 0)
|
||||
return;
|
||||
assert_noexcept(false);
|
||||
}
|
||||
|
||||
TEST_CASE("ptr_invalidate_and_poison") {
|
||||
int *ip = nullptr;
|
||||
int *ip = nullptr; // initialized
|
||||
ptr_invalidate_and_poison(ip);
|
||||
assert(ip != nullptr);
|
||||
(void) ip;
|
||||
double *dp;
|
||||
double *dp; // not initialized
|
||||
ptr_invalidate_and_poison(dp);
|
||||
assert(dp != nullptr);
|
||||
(void) dp;
|
||||
}
|
||||
|
||||
TEST_CASE("upx_getenv") {
|
||||
CHECK_EQ(upx_getenv(nullptr), nullptr);
|
||||
CHECK_EQ(upx_getenv(""), nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("working -fno-strict-aliasing") {
|
||||
bool ok;
|
||||
long v = 0;
|
||||
@@ -635,13 +791,23 @@ TEST_CASE("libc snprintf") {
|
||||
CHECK_EQ(strcmp(buf, "-6.0.0.0.0.0.0.0.6.ffffffffffffffff"), 0);
|
||||
snprintf(buf, sizeof(buf), "%d.%d.%d.%d.%d.%d.%d.%d.%d.%#jx", -7, 0, 0, 0, 0, 0, 0, 0, 7, um);
|
||||
CHECK_EQ(strcmp(buf, "-7.0.0.0.0.0.0.0.7.0xffffffffffffffff"), 0);
|
||||
snprintf(buf, sizeof(buf), "%#X %#lx %#llx", 26u, 27ul, 28ull);
|
||||
CHECK_EQ(strcmp(buf, "0X1A 0x1b 0x1c"), 0);
|
||||
snprintf(buf, sizeof(buf), "%#06x %#06lX %#06llx", 26u, 27ul, 28ull);
|
||||
CHECK_EQ(strcmp(buf, "0x001a 0X001B 0x001c"), 0);
|
||||
snprintf(buf, sizeof(buf), "%#6x %#6lx %#6llX", 26u, 27ul, 28ull);
|
||||
CHECK_EQ(strcmp(buf, " 0x1a 0x1b 0X1C"), 0);
|
||||
snprintf(buf, sizeof(buf), "%#-6X %#-6lx %#-6llx", 26u, 27ul, 28ull);
|
||||
CHECK_EQ(strcmp(buf, "0X1A 0x1b 0x1c "), 0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST_CASE("libc qsort") {
|
||||
// runtime check that libc qsort() never compares identical objects
|
||||
// UPDATE: while only poor implementations of qsort() would actually do
|
||||
// this, it is probably allowed by the standard; so skip this test case
|
||||
// UPDATE: while only poor implementations of qsort() would actually do this
|
||||
// it is probably allowed by the standard, so skip this test by default
|
||||
if (!is_envvar_true("UPX_DEBUG_TEST_LIBC_QSORT"))
|
||||
return;
|
||||
|
||||
struct Elem {
|
||||
upx_uint16_t id;
|
||||
upx_uint16_t value;
|
||||
@@ -651,35 +817,41 @@ TEST_CASE("libc qsort") {
|
||||
assert_noexcept(a->id != b->id); // check not IDENTICAL
|
||||
return a->value < b->value ? -1 : (a->value == b->value ? 0 : 1);
|
||||
}
|
||||
static bool check_sort(upx_sort_func_t sort, Elem *e, size_t n) {
|
||||
upx_uint32_t x = 5381 + n + ((upx_uintptr_t) e & 0xff);
|
||||
static noinline bool check_sort(upx_sort_func_t sort, Elem *e, size_t n, bool is_stable) {
|
||||
upx_uint32_t x = 5381 + (upx_rand() & 255);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
e[i].id = (upx_uint16_t) i;
|
||||
x = x * 33 + 1 + (i & 255);
|
||||
e[i].value = (upx_uint16_t) x;
|
||||
e[i].value = (upx_uint16_t) ((x >> 4) & 15);
|
||||
}
|
||||
sort(e, n, sizeof(Elem), Elem::compare);
|
||||
for (size_t i = 1; i < n; i++)
|
||||
// verify
|
||||
for (size_t i = 1; i < n; i++) {
|
||||
if very_unlikely (e[i - 1].value > e[i].value)
|
||||
return false;
|
||||
if (is_stable)
|
||||
if very_unlikely (e[i - 1].value == e[i].value && e[i - 1].id >= e[i].id)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
constexpr size_t N = 4096;
|
||||
Elem e[N];
|
||||
for (size_t n = 0; n <= N; n = 2 * n + 1) {
|
||||
// CHECK(Elem::check_sort(qsort, e, n)); // libc qsort()
|
||||
CHECK(Elem::check_sort(upx_gnomesort, e, n));
|
||||
CHECK(Elem::check_sort(upx_shellsort_memswap, e, n));
|
||||
CHECK(Elem::check_sort(upx_shellsort_memcpy, e, n));
|
||||
// system sort functions
|
||||
CHECK(Elem::check_sort(::qsort, e, n, false)); // libc qsort()
|
||||
#if UPX_CONFIG_USE_STABLE_SORT
|
||||
upx_sort_func_t wrap_stable_sort = [](void *aa, size_t nn, size_t, upx_compare_func_t cc) {
|
||||
upx_std_stable_sort<sizeof(Elem)>(aa, nn, cc);
|
||||
};
|
||||
CHECK(Elem::check_sort(wrap_stable_sort, e, n));
|
||||
CHECK(Elem::check_sort(wrap_stable_sort, e, n, true)); // std::stable_sort()
|
||||
#endif
|
||||
// simple UPX sort functions
|
||||
CHECK(Elem::check_sort(upx_gnomesort, e, n, true));
|
||||
CHECK(Elem::check_sort(upx_shellsort_memswap, e, n, false));
|
||||
CHECK(Elem::check_sort(upx_shellsort_memcpy, e, n, false));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+151
-7
@@ -27,6 +27,8 @@
|
||||
// lots of tests (and probably quite a number of redundant tests)
|
||||
// modern compilers will optimize away much of this code
|
||||
|
||||
#include "../util/system_headers.h"
|
||||
#include <vector> // std::vector
|
||||
#include "../conf.h"
|
||||
|
||||
/*************************************************************************
|
||||
@@ -49,6 +51,12 @@ ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char, char>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((!upx::is_same_any_v<int, char, long>) )
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER((upx::is_same_any_v<ptrdiff_t, int, long, long long>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(
|
||||
(upx::is_same_any_v<size_t, unsigned, unsigned long, unsigned long long>) )
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(
|
||||
(upx::is_same_any_v<upx_uintptr_t, unsigned, unsigned long, unsigned long long>) )
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == sizeof(int))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof('a') == sizeof(char))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(usizeof("") == 1)
|
||||
@@ -97,6 +105,30 @@ ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_gt("abc", "abz"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::string_ge("abc", "abz"))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::string_le("abc", "abz"))
|
||||
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq((const char *) nullptr, nullptr, 0))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq((const byte *) nullptr, nullptr, 0))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq("", "", 0))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(compile_time::mem_eq("abc", "abc", 3))
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(!compile_time::mem_eq("abc", "abz", 3))
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("std::vector") {
|
||||
constexpr size_t N = 16;
|
||||
std::vector<int> v(N);
|
||||
CHECK(v.end() - v.begin() == N);
|
||||
CHECK(&v[0] == &(*(v.begin())));
|
||||
// CHECK(&v[0] + N == &(*(v.end()))); // TODO later: is this legal??
|
||||
// TODO later: make sure that this throws
|
||||
#if defined(_LIBCPP_HARDENING_MODE_DEBUG) && \
|
||||
(_LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG)
|
||||
CHECK_THROWS((void) &v[N]);
|
||||
#endif
|
||||
UNUSED(v);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// UPX_CXX_DISABLE_xxx
|
||||
**************************************************************************/
|
||||
@@ -134,7 +166,7 @@ struct MyVType2 {
|
||||
UPX_CXX_DISABLE_ADDRESS(Self)
|
||||
UPX_CXX_DISABLE_NEW_DELETE(Self)
|
||||
};
|
||||
TEST_CASE("upx_cxx_disable") {
|
||||
TEST_CASE("UPX_CXX_DISABLE_xxx") {
|
||||
MyType1<char, int, 1> dummy1;
|
||||
MyType2<char, int, 2> dummy2;
|
||||
MyVType1<char, int, 1> vdummy1;
|
||||
@@ -218,8 +250,114 @@ struct Z2_X2 : public X2 {
|
||||
// util
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("ptr_static_cast") {
|
||||
// check that we don't trigger any -Wcast-align warnings
|
||||
#if WITH_THREADS
|
||||
TEST_CASE("upx::ptr_std_atomic_cast") {
|
||||
// pointer-size
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((void **) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((uintptr_t *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((upx_uintptr_t *) nullptr), nullptr);
|
||||
#if 1
|
||||
// more fundamental types
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((char *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((short *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((int *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((long *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((ptrdiff_t *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((size_t *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int8_t *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int16_t *) nullptr), nullptr);
|
||||
CHECK_EQ(upx::ptr_std_atomic_cast((upx_int32_t *) nullptr), nullptr);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE("upx::atomic_exchange") {
|
||||
{
|
||||
upx_uintptr_t x = (upx_uintptr_t) 0 - 1;
|
||||
upx_uintptr_t y = upx::atomic_exchange(&x, (upx_uintptr_t) 2);
|
||||
CHECK_EQ(x, 2);
|
||||
CHECK_EQ(y, (upx_uintptr_t) 0 - 1);
|
||||
UNUSED(y);
|
||||
}
|
||||
{
|
||||
const int buf[2] = {101, 202};
|
||||
const int *ptr_array[2] = {&buf[0], &buf[1]};
|
||||
assert_noexcept(*ptr_array[0] == 101 && *ptr_array[1] == 202);
|
||||
const int *p = upx::atomic_exchange(&ptr_array[0], ptr_array[1]);
|
||||
CHECK_EQ(p, buf + 0);
|
||||
assert_noexcept(*ptr_array[0] == 202 && *ptr_array[1] == 202);
|
||||
p = upx::atomic_exchange(&ptr_array[1], p);
|
||||
CHECK_EQ(p, buf + 1);
|
||||
assert_noexcept(*ptr_array[0] == 202 && *ptr_array[1] == 101);
|
||||
UNUSED(p);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("upx::ObjectDeleter 1") {
|
||||
LE16 *o = nullptr; // object
|
||||
LE32 *a = nullptr; // array
|
||||
LE64 *m = nullptr; // malloc
|
||||
{
|
||||
auto o_deleter = upx::ObjectDeleter(&o, 1);
|
||||
o = new LE16;
|
||||
assert(o != nullptr);
|
||||
auto a_deleter = upx::ArrayDeleter(&a, 1);
|
||||
a = New(LE32, 1);
|
||||
assert(a != nullptr);
|
||||
auto m_deleter = upx::MallocDeleter(&m, 1);
|
||||
m = (LE64 *) ::malloc(sizeof(LE64));
|
||||
assert(m != nullptr);
|
||||
}
|
||||
assert(o == nullptr);
|
||||
assert(a == nullptr);
|
||||
assert(m == nullptr);
|
||||
// test "const" versions
|
||||
{
|
||||
const auto o_deleter = upx::ObjectDeleter(&o, 1);
|
||||
o = new LE16;
|
||||
assert(o != nullptr);
|
||||
const auto a_deleter = upx::ArrayDeleter(&a, 1);
|
||||
a = New(LE32, 1);
|
||||
assert(a != nullptr);
|
||||
const auto m_deleter = upx::MallocDeleter(&m, 1);
|
||||
m = (LE64 *) ::malloc(sizeof(LE64));
|
||||
assert(m != nullptr);
|
||||
}
|
||||
assert(o == nullptr);
|
||||
assert(a == nullptr);
|
||||
assert(m == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("upx::ObjectDeleter 2") {
|
||||
constexpr size_t N = 2;
|
||||
BE16 *o[N]; // multiple objects
|
||||
BE32 *a[N]; // multiple arrays
|
||||
BE64 *m[N]; // multiple mallocs
|
||||
{
|
||||
auto o_deleter = upx::ObjectDeleter(o, 0);
|
||||
auto a_deleter = upx::ArrayDeleter(a, 0);
|
||||
auto m_deleter = upx::MallocDeleter(m, 0);
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
o[i] = new BE16;
|
||||
assert(o[i] != nullptr);
|
||||
o_deleter.count += 1;
|
||||
a[i] = New(BE32, 1 + i);
|
||||
assert(a[i] != nullptr);
|
||||
a_deleter.count += 1;
|
||||
m[i] = (BE64 *) ::malloc(sizeof(BE64));
|
||||
assert(m[i] != nullptr);
|
||||
m_deleter.count += 1;
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
assert(o[i] == nullptr);
|
||||
assert(a[i] == nullptr);
|
||||
assert(m[i] == nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("upx::ptr_static_cast") {
|
||||
// check that we do not trigger any -Wcast-align warnings
|
||||
using upx::ptr_static_cast;
|
||||
void *vp = nullptr;
|
||||
byte *bp = nullptr;
|
||||
@@ -258,7 +396,7 @@ TEST_CASE("ptr_static_cast") {
|
||||
assert((ic == ptr_static_cast<const int *>(ic)));
|
||||
}
|
||||
|
||||
TEST_CASE("noncopyable") {
|
||||
TEST_CASE("upx::noncopyable") {
|
||||
struct Test : private upx::noncopyable {
|
||||
int v = 1;
|
||||
};
|
||||
@@ -282,7 +420,7 @@ TEST_CASE("noncopyable") {
|
||||
namespace {
|
||||
template <class T>
|
||||
struct TestTriBool {
|
||||
static void test(bool expect_true) {
|
||||
static noinline void test(bool expect_true) {
|
||||
static_assert(std::is_class<T>::value);
|
||||
static_assert(std::is_nothrow_default_constructible<T>::value);
|
||||
static_assert(std::is_nothrow_destructible<T>::value);
|
||||
@@ -290,8 +428,12 @@ struct TestTriBool {
|
||||
static_assert(std::is_trivially_copyable<T>::value);
|
||||
static_assert(sizeof(typename T::value_type) == sizeof(typename T::underlying_type));
|
||||
static_assert(alignof(typename T::value_type) == alignof(typename T::underlying_type));
|
||||
#if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__)
|
||||
#if defined(__m68k__) && defined(__atarist__) && defined(__GNUC__)
|
||||
// broken compiler or broken ABI
|
||||
#elif defined(__i386__) && defined(__GNUC__) && (__GNUC__ == 7) && !defined(__clang__)
|
||||
static_assert(sizeof(T) == sizeof(typename T::underlying_type));
|
||||
// i386: "long long" enum align bug/ABI problem on older compilers
|
||||
static_assert(alignof(T) <= alignof(typename T::underlying_type));
|
||||
#else
|
||||
static_assert(sizeof(T) == sizeof(typename T::underlying_type));
|
||||
static_assert(alignof(T) == alignof(typename T::underlying_type));
|
||||
@@ -366,9 +508,11 @@ struct TestTriBool {
|
||||
assert(a);
|
||||
assert(bool(a));
|
||||
assert((a ? true : false));
|
||||
assert((!a ? false : true));
|
||||
} else {
|
||||
assert(!a);
|
||||
assert(!bool(a));
|
||||
assert((a ? false : true));
|
||||
assert((!a ? true : false));
|
||||
}
|
||||
assert(!a.isStrictFalse());
|
||||
@@ -381,7 +525,7 @@ struct TestTriBool {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("TriBool") {
|
||||
TEST_CASE("upx::TriBool") {
|
||||
using upx::TriBool, upx::tribool;
|
||||
static_assert(!tribool(false));
|
||||
static_assert(tribool(true));
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../util/system_defs.h"
|
||||
#include "../util/system_features.h"
|
||||
|
||||
/*************************************************************************
|
||||
// doctest support code implementation
|
||||
**************************************************************************/
|
||||
@@ -33,7 +36,10 @@
|
||||
|
||||
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||
|
||||
#if defined(__i386__) && defined(__MSDOS__) && defined(__DJGPP__) && defined(__GNUC__)
|
||||
#if defined(__wasi__)
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
|
||||
#elif defined(__i386__) && defined(__MSDOS__) && defined(__DJGPP__) && defined(__GNUC__)
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
|
||||
#elif defined(__m68k__) && defined(__atarist__) && defined(__GNUC__)
|
||||
@@ -43,13 +49,13 @@
|
||||
#pragma GCC diagnostic ignored "-Wshadow"
|
||||
#endif
|
||||
|
||||
#if !defined(UPX_DOCTEST_CONFIG_MULTITHREADING) && !(WITH_THREADS)
|
||||
#if !(WITH_THREADS) && !defined(UPX_DOCTEST_CONFIG_MULTITHREADING)
|
||||
#ifndef DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) && defined(__FAST_MATH__) && defined(__INTEL_LLVM_COMPILER)
|
||||
#if defined(__FAST_MATH__) && defined(__clang__) && (__clang_major__ + 0 >= 6)
|
||||
// warning: comparison with NaN always evaluates to false in fast floating point modes
|
||||
#pragma clang diagnostic ignored "-Wtautological-constant-compare"
|
||||
#endif
|
||||
|
||||
@@ -241,6 +241,35 @@ TEST_CASE("basic xspan usage") {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("xspan array access") {
|
||||
const size_t N = 16;
|
||||
char buf[N];
|
||||
memset(buf, 0, sizeof(buf));
|
||||
XSPAN_0_VAR(char, c0, buf, sizeof(buf));
|
||||
XSPAN_P_VAR(char, cp, buf, sizeof(buf));
|
||||
XSPAN_S_VAR(char, cs, buf, sizeof(buf));
|
||||
for (size_t i = 0; i != N; ++i)
|
||||
c0[i] += 1;
|
||||
for (size_t i = 0; i != N; ++i)
|
||||
cp[i] += 1;
|
||||
for (size_t i = 0; i != N; ++i)
|
||||
cs[i] += 1;
|
||||
#if __cplusplus >= 201103L
|
||||
for (auto ptr = c0; ptr != c0 + N; ++ptr)
|
||||
*ptr += 1;
|
||||
for (auto ptr = c0 + 0; ptr < c0 + N; ++ptr)
|
||||
*ptr += 1;
|
||||
for (auto ptr = cp; ptr != cp + N; ++ptr)
|
||||
*ptr += 1;
|
||||
for (auto ptr = cp + 0; ptr < cp + N; ++ptr)
|
||||
*ptr += 1;
|
||||
for (auto ptr = cs; ptr != cs + N; ++ptr)
|
||||
*ptr += 1;
|
||||
for (auto ptr = cs + 0; ptr < cs + N; ++ptr)
|
||||
*ptr += 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
//
|
||||
**************************************************************************/
|
||||
@@ -658,6 +687,9 @@ TEST_CASE("Span subspan") {
|
||||
CHECK((as + 2).subspan(0, -2)[0] == 0);
|
||||
CHECK_THROWS(as.subspan(1, 0)[0]);
|
||||
CHECK_THROWS(as.subspan(1, 1)[-1]);
|
||||
CHECK(as.subspan(1)[0] == 1);
|
||||
CHECK(as.subspan(2)[0] == 2);
|
||||
CHECK(as.subspan(3)[0] == 3);
|
||||
}
|
||||
|
||||
TEST_CASE("Span constness") {
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../util/system_headers.h"
|
||||
#if WITH_BZIP2
|
||||
#include <bzip2/bzlib.h>
|
||||
#endif
|
||||
#include "../conf.h"
|
||||
|
||||
void bzip2_compress_config_t::reset() noexcept { mem_clear(this); }
|
||||
@@ -31,7 +35,6 @@ void bzip2_compress_config_t::reset() noexcept { mem_clear(this); }
|
||||
#if WITH_BZIP2
|
||||
#include "compress.h"
|
||||
#include "../util/membuffer.h"
|
||||
#include <bzip2/bzlib.h>
|
||||
|
||||
#if defined(BZ_NO_STDIO) || 1
|
||||
// we need to supply bz_internal_error() when building with BZ_NO_STDIO
|
||||
|
||||
@@ -37,9 +37,6 @@
|
||||
#if (ACC_CC_MSC)
|
||||
#pragma warning(disable : 4456) // -Wno-shadow
|
||||
#endif
|
||||
#if (ACC_CC_MSC && (_MSC_VER < 1900))
|
||||
#pragma warning(disable : 4127) // warning C4127: conditional expression is constant
|
||||
#endif
|
||||
|
||||
void lzma_compress_config_t::reset() noexcept {
|
||||
pos_bits.reset();
|
||||
@@ -206,15 +203,12 @@ error:
|
||||
// compress - cruft because of pseudo-COM layer
|
||||
**************************************************************************/
|
||||
|
||||
// ensure proper nullptr usage
|
||||
// TODO later: examine why we need this in the first place
|
||||
#undef NULL
|
||||
// NOLINTBEGIN(clang-analyzer-optin.cplusplus.*)
|
||||
#define NULL nullptr
|
||||
// NOLINTEND(clang-analyzer-optin.cplusplus.*)
|
||||
#if defined(__GNUC__)
|
||||
#undef __null
|
||||
#define __null nullptr
|
||||
#if (ACC_CC_CLANG >= 0x080000)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||
#elif (ACC_CC_GNUC >= 0x040700)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||
#endif
|
||||
|
||||
#undef MSDOS
|
||||
@@ -316,6 +310,12 @@ STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outS
|
||||
#include <lzma-sdk/C/7zip/Compress/RangeCoder/RangeCoderBit.cpp>
|
||||
#undef RC_NORMALIZE
|
||||
|
||||
#if (ACC_CC_CLANG >= 0x080000)
|
||||
#pragma clang diagnostic pop
|
||||
#elif (ACC_CC_GNUC >= 0x040700)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
int upx_lzma_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsigned *dst_len,
|
||||
upx_callback_t *cb, int method, int level,
|
||||
const upx_compress_config_t *cconf_parm, upx_compress_result_t *cresult) {
|
||||
@@ -340,7 +340,8 @@ int upx_lzma_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsi
|
||||
progress.cb = cb; // progress.Init()
|
||||
|
||||
NCompress::NLZMA::CEncoder enc;
|
||||
const PROPID propIDs[8] = {
|
||||
constexpr unsigned NPROPS = 8;
|
||||
static const PROPID propIDs[NPROPS] = {
|
||||
NCoderPropID::kPosStateBits, // 0 pb _posStateBits(2)
|
||||
NCoderPropID::kLitPosBits, // 1 lp _numLiteralPosStateBits(0)
|
||||
NCoderPropID::kLitContextBits, // 2 lc _numLiteralContextBits(3)
|
||||
@@ -350,8 +351,7 @@ int upx_lzma_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsi
|
||||
NCoderPropID::kMatchFinderCycles, // 6 mfc _matchFinderCycles, _cutValue
|
||||
NCoderPropID::kMatchFinder // 7 mf
|
||||
};
|
||||
PROPVARIANT pr[8];
|
||||
const unsigned nprops = 8;
|
||||
PROPVARIANT pr[NPROPS];
|
||||
if (!prepare_result(res, src_len, method, level, lcconf))
|
||||
goto error;
|
||||
pr[0].vt = pr[1].vt = pr[2].vt = pr[3].vt = pr[4].vt = pr[5].vt = pr[6].vt = VT_UI4;
|
||||
@@ -368,7 +368,7 @@ int upx_lzma_compress(const upx_bytep src, unsigned src_len, upx_bytep dst, unsi
|
||||
pr[7].bstrVal = ACC_PCAST(BSTR, ACC_UNCONST_CAST(wchar_t *, matchfinder));
|
||||
|
||||
try {
|
||||
if (enc.SetCoderProperties(propIDs, pr, nprops) != S_OK)
|
||||
if (enc.SetCoderProperties(propIDs, pr, NPROPS) != S_OK)
|
||||
goto error;
|
||||
// encode properties in LZMA-style (5 bytes)
|
||||
if (enc.WriteCoderProperties(&os) != S_OK)
|
||||
|
||||
@@ -24,6 +24,12 @@
|
||||
<markus@oberhumer.com>
|
||||
*/
|
||||
|
||||
#include "../util/system_headers.h"
|
||||
#if WITH_ZSTD
|
||||
#include <zstd/lib/zstd.h>
|
||||
#include <zstd/lib/zstd_errors.h>
|
||||
#include <zstd/lib/compress/hist.h>
|
||||
#endif
|
||||
#include "../conf.h"
|
||||
|
||||
void zstd_compress_config_t::reset() noexcept { mem_clear(this); }
|
||||
@@ -31,9 +37,6 @@ void zstd_compress_config_t::reset() noexcept { mem_clear(this); }
|
||||
#if WITH_ZSTD
|
||||
#include "compress.h"
|
||||
#include "../util/membuffer.h"
|
||||
#include <zstd/lib/zstd.h>
|
||||
#include <zstd/lib/zstd_errors.h>
|
||||
#include <zstd/lib/compress/hist.h>
|
||||
|
||||
static int convert_errno_from_zstd(size_t zr) {
|
||||
const ZSTD_ErrorCode ze = ZSTD_getErrorCode(zr);
|
||||
|
||||
+48
-34
@@ -31,7 +31,7 @@
|
||||
// init
|
||||
**************************************************************************/
|
||||
|
||||
#include "headers.h"
|
||||
#include "util/system_headers.h"
|
||||
#include "version.h"
|
||||
|
||||
#if !defined(__has_attribute)
|
||||
@@ -70,7 +70,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER((char) (-1) == 255)
|
||||
#pragma GCC diagnostic error "-Wsuggest-override"
|
||||
#endif
|
||||
#if (ACC_CC_CLANG >= 0x080000)
|
||||
// don't enable before clang-8 because of stddef.h issues
|
||||
// don't enable before clang-8 because of <stddef.h> issues
|
||||
#pragma clang diagnostic error "-Wzero-as-null-pointer-constant"
|
||||
#elif (ACC_CC_GNUC >= 0x040700) && defined(__GLIBC__)
|
||||
// Some non-GLIBC toolchains do not use 'nullptr' everywhere when C++:
|
||||
@@ -145,15 +145,16 @@ typedef acc_int64_t upx_int64_t;
|
||||
typedef acc_uint64_t upx_uint64_t;
|
||||
typedef acc_uintptr_t upx_uintptr_t;
|
||||
|
||||
// convention: use "byte" when dealing with data; use "char/uchar" when dealing
|
||||
// UPX convention: use "byte" when dealing with data; use "char/uchar" when dealing
|
||||
// with strings; use "upx_uint8_t" when dealing with small integers
|
||||
typedef unsigned char byte;
|
||||
#define upx_byte byte
|
||||
#define upx_bytep byte *
|
||||
typedef unsigned char uchar;
|
||||
// convention: use "charptr" when dealing with abstract pointer arithmetics
|
||||
// UPX convention: use "charptr" when dealing with abstract pointer arithmetics
|
||||
#define charptr upx_charptr_unit_type *
|
||||
// upx_charptr_unit_type is some opaque type with sizeof(type) == 1
|
||||
//// typedef char upx_charptr_unit_type; // also works
|
||||
struct alignas(1) upx_charptr_unit_type final { char hidden__; };
|
||||
ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(upx_charptr_unit_type) == 1)
|
||||
|
||||
@@ -161,7 +162,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(upx_charptr_unit_type) == 1)
|
||||
typedef upx_int64_t upx_off_t;
|
||||
#undef off_t
|
||||
#if 0
|
||||
// TODO cleanup: at some future point we can do this:
|
||||
// TODO later cleanup: at some future point we can do this:
|
||||
#define off_t DO_NOT_USE_off_t
|
||||
#else
|
||||
#define off_t upx_off_t
|
||||
@@ -169,18 +170,30 @@ typedef upx_int64_t upx_off_t;
|
||||
|
||||
// shortcuts
|
||||
#define forceinline __acc_forceinline
|
||||
#if _MSC_VER
|
||||
#if (ACC_CC_MSC)
|
||||
#define noinline __declspec(noinline)
|
||||
#undef __acc_noinline
|
||||
#define __acc_noinline noinline
|
||||
#else
|
||||
#define noinline __acc_noinline
|
||||
#endif
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#define noreturn noinline __attribute__((__noreturn__))
|
||||
#elif (ACC_CC_MSC)
|
||||
// do not use, triggers annoying "warning C4702: unreachable code"
|
||||
////#define noreturn noinline __declspec(noreturn)
|
||||
#define noreturn noinline
|
||||
#else
|
||||
#define noreturn noinline
|
||||
#endif
|
||||
#define forceinline_constexpr forceinline constexpr
|
||||
#define likely __acc_likely
|
||||
#define unlikely __acc_unlikely
|
||||
#define very_likely __acc_very_likely
|
||||
#define very_unlikely __acc_very_unlikely
|
||||
|
||||
// cosmetic: explicitly annotate some functions which may throw exceptions
|
||||
// note that noexcept(false) is the default for all C++ functions anyway
|
||||
#define may_throw noexcept(false)
|
||||
|
||||
#define COMPILE_TIME_ASSERT(e) ACC_COMPILE_TIME_ASSERT(e)
|
||||
@@ -198,6 +211,8 @@ typedef upx_int64_t upx_off_t;
|
||||
#undef dos
|
||||
#undef large
|
||||
#undef linux
|
||||
#undef PAGE_MASK
|
||||
#undef PAGE_SIZE
|
||||
#undef small
|
||||
#undef SP
|
||||
#undef SS
|
||||
@@ -215,11 +230,6 @@ typedef upx_int64_t upx_off_t;
|
||||
#undef sopen
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_DUP) && (HAVE_DUP + 0 == 0)
|
||||
#undef dup
|
||||
#define dup(x) (-1)
|
||||
#endif
|
||||
|
||||
#ifndef STDIN_FILENO
|
||||
#define STDIN_FILENO (fileno(stdin))
|
||||
#endif
|
||||
@@ -286,9 +296,6 @@ typedef upx_int64_t upx_off_t;
|
||||
#define index upx_renamed_index
|
||||
#define outp upx_renamed_outp
|
||||
|
||||
#undef PAGE_MASK
|
||||
#undef PAGE_SIZE
|
||||
|
||||
#if !defined(O_BINARY) || (O_BINARY + 0 == 0)
|
||||
#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)
|
||||
@@ -325,7 +332,7 @@ typedef upx_int64_t upx_off_t;
|
||||
// TODO later: check __MINGW_PRINTF_FORMAT
|
||||
#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)
|
||||
#elif defined(__clang__) || defined(__GNUC__)
|
||||
#define attribute_format(a, b) __attribute__((__format__(__printf__, a, b)))
|
||||
#else
|
||||
#define attribute_format(a, b) /*empty*/
|
||||
@@ -341,15 +348,17 @@ inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
|
||||
#define upx_memcpy_inline __builtin_memcpy_inline
|
||||
#elif __has_builtin(__builtin_memcpy)
|
||||
#define upx_memcpy_inline __builtin_memcpy
|
||||
#elif defined(__GNUC__)
|
||||
#elif defined(__clang__) || defined(__GNUC__)
|
||||
#define upx_memcpy_inline __builtin_memcpy
|
||||
#else
|
||||
#define upx_memcpy_inline memcpy
|
||||
#endif
|
||||
|
||||
#if __has_builtin(__builtin_return_address)
|
||||
#if defined(__wasi__)
|
||||
#define upx_return_address() nullptr
|
||||
#elif __has_builtin(__builtin_return_address)
|
||||
#define upx_return_address() __builtin_return_address(0)
|
||||
#elif defined(__GNUC__)
|
||||
#elif defined(__clang__) || defined(__GNUC__)
|
||||
#define upx_return_address() __builtin_return_address(0)
|
||||
#elif (ACC_CC_MSC)
|
||||
#define upx_return_address() _ReturnAddress()
|
||||
@@ -357,9 +366,11 @@ inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
|
||||
#define upx_return_address() nullptr
|
||||
#endif
|
||||
|
||||
// TODO cleanup: we now require C++17, so remove all packed_struct usage
|
||||
// TODO later cleanup: we now require C++17, so remove all packed_struct usage
|
||||
#define packed_struct(s) struct alignas(1) s
|
||||
|
||||
// TODO later cleanup: this was needed in the old days to catch compiler problems/bugs;
|
||||
// we now require C++17, so remove this
|
||||
#define COMPILE_TIME_ASSERT_ALIGNOF_USING_SIZEOF__(a, b) \
|
||||
{ \
|
||||
typedef a acc_tmp_a_t; \
|
||||
@@ -383,6 +394,7 @@ inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
|
||||
|
||||
#define TABLESIZE(table) ((sizeof(table) / sizeof((table)[0])))
|
||||
|
||||
// TODO later: move these to upx namespace in util/cxxlib.h; also see bele.h
|
||||
template <class T>
|
||||
inline T ALIGN_DOWN(const T &a, const T &b) {
|
||||
T r;
|
||||
@@ -424,6 +436,7 @@ inline void mem_clear(T *object) noexcept {
|
||||
static_assert(size >= 1 && size <= UPX_RSIZE_MAX_MEM);
|
||||
memset((void *) object, 0, size);
|
||||
}
|
||||
// disable some overloads
|
||||
#if defined(__clang__) || __GNUC__ != 7
|
||||
template <class T>
|
||||
inline void mem_clear(T (&array)[]) noexcept DELETED_FUNCTION;
|
||||
@@ -440,12 +453,12 @@ inline void mem_clear(T (&array)[N]) noexcept DELETED_FUNCTION;
|
||||
#define ByteArray(var, n) Array(byte, var, (n))
|
||||
|
||||
// assert_noexcept()
|
||||
noinline void assertFailed(const char *expr, const char *file, int line, const char *func) noexcept;
|
||||
noinline void throwAssertFailed(const char *expr, const char *file, int line, const char *func);
|
||||
#if defined(__GNUC__)
|
||||
noreturn void assertFailed(const char *expr, const char *file, int line, const char *func) noexcept;
|
||||
noreturn void throwAssertFailed(const char *expr, const char *file, int line, const char *func);
|
||||
#if defined(__clang__) || defined(__GNUC__)
|
||||
#undef assert
|
||||
#if DEBUG || 0
|
||||
// generate a warning if assert() is used inside a "noexcept" context
|
||||
// trigger a warning if assert() is used inside a "noexcept" context
|
||||
#define assert(e) \
|
||||
((void) (__acc_cte(e) || (assertFailed(#e, __FILE__, __LINE__, __func__), throw 1, 0)))
|
||||
#else
|
||||
@@ -459,6 +472,7 @@ noinline void throwAssertFailed(const char *expr, const char *file, int line, co
|
||||
#define assert_noexcept assert
|
||||
#endif
|
||||
|
||||
// C++ support library
|
||||
#include "util/cxxlib.h"
|
||||
using upx::is_same_any_v;
|
||||
using upx::noncopyable;
|
||||
@@ -575,9 +589,9 @@ using upx::tribool;
|
||||
// #define M_CL1B_8 12
|
||||
// #define M_CL1B_LE16 13
|
||||
#define M_LZMA 14
|
||||
#define M_DEFLATE 15 // zlib
|
||||
#define M_ZSTD 16
|
||||
#define M_BZIP2 17
|
||||
#define M_DEFLATE 15 // NOT YET USED
|
||||
#define M_ZSTD 16 // NOT YET USED
|
||||
#define M_BZIP2 17 // NOT YET USED
|
||||
// compression methods internal usage
|
||||
#define M_ALL (-1)
|
||||
#define M_END (-2)
|
||||
@@ -693,7 +707,7 @@ struct upx_compress_config_t final {
|
||||
}
|
||||
};
|
||||
|
||||
#define NULL_cconf ((upx_compress_config_t *) nullptr)
|
||||
#define NULL_cconf ((const upx_compress_config_t *) nullptr)
|
||||
|
||||
/*************************************************************************
|
||||
// compression - result_t
|
||||
@@ -767,19 +781,19 @@ struct upx_compress_result_t final {
|
||||
|
||||
// classes
|
||||
class ElfLinker;
|
||||
typedef ElfLinker Linker;
|
||||
typedef ElfLinker Linker; // shortcut
|
||||
class Throwable;
|
||||
|
||||
// check/dt_check.cpp
|
||||
noinline void upx_compiler_sanity_check() noexcept;
|
||||
noinline int upx_doctest_check(int argc, char **argv);
|
||||
int upx_doctest_check();
|
||||
|
||||
// util/membuffer.h
|
||||
class MemBuffer;
|
||||
void *membuffer_get_void_ptr(MemBuffer &mb) noexcept;
|
||||
unsigned membuffer_get_size(MemBuffer &mb) noexcept;
|
||||
|
||||
// util/dt_check.cpp
|
||||
noinline void upx_compiler_sanity_check() noexcept;
|
||||
noinline int upx_doctest_check(int argc, char **argv);
|
||||
int upx_doctest_check();
|
||||
|
||||
// main.cpp
|
||||
extern const char *progname;
|
||||
bool main_set_exit_code(int ec);
|
||||
@@ -808,7 +822,7 @@ int do_files(int i, int argc, char *argv[]) may_throw;
|
||||
// help.cpp
|
||||
extern const char gitrev[];
|
||||
void show_header();
|
||||
void show_help(int verbose = 0);
|
||||
void show_help(int verbose);
|
||||
void show_license();
|
||||
void show_sysinfo(const char *options_var);
|
||||
void show_usage();
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
#define WANT_WINDOWS_LEAN_H 1
|
||||
#include "../util/system_headers.h"
|
||||
#if (HAVE_CONIO_H)
|
||||
#include <conio.h>
|
||||
#endif
|
||||
#include "../conf.h"
|
||||
|
||||
#if (USE_SCREEN_WIN32)
|
||||
@@ -33,11 +38,6 @@
|
||||
// direct screen access
|
||||
**************************************************************************/
|
||||
|
||||
#include "../util/windows_lean.h"
|
||||
#if (HAVE_CONIO_H)
|
||||
#include <conio.h>
|
||||
#endif
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
#define this self
|
||||
|
||||
+21
-19
@@ -31,39 +31,41 @@
|
||||
//
|
||||
**************************************************************************/
|
||||
|
||||
/*static*/ upx_std_atomic(size_t) Throwable::debug_counter;
|
||||
/*static*/ Throwable::Stats Throwable::stats;
|
||||
|
||||
Throwable::Throwable(const char *m, int e, bool w) noexcept : super(),
|
||||
msg(nullptr),
|
||||
err(e),
|
||||
is_warning(w) {
|
||||
if (m)
|
||||
if (m != nullptr) {
|
||||
msg = strdup(m);
|
||||
#if 0
|
||||
fprintf(stderr, "construct exception: %s %zu\n", msg, debug_counter);
|
||||
debug_counter += 1;
|
||||
#endif
|
||||
assert_noexcept(msg != nullptr);
|
||||
}
|
||||
NO_fprintf(stderr, "construct exception: %zu %zu %s\n", size_t(stats.counter_current),
|
||||
size_t(stats.counter_total), (const char *) msg);
|
||||
stats.counter_current += 1;
|
||||
stats.counter_total += 1;
|
||||
}
|
||||
|
||||
Throwable::Throwable(const Throwable &other) noexcept : super(other),
|
||||
msg(nullptr),
|
||||
err(other.err),
|
||||
is_warning(other.is_warning) {
|
||||
if (other.msg)
|
||||
if (other.msg != nullptr) {
|
||||
msg = strdup(other.msg);
|
||||
#if 0
|
||||
fprintf(stderr, "copy exception: %s %zu\n", msg, debug_counter);
|
||||
debug_counter += 1;
|
||||
#endif
|
||||
assert_noexcept(msg != nullptr);
|
||||
}
|
||||
NO_fprintf(stderr, "copy construct exception: %zu %zu %s\n", size_t(stats.counter_current),
|
||||
size_t(stats.counter_total), (const char *) msg);
|
||||
stats.counter_current += 1;
|
||||
stats.counter_total += 1;
|
||||
}
|
||||
|
||||
Throwable::~Throwable() noexcept {
|
||||
#if 0
|
||||
debug_counter -= 1;
|
||||
fprintf(stderr, "destruct exception: %s %zu\n", msg, debug_counter);
|
||||
#endif
|
||||
if (msg)
|
||||
free(msg);
|
||||
stats.counter_current -= 1;
|
||||
NO_fprintf(stderr, "destruct exception: %zu %zu %s\n", size_t(stats.counter_current),
|
||||
size_t(stats.counter_total), (const char *) msg);
|
||||
upx::owner_free(msg);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -193,7 +195,7 @@ void throwAssertFailed(const char *expr, const char *file, int line, const char
|
||||
}
|
||||
}
|
||||
|
||||
const char *prettyName(const char *n) noexcept {
|
||||
const char *prettyExceptionName(const char *n) noexcept {
|
||||
if (n == nullptr)
|
||||
return "(null)";
|
||||
while (*n) {
|
||||
@@ -201,7 +203,7 @@ const char *prettyName(const char *n) noexcept {
|
||||
n++;
|
||||
else if (*n == ' ')
|
||||
n++;
|
||||
else if (strncmp(n, "class ", 6) == 0) // Visual C++ (msvc)
|
||||
else if (strncmp(n, "class ", 6) == 0) // Visual C++ (MSVC)
|
||||
n += 6;
|
||||
else
|
||||
break;
|
||||
|
||||
+28
-35
@@ -27,11 +27,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
const char *prettyName(const char *n) noexcept;
|
||||
|
||||
noinline void assertFailed(const char *expr, const char *file, int line, const char *func) noexcept;
|
||||
noinline void throwAssertFailed(const char *expr, const char *file, int line, const char *func);
|
||||
|
||||
/*************************************************************************
|
||||
// exceptions
|
||||
**************************************************************************/
|
||||
@@ -50,7 +45,7 @@ public:
|
||||
bool isWarning() const noexcept { return is_warning; }
|
||||
|
||||
private:
|
||||
char *msg = nullptr;
|
||||
OwningPointer(char) msg = nullptr;
|
||||
int err = 0;
|
||||
protected:
|
||||
bool is_warning = false; // can be set by subclasses
|
||||
@@ -66,7 +61,12 @@ private:
|
||||
UPX_CXX_DISABLE_ADDRESS(Throwable)
|
||||
|
||||
private:
|
||||
static upx_std_atomic(size_t) debug_counter; // for debugging
|
||||
// static debug stats
|
||||
struct Stats {
|
||||
upx_std_atomic(size_t) counter_total;
|
||||
upx_std_atomic(size_t) counter_current;
|
||||
};
|
||||
static Stats stats;
|
||||
};
|
||||
|
||||
// Exceptions can/should be caught
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
// system exception
|
||||
// system exceptions
|
||||
**************************************************************************/
|
||||
|
||||
class OutOfMemoryException final : public Exception {
|
||||
@@ -178,44 +178,37 @@ public:
|
||||
// util
|
||||
**************************************************************************/
|
||||
|
||||
#undef NORET
|
||||
#if 1 && defined(__GNUC__)
|
||||
#define NORET noinline __attribute__((__noreturn__))
|
||||
#else
|
||||
#define NORET noinline
|
||||
#endif
|
||||
const char *prettyExceptionName(const char *n) noexcept;
|
||||
|
||||
NORET void throwCantPack(const char *msg) may_throw;
|
||||
NORET void throwCantPackExact() may_throw;
|
||||
NORET void throwUnknownExecutableFormat(const char *msg = nullptr, bool warn = false) may_throw;
|
||||
NORET void throwNotCompressible(const char *msg = nullptr) may_throw;
|
||||
NORET void throwAlreadyPacked(const char *msg = nullptr) may_throw;
|
||||
NORET void throwAlreadyPackedByUPX(const char *msg = nullptr) may_throw;
|
||||
NORET void throwCantUnpack(const char *msg) may_throw;
|
||||
NORET void throwNotPacked(const char *msg = nullptr) may_throw;
|
||||
NORET void throwFilterException() may_throw;
|
||||
NORET void throwBadLoader() may_throw;
|
||||
NORET void throwChecksumError() may_throw;
|
||||
NORET void throwCompressedDataViolation() may_throw;
|
||||
NORET void throwInternalError(const char *msg) may_throw;
|
||||
NORET void throwOutOfMemoryException(const char *msg = nullptr) may_throw;
|
||||
NORET void throwIOException(const char *msg = nullptr, int e = 0) may_throw;
|
||||
NORET void throwEOFException(const char *msg = nullptr, int e = 0) may_throw;
|
||||
noreturn void throwCantPack(const char *msg) may_throw;
|
||||
noreturn void throwCantPackExact() may_throw;
|
||||
noreturn void throwUnknownExecutableFormat(const char *msg = nullptr, bool warn = false) may_throw;
|
||||
noreturn void throwNotCompressible(const char *msg = nullptr) may_throw;
|
||||
noreturn void throwAlreadyPacked(const char *msg = nullptr) may_throw;
|
||||
noreturn void throwAlreadyPackedByUPX(const char *msg = nullptr) may_throw;
|
||||
noreturn void throwCantUnpack(const char *msg) may_throw;
|
||||
noreturn void throwNotPacked(const char *msg = nullptr) may_throw;
|
||||
noreturn void throwFilterException() may_throw;
|
||||
noreturn void throwBadLoader() may_throw;
|
||||
noreturn void throwChecksumError() may_throw;
|
||||
noreturn void throwCompressedDataViolation() may_throw;
|
||||
noreturn void throwInternalError(const char *msg) may_throw;
|
||||
noreturn void throwOutOfMemoryException(const char *msg = nullptr) may_throw;
|
||||
noreturn void throwIOException(const char *msg = nullptr, int e = 0) may_throw;
|
||||
noreturn void throwEOFException(const char *msg = nullptr, int e = 0) may_throw;
|
||||
|
||||
// some C++ template wizardry is needed to overload throwCantPack() for varargs
|
||||
template <class T>
|
||||
void throwCantPack(const T *, ...) DELETED_FUNCTION;
|
||||
template <>
|
||||
NORET void throwCantPack(const char *format, ...) may_throw attribute_format(1, 2);
|
||||
noreturn void throwCantPack(const char *format, ...) may_throw attribute_format(1, 2);
|
||||
template <class T>
|
||||
void throwCantUnpack(const T *, ...) DELETED_FUNCTION;
|
||||
template <>
|
||||
NORET void throwCantUnpack(const char *format, ...) may_throw attribute_format(1, 2);
|
||||
noreturn void throwCantUnpack(const char *format, ...) may_throw attribute_format(1, 2);
|
||||
template <class T>
|
||||
void throwInternalError(const T *, ...) DELETED_FUNCTION;
|
||||
template <>
|
||||
NORET void throwInternalError(const char *format, ...) may_throw attribute_format(1, 2);
|
||||
|
||||
#undef NORET
|
||||
noreturn void throwInternalError(const char *format, ...) may_throw attribute_format(1, 2);
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+18
-1
@@ -40,6 +40,7 @@
|
||||
#else
|
||||
UNUSED(name);
|
||||
UNUSED(mode);
|
||||
// no error
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ bool FileBase::do_sopen() {
|
||||
else {
|
||||
#if (ACC_OS_DOS32) && defined(__DJGPP__)
|
||||
_fd = ::open(_name, _flags | _shflags, _mode);
|
||||
#elif defined(__MINT__)
|
||||
#elif (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__)
|
||||
_fd = ::open(_name, _flags | (_shflags & O_SHMODE), _mode);
|
||||
#elif defined(SH_DENYRW)
|
||||
_fd = ::sopen(_name, _flags, _shflags, _mode);
|
||||
@@ -98,6 +99,7 @@ bool FileBase::do_sopen() {
|
||||
}
|
||||
if (_fd < 0)
|
||||
return false;
|
||||
st.st_size = 0;
|
||||
if (::fstat(_fd, &st) != 0)
|
||||
throwIOException(_name, errno);
|
||||
_length = st.st_size;
|
||||
@@ -212,6 +214,20 @@ upx_off_t InputFile::seek(upx_off_t off, int whence) {
|
||||
|
||||
upx_off_t InputFile::st_size_orig() const { return _length_orig; }
|
||||
|
||||
int InputFile::dupFd() may_throw {
|
||||
if (!isOpen())
|
||||
throwIOException("bad dup");
|
||||
#if defined(HAVE_DUP) && (HAVE_DUP + 0 == 0)
|
||||
errno = ENOSYS;
|
||||
int r = -1;
|
||||
#else
|
||||
int r = ::dup(getFd());
|
||||
#endif
|
||||
if (r < 0)
|
||||
throwIOException("dup", errno);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
// OutputFile
|
||||
**************************************************************************/
|
||||
@@ -333,6 +349,7 @@ void OutputFile::set_extent(upx_off_t offset, upx_off_t length) {
|
||||
super::set_extent(offset, length);
|
||||
bytes_written = 0;
|
||||
if (0 == offset && 0xffffffffLL == length) { // TODO: check all callers of this method
|
||||
st.st_size = 0;
|
||||
if (::fstat(_fd, &st) != 0)
|
||||
throwIOException(_name, errno);
|
||||
_length = st.st_size - offset;
|
||||
|
||||
@@ -88,6 +88,8 @@ public:
|
||||
virtual upx_off_t seek(upx_off_t off, int whence) override;
|
||||
upx_off_t st_size_orig() const;
|
||||
|
||||
noinline int dupFd() may_throw;
|
||||
|
||||
protected:
|
||||
upx_off_t _length_orig = 0;
|
||||
};
|
||||
|
||||
+86
-25
@@ -25,10 +25,16 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
#if defined(_WIN32_WINNT)
|
||||
static constexpr long long initial_win32_winnt = _WIN32_WINNT + 0LL;
|
||||
#else
|
||||
static constexpr long long initial_win32_winnt = 0;
|
||||
#endif
|
||||
#define WANT_WINDOWS_LEAN_H 1 // _WIN32_WINNT
|
||||
#include "conf.h"
|
||||
#include "compress/compress.h" // upx_ucl_version_string()
|
||||
// for list_all_packers():
|
||||
#include "filter.h" // Filter::isValidFilter
|
||||
#include "packer.h"
|
||||
#include "packmast.h" // PackMaster::visitAllPackers
|
||||
|
||||
@@ -95,47 +101,84 @@ void show_usage(void) {
|
||||
**************************************************************************/
|
||||
|
||||
namespace {
|
||||
struct PackerNames {
|
||||
struct PackerNames final {
|
||||
explicit PackerNames() noexcept = default;
|
||||
~PackerNames() noexcept = default;
|
||||
|
||||
static constexpr unsigned MAX_NAMES = 64; // arbitrary limit, increase as needed
|
||||
struct Entry {
|
||||
const char *fname;
|
||||
const char *sname;
|
||||
unsigned methods_count;
|
||||
unsigned filters_count;
|
||||
unsigned methods[PackerBase::MAX_METHODS];
|
||||
unsigned filters[PackerBase::MAX_FILTERS];
|
||||
};
|
||||
Entry names[64];
|
||||
size_t names_count;
|
||||
const Options *o;
|
||||
PackerNames() : names_count(0), o(nullptr) {}
|
||||
Entry names[MAX_NAMES];
|
||||
unsigned names_count = 0;
|
||||
const Options *o = nullptr;
|
||||
|
||||
void add(const PackerBase *pb) {
|
||||
assert_noexcept(names_count < 64);
|
||||
names[names_count].fname = pb->getFullName(o);
|
||||
names[names_count].sname = pb->getName();
|
||||
names_count++;
|
||||
assert_noexcept(names_count < MAX_NAMES);
|
||||
Entry &e = names[names_count++];
|
||||
e.fname = pb->getFullName(o);
|
||||
e.sname = pb->getName();
|
||||
e.methods_count = e.filters_count = 0;
|
||||
for (const int *m = pb->getCompressionMethods(M_ALL, 10); *m != M_END; m++) {
|
||||
if (*m >= 0) {
|
||||
assert_noexcept(Packer::isValidCompressionMethod(*m));
|
||||
assert_noexcept(e.methods_count < PackerBase::MAX_METHODS);
|
||||
e.methods[e.methods_count++] = *m;
|
||||
}
|
||||
}
|
||||
for (const int *f = pb->getFilters(); f != nullptr && *f != FT_END; f++) {
|
||||
if (*f >= 0) {
|
||||
assert_noexcept(Filter::isValidFilter(*f));
|
||||
assert_noexcept(e.filters_count < PackerBase::MAX_FILTERS);
|
||||
e.filters[e.filters_count++] = *f;
|
||||
}
|
||||
}
|
||||
upx_gnomesort(e.methods, e.methods_count, sizeof(e.methods[0]), ne32_compare);
|
||||
upx_gnomesort(e.filters, e.filters_count, sizeof(e.filters[0]), ne32_compare);
|
||||
}
|
||||
static tribool visit(PackerBase *pb, void *user) {
|
||||
NO_fprintf(stderr, "visit %s\n", pb->getFullName(nullptr));
|
||||
PackerNames *self = (PackerNames *) user;
|
||||
self->add(pb);
|
||||
return false;
|
||||
}
|
||||
static int __acc_cdecl_qsort cmp_fname(const void *a, const void *b) {
|
||||
static int __acc_cdecl_qsort compare_fname(const void *a, const void *b) {
|
||||
return strcmp(((const Entry *) a)->fname, ((const Entry *) b)->fname);
|
||||
}
|
||||
static int __acc_cdecl_qsort cmp_sname(const void *a, const void *b) {
|
||||
static int __acc_cdecl_qsort compare_sname(const void *a, const void *b) {
|
||||
return strcmp(((const Entry *) a)->sname, ((const Entry *) b)->sname);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
static void list_all_packers(FILE *f, int verbose) {
|
||||
static noinline void list_all_packers(FILE *f, int verbose) {
|
||||
Options o;
|
||||
o.reset();
|
||||
PackerNames pn;
|
||||
pn.o = &o;
|
||||
(void) PackMaster::visitAllPackers(PackerNames::visit, nullptr, &o, &pn);
|
||||
upx_qsort(pn.names, pn.names_count, sizeof(PackerNames::Entry), PackerNames::cmp_fname);
|
||||
upx_gnomesort(pn.names, pn.names_count, sizeof(PackerNames::Entry), PackerNames::compare_fname);
|
||||
size_t pos = 0;
|
||||
for (size_t i = 0; i < pn.names_count; ++i) {
|
||||
const char *fn = pn.names[i].fname;
|
||||
const char *sn = pn.names[i].sname;
|
||||
if (verbose > 0) {
|
||||
for (size_t i = 0; i < pn.names_count; i++) {
|
||||
const PackerNames::Entry &e = pn.names[i];
|
||||
const char *const fn = e.fname;
|
||||
const char *const sn = e.sname;
|
||||
if (verbose >= 3) {
|
||||
con_fprintf(f, " %-36s %s\n", fn, sn);
|
||||
con_fprintf(f, " methods:");
|
||||
for (size_t j = 0; j < e.methods_count; j++)
|
||||
con_fprintf(f, " %#x", e.methods[j]);
|
||||
con_fprintf(f, "\n");
|
||||
con_fprintf(f, " filters:");
|
||||
for (size_t j = 0; j < e.filters_count; j++)
|
||||
con_fprintf(f, " %#x", e.filters[j]);
|
||||
con_fprintf(f, "\n");
|
||||
} else if (verbose >= 2) {
|
||||
con_fprintf(f, " %-36s %s\n", fn, sn);
|
||||
} else {
|
||||
size_t fl = strlen(fn);
|
||||
@@ -151,7 +194,7 @@ static void list_all_packers(FILE *f, int verbose) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (verbose <= 0 && pn.names_count)
|
||||
if (verbose < 2 && pn.names_count)
|
||||
con_fprintf(f, "\n");
|
||||
}
|
||||
|
||||
@@ -423,25 +466,28 @@ void show_version(bool one_line) {
|
||||
fprintf(f, "Copyright (C) 1996-2024 Markus Franz Xaver Johannes Oberhumer\n");
|
||||
fprintf(f, "Copyright (C) 1996-2024 Laszlo Molnar\n");
|
||||
fprintf(f, "Copyright (C) 2000-2024 John F. Reiser\n");
|
||||
fprintf(f, "Copyright (C) 2002-2024 Jens Medoch\n");
|
||||
#if (WITH_ZLIB)
|
||||
fprintf(f, "Copyright (C) 1995" "-2023 Jean-loup Gailly and Mark Adler\n");
|
||||
// see vendor/zlib/LICENSE
|
||||
fprintf(f, "Copyright (C) 1995" "-2024 Jean-loup Gailly and Mark Adler\n");
|
||||
#endif
|
||||
#if (WITH_LZMA)
|
||||
// see vendor/lzma-sdk/lzma.txt
|
||||
fprintf(f, "Copyright (C) 1999" "-2006 Igor Pavlov\n");
|
||||
#endif
|
||||
#if (WITH_ZSTD)
|
||||
// see vendor/zstd/LICENSE; main author is Yann Collet
|
||||
fprintf(f, "Copyright (C) 2015" "-2023 Meta Platforms, Inc. and affiliates\n");
|
||||
fprintf(f, "Copyright (C) 2015" "-2024 Meta Platforms, Inc. and affiliates\n");
|
||||
#endif
|
||||
#if (WITH_BZIP2)
|
||||
fprintf(f, "Copyright (C) 1996" "-2010 Julian Seward\n"); // see <bzlib.h>
|
||||
// see vendor/bzip2/bzlib.h
|
||||
fprintf(f, "Copyright (C) 1996" "-2010 Julian Seward\n");
|
||||
#endif
|
||||
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||
// see vendor/doctest/LICENSE.txt
|
||||
fprintf(f, "Copyright (C) 2016" "-2023 Viktor Kirilov\n");
|
||||
#endif
|
||||
fprintf(f, "UPX comes with ABSOLUTELY NO WARRANTY; for details type '%s -L'.\n", progname);
|
||||
// clang-format on
|
||||
fprintf(f, "UPX comes with ABSOLUTELY NO WARRANTY; for details type '%s -L'.\n", progname);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -496,11 +542,20 @@ void show_sysinfo(const char *options_var) {
|
||||
#if defined(__clang_major__)
|
||||
cf_print("__clang_major__", "%lld", __clang_major__ + 0);
|
||||
#endif
|
||||
#if defined(__clang_minor__)
|
||||
cf_print("__clang_minor__", "%lld", __clang_minor__ + 0, 3);
|
||||
#endif
|
||||
#if defined(__clang_patchlevel__)
|
||||
cf_print("__clang_patchlevel__", "%lld", __clang_patchlevel__ + 0, 3);
|
||||
#endif
|
||||
#if defined(__GNUC__)
|
||||
cf_print("__GNUC__", "%lld", __GNUC__ + 0);
|
||||
#endif
|
||||
#if defined(__GNUC_MINOR__)
|
||||
cf_print("__GNUC_MINOR__", "%lld", __GNUC_MINOR__ + 0);
|
||||
cf_print("__GNUC_MINOR__", "%lld", __GNUC_MINOR__ + 0, 3);
|
||||
#endif
|
||||
#if defined(__GNUC_PATCHLEVEL__)
|
||||
cf_print("__GNUC_PATCHLEVEL__", "%lld", __GNUC_PATCHLEVEL__ + 0, 3);
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
cf_print("_MSC_VER", "%lld", _MSC_VER + 0);
|
||||
@@ -514,6 +569,8 @@ void show_sysinfo(const char *options_var) {
|
||||
#endif
|
||||
#if defined(_WIN32_WINNT)
|
||||
cf_print("_WIN32_WINNT", "0x%04llx", _WIN32_WINNT + 0);
|
||||
if (initial_win32_winnt != 0 && initial_win32_winnt != _WIN32_WINNT + 0)
|
||||
cf_print("INITIAL_WIN32_WINNT", "0x%04llx", initial_win32_winnt);
|
||||
#endif
|
||||
#if defined(__MSVCRT_VERSION__)
|
||||
cf_print("__MSVCRT_VERSION__", "0x%04llx", __MSVCRT_VERSION__ + 0);
|
||||
@@ -524,6 +581,9 @@ void show_sysinfo(const char *options_var) {
|
||||
#if defined(__USE_MINGW_ANSI_STDIO)
|
||||
cf_print("__USE_MINGW_ANSI_STDIO", "%lld", __USE_MINGW_ANSI_STDIO + 0, 3);
|
||||
#endif
|
||||
#if defined(__ELF__)
|
||||
cf_print("__ELF__", "%lld", __ELF__ + 0, 3);
|
||||
#endif
|
||||
#if defined(__GLIBC__)
|
||||
cf_print("__GLIBC__", "%lld", __GLIBC__ + 0);
|
||||
#endif
|
||||
@@ -542,6 +602,7 @@ void show_sysinfo(const char *options_var) {
|
||||
#endif
|
||||
UNUSED(cf_count);
|
||||
UNUSED(cf_print);
|
||||
UNUSED(initial_win32_winnt);
|
||||
}
|
||||
|
||||
// run-time
|
||||
@@ -564,7 +625,7 @@ void show_sysinfo(const char *options_var) {
|
||||
#endif
|
||||
|
||||
if (options_var && options_var[0]) {
|
||||
const char *e = getenv(options_var);
|
||||
const char *e = upx_getenv(options_var);
|
||||
con_fprintf(f, "\n");
|
||||
if (e && e[0])
|
||||
con_fprintf(f, "Contents of environment variable %s: '%s'\n\n", options_var, e);
|
||||
|
||||
+8
-7
@@ -144,7 +144,7 @@ unsigned LeFile::getImageSize() const {
|
||||
}
|
||||
|
||||
void LeFile::readImage() {
|
||||
soimage = pages * mps;
|
||||
soimage = mem_size(mps, pages); // assert size
|
||||
if (!soimage) // late detection, but protect against .alloc(0)
|
||||
throwCantPack("no soimage");
|
||||
mb_iimage.alloc(soimage);
|
||||
@@ -157,7 +157,7 @@ void LeFile::readImage() {
|
||||
fif->seek(ih.data_pages_offset + exe_offset +
|
||||
(ipm_entries[ic].m * 0x100 + ipm_entries[ic].l - 1) * mps,
|
||||
SEEK_SET);
|
||||
auto bytes = ic != pages - 1 ? mps : ih.bytes_on_last_page;
|
||||
unsigned bytes = ic != pages - 1 ? mps : ih.bytes_on_last_page;
|
||||
fif->readx(iimage + jc, bytes);
|
||||
}
|
||||
jc += mps;
|
||||
@@ -184,7 +184,7 @@ void LeFile::writeNonResidentNames() {
|
||||
}
|
||||
|
||||
bool LeFile::readFileHeader() {
|
||||
#define H(x) get_le16(header + 2 * (x))
|
||||
#define H(x) get_le16(header + (2 * (x)))
|
||||
byte header[0x40];
|
||||
le_offset = exe_offset = 0;
|
||||
int ic;
|
||||
@@ -208,7 +208,7 @@ bool LeFile::readFileHeader() {
|
||||
} else if (memcmp(header, "BW", 2) == 0) // used in dos4gw.exe
|
||||
le_offset += H(2) * 512 + H(1);
|
||||
else if (memcmp(header, "LE", 2) == 0)
|
||||
break;
|
||||
break; // success
|
||||
else if (memcmp(header, "PMW1", 4) == 0)
|
||||
throwCantPack("already packed with PMWLITE");
|
||||
else
|
||||
@@ -219,10 +219,11 @@ bool LeFile::readFileHeader() {
|
||||
fif->seek(le_offset, SEEK_SET);
|
||||
fif->readx(&ih, sizeof(ih));
|
||||
if (mps < 512 || mps > 2097152 || (mps & (mps - 1)) != 0)
|
||||
throwCantPack("file header invalid page size");
|
||||
throwCantPack("LE file header invalid page size %u", (unsigned) mps);
|
||||
if (ih.bytes_on_last_page > mps || pages == 0)
|
||||
throwCantPack("bad file header");
|
||||
(void) mem_size(mps, pages); // assert size
|
||||
throwCantPack("bad LE file header");
|
||||
if (!mem_size_valid(mps, pages) || exe_offset > le_offset)
|
||||
throwCantPack("bad LE file header");
|
||||
return true;
|
||||
#undef H
|
||||
}
|
||||
|
||||
+2
-6
@@ -190,8 +190,7 @@ protected:
|
||||
unsigned le_offset = 0;
|
||||
unsigned exe_offset = 0;
|
||||
|
||||
le_header_t ih;
|
||||
le_header_t oh;
|
||||
le_header_t ih = {}, oh = {};
|
||||
|
||||
le_object_table_entry_t *iobject_table = nullptr;
|
||||
le_object_table_entry_t *oobject_table = nullptr;
|
||||
@@ -223,10 +222,7 @@ protected:
|
||||
|
||||
private:
|
||||
// disable copy and move
|
||||
LeFile(const LeFile &) DELETED_FUNCTION;
|
||||
LeFile &operator=(const LeFile &) DELETED_FUNCTION;
|
||||
LeFile(LeFile &&) noexcept DELETED_FUNCTION;
|
||||
LeFile &operator=(LeFile &&) noexcept DELETED_FUNCTION;
|
||||
UPX_CXX_DISABLE_COPY_MOVE(LeFile)
|
||||
};
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+107
-89
@@ -30,7 +30,7 @@
|
||||
|
||||
static unsigned hex(uchar c) { return (c & 0xf) + (c > '9' ? 9 : 0); }
|
||||
|
||||
static bool update_capacity(unsigned size, unsigned *capacity) {
|
||||
static bool grow_capacity(unsigned size, unsigned *capacity) {
|
||||
if (size < *capacity)
|
||||
return false;
|
||||
if (*capacity == 0)
|
||||
@@ -40,16 +40,22 @@ static bool update_capacity(unsigned size, unsigned *capacity) {
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
template <class T>
|
||||
static T **realloc_array(T **array, size_t capacity) may_throw {
|
||||
assert_noexcept(capacity > 0);
|
||||
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
|
||||
void *p = realloc(array, mem_size(sizeof(T *), capacity));
|
||||
assert_noexcept(p != nullptr);
|
||||
return static_cast<T **>(p);
|
||||
}
|
||||
|
||||
va_start(ap, format);
|
||||
upx_safe_vsnprintf(buf, sizeof(buf), format, ap);
|
||||
va_end(ap);
|
||||
|
||||
throwInternalError(buf);
|
||||
template <class T>
|
||||
static void free_array(T **array, size_t count) noexcept {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
T *item = upx::atomic_exchange(&array[i], (T *) nullptr);
|
||||
delete item;
|
||||
}
|
||||
::free(array); // NOLINT(bugprone-multi-level-implicit-pointer-conversion)
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -59,19 +65,19 @@ static void internal_error(const char *format, ...) {
|
||||
ElfLinker::Section::Section(const char *n, const void *i, unsigned s, unsigned a)
|
||||
: name(nullptr), output(nullptr), size(s), offset(0), p2align(a), next(nullptr) {
|
||||
name = strdup(n);
|
||||
assert(name != nullptr);
|
||||
input = malloc(s + 1);
|
||||
assert(input != nullptr);
|
||||
assert_noexcept(name != nullptr);
|
||||
input = ::malloc(s + 1);
|
||||
assert_noexcept(input != nullptr);
|
||||
if (s != 0) {
|
||||
assert(i != nullptr);
|
||||
assert_noexcept(i != nullptr);
|
||||
memcpy(input, i, s);
|
||||
}
|
||||
((char *) input)[s] = 0;
|
||||
}
|
||||
|
||||
ElfLinker::Section::~Section() noexcept {
|
||||
free(name);
|
||||
free(input);
|
||||
::free(name);
|
||||
::free(input);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -81,11 +87,11 @@ ElfLinker::Section::~Section() noexcept {
|
||||
ElfLinker::Symbol::Symbol(const char *n, Section *s, upx_uint64_t o)
|
||||
: name(nullptr), section(s), offset(o) {
|
||||
name = strdup(n);
|
||||
assert(name != nullptr);
|
||||
assert(section != nullptr);
|
||||
assert_noexcept(name != nullptr);
|
||||
assert_noexcept(section != nullptr);
|
||||
}
|
||||
|
||||
ElfLinker::Symbol::~Symbol() noexcept { free(name); }
|
||||
ElfLinker::Symbol::~Symbol() noexcept { ::free(name); }
|
||||
|
||||
/*************************************************************************
|
||||
// Relocation
|
||||
@@ -94,7 +100,7 @@ ElfLinker::Symbol::~Symbol() noexcept { 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 != nullptr);
|
||||
assert_noexcept(section != nullptr);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -106,17 +112,9 @@ ElfLinker::ElfLinker(const N_BELE_RTP::AbstractPolicy *b) noexcept : bele(b) {}
|
||||
ElfLinker::~ElfLinker() noexcept {
|
||||
delete[] input;
|
||||
delete[] output;
|
||||
|
||||
unsigned ic;
|
||||
for (ic = 0; ic < nsections; ic++)
|
||||
delete sections[ic];
|
||||
free(sections);
|
||||
for (ic = 0; ic < nsymbols; ic++)
|
||||
delete symbols[ic];
|
||||
free(symbols);
|
||||
for (ic = 0; ic < nrelocations; ic++)
|
||||
delete relocations[ic];
|
||||
free(relocations);
|
||||
free_array(sections, nsections);
|
||||
free_array(symbols, nsymbols);
|
||||
free_array(relocations, nrelocations);
|
||||
}
|
||||
|
||||
void ElfLinker::init(const void *pdata_v, int plen, unsigned pxtra) {
|
||||
@@ -156,7 +154,7 @@ void ElfLinker::init(const void *pdata_v, int plen, unsigned pxtra) {
|
||||
input[inputlen] = 0; // NUL terminate
|
||||
|
||||
output_capacity = (inputlen ? (inputlen + pxtra) : 0x4000);
|
||||
assert(output_capacity <= (1 << 16)); // LE16 l_info.l_size
|
||||
assert(output_capacity < (1 << 16)); // LE16 l_info.l_size
|
||||
output = New(byte, output_capacity);
|
||||
outputlen = 0;
|
||||
NO_printf("\nElfLinker::init %d @%p\n", output_capacity, output);
|
||||
@@ -186,8 +184,9 @@ void ElfLinker::init(const void *pdata_v, int plen, unsigned pxtra) {
|
||||
}
|
||||
|
||||
void ElfLinker::preprocessSections(char *start, char const *end) {
|
||||
assert_noexcept(nsections == 0);
|
||||
char *nextl;
|
||||
for (nsections = 0; start < end; start = 1 + nextl) {
|
||||
for (; start < end; start = 1 + nextl) {
|
||||
nextl = strchr(start, '\n');
|
||||
assert(nextl != nullptr);
|
||||
*nextl = '\0'; // a record is a line
|
||||
@@ -207,8 +206,9 @@ void ElfLinker::preprocessSections(char *start, char const *end) {
|
||||
}
|
||||
|
||||
void ElfLinker::preprocessSymbols(char *start, char const *end) {
|
||||
assert_noexcept(nsymbols == 0);
|
||||
char *nextl;
|
||||
for (nsymbols = 0; start < end; start = 1 + nextl) {
|
||||
for (; start < end; start = 1 + nextl) {
|
||||
nextl = strchr(start, '\n');
|
||||
assert(nextl != nullptr);
|
||||
*nextl = '\0'; // a record is a line
|
||||
@@ -243,9 +243,10 @@ void ElfLinker::preprocessSymbols(char *start, char const *end) {
|
||||
}
|
||||
|
||||
void ElfLinker::preprocessRelocations(char *start, char const *end) {
|
||||
assert_noexcept(nrelocations == 0);
|
||||
Section *section = nullptr;
|
||||
char *nextl;
|
||||
for (nrelocations = 0; start < end; start = 1 + nextl) {
|
||||
for (; start < end; start = 1 + nextl) {
|
||||
nextl = strchr(start, '\n');
|
||||
assert(nextl != nullptr);
|
||||
*nextl = '\0'; // a record is a line
|
||||
@@ -302,7 +303,7 @@ ElfLinker::Section *ElfLinker::findSection(const char *name, bool fatal) const {
|
||||
if (strcmp(sections[ic]->name, name) == 0)
|
||||
return sections[ic];
|
||||
if (fatal)
|
||||
internal_error("unknown section %s\n", name);
|
||||
throwInternalError("unknown section %s\n", name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -311,7 +312,7 @@ ElfLinker::Symbol *ElfLinker::findSymbol(const char *name, bool fatal) const {
|
||||
if (strcmp(symbols[ic]->name, name) == 0)
|
||||
return symbols[ic];
|
||||
if (fatal)
|
||||
internal_error("unknown symbol %s\n", name);
|
||||
throwInternalError("unknown symbol %s\n", name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -320,14 +321,11 @@ ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata,
|
||||
NO_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 *)));
|
||||
assert(sections);
|
||||
assert(sname);
|
||||
assert(sname[0]);
|
||||
assert(sname && sname[0]);
|
||||
assert(sname[strlen(sname) - 1] != ':');
|
||||
assert(findSection(sname, false) == nullptr);
|
||||
if (grow_capacity(nsections, &nsections_capacity))
|
||||
sections = realloc_array(sections, nsections_capacity);
|
||||
Section *sec = new Section(sname, sdata, slen, p2align);
|
||||
sec->sort_id = nsections;
|
||||
sections[nsections++] = sec;
|
||||
@@ -337,13 +335,11 @@ ElfLinker::Section *ElfLinker::addSection(const char *sname, const void *sdata,
|
||||
ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section,
|
||||
upx_uint64_t offset) {
|
||||
NO_printf("addSymbol: %s %s 0x%llx\n", name, section, offset);
|
||||
if (update_capacity(nsymbols, &nsymbols_capacity))
|
||||
symbols = static_cast<Symbol **>(realloc(symbols, nsymbols_capacity * sizeof(Symbol *)));
|
||||
assert(symbols != nullptr);
|
||||
assert(name);
|
||||
assert(name[0]);
|
||||
assert(name && name[0]);
|
||||
assert(name[strlen(name) - 1] != ':');
|
||||
assert(findSymbol(name, false) == nullptr);
|
||||
if (grow_capacity(nsymbols, &nsymbols_capacity))
|
||||
symbols = realloc_array(symbols, nsymbols_capacity);
|
||||
Symbol *sym = new Symbol(name, findSection(section), offset);
|
||||
symbols[nsymbols++] = sym;
|
||||
return sym;
|
||||
@@ -351,19 +347,16 @@ ElfLinker::Symbol *ElfLinker::addSymbol(const char *name, const char *section,
|
||||
|
||||
ElfLinker::Relocation *ElfLinker::addRelocation(const char *section, unsigned off, const char *type,
|
||||
const char *symbol, upx_uint64_t add) {
|
||||
if (update_capacity(nrelocations, &nrelocations_capacity))
|
||||
relocations = static_cast<Relocation **>(
|
||||
realloc(relocations, (nrelocations_capacity) * sizeof(Relocation *)));
|
||||
assert(relocations != nullptr);
|
||||
if (grow_capacity(nrelocations, &nrelocations_capacity))
|
||||
relocations = realloc_array(relocations, nrelocations_capacity);
|
||||
Relocation *rel = new Relocation(findSection(section), off, type, findSymbol(symbol), add);
|
||||
relocations[nrelocations++] = rel;
|
||||
return rel;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void ElfLinker::setLoaderAlignOffset(int phase)
|
||||
{
|
||||
//assert(phase & 0);
|
||||
void ElfLinker::setLoaderAlignOffset(int phase) {
|
||||
// assert(phase & 0);
|
||||
NO_printf("\nFIXME: ElfLinker::setLoaderAlignOffset %d\n", phase);
|
||||
}
|
||||
#endif
|
||||
@@ -425,7 +418,7 @@ int ElfLinker::addLoader(const char *sname) {
|
||||
}
|
||||
sect += strlen(sect) + 1;
|
||||
}
|
||||
free(begin);
|
||||
::free(begin);
|
||||
return outputlen;
|
||||
}
|
||||
|
||||
@@ -474,10 +467,10 @@ void ElfLinker::relocate() {
|
||||
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);
|
||||
throwInternalError("undefined symbol '%s' referenced\n", rel->value->name);
|
||||
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);
|
||||
throwInternalError("can not apply reloc '%s:%x' without section '%s'\n",
|
||||
rel->section->name, rel->offset, rel->value->section->name);
|
||||
else {
|
||||
value = rel->value->section->offset + rel->value->offset + rel->add;
|
||||
}
|
||||
@@ -495,7 +488,7 @@ void ElfLinker::relocate() {
|
||||
void ElfLinker::defineSymbol(const char *name, upx_uint64_t value) {
|
||||
Symbol *symbol = findSymbol(name);
|
||||
if (strcmp(symbol->section->name, "*ABS*") == 0)
|
||||
internal_error("defineSymbol: symbol '%s' is *ABS*\n", name);
|
||||
throwInternalError("defineSymbol: symbol '%s' is *ABS*\n", name);
|
||||
else if (strcmp(symbol->section->name, "*UND*") == 0) // for undefined symbols
|
||||
symbol->offset = value;
|
||||
else if (strcmp(symbol->section->name, name) == 0) // for sections
|
||||
@@ -506,7 +499,7 @@ void ElfLinker::defineSymbol(const char *name, upx_uint64_t value) {
|
||||
value += section->size;
|
||||
}
|
||||
} else
|
||||
internal_error("defineSymbol: symbol '%s' already defined\n", name);
|
||||
throwInternalError("defineSymbol: symbol '%s' already defined\n", name);
|
||||
}
|
||||
|
||||
// debugging support
|
||||
@@ -553,7 +546,7 @@ void ElfLinker::alignWithByte(unsigned len, byte b) {
|
||||
}
|
||||
|
||||
void ElfLinker::relocate1(const Relocation *rel, byte *, upx_uint64_t, const char *) {
|
||||
internal_error("unknown relocation type '%s\n'", rel->type);
|
||||
throwInternalError("unknown relocation type '%s\n'", rel->type);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -563,14 +556,13 @@ void ElfLinker::relocate1(const Relocation *rel, byte *, upx_uint64_t, const cha
|
||||
**************************************************************************/
|
||||
|
||||
#if 0 // FIXME
|
||||
static void check8(const Relocation *rel, const byte *location, int v, int d)
|
||||
{
|
||||
static void check8(const Relocation *rel, const byte *location, int v, int d) {
|
||||
if (v < -128 || v > 127)
|
||||
internal_error("value out of range (%d) in reloc %s:%x\n",
|
||||
v, rel->section->name, rel->offset);
|
||||
throwInternalError("value out of range (%d) in reloc %s:%x\n", v, rel->section->name,
|
||||
rel->offset);
|
||||
if (d < -128 || d > 127)
|
||||
internal_error("displacement target out of range (%d) in reloc %s:%x\n",
|
||||
v, rel->section->name, rel->offset);
|
||||
throwInternalError("displacement target out of range (%d) in reloc %s:%x\n", v,
|
||||
rel->section->name, rel->offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -592,10 +584,10 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, byte *location, upx_uint64
|
||||
}
|
||||
|
||||
if (strcmp(type, "8") == 0) {
|
||||
int displ = (signed char) *location + (int) value;
|
||||
int displ = (upx_int8_t) *location + (int) value;
|
||||
if (range_check && (displ < -128 || displ > 127))
|
||||
internal_error("target out of range (%d) in reloc %s:%x\n", displ, rel->section->name,
|
||||
rel->offset);
|
||||
throwInternalError("target out of range (%d) in reloc %s:%x\n", displ,
|
||||
rel->section->name, rel->offset);
|
||||
*location += value;
|
||||
} else if (strcmp(type, "16") == 0)
|
||||
set_le16(location, get_le16(location) + value);
|
||||
@@ -800,12 +792,12 @@ void ElfLinkerPpc32::relocate1(const Relocation *rel, byte *location, upx_uint64
|
||||
// Note that original (*location).displ is ignored.
|
||||
if (strcmp(type, "24") == 0) {
|
||||
if (3 & value)
|
||||
internal_error("unaligned word displacement");
|
||||
throwInternalError("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_be32(location, (0xfc000003 & get_be32(location)) + (0x03fffffc & value));
|
||||
} else if (strcmp(type, "14") == 0) {
|
||||
if (3 & value)
|
||||
internal_error("unaligned word displacement");
|
||||
throwInternalError("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_be32(location, (0xffff0003 & get_be32(location)) + (0x0000fffc & value));
|
||||
} else
|
||||
@@ -835,18 +827,24 @@ void ElfLinkerPpc64le::relocate1(const Relocation *rel, byte *location, upx_uint
|
||||
/* value will hold relative displacement */
|
||||
value -= rel->section->offset + rel->offset;
|
||||
|
||||
if (strcmp(type, "8") == 0) {
|
||||
int displ = (signed char) *location + (int) value;
|
||||
if (strncmp(type, "14", 2) == 0) { // for "14" and "14S"
|
||||
if (3 & value)
|
||||
throwInternalError("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_le32(location, (0xffff0003 & get_le32(location)) + (0x0000fffc & value));
|
||||
} else if (strncmp(type, "24", 2) == 0) { // for "24" and "24S"
|
||||
if (3 & value)
|
||||
throwInternalError("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_le32(location, (0xfc000003 & get_le32(location)) + (0x03fffffc & value));
|
||||
} else if (strcmp(type, "8") == 0) {
|
||||
int displ = (upx_int8_t) *location + (int) value;
|
||||
if (range_check && (displ < -128 || displ > 127))
|
||||
internal_error("target out of range (%d) in reloc %s:%x\n", displ, rel->section->name,
|
||||
rel->offset);
|
||||
throwInternalError("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 "14" and "14S"
|
||||
} else if (strcmp(type, "16") == 0)
|
||||
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 "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);
|
||||
else if (strcmp(type, "64") == 0)
|
||||
@@ -869,18 +867,38 @@ void ElfLinkerPpc64::relocate1(const Relocation *rel, byte *location, upx_uint64
|
||||
return super::relocate1(rel, location, value, type);
|
||||
type += 11;
|
||||
|
||||
bool range_check = false;
|
||||
if (strncmp(type, "PC", 2) == 0) {
|
||||
type += 2;
|
||||
range_check = true;
|
||||
}
|
||||
|
||||
// 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);
|
||||
if (strncmp(type, "14", 2) == 0) { // for "14" and "14S"
|
||||
if (3 & value)
|
||||
throwInternalError("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_be32(location, (0xffff0003 & get_be32(location)) + (0x0000fffc & value));
|
||||
} else if (strncmp(type, "24", 2) == 0) { // for "24" and "24S"
|
||||
if (3 & value)
|
||||
throwInternalError("unaligned word displacement");
|
||||
// FIXME: displacement overflow?
|
||||
set_be32(location, (0xfc000003 & get_be32(location)) + (0x03fffffc & value));
|
||||
} else if (strcmp(type, "8") == 0) {
|
||||
int displ = (upx_int8_t) *location + (int) value;
|
||||
if (range_check && (displ < -128 || displ > 127))
|
||||
throwInternalError("target out of range (%d) in reloc %s:%x\n", displ,
|
||||
rel->section->name, rel->offset);
|
||||
*location += value;
|
||||
} else if (strcmp(type, "16") == 0)
|
||||
set_be16(location, get_be16(location) + value);
|
||||
else if (strncmp(type, "32", 2) == 0) // for "32" and "32S"
|
||||
set_be32(location, get_be32(location) + value);
|
||||
else if (strcmp(type, "64") == 0)
|
||||
set_be64(location, get_be64(location) + value);
|
||||
else
|
||||
super::relocate1(rel, location, value, type);
|
||||
}
|
||||
@@ -899,10 +917,10 @@ void ElfLinkerX86::relocate1(const Relocation *rel, byte *location, upx_uint64_t
|
||||
}
|
||||
|
||||
if (strcmp(type, "8") == 0) {
|
||||
int displ = (signed char) *location + (int) value;
|
||||
int displ = (upx_int8_t) *location + (int) value;
|
||||
if (range_check && (displ < -128 || displ > 127))
|
||||
internal_error("target out of range (%d,%d,%llu) in reloc %s:%x\n", displ, *location,
|
||||
value, rel->section->name, rel->offset);
|
||||
throwInternalError("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)
|
||||
set_le16(location, get_le16(location) + value);
|
||||
|
||||
+2
-2
@@ -68,7 +68,6 @@ protected:
|
||||
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;
|
||||
|
||||
Symbol *addSymbol(const char *name, const char *section, upx_uint64_t offset);
|
||||
Relocation *addRelocation(const char *section, unsigned off, const char *type,
|
||||
@@ -92,6 +91,7 @@ public:
|
||||
int getSectionSize(const char *sname) const;
|
||||
byte *getLoader(int *llen = nullptr) const;
|
||||
void defineSymbol(const char *name, upx_uint64_t value);
|
||||
Symbol *findSymbol(const char *name, bool fatal = true) const;
|
||||
upx_uint64_t getSymbolOffset(const char *) const;
|
||||
|
||||
void dumpSymbol(const Symbol *, unsigned flags, FILE *fp) const;
|
||||
@@ -142,7 +142,7 @@ struct ElfLinker::Relocation : private noncopyable {
|
||||
unsigned offset = 0;
|
||||
const char *type = nullptr;
|
||||
const Symbol *value = nullptr;
|
||||
upx_uint64_t add; // used in .rela relocations
|
||||
upx_uint64_t add = 0; // used in .rela relocations
|
||||
|
||||
explicit Relocation(const Section *s, unsigned o, const char *t, const Symbol *v,
|
||||
upx_uint64_t a);
|
||||
|
||||
+25
-17
@@ -37,6 +37,9 @@
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef OPTIONS_VAR
|
||||
// historical note: "UPX_OPTIONS" would be a better name, but back in the old
|
||||
// days environment variables used to be short; and we cannot change that now
|
||||
// because of backward compatibility issues
|
||||
#define OPTIONS_VAR "UPX"
|
||||
#endif
|
||||
|
||||
@@ -215,7 +218,7 @@ static void check_and_update_options(int i, int argc) {
|
||||
**************************************************************************/
|
||||
|
||||
static void e_help(void) {
|
||||
show_help();
|
||||
show_help(0);
|
||||
e_exit(EXIT_USAGE);
|
||||
}
|
||||
|
||||
@@ -383,6 +386,8 @@ static int do_option(int optc, const char *arg) {
|
||||
set_cmd(CMD_HELP);
|
||||
break;
|
||||
case 'h' + 256:
|
||||
case 996:
|
||||
case 997:
|
||||
#if 1
|
||||
if (!acc_isatty(STDOUT_FILENO)) {
|
||||
/* according to GNU standards */
|
||||
@@ -390,7 +395,7 @@ static int do_option(int optc, const char *arg) {
|
||||
opt->console = CON_FILE;
|
||||
}
|
||||
#endif
|
||||
show_help(1);
|
||||
show_help(optc == 996 ? 1 : (optc == 997 ? 3 : 2));
|
||||
e_exit(EXIT_OK);
|
||||
break;
|
||||
case 'i':
|
||||
@@ -789,7 +794,7 @@ static int do_option(int optc, const char *arg) {
|
||||
break;
|
||||
|
||||
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||
case 999: // doctest --dt-XXX option
|
||||
case 999: // [doctest] --dt-XXX option; ignored here, see upx_doctest_check()
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -813,7 +818,7 @@ int main_get_options(int argc, char **argv) {
|
||||
// commands
|
||||
{"best", 0x10, N, 900}, // compress best
|
||||
{"brute", 0x10, N, 901}, // compress best, brute force
|
||||
{"ultra-brute", 0x10, N, 902}, // compress best, brute force
|
||||
{"ultra-brute", 0x10, N, 902}, // compress best, ultra-brute force
|
||||
{"decompress", 0, N, 'd'}, // decompress
|
||||
{"fast", 0x10, N, '1'}, // compress faster
|
||||
{"fileinfo", 0x10, N, 909}, // display info about file
|
||||
@@ -923,7 +928,7 @@ int main_get_options(int argc, char **argv) {
|
||||
// atari/tos
|
||||
{"split-segments", 0x90, N, 650},
|
||||
// darwin/macho
|
||||
{"force-macos", 0x90, N, 690}, // undocumented temporary until we fix macOS 13+
|
||||
{"force-macos", 0x90, N, 690}, // undocumented temporary option until we do fix macOS 13+
|
||||
// djgpp2/coff
|
||||
{"coff", 0x90, N, 610}, // produce COFF output
|
||||
// dos/exe
|
||||
@@ -963,7 +968,7 @@ int main_get_options(int argc, char **argv) {
|
||||
{"strip-relocs", 0x12, N, 634},
|
||||
{"keep-resource", 0x31, N, 635},
|
||||
|
||||
#if !defined(DOCTEST_CONFIG_DISABLE)
|
||||
#if !defined(DOCTEST_CONFIG_DISABLE) // accept and ignore some doctest --dt-XXX options
|
||||
// [doctest] Query flags - the program quits after them. Available:
|
||||
{"dt-c", 0x10, N, 999},
|
||||
{"dt-count", 0x10, N, 999},
|
||||
@@ -1020,7 +1025,7 @@ void main_get_envoptions() {
|
||||
// commands
|
||||
{"best", 0x10, N, 900}, // compress best
|
||||
{"brute", 0x10, N, 901}, // compress best, brute force
|
||||
{"ultra-brute", 0x10, N, 902}, // compress best, brute force
|
||||
{"ultra-brute", 0x10, N, 902}, // compress best, ultra-brute force
|
||||
{"fast", 0x10, N, '1'}, // compress faster
|
||||
|
||||
// options
|
||||
@@ -1086,7 +1091,7 @@ void main_get_envoptions() {
|
||||
static const char sep[] = " \t";
|
||||
char shortopts[256];
|
||||
|
||||
var = getenv(OPTIONS_VAR);
|
||||
var = upx_getenv(OPTIONS_VAR);
|
||||
if (var == nullptr || !var[0])
|
||||
return;
|
||||
env = strdup(var);
|
||||
@@ -1111,7 +1116,7 @@ void main_get_envoptions() {
|
||||
if (targc > 1)
|
||||
targv = (const char **) upx_calloc(targc + 1, sizeof(char *));
|
||||
if (targv == nullptr) {
|
||||
free(env);
|
||||
::free(env);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1150,8 +1155,8 @@ void main_get_envoptions() {
|
||||
e_envopt(targv[mfx_optind]);
|
||||
|
||||
/* clean up */
|
||||
free(targv);
|
||||
free(env);
|
||||
::free(targv); // NOLINT(bugprone-multi-level-implicit-pointer-conversion)
|
||||
::free(env);
|
||||
#endif /* defined(OPTIONS_VAR) */
|
||||
}
|
||||
|
||||
@@ -1169,9 +1174,14 @@ static void first_options(int argc, char **argv) {
|
||||
if (strcmp(argv[i], "--version-short") == 0)
|
||||
do_option(998, argv[i]);
|
||||
}
|
||||
for (i = 1; i < n; i++)
|
||||
for (i = 1; i < n; i++) {
|
||||
if (strcmp(argv[i], "--help") == 0)
|
||||
do_option('h' + 256, argv[i]);
|
||||
if (strcmp(argv[i], "--help-short") == 0) // undocumented and subject to change
|
||||
do_option(996, argv[i]);
|
||||
if (strcmp(argv[i], "--help-verbose") == 0) // undocumented and subject to change
|
||||
do_option(997, argv[i]);
|
||||
}
|
||||
for (i = 1; i < n; i++)
|
||||
if (strcmp(argv[i], "--no-env") == 0)
|
||||
do_option(519, argv[i]);
|
||||
@@ -1269,7 +1279,7 @@ int upx_main(int argc, char *argv[]) may_throw {
|
||||
e_exit(EXIT_OK);
|
||||
break;
|
||||
case CMD_HELP:
|
||||
show_help(1);
|
||||
show_help(2);
|
||||
e_exit(EXIT_OK);
|
||||
break;
|
||||
case CMD_LICENSE:
|
||||
@@ -1306,8 +1316,7 @@ int upx_main(int argc, char *argv[]) may_throw {
|
||||
if (gitrev[0]) {
|
||||
// also see UPX_CONFIG_DISABLE_GITREV in CMakeLists.txt
|
||||
bool warn_gitrev = true;
|
||||
const char *ee = getenv("UPX_DEBUG_DISABLE_GITREV_WARNING");
|
||||
if (ee && ee[0] && strcmp(ee, "1") == 0)
|
||||
if (is_envvar_true("UPX_DEBUG_DISABLE_GITREV_WARNING"))
|
||||
warn_gitrev = false;
|
||||
if (warn_gitrev) {
|
||||
FILE *f = stdout;
|
||||
@@ -1355,8 +1364,7 @@ int __acc_cdecl_main main(int argc, char *argv[]) /*noexcept*/ {
|
||||
_set_abort_behavior(_WRITE_ABORT_MSG, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
#endif
|
||||
acc_wildargv(&argc, &argv);
|
||||
// srand((int) time(nullptr));
|
||||
srand((int) clock());
|
||||
upx_rand_init();
|
||||
|
||||
// info: main() is implicitly "noexcept", so we need a try block
|
||||
#if 0
|
||||
|
||||
+8
-8
@@ -25,7 +25,7 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "util/system_headers.h"
|
||||
#include <typeinfo> // typeid()
|
||||
#include "conf.h"
|
||||
|
||||
@@ -82,10 +82,10 @@ static void pr_error(const char *iname, const char *msg, bool is_warning) noexce
|
||||
bool c = acc_isatty(STDERR_FILENO) ? 1 : 0;
|
||||
|
||||
int fg = con_fg(stderr, FG_BRTRED);
|
||||
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s: ", progname);
|
||||
upx_safe_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s: ", progname);
|
||||
pr_print(c, buf);
|
||||
//(void)con_fg(stderr,FG_RED);
|
||||
snprintf(buf, sizeof(buf), "%s: ", iname);
|
||||
upx_safe_snprintf(buf, sizeof(buf), "%s: ", iname);
|
||||
pr_print(c, buf);
|
||||
//(void)con_fg(stderr,FG_BRTRED);
|
||||
pr_print(c, msg);
|
||||
@@ -102,13 +102,13 @@ void printErr(const char *iname, const Throwable &e) noexcept {
|
||||
char buf[1024];
|
||||
size_t l;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s", prettyName(typeid(e).name()));
|
||||
upx_safe_snprintf(buf, sizeof(buf), "%s", prettyExceptionName(typeid(e).name()));
|
||||
l = strlen(buf);
|
||||
if (l < sizeof(buf) && e.getMsg())
|
||||
snprintf(buf + l, sizeof(buf) - l, ": %s", e.getMsg());
|
||||
upx_safe_snprintf(buf + l, sizeof(buf) - l, ": %s", e.getMsg());
|
||||
l = strlen(buf);
|
||||
if (l < sizeof(buf) && e.getErrno()) {
|
||||
snprintf(buf + l, sizeof(buf) - l, ": %s", strerror(e.getErrno()));
|
||||
upx_safe_snprintf(buf + l, sizeof(buf) - l, ": %s", strerror(e.getErrno()));
|
||||
#if 1
|
||||
// some compilers (e.g. Borland C++) put a trailing '\n'
|
||||
// into the strerror() result
|
||||
@@ -143,8 +143,8 @@ void printWarn(const char *iname, const char *format, ...) noexcept {
|
||||
}
|
||||
|
||||
void printUnhandledException(const char *iname, const std::exception *e) noexcept {
|
||||
if (e)
|
||||
printErr(iname, "unhandled exception: %s\n", prettyName(e->what()));
|
||||
if (e != nullptr)
|
||||
printErr(iname, "unhandled exception: %s\n", prettyExceptionName(e->what()));
|
||||
else
|
||||
printErr(iname, "internal error: unhandled exception!\n");
|
||||
if (opt->cmd != CMD_COMPRESS) {
|
||||
|
||||
+5
-5
@@ -28,10 +28,10 @@
|
||||
#include "conf.h"
|
||||
|
||||
static Options global_options;
|
||||
Options *opt = &global_options; // also see class PackMaster
|
||||
Options *opt = &global_options; // also see class PackMaster for per-file local options
|
||||
|
||||
#if WITH_THREADS
|
||||
std::mutex opt_lock_mutex;
|
||||
std::mutex opt_lock_mutex; // for locking "opt"
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
@@ -39,7 +39,7 @@ std::mutex opt_lock_mutex;
|
||||
**************************************************************************/
|
||||
|
||||
void Options::reset() noexcept {
|
||||
#define opt ERROR_DO_NOT_USE_opt // protect against using the wrong variable
|
||||
#define opt ERROR_DO_NOT_USE_opt // self-protect against using the wrong variable
|
||||
Options *const o = this;
|
||||
mem_clear(o);
|
||||
o->crp.reset();
|
||||
@@ -66,7 +66,7 @@ void Options::reset() noexcept {
|
||||
#endif
|
||||
// support NO_COLOR, see https://no-color.org/
|
||||
// "... when present and not an empty string (regardless of its value)"
|
||||
const char *e = getenv("NO_COLOR");
|
||||
const char *e = upx_getenv("NO_COLOR");
|
||||
if (e && e[0])
|
||||
o->console = CON_FILE;
|
||||
|
||||
@@ -90,7 +90,7 @@ void Options::reset() noexcept {
|
||||
**************************************************************************/
|
||||
|
||||
TEST_CASE("Options::reset") {
|
||||
#define opt ERROR_DO_NOT_USE_opt // protect against using the wrong variable
|
||||
#define opt ERROR_DO_NOT_USE_opt // self-protect against using the wrong variable
|
||||
COMPILE_TIME_ASSERT(std::is_standard_layout<Options>::value)
|
||||
COMPILE_TIME_ASSERT(std::is_nothrow_default_constructible<Options>::value)
|
||||
COMPILE_TIME_ASSERT(std::is_trivially_copyable<Options>::value)
|
||||
|
||||
+6
-2
@@ -28,11 +28,12 @@
|
||||
#pragma once
|
||||
|
||||
struct Options;
|
||||
extern Options *opt; // global options, see class PackMaster for per-file local options
|
||||
#define options_t Options // old name
|
||||
|
||||
extern Options *opt; // global options, see class PackMaster for per-file local options
|
||||
|
||||
#if WITH_THREADS
|
||||
extern std::mutex opt_lock_mutex;
|
||||
extern std::mutex opt_lock_mutex; // for locking "opt"
|
||||
#endif
|
||||
|
||||
/*************************************************************************
|
||||
@@ -177,6 +178,9 @@ struct Options final {
|
||||
int strip_relocs;
|
||||
const char *keep_resource;
|
||||
} win32_pe;
|
||||
|
||||
private: // UPX conventions
|
||||
UPX_CXX_DISABLE_NEW_DELETE(Options)
|
||||
};
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@
|
||||
// dos/com
|
||||
**************************************************************************/
|
||||
|
||||
class PackCom : public Packer {
|
||||
class PackCom /*not_final*/ : public Packer {
|
||||
typedef Packer super;
|
||||
|
||||
public:
|
||||
|
||||
+6
-6
@@ -178,9 +178,9 @@ packed_struct(Sym) {
|
||||
#define WANT_SYM_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
|
||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
||||
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
||||
static unsigned char make_st_info(unsigned bind, unsigned type) {
|
||||
static constexpr unsigned get_st_bind(unsigned x) noexcept { return 0xf & (x >> 4); }
|
||||
static constexpr unsigned get_st_type(unsigned x) noexcept { return 0xf & x; }
|
||||
static constexpr unsigned char make_st_info(unsigned bind, unsigned type) noexcept {
|
||||
return (unsigned char) (((bind << 4) + (0xf & type)) & 0xff);
|
||||
}
|
||||
};
|
||||
@@ -252,9 +252,9 @@ packed_struct(Sym) {
|
||||
#define WANT_SYM_ENUM 1
|
||||
#include "p_elf_enum.h"
|
||||
|
||||
static unsigned int get_st_bind(unsigned x) { return 0xf & (x >> 4); }
|
||||
static unsigned int get_st_type(unsigned x) { return 0xf & x; }
|
||||
static unsigned char make_st_info(unsigned bind, unsigned type) {
|
||||
static constexpr unsigned get_st_bind(unsigned x) noexcept { return 0xf & (x >> 4); }
|
||||
static constexpr unsigned get_st_type(unsigned x) noexcept { return 0xf & x; }
|
||||
static constexpr unsigned char make_st_info(unsigned bind, unsigned type) noexcept {
|
||||
return (unsigned char) (((bind << 4) + (0xf & type)) & 0xff);
|
||||
}
|
||||
};
|
||||
|
||||
+76
-66
@@ -33,24 +33,28 @@
|
||||
// - that older compilers do not correctly perform EBCO
|
||||
**************************************************************************/
|
||||
|
||||
#if CLANG_FORMAT_DUMMY_CLASS
|
||||
class Dummy {
|
||||
#endif
|
||||
|
||||
#ifdef WANT_EHDR_ENUM
|
||||
#undef WANT_EHDR_ENUM
|
||||
enum { // indices for e_ident[16]
|
||||
enum { // indices for e_ident[16]
|
||||
EI_CLASS = 4,
|
||||
EI_DATA = 5, /* Data encoding */
|
||||
EI_DATA = 5, // Data encoding
|
||||
EI_VERSION = 6,
|
||||
EI_OSABI = 7,
|
||||
EI_ABIVERSION = 8,
|
||||
};
|
||||
enum { // e_ident[EI_CLASS]
|
||||
ELFCLASS32 = 1, /* 32-bit objects */
|
||||
ELFCLASS64 = 2, /* 64-bit objects */
|
||||
};
|
||||
enum { // e_ident[EI_DATA]
|
||||
ELFDATA2LSB = 1, /* 2's complement, little endian */
|
||||
ELFDATA2MSB = 2, /* 2's complement, big endian */
|
||||
};
|
||||
enum { // e_ident[EI_OSABI]
|
||||
};
|
||||
enum { // e_ident[EI_CLASS]
|
||||
ELFCLASS32 = 1, // 32-bit objects
|
||||
ELFCLASS64 = 2, // 64-bit objects
|
||||
};
|
||||
enum { // e_ident[EI_DATA]
|
||||
ELFDATA2LSB = 1, // 2's complement, little endian
|
||||
ELFDATA2MSB = 2, // 2's complement, big endian
|
||||
};
|
||||
enum { // e_ident[EI_OSABI]
|
||||
ELFOSABI_NONE = 0, // == ELFOSABI_SYSV
|
||||
ELFOSABI_NETBSD = 2,
|
||||
ELFOSABI_LINUX = 3,
|
||||
@@ -60,15 +64,15 @@ enum { // e_ident[EI_OSABI]
|
||||
ELFOSABI_OPENBSD = 12,
|
||||
ELFOSABI_ARM = 97,
|
||||
ELFOSABI_STANDALONE = 255 // Standalone (embedded) application
|
||||
};
|
||||
enum { // e_type
|
||||
};
|
||||
enum { // e_type
|
||||
ET_NONE = 0, /* No file type */
|
||||
ET_REL = 1, /* Relocatable file */
|
||||
ET_EXEC = 2, /* Executable file */
|
||||
ET_DYN = 3, /* Shared object file */
|
||||
ET_CORE = 4, /* Core file */
|
||||
};
|
||||
enum { // e_machine
|
||||
};
|
||||
enum { // e_machine
|
||||
EM_386 = 3, // i386
|
||||
EM_MIPS = 8,
|
||||
EM_MIPS_RS3_LE = 10, // MIPS R3000 little-endian
|
||||
@@ -81,15 +85,15 @@ enum { // e_machine
|
||||
EM_ARM64 = EM_AARCH64,
|
||||
EM_RISCV = 243, // risc-v
|
||||
EM_LOONGARCH = 258,
|
||||
};
|
||||
enum { // e_version
|
||||
};
|
||||
enum { // e_version
|
||||
EV_CURRENT = 1,
|
||||
};
|
||||
#endif
|
||||
};
|
||||
#endif // WANT_EHDR_ENUM
|
||||
|
||||
#ifdef WANT_PHDR_ENUM
|
||||
#undef WANT_PHDR_ENUM
|
||||
enum { // p_type
|
||||
enum { // p_type
|
||||
PT_NULL = 0, /* Ignore: a "comment" */
|
||||
PT_LOAD = 1, /* Loadable program segment */
|
||||
PT_DYNAMIC = 2, /* Dynamic linking information */
|
||||
@@ -99,18 +103,18 @@ enum { // p_type
|
||||
PT_NUM = 8, /* Number of defined types in low range */
|
||||
PT_GNU_STACK = 0x6474e551, /* Indicates stack executability */
|
||||
PT_GNU_RELRO = 0x6474e552, /* Read-only after relocation */
|
||||
};
|
||||
};
|
||||
|
||||
enum { // p_flags
|
||||
enum { // p_flags
|
||||
PF_X = 1, /* Segment is executable */
|
||||
PF_W = 2, /* Segment is writable */
|
||||
PF_R = 4, /* Segment is readable */
|
||||
};
|
||||
#endif
|
||||
};
|
||||
#endif // WANT_PHDR_ENUM
|
||||
|
||||
#ifdef WANT_SHDR_ENUM
|
||||
#undef WANT_SHDR_ENUM
|
||||
enum { // sh_type
|
||||
enum { // sh_type
|
||||
SHT_NULL = 0, /* Section header table entry unused */
|
||||
SHT_PROGBITS = 1, /* Program data */
|
||||
SHT_SYMTAB = 2, /* Symbol table */
|
||||
@@ -138,9 +142,9 @@ enum { // sh_type
|
||||
SHT_LOOS = 0x60000000, /* LOcal OS; SHT_ANDROID_REL{,A} is +1, +2 */
|
||||
SHT_LOPROC = 0x70000000, /* Start of processor-specific */
|
||||
SHT_ARM_ATTRIBUTES = (SHT_LOPROC + 3), /* ARM attributes section. */
|
||||
};
|
||||
};
|
||||
|
||||
enum { // sh_flags
|
||||
enum { // sh_flags
|
||||
SHF_WRITE = (1 << 0), /* Writable */
|
||||
SHF_ALLOC = (1 << 1), /* Occupies memory during execution */
|
||||
SHF_EXECINSTR = (1 << 2), /* Executable */
|
||||
@@ -148,12 +152,12 @@ enum { // sh_flags
|
||||
SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
|
||||
SHF_INFO_LINK = (1 << 6), /* 'sh_info' contains SHT index */
|
||||
SHF_LINK_ORDER = (1 << 7), /* Preserve order after combining */
|
||||
};
|
||||
#endif
|
||||
};
|
||||
#endif // WANT_SHDR_ENUM
|
||||
|
||||
#ifdef WANT_DYN_ENUM
|
||||
#undef WANT_DYN_ENUM
|
||||
enum { // d_tag
|
||||
enum { // d_tag
|
||||
DT_NULL = 0, /* End flag */
|
||||
DT_NEEDED = 1, /* Name of needed library */
|
||||
DT_PLTRELSZ = 2, /* Size in bytes of PLT relocs */
|
||||
@@ -189,22 +193,22 @@ enum { // d_tag
|
||||
DT_FLAGS_1 = 0x6ffffffb, /* DF_1_* */
|
||||
DT_VERDEF = 0x6ffffffc, /* version definitions[] */
|
||||
DT_VERNEED = 0x6ffffffe, /* version[] needed */
|
||||
};
|
||||
enum { // DT_FLAGS_1
|
||||
};
|
||||
enum { // DT_FLAGS_1
|
||||
DF_1_NOW = 0x00000001, /* Set RTLD_NOW for this object. */
|
||||
DF_1_PIE = 0x08000000, // Position-Independent Executable (main program)
|
||||
};
|
||||
#endif
|
||||
};
|
||||
#endif // WANT_DYN_ENUM
|
||||
|
||||
#ifdef WANT_SYM_ENUM
|
||||
#undef WANT_SYM_ENUM
|
||||
enum { // st_bind (high 4 bits of st_info)
|
||||
enum { // st_bind (high 4 bits of st_info)
|
||||
STB_LOCAL = 0, /* Local symbol */
|
||||
STB_GLOBAL = 1, /* Global symbol */
|
||||
STB_WEAK = 2, /* Weak symbol */
|
||||
};
|
||||
};
|
||||
|
||||
enum { // st_type (low 4 bits of st_info)
|
||||
enum { // st_type (low 4 bits of st_info)
|
||||
STT_NOTYPE = 0, /* Symbol type is unspecified */
|
||||
STT_OBJECT = 1, /* Symbol is a data object */
|
||||
STT_FUNC = 2, /* Symbol is a code object */
|
||||
@@ -212,40 +216,42 @@ enum { // st_type (low 4 bits of st_info)
|
||||
STT_FILE = 4, /* Symbol's name is file name */
|
||||
STT_COMMON = 5, /* Symbol is a common data object */
|
||||
STT_TLS = 6, /* Symbol is thread-local data object*/
|
||||
};
|
||||
};
|
||||
|
||||
enum { // st_other (visibility)
|
||||
enum { // st_other (visibility)
|
||||
STV_DEFAULT = 0, /* Default symbol visibility rules */
|
||||
STV_INTERNAL = 1, /* Processor specific hidden class */
|
||||
STV_HIDDEN = 2, /* Sym unavailable in other modules */
|
||||
STV_PROTECTED = 3, /* Not preemptible, not exported */
|
||||
};
|
||||
};
|
||||
|
||||
enum { // st_shndx
|
||||
enum { // st_shndx
|
||||
SHN_UNDEF = 0, /* Undefined section */
|
||||
SHN_ABS = 0xfff1, /* Associated symbol is absolute */
|
||||
SHN_COMMON = 0xfff2, /* Associated symbol is common */
|
||||
};
|
||||
#endif
|
||||
};
|
||||
#endif // WANT_SYM_ENUM
|
||||
|
||||
#ifdef WANT_REL_ENUM //{
|
||||
#ifdef WANT_REL_ENUM
|
||||
#undef WANT_REL_ENUM
|
||||
static inline unsigned ELF32_R_TYPE(unsigned x) { return 0xff & x; }
|
||||
static inline unsigned ELF64_R_TYPE(upx_uint64_t x) { return 0xffffffff & (unsigned) x; }
|
||||
static inline unsigned ELF32_R_SYM(unsigned x) { return x >> 8; }
|
||||
static inline unsigned ELF64_R_SYM(upx_uint64_t x) { return x >> 32; }
|
||||
static inline unsigned ELF32_R_INFO(unsigned sym, unsigned type) {
|
||||
static constexpr inline unsigned ELF32_R_TYPE(unsigned x) noexcept { return 0xff & x; }
|
||||
static constexpr inline unsigned ELF64_R_TYPE(upx_uint64_t x) noexcept {
|
||||
return 0xffffffff & (unsigned) x;
|
||||
}
|
||||
static constexpr inline unsigned ELF32_R_SYM(unsigned x) noexcept { return x >> 8; }
|
||||
static constexpr inline unsigned ELF64_R_SYM(upx_uint64_t x) noexcept { return x >> 32; }
|
||||
static constexpr inline unsigned ELF32_R_INFO(unsigned sym, unsigned type) noexcept {
|
||||
return (sym << 8) + (type & 0xff);
|
||||
}
|
||||
static inline upx_int64_t ELF64_R_INFO(unsigned sym, unsigned type) {
|
||||
}
|
||||
static constexpr inline upx_int64_t ELF64_R_INFO(unsigned sym, unsigned type) {
|
||||
return ((upx_uint64_t) sym << 32) + type;
|
||||
}
|
||||
}
|
||||
|
||||
#undef R_PPC_RELATIVE
|
||||
#undef R_PPC64_RELATIVE
|
||||
#undef R_PPC_JMP_SLOT
|
||||
#undef R_PPC64_JMP_SLOT
|
||||
enum { // relocation types
|
||||
enum { // relocation types
|
||||
R_386_RELATIVE = 8,
|
||||
R_AARCH64_RELATIVE = 1027,
|
||||
R_ARM_RELATIVE = 23,
|
||||
@@ -270,12 +276,12 @@ enum { // relocation types
|
||||
R_AARCH64_ABS64 = 257,
|
||||
R_AARCH64_GLOB_DAT = 1025,
|
||||
|
||||
};
|
||||
#endif //}
|
||||
};
|
||||
#endif // WANT_REL_ENUM
|
||||
|
||||
#ifdef WANT_NHDR_ENUM
|
||||
#undef WANT_NHDR_ENUM
|
||||
enum { // ELF PT_NOTE types
|
||||
enum { // ELF PT_NOTE types
|
||||
#define ELF_NOTE_GNU_NAME "GNU\0"
|
||||
NT_GNU_ABI_TAG = 1,
|
||||
NT_GNU_HWCAP = 2,
|
||||
@@ -288,38 +294,42 @@ enum { // ELF PT_NOTE types
|
||||
NHDR_NETBSD_TAG = 1,
|
||||
NHDR_CHECKSUM_TAG = 2,
|
||||
NHDR_PAX_TAG = 3,
|
||||
};
|
||||
};
|
||||
|
||||
enum { // descsz descriptor sizes
|
||||
enum { // descsz descriptor sizes
|
||||
GNU_ABI_DESCSZ = 16, // int GNU_OS, major, minor, subminor;
|
||||
NETBSD_DESCSZ = 4, // major_ver * (10**8) + minor
|
||||
OPENBSD_DESCSZ = 4, // 32-bit zero
|
||||
// CHECKSUM_DESCSZ is 2*sizeof(short) + sizeof(checksum)
|
||||
PAX_DESCSZ = 4, // 32-bit mask
|
||||
};
|
||||
};
|
||||
|
||||
enum { // GNU OS/version
|
||||
enum { // GNU OS/version
|
||||
GNU_OS_LINUX = 0,
|
||||
GNU_OS_HURD = 1,
|
||||
GNU_OS_SOLARIS = 2,
|
||||
};
|
||||
};
|
||||
|
||||
enum { // NetBSD checksum methods
|
||||
enum { // NetBSD checksum methods
|
||||
CHECKSUM_CRC32 = 1,
|
||||
CHECKSUM_MD5 = 2,
|
||||
CHECKSUM_SHA1 = 3,
|
||||
CHECKSUM_SHA256 = 4,
|
||||
};
|
||||
};
|
||||
|
||||
#define ELF_NOTE_PAX_NAME "PaX\0"
|
||||
enum { // NetBSD PaX bit values
|
||||
enum { // NetBSD PaX bit values
|
||||
PAX_MPROTECT = (1 << 0), /* force enable Mprotect */
|
||||
PAX_NOMPROTECT = (1 << 1), /* force disable Mprotect */
|
||||
PAX_GUARD = (1 << 2), /* force enable SEGVguard */
|
||||
PAX_NOGUARD = (1 << 3), /* force disable SEGVguard */
|
||||
PAX_ASLR = (1 << 4), /* force enable ASLR */
|
||||
PAX_NOASLR = (1 << 5), /* force disable ASLR */
|
||||
};
|
||||
};
|
||||
#endif // WANT_NHDR_ENUM
|
||||
|
||||
#if CLANG_FORMAT_DUMMY_CLASS
|
||||
}; // class
|
||||
#endif
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ protected:
|
||||
LE32 firstreloc;
|
||||
};
|
||||
|
||||
exe_header_t ih, oh;
|
||||
exe_header_t ih = {}, oh = {};
|
||||
|
||||
unsigned ih_exesize = 0;
|
||||
unsigned ih_imagesize = 0;
|
||||
|
||||
+131
-62
@@ -259,7 +259,7 @@ PackLinuxElf::PackLinuxElf(InputFile *f)
|
||||
o_elf_shnum(0)
|
||||
{
|
||||
memset(dt_table, 0, sizeof(dt_table));
|
||||
symnum_end = 0;
|
||||
symnum_max = 0;
|
||||
user_init_rp = nullptr;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ PackLinuxElf32::PackLinuxElf32help1(InputFile *f)
|
||||
sz_elf_hdrs = sz_phdrs + sizeof(Elf32_Ehdr);
|
||||
|
||||
if (f && Elf32_Ehdr::ET_DYN!=e_type) {
|
||||
unsigned const len = sz_phdrs + e_phoff;
|
||||
unsigned const len = file_size; // (sz_phdrs + e_phoff) except --preserve-build-id
|
||||
alloc_file_image(file_image, len);
|
||||
f->seek(0, SEEK_SET);
|
||||
f->readx(file_image, len);
|
||||
@@ -437,7 +437,7 @@ off_t PackLinuxElf::pack3(OutputFile *fo, Filter &ft) // return length of output
|
||||
// FIXME: debugging aid: entry to decompressor
|
||||
if (lowmem.getSize()) {
|
||||
Elf32_Ehdr *const ehdr = (Elf32_Ehdr *)&lowmem[0];
|
||||
set_te32(&ehdr->e_entry, sz_pack2); // hint for decomperssor
|
||||
set_te32(&ehdr->e_entry, sz_pack2); // hint for decompressor
|
||||
}
|
||||
// end debugging aid
|
||||
|
||||
@@ -903,10 +903,10 @@ PackLinuxElf::addStubEntrySections(Filter const *, unsigned m_decompr)
|
||||
addLoader("ELFMAINXu", nullptr);
|
||||
}
|
||||
addLoader(
|
||||
( M_IS_NRV2E(ph.method) ? "NRV_HEAD,NRV2E,NRV_TAIL"
|
||||
: M_IS_NRV2D(ph.method) ? "NRV_HEAD,NRV2D,NRV_TAIL"
|
||||
: M_IS_NRV2B(ph.method) ? "NRV_HEAD,NRV2B,NRV_TAIL"
|
||||
: M_IS_LZMA(ph.method) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
|
||||
( M_IS_NRV2E(ph_forced_method(ph.method)) ? "NRV_HEAD,NRV2E,NRV_TAIL"
|
||||
: M_IS_NRV2D(ph_forced_method(ph.method)) ? "NRV_HEAD,NRV2D,NRV_TAIL"
|
||||
: M_IS_NRV2B(ph_forced_method(ph.method)) ? "NRV_HEAD,NRV2B,NRV_TAIL"
|
||||
: M_IS_LZMA(ph_forced_method(ph.method)) ? "LZMA_ELF00,LZMA_DEC20,LZMA_DEC30"
|
||||
: nullptr), nullptr);
|
||||
if (hasLoaderSection("CFLUSH"))
|
||||
addLoader("CFLUSH");
|
||||
@@ -1031,7 +1031,7 @@ PackLinuxElf64::PackLinuxElf64help1(InputFile *f)
|
||||
sz_elf_hdrs = sz_phdrs + sizeof(Elf64_Ehdr);
|
||||
|
||||
if (f && Elf64_Ehdr::ET_DYN!=e_type) {
|
||||
unsigned const len = sz_phdrs + e_phoff;
|
||||
unsigned const len = file_size; // (sz_phdrs + e_phoff) except --preserve-build-id
|
||||
alloc_file_image(file_image, len);
|
||||
f->seek(0, SEEK_SET);
|
||||
f->readx(file_image, len);
|
||||
@@ -1989,6 +1989,7 @@ void
|
||||
PackLinuxElf32::sort_DT32_offsets(Elf32_Dyn const *const dynp0)
|
||||
{
|
||||
mb_dt_offsets.alloc(sizeof(unsigned) * sizeof(dt_keys)/sizeof(dt_keys[0]));
|
||||
mb_dt_offsets.clear();
|
||||
dt_offsets = (unsigned *)mb_dt_offsets.getVoidPtr();
|
||||
unsigned n_off = 0, k;
|
||||
for (unsigned j=0; ((k = dt_keys[j]), k); ++j) {
|
||||
@@ -2028,7 +2029,8 @@ PackLinuxElf32::sort_DT32_offsets(Elf32_Dyn const *const dynp0)
|
||||
unsigned PackLinuxElf32::find_dt_ndx(unsigned rva)
|
||||
{
|
||||
unsigned *const dto = (unsigned *)mb_dt_offsets.getVoidPtr();
|
||||
for (unsigned j = 0; dto[j]; ++j) { // linear search of short table
|
||||
unsigned const dto_size = mb_dt_offsets.getSize() / sizeof(*dto);
|
||||
for (unsigned j = 0; j < dto_size && dto[j]; ++j) { // linear search of short table
|
||||
if (rva == dto[j]) {
|
||||
return j;
|
||||
}
|
||||
@@ -2046,6 +2048,9 @@ unsigned PackLinuxElf32::elf_find_table_size(unsigned dt_type, unsigned sh_type)
|
||||
unsigned x_rva;
|
||||
if (dt_type < DT_NUM) {
|
||||
unsigned const x_ndx = dt_table[dt_type];
|
||||
if (!x_ndx) { // no such entry
|
||||
return 0;
|
||||
}
|
||||
x_rva = get_te32(&dynseg[-1+ x_ndx].d_val);
|
||||
}
|
||||
else {
|
||||
@@ -2099,15 +2104,21 @@ PackLinuxElf32::invert_pt_dynamic(Elf32_Dyn const *dynp, u32_t headway)
|
||||
else if (dt_table[Elf32_Dyn::DT_INIT_ARRAY]) upx_dt_init = Elf32_Dyn::DT_INIT_ARRAY;
|
||||
|
||||
unsigned const z_str = dt_table[Elf32_Dyn::DT_STRSZ];
|
||||
strtab_end = !z_str ? 0 : get_te32(&dynp0[-1+ z_str].d_val);
|
||||
if (!z_str || (u32_t)file_size <= strtab_end) { // FIXME: weak
|
||||
strtab_max = !z_str ? 0 : get_te32(&dynp0[-1+ z_str].d_val);
|
||||
unsigned const z_tab = dt_table[Elf32_Dyn::DT_STRTAB];
|
||||
unsigned const strtab_beg = !z_tab ? 0 : get_te32(&dynp0[-1+ z_tab].d_val);
|
||||
if (!z_str || !z_tab
|
||||
|| (this->file_size - strtab_beg) < strtab_max // strtab overlaps EOF
|
||||
// last string in table must have terminating NUL
|
||||
|| '\0' != ((char *)file_image.getVoidPtr())[-1+ strtab_max + strtab_beg]
|
||||
) {
|
||||
char msg[50]; snprintf(msg, sizeof(msg),
|
||||
"bad DT_STRSZ %#x", strtab_end);
|
||||
"bad DT_STRSZ %#x", strtab_max);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
|
||||
// Find end of DT_SYMTAB
|
||||
symnum_end = elf_find_table_size(
|
||||
symnum_max = elf_find_table_size(
|
||||
Elf32_Dyn::DT_SYMTAB, Elf32_Shdr::SHT_DYNSYM) / sizeof(Elf32_Sym);
|
||||
|
||||
unsigned const x_sym = dt_table[Elf32_Dyn::DT_SYMTAB];
|
||||
@@ -2126,9 +2137,15 @@ PackLinuxElf32::invert_pt_dynamic(Elf32_Dyn const *dynp, u32_t headway)
|
||||
unsigned const nbucket = get_te32(&hashtab[0]);
|
||||
unsigned const *const buckets = &hashtab[2];
|
||||
unsigned const *const chains = &buckets[nbucket]; (void)chains;
|
||||
if ((unsigned)(file_size - ((char const *)buckets - (char const *)(void const *)file_image))
|
||||
<= sizeof(unsigned)*nbucket ) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad nbucket %#x\n", nbucket);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
|
||||
unsigned const v_sym = !x_sym ? 0 : get_te32(&dynp0[-1+ x_sym].d_val);
|
||||
if ((unsigned)file_size <= nbucket/sizeof(*buckets) // FIXME: weak
|
||||
if ((unsigned)(hashend - buckets) < nbucket
|
||||
|| !v_sym || (unsigned)file_size <= v_sym
|
||||
|| ((v_hsh < v_sym) && (v_sym - v_hsh) < sizeof(*buckets)*(2+ nbucket))
|
||||
) {
|
||||
@@ -2170,11 +2187,18 @@ PackLinuxElf32::invert_pt_dynamic(Elf32_Dyn const *dynp, u32_t headway)
|
||||
unsigned const *const buckets = (unsigned const *)&bitmask[n_bitmask];
|
||||
unsigned const *const hasharr = &buckets[n_bucket]; (void)hasharr;
|
||||
if (!n_bucket || (1u<<31) <= n_bucket /* fie on fuzzers */
|
||||
|| (void const *)&file_image[file_size] <= (void const *)hasharr) {
|
||||
|| (unsigned)(gashend - buckets) < n_bucket
|
||||
|| (file_size + file_image) <= (void const *)hasharr) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad n_bucket %#x\n", n_bucket);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
// It would be better to detect zeroes shifted into low 5 bits of:
|
||||
// (037 & (hash_32 >> gnu_shift))
|
||||
// but compilers can be stupid.
|
||||
if (31 < gnu_shift) {
|
||||
throwCantPack("bad gnu_shift %#x", gnu_shift);
|
||||
}
|
||||
// unsigned const *const gashend = &hasharr[n_bucket];
|
||||
// minimum, except:
|
||||
// Rust and Android trim unused zeroes from high end of hasharr[]
|
||||
@@ -2342,7 +2366,7 @@ Elf64_Shdr *PackLinuxElf64::elf_find_section_type(
|
||||
|
||||
char const *PackLinuxElf64::get_str_name(unsigned st_name, unsigned symnum) const
|
||||
{
|
||||
if (strtab_end <= st_name) {
|
||||
if (strtab_max <= st_name) {
|
||||
char msg[70]; snprintf(msg, sizeof(msg),
|
||||
"bad .st_name %#x in DT_SYMTAB[%d]", st_name, symnum);
|
||||
throwCantPack(msg);
|
||||
@@ -2352,7 +2376,7 @@ char const *PackLinuxElf64::get_str_name(unsigned st_name, unsigned symnum) cons
|
||||
|
||||
char const *PackLinuxElf64::get_dynsym_name(unsigned symnum, unsigned relnum) const
|
||||
{
|
||||
if (symnum_end <= symnum) {
|
||||
if (symnum_max <= symnum) {
|
||||
char msg[70]; snprintf(msg, sizeof(msg),
|
||||
"bad symnum %#x in Elf64_Rel[%d]", symnum, relnum);
|
||||
throwCantPack(msg);
|
||||
@@ -2379,7 +2403,7 @@ bool PackLinuxElf64::calls_crt1(Elf64_Rela const *rela, int sz)
|
||||
|
||||
char const *PackLinuxElf32::get_str_name(unsigned st_name, unsigned symnum) const
|
||||
{
|
||||
if (strtab_end <= st_name) {
|
||||
if (strtab_max <= st_name) {
|
||||
char msg[70]; snprintf(msg, sizeof(msg),
|
||||
"bad .st_name %#x in DT_SYMTAB[%d]\n", st_name, symnum);
|
||||
throwCantPack(msg);
|
||||
@@ -2389,7 +2413,7 @@ char const *PackLinuxElf32::get_str_name(unsigned st_name, unsigned symnum) cons
|
||||
|
||||
char const *PackLinuxElf32::get_dynsym_name(unsigned symnum, unsigned relnum) const
|
||||
{
|
||||
if (symnum_end <= symnum) {
|
||||
if (symnum_max <= symnum) {
|
||||
char msg[70]; snprintf(msg, sizeof(msg),
|
||||
"bad symnum %#x in Elf32_Rel[%d]\n", symnum, relnum);
|
||||
throwCantPack(msg);
|
||||
@@ -2419,6 +2443,9 @@ tribool PackLinuxElf32::canUnpack() // bool, except -1: format known, but not pa
|
||||
if (checkEhdr(&ehdri)) {
|
||||
return false;
|
||||
}
|
||||
if (get_te16(&ehdri.e_phnum) < 2) {
|
||||
throwCantUnpack("e_phnum must be >= 2");
|
||||
}
|
||||
if (Elf32_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
||||
PackLinuxElf32help1(fi);
|
||||
}
|
||||
@@ -2965,6 +2992,9 @@ tribool PackLinuxElf64::canUnpack() // bool, except -1: format known, but not pa
|
||||
if (checkEhdr(&ehdri)) {
|
||||
return false;
|
||||
}
|
||||
if (get_te16(&ehdri.e_phnum) < 2) {
|
||||
throwCantUnpack("e_phnum must be >= 2");
|
||||
}
|
||||
if (Elf64_Ehdr::ET_DYN==get_te16(&ehdri.e_type)) {
|
||||
PackLinuxElf64help1(fi);
|
||||
}
|
||||
@@ -3955,8 +3985,8 @@ void PackLinuxElf32::pack1(OutputFile * /*fo*/, Filter &ft)
|
||||
phdr = phdri;
|
||||
for (unsigned j=0; j < e_phnum; ++phdr, ++j) {
|
||||
unsigned const type = get_te32(&phdr->p_type);
|
||||
if (PT_NOTE32 == type) {
|
||||
unsigned const len = get_te32(&phdr->p_filesz);
|
||||
if (PT_NOTE32 == type && len && note_body.getSize()) {
|
||||
fi->seek(get_te32(&phdr->p_offset), SEEK_SET);
|
||||
fi->readx(¬e_body[note_size], len);
|
||||
note_size += up4(len);
|
||||
@@ -4002,10 +4032,9 @@ void PackLinuxElf32::pack1(OutputFile * /*fo*/, Filter &ft)
|
||||
if (opt->o_unix.preserve_build_id) {
|
||||
// set this so we can use elf_find_section_name
|
||||
e_shnum = get_te16(&ehdri.e_shnum);
|
||||
MemBuffer mb_shdri;
|
||||
if (!shdri) {
|
||||
mb_shdri.alloc(e_shnum * sizeof(Elf32_Shdr));
|
||||
shdri = (Elf32_Shdr *)mb_shdri.getVoidPtr();
|
||||
mb_shdr.alloc(e_shnum * sizeof(Elf32_Shdr));
|
||||
shdri = (Elf32_Shdr *)mb_shdr.getVoidPtr();
|
||||
e_shoff = get_te32(&ehdri.e_shoff);
|
||||
fi->seek(e_shoff, SEEK_SET);
|
||||
fi->readx(shdri, e_shnum * sizeof(Elf32_Shdr));
|
||||
@@ -4892,10 +4921,9 @@ void PackLinuxElf64::pack1(OutputFile * /*fo*/, Filter &ft)
|
||||
if (opt->o_unix.preserve_build_id) {
|
||||
// set this so we can use elf_find_section_name
|
||||
e_shnum = get_te16(&ehdri.e_shnum);
|
||||
MemBuffer mb_shdri;
|
||||
if (!shdri) {
|
||||
mb_shdri.alloc(e_shnum * sizeof(Elf64_Shdr));
|
||||
shdri = (Elf64_Shdr *)mb_shdri.getVoidPtr();
|
||||
mb_shdr.alloc(e_shnum * sizeof(Elf64_Shdr));
|
||||
shdri = (Elf64_Shdr *)mb_shdr.getVoidPtr();
|
||||
e_shoff = get_te64(&ehdri.e_shoff);
|
||||
fi->seek(e_shoff, SEEK_SET);
|
||||
fi->readx(shdri, e_shnum * sizeof(Elf64_Shdr));
|
||||
@@ -5098,7 +5126,7 @@ int PackLinuxElf32::pack2(OutputFile *fo, Filter &ft)
|
||||
fo->seek(x.offset, SEEK_SET);
|
||||
fo->write(&file_image[x.offset], x.size);
|
||||
total_out += x.size;
|
||||
// Kepp the input side in sync
|
||||
// Keep the input side in sync
|
||||
total_in += x.size;
|
||||
fi->seek(x.size + x.offset, SEEK_SET);
|
||||
}
|
||||
@@ -5356,7 +5384,7 @@ int PackLinuxElf64::pack2(OutputFile *fo, Filter &ft)
|
||||
fo->seek(x.offset, SEEK_SET);
|
||||
fo->write(&file_image[x.offset], x.size);
|
||||
total_out += x.size;
|
||||
// Kepp the input side in sync
|
||||
// Keep the input side in sync
|
||||
total_in += x.size;
|
||||
fi->seek(x.size + x.offset, SEEK_SET);
|
||||
}
|
||||
@@ -6306,7 +6334,7 @@ PackLinuxElf64::un_asl_dynsym( // ibuf has the input
|
||||
// un-Relocate dynsym (DT_SYMTAB) which is below xct_off
|
||||
dynstr = (char const *)elf_find_dynamic(Elf64_Dyn::DT_STRTAB);
|
||||
sec_dynsym = elf_find_section_type(Elf64_Shdr::SHT_DYNSYM);
|
||||
if (sec_dynsym) {
|
||||
if (dynstr && sec_dynsym) {
|
||||
upx_uint64_t const off_dynsym = get_te64(&sec_dynsym->sh_offset);
|
||||
upx_uint64_t const sz_dynsym = get_te64(&sec_dynsym->sh_size);
|
||||
if (orig_file_size < sz_dynsym
|
||||
@@ -6347,7 +6375,7 @@ PackLinuxElf32::un_asl_dynsym( // ibuf has the input
|
||||
// un-Relocate dynsym (DT_SYMTAB) which is below xct_off
|
||||
dynstr = (char const *)elf_find_dynamic(Elf32_Dyn::DT_STRTAB);
|
||||
sec_dynsym = elf_find_section_type(Elf32_Shdr::SHT_DYNSYM);
|
||||
if (sec_dynsym) {
|
||||
if (dynstr && sec_dynsym) {
|
||||
upx_uint32_t const off_dynsym = get_te32(&sec_dynsym->sh_offset);
|
||||
upx_uint32_t const sz_dynsym = get_te32(&sec_dynsym->sh_size);
|
||||
if (orig_file_size < sz_dynsym
|
||||
@@ -6455,13 +6483,17 @@ void PackLinuxElf64::un_shlib_1(
|
||||
struct {
|
||||
struct l_info l;
|
||||
struct p_info p;
|
||||
struct b_info b;
|
||||
} hdr;
|
||||
fi->readx(&hdr, sizeof(hdr));
|
||||
if (hdr.l.l_magic != UPX_MAGIC_LE32
|
||||
|| hdr.l.l_lsize != (unsigned)lsize
|
||||
|| hdr.p.p_filesize != ph.u_file_size) {
|
||||
throwCantUnpack("corrupt l_info/p_info");
|
||||
|| get_te16(&hdr.l.l_lsize) != (unsigned)lsize
|
||||
|| get_te32(&hdr.p.p_filesize) != ph.u_file_size
|
||||
|| get_te32(&hdr.b.sz_unc) < sz_elf_hdrs // peek: 1st b_info covers Elf headers
|
||||
) {
|
||||
throwCantUnpack("corrupt l_info/p_info/b_info");
|
||||
}
|
||||
fi->seek(-(off_t)sizeof(struct b_info), SEEK_CUR); // hdr.b_info was a peek
|
||||
|
||||
// The default layout for a shared library created by binutils-2.29
|
||||
// (Fedora 28; 2018) has two PT_LOAD: permissions r-x and rw-.
|
||||
@@ -6651,13 +6683,17 @@ void PackLinuxElf32::un_shlib_1(
|
||||
struct {
|
||||
struct l_info l;
|
||||
struct p_info p;
|
||||
struct b_info b;
|
||||
} hdr;
|
||||
fi->readx(&hdr, sizeof(hdr));
|
||||
if (hdr.l.l_magic != UPX_MAGIC_LE32
|
||||
|| hdr.l.l_lsize != (unsigned)lsize
|
||||
|| hdr.p.p_filesize != ph.u_file_size) {
|
||||
throwCantUnpack("corrupt l_info/p_info");
|
||||
|| get_te16(&hdr.l.l_lsize) != (unsigned)lsize
|
||||
|| get_te32(&hdr.p.p_filesize) != ph.u_file_size
|
||||
|| get_te32(&hdr.b.sz_unc) < sz_elf_hdrs // peek: 1st b_info covers Elf headers
|
||||
) {
|
||||
throwCantUnpack("corrupt l_info/p_info/b_info");
|
||||
}
|
||||
fi->seek(-(off_t)sizeof(struct b_info), SEEK_CUR); // hdr.b_info was a peek
|
||||
|
||||
// The default layout for a shared library created by binutils-2.29
|
||||
// (Fedora 28; 2018) has two PT_LOAD: permissions r-x and rw-.
|
||||
@@ -7160,7 +7196,10 @@ void PackLinuxElf64::unpack(OutputFile *fo)
|
||||
upx_uint64_t old_dtinit = 0;
|
||||
|
||||
if (Elf64_Ehdr::ET_EXEC == get_te16(&ehdri.e_type)) {
|
||||
if (get_te64(&ehdri.e_entry) < 0x401180
|
||||
// 40fddf17153ee3db73a04ff1bf288b91676138d6 2001-02-01 ph.version 11; b_info 12 bytes
|
||||
// df9db96bd1c013c07da1d7ec740021d588ab2815 2001-01-17 ph.version 11; no b_info (==> 8 bytes)
|
||||
if (ph.version <= 11
|
||||
&& get_te64(&ehdri.e_entry) < 0x401180
|
||||
&& get_te16(&ehdri.e_machine)==Elf64_Ehdr::EM_X86_64) {
|
||||
// old style, 8-byte b_info:
|
||||
// sizeof(b_info.sz_unc) + sizeof(b_info.sz_cpr);
|
||||
@@ -7404,7 +7443,8 @@ void PackLinuxElf64::unpack(OutputFile *fo)
|
||||
}
|
||||
}
|
||||
int boff = find_le32(peek_arr, sizeof(peek_arr), size);
|
||||
if (boff < 0) {
|
||||
if (boff < 0
|
||||
|| sizeof(peek_arr) < (boff + sizeof(b_info))) {
|
||||
throwCantUnpack("b_info corrupted");
|
||||
}
|
||||
bp = (b_info *)(void *)&peek_arr[boff];
|
||||
@@ -7870,6 +7910,7 @@ void
|
||||
PackLinuxElf64::sort_DT64_offsets(Elf64_Dyn const *const dynp0)
|
||||
{
|
||||
mb_dt_offsets.alloc(sizeof(unsigned) * sizeof(dt_keys)/sizeof(dt_keys[0]));
|
||||
mb_dt_offsets.clear();
|
||||
dt_offsets = (unsigned *)mb_dt_offsets.getVoidPtr();
|
||||
unsigned n_off = 0, k;
|
||||
for (unsigned j=0; ((k = dt_keys[j]), k); ++j) {
|
||||
@@ -7909,7 +7950,8 @@ PackLinuxElf64::sort_DT64_offsets(Elf64_Dyn const *const dynp0)
|
||||
unsigned PackLinuxElf64::find_dt_ndx(u64_t rva)
|
||||
{
|
||||
unsigned *const dto = (unsigned *)mb_dt_offsets.getVoidPtr();
|
||||
for (unsigned j = 0; dto[j]; ++j) { // linear search of short table
|
||||
unsigned const dto_size = mb_dt_offsets.getSize() / sizeof(*dto);
|
||||
for (unsigned j = 0; j < dto_size && dto[j]; ++j) { // linear search of short table
|
||||
if (rva == dto[j]) {
|
||||
return j;
|
||||
}
|
||||
@@ -7927,6 +7969,9 @@ unsigned PackLinuxElf64::elf_find_table_size(unsigned dt_type, unsigned sh_type)
|
||||
unsigned x_rva;
|
||||
if (dt_type < DT_NUM) {
|
||||
unsigned const x_ndx = dt_table[dt_type];
|
||||
if (!x_ndx) { // no such entry
|
||||
return 0;
|
||||
}
|
||||
x_rva = get_te64(&dynseg[-1+ x_ndx].d_val);
|
||||
}
|
||||
else {
|
||||
@@ -7985,15 +8030,21 @@ PackLinuxElf64::invert_pt_dynamic(Elf64_Dyn const *dynp, upx_uint64_t headway)
|
||||
else if (dt_table[Elf64_Dyn::DT_INIT_ARRAY]) upx_dt_init = Elf64_Dyn::DT_INIT_ARRAY;
|
||||
|
||||
unsigned const z_str = dt_table[Elf64_Dyn::DT_STRSZ];
|
||||
strtab_end = !z_str ? 0 : get_te64(&dynp0[-1+ z_str].d_val);
|
||||
if (!z_str || (u64_t)file_size <= strtab_end) { // FIXME: weak
|
||||
strtab_max = !z_str ? 0 : get_te64(&dynp0[-1+ z_str].d_val);
|
||||
unsigned const z_tab = dt_table[Elf64_Dyn::DT_STRTAB];
|
||||
unsigned const strtab_beg = !z_tab ? 0 : get_te64(&dynp0[-1+ z_tab].d_val);
|
||||
if (!z_str || !z_tab
|
||||
|| (this->file_size - strtab_beg) < strtab_max // strtab overlaps EOF
|
||||
// last string in table must have terminating NUL
|
||||
|| '\0' != ((char *)file_image.getVoidPtr())[-1+ strtab_max + strtab_beg]
|
||||
) {
|
||||
char msg[50]; snprintf(msg, sizeof(msg),
|
||||
"bad DT_STRSZ %#x", strtab_end);
|
||||
"bad DT_STRSZ %#x", strtab_max);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
|
||||
// Find end of DT_SYMTAB
|
||||
symnum_end = elf_find_table_size(
|
||||
symnum_max = elf_find_table_size(
|
||||
Elf64_Dyn::DT_SYMTAB, Elf64_Shdr::SHT_DYNSYM) / sizeof(Elf64_Sym);
|
||||
|
||||
unsigned const x_sym = dt_table[Elf64_Dyn::DT_SYMTAB];
|
||||
@@ -8012,9 +8063,15 @@ PackLinuxElf64::invert_pt_dynamic(Elf64_Dyn const *dynp, upx_uint64_t headway)
|
||||
unsigned const nbucket = get_te32(&hashtab[0]);
|
||||
unsigned const *const buckets = &hashtab[2];
|
||||
unsigned const *const chains = &buckets[nbucket]; (void)chains;
|
||||
if ((unsigned)(file_size - ((char const *)buckets - (char const *)(void const *)file_image))
|
||||
<= sizeof(unsigned)*nbucket ) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad nbucket %#x\n", nbucket);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
|
||||
unsigned const v_sym = !x_sym ? 0 : get_te64(&dynp0[-1+ x_sym].d_val); // UPX_RSIZE_MAX_MEM
|
||||
if ((unsigned)file_size <= nbucket/sizeof(*buckets) // FIXME: weak
|
||||
if ((unsigned)(hashend - buckets) < nbucket
|
||||
|| !v_sym || (unsigned)file_size <= v_sym
|
||||
|| ((v_hsh < v_sym) && (v_sym - v_hsh) < sizeof(*buckets)*(2+ nbucket))
|
||||
) {
|
||||
@@ -8056,11 +8113,18 @@ PackLinuxElf64::invert_pt_dynamic(Elf64_Dyn const *dynp, upx_uint64_t headway)
|
||||
unsigned const *const buckets = (unsigned const *)&bitmask[n_bitmask];
|
||||
unsigned const *const hasharr = &buckets[n_bucket]; (void)hasharr;
|
||||
if (!n_bucket || (1u<<31) <= n_bucket /* fie on fuzzers */
|
||||
|| (void const *)&file_image[file_size] <= (void const *)hasharr) {
|
||||
|| (unsigned)(gashend - buckets) < n_bucket
|
||||
|| (file_size + file_image) <= (void const *)hasharr) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad n_bucket %#x\n", n_bucket);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
// It would be better to detect zeroes shifted into low 6 bits of:
|
||||
// (077 & (hash_32 >> gnu_shift))
|
||||
// but compilers can be stupid.
|
||||
if (31 < gnu_shift) {
|
||||
throwCantPack("bad gnu_shift %#x", gnu_shift);
|
||||
}
|
||||
// unsigned const *const gashend = &hasharr[n_bucket];
|
||||
// minimum, except:
|
||||
// Rust and Android trim unused zeroes from high end of hasharr[]
|
||||
@@ -8153,20 +8217,18 @@ Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
|
||||
unsigned const nbucket = get_te32(&hashtab[0]);
|
||||
unsigned const *const buckets = &hashtab[2];
|
||||
unsigned const *const chains = &buckets[nbucket];
|
||||
if ((unsigned)(file_size - ((char const *)buckets - (char const *)(void const *)file_image))
|
||||
<= sizeof(unsigned)*nbucket ) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad nbucket %#x\n", nbucket);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
if (nbucket) {
|
||||
unsigned const m = elf_hash(name) % nbucket;
|
||||
unsigned nvisit = 0;
|
||||
unsigned si;
|
||||
for (si= get_te32(&buckets[m]); 0!=si; si= get_te32(&chains[si])) {
|
||||
char const *const p= get_dynsym_name(si, (unsigned)-1);
|
||||
if (0==strcmp(name, p)) {
|
||||
return &dynsym[si];
|
||||
}
|
||||
if (nbucket <= ++nvisit) {
|
||||
throwCantPack("circular DT_HASH chain %d\n", si);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8178,7 +8240,10 @@ Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
|
||||
unsigned const *const bitmask = &gashtab[4];
|
||||
unsigned const *const buckets = &bitmask[n_bitmask];
|
||||
unsigned const *const hasharr = &buckets[n_bucket];
|
||||
if ((void const *)&file_image[file_size] <= (void const *)hasharr) {
|
||||
if (31 < gnu_shift) {
|
||||
throwCantPack("bad gnu_shift %#x", gnu_shift);
|
||||
}
|
||||
if ((file_size + file_image) <= (void const *)hasharr) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad n_bucket %#x\n", n_bucket);
|
||||
throwCantPack(msg);
|
||||
@@ -8214,7 +8279,7 @@ Elf32_Sym const *PackLinuxElf32::elf_lookup(char const *name) const
|
||||
return dsp;
|
||||
}
|
||||
} while (++dsp,
|
||||
(char const *)hp < (char const *)&file_image[file_size]
|
||||
((char const *)hp < (char const *)(file_size + file_image))
|
||||
&& 0==(1u& get_te32(hp++)));
|
||||
}
|
||||
}
|
||||
@@ -8235,20 +8300,18 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const
|
||||
unsigned const nbucket = get_te32(&hashtab[0]);
|
||||
unsigned const *const buckets = &hashtab[2];
|
||||
unsigned const *const chains = &buckets[nbucket];
|
||||
if ((unsigned)(file_size - ((char const *)buckets - (char const *)(void const *)file_image))
|
||||
<= sizeof(unsigned)*nbucket ) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad nbucket %#x\n", nbucket);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
if (nbucket) { // -rust-musl can have "empty" hashtab
|
||||
unsigned const m = elf_hash(name) % nbucket;
|
||||
unsigned nvisit = 0;
|
||||
unsigned si;
|
||||
for (si= get_te32(&buckets[m]); 0!=si; si= get_te32(&chains[si])) {
|
||||
char const *const p= get_dynsym_name(si, (unsigned)-1);
|
||||
if (0==strcmp(name, p)) {
|
||||
return &dynsym[si];
|
||||
}
|
||||
if (nbucket <= ++nvisit) {
|
||||
throwCantPack("circular DT_HASH chain %d\n", si);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8261,7 +8324,10 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const
|
||||
unsigned const *const buckets = (unsigned const *)&bitmask[n_bitmask];
|
||||
unsigned const *const hasharr = &buckets[n_bucket];
|
||||
|
||||
if ((void const *)&file_image[file_size] <= (void const *)hasharr) {
|
||||
if (31 < gnu_shift) {
|
||||
throwCantPack("bad gnu_shift %#x", gnu_shift);
|
||||
}
|
||||
if ((file_size + file_image) <= (void const *)hasharr) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad n_bucket %#x\n", n_bucket);
|
||||
throwCantPack(msg);
|
||||
@@ -8323,7 +8389,10 @@ void PackLinuxElf32::unpack(OutputFile *fo)
|
||||
upx_uint32_t old_dtinit = 0;
|
||||
|
||||
if (Elf32_Ehdr::ET_EXEC == get_te16(&ehdri.e_type)) {
|
||||
if (get_te32(&ehdri.e_entry) < 0x401180
|
||||
// 40fddf17153ee3db73a04ff1bf288b91676138d6 2001-02-01 ph.version 11; b_info 12 bytes
|
||||
// df9db96bd1c013c07da1d7ec740021d588ab2815 2001-01-17 ph.version 11; no b_info (==> 8 bytes)
|
||||
if (ph.version <= 11
|
||||
&& get_te32(&ehdri.e_entry) < 0x401180
|
||||
&& get_te16(&ehdri.e_machine)==Elf32_Ehdr::EM_386) {
|
||||
// old style, 8-byte b_info:
|
||||
// sizeof(b_info.sz_unc) + sizeof(b_info.sz_cpr);
|
||||
@@ -8549,7 +8618,7 @@ void PackLinuxElf32::unpack(OutputFile *fo)
|
||||
}
|
||||
}
|
||||
int boff = find_le32(peek_arr, sizeof(peek_arr), size);
|
||||
if (boff < 0) {
|
||||
if (boff < 0 || sizeof(peek_arr) < (sizeof(*bp) + boff)) {
|
||||
throwCantUnpack("b_info corrupted");
|
||||
}
|
||||
bp = (b_info *)(void *)&peek_arr[boff];
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@ public:
|
||||
PackLinuxElf(InputFile *f);
|
||||
virtual ~PackLinuxElf();
|
||||
/*virtual void buildLoader(const Filter *);*/
|
||||
virtual int getVersion() const override { return 14; } // upx-3.96 cannot upack, for instance
|
||||
virtual int getVersion() const override { return 14; } // upx-3.96 cannot unpack, for instance
|
||||
virtual bool canUnpackVersion(int version) const override { return (version >= 11); }
|
||||
virtual tribool canUnpack() override { return super::canUnpack(); } // bool, except -1: format known, but not packed
|
||||
|
||||
@@ -84,8 +84,8 @@ protected:
|
||||
MemBuffer mb_shdr; // Shdr might not be near Phdr
|
||||
MemBuffer mb_dt_offsets; // file offset of various DT_ tables
|
||||
unsigned *dt_offsets; // index by dt_table[]
|
||||
unsigned symnum_end;
|
||||
unsigned strtab_end;
|
||||
unsigned symnum_max;
|
||||
unsigned strtab_max;
|
||||
char const *dynstr; // from DT_STRTAB
|
||||
|
||||
unsigned sz_phdrs; // sizeof Phdr[]
|
||||
|
||||
+10
-1
@@ -382,9 +382,18 @@ PackLinuxI386::buildLinuxLoader(
|
||||
if (bele->isBE()) // big endian - bswap32
|
||||
properties = bswap32(properties);
|
||||
linker->defineSymbol("lzma_properties", properties);
|
||||
|
||||
// These lengths assume only one block (typ. 524288 bytes: 0.5 MiB).
|
||||
// i386 handles more than one block, and computes the lengths
|
||||
// dynamically from struct b_info. Why do others need these?
|
||||
if (linker->findSymbol("lzma_c_len", false)) {
|
||||
// -2 for properties
|
||||
linker->defineSymbol("lzma_c_len", ph.c_len - 2);
|
||||
linker->defineSymbol("lzma_u_len", ph.u_len);
|
||||
}
|
||||
if (linker->findSymbol("lzma_u_len", false)) {
|
||||
linker->defineSymbol("lzma_u_len", ph.c_len);
|
||||
}
|
||||
|
||||
unsigned const stack = getDecompressorWrkmemSize();
|
||||
linker->defineSymbol("lzma_stack_adjust", 0u - stack);
|
||||
}
|
||||
|
||||
+42
-20
@@ -117,7 +117,7 @@ static const Lc_seg_info lc_seg_info[2] = {
|
||||
// > 0 : actual size
|
||||
// < 0 : neg. of minimum size; total must be (0 mod 4) or (0 mod 8)
|
||||
//
|
||||
static const signed char lc_cmd_size[] = {
|
||||
static const upx_int8_t lc_cmd_size[] = {
|
||||
// 2021-12: gcc 11.2.1 does not support 'sizeof' in designated initializer.
|
||||
// 2021-12: gcc 11.2.1 does not support [enum] as designator.
|
||||
// 2021-12: "clang++-10 -std=c++14":
|
||||
@@ -1468,6 +1468,8 @@ umin(unsigned a, unsigned b)
|
||||
return (a <= b) ? a : b;
|
||||
}
|
||||
|
||||
#define MAX_N_CMDS 256
|
||||
|
||||
template <class T>
|
||||
void PackMachBase<T>::unpack(OutputFile *fo)
|
||||
{
|
||||
@@ -1512,6 +1514,9 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
||||
if ((unsigned)file_size < ph.c_len || ph.c_len == 0 || ph.u_len == 0)
|
||||
throwCantUnpack("file header corrupted");
|
||||
ph.method = bhdr.b_method;
|
||||
if (ph.method < M_NRV2B_LE32
|
||||
|| ph.method > M_BZIP2)
|
||||
throwCantUnpack("file header bad method");
|
||||
ph.filter = bhdr.b_ftid;
|
||||
ph.filter_cto = bhdr.b_cto8;
|
||||
|
||||
@@ -1526,7 +1531,7 @@ void PackMachBase<T>::unpack(OutputFile *fo)
|
||||
|| mhdri.filetype != mhdr->filetype)
|
||||
throwCantUnpack("file header corrupted");
|
||||
unsigned const ncmds = mhdr->ncmds;
|
||||
if (!ncmds || 256 < ncmds) { // arbitrary limit
|
||||
if (!ncmds || MAX_N_CMDS < ncmds) { // arbitrary limit
|
||||
char msg[40]; snprintf(msg, sizeof(msg),
|
||||
"bad Mach_header.ncmds = %d", ncmds);
|
||||
throwCantUnpack(msg);
|
||||
@@ -1640,6 +1645,12 @@ tribool PackMachBase<T>::canUnpack()
|
||||
|
||||
unsigned const ncmds = mhdri.ncmds;
|
||||
int headway = (int)mhdri.sizeofcmds;
|
||||
if (!ncmds || MAX_N_CMDS < ncmds || file_size < headway
|
||||
|| headway < 4*4 ) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad Mach_header ncmds=%d sizeofcmds=0x%x", ncmds, headway);
|
||||
throwCantUnpack(msg);
|
||||
}
|
||||
// old style: LC_SEGMENT + LC_UNIXTHREAD [smaller, varies by $ARCH]
|
||||
// new style: 3*LC_SEGMENT + LC_MAIN [larger]
|
||||
if ((2 == ncmds
|
||||
@@ -1673,11 +1684,20 @@ tribool PackMachBase<T>::canUnpack()
|
||||
unsigned const cmd = ptr->cmd;
|
||||
unsigned const cmdsize = ptr->cmdsize;
|
||||
if (is_bad_linker_command(cmd, cmdsize, headway, lc_seg, sizeof(Addr))) {
|
||||
infoWarning("bad Mach_command[%u]{@0x%zx,+0x%x}: file_size=0x%lx cmdsize=0x%lx",
|
||||
opt->info_mode += 1;
|
||||
infoWarning("bad Mach_command[%u]{@0x%zx,+0x%x}=0x%x: file_size=0x%lx cmdsize=0x%lx",
|
||||
j, (sizeof(mhdri) + ((char const *)ptr - (char const *)rawmseg)), headway,
|
||||
(unsigned long) file_size, (unsigned long)ptr->cmdsize);
|
||||
cmd, (unsigned long) file_size, (unsigned long)ptr->cmdsize);
|
||||
opt->info_mode -= 1;
|
||||
throwCantUnpack("file corrupted");
|
||||
}
|
||||
headway -= cmdsize;
|
||||
if (headway < 0) {
|
||||
infoWarning("Mach_command[%u]{@%lu}.cmdsize = %u", j,
|
||||
(unsigned long) (sizeof(mhdri) + mhdri.sizeofcmds - (headway + ptr->cmdsize)),
|
||||
(unsigned)ptr->cmdsize);
|
||||
throwCantUnpack("sum(.cmdsize) exceeds .sizeofcmds");
|
||||
}
|
||||
if (lc_seg == ptr->cmd) {
|
||||
Mach_segment_command const *const segptr = (Mach_segment_command const *)ptr;
|
||||
if ((unsigned long)file_size < segptr->filesize
|
||||
@@ -1713,12 +1733,6 @@ tribool PackMachBase<T>::canUnpack()
|
||||
}
|
||||
}
|
||||
pos_next = segptr->filesize + segptr->fileoff;
|
||||
if ((headway -= ptr->cmdsize) < 0) {
|
||||
infoWarning("Mach_command[%u]{@%lu}.cmdsize = %u", j,
|
||||
(unsigned long) (sizeof(mhdri) + mhdri.sizeofcmds - (headway + ptr->cmdsize)),
|
||||
(unsigned)ptr->cmdsize);
|
||||
throwCantUnpack("sum(.cmdsize) exceeds .sizeofcmds");
|
||||
}
|
||||
}
|
||||
else if (Mach_command::LC_UNIXTHREAD==ptr->cmd) {
|
||||
rip = entryVMA = threadc_getPC(ptr);
|
||||
@@ -1948,8 +1962,8 @@ tribool PackMachBase<T>::canPack()
|
||||
my_cpusubtype = mhdri.cpusubtype;
|
||||
|
||||
unsigned const ncmds = mhdri.ncmds;
|
||||
if (!ncmds || 256 < ncmds) { // arbitrary, but guard against garbage
|
||||
throwCantPack("256 < Mach_header.ncmds");
|
||||
if (!ncmds || MAX_N_CMDS < ncmds) { // arbitrary, but guard against garbage
|
||||
throwCantPack("%d < Mach_header.ncmds", MAX_N_CMDS);
|
||||
}
|
||||
unsigned const sz_mhcmds = (unsigned)mhdri.sizeofcmds;
|
||||
unsigned headway = umin(sz_mhcmds, file_size - sizeof(mhdri));
|
||||
@@ -1973,9 +1987,10 @@ tribool PackMachBase<T>::canPack()
|
||||
unsigned const cmd = segptr->cmd &~ LC_REQ_DYLD;
|
||||
unsigned const cmdsize = segptr->cmdsize;
|
||||
if (is_bad_linker_command(cmd, cmdsize, headway, lc_seg, sizeof(Addr))) {
|
||||
char buf[80]; snprintf(buf, sizeof(buf),
|
||||
"bad Mach_command[%d]{cmd=%#x, size=%#x}", j,
|
||||
cmd, cmdsize);
|
||||
char buf[200]; snprintf(buf, sizeof(buf),
|
||||
"bad Mach_command[%u]{@0x%zx,+0x%x}=0x%x: file_size=0x%lx cmdsize=0x%x",
|
||||
j, (sizeof(mhdri) + ((char const *)segptr - (char const *)rawmseg)), headway,
|
||||
cmd, (unsigned long) file_size, cmdsize);
|
||||
throwCantPack(buf);
|
||||
}
|
||||
headway -= cmdsize;
|
||||
@@ -2229,17 +2244,19 @@ tribool PackMachBase<T>::canPack()
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if !defined(DEBUG)
|
||||
// disable macOS packing in Release builds until we do support macOS 13+
|
||||
// disable macOS packing until we do support macOS 13+
|
||||
// https://github.com/upx/upx/issues/612
|
||||
if (my_cputype == CPU_TYPE_X86_64 || my_cputype == CPU_TYPE_ARM64)
|
||||
if (!opt->darwin_macho.force_macos)
|
||||
if (my_cputype == CPU_TYPE_X86_64 || my_cputype == CPU_TYPE_ARM64) {
|
||||
bool force = opt->darwin_macho.force_macos || is_envvar_true("UPX_DEBUG_FORCE_PACK_MACOS");
|
||||
if (!force)
|
||||
throwCantPack("macOS is currently not supported (try --force-macos)");
|
||||
#endif
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// instantiate instances
|
||||
template class PackMachBase<MachClass_BE32>;
|
||||
// template class PackMachBase<MachClass_BE64>; // currently not used
|
||||
template class PackMachBase<MachClass_LE32>;
|
||||
template class PackMachBase<MachClass_LE64>;
|
||||
|
||||
@@ -2263,6 +2280,11 @@ unsigned PackMachFat::check_fat_head()
|
||||
}
|
||||
for (unsigned j=0; j < nfat; ++j) {
|
||||
unsigned const align = arch[j].align;
|
||||
if (24 < align) {
|
||||
char msg[80]; snprintf(msg, sizeof(msg),
|
||||
"bad fat_arch alignment 0x%x > 24", align);
|
||||
throwCantPack(msg);
|
||||
}
|
||||
unsigned const mask = ~(~0u<<align);
|
||||
unsigned const size = arch[j].size;
|
||||
unsigned const offset = arch[j].offset;
|
||||
|
||||
+8
-1
@@ -24,7 +24,6 @@
|
||||
<jreiser@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// Use the preprocessor to work around
|
||||
// - that the types embedding these enums have to be PODs, and
|
||||
@@ -33,6 +32,10 @@
|
||||
// - that older compilers do not correctly perform EBCO
|
||||
**************************************************************************/
|
||||
|
||||
#if CLANG_FORMAT_DUMMY_CLASS
|
||||
class Dummy {
|
||||
#endif
|
||||
|
||||
#ifdef WANT_MACH_HEADER_ENUM /*{*/
|
||||
#undef WANT_MACH_HEADER_ENUM
|
||||
enum : unsigned { // magic
|
||||
@@ -168,4 +171,8 @@
|
||||
};
|
||||
#endif /*}*/
|
||||
|
||||
#if CLANG_FORMAT_DUMMY_CLASS
|
||||
}; // class
|
||||
#endif
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+1
-3
@@ -75,9 +75,7 @@ static const CLANG_FORMAT_DUMMY_STATEMENT
|
||||
**************************************************************************/
|
||||
|
||||
PackPs1::PackPs1(InputFile *f)
|
||||
: super(f), isCon(!opt->ps1_exe.boot_only), is32Bit(!opt->ps1_exe.do_8bit), buildPart2(0),
|
||||
foundBss(0), sa_cnt(0), overlap(0), sz_lunc(0), sz_lcpr(0), pad_code(0), bss_start(0),
|
||||
bss_end(0) {
|
||||
: super(f), isCon(!opt->ps1_exe.boot_only), is32Bit(!opt->ps1_exe.do_8bit) {
|
||||
bele = &N_BELE_RTP::le_policy;
|
||||
|
||||
COMPILE_TIME_ASSERT(sizeof(ps1_exe_t) == 136)
|
||||
|
||||
+12
-12
@@ -108,20 +108,20 @@ protected:
|
||||
LE16 hi2, op3, lo2, op4;
|
||||
};
|
||||
|
||||
ps1_exe_t ih, oh;
|
||||
ps1_exe_hb_t bh;
|
||||
ps1_exe_t ih = {}, oh = {};
|
||||
ps1_exe_hb_t bh = {};
|
||||
|
||||
bool isCon;
|
||||
bool is32Bit;
|
||||
bool buildPart2;
|
||||
bool foundBss;
|
||||
unsigned ram_size;
|
||||
unsigned sa_cnt, overlap;
|
||||
unsigned sz_lunc, sz_lcpr;
|
||||
unsigned pad_code;
|
||||
unsigned bss_start, bss_end;
|
||||
bool isCon = false;
|
||||
bool is32Bit = false;
|
||||
bool buildPart2 = false;
|
||||
bool foundBss = false;
|
||||
unsigned ram_size = 0;
|
||||
unsigned sa_cnt = 0, overlap = 0;
|
||||
unsigned sz_lunc = 0, sz_lcpr = 0;
|
||||
unsigned pad_code = 0;
|
||||
unsigned bss_start = 0, bss_end = 0;
|
||||
// filesize-PS_HDR_SIZE
|
||||
unsigned fdata_size;
|
||||
unsigned fdata_size = 0;
|
||||
};
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ protected:
|
||||
byte ___[12]; // esp,numfixups,flags
|
||||
LE32 relocsize;
|
||||
};
|
||||
tmt_header_t ih, oh;
|
||||
tmt_header_t ih = {}, oh = {};
|
||||
};
|
||||
|
||||
/* vim:set ts=4 sw=4 et: */
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ protected:
|
||||
BE16 fh_reloc;
|
||||
};
|
||||
|
||||
tos_header_t ih, oh;
|
||||
tos_header_t ih = {}, oh = {};
|
||||
|
||||
// symbols for buildLoader()
|
||||
struct LinkerSymbols {
|
||||
|
||||
+19
-6
@@ -481,7 +481,7 @@ unsigned PackUnix::unpackExtent(unsigned wanted, OutputFile *fo,
|
||||
int const sz_cpr = ph.c_len = get_te32(&hdr.sz_cpr);
|
||||
ph.filter_cto = hdr.b_cto8;
|
||||
|
||||
if (sz_unc == 0) { // must never happen while 0!=wanted
|
||||
if (sz_unc == 0 || M_LZMA < hdr.b_method) {
|
||||
throwCantUnpack("corrupt b_info");
|
||||
break;
|
||||
}
|
||||
@@ -491,8 +491,10 @@ unsigned PackUnix::unpackExtent(unsigned wanted, OutputFile *fo,
|
||||
throwCantUnpack("corrupt b_info");
|
||||
|
||||
// place the input for overlapping de-compression
|
||||
// FIXME: inlen cheats OVERHEAD; assumes small wanted peek length
|
||||
int j = inlen + blocksize + OVERHEAD - sz_cpr;
|
||||
int j = inlen + sz_unc + OVERHEAD - sz_cpr;
|
||||
if (ibuf.getSize() < (unsigned)(j + sz_cpr)) {
|
||||
throwCantUnpack("corrupt b_info");
|
||||
}
|
||||
fi->readx(ibuf+j, sz_cpr);
|
||||
total_in += sz_cpr;
|
||||
// update checksum of compressed data
|
||||
@@ -581,7 +583,7 @@ int PackUnix::find_overlay_offset(MemBuffer const &buf)
|
||||
return false;
|
||||
|
||||
int l = ph.buf_offset + ph.getPackHeaderSize();
|
||||
if (l < 0 || l + 4 > bufsize)
|
||||
if (l < 0 || i + l + 4 > bufsize)
|
||||
throwCantUnpack("file corrupted");
|
||||
overlay_offset = get_te32(buf + i + l);
|
||||
if ((off_t)overlay_offset >= file_size)
|
||||
@@ -597,6 +599,8 @@ int PackUnix::find_overlay_offset(MemBuffer const &buf)
|
||||
// See notes there.
|
||||
**************************************************************************/
|
||||
|
||||
static unsigned umax(unsigned a, unsigned b) {return (a < b) ? b : a;}
|
||||
|
||||
void PackUnix::unpack(OutputFile *fo)
|
||||
{
|
||||
b_info bhdr;
|
||||
@@ -617,10 +621,15 @@ void PackUnix::unpack(OutputFile *fo)
|
||||
fi->readx(&hbuf, sizeof(hbuf));
|
||||
orig_file_size = get_te32(&hbuf.p_filesize);
|
||||
blocksize = get_te32(&hbuf.p_blocksize);
|
||||
off_t max_inflated = file_size * 273; // zlib limit (256 + 16 + 1)
|
||||
|
||||
if (file_size > (off_t)orig_file_size || blocksize > orig_file_size)
|
||||
if (max_inflated < orig_file_size
|
||||
|| max_inflated < blocksize
|
||||
|| file_size > (off_t)orig_file_size
|
||||
|| blocksize > orig_file_size) {
|
||||
throwCantUnpack("file header corrupted");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// skip 4 bytes (program id)
|
||||
@@ -658,7 +667,11 @@ void PackUnix::unpack(OutputFile *fo)
|
||||
if (sz_cpr > sz_unc || sz_unc > blocksize)
|
||||
throwCompressedDataViolation();
|
||||
|
||||
i = blocksize + OVERHEAD - sz_cpr;
|
||||
// Compressed output has control bytes such as the 32-bit
|
||||
// first flag bits of NRV_d32, the 5-byte info of LZMA, etc.
|
||||
// Fuzzers may try sz_cpr shorter than possible.
|
||||
// Use some OVERHEAD for safety.
|
||||
i = blocksize + OVERHEAD - umax(12, sz_cpr);
|
||||
if (i < 0)
|
||||
throwCantUnpack("corrupt b_info");
|
||||
fi->readx(buf+i, sz_cpr);
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define ALLOW_INT_PLUS_MEMBUFFER 1
|
||||
#include "conf.h"
|
||||
|
||||
#include "file.h"
|
||||
@@ -1239,7 +1240,7 @@ Linker* PackVmlinuxAMD64::newLinker() const
|
||||
|
||||
// instantiate instances
|
||||
template class PackVmlinuxBase<ElfClass_BE32>;
|
||||
// template class PackVmlinuxBase<ElfClass_BE64>; // not used
|
||||
// template class PackVmlinuxBase<ElfClass_BE64>; // currently not used
|
||||
template class PackVmlinuxBase<ElfClass_LE32>;
|
||||
template class PackVmlinuxBase<ElfClass_LE64>;
|
||||
|
||||
|
||||
+6
-2
@@ -267,7 +267,7 @@ int PackVmlinuzI386::decompressKernel()
|
||||
fd_pos = -1;
|
||||
// open
|
||||
fi->seek(gzoff, SEEK_SET);
|
||||
fd = dup(fi->getFd());
|
||||
fd = fi->dupFd();
|
||||
if (fd < 0)
|
||||
break;
|
||||
gzFile zf = gzdopen(fd, "rb");
|
||||
@@ -599,8 +599,12 @@ void PackBvmlinuzI386::pack(OutputFile *fo)
|
||||
properties = bswap32(properties);
|
||||
linker->defineSymbol("lzma_properties", properties);
|
||||
// -2 for properties
|
||||
if (linker->findSymbol("lzma_c_len", false)) {
|
||||
linker->defineSymbol("lzma_c_len", ph.c_len - 2);
|
||||
}
|
||||
if (linker->findSymbol("lzma_u_len", false)) {
|
||||
linker->defineSymbol("lzma_u_len", ph.u_len);
|
||||
}
|
||||
unsigned const stack = getDecompressorWrkmemSize();
|
||||
linker->defineSymbol("lzma_stack_adjust", 0u - stack);
|
||||
}
|
||||
@@ -849,7 +853,7 @@ int PackVmlinuzARMEL::decompressKernel()
|
||||
fd_pos = -1;
|
||||
// open
|
||||
fi->seek(gzoff, SEEK_SET);
|
||||
fd = dup(fi->getFd());
|
||||
fd = fi->dupFd();
|
||||
if (fd < 0)
|
||||
break;
|
||||
gzFile zf = gzdopen(fd, "rb");
|
||||
|
||||
@@ -235,7 +235,8 @@ void PackW32PeI386::defineSymbols(unsigned ncsection, unsigned upxsection, unsig
|
||||
|
||||
void PackW32PeI386::addNewRelocations(Reloc &rel, unsigned upxsection) {
|
||||
if (use_stub_relocs)
|
||||
rel.add(upxsection + linker->getSymbolOffset("PESOCREL") + 1, 3);
|
||||
rel.add_reloc(upxsection + linker->getSymbolOffset("PESOCREL") + 1,
|
||||
IMAGE_REL_BASED_HIGHLOW);
|
||||
}
|
||||
|
||||
void PackW32PeI386::setOhDataBase(const pe_section_t *osection) { oh.database = osection[2].vaddr; }
|
||||
|
||||
@@ -203,9 +203,13 @@ void PackW64PeAmd64::defineSymbols(unsigned ncsection, unsigned upxsection, unsi
|
||||
}
|
||||
|
||||
if (M_IS_LZMA(ph.method)) {
|
||||
if (linker->findSymbol("lzma_c_len", false)) {
|
||||
linker->defineSymbol("lzma_c_len", ph.c_len - 2);
|
||||
}
|
||||
if (linker->findSymbol("lzma_u_len", false)) {
|
||||
linker->defineSymbol("lzma_u_len", ph.u_len);
|
||||
}
|
||||
}
|
||||
linker->defineSymbol("filter_buffer_start", ih.codebase - rvamin);
|
||||
|
||||
// in case of overlapping decompression, this hack is needed,
|
||||
|
||||
@@ -743,6 +743,7 @@ tribool PackWcle::canUnpack() {
|
||||
return readPackHeader(len) ? 1 : -1;
|
||||
}
|
||||
|
||||
/*static*/
|
||||
void PackWcle::virt2rela(const le_object_table_entry_t *entr, unsigned *objn, unsigned *addr) {
|
||||
for (; *objn > 1; objn[0]--) {
|
||||
if (entr[*objn - 1].my_base_address > *addr)
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ void PackWinCeArm::addNewRelocations(Reloc &rel, unsigned upxsection) {
|
||||
for (unsigned s2r = 0; s2r < TABLESIZE(symbols_to_relocate); s2r++) {
|
||||
unsigned off = linker->getSymbolOffset(symbols_to_relocate[s2r]);
|
||||
if (off != 0xdeaddead)
|
||||
rel.add(off + upxsection, 3);
|
||||
rel.add_reloc(off + upxsection, IMAGE_REL_BASED_HIGHLOW);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+13
-36
@@ -57,9 +57,9 @@ void Packer::assertPacker() const {
|
||||
assert(getVersion() >= 11);
|
||||
assert(getVersion() <= 14);
|
||||
assert(strlen(getName()) <= 15);
|
||||
// info: 36 is the limit for show_all_packers() in help.cpp, but 32 should be enough
|
||||
assert(strlen(getFullName(opt)) <= 32);
|
||||
// info: 36 is the limit for show_all_packers() in help.cpp, but 32 should be enough for now
|
||||
assert(strlen(getFullName(nullptr)) <= 32);
|
||||
assert(strlen(getFullName(opt)) <= 32);
|
||||
if (bele == nullptr)
|
||||
fprintf(stderr, "%s\n", getName());
|
||||
assert(bele != nullptr);
|
||||
@@ -469,33 +469,10 @@ unsigned Packer::getRandomId() const {
|
||||
if (opt->debug.disable_random_id)
|
||||
return 0x01020304;
|
||||
unsigned id = 0;
|
||||
#if 0 && defined(__unix__)
|
||||
// Don't consume precious bytes from /dev/urandom.
|
||||
int fd = open("/dev/urandom", O_RDONLY | O_BINARY);
|
||||
if (fd < 0)
|
||||
fd = open("/dev/random", O_RDONLY | O_BINARY);
|
||||
if (fd >= 0) {
|
||||
if (read(fd, &id, 4) != 4)
|
||||
id = 0;
|
||||
close(fd);
|
||||
}
|
||||
#endif
|
||||
while (id == 0) {
|
||||
#if !(HAVE_GETTIMEOFDAY) || ((ACC_OS_DOS32) && defined(__DJGPP__))
|
||||
id ^= (unsigned) time(nullptr);
|
||||
id ^= ((unsigned) clock()) << 12;
|
||||
#else
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nullptr);
|
||||
id ^= (unsigned) tv.tv_sec;
|
||||
id ^= ((unsigned) tv.tv_usec) << 12; // shift into high-bits
|
||||
#endif
|
||||
#if HAVE_GETPID
|
||||
id ^= (unsigned) getpid();
|
||||
#endif
|
||||
id ^= (unsigned) fi->st.st_ino;
|
||||
id ^= (unsigned) fi->st.st_atime;
|
||||
id ^= (unsigned) rand();
|
||||
id ^= (unsigned) upx_rand();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
@@ -947,10 +924,10 @@ int Packer::prepareMethods(int *methods, int ph_method, const int *all_methods)
|
||||
}
|
||||
// debug
|
||||
if (opt->debug.use_random_method && nmethods >= 2) {
|
||||
int method = methods[rand() % nmethods];
|
||||
int method = methods[upx_rand() % nmethods];
|
||||
NO_printf("\nuse_random_method = %#x (%d)\n", method, nmethods);
|
||||
methods[0] = method;
|
||||
nmethods = 1;
|
||||
NO_printf("\nuse_random_method = %d\n", method);
|
||||
}
|
||||
return nmethods;
|
||||
}
|
||||
@@ -1015,12 +992,12 @@ done:
|
||||
filters[nfilters++] = 0;
|
||||
// debug
|
||||
if (opt->debug.use_random_filter && nfilters >= 3 && filters[nfilters - 1] == 0) {
|
||||
int filter_id = filters[rand() % (nfilters - 1)];
|
||||
int filter_id = filters[upx_rand() % (nfilters - 1)];
|
||||
if (filter_id > 0) {
|
||||
NO_printf("\nuse_random_filter = %#x (%d)\n", filter_id, nfilters - 1);
|
||||
filters[0] = filter_id;
|
||||
filters[1] = 0;
|
||||
nfilters = 2;
|
||||
NO_printf("\nuse_random_filter = %d\n", filter_id);
|
||||
}
|
||||
}
|
||||
return nfilters;
|
||||
@@ -1054,14 +1031,14 @@ void Packer::compressWithFilters(byte *i_ptr,
|
||||
assert(orig_ft.id == 0);
|
||||
|
||||
// prepare methods and filters
|
||||
int methods[256];
|
||||
int methods[MAX_METHODS];
|
||||
int nmethods = prepareMethods(methods, ph.method, getCompressionMethods(M_ALL, ph.level));
|
||||
assert(nmethods > 0);
|
||||
assert(nmethods < 256);
|
||||
int filters[256];
|
||||
assert_noexcept(nmethods > 0);
|
||||
assert_noexcept(nmethods < (int) MAX_METHODS);
|
||||
int filters[MAX_FILTERS];
|
||||
int nfilters = prepareFilters(filters, filter_strategy, getFilters());
|
||||
assert(nfilters > 0);
|
||||
assert(nfilters < 256);
|
||||
assert_noexcept(nfilters > 0);
|
||||
assert_noexcept(nfilters < (int) MAX_FILTERS);
|
||||
#if 0
|
||||
printf("compressWithFilters: m(%d):", nmethods);
|
||||
for (int i = 0; i < nmethods; i++)
|
||||
|
||||
+7
-3
@@ -36,7 +36,7 @@ class UiPacker;
|
||||
class Filter;
|
||||
|
||||
/*************************************************************************
|
||||
// PackerBase: purely abstract minimal base class for all packers
|
||||
// PackerBase: abstract minimal base class for all packers
|
||||
//
|
||||
// clients: PackMaster, UiPacker
|
||||
**************************************************************************/
|
||||
@@ -76,11 +76,15 @@ public:
|
||||
virtual void doList() = 0;
|
||||
virtual void doFileInfo() = 0;
|
||||
|
||||
// arbitrary limits, increase as needed
|
||||
static constexpr unsigned MAX_METHODS = 8; // for getCompressionMethods()
|
||||
static constexpr unsigned MAX_FILTERS = 16; // for getFilters()
|
||||
|
||||
protected:
|
||||
InputFile *const fi; // reference
|
||||
union { // unnamed union
|
||||
const upx_int64_t file_size; // must get set by constructor
|
||||
const upx_uint64_t file_size_u; // (explicitly unsigned to avoid casts)
|
||||
const upx_uint64_t file_size_u; // (explicitly unsigned to avoid -Wsign-compare casts)
|
||||
};
|
||||
PackHeader ph; // must be filled by canUnpack(); also used by UiPacker
|
||||
};
|
||||
@@ -245,7 +249,7 @@ protected:
|
||||
unsigned image_size, int bits, bool bswap);
|
||||
|
||||
// TE - Target Endianness abstraction
|
||||
#if 0
|
||||
#if !(DEBUG)
|
||||
// permissive version using "void *"
|
||||
inline unsigned get_te16(const void *p) const noexcept { return bele->get16(p); }
|
||||
inline unsigned get_te32(const void *p) const noexcept { return bele->get32(p); }
|
||||
|
||||
+7
-5
@@ -33,10 +33,8 @@
|
||||
// compression method util
|
||||
**************************************************************************/
|
||||
|
||||
/*static*/ bool Packer::isValidCompressionMethod(int method) {
|
||||
if (M_IS_LZMA(method))
|
||||
return true;
|
||||
return method >= M_NRV2B_LE32 && method <= M_LZMA;
|
||||
/*static*/ bool Packer::isValidCompressionMethod(int m) {
|
||||
return M_IS_LZMA(m) || M_IS_NRV2B(m) || M_IS_NRV2D(m) || M_IS_NRV2E(m);
|
||||
}
|
||||
|
||||
const int *Packer::getDefaultCompressionMethods_8(int method, int level, int small) const {
|
||||
@@ -219,7 +217,7 @@ const char *Packer::getDecompressorSections() const {
|
||||
"LZMA_ELF00,LZMA_DEC20,LZMA_DEC30";
|
||||
// clang-format on
|
||||
|
||||
unsigned const method = ph_forced_method(ph.method);
|
||||
const unsigned method = ph_forced_method(ph.method);
|
||||
if (method == M_NRV2B_LE32)
|
||||
return opt->small ? nrv2b_le32_small : nrv2b_le32_fast;
|
||||
if (method == M_NRV2D_LE32)
|
||||
@@ -264,8 +262,12 @@ void Packer::defineDecompressorSymbols() {
|
||||
|
||||
linker->defineSymbol("lzma_properties", properties);
|
||||
// len - 2 because of properties
|
||||
if (linker->findSymbol("lzma_c_len", false)) {
|
||||
linker->defineSymbol("lzma_c_len", ph.c_len - 2);
|
||||
}
|
||||
if (linker->findSymbol("lzma_u_len", false)) {
|
||||
linker->defineSymbol("lzma_u_len", ph.u_len);
|
||||
}
|
||||
unsigned stack = getDecompressorWrkmemSize();
|
||||
linker->defineSymbol("lzma_stack_adjust", 0u - stack);
|
||||
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@
|
||||
|
||||
/*************************************************************************
|
||||
// sort and delta-compress relocations with optional bswap within image
|
||||
// returns number of bytes written to 'out'
|
||||
// returns number of **bytes** written to 'out'
|
||||
**************************************************************************/
|
||||
|
||||
/*static*/
|
||||
@@ -102,7 +102,7 @@ unsigned Packer::optimizeReloc(unsigned relocnum, SPAN_P(byte) relocs, SPAN_S(by
|
||||
/*************************************************************************
|
||||
// delta-decompress relocations
|
||||
// advances 'in'
|
||||
// allocates 'out' and returns number of relocs written to 'out'
|
||||
// allocates 'out' and returns number of **relocs** written to 'out'
|
||||
**************************************************************************/
|
||||
|
||||
/*static*/
|
||||
@@ -132,7 +132,7 @@ unsigned Packer::unoptimizeReloc(SPAN_S(const byte) & in, MemBuffer &out, SPAN_P
|
||||
upx_adler32(image, image_size));
|
||||
}
|
||||
|
||||
out.alloc(4 * (relocnum + 1)); // one extra entry
|
||||
out.alloc(mem_size(4, relocnum + 1)); // one extra entry
|
||||
SPAN_S_VAR(LE32, relocs, out);
|
||||
|
||||
fix = in;
|
||||
|
||||
+4
-4
@@ -49,7 +49,7 @@ void PackHeader::reset() noexcept {
|
||||
// extremely simple checksum for the header itself (since version 10)
|
||||
**************************************************************************/
|
||||
|
||||
static byte get_packheader_checksum(SPAN_S(const byte) buf, int blen) {
|
||||
static upx_uint8_t get_packheader_checksum(SPAN_S(const byte) buf, int blen) {
|
||||
assert(blen >= 4);
|
||||
assert(get_le32(buf) == UPX_MAGIC_LE32);
|
||||
buf += 4;
|
||||
@@ -58,7 +58,7 @@ static byte get_packheader_checksum(SPAN_S(const byte) buf, int blen) {
|
||||
while (blen-- > 0)
|
||||
c += *buf++;
|
||||
c %= 251;
|
||||
return (byte) c;
|
||||
return (upx_uint8_t) c;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -99,7 +99,7 @@ int PackHeader::getPackHeaderSize() const {
|
||||
**************************************************************************/
|
||||
|
||||
void PackHeader::putPackHeader(SPAN_S(byte) p) const {
|
||||
// NOTE: It is the caller's responsbility to ensure the buffer p has
|
||||
// NOTE: It is the caller's responsibility to ensure the buffer p has
|
||||
// sufficient space for the header.
|
||||
assert(get_le32(p) == UPX_MAGIC_LE32);
|
||||
if (get_le32(p + 4) != UPX_MAGIC2_LE32) {
|
||||
@@ -108,7 +108,7 @@ void PackHeader::putPackHeader(SPAN_S(byte) p) const {
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
int old_chksum = 0;
|
||||
upx_uint8_t old_chksum = 0;
|
||||
|
||||
// the new variable length header
|
||||
if (format < 128) { // little endian
|
||||
|
||||
+7
-3
@@ -49,8 +49,8 @@ struct PackHeader final {
|
||||
// enum { magic = UPX_MAGIC_LE32 };
|
||||
int version;
|
||||
int format; // executable format UPX_F_xxx
|
||||
int method; // compresison method M_xxx
|
||||
int level; // compresison level 1..10
|
||||
int method; // compression method M_xxx
|
||||
int level; // compression level 1..10
|
||||
unsigned u_len;
|
||||
unsigned c_len;
|
||||
unsigned u_adler;
|
||||
@@ -84,10 +84,14 @@ struct PackHeader final {
|
||||
|
||||
// info fields set by Packer::compressWithFilters()
|
||||
unsigned overlap_overhead;
|
||||
|
||||
private: // UPX conventions
|
||||
UPX_CXX_DISABLE_ADDRESS(PackHeader)
|
||||
UPX_CXX_DISABLE_NEW_DELETE(PackHeader)
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
// ph default util functions
|
||||
// PackHeader ph util functions
|
||||
**************************************************************************/
|
||||
|
||||
bool ph_is_forced_method(int method) noexcept; // predicate
|
||||
|
||||
@@ -25,8 +25,6 @@
|
||||
<markus@oberhumer.com> <ezerotven+github@gmail.com>
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include <memory> // std::unique_ptr
|
||||
#include "conf.h"
|
||||
#include "file.h"
|
||||
#include "packmast.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user