From 1a0a64e4de2ae99438c3827118efbabda83841b3 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Sun, 9 Jul 2006 08:48:06 -0700 Subject: [PATCH] ::addStubEntrySections() with default ELFMAINX --- src/p_lx_elf.cpp | 39 ++++++++++++++++++++++++++++----------- src/p_lx_elf.h | 2 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index b151442c..628f6e1c 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -150,19 +150,24 @@ PackLinuxElf::PackLinuxElf(InputFile *f) { } -Linker *PackLinuxElf::newLinker() const -{ - return new ElfLinker; -} - PackLinuxElf::~PackLinuxElf() { delete[] file_image; } -Linker* PackLinuxElf64amd::newLinker() const +Linker *PackLinuxElf::newLinker() const { - return new ElfLinkerAMD64; + return new ElfLinker; +} + +void +PackLinuxElf::addStubEntrySections( + upx_byte const *const proto, + unsigned const szproto +) +{ + linker->addSection("ELFMAINX", proto, szproto); + addLoader("ELFMAINX", NULL); } PackLinuxElf32::PackLinuxElf32(InputFile *f) @@ -186,6 +191,11 @@ PackLinuxElf64::~PackLinuxElf64() delete[] phdri; } +Linker* PackLinuxElf64amd::newLinker() const +{ + return new ElfLinkerAMD64; +} + int const * PackLinuxElf::getCompressionMethods(int method, int level) const { @@ -512,9 +522,8 @@ PackLinuxElf32::buildLinuxLoader( //int const GAP = 128; // must match stub/l_mac_ppc.S //segcmdo.vmsize += sz_unc - sz_cpr + GAP + 64; - linker->addSection("ELFMAINX", proto, szproto); + addStubEntrySections(proto, szproto); - addLoader("ELFMAINX", NULL); addLoader("FOLDEXEC", NULL); freezeLoader(); return getLoaderSize(); @@ -568,14 +577,22 @@ PackLinuxElf64::buildLinuxLoader( linker->addSection("FOLDEXEC", cprLoader, sizeof(h) + sz_cpr); delete [] cprLoader; - linker->addSection("ELFMAINX", proto, szproto); + addStubEntrySections(proto, szproto); - addLoader("ELFMAINX", NULL); addLoader("FOLDEXEC", NULL); freezeLoader(); return getLoaderSize(); } +void +PackLinuxElf64amd::addStubEntrySections( + upx_byte const *const /*proto*/, + unsigned const /*szproto*/ +) +{ + // FIXME +} + static const #include "stub/i386-linux.elf-entry.h" static const diff --git a/src/p_lx_elf.h b/src/p_lx_elf.h index bbb6e034..64113427 100644 --- a/src/p_lx_elf.h +++ b/src/p_lx_elf.h @@ -60,6 +60,7 @@ protected: void const *proto, unsigned const brka ) = 0; + virtual void addStubEntrySections(upx_byte const *, unsigned); virtual void unpack(OutputFile *fo) = 0; protected: @@ -286,6 +287,7 @@ protected: virtual void pack3(OutputFile *, Filter &); // append loader virtual const int *getCompressionMethods(int method, int level) const; virtual int buildLoader(const Filter *); + virtual void addStubEntrySections(upx_byte const *, unsigned); virtual Linker* newLinker() const; };