mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Make upx build with gcc-2.95 again.
This commit is contained in:
parent
cd0efe3edb
commit
9eca502026
|
@ -470,6 +470,7 @@ struct upx_callback_t
|
|||
template <class T, T default_value, T min_value, T max_value>
|
||||
struct OptVar
|
||||
{
|
||||
typedef T Type;
|
||||
static const T default_value_c = default_value;
|
||||
static const T min_value_c = min_value;
|
||||
static const T max_value_c = max_value;
|
||||
|
|
|
@ -695,6 +695,37 @@ void ElfLinkerM68k::relocate1(const Relocation *rel, upx_byte *location,
|
|||
}
|
||||
|
||||
|
||||
void ElfLinkerMipsLE::relocate1(const Relocation *rel, upx_byte *location,
|
||||
unsigned value, const char *type)
|
||||
{
|
||||
#define MIPS_HI(a) (((a) >> 16) + (((a) & 0x8000) >> 15))
|
||||
#define MIPS_LO(a) ((a) & 0xffff)
|
||||
#define MIPS_PC16(a) ((a) >> 2)
|
||||
#define MIPS_PC26(a) (((a) & 0x0fffffff) >> 2)
|
||||
|
||||
if (strcmp(type, "R_MIPS_HI16") == 0)
|
||||
set_le16(location, get_le16(location) + MIPS_HI(value));
|
||||
else if (strcmp(type, "R_MIPS_LO16") == 0)
|
||||
set_le16(location, get_le16(location) + MIPS_LO(value));
|
||||
else if (strcmp(type, "R_MIPS_PC16") == 0)
|
||||
{
|
||||
value -= rel->section->offset + rel->offset;
|
||||
set_le16(location, get_le16(location) + MIPS_PC16(value));
|
||||
}
|
||||
else if (strcmp(type, "R_MIPS_26") == 0)
|
||||
set_le32(location, get_le32(location) + MIPS_PC26(value));
|
||||
else if (strcmp(type, "R_MIPS_32") == 0)
|
||||
set_le32(location, get_le32(location) + value);
|
||||
else
|
||||
super::relocate1(rel, location, value, type);
|
||||
|
||||
#undef MIPS_HI
|
||||
#undef MIPS_LO
|
||||
#undef MIPS_PC16
|
||||
#undef MIPS_PC26
|
||||
}
|
||||
|
||||
|
||||
void ElfLinkerPpc32::relocate1(const Relocation *rel, upx_byte *location,
|
||||
unsigned value, const char *type)
|
||||
{
|
||||
|
|
|
@ -180,6 +180,15 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class ElfLinkerMipsLE : public ElfLinker
|
||||
{
|
||||
typedef ElfLinker super;
|
||||
protected:
|
||||
virtual void relocate1(const Relocation *, upx_byte *location,
|
||||
unsigned value, const char *type);
|
||||
};
|
||||
|
||||
|
||||
class ElfLinkerPpc32 : public ElfLinker
|
||||
{
|
||||
typedef ElfLinker super;
|
||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -442,6 +442,7 @@ done:
|
|||
return r;
|
||||
}
|
||||
|
||||
#if 1 && (ACC_CC_GNUC >= 0x030300)
|
||||
template <class T, T default_value, T min_value, T max_value>
|
||||
int getoptvar(OptVar<T,default_value,min_value,max_value> *var, const char *arg_fatal)
|
||||
{
|
||||
|
@ -451,6 +452,17 @@ int getoptvar(OptVar<T,default_value,min_value,max_value> *var, const char *arg_
|
|||
*var = v;
|
||||
return r;
|
||||
}
|
||||
#else
|
||||
template <class T>
|
||||
int getoptvar(T *var, const char *arg_fatal)
|
||||
{
|
||||
typename T::Type v = T::default_value_c;
|
||||
int r = getoptvar(&v, T::min_value_c, T::max_value_c, arg_fatal);
|
||||
if (r == 0)
|
||||
*var = v;
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static int do_option(int optc, const char *arg)
|
||||
|
|
|
@ -61,6 +61,7 @@ static const
|
|||
#define MIPS_PC16(a) ((a) >> 2)
|
||||
#define MIPS_PC26(a) (((a) & 0x0fffffff) >> 2)
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
// ps1 exe looks like this:
|
||||
// 1. <header> 2048 bytes
|
||||
|
@ -110,30 +111,6 @@ const int *PackPs1::getFilters() const
|
|||
|
||||
Linker* PackPs1::newLinker() const
|
||||
{
|
||||
class ElfLinkerMipsLE : public ElfLinker
|
||||
{
|
||||
typedef ElfLinker super;
|
||||
|
||||
virtual void relocate1(const Relocation *rel, upx_byte *location,
|
||||
unsigned value, const char *type)
|
||||
{
|
||||
if (strcmp(type, "R_MIPS_HI16") == 0)
|
||||
set_le16(location, get_le16(location) + MIPS_HI(value));
|
||||
else if (strcmp(type, "R_MIPS_LO16") == 0)
|
||||
set_le16(location, get_le16(location) + MIPS_LO(value));
|
||||
else if (strcmp(type, "R_MIPS_PC16") == 0)
|
||||
{
|
||||
value -= rel->section->offset + rel->offset;
|
||||
set_le16(location, get_le16(location) + MIPS_PC16(value));
|
||||
}
|
||||
else if (strcmp(type, "R_MIPS_26") == 0)
|
||||
set_le32(location, get_le32(location) + MIPS_PC26(value));
|
||||
else if (strcmp(type, "R_MIPS_32") == 0)
|
||||
set_le32(location, get_le32(location) + value);
|
||||
else
|
||||
super::relocate1(rel, location, value, type);
|
||||
}
|
||||
};
|
||||
return new ElfLinkerMipsLE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user