From c23c7a9379b8d9f7bce5e4e3927e9441a6954ac0 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Thu, 15 Dec 2022 16:20:22 +0100 Subject: [PATCH] all: minor updates --- .github/workflows/ci.yml | 16 +++++++++++++--- .gitignore | 6 ------ src/conf.h | 9 +++++++++ src/p_lx_elf.cpp | 4 +--- src/p_lx_exc.cpp | 2 -- src/p_tmt.h | 5 +++-- src/p_tos.h | 5 +++-- 7 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9059eaed..f513240d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,7 @@ on: branches: - '*' - '!appveyor*' + - '!gitea*' - '!gitlab*' - '!travis*' workflow_dispatch: @@ -28,13 +29,14 @@ jobs: run: | uname -a; pwd; id; umask cd ..; mkdir -p deps; cd deps; mkdir packages - # for ubuntu-22.04: install python2 + # for ubuntu-22.04: install python2-minimal ##export DEBIAN_FRONTEND=noninteractive - ##sudo apt-get install -y --no-install-recommends python2-minimal + ##sudo apt-get update && sudo apt-get install -y --no-install-recommends python2-minimal # manually install compat libs from Ubuntu 16.04 wget -q 'http://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 wget -q -O - https://github.com/upx/upx-stubtools/releases/download/v20221212/bin-upx-20221212.tar.xz | tar -xJ - name: 'Check out code' @@ -43,6 +45,14 @@ jobs: - name: 'Rebuild and verify stubs' run: | env C=gcc X=rebuild-stubs TRAVIS_OS_NAME=linux bash ./.github/travis_build.sh + if ! git diff --quiet; then git diff; exit 1; fi + - name: 'Rebuild and verify stubs v2' + run: | + export PATH="$(readlink -fn ../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 @@ -100,7 +110,7 @@ jobs: matrix: include: - { os: macos-11, gcc: gcc-10, gxx: 'g++-10' } - # { os: macos-12, gcc: gcc-11, gxx: 'g++-11' } # disable gcc - XCode 14.0 ld bug + # { os: macos-12, gcc: gcc-11, gxx: 'g++-11' } # disable gcc - XCode 14.0 ld bug; supposed to be fixed in 14.1 - { os: macos-12 } steps: - name: 'Check out code' diff --git a/.gitignore b/.gitignore index f45dfb8a..ebff394d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,20 +30,14 @@ doc/*.ps doc/*.tex src/stub/**/.*-stamp -src/stub/**/MMakefile src/stub/tmp*/*.bin src/stub/tmp*/*.bin.bindump src/stub/tmp*/*.bin.disasm -src/stub/tmp*/*.d -src/stub/tmp*/*.o src/stub/tmp*/*.o.disasm src/stub/tmp*/mips.r3000-*.[is] src/stub/tmp*/mipsel.r3000-*.[is] src/stub/src/**/tmp*/* -src/stub/tools/armpe/armpe_tester.exe -src/stub/tools/armpe/armpe_tester.out - src/stub/tools/sstrip/amd64-linux-sstrip src/stub/tools/sstrip/i386-linux-sstrip src/stub/tools/sstrip/sstrip diff --git a/src/conf.h b/src/conf.h index a2bcc934..5a9f3b4d 100644 --- a/src/conf.h +++ b/src/conf.h @@ -355,6 +355,15 @@ inline const T& UPX_MAX(const T& a, const T& b) { if (a < b) return b; return a; template inline const T& UPX_MIN(const T& a, const T& b) { if (a < b) return a; return b; } +template +struct USizeOfTypeImpl { + __acc_static_forceinline constexpr unsigned value() { + COMPILE_TIME_ASSERT(TypeSize >= 1 && TypeSize <= 64 * 1024); // arbitrary limit + return ACC_ICONV(unsigned, TypeSize); + } +}; +#define usizeof(type) (USizeOfTypeImpl::value()) +ACC_COMPILE_TIME_ASSERT_HEADER(usizeof(int) == 4) // An Array allocates memory on the heap, and automatically // gets destructed when leaving scope or on exceptions. diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index a6a497e5..0e5c899e 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -62,8 +62,6 @@ unsigned char PackLinuxElf::o_shstrtab[] = { \ /*offset 20*/ '.','s','h','s','t','r','t','a','b','\0' }; -#define usizeof(x) ((unsigned) sizeof(x)) - static unsigned umin(unsigned a, unsigned b) { @@ -5178,7 +5176,7 @@ void PackLinuxElf64::unpack(OutputFile *fo) fi->seek(overlay_offset - sizeof(l_info), SEEK_SET); fi->readx(&linfo, sizeof(linfo)); if (UPX_MAGIC_LE32 != get_le32(&linfo.l_magic)) { - unsigned const *const lp = (unsigned const *)(void const *)&linfo; + NE32 const *const lp = (NE32 const *)(void const *)&linfo; // Workaround for bug of extra linfo by some asl_pack2_Shdrs(). if (0==lp[0] && 0==lp[1] && 0==lp[2]) { // looks like blank extra fi->readx(&linfo, sizeof(linfo)); diff --git a/src/p_lx_exc.cpp b/src/p_lx_exc.cpp index 210f00d1..ce2ff9e2 100644 --- a/src/p_lx_exc.cpp +++ b/src/p_lx_exc.cpp @@ -49,8 +49,6 @@ #define DT_STRSZ Elf32_Dyn::DT_STRSZ #endif -#define usizeof(x) ((unsigned) sizeof(x)) - /************************************************************************* // linux/386 (generic "execve" format) diff --git a/src/p_tmt.h b/src/p_tmt.h index 78d7cdd5..1f2c2018 100644 --- a/src/p_tmt.h +++ b/src/p_tmt.h @@ -25,8 +25,9 @@ */ -#ifndef __UPX_P_TMT_H -#define __UPX_P_TMT_H 1 +#pragma once +#ifndef UPX_P_TMT_H__ +#define UPX_P_TMT_H__ 1 /************************************************************************* // tmt/adam diff --git a/src/p_tos.h b/src/p_tos.h index f9c6d52f..7199ef65 100644 --- a/src/p_tos.h +++ b/src/p_tos.h @@ -25,8 +25,9 @@ */ -#ifndef __UPX_P_TOS_H -#define __UPX_P_TOS_H 1 +#pragma once +#ifndef UPX_P_TOS_H__ +#define UPX_P_TOS_H__ 1 /************************************************************************* // atari/tos