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