mirror of
https://github.com/upx/upx.git
synced 2024-12-01 00:20:33 +00:00
Minor portability fixes.
This commit is contained in:
parent
750c1a0f27
commit
ace24ad68e
@ -49,7 +49,7 @@ PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned flavor,
|
||||
unsigned count, unsigned size) :
|
||||
super(f), my_cputype(cputype), my_thread_flavor(flavor),
|
||||
my_thread_state_word_count(count), my_thread_command_size(size),
|
||||
n_segment(0), rawmseg(0), msegcmd(0)
|
||||
n_segment(0), rawmseg(NULL), msegcmd(NULL)
|
||||
{
|
||||
MachClass::compileTimeAssertions();
|
||||
bele = N_BELE_CTP::getRTP<BeLePolicy>();
|
||||
@ -58,8 +58,8 @@ PackMachBase<T>::PackMachBase(InputFile *f, unsigned cputype, unsigned flavor,
|
||||
template <class T>
|
||||
PackMachBase<T>::~PackMachBase()
|
||||
{
|
||||
delete [] msegcmd;
|
||||
delete [] rawmseg;
|
||||
delete [] msegcmd;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@ -652,7 +652,7 @@ void PackMachFat::pack(OutputFile *fo)
|
||||
unsigned length = 0;
|
||||
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
||||
unsigned base = fo->unset_extent(); // actual length
|
||||
base += ~(~0u<<fat_head.arch[j].align) & -base; // align up
|
||||
base += ~(~0u<<fat_head.arch[j].align) & (0-base); // align up
|
||||
fo->seek(base, SEEK_SET);
|
||||
fo->set_extent(base, ~0u);
|
||||
|
||||
@ -695,7 +695,7 @@ void PackMachFat::unpack(OutputFile *fo)
|
||||
unsigned length;
|
||||
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
|
||||
unsigned base = fo->unset_extent(); // actual length
|
||||
base += ~(~0u<<fat_head.arch[j].align) & -base; // align up
|
||||
base += ~(~0u<<fat_head.arch[j].align) & (0-base); // align up
|
||||
fo->seek(base, SEEK_SET);
|
||||
fo->set_extent(base, ~0u);
|
||||
|
||||
|
23
src/p_mach.h
23
src/p_mach.h
@ -32,9 +32,9 @@
|
||||
|
||||
struct Mach_fat_header {
|
||||
BE32 magic;
|
||||
enum e8 { // note conflict with java bytecode PackLinuxI386
|
||||
enum { // note conflict with java bytecode PackLinuxI386
|
||||
FAT_MAGIC = 0xcafebabe,
|
||||
FAT_MAGIC_SWAB = 0xbebafeca,
|
||||
FAT_MAGIC_SWAB = 0xbebafeca
|
||||
};
|
||||
BE32 nfat_arch; // Number of Mach_fat_arch which follow.
|
||||
}
|
||||
@ -241,7 +241,11 @@ struct MachClass_32
|
||||
typedef typename TP::U32 U32;
|
||||
typedef typename TP::U64 U64;
|
||||
typedef N_Mach::MachITypes<U32, U64, U32, U32> MachITypes;
|
||||
#if (ACC_CC_BORLANDC)
|
||||
typedef U32 Addr;
|
||||
#else
|
||||
typedef typename MachITypes::Addr Addr;
|
||||
#endif
|
||||
|
||||
// Mach types
|
||||
typedef N_Mach::Mach_header<MachITypes> Mach_header;
|
||||
@ -252,6 +256,7 @@ struct MachClass_32
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
BeLePolicy::compileTimeAssertions();
|
||||
COMPILE_TIME_ASSERT(sizeof(Addr) == 4)
|
||||
}
|
||||
};
|
||||
|
||||
@ -270,6 +275,10 @@ struct MachClass_64
|
||||
typedef N_Mach::Mach_header64<MachITypes> Mach_header;
|
||||
typedef N_Mach::Mach_segment_command<MachITypes> Mach_segment_command;
|
||||
typedef N_Mach::Mach_section_command<MachITypes> Mach_section_command;
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
BeLePolicy::compileTimeAssertions();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace N_Mach
|
||||
@ -515,12 +524,17 @@ protected:
|
||||
virtual void buildLoader(const Filter *ft);
|
||||
virtual Linker* newLinker() const;
|
||||
|
||||
protected:
|
||||
#if (ACC_CC_BORLANDC)
|
||||
public:
|
||||
#endif
|
||||
enum { N_FAT_ARCH = 5 };
|
||||
protected:
|
||||
struct Fat_head {
|
||||
struct Mach_fat_header fat;
|
||||
struct Mach_fat_arch arch[N_FAT_ARCH];
|
||||
} fat_head;
|
||||
}
|
||||
__attribute_packed;
|
||||
Fat_head fat_head;
|
||||
|
||||
// UI handler
|
||||
UiPacker *uip;
|
||||
@ -529,7 +543,6 @@ protected:
|
||||
Linker *linker;
|
||||
#define WANT_MACH_HEADER_ENUM
|
||||
#include "p_mach_enum.h"
|
||||
#undef WANT_MACH_HEADER_ENUM
|
||||
};
|
||||
|
||||
#endif /* already included */
|
||||
|
@ -98,7 +98,7 @@
|
||||
enum { // thread flavor
|
||||
PPC_THREAD_STATE = 1,
|
||||
i386_THREAD_STATE = -1,
|
||||
i386_NEW_THREAD_STATE = 1,
|
||||
i386_NEW_THREAD_STATE = 1
|
||||
};
|
||||
#endif /*}*/
|
||||
|
||||
|
@ -66,9 +66,9 @@ PackVmlinuxBase<T>::PackVmlinuxBase(InputFile *f,
|
||||
template <class T>
|
||||
PackVmlinuxBase<T>::~PackVmlinuxBase()
|
||||
{
|
||||
delete [] shstrtab;
|
||||
delete [] phdri;
|
||||
delete [] shdri;
|
||||
delete [] shstrtab;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
Loading…
Reference in New Issue
Block a user