Silence some compiler warnings.

This commit is contained in:
Markus F.X.J. Oberhumer
2017-04-05 16:33:09 +02:00
parent cdd58cf757
commit 2c23cbb359
2 changed files with 56 additions and 97 deletions
+4 -4
View File
@@ -2374,7 +2374,7 @@ PackLinuxElf32::generateElfHdr(
set_te32(&h2->phdr[1].p_flags, Elf32_Phdr::PF_R | Elf32_Phdr::PF_W); set_te32(&h2->phdr[1].p_flags, Elf32_Phdr::PF_R | Elf32_Phdr::PF_W);
} }
if (ph.format==getFormat()) { if (ph.format==getFormat()) {
assert((2+ !!gnu_stack) == get_te16(&h2->ehdr.e_phnum)); assert((2u+ !!gnu_stack) == get_te16(&h2->ehdr.e_phnum));
set_te32(&h2->phdr[0].p_flags, ~Elf32_Phdr::PF_W & get_te32(&h2->phdr[0].p_flags)); set_te32(&h2->phdr[0].p_flags, ~Elf32_Phdr::PF_W & get_te32(&h2->phdr[0].p_flags));
if (!gnu_stack) { if (!gnu_stack) {
memset(&h2->linfo, 0, sizeof(h2->linfo)); memset(&h2->linfo, 0, sizeof(h2->linfo));
@@ -2635,7 +2635,7 @@ PackLinuxElf64::generateElfHdr(
set_te32(&h2->phdr[1].p_flags, Elf64_Phdr::PF_R | Elf64_Phdr::PF_W); set_te32(&h2->phdr[1].p_flags, Elf64_Phdr::PF_R | Elf64_Phdr::PF_W);
} }
if (ph.format==getFormat()) { if (ph.format==getFormat()) {
assert((2+ !!gnu_stack) == get_te16(&h2->ehdr.e_phnum)); assert((2u+ !!gnu_stack) == get_te16(&h2->ehdr.e_phnum));
set_te32(&h2->phdr[0].p_flags, ~Elf64_Phdr::PF_W & get_te32(&h2->phdr[0].p_flags)); set_te32(&h2->phdr[0].p_flags, ~Elf64_Phdr::PF_W & get_te32(&h2->phdr[0].p_flags));
if (!gnu_stack) { if (!gnu_stack) {
memset(&h2->linfo, 0, sizeof(h2->linfo)); memset(&h2->linfo, 0, sizeof(h2->linfo));
@@ -3537,7 +3537,7 @@ void PackLinuxElf32::pack4(OutputFile *fo, Filter &ft)
if (0!=xct_off) { // shared library if (0!=xct_off) { // shared library
if (opt->o_unix.android_shlib && shdri) { // dlopen() checks Elf32_Shdr vs Elf32_Phdr if (opt->o_unix.android_shlib && shdri) { // dlopen() checks Elf32_Shdr vs Elf32_Phdr
unsigned load0_hi = ~0; unsigned load0_hi = ~0u;
Elf32_Phdr const *phdr = phdri; Elf32_Phdr const *phdr = phdri;
for (unsigned j = 0; j < e_phnum; ++j, ++phdr) { for (unsigned j = 0; j < e_phnum; ++j, ++phdr) {
unsigned load0_lo = get_te32(&phdr->p_vaddr); unsigned load0_lo = get_te32(&phdr->p_vaddr);
@@ -3668,7 +3668,7 @@ void PackLinuxElf64::pack4(OutputFile *fo, Filter &ft)
if (0!=xct_off) { // shared library if (0!=xct_off) { // shared library
if (opt->o_unix.android_shlib && shdri) { // dlopen() checks Elf64_Shdr vs Elf64_Phdr if (opt->o_unix.android_shlib && shdri) { // dlopen() checks Elf64_Shdr vs Elf64_Phdr
unsigned load0_hi = ~0; unsigned load0_hi = ~0u;
Elf64_Phdr const *phdr = phdri; Elf64_Phdr const *phdr = phdri;
for (unsigned j = 0; j < e_phnum; ++j, ++phdr) { for (unsigned j = 0; j < e_phnum; ++j, ++phdr) {
upx_uint64_t load0_lo = get_te64(&phdr->p_vaddr); upx_uint64_t load0_lo = get_te64(&phdr->p_vaddr);
+52 -93
View File
@@ -148,13 +148,16 @@ static Packer* try_unpack(Packer *p, void *user)
**************************************************************************/ **************************************************************************/
#define D(name) if (o->debug.debug_level) fprintf(stderr, "%s\n", #name)
Packer* PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const options_t *o, void *user) Packer* PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const options_t *o, void *user)
{ {
Packer *p = NULL; Packer *p = NULL;
#define D(klass) \
ACC_BLOCK_BEGIN \
if (o->debug.debug_level) fprintf(stderr, "visitAllPackers: %s\n", #klass); \
if ((p = func(new klass(f), user)) != NULL) return p; \
ACC_BLOCK_END
// note: order of tries is important ! // note: order of tries is important !
// //
@@ -162,49 +165,32 @@ Packer* PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const optio
// //
if (!o->dos_exe.force_stub) if (!o->dos_exe.force_stub)
{ {
D(PackDjgpp2); if ((p = func(new PackDjgpp2(f), user))) D(PackDjgpp2);
return p; D(PackTmt);
D(PackTmt); if ((p = func(new PackTmt(f), user))) D(PackWcle);
return p; D(PackW64Pep);
D(PackWcle); if ((p = func(new PackWcle(f), user))) D(PackW32Pe);
return p;
D(PackW64Pep); if ((p = func(new PackW64Pep(f), user)))
return p;
D(PackW32Pe); if ((p = func(new PackW32Pe(f), user)))
return p;
} }
D(PackArmPe); if ((p = func(new PackArmPe(f), user))) D(PackArmPe);
return p; D(PackExe);
D(PackExe); if ((p = func(new PackExe(f), user)))
return p;
// //
// atari // atari
// //
D(PackTos); if ((p = func(new PackTos(f), user))) D(PackTos);
return p;
// //
// linux kernel // linux kernel
// //
D(PackVmlinuxARMEL); if ((p = func(new PackVmlinuxARMEL(f), user))) D(PackVmlinuxARMEL);
return p; D(PackVmlinuxARMEB);
D(PackVmlinuxARMEB); if ((p = func(new PackVmlinuxARMEB(f), user))) D(PackVmlinuxPPC32);
return p; D(PackVmlinuxPPC64LE);
D(PackVmlinuxPPC32); if ((p = func(new PackVmlinuxPPC32(f), user))) D(PackVmlinuxAMD64);
return p; D(PackVmlinuxI386);
D(PackVmlinuxPPC64LE); if ((p = func(new PackVmlinuxPPC64LE(f), user))) D(PackVmlinuzI386);
return p; D(PackBvmlinuzI386);
D(PackVmlinuxAMD64); if ((p = func(new PackVmlinuxAMD64(f), user))) D(PackVmlinuzARMEL);
return p;
D(PackVmlinuxI386); if ((p = func(new PackVmlinuxI386(f), user)))
return p;
D(PackVmlinuzI386); if ((p = func(new PackVmlinuzI386(f), user)))
return p;
D(PackBvmlinuzI386); if ((p = func(new PackBvmlinuzI386(f), user)))
return p;
D(PackVmlinuzARMEL); if ((p = func(new PackVmlinuzARMEL(f), user)))
return p;
// //
// linux // linux
@@ -212,80 +198,53 @@ Packer* PackMaster::visitAllPackers(visit_func_t func, InputFile *f, const optio
if (!o->o_unix.force_execve) if (!o->o_unix.force_execve)
{ {
if (o->o_unix.use_ptinterp) { if (o->o_unix.use_ptinterp) {
D(PackLinuxElf32x86interp); if ((p = func(new PackLinuxElf32x86interp(f), user))) D(PackLinuxElf32x86interp);
return p;
} }
D(PackFreeBSDElf32x86); if ((p = func(new PackFreeBSDElf32x86(f), user))) D(PackFreeBSDElf32x86);
return p; D(PackNetBSDElf32x86);
D(PackNetBSDElf32x86); if ((p = func(new PackNetBSDElf32x86(f), user))) D(PackOpenBSDElf32x86);
return p; D(PackLinuxElf32x86);
D(PackOpenBSDElf32x86); if ((p = func(new PackOpenBSDElf32x86(f), user))) D(PackLinuxElf64amd);
return p; D(PackLinuxElf32armLe);
D(PackLinuxElf32x86); if ((p = func(new PackLinuxElf32x86(f), user))) D(PackLinuxElf32armBe);
return p; D(PackLinuxElf64arm);
D(PackLinuxElf64amd); if ((p = func(new PackLinuxElf64amd(f), user))) D(PackLinuxElf32ppc);
return p; D(PackLinuxElf64ppcle);
D(PackLinuxElf32armLe); if ((p = func(new PackLinuxElf32armLe(f), user))) D(PackLinuxElf32mipsel);
return p; D(PackLinuxElf32mipseb);
D(PackLinuxElf32armBe); if ((p = func(new PackLinuxElf32armBe(f), user))) D(PackLinuxI386sh);
return p;
D(PackLinuxElf64arm); if ((p = func(new PackLinuxElf64arm(f), user)))
return p;
D(PackLinuxElf32ppc); if ((p = func(new PackLinuxElf32ppc(f), user)))
return p;
D(PackLinuxElf64ppcle); if ((p = func(new PackLinuxElf64ppcle(f), user)))
return p;
D(PackLinuxElf32mipsel); if ((p = func(new PackLinuxElf32mipsel(f), user)))
return p;
D(PackLinuxElf32mipseb); if ((p = func(new PackLinuxElf32mipseb(f), user)))
return p;
D(PackLinuxI386sh); if ((p = func(new PackLinuxI386sh(f), user)))
return p;
} }
D(PackBSDI386); if ((p = func(new PackBSDI386(f), user))) D(PackBSDI386);
return p; D(PackMachFat); // cafebabe conflict
D(PackMachFat); if ((p = func(new PackMachFat(f), user))) // cafebabe conflict D(PackLinuxI386); // cafebabe conflict
return p;
D(PackLinuxI386); if ((p = func(new PackLinuxI386(f), user))) // cafebabe conflict
return p;
// //
// psone // psone
// //
D(PackPs1); if ((p = func(new PackPs1(f), user))) D(PackPs1);
return p;
// //
// .sys and .com // .sys and .com
// //
D(PackSys); if ((p = func(new PackSys(f), user))) D(PackSys);
return p; D(PackCom);
D(PackCom); if ((p = func(new PackCom(f), user)))
return p;
// Mach (MacOS X PowerPC) // Mach (MacOS X PowerPC)
D(PackMachPPC32); if ((p = func(new PackMachPPC32(f), user))) D(PackMachPPC32);
return p; D(PackMachPPC64LE);
D(PackMachPPC64LE); if ((p = func(new PackMachPPC64LE(f), user))) D(PackMachI386);
return p; D(PackMachAMD64);
D(PackMachI386); if ((p = func(new PackMachI386(f), user))) D(PackMachARMEL);
return p;
D(PackMachAMD64); if ((p = func(new PackMachAMD64(f), user)))
return p;
D(PackMachARMEL); if ((p = func(new PackMachARMEL(f), user)))
return p;
// 2010-03-12 omit these because PackMachBase<T>::pack4dylib (p_mach.cpp) // 2010-03-12 omit these because PackMachBase<T>::pack4dylib (p_mach.cpp)
// does not understand what the Darwin (Apple Mac OS X) dynamic loader // does not understand what the Darwin (Apple Mac OS X) dynamic loader
// assumes about .dylib file structure. // assumes about .dylib file structure.
// D(PackDylibI386); if ((p = func(new PackDylibI386(f), user))) // D(PackDylibI386);
// return p; // D(PackDylibPPC32);
// D(PackDylibPPC32); if ((p = func(new PackDylibPPC32(f), user))) // D(PackDylibAMD64);
// return p;
// D(PackDylibAMD64); if ((p = func(new PackDylibAMD64(f), user)))
// return p;
return NULL; return NULL;
#undef D
} }