all: misc updates

This commit is contained in:
Markus F.X.J. Oberhumer
2023-05-19 13:21:26 +02:00
parent 40653e40a4
commit 09bd1d8c40
9 changed files with 95 additions and 22 deletions
+13 -5
View File
@@ -498,6 +498,12 @@ static int do_option(int optc, const char *arg) {
case 545:
opt->debug.disable_random_id = true;
break;
case 546:
opt->debug.use_random_method = true;
break;
case 547:
opt->debug.use_random_filter = true;
break;
// misc
case 512:
@@ -806,10 +812,12 @@ int main_get_options(int argc, char **argv) {
// debug options
{"debug", 0x10, N, 'D'},
{"dump-stub-loader", 0x31, N, 544}, // for internal debugging
{"fake-stub-version", 0x31, N, 542}, // for internal debugging
{"fake-stub-year", 0x31, N, 543}, // for internal debugging
{"disable-random-id", 0x10, N, 545}, // for internal debugging
{"dump-stub-loader", 0x31, N, 544}, // for internal debugging
{"fake-stub-version", 0x31, N, 542}, // for internal debugging
{"fake-stub-year", 0x31, N, 543}, // for internal debugging
{"disable-random-id", 0x90, N, 545}, // for internal debugging
{"debug-use-random-method", 0x90, N, 546}, // for internal debugging
{"debug-use-random-filter", 0x90, N, 547}, // for internal debugging
// backup options
{"backup", 0x10, N, 'k'},
@@ -984,7 +992,7 @@ void main_get_envoptions() {
{"verbose", 0, N, 'v'}, // verbose mode
// debug options
{"disable-random-id", 0x10, N, 545}, // for internal debugging
{"disable-random-id", 0x90, N, 545}, // for internal debugging
// backup options
{"backup", 0x10, N, 'k'},
+3 -1
View File
@@ -95,7 +95,9 @@ struct Options final {
const char *dump_stub_loader;
char fake_stub_version[4 + 1]; // for internal debugging
char fake_stub_year[4 + 1]; // for internal debugging
bool getopt_throw_instead_of_exit; // for doctest
bool getopt_throw_instead_of_exit; // for internal doctest checks
bool use_random_method; // for internal debugging
bool use_random_filter; // for internal debugging
} debug;
// overlay handling
+32 -5
View File
@@ -1030,10 +1030,20 @@ int Packer::prepareMethods(int *methods, int ph_method, const int *all_methods)
continue;
if (opt->all_methods && opt->all_methods_use_lzma != 1 && M_IS_LZMA(method))
continue;
// use this method
// check duplicate
assert(Packer::isValidCompressionMethod(method));
for (int i = 0; i < nmethods; i++)
assert(method != methods[i]);
// use this method
methods[nmethods++] = method;
}
// debug
if (opt->debug.use_random_method && nmethods >= 2) {
int method = methods[rand() % nmethods];
methods[0] = method;
nmethods = 1;
NO_printf("\nuse_random_method = %d\n", method);
}
return nmethods;
}
@@ -1073,8 +1083,11 @@ static int prepareFilters(int *filters, int &filter_strategy, const int *all_fil
continue;
if (filter_id == 0)
continue;
// use this filter
// check duplicate
assert(Filter::isValidFilter(filter_id));
for (int i = 0; i < nfilters; i++)
assert(filter_id != filters[i]);
// use this filter
filters[nfilters++] = filter_id;
if (filter_strategy >= 0 && nfilters >= filter_strategy)
break;
@@ -1084,10 +1097,24 @@ done:
// filter_strategy now only means "stop after first successful filter"
filter_strategy = (filter_strategy < 0) ? -1 : 0;
// make sure that we have a "no filter" fallback
bool have_filter0 = false;
for (int i = 0; i < nfilters; i++)
if (filters[i] == 0)
return nfilters;
filters[nfilters++] = 0;
if (filters[i] == 0) {
have_filter0 = true;
break;
}
if (!have_filter0)
filters[nfilters++] = 0;
// debug
if (opt->debug.use_random_filter && nfilters >= 3 && filters[nfilters - 1] == 0) {
int filter_id = filters[rand() % (nfilters - 1)];
if (filter_id > 0) {
filters[0] = filter_id;
filters[1] = 0;
nfilters = 2;
NO_printf("\nuse_random_filter = %d\n", filter_id);
}
}
return nfilters;
}
+1 -1
View File
@@ -42,7 +42,7 @@ unsigned Packer::optimizeReloc(unsigned relocnum, SPAN_P(byte) relocs, SPAN_S(by
ptr_check_no_overlap(relocs.data(), relocs.size_bytes(), image.data(image_size), image_size,
out.data(), out.size_bytes());
#endif
SPAN_P_VAR(byte, fix, out);
SPAN_S_VAR(byte, fix, out);
*big = 0;
if (opt->exact)
+4 -3
View File
@@ -144,6 +144,7 @@ struct XSpan_is_convertible
#endif
#if DEBUG
// need extra parenthesis because the C preprocessor does not understand C++ templates
// char => char
ACC_COMPILE_TIME_ASSERT_HEADER((XSpan_is_convertible<char, char>::value))
ACC_COMPILE_TIME_ASSERT_HEADER((XSpan_is_convertible<char, const char>::value))
@@ -165,9 +166,9 @@ ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible<void, const char>::value))
ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible<const void, const char>::value))
ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible<const void, char>::value))
// char => int
ACC_COMPILE_TIME_ASSERT_HEADER(!(XSpan_is_convertible<char, int>::value))
ACC_COMPILE_TIME_ASSERT_HEADER(!(XSpan_is_convertible<char, const int>::value))
ACC_COMPILE_TIME_ASSERT_HEADER(!(XSpan_is_convertible<const char, const int>::value))
ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible<char, int>::value))
ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible<char, const int>::value))
ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible<const char, const int>::value))
ACC_COMPILE_TIME_ASSERT_HEADER((!XSpan_is_convertible<const char, int>::value))
#endif
+2 -2
View File
@@ -1,8 +1,8 @@
#define UPX_VERSION_HEX 0x040003 /* 04.00.03 */
#define UPX_VERSION_STRING "4.0.3"
#define UPX_VERSION_STRING4 "4.03"
#define UPX_VERSION_DATE "Feb 5th 2023"
#define UPX_VERSION_DATE_ISO "2023-02-05"
#define UPX_VERSION_DATE "May 19th 2023"
#define UPX_VERSION_DATE_ISO "2023-05-19"
#define UPX_VERSION_YEAR "2023"
/* vim:set ts=4 sw=4 et: */