mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Rename template integral types from U32 to TE32 to emphasize on target
endianness.
This commit is contained in:
parent
d9073e4a17
commit
9060ac7897
20
src/p_elf.h
20
src/p_elf.h
|
@ -284,11 +284,11 @@ struct ElfClass_32
|
|||
{
|
||||
typedef TP BeLePolicy;
|
||||
|
||||
// integral types
|
||||
typedef typename TP::U16 U16;
|
||||
typedef typename TP::U32 U32;
|
||||
typedef typename TP::U64 U64;
|
||||
typedef N_Elf::ElfITypes<U16, U32, U32, U32, U32> ElfITypes;
|
||||
// integral types (target endianness)
|
||||
typedef typename TP::U16 TE16;
|
||||
typedef typename TP::U32 TE32;
|
||||
typedef typename TP::U64 TE64;
|
||||
typedef N_Elf::ElfITypes<TE16, TE32, TE32, TE32, TE32> ElfITypes;
|
||||
|
||||
// ELF types
|
||||
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||
|
@ -319,11 +319,11 @@ struct ElfClass_64
|
|||
{
|
||||
typedef TP BeLePolicy;
|
||||
|
||||
// integral types
|
||||
typedef typename TP::U16 U16;
|
||||
typedef typename TP::U32 U32;
|
||||
typedef typename TP::U64 U64;
|
||||
typedef N_Elf::ElfITypes<U16, U32, U64, U64, U64> ElfITypes;
|
||||
// integral types (target endianness)
|
||||
typedef typename TP::U16 TE16;
|
||||
typedef typename TP::U32 TE32;
|
||||
typedef typename TP::U64 TE64;
|
||||
typedef N_Elf::ElfITypes<TE16, TE32, TE64, TE64, TE64> ElfITypes;
|
||||
|
||||
// ELF types
|
||||
typedef N_Elf ::Ehdr<ElfITypes> Ehdr;
|
||||
|
|
54
src/p_mach.h
54
src/p_mach.h
|
@ -236,13 +236,13 @@ struct MachClass_32
|
|||
{
|
||||
typedef TP BeLePolicy;
|
||||
|
||||
// integral types
|
||||
typedef typename TP::U16 U16;
|
||||
typedef typename TP::U32 U32;
|
||||
typedef typename TP::U64 U64;
|
||||
typedef N_Mach::MachITypes<U32, U64, U32, U32> MachITypes;
|
||||
// integral types (target endianness)
|
||||
typedef typename TP::U16 TE16;
|
||||
typedef typename TP::U32 TE32;
|
||||
typedef typename TP::U64 TE64;
|
||||
typedef N_Mach::MachITypes<TE32, TE64, TE32, TE32> MachITypes;
|
||||
#if (ACC_CC_BORLANDC)
|
||||
typedef U32 Addr;
|
||||
typedef TE32 Addr;
|
||||
#else
|
||||
typedef typename MachITypes::Addr Addr;
|
||||
#endif
|
||||
|
@ -265,11 +265,11 @@ struct MachClass_64
|
|||
{
|
||||
typedef TP BeLePolicy;
|
||||
|
||||
// integral types
|
||||
typedef typename TP::U16 U16;
|
||||
typedef typename TP::U32 U32;
|
||||
typedef typename TP::U64 U64;
|
||||
typedef N_Mach::MachITypes<U32, U64, U64, U64> MachITypes;
|
||||
// integral types (target endianness)
|
||||
typedef typename TP::U16 TE16;
|
||||
typedef typename TP::U32 TE32;
|
||||
typedef typename TP::U64 TE64;
|
||||
typedef N_Mach::MachITypes<TE32, TE64, TE64, TE64> MachITypes;
|
||||
|
||||
// Mach types
|
||||
typedef N_Mach::Mach_header64<MachITypes> Mach_header;
|
||||
|
@ -322,10 +322,10 @@ protected:
|
|||
typedef TMachClass MachClass;
|
||||
typedef typename MachClass::BeLePolicy BeLePolicy;
|
||||
typedef typename MachClass::MachITypes MachITypes;
|
||||
// integral types
|
||||
typedef typename MachClass::U16 U16;
|
||||
typedef typename MachClass::U32 U32;
|
||||
typedef typename MachClass::U64 U64;
|
||||
// integral types (target endianness)
|
||||
typedef typename MachClass::TE16 TE16;
|
||||
typedef typename MachClass::TE32 TE32;
|
||||
typedef typename MachClass::TE64 TE64;
|
||||
typedef typename MachClass::Addr Addr;
|
||||
// Mach types
|
||||
typedef typename MachClass::Mach_header Mach_header;
|
||||
|
@ -381,8 +381,8 @@ protected:
|
|||
Mach_segment_command segcmdo;
|
||||
|
||||
struct b_info { // 12-byte header before each compressed block
|
||||
U32 sz_unc; // uncompressed_size
|
||||
U32 sz_cpr; // compressed_size
|
||||
TE32 sz_unc; // uncompressed_size
|
||||
TE32 sz_cpr; // compressed_size
|
||||
unsigned char b_method; // compression algorithm
|
||||
unsigned char b_ftid; // filter id
|
||||
unsigned char b_cto8; // filter parameter
|
||||
|
@ -390,22 +390,32 @@ protected:
|
|||
}
|
||||
__attribute_packed;
|
||||
struct l_info { // 12-byte trailer in header for loader
|
||||
U32 l_checksum;
|
||||
TE32 l_checksum;
|
||||
LE32 l_magic;
|
||||
U16 l_lsize;
|
||||
TE16 l_lsize;
|
||||
unsigned char l_version;
|
||||
unsigned char l_format;
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
struct p_info { // 12-byte packed program header
|
||||
U32 p_progid;
|
||||
U32 p_filesize;
|
||||
U32 p_blocksize;
|
||||
TE32 p_progid;
|
||||
TE32 p_filesize;
|
||||
TE32 p_blocksize;
|
||||
}
|
||||
__attribute_packed;
|
||||
|
||||
struct l_info linfo;
|
||||
|
||||
static void compileTimeAssertions() {
|
||||
MachClass::compileTimeAssertions();
|
||||
COMPILE_TIME_ASSERT(sizeof(b_info) == 12)
|
||||
COMPILE_TIME_ASSERT(sizeof(l_info) == 12)
|
||||
COMPILE_TIME_ASSERT(sizeof(p_info) == 12)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(b_info)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(l_info)
|
||||
COMPILE_TIME_ASSERT_ALIGNED1(p_info)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
|
|||
{
|
||||
unsigned fo_off = 0;
|
||||
Ehdr ehdro;
|
||||
U32 tmp_u32;
|
||||
TE32 tmp_u32;
|
||||
|
||||
// NULL
|
||||
// .text(PT_LOADs) .note(1st page) .note(rest)
|
||||
|
@ -709,7 +709,7 @@ int PackVmlinuxBase<T>::canUnpack()
|
|||
template <class T>
|
||||
void PackVmlinuxBase<T>::unpack(OutputFile *fo)
|
||||
{
|
||||
U32 word;
|
||||
TE32 word;
|
||||
PackHeader const ph_tmp(ph);
|
||||
|
||||
fi->seek(p_note0->sh_offset, SEEK_SET);
|
||||
|
@ -1015,7 +1015,7 @@ unsigned PackVmlinuxI386::write_vmlinux_head(
|
|||
// COMPRESSED_LENGTH
|
||||
fo->write(&stub_i386_linux_kernel_vmlinux_head[0],
|
||||
sizeof(stub_i386_linux_kernel_vmlinux_head)-(1+ 4) +1);
|
||||
U32 tmp_u32; tmp_u32 = ph.c_len; fo->write(&tmp_u32, 4);
|
||||
TE32 tmp_u32; tmp_u32 = ph.c_len; fo->write(&tmp_u32, 4);
|
||||
|
||||
stxt->sh_size += sizeof(stub_i386_linux_kernel_vmlinux_head);
|
||||
|
||||
|
@ -1030,7 +1030,7 @@ unsigned PackVmlinuxAMD64::write_vmlinux_head(
|
|||
// COMPRESSED_LENGTH
|
||||
fo->write(&stub_amd64_linux_kernel_vmlinux_head[0],
|
||||
sizeof(stub_amd64_linux_kernel_vmlinux_head)-(1+ 4) +1);
|
||||
U32 tmp_u32; tmp_u32 = ph.c_len; fo->write(&tmp_u32, 4);
|
||||
TE32 tmp_u32; tmp_u32 = ph.c_len; fo->write(&tmp_u32, 4);
|
||||
printf(" Compressed length=0x%x\n", ph.c_len);
|
||||
printf("UnCompressed length=0x%x\n", ph.u_len);
|
||||
|
||||
|
@ -1089,7 +1089,7 @@ unsigned PackVmlinuxARMEL::write_vmlinux_head(
|
|||
fo->write(&stub_arm_linux_kernel_vmlinux_head[0], 4);
|
||||
|
||||
// Second word
|
||||
U32 tmp_u32;
|
||||
TE32 tmp_u32;
|
||||
unsigned const t = (0xff000000 &
|
||||
BeLePolicy::get32(&stub_arm_linux_kernel_vmlinux_head[4]))
|
||||
| (0x00ffffff & (0u - 1 + ((3+ ph.c_len)>>2)));
|
||||
|
@ -1111,7 +1111,7 @@ unsigned PackVmlinuxARMEB::write_vmlinux_head(
|
|||
fo->write(&stub_armeb_linux_kernel_vmlinux_head[0], 4);
|
||||
|
||||
// Second word
|
||||
U32 tmp_u32;
|
||||
TE32 tmp_u32;
|
||||
unsigned const t = (0xff000000 &
|
||||
BeLePolicy::get32(&stub_armeb_linux_kernel_vmlinux_head[4]))
|
||||
| (0x00ffffff & (0u - 1 + ((3+ ph.c_len)>>2)));
|
||||
|
@ -1135,7 +1135,7 @@ unsigned PackVmlinuxPPC32::write_vmlinux_head(
|
|||
|
||||
bool PackVmlinuxARMEL::has_valid_vmlinux_head()
|
||||
{
|
||||
U32 buf[2];
|
||||
TE32 buf[2];
|
||||
fi->seek(p_text->sh_offset + sizeof(stub_arm_linux_kernel_vmlinux_head) -8, SEEK_SET);
|
||||
fi->readx(buf, sizeof(buf));
|
||||
//unsigned const word0 = buf[0];
|
||||
|
@ -1149,7 +1149,7 @@ bool PackVmlinuxARMEL::has_valid_vmlinux_head()
|
|||
|
||||
bool PackVmlinuxARMEB::has_valid_vmlinux_head()
|
||||
{
|
||||
U32 buf[2];
|
||||
TE32 buf[2];
|
||||
fi->seek(p_text->sh_offset + sizeof(stub_armeb_linux_kernel_vmlinux_head) -8, SEEK_SET);
|
||||
fi->readx(buf, sizeof(buf));
|
||||
//unsigned const word0 = buf[0];
|
||||
|
@ -1163,7 +1163,7 @@ bool PackVmlinuxARMEB::has_valid_vmlinux_head()
|
|||
|
||||
bool PackVmlinuxPPC32::has_valid_vmlinux_head()
|
||||
{
|
||||
U32 buf[2];
|
||||
TE32 buf[2];
|
||||
fi->seek(p_text->sh_offset + sizeof(stub_powerpc_linux_kernel_vmlinux_head) -8, SEEK_SET);
|
||||
fi->readx(buf, sizeof(buf));
|
||||
//unsigned const word0 = buf[0];
|
||||
|
|
|
@ -45,9 +45,9 @@ protected:
|
|||
typedef typename ElfClass::BeLePolicy BeLePolicy;
|
||||
typedef typename ElfClass::ElfITypes ElfITypes;
|
||||
// integral types
|
||||
typedef typename ElfClass::U16 U16;
|
||||
typedef typename ElfClass::U32 U32;
|
||||
typedef typename ElfClass::U64 U64;
|
||||
typedef typename ElfClass::TE16 TE16;
|
||||
typedef typename ElfClass::TE32 TE32;
|
||||
typedef typename ElfClass::TE64 TE64;
|
||||
typedef typename ElfITypes::Addr Addr;
|
||||
// ELF types
|
||||
typedef typename ElfClass::Ehdr Ehdr;
|
||||
|
|
Loading…
Reference in New Issue
Block a user