From 579ce20cad68ef7a9a7c5820249486fa6c904593 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 22 Aug 2006 20:49:28 -0700 Subject: [PATCH] remove patchFilter32() --- src/p_lx_elf.cpp | 9 ++++++++- src/p_lx_exc.cpp | 7 +++++++ src/p_unix.cpp | 3 +-- src/packer.h | 1 - src/packer_f.cpp | 21 --------------------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 231189bd..5741e4a8 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -416,8 +416,15 @@ void PackLinuxElf32x86::addStubEntrySections(Filter const *ft) addLoader("FOLDEXEC", NULL); } -void PackLinuxElf32x86::addLinkerSymbols(Filter const */*ft*/) +void PackLinuxElf32x86::addLinkerSymbols(Filter const *const ft) { + if (0x80==(ft->id & 0xF0)) { + int const mru = ft->n_mru ? 1+ ft->n_mru : 0; + if (mru && mru!=256) { + unsigned const is_pwr2 = (0==((mru -1) & mru)); + linker->defineSymbol("NMRU", mru - is_pwr2); + } + } } int diff --git a/src/p_lx_exc.cpp b/src/p_lx_exc.cpp index ee00ae03..499e51c1 100644 --- a/src/p_lx_exc.cpp +++ b/src/p_lx_exc.cpp @@ -376,6 +376,13 @@ PackLinuxI386::buildLinuxLoader( unsigned const stack = getDecompressorWrkmemSize(); linker->defineSymbol("UPXa", 0u - stack); } + if (0x80==(ft->id & 0xF0)) { + int const mru = ft->n_mru ? 1+ ft->n_mru : 0; + if (mru && mru!=256) { + unsigned const is_pwr2 = (0==((mru -1) & mru)); + linker->defineSymbol("NMRU", mru - is_pwr2); + } + } linker->relocate(); return getLoaderSize(); } diff --git a/src/p_unix.cpp b/src/p_unix.cpp index 0ea13de3..4f682295 100644 --- a/src/p_unix.cpp +++ b/src/p_unix.cpp @@ -236,11 +236,10 @@ PackUnix::patchLoaderChecksum() lp->l_checksum = upx_adler32(ptr, lsize); } -void PackUnix::pack3(OutputFile *fo, Filter &ft) +void PackUnix::pack3(OutputFile *fo, Filter &/*ft*/) { upx_byte *p = getLoader(); lsize = getLoaderSize(); - patchFilter32(p, lsize, &ft); updateLoader(fo); patchLoaderChecksum(); fo->write(p, lsize); diff --git a/src/packer.h b/src/packer.h index eb1c2ced..dc502d3e 100644 --- a/src/packer.h +++ b/src/packer.h @@ -237,7 +237,6 @@ protected: virtual void optimizeFilter(Filter *, const upx_byte *, unsigned) const { } virtual void addFilter32(int filter_id); - virtual bool patchFilter32(void *, int, const Filter *ft); // stub and overlay util static void handleStub(InputFile *fi, OutputFile *fo, long size); diff --git a/src/packer_f.cpp b/src/packer_f.cpp index 52e4e091..f9290df2 100644 --- a/src/packer_f.cpp +++ b/src/packer_f.cpp @@ -360,27 +360,6 @@ void Packer::addFilter32(int filter_id) #undef MRUFLT -/************************************************************************* -// patchFilter32 -**************************************************************************/ - -bool Packer::patchFilter32(void *loader, int lsize, const Filter *ft) -{ - if (ft->id == 0) - return false; - assert(ft->calls > 0); - - if (0x80==(ft->id & 0xF0)) { - int const mru = ph.n_mru ? 1+ ph.n_mru : 0; - if (mru && mru!=256) { - unsigned const is_pwr2 = (0==((mru -1) & mru)); - patch_le32(0x80 + (char *)loader, lsize - 0x80, "NMRU", mru - is_pwr2); - } - } - return true; -} - - /* vi:ts=4:et:nowrap */