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

More portability fixes.

This commit is contained in:
Markus F.X.J. Oberhumer 2007-01-14 12:47:38 +01:00
parent 9c59a5d9b6
commit 6361213e07
12 changed files with 350 additions and 92 deletions

View File

@ -186,14 +186,18 @@ inline void set_le64(void *p, acc_uint64l_t v)
inline int sign_extend(unsigned v, unsigned bits)
{
const unsigned sign_bit = 1u << (bits - 1);
v |= 0u - (v & sign_bit);
v &= sign_bit | (sign_bit - 1);
//v = (v ^ sign_bit) - sign_bit;
v |= 0 - (v & sign_bit);
return (int) v;
}
inline acc_int64l_t sign_extend(acc_uint64l_t v, unsigned bits)
{
const acc_uint64l_t sign_bit = ACC_UINT64_C(1) << (bits - 1);
v |= ACC_UINT64_C(0) - (v & sign_bit);
v &= sign_bit | (sign_bit - 1);
//v = (v ^ sign_bit) - sign_bit;
v |= 0 - (v & sign_bit);
return (acc_int64l_t) v;
}
@ -530,6 +534,7 @@ inline unsigned UPX_MIN(const LE32& a, unsigned b) { return UPX_MIN((unsigned
**************************************************************************/
// for use with qsort()
extern "C" {
int __acc_cdecl_qsort be16_compare(const void *, const void *);
int __acc_cdecl_qsort be24_compare(const void *, const void *);
int __acc_cdecl_qsort be32_compare(const void *, const void *);
@ -546,6 +551,7 @@ int __acc_cdecl_qsort le16_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le24_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le32_compare_signed(const void *, const void *);
int __acc_cdecl_qsort le64_compare_signed(const void *, const void *);
} // extern "C"
// just for testing...

View File

@ -84,13 +84,14 @@ static int convert_errno_from_ucl(int r)
}
extern "C" {
static void wrap_nprogress_ucl(ucl_uint a, ucl_uint b, int state, ucl_voidp user)
{
if (state != -1 && state != 3) return;
upx_callback_p cb = (upx_callback_p) user;
if (cb && cb->nprogress)
cb->nprogress(cb, a, b);
}
}}
/*************************************************************************

View File

@ -104,6 +104,8 @@
# if (_MSC_VER >= 1400)
# pragma warning(disable: 4996) // W1: 'function': was declared deprecated
# endif
#elif (ACC_CC_SUNPROC)
//# pragma error_messages(off,"badargtype2w") // FIXME
#elif (ACC_CC_WATCOMC)
# if (__WATCOMC__ < 1100)
# error "need Watcom C++ 11.0c or newer"
@ -566,15 +568,15 @@ struct OptVar
// optional assignments
template <class T> void oassign(T& self, const T& other) {
template <class T> inline void oassign(T& self, const T& other) {
if (other.is_set) { self.v = other.v; self.is_set += 1; }
}
#if 0
template <class V, class T> void oassign(V& v, const T& other) {
template <class V, class T> inline void oassign(V& v, const T& other) {
if (other.is_set) { v = other.v; }
}
#else
template <class T> void oassign(unsigned& v, const T& other) {
template <class T> inline void oassign(unsigned& v, const T& other) {
if (other.is_set) { v = other.v; }
}
#endif

View File

@ -1321,6 +1321,7 @@ void upx_sanity_check(void)
assert(get_le24_signed(d) == -131329);
assert(get_le32(d) == 0xfcfdfeff);
assert(get_le32_signed(d) == -50462977);
assert(get_le64_signed(d) == ACC_INT64_C(-506097522914230529));
assert(find_be16(d, 2, 0xfffe) == 0);
assert(find_le16(d, 2, 0xfeff) == 0);
assert(find_be32(d, 4, 0xfffefdfc) == 0);
@ -1329,6 +1330,7 @@ void upx_sanity_check(void)
assert(get_be16_signed(d) == 32638);
assert(get_be24_signed(d) == 8355453);
assert(get_be32_signed(d) == 2138996092);
assert(get_be64_signed(d) == ACC_INT64_C(9186918263483431288));
}
#endif
}

View File

@ -2,6 +2,7 @@
This file is part of the UPX executable compressor.
Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
@ -37,7 +38,7 @@
#ifndef __ACC_H_INCLUDED
#define __ACC_H_INCLUDED 1
#define ACC_VERSION 20060823L
#define ACC_VERSION 20070112L
#if defined(__CYGWIN32__) && !defined(__CYGWIN__)
# define __CYGWIN__ __CYGWIN32__
#endif
@ -1169,7 +1170,7 @@ extern "C" {
# define ACC_SIZEOF_LONG_LONG 8
#elif (ACC_ARCH_I386 && (ACC_CC_INTELC && defined(__linux__)))
# define ACC_SIZEOF_LONG_LONG 8
#elif (ACC_ARCH_I386 && (ACC_CC_MWERKS || ACC_CC_PELLESC || ACC_CC_PGI))
#elif (ACC_ARCH_I386 && (ACC_CC_MWERKS || ACC_CC_PELLESC || ACC_CC_PGI || ACC_CC_SUNPROC))
# define ACC_SIZEOF_LONG_LONG 8
#elif (ACC_ARCH_I386 && (ACC_CC_INTELC || ACC_CC_MSC))
# define ACC_SIZEOF___INT64 8
@ -1634,6 +1635,15 @@ extern "C" {
# define ACC_UNUSED_LABEL(l) switch(0) case 1:goto l
# endif
#endif
#if !defined(ACC_DEFINE_UNINITIALIZED_VAR)
# if 0
# define ACC_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
# elif 0 && (ACC_CC_GNUC)
# define ACC_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
# else
# define ACC_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
# endif
#endif
#if !defined(ACC_COMPILE_TIME_ASSERT_HEADER)
# if (ACC_CC_AZTECC || ACC_CC_ZORTECHC)
# define ACC_COMPILE_TIME_ASSERT_HEADER(e) extern int __acc_cta[1-!(e)];
@ -2745,6 +2755,9 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
#if !defined(acc_signo_t)
# define acc_signo_t int
#endif
#if defined(__cplusplus)
extern "C" {
#endif
#if (ACC_BROKEN_CDECL_ALT_SYNTAX)
typedef void __acc_cdecl_sighandler (*acc_sighandler_t)(acc_signo_t);
#elif defined(RETSIGTYPE)
@ -2752,6 +2765,9 @@ typedef RETSIGTYPE (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t);
#else
typedef void (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t);
#endif
#if defined(__cplusplus)
}
#endif
# if defined(ACC_CFG_NO_ACC_UA_H)
# else
#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020700ul))
@ -3164,6 +3180,9 @@ __acc_gnuc_extension__ typedef unsigned long long acc_ullong_t;
#if !defined(acc_signo_t)
# define acc_signo_t int
#endif
#if defined(__cplusplus)
extern "C" {
#endif
#if (ACC_BROKEN_CDECL_ALT_SYNTAX)
typedef void __acc_cdecl_sighandler (*acc_sighandler_t)(acc_signo_t);
#elif defined(RETSIGTYPE)
@ -3171,6 +3190,9 @@ typedef RETSIGTYPE (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t);
#else
typedef void (__acc_cdecl_sighandler *acc_sighandler_t)(acc_signo_t);
#endif
#if defined(__cplusplus)
}
#endif
# if !defined(ACC_CFG_NO_ACC_UA_H)
#if (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020700ul))
#elif (ACC_CC_GNUC && (ACC_CC_GNUC < 0x020800ul)) && defined(__cplusplus)
@ -3968,32 +3990,42 @@ ACCLIB_EXTERN(void, acc_uclock_read) (acc_uclock_handle_p, acc_uclock_p);
ACCLIB_EXTERN(double, acc_uclock_get_elapsed) (acc_uclock_handle_p, const acc_uclock_p, const acc_uclock_p);
#endif
ACCLIB_EXTERN(int, acc_uclock_flush_cpu_cache) (acc_uclock_handle_p, unsigned);
typedef struct {
struct acc_getopt_t;
typedef struct acc_getopt_t acc_getopt_t;
#ifndef acc_getopt_p
#define acc_getopt_p acc_getopt_t *
#endif
struct acc_getopt_longopt_t;
typedef struct acc_getopt_longopt_t acc_getopt_longopt_t;
#ifndef acc_getopt_longopt_p
#define acc_getopt_longopt_p acc_getopt_longopt_t *
#endif
struct acc_getopt_longopt_t {
const char* name;
int has_arg;
int* flag;
int val;
} acc_getopt_longopt_t;
#ifndef acc_getopt_longopt_p
#define acc_getopt_longopt_p acc_getopt_longopt_t *
#endif
typedef struct {
int go_argc;
char** go_argv;
const char* go_shortopts;
const acc_getopt_longopt_p longopts;
#if (ACC_BROKEN_CDECL_ALT_SYNTAX)
int __acc_cdecl_va (*go_error)(const char *, ...);
#else
int (__acc_cdecl_va *go_error)(const char *, ...);
#endif
} acc_getopt_t;
#ifndef acc_getopt_p
#define acc_getopt_p acc_getopt_t *
#endif
ACCLIB_EXTERN(void, acc_getopt_init) (acc_getopt_p);
ACCLIB_EXTERN(int, acc_getopt) (acc_getopt_p);
ACCLIB_EXTERN(void, acc_getopt_close)(acc_getopt_p);
};
struct acc_getopt_t {
void *user;
char *optarg;
void (*opterr)(acc_getopt_p, const char*, void *);
int optind;
int optopt;
int errcount;
const char* progname;
int argc; char** argv;
int eof; int shortpos;
int pending_rotate_first, pending_rotate_middle;
};
enum { ACC_GETOPT_NO_ARG, ACC_GETOPT_REQUIRED_ARG, ACC_GETOPT_OPTIONAL_ARG, ACC_GETOPT_EXACT_ARG = 0x10 };
enum { ACC_GETOPT_PERMUTE, ACC_GETOPT_RETURN_IN_ORDER, ACC_GETOPT_REQUIRE_ORDER };
ACCLIB_EXTERN(void, acc_getopt_init) (acc_getopt_p g,
int start_argc, int argc, char** argv);
ACCLIB_EXTERN(int, acc_getopt) (acc_getopt_p g,
const char* shortopts,
const acc_getopt_longopt_p longopts,
int* longind);
typedef struct {
acc_uint32l_t seed;
} acc_rand31_t;
@ -5245,6 +5277,213 @@ ACCLIB_PUBLIC(int, acc_dos_free) (void __far* p)
}
#endif
#endif
#if defined(ACC_WANT_ACCLIB_GETOPT)
# undef ACC_WANT_ACCLIB_GETOPT
#define __ACCLIB_GETOPT_CH_INCLUDED 1
#if !defined(ACCLIB_PUBLIC)
# define ACCLIB_PUBLIC(r,f) r __ACCLIB_FUNCNAME(f)
#endif
ACCLIB_PUBLIC(void, acc_getopt_init) (acc_getopt_p g,
int start_argc, int argc, char** argv)
{
memset(g, 0, sizeof(*g));
g->argc = argc;
g->argv = argv;
g->pending_rotate_first = g->pending_rotate_middle = g->optind = start_argc;
}
static int __ACCLIB_FUNCNAME(acc_getopt_rotate) (char **p, int first, int middle, int last)
{
char** a; char** b;
if (first >= middle || middle >= last) return 0;
for (a = p + first, b = p + middle - 1; a < b; ++a, --b) {
char* t = *a; *a = *b; *b = t;
}
for (a = p + middle, b = p + last - 1; a < b; ++a, --b) {
char* t = *a; *a = *b; *b = t;
}
for (a = p + first, b = p + last - 1; a < b; ++a, --b) {
char* t = *a; *a = *b; *b = t;
}
return middle - first;
}
static int __acc_getopt_x(acc_getopt_p g, int ret, int oo, int flags, const char *f, ...)
{
if (oo >= 0)
g->optopt = oo;
if (flags & 1)
{
if (g->shortpos == 0)
g->optind++;
else if (!g->argv[g->optind][++g->shortpos])
g->optind++, g->shortpos = 0;
}
if (f == NULL)
return ret;
if (g->opterr)
{
#if !defined(HAVE_STDARG_H)
g->opterr(g, f, NULL);
#else
va_list ap;
va_start(ap, f);
g->opterr(g, f, &ap);
va_end(ap);
#endif
}
g->errcount++;
return ret;
}
ACCLIB_PUBLIC(int, acc_getopt) (acc_getopt_p g,
const char* shortopts,
const acc_getopt_longopt_p longopts,
int* longind)
{
int ordering = ACC_GETOPT_PERMUTE;
char *a;
int has_arg = 0;
char *arg;
unsigned char sc;
int i;
if (shortopts && (*shortopts == '-' || *shortopts == '+'))
ordering = *shortopts++ == '-' ? ACC_GETOPT_RETURN_IN_ORDER : ACC_GETOPT_REQUIRE_ORDER;
g->optarg = NULL;
g->optopt = '?';
if (longind != NULL)
*longind = -1;
if (g->eof || g->optind >= g->argc || g->argv == NULL)
goto acc_label_eof;
if (g->shortpos)
goto acc_label_next_shortopt;
g->optind -= __ACCLIB_FUNCNAME(acc_getopt_rotate)(g->argv, g->pending_rotate_first, g->pending_rotate_middle, g->optind);
g->pending_rotate_first = g->pending_rotate_middle = g->optind;
if (ordering == ACC_GETOPT_PERMUTE)
{
while (g->optind < g->argc && !(g->argv[g->optind][0] == '-' && g->argv[g->optind][1]))
g->optind++;
g->pending_rotate_middle = g->optind;
}
if (g->optind >= g->argc)
{
g->optind = g->pending_rotate_first;
acc_label_eof:
g->optind -= __ACCLIB_FUNCNAME(acc_getopt_rotate)(g->argv, g->pending_rotate_first, g->pending_rotate_middle, g->optind);
g->pending_rotate_first = g->pending_rotate_middle = g->optind;
g->eof = 1;
return -1;
}
a = g->argv[g->optind];
if (strcmp(a, "--") == 0)
{
g->optind++;
goto acc_label_eof;
}
if (!(a[0] == '-' && a[1]))
{
if (ordering == ACC_GETOPT_REQUIRE_ORDER)
goto acc_label_eof;
if (ordering == ACC_GETOPT_RETURN_IN_ORDER)
{
g->optarg = a;
g->optind++;
return 1;
}
__acc_getopt_x(g, -1, -1, 0, "invalid ordering %d", ordering);
goto acc_label_eof;
}
if (a[1] == '-')
{
const acc_getopt_longopt_p lo = NULL;
size_t match_chars;
for (arg = a + 2; *arg && *arg != '=' && *arg != '#'; )
++arg;
match_chars = (size_t) (arg - (a + 2));
for (i = 0; longopts && longopts[i].name; ++i)
{
size_t n = match_chars;
size_t l = strlen(longopts[i].name);
if (longopts[i].has_arg & ACC_GETOPT_EXACT_ARG) n = l;
if (strncmp(a, longopts[i].name, n) != 0)
continue;
if (match_chars == l)
{
lo = &longopts[i];
break;
}
else if (lo == NULL)
lo = &longopts[i];
else
return __acc_getopt_x(g, '?', 0, 1, "option '%s' is ambiguous (could be '--%s' or '--%s')",
a, lo->name, longopts[i].name);
}
if (lo == NULL)
return __acc_getopt_x(g, '?', 0, 1, "unrecognized option '%s'", a);
switch (lo->has_arg & 0x2f)
{
case ACC_GETOPT_OPTIONAL_ARG:
break;
case ACC_GETOPT_REQUIRED_ARG:
if (*arg)
g->optarg = arg + 1;
else if (g->optind + 1 < g->argc)
g->optarg = g->argv[++g->optind];
else
return __acc_getopt_x(g, '?', 0, 1, "option '%s' requires an argument", lo->name);
g->optind++;
break;
case ACC_GETOPT_REQUIRED_ARG | 0x20:
break;
default:
if (*arg)
return __acc_getopt_x(g, '?', lo->val, 1, "option '%s' doesn't allow an argument", lo->name);
g->optind++;
break;
}
if (longind != NULL)
*longind = (int) (lo - longopts);
if (lo->flag != NULL)
{
*lo->flag = lo->val;
return 0;
}
return lo->val;
}
else
{
const char *sp;
g->shortpos = 1;
acc_label_next_shortopt:
a = g->argv[g->optind] + g->shortpos;
sp = NULL; sc = (unsigned char) *a;
if (shortopts)
sp = strchr(shortopts, sc);
if (!sp)
return __acc_getopt_x(g, '?', sc, 1, "invalid option '-%c'", sc);
if (sp[1] == ':') { has_arg++; if (sp[2] == ':') has_arg++; }
arg = a + 1;
switch (has_arg)
{
case ACC_GETOPT_OPTIONAL_ARG:
if (*arg)
g->optarg = arg + 1;
g->optind++, g->shortpos = 0;
break;
case ACC_GETOPT_REQUIRED_ARG:
if (*arg)
g->optarg = arg + 1;
else if (g->optind + 1 < g->argc)
g->optarg = g->argv[++g->optind];
else
return __acc_getopt_x(g, '?', 0, 1, "option '-%c' requires an argument", sc);
g->optind++, g->shortpos = 0;
break;
default:
__acc_getopt_x(g, 0, -1, 1, NULL);
break;
}
return sc;
}
}
#endif
#if defined(ACC_WANT_ACCLIB_HALLOC)
# undef ACC_WANT_ACCLIB_HALLOC
#define __ACCLIB_HALLOC_CH_INCLUDED 1
@ -6161,7 +6400,7 @@ ACCLIB_PUBLIC(acclib_handle_t, acc_get_osfhandle) (int fd)
}
ACCLIB_PUBLIC(int, acc_set_binmode) (int fd, int binary)
{
#if (ACC_ARCH_M68K && ACC_OS_TOS && defined(__MINT__))
#if (ACC_ARCH_M68K && ACC_OS_TOS && ACC_CC_GNUC) && defined(__MINT__)
FILE* fp; int old_binary;
if (fd == STDIN_FILENO) fp = stdin;
else if (fd == STDOUT_FILENO) fp = stdout;

View File

@ -41,15 +41,15 @@
EI_DATA = 5, /* Data encoding */
EI_VERSION = 6,
EI_OSABI = 7,
EI_ABIVERSION = 8,
EI_ABIVERSION = 8
};
enum { // e_ident[EI_CLASS]
ELFCLASS32 = 1, /* 32-bit objects */
ELFCLASS64 = 2, /* 64-bit objects */
ELFCLASS64 = 2 /* 64-bit objects */
};
enum { // e_ident[EI_DATA]
ELFDATA2LSB = 1, /* 2's complement, little endian */
ELFDATA2MSB = 2, /* 2's complement, big endian */
ELFDATA2MSB = 2 /* 2's complement, big endian */
};
enum { // e_ident[EI_OSABI]
ELFOSABI_NONE = 0, // == ELFOSABI_SYSV
@ -57,24 +57,24 @@
ELFOSABI_LINUX = 3,
ELFOSABI_FREEBSD = 9,
ELFOSABI_OPENBSD = 12,
ELFOSABI_ARM = 97,
ELFOSABI_ARM = 97
};
enum { // e_type
ET_NONE = 0, /* No file type */
ET_REL = 1, /* Relocatable file */
ET_EXEC = 2, /* Executable file */
ET_DYN = 3, /* Shared object file */
ET_CORE = 4, /* Core file */
ET_CORE = 4 /* Core file */
};
enum { // e_machine
EM_386 = 3,
EM_PPC = 20,
EM_PPC64 = 21,
EM_ARM = 40,
EM_X86_64 = 62,
EM_X86_64 = 62
};
enum { // e_version
EV_CURRENT = 1,
EV_CURRENT = 1
};
#endif
@ -86,13 +86,13 @@
PT_DYNAMIC = 2, /* Dynamic linking information */
PT_INTERP = 3, /* Name of program interpreter */
PT_NOTE = 4, /* Auxiliary information (esp. OpenBSD) */
PT_PHDR = 6, /* Entry for header table itself */
PT_PHDR = 6 /* Entry for header table itself */
};
enum { // p_flags
PF_X = 1, /* Segment is executable */
PF_W = 2, /* Segment is writable */
PF_R = 4, /* Segment is readable */
PF_R = 4 /* Segment is readable */
};
#endif
@ -118,7 +118,7 @@
SHT_PREINIT_ARRAY = 16, /* Array of pre-constructors */
SHT_GROUP = 17, /* Section group */
SHT_SYMTAB_SHNDX = 18, /* Extended section indeces */
SHT_GNU_LIBLIST = 0x6ffffff7, /* Prelink library list */
SHT_GNU_LIBLIST = 0x6ffffff7 /* Prelink library list */
};
enum { // sh_flags
@ -128,7 +128,7 @@
SHF_MERGE = (1 << 4), /* Might be merged */
SHF_STRINGS = (1 << 5), /* Contains nul-terminated strings */
SHF_INFO_LINK = (1 << 6), /* 'sh_info' contains SHT index */
SHF_LINK_ORDER = (1 << 7), /* Preserve order after combining */
SHF_LINK_ORDER = (1 << 7) /* Preserve order after combining */
};
#endif
@ -141,7 +141,7 @@
DT_HASH = 4, /* Hash table of symbol names */
DT_STRTAB = 5, /* String table */
DT_SYMTAB = 6, /* Symbol table */
DT_STRSZ = 10, /* Sizeof string table */
DT_STRSZ = 10 /* Sizeof string table */
};
#endif
@ -151,7 +151,7 @@
enum { // st_bind (high 4 bits of st_info)
STB_LOCAL = 0, /* Local symbol */
STB_GLOBAL = 1, /* Global symbol */
STB_WEAK = 2, /* Weak symbol */
STB_WEAK = 2 /* Weak symbol */
};
enum { // st_type (low 4 bits of st_info)
@ -161,20 +161,20 @@
STT_SECTION = 3, /* Symbol associated with a section */
STT_FILE = 4, /* Symbol's name is file name */
STT_COMMON = 5, /* Symbol is a common data object */
STT_TLS = 6, /* Symbol is thread-local data object*/
STT_TLS = 6 /* Symbol is thread-local data object*/
};
enum { // st_other (visibility)
STV_DEFAULT = 0, /* Default symbol visibility rules */
STV_INTERNAL = 1, /* Processor specific hidden class */
STV_HIDDEN = 2, /* Sym unavailable in other modules */
STV_PROTECTED= 3, /* Not preemptible, not exported */
STV_PROTECTED= 3 /* Not preemptible, not exported */
};
enum { // st_shndx
SHN_UNDEF = 0, /* Undefined section */
SHN_ABS = 0xfff1, /* Associated symbol is absolute */
SHN_COMMON = 0xfff2, /* Associated symbol is common */
SHN_COMMON = 0xfff2 /* Associated symbol is common */
};
#endif

