Final round of portab fixes - UPX should now compile on any halfway
modern C++ compiler. committer: mfx <mfx> 1058789145 +0000
This commit is contained in:
+38
-7
@@ -145,7 +145,8 @@ DEFS += -D_FILE_OFFSET_BITS=64
|
|||||||
LDLIBS += -lmcheck
|
LDLIBS += -lmcheck
|
||||||
##CFLAGS_WERROR = -Werror
|
##CFLAGS_WERROR = -Werror
|
||||||
|
|
||||||
ifeq ($(DEBUG),0)
|
ifeq ($(DEBUG),1)
|
||||||
|
else
|
||||||
##LDFLAGS += -static
|
##LDFLAGS += -static
|
||||||
STUBEDIT_EXE = objcopy -S -R .comment -R .note $@
|
STUBEDIT_EXE = objcopy -S -R .comment -R .note $@
|
||||||
ifeq ($(arch),i386)
|
ifeq ($(arch),i386)
|
||||||
@@ -190,7 +191,7 @@ endif
|
|||||||
ifeq ($(target),linux-bc57)
|
ifeq ($(target),linux-bc57)
|
||||||
##DEPMODE := XXX_linux
|
##DEPMODE := XXX_linux
|
||||||
CC = bc++ -q -3
|
CC = bc++ -q -3
|
||||||
CFLAGS = -w -w-aus -w-inl '-w!'
|
CFLAGS = -w '-w!'
|
||||||
CFLAGS_OUTPUT = -o$@
|
CFLAGS_OUTPUT = -o$@
|
||||||
LDFLAGS += -ls
|
LDFLAGS += -ls
|
||||||
LINK_EXE_OUTPUT = -e$@
|
LINK_EXE_OUTPUT = -e$@
|
||||||
@@ -314,7 +315,7 @@ ifeq ($(target),rsxnt)
|
|||||||
include $(srcdir)/Makedefs.gcc
|
include $(srcdir)/Makedefs.gcc
|
||||||
e = .exe
|
e = .exe
|
||||||
CXX = gcc
|
CXX = gcc
|
||||||
CFLAGS_O = -O0
|
CFLAGS_O = -O2
|
||||||
CCARCH += -Zwin32 -Zsys -mno-probe
|
CCARCH += -Zwin32 -Zsys -mno-probe
|
||||||
LDFLAGS = -s
|
LDFLAGS = -s
|
||||||
STUBEDIT_EXE = pestack -s1024 -c1024 $@
|
STUBEDIT_EXE = pestack -s1024 -c1024 $@
|
||||||
@@ -330,8 +331,8 @@ o = .obj
|
|||||||
a = .lib
|
a = .lib
|
||||||
e = .exe
|
e = .exe
|
||||||
CC = bcc32 -3
|
CC = bcc32 -3
|
||||||
INCLUDES += -I$(srcdir)/acc
|
INCLUDES += -I$(srcdir)/acc -I$(srcdir)/filter
|
||||||
CFLAGS = -w -w-aus -w-inl -g1
|
CFLAGS = -w -w-inl -g1
|
||||||
CFLAGS_OUTPUT = -o$@
|
CFLAGS_OUTPUT = -o$@
|
||||||
LDFLAGS = -ls
|
LDFLAGS = -ls
|
||||||
LINK_EXE_OUTPUT = -e$@
|
LINK_EXE_OUTPUT = -e$@
|
||||||
@@ -418,11 +419,41 @@ else
|
|||||||
CFLAGS += -O1 -GF
|
CFLAGS += -O1 -GF
|
||||||
LINK_EXE_LDFLAGS += /release
|
LINK_EXE_LDFLAGS += /release
|
||||||
endif
|
endif
|
||||||
RESOURCES = upx.res
|
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
|
||||||
|
|
||||||
endif # ic
|
endif # ic
|
||||||
|
|
||||||
|
|
||||||
|
###
|
||||||
|
### win32 - Symantec C++
|
||||||
|
###
|
||||||
|
|
||||||
|
ifeq ($(target),sc)
|
||||||
|
o = .obj
|
||||||
|
a = .lib
|
||||||
|
e = .exe
|
||||||
|
CC = sc -mn
|
||||||
|
CFLAGS = -w- -wx
|
||||||
|
CXXFLAGS = $(CFLAGS) -EH -ER
|
||||||
|
CFLAGS_OUTPUT = -o$@
|
||||||
|
LDFLAGS = -L/map
|
||||||
|
LINK_EXE_OUTPUT = -o$@
|
||||||
|
LDLIBS = $(DOS_LDLIBS)
|
||||||
|
|
||||||
|
ifneq ($(strip $(DOS_LIBDIRS)),)
|
||||||
|
LIB := $(DOS_LIBDIRS);$(LIB)
|
||||||
|
endif
|
||||||
|
export LIB
|
||||||
|
|
||||||
|
ifeq ($(DEBUG),1)
|
||||||
|
CFLAGS += -o- -g -s
|
||||||
|
else
|
||||||
|
CFLAGS += -o
|
||||||
|
endif
|
||||||
|
|
||||||
|
endif # dm
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
### win32 - Visual C++
|
### win32 - Visual C++
|
||||||
###
|
###
|
||||||
@@ -460,7 +491,7 @@ else
|
|||||||
CFLAGS += -O1 -GF
|
CFLAGS += -O1 -GF
|
||||||
LINK_EXE_LDFLAGS += /release
|
LINK_EXE_LDFLAGS += /release
|
||||||
endif
|
endif
|
||||||
RESOURCES = upx.res
|
RESOURCES := $(subst .rc,.res,$(notdir $(wildcard $(srcdir)/*.rc)))
|
||||||
|
|
||||||
endif # vc
|
endif # vc
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ console_t console_init =
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void __acc_cdecl con_fprintf(FILE *f, const char *format, ...)
|
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char buf[80*25];
|
char buf[80*25];
|
||||||
|
|||||||
+28
-21
@@ -40,7 +40,9 @@
|
|||||||
# define ACC_CONFIG_HEADER UPX_CONFIG_HEADER
|
# define ACC_CONFIG_HEADER UPX_CONFIG_HEADER
|
||||||
#endif
|
#endif
|
||||||
#include "acc/acc.h"
|
#include "acc/acc.h"
|
||||||
|
#include "acc/acc_incd.h"
|
||||||
#include "acc/acc_ince.h"
|
#include "acc/acc_ince.h"
|
||||||
|
#include "acc/acc_lib.h"
|
||||||
#if !defined(acc_int64l_t) || !defined(acc_uint64l_t)
|
#if !defined(acc_int64l_t) || !defined(acc_uint64l_t)
|
||||||
# error "need a 64-bit integer type"
|
# error "need a 64-bit integer type"
|
||||||
#endif
|
#endif
|
||||||
@@ -55,11 +57,18 @@
|
|||||||
# if (__BORLANDC__ < 0x0520)
|
# if (__BORLANDC__ < 0x0520)
|
||||||
# error "need Borland C++ 5.02 or newer"
|
# error "need Borland C++ 5.02 or newer"
|
||||||
# endif
|
# endif
|
||||||
|
# pragma warn -aus // 8004: 'x' is assigned a value that is never used
|
||||||
|
# pragma warn -inl // 8026+8027: Function not expanded inline
|
||||||
|
// Borland compilers typically generate a number of bogus warnings, and
|
||||||
|
// the actual diagnostics vary from version to version...
|
||||||
# if (__BORLANDC__ < 0x0530)
|
# if (__BORLANDC__ < 0x0530)
|
||||||
# pragma warn -csu // 8012: comparing signed and unsigned values
|
# pragma warn -csu // 8012: Comparing signed and unsigned values
|
||||||
|
# endif
|
||||||
|
# if (__BORLANDC__ >= 0x0530 && __BORLANDC__ < 0x0560)
|
||||||
|
# pragma warn -osh // 8055: Possible overflow in shift operation
|
||||||
# endif
|
# endif
|
||||||
# if (__BORLANDC__ >= 0x0560)
|
# if (__BORLANDC__ >= 0x0560)
|
||||||
# pragma warn -use
|
# pragma warn -use // 8080: 'x' is declared but never used
|
||||||
# endif
|
# endif
|
||||||
#elif (ACC_CC_DMC)
|
#elif (ACC_CC_DMC)
|
||||||
# if (__DMC__ < 0x829)
|
# if (__DMC__ < 0x829)
|
||||||
@@ -83,9 +92,7 @@
|
|||||||
# if (_MSC_VER < 1100)
|
# if (_MSC_VER < 1100)
|
||||||
# error "need Visual C++ 5.0 or newer"
|
# error "need Visual C++ 5.0 or newer"
|
||||||
# endif
|
# endif
|
||||||
#if 0
|
# pragma warning(error: 4096) // W2: '__cdecl' must be used with '...'
|
||||||
# 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: 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: 4511) // W3: 'class': copy constructor could not be generated
|
||||||
# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated
|
# pragma warning(disable: 4512) // W4: 'class': assignment operator could not be generated
|
||||||
@@ -443,7 +450,7 @@ extern const char *progname;
|
|||||||
void init_options(struct options_t *o);
|
void init_options(struct options_t *o);
|
||||||
bool set_ec(int ec);
|
bool set_ec(int ec);
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
void e_exit(int ec) __attribute__((noreturn));
|
void e_exit(int ec) __attribute__((__noreturn__));
|
||||||
#else
|
#else
|
||||||
void e_exit(int ec);
|
void e_exit(int ec);
|
||||||
#endif
|
#endif
|
||||||
@@ -455,26 +462,26 @@ void printClearLine(FILE *f = NULL);
|
|||||||
void printErr(const char *iname, const Throwable *e);
|
void printErr(const char *iname, const Throwable *e);
|
||||||
void printUnhandledException(const char *iname, const std::exception *e);
|
void printUnhandledException(const char *iname, const std::exception *e);
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
void __acc_cdecl printErr(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
|
||||||
__attribute__((format(printf,2,3)));
|
__attribute__((__format__(printf,2,3)));
|
||||||
void __acc_cdecl printWarn(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
|
||||||
__attribute__((format(printf,2,3)));
|
__attribute__((__format__(printf,2,3)));
|
||||||
#else
|
#else
|
||||||
void __acc_cdecl printErr(const char *iname, const char *format, ...);
|
void __acc_cdecl_va printErr(const char *iname, const char *format, ...);
|
||||||
void __acc_cdecl printWarn(const char *iname, const char *format, ...);
|
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
void __acc_cdecl infoWarning(const char *format, ...)
|
void __acc_cdecl_va infoWarning(const char *format, ...)
|
||||||
__attribute__((format(printf,1,2)));
|
__attribute__((__format__(printf,1,2)));
|
||||||
void __acc_cdecl infoHeader(const char *format, ...)
|
void __acc_cdecl_va infoHeader(const char *format, ...)
|
||||||
__attribute__((format(printf,1,2)));
|
__attribute__((__format__(printf,1,2)));
|
||||||
void __acc_cdecl info(const char *format, ...)
|
void __acc_cdecl_va info(const char *format, ...)
|
||||||
__attribute__((format(printf,1,2)));
|
__attribute__((__format__(printf,1,2)));
|
||||||
#else
|
#else
|
||||||
void __acc_cdecl infoWarning(const char *format, ...);
|
void __acc_cdecl_va infoWarning(const char *format, ...);
|
||||||
void __acc_cdecl infoHeader(const char *format, ...);
|
void __acc_cdecl_va infoHeader(const char *format, ...);
|
||||||
void __acc_cdecl info(const char *format, ...);
|
void __acc_cdecl_va info(const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
void infoHeader();
|
void infoHeader();
|
||||||
void infoWriting(const char *what, long size);
|
void infoWriting(const char *what, long size);
|
||||||
|
|||||||
+3
-3
@@ -123,10 +123,10 @@ console_t;
|
|||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
void __acc_cdecl con_fprintf(FILE *f, const char *format, ...)
|
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
|
||||||
__attribute__((format(printf,2,3)));
|
__attribute__((__format__(printf,2,3)));
|
||||||
#else
|
#else
|
||||||
void __acc_cdecl con_fprintf(FILE *f, const char *format, ...);
|
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -94,7 +94,7 @@ static int exit_code = EXIT_OK;
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
static void do_exit(void) __attribute__((noreturn));
|
static void do_exit(void) __attribute__((__noreturn__));
|
||||||
#endif
|
#endif
|
||||||
static void do_exit(void)
|
static void do_exit(void)
|
||||||
{
|
{
|
||||||
|
|||||||
+5
-5
@@ -130,7 +130,7 @@ void printErr(const char *iname, const Throwable *e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __acc_cdecl printErr(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printErr(const char *iname, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
@@ -143,7 +143,7 @@ void __acc_cdecl printErr(const char *iname, const char *format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __acc_cdecl printWarn(const char *iname, const char *format, ...)
|
void __acc_cdecl_va printWarn(const char *iname, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
@@ -200,7 +200,7 @@ void infoHeader()
|
|||||||
info_header = 0;
|
info_header = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __acc_cdecl infoHeader(const char *format, ...)
|
void __acc_cdecl_va infoHeader(const char *format, ...)
|
||||||
{
|
{
|
||||||
if (opt->info_mode <= 0)
|
if (opt->info_mode <= 0)
|
||||||
return;
|
return;
|
||||||
@@ -214,7 +214,7 @@ void __acc_cdecl infoHeader(const char *format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __acc_cdecl info(const char *format, ...)
|
void __acc_cdecl_va info(const char *format, ...)
|
||||||
{
|
{
|
||||||
if (opt->info_mode <= 0)
|
if (opt->info_mode <= 0)
|
||||||
return;
|
return;
|
||||||
@@ -229,7 +229,7 @@ void __acc_cdecl info(const char *format, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void __acc_cdecl infoWarning(const char *format, ...)
|
void __acc_cdecl_va infoWarning(const char *format, ...)
|
||||||
{
|
{
|
||||||
if (opt->info_mode <= 0)
|
if (opt->info_mode <= 0)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-2
@@ -801,7 +801,7 @@ int __acc_cdecl upx_vsnprintf(char *str, size_t count, const char *format, va_li
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int __acc_cdecl upx_snprintf(char *str, size_t count, const char *format,...)
|
int __acc_cdecl_va upx_snprintf(char *str, size_t count, const char *format,...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -832,7 +832,7 @@ int __acc_cdecl upx_vasprintf(char **ptr, const char *format, va_list ap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int __acc_cdecl upx_asprintf(char **ptr, const char *format, ...)
|
int __acc_cdecl_va upx_asprintf(char **ptr, const char *format, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
+2
-2
@@ -39,9 +39,9 @@ extern "C" {
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
int __acc_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);
|
||||||
int __acc_cdecl upx_snprintf(char *str, size_t count, const char *format,...);
|
int __acc_cdecl_va 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_vasprintf(char **ptr, const char *format, va_list ap);
|
||||||
int __acc_cdecl upx_asprintf(char **ptr, const char *format, ...);
|
int __acc_cdecl_va upx_asprintf(char **ptr, const char *format, ...);
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
# undef sprintf
|
# undef sprintf
|
||||||
|
|||||||
+29
-10
@@ -41,7 +41,7 @@
|
|||||||
// disable dynamic allocation of an object
|
// disable dynamic allocation of an object
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#if defined(new) || defined(delete) || defined(__EMX__)
|
#if defined(new) || defined(delete) || defined(__EMX__) || (ACC_CC_SYMANTECC)
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
# define DISABLE_NEW_DELETE private:
|
# define DISABLE_NEW_DELETE private:
|
||||||
@@ -89,7 +89,16 @@ private:
|
|||||||
// exceptions & RTTI
|
// exceptions & RTTI
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#if defined(__DMC__) && (__DMC__ < 0x834)
|
#if (ACC_CC_BORLANDC && (__BORLANDC__ < 0x0530))
|
||||||
|
|
||||||
|
#include <stdcomp.h>
|
||||||
|
#undef RWSTD_MULTI_THREAD
|
||||||
|
#include <stdexcep.h>
|
||||||
|
#include <new.h>
|
||||||
|
#include <typeinfo.h>
|
||||||
|
namespace std { class bad_alloc { }; }
|
||||||
|
|
||||||
|
#elif (ACC_CC_DMC && (__DMC__ < 0x834))
|
||||||
|
|
||||||
#include <new.h>
|
#include <new.h>
|
||||||
#include <typeinfo.h>
|
#include <typeinfo.h>
|
||||||
@@ -104,14 +113,21 @@ public:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__BORLANDC__) && (__BORLANDC__ < 0x0530)
|
#elif (ACC_CC_SYMANTECC)
|
||||||
|
|
||||||
#include <stdcomp.h>
|
|
||||||
#undef RWSTD_MULTI_THREAD
|
|
||||||
#include <stdexcep.h>
|
|
||||||
#include <new.h>
|
#include <new.h>
|
||||||
#include <typeinfo.h>
|
#include <typeinfo.h>
|
||||||
namespace std { class bad_alloc { }; }
|
|
||||||
|
class exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
exception() NOTHROW { }
|
||||||
|
virtual ~exception() NOTHROW { }
|
||||||
|
virtual const char* what() const NOTHROW { return "exception"; }
|
||||||
|
};
|
||||||
|
#define bool int
|
||||||
|
#define true 1
|
||||||
|
#define false 0
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@@ -122,13 +138,16 @@ namespace std { class bad_alloc { }; }
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
#if (ACC_CC_BORLANDC)
|
||||||
using namespace std;
|
using namespace std;
|
||||||
#elif defined(__DMC__)
|
#elif (ACC_CC_DMC)
|
||||||
namespace std { class bad_alloc { }; }
|
namespace std { class bad_alloc { }; }
|
||||||
#elif defined(__EMX__)
|
#elif defined(__EMX__)
|
||||||
#define std
|
#define std
|
||||||
#elif defined(__WATCOMC__)
|
#elif (ACC_CC_SYMANTECC)
|
||||||
|
#define std
|
||||||
|
class bad_alloc { };
|
||||||
|
#elif (ACC_CC_WATCOMC)
|
||||||
#define std
|
#define std
|
||||||
class bad_alloc { };
|
class bad_alloc { };
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user