all: minor cleanups, update some comments

This commit is contained in:
Markus F.X.J. Oberhumer 2023-01-13 05:37:28 +01:00
parent 696d0eec64
commit f00667ad7d
7 changed files with 32 additions and 23 deletions

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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 <class T>
inline T *operator-(T *ptr, const BE16 &v) {
return ptr - unsigned(v);
}
template <class T>
inline T *operator+(T *ptr, const BE32 &v) {
return ptr + unsigned(v);
@ -582,13 +582,6 @@ template <class T>
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 <class T>
T *operator+(T *ptr, const BE64 &v);
template <class T>
T *operator-(T *ptr, const BE64 &v);
template <class T>
inline T *operator+(T *ptr, const LE16 &v) {
return ptr + unsigned(v);
@ -597,7 +590,6 @@ template <class T>
inline T *operator-(T *ptr, const LE16 &v) {
return ptr - unsigned(v);
}
template <class T>
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 <class T>
T *operator+(T *ptr, const BE64 &v);
template <class T>
T *operator-(T *ptr, const BE64 &v);
template <class T>
T *operator+(T *ptr, const LE64 &v);
template <class T>
T *operator-(T *ptr, const LE64 &v);

View File

@ -25,6 +25,8 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
// main entry, mostly boring stuff; see work.cpp for actual action
#include "conf.h"
#include "compress.h"
#include "file.h"

View File

@ -25,6 +25,10 @@
<markus@oberhumer.com> <ezerotven+github@gmail.com>
*/
// 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"