View File

@ -1056,7 +1056,6 @@ Linker* PackVmlinuxAMD64::newLinker() const
// instantiate instances
template class PackVmlinuxBase<ElfClass_LE32>;
template class PackVmlinuxBase<ElfClass_LE64>;

View File

@ -127,7 +127,7 @@ public:
Ehdr::ELFCLASS32, Ehdr::ELFDATA2LSB, "decompress_kernel") { }
virtual int getFormat() const { return UPX_F_VMLINUX_ARM; }
virtual const char *getName() const { return "vmlinux/ARM"; }
virtual const char *getFullName(const options_t *) const { return "ARM-linux.kernel.vmlinux"; }
virtual const char *getFullName(const options_t *) const { return "arm-linux.kernel.vmlinux"; }
virtual const int *getCompressionMethods(int method, int level) const;
virtual const int *getFilters() const;

View File

@ -1055,30 +1055,40 @@ void Packer::initLoader(const void *pdata, int plen, int small)
linker->addSection("IDENTSTR", ident, size, 0);
}
#if 1 && (ACC_CC_BORLANDC)
#else
void Packer::addLoader(const char *s)
{
if (s)
linker->addLoader(s);
}
#endif
#if 1 && (ACC_CC_BORLANDC)
void __acc_cdecl_va Packer::addLoader(const char *s, ...)
#else
// provide specialization for [T = const char *]
template <>
void __acc_cdecl_va Packer::addLoader<char>(const char *s, ...)
#endif
#define C const char *
void Packer::addLoader(C a)
{ addLoaderVA(a, NULL); }
void Packer::addLoader(C a, C b)
{ addLoaderVA(a, b, NULL); }
void Packer::addLoader(C a, C b, C c)
{ addLoaderVA(a, b, c, NULL); }
void Packer::addLoader(C a, C b, C c, C d)
{ addLoaderVA(a, b, c, d, NULL); }
void Packer::addLoader(C a, C b, C c, C d, C e)
{ addLoaderVA(a, b, c, d, e, NULL); }
void Packer::addLoader(C a, C b, C c, C d, C e, C f)
{ addLoaderVA(a, b, c, d, e, f, NULL); }
void Packer::addLoader(C a, C b, C c, C d, C e, C f, C g)
{ addLoaderVA(a, b, c, d, e, f, g, NULL); }
void Packer::addLoader(C a, C b, C c, C d, C e, C f, C g, C h)
{ addLoaderVA(a, b, c, d, e, f, g, h, NULL); }
void Packer::addLoader(C a, C b, C c, C d, C e, C f, C g, C h, C i)
{ addLoaderVA(a, b, c, d, e, f, g, h, i, NULL); }
void Packer::addLoader(C a, C b, C c, C d, C e, C f, C g, C h, C i, C j)
{ addLoaderVA(a, b, c, d, e, f, g, h, i, j, NULL); }
#undef C
void __acc_cdecl_va Packer::addLoaderVA(const char *s, ...)
{
va_list ap;
const char *t = s;
va_start(ap, s);
while (s != NULL)
while (t != NULL)
{
linker->addLoader(s);
s = va_arg(ap, const char *);
linker->addLoader(t);
t = va_arg(ap, const char *);
}
va_end(ap);
}

