From cb4704c821a0742f464b52947cb76e32e594f9e4 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Tue, 19 Dec 2006 15:22:50 +0100 Subject: [PATCH] Cosmetic cleanups. --- src/p_elf.h | 18 +++++++++++++++--- src/p_vmlinx.h | 13 +++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/p_elf.h b/src/p_elf.h index a7fac4b8..401d0fd4 100644 --- a/src/p_elf.h +++ b/src/p_elf.h @@ -36,10 +36,10 @@ namespace N_Elf { +// integral types template struct ElfITypes { - // integral types typedef THalf Half; typedef TWord Word; typedef TXword Xword; @@ -94,6 +94,7 @@ struct Dyn } __attribute_packed; + } // namespace N_Elf @@ -255,7 +256,7 @@ __attribute_packed; /************************************************************************* -// aggregate types in an ElfClass +// aggregate types into an ElfClass **************************************************************************/ namespace N_Elf { @@ -285,6 +286,11 @@ struct ElfClass_32 COMPILE_TIME_ASSERT(sizeof(Shdr) == 40) COMPILE_TIME_ASSERT(sizeof(Dyn) == 8) COMPILE_TIME_ASSERT(sizeof(Sym) == 16) + COMPILE_TIME_ASSERT_ALIGNOF(Ehdr, char) + COMPILE_TIME_ASSERT_ALIGNOF(Phdr, char) + COMPILE_TIME_ASSERT_ALIGNOF(Shdr, char) + COMPILE_TIME_ASSERT_ALIGNOF(Dyn, char) + COMPILE_TIME_ASSERT_ALIGNOF(Sym, char) } }; @@ -314,9 +320,15 @@ struct ElfClass_64 COMPILE_TIME_ASSERT(sizeof(Shdr) == 64) COMPILE_TIME_ASSERT(sizeof(Dyn) == 16) COMPILE_TIME_ASSERT(sizeof(Sym) == 24) + COMPILE_TIME_ASSERT_ALIGNOF(Ehdr, char) + COMPILE_TIME_ASSERT_ALIGNOF(Phdr, char) + COMPILE_TIME_ASSERT_ALIGNOF(Shdr, char) + COMPILE_TIME_ASSERT_ALIGNOF(Dyn, char) + COMPILE_TIME_ASSERT_ALIGNOF(Sym, char) } }; + } // namespace N_Elf @@ -329,7 +341,7 @@ typedef N_Elf::ElfClass_64 ElfClass_LE64; /************************************************************************* -// typedef shortcuts +// shortcuts **************************************************************************/ typedef ElfClass_Host32::Ehdr Elf32_Ehdr; diff --git a/src/p_vmlinx.h b/src/p_vmlinx.h index 4e1cf7d7..ee83e5d9 100644 --- a/src/p_vmlinx.h +++ b/src/p_vmlinx.h @@ -65,6 +65,7 @@ protected: unsigned int const my_e_machine; unsigned char const my_elfclass; unsigned char const my_elfdata; + int n_ptload; unsigned sz_ptload; Phdr *phdri; // from input file @@ -87,8 +88,8 @@ class PackVmlinuxI386 : public PackVmlinuxBase { typedef PackVmlinuxBase super; public: - PackVmlinuxI386(InputFile *f) : super(f, Elf32_Ehdr::EM_386, - Elf32_Ehdr::ELFCLASS32, Elf32_Ehdr::ELFDATA2LSB) { } + PackVmlinuxI386(InputFile *f) : super(f, Ehdr::EM_386, + Ehdr::ELFCLASS32, Ehdr::ELFDATA2LSB) { } virtual int getFormat() const { return UPX_F_VMLINUX_i386; } virtual const char *getName() const { return "vmlinux/386"; } virtual const char *getFullName(const options_t *) const { return "i386-linux.kernel.vmlinux"; } @@ -111,8 +112,8 @@ class PackVmlinuxARM : public PackVmlinuxBase { typedef PackVmlinuxBase super; public: - PackVmlinuxARM(InputFile *f) : super(f, Elf32_Ehdr::EM_ARM, - Elf32_Ehdr::ELFCLASS32, Elf32_Ehdr::ELFDATA2LSB) { } + PackVmlinuxARM(InputFile *f) : super(f, Ehdr::EM_ARM, + Ehdr::ELFCLASS32, Ehdr::ELFDATA2LSB) { } virtual int getFormat() const { return UPX_F_VMLINUX_ARM; } virtual const char *getName() const { return "vmlinux/ARM"; } virtual const char *getFullName(const options_t *) const { return "ARM-linux.kernel.vmlinux"; } @@ -135,8 +136,8 @@ class PackVmlinuxAMD64 : public PackVmlinuxBase { typedef PackVmlinuxBase super; public: - PackVmlinuxAMD64(InputFile *f) : super(f, Elf64_Ehdr::EM_X86_64, - Elf64_Ehdr::ELFCLASS64, Elf64_Ehdr::ELFDATA2LSB) { } + PackVmlinuxAMD64(InputFile *f) : super(f, Ehdr::EM_X86_64, + Ehdr::ELFCLASS64, Ehdr::ELFDATA2LSB) { } virtual int getFormat() const { return UPX_F_VMLINUX_AMD64; } virtual const char *getName() const { return "vmlinux/AMD64"; } virtual const char *getFullName(const options_t *) const { return "amd64-linux.kernel.vmlinux"; }