1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

src: fix djgpp and musl builds

This commit is contained in:
Markus F.X.J. Oberhumer 2022-10-02 19:42:16 +02:00
parent 7398d8f68f
commit 0f42579e68
6 changed files with 18 additions and 3 deletions

View File

@ -111,6 +111,7 @@ ACC_COMPILE_TIME_ASSERT_HEADER((char)(-1) == 255) // -funsigned-char
#undef snprintf
#undef vsnprintf
#define HAVE_STDINT_H 1
#define ACC_WANT_ACC_INCD_H 1
#define ACC_WANT_ACC_INCE_H 1
#define ACC_WANT_ACC_LIB_H 1
@ -738,7 +739,7 @@ unsigned membuffer_get_size(MemBuffer &mb);
#include "util/xspan.h"
//#define DOCTEST_CONFIG_DISABLE
//#define DOCTEST_CONFIG_DISABLE 1
#include <doctest/parts/doctest_fwd.h>
// util/dt_check.cpp

View File

@ -6085,7 +6085,7 @@ Elf64_Sym const *PackLinuxElf64::elf_lookup(char const *name) const
do {
if (gashend <= hp) {
char msg[120]; snprintf(msg, sizeof(msg),
"bad gnu_hash[%#zx] head=%u",
"bad gnu_hash[%#tx] head=%u",
hp - hasharr, hhead);
throwCantPack(msg);
}

View File

@ -32,6 +32,10 @@
**************************************************************************/
bool upx_doctest_check(int argc, char **argv) {
#if defined(DOCTEST_CONFIG_DISABLE)
UNUSED(argc);
UNUSED(argv);
#else
bool minimal = true; // only show failing tests
bool duration = false; // show timings
bool success = false; // show all tests
@ -66,6 +70,7 @@ bool upx_doctest_check(int argc, char **argv) {
int r = context.run();
if (context.shouldExit() || r != 0)
return false;
#endif
return true;
}

View File

@ -32,6 +32,11 @@
#define DOCTEST_CONFIG_IMPLEMENT
#define DOCTEST_CONFIG_NO_MULTITHREADING
#define DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS
#if defined(__MSDOS__) && defined(__DJGPP__)
#define DOCTEST_CONFIG_NO_POSIX_SIGNALS
#endif
#if !defined(DOCTEST_CONFIG_DISABLE)
#include <doctest/parts/doctest.cpp>
#endif
/* vim:set ts=4 sw=4 et: */

View File

@ -480,6 +480,7 @@ TEST_CASE("Span constness") {
//
**************************************************************************/
#if !defined(DOCTEST_CONFIG_DISABLE)
namespace {
int my_memcmp_v1(SPAN_P(const void) a, SPAN_0(const void) b, size_t n) {
if (b == nullptr)
@ -499,6 +500,7 @@ int my_memcmp_v2(SPAN_P(const char) a, SPAN_0(const char) b, size_t n) {
return memcmp(x, y, n);
}
} // namespace
#endif
TEST_CASE("PtrOrSpan") {
static const char buf[4] = {0, 1, 2, 3};

View File

@ -283,7 +283,9 @@ inline C<T> operator-(const C<T> &a, const LE32 &v) {
template <class T>
typename std::enable_if<sizeof(T) == 1, upx_rsize_t>::type upx_safe_strlen(const C<T> &a) {
// not fully checked, but can require at least 1 byte
return upx_safe_strlen(a.raw_bytes(1));
upx_rsize_t len = upx_safe_strlen(a.raw_bytes(1));
(void) a.raw_bytes(len + 1); // now can do a full check
return len;
}
#endif // UPX_VERSION_HEX