diff --git a/Makefile b/Makefile index 0153f9ea..fa4f8b29 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,12 @@ build/extra/clang-m32/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/clang-m32/%: export CC = clang -m32 build/extra/clang-m32/%: export CXX = clang++ -m32 +# force building with clang/clang++ -mx32 +build/extra/clang-mx32/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/clang-mx32/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/clang-mx32/%: export CC = clang -mx32 +build/extra/clang-mx32/%: export CXX = clang++ -mx32 + # force building with clang/clang++ -m64 build/extra/clang-m64/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/clang-m64/release: PHONY; $(call run_config_and_build,$@,Release) @@ -82,18 +88,18 @@ build/extra/gcc-m32/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/gcc-m32/%: export CC = gcc -m32 build/extra/gcc-m32/%: export CXX = g++ -m32 -# force building with gcc/g++ -m64 -build/extra/gcc-m64/debug: PHONY; $(call run_config_and_build,$@,Debug) -build/extra/gcc-m64/release: PHONY; $(call run_config_and_build,$@,Release) -build/extra/gcc-m64/%: export CC = gcc -m64 -build/extra/gcc-m64/%: export CXX = g++ -m64 - # force building with gcc/g++ -mx32 build/extra/gcc-mx32/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/gcc-mx32/release: PHONY; $(call run_config_and_build,$@,Release) build/extra/gcc-mx32/%: export CC = gcc -mx32 build/extra/gcc-mx32/%: export CXX = g++ -mx32 +# force building with gcc/g++ -m64 +build/extra/gcc-m64/debug: PHONY; $(call run_config_and_build,$@,Debug) +build/extra/gcc-m64/release: PHONY; $(call run_config_and_build,$@,Release) +build/extra/gcc-m64/%: export CC = gcc -m64 +build/extra/gcc-m64/%: export CXX = g++ -m64 + # cross compiler: Linux glibc aarch64-linux-gnu build/extra/cross-linux-aarch64/debug: PHONY; $(call run_config_and_build,$@,Debug) build/extra/cross-linux-aarch64/release: PHONY; $(call run_config_and_build,$@,Release) diff --git a/README.SRC b/README.SRC index 8438a698..31875007 100644 --- a/README.SRC +++ b/README.SRC @@ -44,7 +44,8 @@ Short overview Tools needed to build/modify the UPX sources -------------------------------------------- - - A C++ compiler that supports C++ 17: clang, gcc or msvc + - A C++ compiler that supports C++ 17: clang 5.0, gcc 8.0 or msvc 2019 16.11 + (older or other compilers may work, use at your own risk) - GNU make diff --git a/misc/cross-compile-upx-with-podman/20-image-run-shell.sh b/misc/cross-compile-upx-with-podman/20-image-run-shell.sh index bf97caca..051db536 100755 --- a/misc/cross-compile-upx-with-podman/20-image-run-shell.sh +++ b/misc/cross-compile-upx-with-podman/20-image-run-shell.sh @@ -40,9 +40,9 @@ podman run "${flags[@]}" "$image" bash -l # lots of other cross-compilers are installed; see "ls /usr/bin/*g++*" # and see misc/cross-compile-upx-with-podman/build-all-inside-container.sh; after -# running that script you can do cool things like: +# running that script we can do cool things like: # cd /home/upx/src/upx/build/cross-compile-upx-with-podman/alpha-linux-gnu/debug # qemu-alpha -L /usr/alpha-linux-gnu upx --version # cd /home/upx/src/upx/build/cross-compile-upx-with-podman/hppa-linux-gnu/debug # qemu-hppa -L /usr/hppa-linux-gnu upx --version -# (similar for many other archs) +# (similar for many other archs) diff --git a/misc/rebuild-stubs-with-podman/20-image-run-shell.sh b/misc/rebuild-stubs-with-podman/20-image-run-shell.sh index 1a0787e0..222eacf0 100755 --- a/misc/rebuild-stubs-with-podman/20-image-run-shell.sh +++ b/misc/rebuild-stubs-with-podman/20-image-run-shell.sh @@ -53,7 +53,7 @@ podman run "${flags[@]}" "$image" bash -l # ./build/extra/gcc/release/upx --version # make -C build/extra/gcc/release test -# and we can also rebuild UPX with -m32: +# and we can also build UPX with -m32: # cd /home/upx/src/upx # rm -rf ./build/extra/gcc-m32/release # make build/extra/gcc-m32/release @@ -61,7 +61,7 @@ podman run "${flags[@]}" "$image" bash -l # ./build/extra/gcc-m32/release/upx --version # make -C build/extra/gcc-m32/release test -# and we can also rebuild UPX with -mx32: (NOTE: needs CONFIG_X86_X32_ABI on host kernel!) +# and we can also build UPX with -mx32: (NOTE: needs CONFIG_X86_X32_ABI on host kernel!) # cd /home/upx/src/upx # rm -rf ./build/extra/gcc-mx32/release # make build/extra/gcc-mx32/release diff --git a/src/bele.h b/src/bele.h index 8eaabd4a..21831709 100644 --- a/src/bele.h +++ b/src/bele.h @@ -105,9 +105,7 @@ __acc_static_forceinline constexpr upx_uint64_t bswap64(upx_uint64_t v) { __acc_static_forceinline constexpr unsigned no_bswap16(unsigned v) { return v & 0xffff; // needed so that this is equivalent to bswap16() above } - __acc_static_forceinline constexpr unsigned no_bswap32(unsigned v) { return v; } - __acc_static_forceinline constexpr upx_uint64_t no_bswap64(upx_uint64_t v) { return v; } #if (ACC_ABI_BIG_ENDIAN) @@ -175,10 +173,13 @@ inline unsigned get_le26(const void *p) { return get_le32(p) & 0x03ffffff; } inline void set_le26(void *p, unsigned v) { // preserve the top 6 bits - // set_le32(p, (get_le32(p) & 0xfc000000) | (v & 0x03ffffff)); +#if 0 + set_le32(p, (get_le32(p) & 0xfc000000) | (v & 0x03ffffff)); +#else // optimized version, saving a runtime bswap32 set_ne32(p, (get_ne32(p) & ne32_to_le32(0xfc000000)) | (ne32_to_le32(v) & ne32_to_le32(0x03ffffff))); +#endif } /************************************************************************* @@ -573,7 +574,6 @@ template inline T *operator-(T *ptr, const BE16 &v) { return ptr - unsigned(v); } - template inline T *operator+(T *ptr, const BE32 &v) { return ptr + unsigned(v); @@ -582,13 +582,6 @@ template inline T *operator-(T *ptr, const BE32 &v) { return ptr - unsigned(v); } - -// these are not implemented on purpose and will cause link-time errors -template -T *operator+(T *ptr, const BE64 &v); -template -T *operator-(T *ptr, const BE64 &v); - template inline T *operator+(T *ptr, const LE16 &v) { return ptr + unsigned(v); @@ -597,7 +590,6 @@ template inline T *operator-(T *ptr, const LE16 &v) { return ptr - unsigned(v); } - template inline T *operator+(T *ptr, const LE32 &v) { return ptr + unsigned(v); @@ -609,6 +601,10 @@ inline T *operator-(T *ptr, const LE32 &v) { // these are not implemented on purpose and will cause link-time errors template +T *operator+(T *ptr, const BE64 &v); +template +T *operator-(T *ptr, const BE64 &v); +template T *operator+(T *ptr, const LE64 &v); template T *operator-(T *ptr, const LE64 &v); diff --git a/src/main.cpp b/src/main.cpp index 6c0ccf6b..0c56d707 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,8 @@ */ +// main entry, mostly boring stuff; see work.cpp for actual action + #include "conf.h" #include "compress.h" #include "file.h" diff --git a/src/work.cpp b/src/work.cpp index 86e255ee..b9db3603 100644 --- a/src/work.cpp +++ b/src/work.cpp @@ -25,6 +25,10 @@ */ +// work.cpp implements the central loop, and it uses class PackMaster to +// dispatch. PackMaster by itself will instatiate a concrete subclass +// of Packer which then does the actual work. + #include "conf.h" #include "file.h" #include "packmast.h"