1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

Avoid compiler warnings.

This commit is contained in:
Markus F.X.J. Oberhumer 2007-02-08 15:00:42 +01:00
parent 52d89bd66b
commit 750c1a0f27
2 changed files with 13 additions and 6 deletions

View File

@ -649,7 +649,7 @@ void PackMachFat::pack(OutputFile *fo)
unsigned const in_size = this->file_size; unsigned const in_size = this->file_size;
fo->write(&fat_head, sizeof(fat_head.fat) + fo->write(&fat_head, sizeof(fat_head.fat) +
fat_head.fat.nfat_arch * sizeof(fat_head.arch[0])); fat_head.fat.nfat_arch * sizeof(fat_head.arch[0]));
unsigned length; unsigned length = 0;
for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) { for (unsigned j=0; j < fat_head.fat.nfat_arch; ++j) {
unsigned base = fo->unset_extent(); // actual length unsigned base = fo->unset_extent(); // actual length
base += ~(~0u<<fat_head.arch[j].align) & -base; // align up base += ~(~0u<<fat_head.arch[j].align) & -base; // align up

View File

@ -29,6 +29,7 @@
#ifndef __UPX_P_MACHO_H #ifndef __UPX_P_MACHO_H
#define __UPX_P_MACHO_H #define __UPX_P_MACHO_H
struct Mach_fat_header { struct Mach_fat_header {
BE32 magic; BE32 magic;
enum e8 { // note conflict with java bytecode PackLinuxI386 enum e8 { // note conflict with java bytecode PackLinuxI386
@ -36,14 +37,18 @@ struct Mach_fat_header {
FAT_MAGIC_SWAB = 0xbebafeca, FAT_MAGIC_SWAB = 0xbebafeca,
}; };
BE32 nfat_arch; // Number of Mach_fat_arch which follow. BE32 nfat_arch; // Number of Mach_fat_arch which follow.
}; }
__attribute_packed;
struct Mach_fat_arch { struct Mach_fat_arch {
BE32 cputype; BE32 cputype;
BE32 cpusubtype; BE32 cpusubtype;
BE32 offset; BE32 offset;
BE32 size; BE32 size;
BE32 align; /* shift count; log base 2 */ BE32 align; /* shift count; log base 2 */
}; }
__attribute_packed;
/************************************************************************* /*************************************************************************
// Mach Mach Object executable; all structures are target-endian // Mach Mach Object executable; all structures are target-endian
@ -400,7 +405,7 @@ class PackMachPPC32 : public PackMachBase<MachClass_BE32>
typedef PackMachBase<MachClass_BE32> super; typedef PackMachBase<MachClass_BE32> super;
public: public:
PackMachPPC32::PackMachPPC32(InputFile *f) : super(f, Mach_header::CPU_TYPE_POWERPC, PackMachPPC32(InputFile *f) : super(f, Mach_header::CPU_TYPE_POWERPC,
Mach_thread_command::PPC_THREAD_STATE, Mach_thread_command::PPC_THREAD_STATE,
sizeof(Mach_ppc_thread_state)>>2, sizeof(threado)) { } sizeof(Mach_ppc_thread_state)>>2, sizeof(threado)) { }
@ -433,8 +438,9 @@ protected:
Mach_ppc_thread_state state; Mach_ppc_thread_state state;
#define WANT_MACH_THREAD_ENUM #define WANT_MACH_THREAD_ENUM
#include "p_mach_enum.h" #include "p_mach_enum.h"
} threado }
__attribute_packed; __attribute_packed;
Mach_thread_command threado;
}; };
class PackMachI386 : public PackMachBase<MachClass_LE32> class PackMachI386 : public PackMachBase<MachClass_LE32>
@ -475,8 +481,9 @@ protected:
Mach_i386_thread_state state; Mach_i386_thread_state state;
#define WANT_MACH_THREAD_ENUM #define WANT_MACH_THREAD_ENUM
#include "p_mach_enum.h" #include "p_mach_enum.h"
} threado }
__attribute_packed; __attribute_packed;
Mach_thread_command threado;
}; };
class PackMachFat : public Packer class PackMachFat : public Packer