/* p_lx_elf.h -- This file is part of the UPX executable compressor. Copyright (C) 1996-2016 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996-2016 Laszlo Molnar Copyright (C) 2000-2016 John F. Reiser All Rights Reserved. UPX and the UCL library are free software; you can redistribute them and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Markus F.X.J. Oberhumer Laszlo Molnar John F. Reiser */ #ifndef __UPX_P_LX_ELF_H //{ #define __UPX_P_LX_ELF_H 1 class PackLinuxElf : public PackUnix { typedef PackUnix super; public: PackLinuxElf(InputFile *f); virtual ~PackLinuxElf(); /*virtual void buildLoader(const Filter *);*/ virtual bool canUnpackVersion(int version) const { return (version >= 11); } protected: virtual const int *getCompressionMethods(int method, int level) const; // All other virtual functions in this class must be pure virtual // because they depend on Elf32 or Elf64 data structures, which differ. virtual void pack1(OutputFile *, Filter &) = 0; // generate executable header virtual int pack2(OutputFile *, Filter &) = 0; // append compressed data virtual void pack3(OutputFile *, Filter &) = 0; // append loader //virtual void pack4(OutputFile *, Filter &) = 0; // append pack header virtual void generateElfHdr( OutputFile *, void const *proto, unsigned const brka ) = 0; virtual void defineSymbols(Filter const *); virtual void addStubEntrySections(Filter const *); virtual void unpack(OutputFile *fo); //virtual void const *elf_find_dynamic(unsigned) const = 0; virtual upx_uint64_t elf_unsigned_dynamic(unsigned) const = 0; static unsigned elf_hash(char const *) /*const*/; static unsigned gnu_hash(char const *) /*const*/; protected: unsigned e_type; unsigned e_phnum; /* Program header table entry count */ unsigned e_shnum; MemBuffer file_image; // if ET_DYN investigation char const *dynstr; // from DT_STRTAB unsigned sz_phdrs; // sizeof Phdr[] unsigned sz_elf_hdrs; // all Elf headers unsigned sz_pack2; // after pack2(), before loader unsigned sz_pack2a; // after pack2() of all PT_LOAD unsigned lg2_page; // log2(PAGE_SIZE) unsigned page_size; // 1u<