From 0604f068413e35d19ccd4b9c9255a09816d12ee8 Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Mon, 23 Apr 2007 07:36:46 +0200 Subject: [PATCH] Backed out changeset 1b7b0715e0ab0d3b2e8afc96ac95d46d44bf3618 --- src/conf.h | 3 +- src/p_lx_elf.h | 2 +- src/p_vmlinx.cpp | 92 ------------------------------- src/p_vmlinx.h | 24 -------- src/packer_c.cpp | 6 +- src/packmast.cpp | 2 - src/stub/Makefile | 24 -------- src/stub/i386-bsd.elf-entry.h | 16 +++--- src/stub/src/i386-bsd.elf-entry.S | 12 ++-- 9 files changed, 18 insertions(+), 163 deletions(-) diff --git a/src/conf.h b/src/conf.h index 65e1cfb6..119d5147 100644 --- a/src/conf.h +++ b/src/conf.h @@ -463,9 +463,8 @@ private: #define UPX_F_SOLARIS_SPARC 130 #define UPX_F_MACH_PPC32 131 #define UPX_F_LINUX_ELFPPC32 132 -#define UPX_F_LINUX_ELF32_ARMEB 133 +#define UPX_F_LINUX_ELF32_ARMBE 133 #define UPX_F_MACH_FAT 134 -#define UPX_F_VMLINUX_ARMEB 135 // compression methods diff --git a/src/p_lx_elf.h b/src/p_lx_elf.h index dbf45bd1..f446cddc 100644 --- a/src/p_lx_elf.h +++ b/src/p_lx_elf.h @@ -436,7 +436,7 @@ class PackLinuxElf32armBe : public PackLinuxElf32Be public: PackLinuxElf32armBe(InputFile *f); virtual ~PackLinuxElf32armBe(); - virtual int getFormat() const { return UPX_F_LINUX_ELF32_ARMEB; } + virtual int getFormat() const { return UPX_F_LINUX_ELF32_ARMBE; } virtual const char *getName() const { return "linux/armBE"; } virtual const char *getFullName(const options_t *) const { return "armeb-linux.elf"; } virtual const int *getFilters() const; diff --git a/src/p_vmlinx.cpp b/src/p_vmlinx.cpp index 8e13efe6..7470627d 100644 --- a/src/p_vmlinx.cpp +++ b/src/p_vmlinx.cpp @@ -44,8 +44,6 @@ static const #include "stub/amd64-linux.kernel.vmlinux.h" static const #include "stub/arm-linux.kernel.vmlinux.h" -static const -#include "stub/armeb-linux.kernel.vmlinux.h" /************************************************************************* @@ -554,11 +552,6 @@ const int *PackVmlinuxARM::getCompressionMethods(int method, int level) const return Packer::getDefaultCompressionMethods_8(method, level); } -const int *PackVmlinuxARMEB::getCompressionMethods(int method, int level) const -{ - return Packer::getDefaultCompressionMethods_8(method, level); -} - const int *PackVmlinuxARM::getFilters() const { @@ -566,12 +559,6 @@ const int *PackVmlinuxARM::getFilters() const return f50; } -const int *PackVmlinuxARMEB::getFilters() const -{ - static const int f51[] = { 0x51, FT_END }; - return f51; -} - // // Examples as of 2004-07-16 [readelf --segments vmlinux # before fiddling]: // @@ -664,21 +651,11 @@ bool PackVmlinuxARM::is_valid_e_entry(Addr e_entry) return 0xc0008000==e_entry; } -bool PackVmlinuxARMEB::is_valid_e_entry(Addr e_entry) -{ - return 0xc0008000==e_entry; -} - Linker* PackVmlinuxARM::newLinker() const { return new ElfLinkerArmLE; } -Linker* PackVmlinuxARMEB::newLinker() const -{ - return new ElfLinkerArmBE; -} - void PackVmlinuxARM::buildLoader(const Filter *ft) { @@ -702,28 +679,6 @@ void PackVmlinuxARM::buildLoader(const Filter *ft) addLoader("IDENTSTR,UPX1HEAD", NULL); } -void PackVmlinuxARMEB::buildLoader(const Filter *ft) -{ - // prepare loader - initLoader(stub_armeb_linux_kernel_vmlinux, sizeof(stub_armeb_linux_kernel_vmlinux)); - addLoader("LINUX000", NULL); - if (ft->id) { - assert(ft->calls > 0); - addLoader("LINUX010", NULL); - } - addLoader("LINUX020", NULL); - if (ft->id) { - addFilter32(ft->id); - } - addLoader("LINUX030", NULL); - if (ph.method == M_NRV2E_8) addLoader("NRV2E", NULL); - else if (ph.method == M_NRV2B_8) addLoader("NRV2B", NULL); - else if (ph.method == M_NRV2D_8) addLoader("NRV2D", NULL); - else if (M_IS_LZMA(ph.method)) addLoader("LZMA_ELF00,LZMA_DEC10,LZMA_DEC30", NULL); - else throwBadLoader(); - addLoader("IDENTSTR,UPX1HEAD", NULL); -} - static const #include "stub/i386-linux.kernel.vmlinux-head.h" @@ -731,8 +686,6 @@ static const #include "stub/amd64-linux.kernel.vmlinux-head.h" static const #include "stub/arm-linux.kernel.vmlinux-head.h" -static const -#include "stub/armeb-linux.kernel.vmlinux-head.h" unsigned PackVmlinuxI386::write_vmlinux_head( OutputFile *const fo, @@ -774,14 +727,6 @@ void PackVmlinuxARM::defineDecompressorSymbols() linker->defineSymbol("METHOD", ph.method); } -void PackVmlinuxARMEB::defineDecompressorSymbols() -{ - super::defineDecompressorSymbols(); - linker->defineSymbol( "COMPRESSED_LENGTH", ph.c_len); - linker->defineSymbol("UNCOMPRESSED_LENGTH", ph.u_len); - linker->defineSymbol("METHOD", ph.method); -} - void PackVmlinuxI386::defineDecompressorSymbols() { super::defineDecompressorSymbols(); @@ -821,28 +766,6 @@ unsigned PackVmlinuxARM::write_vmlinux_head( return sizeof(stub_arm_linux_kernel_vmlinux_head); } -unsigned PackVmlinuxARMEB::write_vmlinux_head( - OutputFile *const fo, - Shdr *const stxt -) -{ - // First word from vmlinux-head.S - fo->write(&stub_armeb_linux_kernel_vmlinux_head[0], 4); - - // Second word - U32 tmp_u32; - unsigned const t = (0xff000000 & - BeLePolicy::get32(&stub_armeb_linux_kernel_vmlinux_head[4])) - | (0x00ffffff & (0u - 1 + ((3+ ph.c_len)>>2))); - tmp_u32 = t; - fo->write(&tmp_u32, 4); - - stxt->sh_addralign = 4; - stxt->sh_size += sizeof(stub_armeb_linux_kernel_vmlinux_head); - - return sizeof(stub_armeb_linux_kernel_vmlinux_head); -} - bool PackVmlinuxARM::has_valid_vmlinux_head() { @@ -858,20 +781,6 @@ bool PackVmlinuxARM::has_valid_vmlinux_head() return false; } -bool PackVmlinuxARMEB::has_valid_vmlinux_head() -{ - U32 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]; - unsigned const word1 = buf[1]; - if (0xeb==(word1>>24) - && (0x00ffffff& word1)==(0u - 1 + ((3+ ph.c_len)>>2))) { - return true; - } - return false; -} - bool PackVmlinuxI386::has_valid_vmlinux_head() { unsigned char buf[5]; @@ -1149,7 +1058,6 @@ Linker* PackVmlinuxAMD64::newLinker() const // instantiate instances template class PackVmlinuxBase; -template class PackVmlinuxBase; template class PackVmlinuxBase; diff --git a/src/p_vmlinx.h b/src/p_vmlinx.h index f9c28a4e..04ad83b5 100644 --- a/src/p_vmlinx.h +++ b/src/p_vmlinx.h @@ -143,30 +143,6 @@ protected: ); }; -class PackVmlinuxARMEB : public PackVmlinuxBase -{ - typedef PackVmlinuxBase super; -public: - PackVmlinuxARMEB(InputFile *f) : super(f, Ehdr::EM_ARM, - Ehdr::ELFCLASS32, Ehdr::ELFDATA2MSB, "decompress_kernel") { } - virtual int getFormat() const { return UPX_F_VMLINUX_ARMEB; } - virtual const char *getName() const { return "vmlinux/ARMEB"; } - virtual const char *getFullName(const options_t *) const { return "armbe-linux.kernel.vmlinux"; } - virtual const int *getCompressionMethods(int method, int level) const; - virtual const int *getFilters() const; - -protected: - virtual void buildLoader(const Filter *ft); - virtual void defineDecompressorSymbols(); - virtual Linker* newLinker() const; - virtual bool is_valid_e_entry(Addr); - virtual bool has_valid_vmlinux_head(); - virtual unsigned write_vmlinux_head( - OutputFile *const fo, - Shdr *const stxt - ); -}; - class PackVmlinuxAMD64 : public PackVmlinuxBase { diff --git a/src/packer_c.cpp b/src/packer_c.cpp index c14c8428..437089be 100644 --- a/src/packer_c.cpp +++ b/src/packer_c.cpp @@ -210,10 +210,9 @@ const char *Packer::getDecompressorSections() const || UPX_F_LINUX_ELF64_AMD ==ph.format || UPX_F_LINUX_ELF32_ARMLE==ph.format || UPX_F_LINUX_ELFPPC32 ==ph.format - || UPX_F_LINUX_ELF32_ARMEB==ph.format + || UPX_F_LINUX_ELF32_ARMBE==ph.format || UPX_F_BSD_ELF_i386 ==ph.format || UPX_F_VMLINUX_ARM ==ph.format - || UPX_F_VMLINUX_ARMEB ==ph.format || UPX_F_MACH_PPC32 ==ph.format || UPX_F_MACH_i386 ==ph.format ) { @@ -247,10 +246,9 @@ void Packer::defineDecompressorSymbols() || UPX_F_LINUX_ELF64_AMD ==ph.format || UPX_F_LINUX_ELF32_ARMLE==ph.format || UPX_F_LINUX_ELFPPC32 ==ph.format - || UPX_F_LINUX_ELF32_ARMEB==ph.format + || UPX_F_LINUX_ELF32_ARMBE==ph.format || UPX_F_BSD_ELF_i386 ==ph.format || UPX_F_VMLINUX_ARM ==ph.format - || UPX_F_VMLINUX_ARMEB ==ph.format || UPX_F_MACH_PPC32 ==ph.format || UPX_F_MACH_i386 ==ph.format ) { diff --git a/src/packmast.cpp b/src/packmast.cpp index d77419b1..9144e14e 100644 --- a/src/packmast.cpp +++ b/src/packmast.cpp @@ -194,8 +194,6 @@ Packer* PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const optio // if ((p = func(new PackVmlinuxARM(f), user)) != NULL) return p; - if ((p = func(new PackVmlinuxARMEB(f), user)) != NULL) - return p; if ((p = func(new PackVmlinuxAMD64(f), user)) != NULL) return p; if ((p = func(new PackVmlinuxI386(f), user)) != NULL) diff --git a/src/stub/Makefile b/src/stub/Makefile index 75ea26e2..992286d9 100644 --- a/src/stub/Makefile +++ b/src/stub/Makefile @@ -56,8 +56,6 @@ STUBS += arm-linux.kernel.vmlinux.h STUBS += arm-linux.kernel.vmlinux-head.h STUBS += armeb-linux.elf-entry.h STUBS += armeb-linux.elf-fold.h -STUBS += armeb-linux.kernel.vmlinux.h -STUBS += armeb-linux.kernel.vmlinux-head.h STUBS += arm.v4a-wince.pe.h STUBS += arm.v4t-wince.pe.h STUBS += i086-dos16.com.h @@ -338,28 +336,6 @@ arm-linux.kernel.vmlinux-head.h : $(srcdir)/src/$$T.S $(call tc,bin2h) tmp/$T.bin $@ -# /*********************************************************************** -# // armeb-linux.kernel.vmlinux -# // armeb-linux.kernel.vmlinuz -# // armeb-linux.kernel.vmlinux-head -# ************************************************************************/ - -armeb-linux.kernel.vmlinu%.h : tc_list = armeb-linux.kernel default -armeb-linux.kernel.vmlinu%.h : tc_bfdname = elf32-bigarm - -tc.armeb-linux.kernel.gcc = $(tc.arm-linux.elf.gcc) -mbig-endian - -armeb-linux.kernel.vmlinu%.h : $(srcdir)/src/$$T.S - $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.bin - $(call tc,f-embed_objinfo,tmp/$T.bin) - $(call tc,bin2h-c) tmp/$T.bin $@ - -armeb-linux.kernel.vmlinux-head.h : $(srcdir)/src/$$T.S - $(call tc,gcc) -c -x assembler-with-cpp $< -o tmp/$T.o - $(call tc,objcopy) --output-target binary --only-section .text tmp/$T.o tmp/$T.bin - $(call tc,bin2h) tmp/$T.bin $@ - - # /*********************************************************************** # // armeb-linux.elf # ************************************************************************/ diff --git a/src/stub/i386-bsd.elf-entry.h b/src/stub/i386-bsd.elf-entry.h index 9a297fd2..78569aaa 100644 --- a/src/stub/i386-bsd.elf-entry.h +++ b/src/stub/i386-bsd.elf-entry.h @@ -29,15 +29,15 @@ #define STUB_I386_BSD_ELF_ENTRY_SIZE 37562 -#define STUB_I386_BSD_ELF_ENTRY_ADLER32 0x0c31915d -#define STUB_I386_BSD_ELF_ENTRY_CRC32 0x68fd1b14 +#define STUB_I386_BSD_ELF_ENTRY_ADLER32 0xb6d5917d +#define STUB_I386_BSD_ELF_ENTRY_CRC32 0x57a02d3a unsigned char stub_i386_bsd_elf_entry[37562] = { 127, 69, 76, 70, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 0 */ 1, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x 10 */ 116, 34, 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, 0, 0, 40, 0, /* 0x 20 */ -243, 0,240, 0,232,123, 0, 0, 0, 96,139,116, 36, 36,139,124, /* 0x 30 */ - 36, 44,131,205,255,235, 3,164,235, 3,138, 6, 70,136, 7, 71, /* 0x 40 */ +243, 0,240, 0,232,123, 0, 0, 0, 96,139,116, 36, 40,139,124, /* 0x 30 */ + 36, 48,131,205,255,235, 3,164,235, 3,138, 6, 70,136, 7, 71, /* 0x 40 */ 1,219,117, 7,139, 30,131,238,252, 17,219,114, 1, 49,192, 64, /* 0x 50 */ 138, 7,114,255,184, 1, 0, 0, 0, 1,219,117, 7,139, 30,131, /* 0x 60 */ 238,252, 17,219, 17,192, 1,219,117, 7,139, 30,131,238,252, 17, /* 0x 70 */ @@ -88,10 +88,10 @@ unsigned char stub_i386_bsd_elf_entry[37562] = { 4,119,241, 1,207,233,252,255,255,255,137,229,141,156, 36, 0, /* 0x 340 */ 0, 0, 0, 49,192, 80, 57,220,117,251, 70, 70, 83,104, 0, 0, /* 0x 350 */ 0, 0, 87,131,195, 4, 83,104, 0, 0, 0, 0, 86,131,195, 4, /* 0x 360 */ - 83, 80,199, 3, 0, 0, 0, 0,137,229,139, 85, 40,172, 74,136, /* 0x 370 */ + 83, 80,199, 3, 0, 0, 0, 0,137,229,139, 85, 44,172, 74,136, /* 0x 370 */ 193, 36, 7,192,233, 3,187, 0,253,255,255,211,227,141,164, 92, /* 0x 380 */ 144,241,255,255,131,228,224,106, 0,106, 0,137,227, 83,131,195, /* 0x 390 */ - 4,139, 77, 48,255, 49, 87, 83,131,195, 4,136, 67, 2,172, 74, /* 0x 3a0 */ + 4,139, 77, 52,255, 49, 87, 83,131,195, 4,136, 67, 2,172, 74, /* 0x 3a0 */ 136,193, 36, 15,136, 3,192,233, 4,136, 75, 1, 82, 86, 83, 80, /* 0x 3b0 */ 85, 87, 86, 83,131,236,124,139,148, 36,144, 0, 0, 0,199, 68, /* 0x 3c0 */ 36,116, 0, 0, 0, 0,198, 68, 36,115, 0,139,172, 36,156, 0, /* 0x 3d0 */ @@ -431,8 +431,8 @@ unsigned char stub_i386_bsd_elf_entry[37562] = { 148, 36,156, 0, 0, 0,139, 76, 36,116,137, 26,139,156, 36,168, /* 0x18b0 */ 0, 0, 0,137, 11,131,196,124, 91, 94, 95, 93, 3,115,252, 3, /* 0x18c0 */ 123,248, 49,192,141,140, 36, 0,255,255,255,137,236, 80, 57,204, /* 0x18d0 */ -117,251,137,236, 49,201,139, 84, 36, 36, 3, 84, 36, 40, 57,214, /* 0x18e0 */ -116, 1, 72, 43,124, 36, 44,139, 84, 36, 48,137, 58,137, 68, 36, /* 0x18f0 */ +117,251,137,236, 49,201,139, 84, 36, 40, 3, 84, 36, 44, 57,214, /* 0x18e0 */ +116, 1, 72, 43,124, 36, 48,139, 84, 36, 52,137, 58,137, 68, 36, /* 0x18f0 */ 28, 97,195,235, 4, 90, 88, 89,151, 96, 49,219,187, 0, 0, 0, /* 0x1900 */ 0,106, 15, 88,138,100, 36, 32,106, 15, 91,138,124, 36, 32,138, /* 0x1910 */ 84, 36, 32,233,252,255,255,255, 15,183, 47, 43,110, 12, 41,221, /* 0x1920 */ diff --git a/src/stub/src/i386-bsd.elf-entry.S b/src/stub/src/i386-bsd.elf-entry.S index 5083a9d9..071f6def 100644 --- a/src/stub/src/i386-bsd.elf-entry.S +++ b/src/stub/src/i386-bsd.elf-entry.S @@ -67,12 +67,12 @@ decompress: // // C callable decompressor // **************************************************************************/ -// /* Offsets to parameters, allowing for {pusha + call} */ -#define O_INP (8*4 +1*4) -#define O_INS (8*4 +2*4) -#define O_OUTP (8*4 +3*4) -#define O_OUTS (8*4 +4*4) -#define O_PARAM (8*4 +5*4) +// /* Offsets to parameters, allowing for {push + pusha + call} */ +#define O_INP (4+ 8*4 +1*4) +#define O_INS (4+ 8*4 +2*4) +#define O_OUTP (4+ 8*4 +3*4) +#define O_OUTS (4+ 8*4 +4*4) +#define O_PARAM (4+ 8*4 +5*4) #define INP dword ptr [esp+O_INP] #define INS dword ptr [esp+O_INS]