From 83052eafaedcf274f939cb5a1dfc15e3bc88eaad Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Fri, 1 Dec 2006 00:57:03 +0100 Subject: [PATCH] Minor cleanups. --- src/help.cpp | 18 +++++++++--------- src/linker.cpp | 8 +++++--- src/linker.h | 2 +- src/packer.cpp | 2 +- src/packer.h | 2 +- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/help.cpp b/src/help.cpp index 3a6abd2a..cd1111ec 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -100,8 +100,8 @@ struct PackerNames Entry names[32]; size_t names_count; const options_t *o; - PackerNames() { names_count = 0; o = NULL; } - void add(Packer *p) + PackerNames() : names_count(0), o(NULL) { } + void add(const Packer *p) { p->assertPacker(); assert(names_count < 32); @@ -161,7 +161,7 @@ static void show_all_packers(FILE *f, int verbose) // **************************************************************************/ -void show_help(int x/*verbose*/) +void show_help(int verbose) { FILE *f = con_term; int fg; @@ -178,8 +178,8 @@ void show_help(int x/*verbose*/) " -d decompress -l list compressed file\n" " -t test compressed file -V display version number\n" " -h give %s help -L display software license\n%s", - x == 0 ? "" : " --best compress best (can be slow for big files)\n", - x == 0 ? "more" : "this", x == 0 ? "" : "\n"); + verbose == 0 ? "" : " --best compress best (can be slow for big files)\n", + verbose == 0 ? "more" : "this", verbose == 0 ? "" : "\n"); fg = con_fg(f,FG_YELLOW); con_fprintf(f,"Options:\n"); @@ -191,15 +191,15 @@ void show_help(int x/*verbose*/) //" -f force overwrite of output files and compression of suspicious files\n" " -f force compression of suspicious files\n" "%s%s" - , (x == 0) ? " -k keep backup files\n" : "" + , (verbose == 0) ? " -k keep backup files\n" : "" #if 1 - , (x > 0) ? " --no-color, --mono, --color, --no-progress change look\n" : "" + , (verbose > 0) ? " --no-color, --mono, --color, --no-progress change look\n" : "" #else , "" #endif ); - if (x > 0) + if (verbose > 0) { fg = con_fg(f,FG_YELLOW); con_fprintf(f,"\nBackup options:\n"); @@ -318,7 +318,7 @@ void show_help(int x/*verbose*/) fg = con_fg(f,FG_YELLOW); con_fprintf(f,"This version supports:\n"); fg = con_fg(f,fg); - show_all_packers(f, x); + show_all_packers(f, verbose); con_fprintf(f,"\nUPX comes with ABSOLUTELY NO WARRANTY; for details visit http://upx.sf.net\n" // "\nUPX comes with ABSOLUTELY NO WARRANTY; for details type `upx -L'.\n" ""); diff --git a/src/linker.cpp b/src/linker.cpp index 24e0af22..3e984525 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -173,14 +173,14 @@ void ElfLinker::init(const void *pdata_v, int plen) output = new upx_byte[inputlen]; outputlen = 0; - int pos = find(input, inputlen, "Sections:", 9); + int pos = find(input, inputlen, "Sections:\n", 10); assert(pos != -1); char *psections = (char *) input + pos; - char *psymbols = strstr(psections, "SYMBOL TABLE:"); + char *psymbols = strstr(psections, "SYMBOL TABLE:\n"); assert(psymbols != NULL); - char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR"); + char *prelocs = strstr(psymbols, "RELOCATION RECORDS FOR "); assert(prelocs != NULL); preprocessSections(psections, psymbols); @@ -369,11 +369,13 @@ ElfLinker::Relocation *ElfLinker::addRelocation(const char *section, unsigned of return rel; } +#if 0 void ElfLinker::setLoaderAlignOffset(int phase) { //assert(phase & 0); printf("\nFIXME: ElfLinker::setLoaderAlignOffset %d\n", phase); } +#endif int ElfLinker::addLoader(const char *sname) { diff --git a/src/linker.h b/src/linker.h index 73554210..b7cbd44f 100644 --- a/src/linker.h +++ b/src/linker.h @@ -81,7 +81,7 @@ public: virtual ~ElfLinker(); virtual void init(const void *pdata, int plen); - virtual void setLoaderAlignOffset(int phase); + //virtual void setLoaderAlignOffset(int phase); virtual int addLoader(const char *sname); virtual Section *addSection(const char *sname, const void *sdata, int slen, unsigned p2align); virtual int getSection(const char *sname, int *slen=NULL) const; diff --git a/src/packer.cpp b/src/packer.cpp index 4920ef57..92e9eb2a 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -60,7 +60,7 @@ Packer::~Packer() // for PackMaster -void Packer::assertPacker() +void Packer::assertPacker() const { assert(getFormat() > 0); assert(getFormat() <= 255); diff --git a/src/packer.h b/src/packer.h index d58dcef1..18c46b66 100644 --- a/src/packer.h +++ b/src/packer.h @@ -119,7 +119,7 @@ protected: Packer(InputFile *f); public: virtual ~Packer(); - virtual void assertPacker(); + virtual void assertPacker() const; virtual int getVersion() const = 0; // A unique integer ID for this executable format. See conf.h.