View File

@ -226,14 +226,17 @@ protected:
virtual upx_byte *getLoader() const;
virtual int getLoaderSize() const;
virtual void initLoader(const void *pdata, int plen, int small=-1);
#if 1 && (ACC_CC_BORLANDC)
void __acc_cdecl_va addLoader(const char *, ...);
#elif 1 && (ACC_CC_GNUC >= 0x040100)
void addLoader(const char *);
template <class T> void __acc_cdecl_va addLoader(const T *, ...) __attribute__((__sentinel__));
#define C const char *
void addLoader(C); void addLoader(C,C); void addLoader(C,C,C);
void addLoader(C,C,C,C); void addLoader(C,C,C,C,C);
void addLoader(C,C,C,C,C,C); void addLoader(C,C,C,C,C,C,C);
void addLoader(C,C,C,C,C,C,C,C); void addLoader(C,C,C,C,C,C,C,C,C);
void addLoader(C,C,C,C,C,C,C,C,C,C);
#undef C
#if 1 && (ACC_CC_GNUC >= 0x040100)
void __acc_cdecl_va addLoaderVA(const char *s, ...) __attribute__((__sentinel__));
#else
void addLoader(const char *);
template <class T> void __acc_cdecl_va addLoader(const T *, ...);
void __acc_cdecl_va addLoaderVA(const char *s, ...);
#endif
virtual int getLoaderSection(const char *name, int *slen=NULL) const;
virtual int getLoaderSectionStart(const char *name, int *slen=NULL) const;
@ -309,13 +312,6 @@ private:
};
#if 1 && (ACC_CC_BORLANDC)
#else
template <>
void __acc_cdecl_va Packer::addLoader<char>(const char *, ...);
#endif
#endif /* already included */

