diff --git a/misc/podman/rebuild-stubs/Dockerfile b/misc/podman/rebuild-stubs/Dockerfile index 84a1819a..bbce87ff 100644 --- a/misc/podman/rebuild-stubs/Dockerfile +++ b/misc/podman/rebuild-stubs/Dockerfile @@ -59,9 +59,9 @@ 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 \ + && curl -sS -L -O https://github.com/upx/upx/releases/download/v3.91/upx-3.91-amd64_linux.tar.bz2 \ && 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 4.2.4" \ - && for v in $xzversions; do wget -q https://github.com/upx/upx/releases/download/v${v}/upx-${v}-amd64_linux.tar.xz; done \ + && for v in $xzversions; do curl -sS -L -O 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 $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 \ diff --git a/misc/podman/rebuild-stubs/packages.txt b/misc/podman/rebuild-stubs/packages.txt index 185e9ce4..04d2e0d1 100644 --- a/misc/podman/rebuild-stubs/packages.txt +++ b/misc/podman/rebuild-stubs/packages.txt @@ -144,7 +144,7 @@ ii libgcc-s1:i386 14-20240412-0ubuntu1 i386 ii libgcrypt20:amd64 1.10.3-2build1 amd64 LGPL Crypto library - runtime library ii libgdbm-compat4t64:amd64 1.23-5.1build1 amd64 GNU dbm database routines (legacy support runtime version) ii libgdbm6t64:amd64 1.23-5.1build1 amd64 GNU dbm database routines (runtime version) -ii libglib2.0-0t64:amd64 2.80.0-6ubuntu1 amd64 GLib library of C routines +ii libglib2.0-0t64:amd64 2.80.0-6ubuntu3.1 amd64 GLib library of C routines ii libgmp10:amd64 2:6.3.0+dfsg-2ubuntu6 amd64 Multiprecision arithmetic library ii libgnutls30t64:amd64 3.8.3-1.1ubuntu3.1 amd64 GNU TLS library - main runtime library ii libgomp1:amd64 14-20240412-0ubuntu1 amd64 GCC OpenMP (GOMP) support library @@ -186,7 +186,7 @@ ii libmspack0t64:amd64 0.11-1.1build1 amd64 ii libncurses6:amd64 6.4+20240113-1ubuntu2 amd64 shared libraries for terminal handling ii libncursesw6:amd64 6.4+20240113-1ubuntu2 amd64 shared libraries for terminal handling (wide character support) ii libnettle8t64:amd64 3.9.1-2.2build1 amd64 low level cryptographic library (symmetric and one-way cryptos) -ii libnghttp2-14:amd64 1.59.0-1build4 amd64 library implementing HTTP/2 protocol (shared library) +ii libnghttp2-14:amd64 1.59.0-1ubuntu0.1 amd64 library implementing HTTP/2 protocol (shared library) ii libnl-3-200:amd64 3.7.0-0.3build1 amd64 library for dealing with netlink sockets ii libnl-genl-3-200:amd64 3.7.0-0.3build1 amd64 library for dealing with netlink sockets - generic netlink ii libnpth0t64:amd64 1.6-3.1build1 amd64 replacement for GNU Pth using system threads @@ -361,7 +361,7 @@ ii zstd 1.5.5+dfsg2-2build1 amd64 ||/ Name Version Architecture Description Packages sorted by Installed-Size: - 964659 ===== TOTAL (355 packages) + 964903 ===== TOTAL (355 packages) 76943 valgrind amd64 72249 gcc-13-x86-64-linux-gnu amd64 37841 g++-13-x86-64-linux-gnu amd64 @@ -411,10 +411,10 @@ Packages sorted by Installed-Size: 4879 libhwasan0 amd64 4341 ncurses-term all 4244 minify amd64 + 4193 libglib2.0-0t64 amd64 4103 apt amd64 3983 gojq amd64 3956 python3-pycryptodome amd64 - 3949 libglib2.0-0t64 amd64 3849 libgprofng0 amd64 3806 liblsan0 amd64 3721 groff-base amd64 diff --git a/src/check/dt_check.cpp b/src/check/dt_check.cpp index a1ec68ac..d44eee55 100644 --- a/src/check/dt_check.cpp +++ b/src/check/dt_check.cpp @@ -232,6 +232,7 @@ struct CheckIntegral { checkU::type>(); } }; + template struct CheckAlignment { static void check(void) noexcept { @@ -256,16 +257,17 @@ struct CheckAlignment { UNUSED(t2); } }; + template struct TestBELE { static noinline bool test(void) noexcept { CheckIntegral::check(); CheckAlignment::check(); // arithmetic checks - T allbits = {}; - assert_noexcept(allbits == 0); - allbits += 1; - allbits -= 2; + T all_bits = {}; + assert_noexcept(all_bits == 0); + all_bits += 1; + all_bits -= 2; T v1; v1 = 1; v1 *= 4; @@ -279,7 +281,7 @@ struct TestBELE { assert_noexcept((v1 >= v2)); assert_noexcept(!(v1 < v2)); assert_noexcept(!(v1 > v2)); - v2 ^= allbits; + v2 ^= all_bits; assert_noexcept(!(v1 == v2)); assert_noexcept((v1 != v2)); assert_noexcept((v1 <= v2)); @@ -305,6 +307,25 @@ struct TestBELE { } }; +template +struct CheckSignedness { + template + static inline void checkU(void) noexcept { + COMPILE_TIME_ASSERT(sizeof(U) == sizeof(T)); + COMPILE_TIME_ASSERT(alignof(U) == alignof(T)); + COMPILE_TIME_ASSERT(U_is_signed ? ((U) 0 - 1 < 0) : ((U) 0 - 1 > 0)); + constexpr U all_bits = (U) (U(0) - U(1)); + COMPILE_TIME_ASSERT(U_is_signed ? (all_bits < 0) : (all_bits > 0)); + } + static void check(void) noexcept { + checkU(); + using signed_type = std::make_signed_t; + checkU(); + using unsigned_type = std::make_unsigned_t; + checkU(); + } +}; + template struct TestNoAliasingStruct { static noinline bool test(A *a, B *b) noexcept { @@ -501,12 +522,16 @@ void upx_compiler_sanity_check(void) noexcept { CheckIntegral::check(); CheckIntegral::check(); - COMPILE_TIME_ASSERT(ptrdiff_t(0) - 1 < 0); - COMPILE_TIME_ASSERT(intptr_t(0) - 1 < 0); - COMPILE_TIME_ASSERT(size_t(0) - 1 > 0); - COMPILE_TIME_ASSERT(uintptr_t(0) - 1 > 0); - COMPILE_TIME_ASSERT(upx_ptraddr_t(0) - 1 > 0); - COMPILE_TIME_ASSERT(upx_uintptr_t(0) - 1 > 0); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); + CheckSignedness::check(); COMPILE_TIME_ASSERT(sizeof(upx_charptr_unit_type) == 1) COMPILE_TIME_ASSERT_ALIGNED1(upx_charptr_unit_type) diff --git a/src/conf.h b/src/conf.h index 8c3606a5..c1321a68 100644 --- a/src/conf.h +++ b/src/conf.h @@ -145,7 +145,8 @@ typedef acc_int64_t upx_int64_t; typedef acc_uint64_t upx_uint64_t; typedef acc_uintptr_t upx_uintptr_t; // see CHERI ptraddr_t / vaddr_t -typedef upx_uintptr_t upx_ptraddr_t; +typedef acc_uintptr_t upx_ptraddr_t; +typedef acc_intptr_t upx_sptraddr_t; // UPX convention: use "byte" when dealing with data; use "char/uchar" when dealing // with strings; use "upx_uint8_t" when dealing with small integers diff --git a/src/util/xspan.cpp b/src/util/xspan.cpp index 3807f984..e971996b 100644 --- a/src/util/xspan.cpp +++ b/src/util/xspan.cpp @@ -78,8 +78,7 @@ void xspan_check_range(const void *ptr, const void *base, ptrdiff_t size_in_byte xspan_fail_range_nullbase(); #if defined(__SANITIZE_ADDRESS__) || 1 // info: pointers are out of range deliberately during internal doctest checks; see dt_xspan.cpp - ACC_COMPILE_TIME_ASSERT(sizeof(intptr_t) == sizeof(upx_ptraddr_t)) - const intptr_t off = ptr_get_address(ptr) - ptr_get_address(base); + const upx_sptraddr_t off = ptr_get_address(ptr) - ptr_get_address(base); #else const ptrdiff_t off = (const charptr) ptr - (const charptr) base; #endif