diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 296ef899..fa55470f 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -1978,7 +1978,7 @@ bool PackLinuxElf32::calls_crt1(Elf32_Rel const *rel, int sz) #include "p_elf_enum.h" #undef WANT_REL_ENUM -int PackLinuxElf32::canUnpack() // really 'bool' +int PackLinuxElf32::canUnpack() // bool, except -1: format known, but not packed { if (checkEhdr(&ehdri)) { return false; @@ -2409,7 +2409,7 @@ proceed: ; return true; } -int PackLinuxElf64::canUnpack() // really 'bool' +int PackLinuxElf64::canUnpack() // bool, except -1: format known, but not packed { if (checkEhdr(&ehdri)) { return false; @@ -2497,7 +2497,7 @@ PackLinuxElf64::canPack() max_offset = UPX_MAX(max_offset, get_te64(&phdr->p_filesz) + get_te64(&phdr->p_offset)); } } - if (canUnpack()) { + if (canUnpack() > 0) { throwAlreadyPacked(); } // We want to compress position-independent executable (gcc -pie) @@ -5340,7 +5340,7 @@ PackLinuxElf32x86::~PackLinuxElf32x86() { } -int PackLinuxElf32x86::canUnpack() // really 'bool' +int PackLinuxElf32x86::canUnpack() // bool, except -1: format known, but not packed { if (super::canUnpack()) { return true; diff --git a/src/p_lx_elf.h b/src/p_lx_elf.h index 3258f609..1f3bc14d 100644 --- a/src/p_lx_elf.h +++ b/src/p_lx_elf.h @@ -42,7 +42,7 @@ public: /*virtual void buildLoader(const Filter *);*/ virtual int getVersion() const override { return 14; } // upx-3.96 cannot upack, for instance virtual bool canUnpackVersion(int version) const override { return (version >= 11); } - virtual int canUnpack() override { return super::canUnpack(); } // really 'bool' + virtual int canUnpack() override { return super::canUnpack(); } // bool, except -1: format known, but not packed protected: virtual const int *getCompressionMethods(int method, int level) const override; @@ -123,7 +123,7 @@ protected: virtual void PackLinuxElf32help1(InputFile *f); virtual int checkEhdr(Elf32_Ehdr const *ehdr) const; virtual bool canPack() override; - virtual int canUnpack() override; // really 'bool' + virtual int canUnpack() override; // bool, except -1: format known, but not packed // These ARM routines are essentially common to big/little endian, // but the class hierarchy splits after this class. @@ -266,7 +266,7 @@ protected: virtual void PackLinuxElf64help1(InputFile *f); virtual int checkEhdr(Elf64_Ehdr const *ehdr) const; virtual bool canPack() override; - virtual int canUnpack() override; // really 'bool' + virtual int canUnpack() override; // bool, except -1: format known, but not packed virtual void pack1(OutputFile *, Filter &) override; // generate executable header virtual void asl_pack2_Shdrs(OutputFile *); // AndroidSharedLibrary processes Shdrs @@ -559,7 +559,7 @@ public: virtual const char *getName() const override { return "linux/i386"; } virtual const char *getFullName(const options_t *) const override { return "i386-linux.elf"; } virtual const int *getFilters() const override; - virtual int canUnpack() override; // reallly 'bool' + virtual int canUnpack() override; // bool, except -1: format known, but not packed protected: virtual void pack1(OutputFile *, Filter &) override; // generate executable header diff --git a/src/p_unix.h b/src/p_unix.h index 35739bb9..07e669a9 100644 --- a/src/p_unix.h +++ b/src/p_unix.h @@ -49,7 +49,7 @@ public: virtual void unpack(OutputFile *fo) override; virtual bool canPack() override; - virtual int canUnpack() override; // really 'bool' + virtual int canUnpack() override; // bool, except -1: format known, but not packed int find_overlay_offset(MemBuffer const &buf); protected: diff --git a/src/packer.h b/src/packer.h index 3ed72373..6e73ed24 100644 --- a/src/packer.h +++ b/src/packer.h @@ -155,12 +155,10 @@ protected: public: // canPack() should throw a cantPackException eplaining why it // cannot pack a recognized format. - // canUnpack() can return -1 meaning "format recognized, but file - // is definitely not packed" (see packmast.cpp). virtual bool canPack() = 0; + // canUnpack() can return -1 meaning "format recognized, but file + // is definitely not packed". See packmast.cpp try_unpack(). virtual int canUnpack() = 0; - virtual int canTest() { return canUnpack(); } - virtual int canList() { return canUnpack(); } protected: // main compression drivers