View File

@ -83,9 +83,12 @@
#undef NO_FLOAT
#undef LDOUBLE
#if 1
# define NO_FLOAT
# define float error_no_float
# define double error_no_float
# define NO_FLOAT 1
# if (ACC_CC_SUNPROC)
# else
# define float error no_float
# define double error no_float
# endif
#elif 0 || defined(HAVE_LONG_DOUBLE)
# define LDOUBLE long double
#else

View File

@ -271,24 +271,24 @@ void do_files(int i, int argc, char *argv[])
unlink_ofile(oname);
printErr(iname,&e);
e_exit(EXIT_ERROR);
} catch (std::bad_alloc *e) {
unlink_ofile(oname);
printErr(iname,"out of memory");
//delete e;
e_exit(EXIT_ERROR);
} catch (const std::bad_alloc &) {
unlink_ofile(oname);
printErr(iname,"out of memory");
e_exit(EXIT_ERROR);
} catch (std::bad_alloc *e) {
} catch (std::exception *e) {
unlink_ofile(oname);
printErr(iname,"out of memory");
delete e;
printUnhandledException(iname,e);
//delete e;
e_exit(EXIT_ERROR);
} catch (const std::exception &e) {
unlink_ofile(oname);
printUnhandledException(iname,&e);
e_exit(EXIT_ERROR);
} catch (std::exception *e) {
unlink_ofile(oname);
printUnhandledException(iname,e);
delete e;
e_exit(EXIT_ERROR);
} catch (...) {
unlink_ofile(oname);
printUnhandledException(iname,NULL);