diff --git a/src/Makefile.bld b/src/Makefile.bld index 606e5b04..1baacf56 100644 --- a/src/Makefile.bld +++ b/src/Makefile.bld @@ -329,7 +329,7 @@ ifeq ($(target),bc) o = .obj a = .lib e = .exe -CC = bcc32 -q -6 +CC = bcc32 -q -3 CFLAGS = -w -w-aus -w-inl -g1 CFLAGS_OUTPUT = -o$@ LDFLAGS = -ls diff --git a/src/bele.h b/src/bele.h index c656c84f..26965486 100644 --- a/src/bele.h +++ b/src/bele.h @@ -221,6 +221,7 @@ class BE16 unsigned char d[2]; public: + BE16() { } BE16& operator = (const BE16 &v) { memcpy(d, v.d, sizeof(d)); return *this; } BE16& operator = (unsigned v) { set_be16(d, v); return *this; } @@ -239,6 +240,7 @@ class BE32 unsigned char d[4]; public: + BE32() { } BE32& operator = (const BE32 &v) { memcpy(d, v.d, sizeof(d)); return *this; } BE32& operator = (unsigned v) { set_be32(d, v); return *this; } @@ -257,6 +259,7 @@ class LE16 unsigned char d[2]; public: + LE16() { } LE16& operator = (const LE16 &v) { memcpy(d, v.d, sizeof(d)); return *this; } LE16& operator = (unsigned v) { set_le16(d, v); return *this; } @@ -275,6 +278,7 @@ class LE32 unsigned char d[4]; public: + LE32() { } LE32& operator = (const LE32 &v) { memcpy(d, v.d, sizeof(d)); return *this; } LE32& operator = (unsigned v) { set_le32(d, v); return *this; } diff --git a/src/c_init.cpp b/src/c_init.cpp index a3b310f2..83c64e81 100644 --- a/src/c_init.cpp +++ b/src/c_init.cpp @@ -142,7 +142,7 @@ console_t console_init = }; -void con_fprintf(FILE *f, const char *format, ...) +void __acc_cdecl con_fprintf(FILE *f, const char *format, ...) { va_list args; char buf[80*25]; diff --git a/src/conf.h b/src/conf.h index 97e8b4b3..f7d25c7b 100644 --- a/src/conf.h +++ b/src/conf.h @@ -53,18 +53,18 @@ # if (__BORLANDC__ < 0x550) # error "need Borland C++ 5.5 or newer" # endif -# define __UPX_CDECL __cdecl # if (__BORLANDC__ >= 0x560) # pragma warn -use # endif #elif (ACC_CC_DMC) -# define __UPX_CDECL __cdecl +# if (__DMC__ < 0x829) +# error "need Digital Mars C++ 8.29 or newer" +# endif #elif (ACC_CC_INTELC) # if (__INTEL_COMPILER < 450) # error "need Intel C++ 4.5 or newer" # endif -# if (ACC_CC_WIN32 || ACC_CC_WIN64) -# define __UPX_CDECL __cdecl +# if (ACC_OS_WIN32 || ACC_OS_WIN64) # elif defined(__linux__) # pragma warning(error: 424) // #424: extra ";" ignored # pragma warning(disable: 193) // #193: zero used for undefined preprocessing identifier @@ -78,8 +78,9 @@ # if (_MSC_VER < 1100) # error "need Visual C++ 5.0 or newer" # endif -# define __UPX_CDECL __cdecl -# pragma warning(disable: 4096) // __cdecl + '...' +#if 0 +# pragma warning(disable: 4096) // W2: '__cdecl' must be used with '...' +#endif # pragma warning(disable: 4097) // W3: typedef-name 'A' used as synonym for class-name 'B' # pragma warning(disable: 4511) // W3: 'class': copy constructor could not be generated # pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated @@ -94,10 +95,6 @@ # endif #endif -#if !defined(__UPX_CDECL) -# define __UPX_CDECL -#endif - /************************************************************************* // @@ -453,26 +450,26 @@ void printClearLine(FILE *f = NULL); void printErr(const char *iname, const Throwable *e); void printUnhandledException(const char *iname, const std::exception *e); #if defined(__GNUC__) -void printErr(const char *iname, const char *format, ...) +void __acc_cdecl printErr(const char *iname, const char *format, ...) __attribute__((format(printf,2,3))); -void printWarn(const char *iname, const char *format, ...) +void __acc_cdecl printWarn(const char *iname, const char *format, ...) __attribute__((format(printf,2,3))); #else -void printErr(const char *iname, const char *format, ...); -void printWarn(const char *iname, const char *format, ...); +void __acc_cdecl printErr(const char *iname, const char *format, ...); +void __acc_cdecl printWarn(const char *iname, const char *format, ...); #endif #if defined(__GNUC__) -void infoWarning(const char *format, ...) +void __acc_cdecl infoWarning(const char *format, ...) __attribute__((format(printf,1,2))); -void infoHeader(const char *format, ...) +void __acc_cdecl infoHeader(const char *format, ...) __attribute__((format(printf,1,2))); -void info(const char *format, ...) +void __acc_cdecl info(const char *format, ...) __attribute__((format(printf,1,2))); #else -void infoWarning(const char *format, ...); -void infoHeader(const char *format, ...); -void info(const char *format, ...); +void __acc_cdecl infoWarning(const char *format, ...); +void __acc_cdecl infoHeader(const char *format, ...); +void __acc_cdecl info(const char *format, ...); #endif void infoHeader(); void infoWriting(const char *what, long size); diff --git a/src/console.h b/src/console.h index 9bc9f586..dd0ed3f3 100644 --- a/src/console.h +++ b/src/console.h @@ -123,10 +123,10 @@ console_t; #if defined(__GNUC__) -void con_fprintf(FILE *f, const char *format, ...) +void __acc_cdecl con_fprintf(FILE *f, const char *format, ...) __attribute__((format(printf,2,3))); #else -void con_fprintf(FILE *f, const char *format, ...); +void __acc_cdecl con_fprintf(FILE *f, const char *format, ...); #endif diff --git a/src/main.cpp b/src/main.cpp index b93f1cdf..4a6df6e3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -65,13 +65,13 @@ void init_options(struct options_t *o) #endif o->verbose = 2; - o->w32pe.compress_exports = 1; - o->w32pe.compress_icons = 2; - o->w32pe.compress_resources = -1; - for (unsigned i = 0; i < TABLESIZE(opt->w32pe.compress_rt); i++) - opt->w32pe.compress_rt[i] = -1; - opt->w32pe.compress_rt[24] = false; // 24 == RT_MANIFEST - o->w32pe.strip_relocs = -1; + o->win32_pe.compress_exports = 1; + o->win32_pe.compress_icons = 2; + o->win32_pe.compress_resources = -1; + for (unsigned i = 0; i < TABLESIZE(o->win32_pe.compress_rt); i++) + o->win32_pe.compress_rt[i] = -1; + o->win32_pe.compress_rt[24] = false; // 24 == RT_MANIFEST + o->win32_pe.strip_relocs = -1; } static struct options_t global_options; @@ -403,7 +403,7 @@ char* prepare_shortopts(char *buf, const char *n, template -int getoptvar(T *var, T minval, T maxval) +int getoptvar(T *var, const T minval, const T maxval) { const char *p = mfx_optarg; char *endptr; @@ -594,7 +594,7 @@ static int do_option(int optc, const char *arg) getoptvar(&opt->crp.max_match, 16u, ~0u); break; case 537: - if (getoptvar(&opt->crp.m_size, 10000u, (unsigned)999999u) != 0) + if (getoptvar(&opt->crp.m_size, 10000u, 999999u) != 0) e_optval("--crp-ms="); break; // backup @@ -647,41 +647,41 @@ static int do_option(int optc, const char *arg) break; // case 600: - opt->dos.force_stub = true; + opt->dos_exe.force_stub = true; break; case 601: - opt->dos.no_reloc = true; + opt->dos_exe.no_reloc = true; break; case 610: - opt->djgpp2.coff = true; + opt->djgpp2_coff.coff = true; break; case 620: - opt->wcle.le = true; + opt->watcom_le.le = true; break; case 630: - opt->w32pe.compress_exports = 1; - getoptvar(&opt->w32pe.compress_exports, 0, 1); - //printf("compress_exports: %d\n", opt->w32pe.compress_exports); + opt->win32_pe.compress_exports = 1; + getoptvar(&opt->win32_pe.compress_exports, 0, 1); + //printf("compress_exports: %d\n", opt->win32_pe.compress_exports); break; case 631: - opt->w32pe.compress_icons = 1; - getoptvar(&opt->w32pe.compress_icons, 0, 2); - //printf("compress_icons: %d\n", opt->w32pe.compress_icons); + opt->win32_pe.compress_icons = 1; + getoptvar(&opt->win32_pe.compress_icons, 0, 2); + //printf("compress_icons: %d\n", opt->win32_pe.compress_icons); break; case 632: - opt->w32pe.compress_resources = true; + opt->win32_pe.compress_resources = true; if (mfx_optarg && strcmp(mfx_optarg,"0") == 0) - opt->w32pe.compress_resources = false; - //printf("compress_resources: %d\n", opt->w32pe.compress_resources); + opt->win32_pe.compress_resources = false; + //printf("compress_resources: %d\n", opt->win32_pe.compress_resources); break; case 633: - opt->w32pe.strip_relocs = 1; + opt->win32_pe.strip_relocs = 1; if (mfx_optarg && strcmp(mfx_optarg,"0") == 0) - opt->w32pe.strip_relocs = 0; - //printf("strip_relocs: %d\n", opt->w32pe.strip_relocs); + opt->win32_pe.strip_relocs = 0; + //printf("strip_relocs: %d\n", opt->win32_pe.strip_relocs); break; case 650: - opt->tos.split_segments = true; + opt->atari_tos.split_segments = true; break; case 660: getoptvar(&opt->unix.blocksize, 8192u, ~0u); @@ -698,7 +698,7 @@ static int do_option(int optc, const char *arg) opt->unix.ptinterp = true; break; case 670: - opt->ps1.no_align = true; + opt->ps1_exe.no_align = true; break; case '\0': @@ -1044,6 +1044,7 @@ void upx_sanity_check(void) COMPILE_TIME_ASSERT(((((unsigned)1 << 31) + 1) >> 31) == 1); COMPILE_TIME_ASSERT(((((acc_uint64l_t)1 << 63) + 1) >> 63) == 1); +#if !defined(ACC_CC_WATCOMC) struct foo1a_t { char c1; LE16 v[4]; } __attribute_packed; struct align_assertion_1a_t { foo1a_t d[3]; } __attribute_packed; struct foo1b_t { char c1; char v[4*2]; } __attribute_packed; @@ -1060,6 +1061,7 @@ void upx_sanity_check(void) COMPILE_TIME_ASSERT(sizeof(align_assertion_2a_t) == sizeof(align_assertion_2b_t)); COMPILE_TIME_ASSERT(sizeof(align_assertion_1a_t) == 3*9); COMPILE_TIME_ASSERT(sizeof(align_assertion_2a_t) == 3*17); +#endif COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_STRING4) == 4 + 1); assert(strlen(UPX_VERSION_STRING4) == 4); diff --git a/src/mem.cpp b/src/mem.cpp index 5e54a5a8..46170431 100644 --- a/src/mem.cpp +++ b/src/mem.cpp @@ -57,7 +57,6 @@ static int mcheck_init() // **************************************************************************/ - MemBuffer::MemBuffer() : b(NULL), b_size(0) { diff --git a/src/msg.cpp b/src/msg.cpp index 95b38d1c..1423cbac 100644 --- a/src/msg.cpp +++ b/src/msg.cpp @@ -130,7 +130,7 @@ void printErr(const char *iname, const Throwable *e) } -void printErr(const char *iname, const char *format, ...) +void __acc_cdecl printErr(const char *iname, const char *format, ...) { va_list args; char buf[1024]; @@ -143,7 +143,7 @@ void printErr(const char *iname, const char *format, ...) } -void printWarn(const char *iname, const char *format, ...) +void __acc_cdecl printWarn(const char *iname, const char *format, ...) { va_list args; char buf[1024]; @@ -200,7 +200,7 @@ void infoHeader() info_header = 0; } -void infoHeader(const char *format, ...) +void __acc_cdecl infoHeader(const char *format, ...) { if (opt->info_mode <= 0) return; @@ -214,7 +214,7 @@ void infoHeader(const char *format, ...) } -void info(const char *format, ...) +void __acc_cdecl info(const char *format, ...) { if (opt->info_mode <= 0) return; @@ -229,7 +229,7 @@ void info(const char *format, ...) } -void infoWarning(const char *format, ...) +void __acc_cdecl infoWarning(const char *format, ...) { if (opt->info_mode <= 0) { diff --git a/src/options.h b/src/options.h index 4454e0a3..6fe5e4a5 100644 --- a/src/options.h +++ b/src/options.h @@ -99,18 +99,18 @@ struct options_t { // options for various executable formats struct { - bool force_stub; - bool no_reloc; - } dos; + bool split_segments; + } atari_tos; struct { bool coff; - } djgpp2; + } djgpp2_coff; + struct { + bool force_stub; + bool no_reloc; + } dos_exe; struct { bool no_align; - } ps1; - struct { - bool split_segments; - } tos; + } ps1_exe; struct { unsigned blocksize; bool force_execve; // force the linux/386 execve format @@ -120,14 +120,14 @@ struct options_t { } unix; struct { bool le; - } wcle; + } watcom_le; struct { int compress_exports; int compress_icons; int compress_resources; signed char compress_rt[25]; // 25 == RT_LAST int strip_relocs; - } w32pe; + } win32_pe; }; extern struct options_t * volatile opt; diff --git a/src/p_djgpp2.cpp b/src/p_djgpp2.cpp index 8f45fdb5..798af023 100644 --- a/src/p_djgpp2.cpp +++ b/src/p_djgpp2.cpp @@ -109,7 +109,7 @@ int PackDjgpp2::buildLoader(const Filter *ft) void PackDjgpp2::handleStub(OutputFile *fo) { - if (fo && !opt->djgpp2.coff) + if (fo && !opt->djgpp2_coff.coff) { if (coff_offset > 0) { diff --git a/src/p_exe.cpp b/src/p_exe.cpp index dacdd217..f3028e88 100644 --- a/src/p_exe.cpp +++ b/src/p_exe.cpp @@ -72,7 +72,7 @@ int PackExe::fillExeHeader(struct exe_header_t *eh) const #define oh (*eh) // fill new exe header int flag = 0; - if (!opt->dos.no_reloc) + if (!opt->dos_exe.no_reloc) flag |= USEJUMP; if (ih.relocs == 0) flag |= NORELOC; @@ -213,7 +213,7 @@ bool PackExe::canPack() fi->readx(&offs,sizeof (offs)); if (ih.relocoffs >= 0x40 && offs) { - if (opt->dos.force_stub) + if (opt->dos_exe.force_stub) opt->overlay = opt->COPY_OVERLAY; else throwCantPack("can't pack new-exe"); diff --git a/src/p_ps1.cpp b/src/p_ps1.cpp index 6172c7d6..8bd2a3c6 100644 --- a/src/p_ps1.cpp +++ b/src/p_ps1.cpp @@ -318,7 +318,7 @@ void PackPs1::pack(OutputFile *fo) oh.tx_len = ph.c_len + e_len + pad_code; oh.epc = entry; - if (!opt->ps1.no_align) + if (!opt->ps1_exe.no_align) { pad = oh.tx_len; oh.tx_len = ALIGN_UP(oh.tx_len, CD_SEC); diff --git a/src/p_tos.cpp b/src/p_tos.cpp index 6f0f0593..9efb2f47 100644 --- a/src/p_tos.cpp +++ b/src/p_tos.cpp @@ -580,7 +580,7 @@ void PackTos::pack(OutputFile *fo) // set new file_hdr memcpy(&oh, &ih, FH_SIZE); - if (opt->tos.split_segments) + if (opt->atari_tos.split_segments) { oh.fh_text = o_text; oh.fh_data = o_data; diff --git a/src/p_w32pe.cpp b/src/p_w32pe.cpp index 82a915b6..08fed486 100644 --- a/src/p_w32pe.cpp +++ b/src/p_w32pe.cpp @@ -88,7 +88,7 @@ PackW32Pe::PackW32Pe(InputFile *f) : super(f) //printf("pe_section_t %d\n", (int) sizeof(pe_section_t)); COMPILE_TIME_ASSERT(sizeof(pe_header_t) == 248); COMPILE_TIME_ASSERT(sizeof(pe_section_t) == 40); - COMPILE_TIME_ASSERT(RT_LAST == TABLESIZE(opt->w32pe.compress_rt)); + COMPILE_TIME_ASSERT(RT_LAST == TABLESIZE(opt->win32_pe.compress_rt)); isection = NULL; oimport = NULL; @@ -391,7 +391,7 @@ void Reloc::finish(upx_byte *&p,unsigned &siz) void PackW32Pe::processRelocs(Reloc *rel) // pass2 { rel->finish(oxrelocs,soxrelocs); - if (opt->w32pe.strip_relocs && !isdll) + if (opt->win32_pe.strip_relocs && !isdll) soxrelocs = 0; } @@ -403,7 +403,7 @@ void PackW32Pe::processRelocs() // pass1 const unsigned *counts = rel.getcounts(); const unsigned rnum = counts[1] + counts[2] + counts[3]; - if ((opt->w32pe.strip_relocs && !isdll) || rnum == 0) + if ((opt->win32_pe.strip_relocs && !isdll) || rnum == 0) { if (IDSIZE(PEDIR_RELOC)) ibuf.fill(IDADDR(PEDIR_RELOC), IDSIZE(PEDIR_RELOC), FILLVAL); @@ -489,7 +489,7 @@ void PackW32Pe::processImports(unsigned myimport) // pass 2 unsigned PackW32Pe::processImports() // pass 1 { - static const upx_byte kernel32dll[] = "KERNEL32.DLL"; + static const unsigned char kernel32dll[] = "KERNEL32.DLL"; static const char llgpa[] = "\x0\x0""LoadLibraryA\x0\x0""GetProcAddress\x0\x0"; static const char exitp[] = "ExitProcess\x0\x0\x0"; @@ -777,7 +777,7 @@ class Export Interval iv; public: - Export(char *base); + Export(char *_base); ~Export(); void convert(unsigned eoffs,unsigned esize); @@ -785,6 +785,7 @@ public: unsigned getsize() const { return size; } private: + // disable copy and assignment Export(const Export&); Export& operator=(const Export&); }; @@ -850,7 +851,7 @@ void Export::convert(unsigned eoffs,unsigned esize) names[ic + edir.names] = strdup(forw); } else - names[ic + edir.names] = 0; + names[ic + edir.names] = NULL; len = 2 * edir.names; ordinals = new char[len + 1]; @@ -907,7 +908,7 @@ void PackW32Pe::processExports(Export *xport) // pass1 soexport = ALIGN_UP(IDSIZE(PEDIR_EXPORT),4); if (soexport == 0) return; - if (!isdll && opt->w32pe.compress_exports) + if (!isdll && opt->win32_pe.compress_exports) { infoWarning("exports compressed, --compress-exports=0 might be needed"); soexport = 0; @@ -1098,7 +1099,7 @@ public: void init(const upx_byte *); unsigned dirsize() const {return ALIGN_UP(dsize + ssize,4);} - bool next() {return (current = current ? current->next : head) != 0;} // wow, builtin autorewind... :-) + bool next() {return (current = current ? current->next : head) != NULL;} // wow, builtin autorewind... :-) unsigned itype() const {return current->parent->parent->id;} const upx_byte *ntype() const {return current->parent->parent->name;} @@ -1126,10 +1127,10 @@ void Resource::init(const upx_byte *res) COMPILE_TIME_ASSERT(sizeof(res_data) == 16); start = res; - root = head = current = 0; + root = head = current = NULL; dsize = ssize = 0; check((const res_dir*) start,0); - root = convert(start,0,0); + root = convert(start,NULL,0); } void Resource::check(const res_dir *node,unsigned level) @@ -1153,7 +1154,7 @@ Resource::upx_rnode *Resource::convert(const void *rnode,upx_rnode *parent,unsig { const res_data *node = (const res_data *) rnode; upx_rleaf *leaf = new upx_rleaf; - leaf->name = 0; + leaf->name = NULL; leaf->parent = parent; leaf->next = head; leaf->newoffset = 0; @@ -1166,7 +1167,7 @@ Resource::upx_rnode *Resource::convert(const void *rnode,upx_rnode *parent,unsig const res_dir *node = (const res_dir *) rnode; upx_rbranch *branch = new upx_rbranch; - branch->name = 0; + branch->name = NULL; branch->parent = parent; int ic = branch->nc = node->identr + node->namedentr; branch->children = new upx_rnode*[ic]; @@ -1317,20 +1318,20 @@ void PackW32Pe::processResources(Resource *res) return; // setup default options for resource compression - if (opt->w32pe.compress_resources < 0) - opt->w32pe.compress_resources = true; - if (!opt->w32pe.compress_resources) + if (opt->win32_pe.compress_resources < 0) + opt->win32_pe.compress_resources = true; + if (!opt->win32_pe.compress_resources) { - opt->w32pe.compress_icons = false; + opt->win32_pe.compress_icons = false; for (int i = 0; i < RT_LAST; i++) - opt->w32pe.compress_rt[i] = false; + opt->win32_pe.compress_rt[i] = false; } - if (opt->w32pe.compress_rt[RT_STRING] < 0) + if (opt->win32_pe.compress_rt[RT_STRING] < 0) { // by default, don't compress RT_STRINGs of screensavers (".scr") - opt->w32pe.compress_rt[RT_STRING] = true; + opt->win32_pe.compress_rt[RT_STRING] = true; if (fn_has_ext(fi->getName(),"scr")) - opt->w32pe.compress_rt[RT_STRING] = false; + opt->win32_pe.compress_rt[RT_STRING] = false; } res->init(ibuf + vaddr); @@ -1341,7 +1342,7 @@ void PackW32Pe::processResources(Resource *res) upx_byte *ores = oresources + res->dirsize(); unsigned iconsin1stdir = 0; - if (opt->w32pe.compress_icons == 2) + if (opt->win32_pe.compress_icons == 2) while (res->next()) // there is no rewind() in Resource if (res->itype() == RT_GROUP_ICON && iconsin1stdir == 0) iconsin1stdir = get_le16(ibuf + res->offs() + 4); @@ -1359,16 +1360,16 @@ void PackW32Pe::processResources(Resource *res) { const unsigned rtype = res->itype(); bool do_compress = true; - if (!opt->w32pe.compress_resources) + if (!opt->win32_pe.compress_resources) do_compress = false; else if (rtype == RT_VERSION) // version info do_compress = false; else if (rtype == RT_ICON) // icon - do_compress = compress_icon && opt->w32pe.compress_icons; + do_compress = compress_icon && opt->win32_pe.compress_icons; else if (rtype == RT_GROUP_ICON) // icon directory - do_compress = compress_idir && opt->w32pe.compress_icons; + do_compress = compress_idir && opt->win32_pe.compress_icons; else if (rtype > 0 && rtype < RT_LAST) - do_compress = opt->w32pe.compress_rt[rtype] ? true : false; + do_compress = opt->win32_pe.compress_rt[rtype] ? true : false; else if (res->ntype()) // named resource type { const upx_byte * const t = res->ntype(); @@ -1394,10 +1395,10 @@ void PackW32Pe::processResources(Resource *res) ibuf.fill(res->offs(), res->size(), FILLVAL); res->newoffs() = ptr_diff(ores,oresources); if (rtype == RT_ICON) - compress_icon = (++iconcnt >= iconsin1stdir || opt->w32pe.compress_icons == 1); + compress_icon = (++iconcnt >= iconsin1stdir || opt->win32_pe.compress_icons == 1); else if (rtype == RT_GROUP_ICON) { - if (opt->w32pe.compress_icons == 1) + if (opt->win32_pe.compress_icons == 1) { icondir_offset = 4 + ptr_diff(ores,oresources); icondir_count = get_le16(oresources + icondir_offset); @@ -1539,7 +1540,7 @@ int PackW32Pe::buildLoader(const Filter *ft) void PackW32Pe::pack(OutputFile *fo) { - unsigned objs = ih.objects; + const unsigned objs = ih.objects; isection = new pe_section_t[objs]; fi->seek(pe_offset+sizeof(ih),SEEK_SET); fi->readx(isection,sizeof(pe_section_t)*objs); @@ -1569,10 +1570,10 @@ void PackW32Pe::pack(OutputFile *fo) //if (IDSIZE(PEDIR_DELAYIMP)) // throwCantPack("delay load imports are not supported"); if (isdll) - opt->w32pe.strip_relocs = 0; - else if (opt->w32pe.strip_relocs < 0) - opt->w32pe.strip_relocs = (ih.imagebase >= 0x400000); - if (opt->w32pe.strip_relocs) + opt->win32_pe.strip_relocs = false; + else if (opt->win32_pe.strip_relocs < 0) + opt->win32_pe.strip_relocs = (ih.imagebase >= 0x400000); + if (opt->win32_pe.strip_relocs) if (ih.imagebase < 0x400000) throwCantPack("--strip-relocs is not allowed when imagebase < 0x400000"); else @@ -1819,7 +1820,7 @@ void PackW32Pe::pack(OutputFile *fo) const unsigned esi0 = s1addr + ic; patch_le32(loader,codesize,"EDI0", rvamin - esi0); - patch_le32(loader,codesize,"ESI0",esi0 + ih.imagebase); + patch_le32(loader,codesize,"ESI0", esi0 + ih.imagebase); ic = getLoaderSection("PEMAIN01") + 2 + upxsection; Reloc rel(1024); // new relocations are put here @@ -1865,7 +1866,7 @@ void PackW32Pe::pack(OutputFile *fo) processExports(&xport,ic); ODADDR(PEDIR_EXPORT) = soexport ? ic : 0; ODSIZE(PEDIR_EXPORT) = soexport; - if (!isdll && opt->w32pe.compress_exports) + if (!isdll && opt->win32_pe.compress_exports) { ODADDR(PEDIR_EXPORT) = IDADDR(PEDIR_EXPORT); ODSIZE(PEDIR_EXPORT) = IDSIZE(PEDIR_EXPORT); @@ -1927,7 +1928,7 @@ void PackW32Pe::pack(OutputFile *fo) // oh.headersize = osection[0].rawdataptr; oh.headersize = rvamin; - if (opt->w32pe.strip_relocs && !isdll) + if (opt->win32_pe.strip_relocs && !isdll) oh.flags |= RELOCS_STRIPPED; //for (ic = 0; ic < oh.filealign; ic += 4) @@ -2026,14 +2027,14 @@ int PackW32Pe::canUnpack() if (is_packed && ih.entry < isection[2].vaddr) { unsigned char buf[256]; - memset(buf, 0, sizeof(buf)); bool x = false; + memset(buf, 0, sizeof(buf)); try { fi->seek(ih.entry - isection[1].vaddr + isection[1].rawdataptr, SEEK_SET); fi->read(buf, sizeof(buf)); - static const char magic[] = "\x8b\x1e\x83\xee\xfc\x11\xdb"; + static const unsigned char magic[] = "\x8b\x1e\x83\xee\xfc\x11\xdb"; // mov ebx, [esi]; sub esi, -4; adc ebx,ebx int offset = find(buf, sizeof(buf), magic, 7); @@ -2194,7 +2195,7 @@ void PackW32Pe::rebuildRelocs(upx_byte *& extrainfo) } rel.finish (oxrelocs,soxrelocs); - if (opt->w32pe.strip_relocs && !isdll) + if (opt->win32_pe.strip_relocs && !isdll) { obuf.clear(ODADDR(PEDIR_RELOC) - rvamin, ODSIZE(PEDIR_RELOC)); ODADDR(PEDIR_RELOC) = 0; @@ -2214,7 +2215,7 @@ void PackW32Pe::rebuildExports() if (ODSIZE(PEDIR_EXPORT) == 0 || ODADDR(PEDIR_EXPORT) == IDADDR(PEDIR_EXPORT)) return; // nothing to do - opt->w32pe.compress_exports = 0; + opt->win32_pe.compress_exports = 0; Export xport((char*)(unsigned char*) ibuf - isection[2].vaddr); processExports(&xport); processExports(&xport,ODADDR(PEDIR_EXPORT)); @@ -2323,7 +2324,7 @@ void PackW32Pe::unpack(OutputFile *fo) oh.chksum = 0; // FIXME: ih.flags is checked here because of a bug in UPX 0.92 - if ((opt->w32pe.strip_relocs && !isdll) || (ih.flags & RELOCS_STRIPPED)) + if ((opt->win32_pe.strip_relocs && !isdll) || (ih.flags & RELOCS_STRIPPED)) { oh.flags |= RELOCS_STRIPPED; ODADDR(PEDIR_RELOC) = 0; diff --git a/src/p_wcle.cpp b/src/p_wcle.cpp index da25f94d..df1fb051 100644 --- a/src/p_wcle.cpp +++ b/src/p_wcle.cpp @@ -120,7 +120,7 @@ int PackWcle::buildLoader(const Filter *ft) void PackWcle::handleStub(OutputFile *fo) { - if (fo && !opt->wcle.le) + if (fo && !opt->watcom_le.le) Packer::handleStub(fi,fo,le_offset); } @@ -540,7 +540,7 @@ void PackWcle::pack(OutputFile *fo) patch_le32(oimage,e_len,"EDI0",((ic+d_len+3)&~3)-4); patch_le32(oimage,e_len,"ESI0",e_len+jpos*4-4); - writeFile(fo, opt->wcle.le); + writeFile(fo, opt->watcom_le.le); // copy the overlay const unsigned overlaystart = ih.data_pages_offset + exe_offset @@ -827,7 +827,7 @@ void PackWcle::unpack(OutputFile *fo) // write decompressed file if (fo) - writeFile(fo, opt->wcle.le); + writeFile(fo, opt->watcom_le.le); // copy the overlay const unsigned overlaystart = ih.data_pages_offset + exe_offset diff --git a/src/packmast.cpp b/src/packmast.cpp index 0829accc..14e5bd8b 100644 --- a/src/packmast.cpp +++ b/src/packmast.cpp @@ -153,7 +153,7 @@ static Packer* try_packers(InputFile *f, try_function func) // // .exe // - if (!opt->dos.force_stub) + if (!opt->dos_exe.force_stub) { if ((p = func(new PackDjgpp2(f),f)) != NULL) return p; diff --git a/src/snprintf.cpp b/src/snprintf.cpp index 46212329..39685b61 100644 --- a/src/snprintf.cpp +++ b/src/snprintf.cpp @@ -795,13 +795,13 @@ static int xdopr(char *buffer, size_t maxlen, const char *format, va_list args) } -int __UPX_CDECL upx_vsnprintf(char *str, size_t count, const char *format, va_list ap) +int __acc_cdecl upx_vsnprintf(char *str, size_t count, const char *format, va_list ap) { return xdopr(str, count, format, ap); } -int __UPX_CDECL upx_snprintf(char *str, size_t count, const char *format,...) +int __acc_cdecl upx_snprintf(char *str, size_t count, const char *format,...) { va_list ap; int ret; @@ -813,7 +813,7 @@ int __UPX_CDECL upx_snprintf(char *str, size_t count, const char *format,...) } -int __UPX_CDECL upx_vasprintf(char **ptr, const char *format, va_list ap) +int __acc_cdecl upx_vasprintf(char **ptr, const char *format, va_list ap) { int ret; @@ -832,7 +832,7 @@ int __UPX_CDECL upx_vasprintf(char **ptr, const char *format, va_list ap) } -int __UPX_CDECL upx_asprintf(char **ptr, const char *format, ...) +int __acc_cdecl upx_asprintf(char **ptr, const char *format, ...) { va_list ap; int ret; diff --git a/src/snprintf.h b/src/snprintf.h index 72273d6f..6aab224b 100644 --- a/src/snprintf.h +++ b/src/snprintf.h @@ -38,10 +38,10 @@ extern "C" { // **************************************************************************/ -int __UPX_CDECL upx_vsnprintf(char *str, size_t count, const char *format, va_list ap); -int __UPX_CDECL upx_snprintf(char *str, size_t count, const char *format,...); -int __UPX_CDECL upx_vasprintf(char **ptr, const char *format, va_list ap); -int __UPX_CDECL upx_asprintf(char **ptr, const char *format, ...); +int __acc_cdecl upx_vsnprintf(char *str, size_t count, const char *format, va_list ap); +int __acc_cdecl upx_snprintf(char *str, size_t count, const char *format,...); +int __acc_cdecl upx_vasprintf(char **ptr, const char *format, va_list ap); +int __acc_cdecl upx_asprintf(char **ptr, const char *format, ...); #if 1 # undef sprintf