CI updates

This commit is contained in:
Markus F.X.J. Oberhumer
2024-05-01 13:11:12 +02:00
parent b0dc483165
commit 8393ded1b3
11 changed files with 136 additions and 46 deletions
+28 -9
View File
@@ -329,6 +329,13 @@ struct TestIntegerWrap {
// 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);
@@ -336,12 +343,19 @@ 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 (...) {
}
@@ -490,13 +504,18 @@ 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);
{
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_STRING, UPX_VERSION_STRING4, 3));
static_assert(mem_eq(UPX_VERSION_DATE_ISO, UPX_VERSION_YEAR, 4));
static_assert(mem_eq(&UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE) - 5], UPX_VERSION_YEAR, 4));
}
if (gitrev[0]) {
size_t revlen = strlen(gitrev);
if (strncmp(gitrev, "ERROR", 5) == 0) {
+6
View File
@@ -105,6 +105,12 @@ 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))
/*************************************************************************
//
**************************************************************************/
+4 -4
View File
@@ -592,7 +592,7 @@ 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);
@@ -846,7 +846,7 @@ void ElfLinkerPpc64le::relocate1(const Relocation *rel, byte *location, upx_uint
// FIXME: displacement overflow?
set_le32(location, (0xfc000003 & get_le32(location)) + (0x03fffffc & value));
} else 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);
@@ -896,7 +896,7 @@ void ElfLinkerPpc64::relocate1(const Relocation *rel, byte *location, upx_uint64
// FIXME: displacement overflow?
set_be32(location, (0xfc000003 & get_be32(location)) + (0x03fffffc & value));
} else 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);
@@ -925,7 +925,7 @@ 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);
+1 -1
View File
@@ -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":
+7
View File
@@ -241,6 +241,13 @@ constexpr bool string_ne(const char *a, const char *b) { return !string_eq(a, b)
constexpr bool string_gt(const char *a, const char *b) { return string_lt(b, a); }
constexpr bool string_le(const char *a, const char *b) { return !string_lt(b, a); }
constexpr bool string_ge(const char *a, const char *b) { return !string_lt(a, b); }
constexpr bool mem_eq(const char *a, const char *b, size_t n) {
return n == 0 || (*a == *b && mem_eq(a + 1, b + 1, n - 1));
}
constexpr bool mem_eq(const unsigned char *a, const unsigned char *b, size_t n) {
return n == 0 || (*a == *b && mem_eq(a + 1, b + 1, n - 1));
}
} // namespace compile_time
/*************************************************************************