mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Small compatibility updates.
This commit is contained in:
parent
29576da985
commit
967ecafc33
|
@ -366,6 +366,7 @@ off_t OutputFile::st_size() const
|
|||
return bytes_written; // too big if seek()+write() instead of rewrite()
|
||||
}
|
||||
struct stat my_st;
|
||||
my_st.st_size = 0;
|
||||
if (::fstat(_fd, &my_st) != 0)
|
||||
throwIOException(_name, errno);
|
||||
return my_st.st_size;
|
||||
|
|
|
@ -71,7 +71,11 @@ static const
|
|||
static const
|
||||
#include "stub/powerpc-darwin.dylib-entry.h"
|
||||
|
||||
static unsigned lc_segment[2];
|
||||
static const unsigned lc_segment[2] = {
|
||||
0x1, 0x19
|
||||
//Mach_segment_command::LC_SEGMENT,
|
||||
//Mach_segment_command::LC_SEGMENT_64
|
||||
};
|
||||
|
||||
template <class T>
|
||||
PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned filetype,
|
||||
|
@ -83,8 +87,6 @@ PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned filetype,
|
|||
{
|
||||
MachClass::compileTimeAssertions();
|
||||
bele = N_BELE_CTP::getRTP((const BeLePolicy*) NULL);
|
||||
lc_segment[0] = Mach_segment_command::LC_SEGMENT;
|
||||
lc_segment[1] = Mach_segment_command::LC_SEGMENT_64;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@ -117,24 +119,44 @@ const int *PackMachARMEL::getCompressionMethods(int method, int level) const
|
|||
}
|
||||
|
||||
|
||||
PackMachPPC32::PackMachPPC32(InputFile *f) : super(f, Mach_header::CPU_TYPE_POWERPC,
|
||||
Mach_header::MH_EXECUTE, Mach_thread_command::PPC_THREAD_STATE,
|
||||
sizeof(Mach_ppc_thread_state)>>2, sizeof(threado))
|
||||
{ }
|
||||
|
||||
const int *PackMachPPC32::getFilters() const
|
||||
{
|
||||
static const int filters[] = { 0xd0, FT_END };
|
||||
return filters;
|
||||
}
|
||||
|
||||
PackMachI386::PackMachI386(InputFile *f) : super(f, Mach_header::CPU_TYPE_I386,
|
||||
Mach_header::MH_EXECUTE, (unsigned)Mach_thread_command::x86_THREAD_STATE32,
|
||||
sizeof(Mach_i386_thread_state)>>2, sizeof(threado))
|
||||
{ }
|
||||
|
||||
int const *PackMachI386::getFilters() const
|
||||
{
|
||||
static const int filters[] = { 0x49, FT_END };
|
||||
return filters;
|
||||
}
|
||||
|
||||
PackMachAMD64::PackMachAMD64(InputFile *f) : super(f, Mach_header::CPU_TYPE_X86_64,
|
||||
Mach_header::MH_EXECUTE, (unsigned)Mach_thread_command::x86_THREAD_STATE64,
|
||||
sizeof(Mach_AMD64_thread_state)>>2, sizeof(threado))
|
||||
{ }
|
||||
|
||||
int const *PackMachAMD64::getFilters() const
|
||||
{
|
||||
static const int filters[] = { 0x49, FT_END };
|
||||
return filters;
|
||||
}
|
||||
|
||||
PackMachARMEL::PackMachARMEL(InputFile *f) : super(f, Mach_header::CPU_TYPE_ARM,
|
||||
Mach_header::MH_EXECUTE, (unsigned)Mach_thread_command::ARM_THREAD_STATE,
|
||||
sizeof(Mach_ARM_thread_state)>>2, sizeof(threado))
|
||||
{ }
|
||||
|
||||
int const *PackMachARMEL::getFilters() const
|
||||
{
|
||||
static const int filters[] = { 0x50, FT_END };
|
||||
|
@ -472,7 +494,7 @@ void PackMachARMEL::pack4(OutputFile *fo, Filter &ft) // append PackHeader
|
|||
|
||||
#undef PAGE_MASK64
|
||||
#undef PAGE_SIZE64
|
||||
#define PAGE_MASK64 (~(uint64_t)0<<12)
|
||||
#define PAGE_MASK64 (~(acc_uint64l_t)0<<12)
|
||||
#define PAGE_SIZE64 -PAGE_MASK64
|
||||
|
||||
template <class T>
|
||||
|
|
21
src/p_mach.h
21
src/p_mach.h
|
@ -388,7 +388,11 @@ struct MachClass_64
|
|||
typedef typename TP::U32 TE32;
|
||||
typedef typename TP::U64 TE64;
|
||||
typedef N_Mach::MachITypes<TE32, TE64, TE64, TE64> MachITypes;
|
||||
#if (ACC_CC_BORLANDC)
|
||||
typedef TE64 Addr;
|
||||
#else
|
||||
typedef typename MachITypes::Addr Addr;
|
||||
#endif
|
||||
|
||||
// Mach types
|
||||
typedef N_Mach::Mach_header64<MachITypes> Mach_header;
|
||||
|
@ -402,6 +406,7 @@ struct MachClass_64
|
|||
|
||||
static void compileTimeAssertions() {
|
||||
BeLePolicy::compileTimeAssertions();
|
||||
COMPILE_TIME_ASSERT(sizeof(Addr) == 8)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -589,9 +594,7 @@ class PackMachPPC32 : public PackMachBase<MachClass_BE32>
|
|||
typedef PackMachBase<MachClass_BE32> super;
|
||||
|
||||
public:
|
||||
PackMachPPC32(InputFile *f) : super(f, Mach_header::CPU_TYPE_POWERPC,
|
||||
Mach_header::MH_EXECUTE, Mach_thread_command::PPC_THREAD_STATE,
|
||||
sizeof(Mach_ppc_thread_state)>>2, sizeof(threado)) { }
|
||||
PackMachPPC32(InputFile *f);
|
||||
|
||||
virtual int getFormat() const { return UPX_F_MACH_PPC32; }
|
||||
virtual const char *getName() const { return "Mach/ppc32"; }
|
||||
|
@ -640,9 +643,7 @@ class PackMachI386 : public PackMachBase<MachClass_LE32>
|
|||
typedef PackMachBase<MachClass_LE32> super;
|
||||
|
||||
public:
|
||||
PackMachI386(InputFile *f) : super(f, Mach_header::CPU_TYPE_I386,
|
||||
Mach_header::MH_EXECUTE, (unsigned)Mach_thread_command::x86_THREAD_STATE32,
|
||||
sizeof(Mach_i386_thread_state)>>2, sizeof(threado)) { }
|
||||
PackMachI386(InputFile *f);
|
||||
|
||||
virtual int getFormat() const { return UPX_F_MACH_i386; }
|
||||
virtual const char *getName() const { return "Mach/i386"; }
|
||||
|
@ -691,9 +692,7 @@ class PackMachAMD64 : public PackMachBase<MachClass_LE64>
|
|||
typedef PackMachBase<MachClass_LE64> super;
|
||||
|
||||
public:
|
||||
PackMachAMD64(InputFile *f) : super(f, Mach_header::CPU_TYPE_X86_64,
|
||||
Mach_header::MH_EXECUTE, (unsigned)Mach_thread_command::x86_THREAD_STATE64,
|
||||
sizeof(Mach_AMD64_thread_state)>>2, sizeof(threado)) { }
|
||||
PackMachAMD64(InputFile *f);
|
||||
|
||||
virtual int getFormat() const { return UPX_F_MACH_AMD64; }
|
||||
virtual const char *getName() const { return "Mach/AMD64"; }
|
||||
|
@ -726,9 +725,7 @@ class PackMachARMEL : public PackMachBase<MachClass_LE32>
|
|||
typedef PackMachBase<MachClass_LE32> super;
|
||||
|
||||
public:
|
||||
PackMachARMEL(InputFile *f) : super(f, Mach_header::CPU_TYPE_ARM,
|
||||
Mach_header::MH_EXECUTE, (unsigned)Mach_thread_command::ARM_THREAD_STATE,
|
||||
sizeof(Mach_ARM_thread_state)>>2, sizeof(threado)) { }
|
||||
PackMachARMEL(InputFile *f);
|
||||
|
||||
virtual int getFormat() const { return UPX_F_MACH_ARMEL; }
|
||||
virtual const char *getName() const { return "Mach/ARMEL"; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user