src: work on packed_struct cleanup
This commit is contained in:
+2
-5
@@ -356,11 +356,8 @@ inline void NO_fprintf(FILE *, const char *, ...) noexcept {}
|
|||||||
#define upx_return_address() nullptr
|
#define upx_return_address() nullptr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO cleanup: we now require C++17, so remove all __packed_struct usage
|
// TODO cleanup: we now require C++17, so remove all packed_struct usage
|
||||||
#define __packed_struct(s) struct alignas(1) s {
|
#define packed_struct(s) struct alignas(1) s
|
||||||
#define __packed_struct_end() \
|
|
||||||
} \
|
|
||||||
;
|
|
||||||
|
|
||||||
#define COMPILE_TIME_ASSERT_ALIGNOF_USING_SIZEOF__(a, b) \
|
#define COMPILE_TIME_ASSERT_ALIGNOF_USING_SIZEOF__(a, b) \
|
||||||
{ \
|
{ \
|
||||||
|
|||||||
+22
-22
@@ -49,7 +49,7 @@ struct ElfITypes
|
|||||||
|
|
||||||
// The ELF file header. This appears at the start of every ELF file.
|
// The ELF file header. This appears at the start of every ELF file.
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Ehdr)
|
packed_struct(Ehdr) {
|
||||||
typedef typename TElfITypes::Half Half;
|
typedef typename TElfITypes::Half Half;
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -72,11 +72,11 @@ __packed_struct(Ehdr)
|
|||||||
|
|
||||||
# define WANT_EHDR_ENUM 1
|
# define WANT_EHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Dyn)
|
packed_struct(Dyn) {
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
@@ -85,32 +85,32 @@ __packed_struct(Dyn)
|
|||||||
|
|
||||||
# define WANT_DYN_ENUM 1
|
# define WANT_DYN_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Rel)
|
packed_struct(Rel) {
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
Addr r_offset;
|
Addr r_offset;
|
||||||
Xword r_info;
|
Xword r_info;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Rela)
|
packed_struct(Rela) {
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
|
|
||||||
Addr r_offset;
|
Addr r_offset;
|
||||||
Xword r_info;
|
Xword r_info;
|
||||||
Xword r_addend;
|
Xword r_addend;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(External_Note)
|
packed_struct(External_Note) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
|
|
||||||
Word xn_namesz; // includes terminating '\0'
|
Word xn_namesz; // includes terminating '\0'
|
||||||
@@ -118,7 +118,7 @@ __packed_struct(External_Note)
|
|||||||
Word xn_type;
|
Word xn_type;
|
||||||
//char xn_name[N]; // terminate with '\0'
|
//char xn_name[N]; // terminate with '\0'
|
||||||
//char xn_data[M]; // aligned to 0 mod 4
|
//char xn_data[M]; // aligned to 0 mod 4
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf
|
} // namespace N_Elf
|
||||||
@@ -131,7 +131,7 @@ __packed_struct_end()
|
|||||||
namespace N_Elf32 {
|
namespace N_Elf32 {
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Phdr)
|
packed_struct(Phdr) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
typedef typename TElfITypes::Off Off;
|
typedef typename TElfITypes::Off Off;
|
||||||
@@ -147,11 +147,11 @@ __packed_struct(Phdr)
|
|||||||
|
|
||||||
# define WANT_PHDR_ENUM 1
|
# define WANT_PHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Shdr)
|
packed_struct(Shdr) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
typedef typename TElfITypes::Off Off;
|
typedef typename TElfITypes::Off Off;
|
||||||
@@ -169,11 +169,11 @@ __packed_struct(Shdr)
|
|||||||
|
|
||||||
# define WANT_SHDR_ENUM 1
|
# define WANT_SHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Sym)
|
packed_struct(Sym) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
typedef typename TElfITypes::Section Section;
|
typedef typename TElfITypes::Section Section;
|
||||||
@@ -192,7 +192,7 @@ __packed_struct(Sym)
|
|||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type)
|
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||||
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf32
|
} // namespace N_Elf32
|
||||||
@@ -205,7 +205,7 @@ __packed_struct_end()
|
|||||||
namespace N_Elf64 {
|
namespace N_Elf64 {
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Phdr)
|
packed_struct(Phdr) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -222,11 +222,11 @@ __packed_struct(Phdr)
|
|||||||
|
|
||||||
# define WANT_PHDR_ENUM 1
|
# define WANT_PHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Shdr)
|
packed_struct(Shdr) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -245,11 +245,11 @@ __packed_struct(Shdr)
|
|||||||
|
|
||||||
# define WANT_SHDR_ENUM 1
|
# define WANT_SHDR_ENUM 1
|
||||||
# include "p_elf_enum.h"
|
# include "p_elf_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class TElfITypes>
|
template <class TElfITypes>
|
||||||
__packed_struct(Sym)
|
packed_struct(Sym) {
|
||||||
typedef typename TElfITypes::Word Word;
|
typedef typename TElfITypes::Word Word;
|
||||||
typedef typename TElfITypes::Xword Xword;
|
typedef typename TElfITypes::Xword Xword;
|
||||||
typedef typename TElfITypes::Addr Addr;
|
typedef typename TElfITypes::Addr Addr;
|
||||||
@@ -269,7 +269,7 @@ __packed_struct(Sym)
|
|||||||
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
static unsigned int get_st_type(unsigned x) { return 0xf & x ; }
|
||||||
static unsigned char make_st_info(unsigned bind, unsigned type)
|
static unsigned char make_st_info(unsigned bind, unsigned type)
|
||||||
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
{ return (unsigned char) (((bind<<4) + (0xf & type)) & 0xff); }
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace N_Elf64
|
} // namespace N_Elf64
|
||||||
|
|||||||
+22
-22
@@ -242,41 +242,41 @@ protected:
|
|||||||
Elf32_Shdr const *sec_dynstr;
|
Elf32_Shdr const *sec_dynstr;
|
||||||
Elf32_Shdr *sec_arm_attr; // SHT_ARM_ATTRIBUTES;
|
Elf32_Shdr *sec_arm_attr; // SHT_ARM_ATTRIBUTES;
|
||||||
|
|
||||||
__packed_struct(cprElfHdr1)
|
packed_struct(cprElfHdr1) {
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[1];
|
Elf32_Phdr phdr[1];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr2)
|
packed_struct(cprElfHdr2) {
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[2];
|
Elf32_Phdr phdr[2];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr3)
|
packed_struct(cprElfHdr3) {
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[3];
|
Elf32_Phdr phdr[3];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr4)
|
packed_struct(cprElfHdr4) {
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[4];
|
Elf32_Phdr phdr[4];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdrNetBSD)
|
packed_struct(cprElfHdrNetBSD) {
|
||||||
Elf32_Ehdr ehdr;
|
Elf32_Ehdr ehdr;
|
||||||
Elf32_Phdr phdr[4];
|
Elf32_Phdr phdr[4];
|
||||||
unsigned char notes[512];
|
unsigned char notes[512];
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
cprElfHdrNetBSD elfout;
|
cprElfHdrNetBSD elfout;
|
||||||
|
|
||||||
__packed_struct(cprElfShdr3)
|
packed_struct(cprElfShdr3) {
|
||||||
Elf32_Shdr shdr[3];
|
Elf32_Shdr shdr[3];
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
cprElfShdr3 shdrout;
|
cprElfShdr3 shdrout;
|
||||||
|
|
||||||
@@ -402,35 +402,35 @@ protected:
|
|||||||
Elf64_Shdr const *sec_dynstr;
|
Elf64_Shdr const *sec_dynstr;
|
||||||
Elf64_Shdr *sec_arm_attr; // SHT_ARM_ATTRIBUTES;
|
Elf64_Shdr *sec_arm_attr; // SHT_ARM_ATTRIBUTES;
|
||||||
|
|
||||||
__packed_struct(cprElfHdr1)
|
packed_struct(cprElfHdr1) {
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[1];
|
Elf64_Phdr phdr[1];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr2)
|
packed_struct(cprElfHdr2) {
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[2];
|
Elf64_Phdr phdr[2];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr3)
|
packed_struct(cprElfHdr3) {
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[3];
|
Elf64_Phdr phdr[3];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr4)
|
packed_struct(cprElfHdr4) {
|
||||||
Elf64_Ehdr ehdr;
|
Elf64_Ehdr ehdr;
|
||||||
Elf64_Phdr phdr[4];
|
Elf64_Phdr phdr[4];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
cprElfHdr4 elfout;
|
cprElfHdr4 elfout;
|
||||||
|
|
||||||
__packed_struct(cprElfShdr3)
|
packed_struct(cprElfShdr3) {
|
||||||
Elf64_Shdr shdr[3];
|
Elf64_Shdr shdr[3];
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
cprElfShdr3 shdrout;
|
cprElfShdr3 shdrout;
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -88,23 +88,23 @@ protected:
|
|||||||
|
|
||||||
unsigned n_mru;
|
unsigned n_mru;
|
||||||
|
|
||||||
__packed_struct(cprElfHdr1)
|
packed_struct(cprElfHdr1) {
|
||||||
Elf_LE32_Ehdr ehdr;
|
Elf_LE32_Ehdr ehdr;
|
||||||
Elf_LE32_Phdr phdr[1];
|
Elf_LE32_Phdr phdr[1];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr2)
|
packed_struct(cprElfHdr2) {
|
||||||
Elf_LE32_Ehdr ehdr;
|
Elf_LE32_Ehdr ehdr;
|
||||||
Elf_LE32_Phdr phdr[2];
|
Elf_LE32_Phdr phdr[2];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(cprElfHdr3)
|
packed_struct(cprElfHdr3) {
|
||||||
Elf_LE32_Ehdr ehdr;
|
Elf_LE32_Ehdr ehdr;
|
||||||
Elf_LE32_Phdr phdr[3];
|
Elf_LE32_Phdr phdr[3];
|
||||||
l_info linfo;
|
l_info linfo;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
cprElfHdr3 elfout;
|
cprElfHdr3 elfout;
|
||||||
|
|
||||||
|
|||||||
+81
-80
@@ -32,22 +32,22 @@
|
|||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|
||||||
__packed_struct(Mach_fat_header)
|
packed_struct(Mach_fat_header) {
|
||||||
BE32 magic;
|
BE32 magic;
|
||||||
enum : unsigned { // note conflict with java bytecode PackLinuxI386
|
enum : unsigned { // note conflict with java bytecode PackLinuxI386
|
||||||
FAT_MAGIC = 0xcafebabe,
|
FAT_MAGIC = 0xcafebabe,
|
||||||
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.
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(Mach_fat_arch)
|
packed_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 */
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// Mach Mach Object executable; all structures are target-endian
|
// Mach Mach Object executable; all structures are target-endian
|
||||||
@@ -67,7 +67,7 @@ struct MachITypes
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_header)
|
packed_struct(Mach_header) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word magic;
|
Word magic;
|
||||||
@@ -79,10 +79,10 @@ __packed_struct(Mach_header)
|
|||||||
Word flags;
|
Word flags;
|
||||||
#define WANT_MACH_HEADER_ENUM 1
|
#define WANT_MACH_HEADER_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_header64)
|
packed_struct(Mach_header64) {
|
||||||
// only difference is padding to 0 mod 8
|
// only difference is padding to 0 mod 8
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
@@ -96,10 +96,10 @@ __packed_struct(Mach_header64)
|
|||||||
Word reserved; // pad to 0 mod 8
|
Word reserved; // pad to 0 mod 8
|
||||||
#define WANT_MACH_HEADER_ENUM 1
|
#define WANT_MACH_HEADER_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_command) // generic prefix
|
packed_struct(Mach_command) { // generic prefix
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd;
|
Word cmd;
|
||||||
@@ -107,10 +107,10 @@ __packed_struct(Mach_command) // generic prefix
|
|||||||
Word data[2]; // because cmdsize >= 16
|
Word data[2]; // because cmdsize >= 16
|
||||||
#define WANT_MACH_SEGMENT_ENUM 1
|
#define WANT_MACH_SEGMENT_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_segment_command)
|
packed_struct(Mach_segment_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
@@ -128,10 +128,10 @@ __packed_struct(Mach_segment_command)
|
|||||||
Word flags;
|
Word flags;
|
||||||
#define WANT_MACH_SEGMENT_ENUM 1
|
#define WANT_MACH_SEGMENT_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_section_command)
|
packed_struct(Mach_section_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
@@ -149,10 +149,10 @@ __packed_struct(Mach_section_command)
|
|||||||
Word reserved2; /* for count or sizeof */
|
Word reserved2; /* for count or sizeof */
|
||||||
#define WANT_MACH_SECTION_ENUM 1
|
#define WANT_MACH_SECTION_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_section_command_64)
|
packed_struct(Mach_section_command_64) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
@@ -173,10 +173,10 @@ __packed_struct(Mach_section_command_64)
|
|||||||
Word reserved3; /* NOT IN 32-bit VERSION!! */
|
Word reserved3; /* NOT IN 32-bit VERSION!! */
|
||||||
#define WANT_MACH_SECTION_ENUM 1
|
#define WANT_MACH_SECTION_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_symtab_command)
|
packed_struct(Mach_symtab_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
typedef typename TMachITypes::Word Off32;
|
typedef typename TMachITypes::Word Off32;
|
||||||
@@ -187,10 +187,10 @@ __packed_struct(Mach_symtab_command)
|
|||||||
Word nsyms; /* number of symbol table entries */
|
Word nsyms; /* number of symbol table entries */
|
||||||
Off32 stroff; /* string table offset */
|
Off32 stroff; /* string table offset */
|
||||||
Word strsize; /* string table size in bytes */
|
Word strsize; /* string table size in bytes */
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_dysymtab_command)
|
packed_struct(Mach_dysymtab_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
typedef typename TMachITypes::Word Off32;
|
typedef typename TMachITypes::Word Off32;
|
||||||
@@ -215,10 +215,10 @@ __packed_struct(Mach_dysymtab_command)
|
|||||||
Word nextrel; /* number of external relocation entries */
|
Word nextrel; /* number of external relocation entries */
|
||||||
Off32 locreloff; /* offset to local relocation entries */
|
Off32 locreloff; /* offset to local relocation entries */
|
||||||
Word nlocrel; /* number of local relocation entries */
|
Word nlocrel; /* number of local relocation entries */
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_segsplit_info_command)
|
packed_struct(Mach_segsplit_info_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
|
|
||||||
@@ -226,10 +226,10 @@ __packed_struct(Mach_segsplit_info_command)
|
|||||||
Word cmdsize; /* sizeof(struct Mach_segsplit_info_command) */
|
Word cmdsize; /* sizeof(struct Mach_segsplit_info_command) */
|
||||||
Off dataoff;
|
Off dataoff;
|
||||||
Word datasize;
|
Word datasize;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_routines_command)
|
packed_struct(Mach_routines_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
|
|
||||||
@@ -245,10 +245,10 @@ __packed_struct(Mach_routines_command)
|
|||||||
Word reserved6;
|
Word reserved6;
|
||||||
#define WANT_MACH_SEGMENT_ENUM 1
|
#define WANT_MACH_SEGMENT_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_routines_command_64)
|
packed_struct(Mach_routines_command_64) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
typedef typename TMachITypes::Xword Xword;
|
typedef typename TMachITypes::Xword Xword;
|
||||||
@@ -265,10 +265,10 @@ __packed_struct(Mach_routines_command_64)
|
|||||||
Xword reserved6;
|
Xword reserved6;
|
||||||
#define WANT_MACH_SEGMENT_ENUM 1
|
#define WANT_MACH_SEGMENT_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_twolevel_hints_command)
|
packed_struct(Mach_twolevel_hints_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Off Off;
|
typedef typename TMachITypes::Off Off;
|
||||||
|
|
||||||
@@ -278,10 +278,10 @@ __packed_struct(Mach_twolevel_hints_command)
|
|||||||
Word nhints; /* number of hints */
|
Word nhints; /* number of hints */
|
||||||
#define WANT_MACH_SEGMENT_ENUM 1
|
#define WANT_MACH_SEGMENT_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_linkedit_data_command)
|
packed_struct(Mach_linkedit_data_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd; // LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO,
|
Word cmd; // LC_CODE_SIGNATURE, LC_SEGMENT_SPLIT_INFO,
|
||||||
@@ -290,19 +290,19 @@ __packed_struct(Mach_linkedit_data_command)
|
|||||||
Word cmdsize;
|
Word cmdsize;
|
||||||
Word dataoff; // file offset of data in __LINKEDIT segment
|
Word dataoff; // file offset of data in __LINKEDIT segment
|
||||||
Word datasize; // file size of data in __LINKEDIT segment
|
Word datasize; // file size of data in __LINKEDIT segment
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_uuid_command)
|
packed_struct(Mach_uuid_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd; // LC_UUID
|
Word cmd; // LC_UUID
|
||||||
Word cmdsize; // 24
|
Word cmdsize; // 24
|
||||||
unsigned char uuid[16];
|
unsigned char uuid[16];
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes, class TMachThreadState>
|
template <class TMachITypes, class TMachThreadState>
|
||||||
__packed_struct(Mach_thread_command)
|
packed_struct(Mach_thread_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
Word cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
@@ -312,10 +312,10 @@ __packed_struct(Mach_thread_command)
|
|||||||
TMachThreadState state;
|
TMachThreadState state;
|
||||||
#define WANT_MACH_THREAD_ENUM 1
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_main_command)
|
packed_struct(Mach_main_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Xword Xword;
|
typedef typename TMachITypes::Xword Xword;
|
||||||
|
|
||||||
@@ -323,30 +323,30 @@ __packed_struct(Mach_main_command)
|
|||||||
Word cmdsize; // 24
|
Word cmdsize; // 24
|
||||||
Xword entryoff; // file offset of main() [expected in __TEXT]
|
Xword entryoff; // file offset of main() [expected in __TEXT]
|
||||||
Xword stacksize; // non-default initial stack size
|
Xword stacksize; // non-default initial stack size
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_source_version_command)
|
packed_struct(Mach_source_version_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd; // LC_SOURCE_VERSION
|
Word cmd; // LC_SOURCE_VERSION
|
||||||
Word cmdsize; // 16
|
Word cmdsize; // 16
|
||||||
Word version;
|
Word version;
|
||||||
Word __pad; // to 0 mod 8
|
Word __pad; // to 0 mod 8
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_version_min_command)
|
packed_struct(Mach_version_min_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd; // LC_VERSION_MIN_MACOSX
|
Word cmd; // LC_VERSION_MIN_MACOSX
|
||||||
Word cmdsize; // 16
|
Word cmdsize; // 16
|
||||||
Word version; // X.Y.Z ==> xxxx.yy.zz
|
Word version; // X.Y.Z ==> xxxx.yy.zz
|
||||||
Word sdk; // X.Y.Z ==> xxxx.yy.zz
|
Word sdk; // X.Y.Z ==> xxxx.yy.zz
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_dyld_info_only_command)
|
packed_struct(Mach_dyld_info_only_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd; // LC_DYLD_INFO_ONLY
|
Word cmd; // LC_DYLD_INFO_ONLY
|
||||||
@@ -361,42 +361,42 @@ __packed_struct(Mach_dyld_info_only_command)
|
|||||||
Word lazy_bind_size;
|
Word lazy_bind_size;
|
||||||
Word export_off;
|
Word export_off;
|
||||||
Word export_size;
|
Word export_size;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_load_dylinker_command)
|
packed_struct(Mach_load_dylinker_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd;
|
Word cmd;
|
||||||
Word cmdsize;
|
Word cmdsize;
|
||||||
Word name;
|
Word name;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_dylib)
|
packed_struct(Mach_dylib) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word name; /* library's path name */
|
Word name; /* library's path name */
|
||||||
Word timestamp; /* library's build time stamp */
|
Word timestamp; /* library's build time stamp */
|
||||||
Word current_version; /* library's current version number */
|
Word current_version; /* library's current version number */
|
||||||
Word compatibility_version; /* library's compatibility vers number*/
|
Word compatibility_version; /* library's compatibility vers number*/
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_load_dylib_command)
|
packed_struct(Mach_load_dylib_command) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word cmd;
|
Word cmd;
|
||||||
Word cmdsize;
|
Word cmdsize;
|
||||||
Mach_dylib<TMachITypes> dylib;
|
Mach_dylib<TMachITypes> dylib;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
} // namespace N_Mach
|
} // namespace N_Mach
|
||||||
|
|
||||||
namespace N_Mach32 {
|
namespace N_Mach32 {
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_ppc_thread_state)
|
packed_struct(Mach_ppc_thread_state) {
|
||||||
typedef typename TMachITypes::Addr Addr;
|
typedef typename TMachITypes::Addr Addr;
|
||||||
|
|
||||||
Addr srr0; /* Instruction address register (PC; entry addr) */
|
Addr srr0; /* Instruction address register (PC; entry addr) */
|
||||||
@@ -413,10 +413,10 @@ __packed_struct(Mach_ppc_thread_state)
|
|||||||
Addr mq; /* MQ register (601 only) */
|
Addr mq; /* MQ register (601 only) */
|
||||||
|
|
||||||
Addr vrsave; /* Vector Save Register */
|
Addr vrsave; /* Vector Save Register */
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_i386_thread_state)
|
packed_struct(Mach_i386_thread_state) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word eax, ebx, ecx, edx;
|
Word eax, ebx, ecx, edx;
|
||||||
@@ -425,10 +425,10 @@ __packed_struct(Mach_i386_thread_state)
|
|||||||
Word eflags;
|
Word eflags;
|
||||||
Word eip, cs;
|
Word eip, cs;
|
||||||
Word ds, es, fs, gs;
|
Word ds, es, fs, gs;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_ARM_thread_state)
|
packed_struct(Mach_ARM_thread_state) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
Word r[13]; // r0-r12
|
Word r[13]; // r0-r12
|
||||||
@@ -436,14 +436,14 @@ __packed_struct(Mach_ARM_thread_state)
|
|||||||
Word lr; // r14
|
Word lr; // r14
|
||||||
Word pc; // r15
|
Word pc; // r15
|
||||||
Word cpsr;
|
Word cpsr;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
} // namespace N_Mach32
|
} // namespace N_Mach32
|
||||||
|
|
||||||
namespace N_Mach64 {
|
namespace N_Mach64 {
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_AMD64_thread_state)
|
packed_struct(Mach_AMD64_thread_state) {
|
||||||
typedef typename TMachITypes::Xword Xword;
|
typedef typename TMachITypes::Xword Xword;
|
||||||
|
|
||||||
Xword rax, rbx, rcx, rdx;
|
Xword rax, rbx, rcx, rdx;
|
||||||
@@ -452,10 +452,10 @@ __packed_struct(Mach_AMD64_thread_state)
|
|||||||
Xword r12, r13, r14, r15;
|
Xword r12, r13, r14, r15;
|
||||||
Xword rip, rflags;
|
Xword rip, rflags;
|
||||||
Xword cs, fs, gs;
|
Xword cs, fs, gs;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes>
|
template <class TMachITypes>
|
||||||
__packed_struct(Mach_ppc_thread_state64)
|
packed_struct(Mach_ppc_thread_state64) {
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
typedef typename TMachITypes::Xword Xword;
|
typedef typename TMachITypes::Xword Xword;
|
||||||
|
|
||||||
@@ -472,9 +472,10 @@ __packed_struct(Mach_ppc_thread_state64)
|
|||||||
Xword ctr; /* Count register */
|
Xword ctr; /* Count register */
|
||||||
|
|
||||||
Word vrsave; /* Vector Save Register */
|
Word vrsave; /* Vector Save Register */
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
template <class TMachITypes> __packed_struct(Mach_ARM64_thread_state)
|
template <class TMachITypes>
|
||||||
|
packed_struct(Mach_ARM64_thread_state) {
|
||||||
typedef typename TMachITypes::Xword Xword;
|
typedef typename TMachITypes::Xword Xword;
|
||||||
typedef typename TMachITypes::Word Word;
|
typedef typename TMachITypes::Word Word;
|
||||||
|
|
||||||
@@ -489,7 +490,7 @@ template <class TMachITypes> __packed_struct(Mach_ARM64_thread_state)
|
|||||||
Xword pc;
|
Xword pc;
|
||||||
Word cpsr;
|
Word cpsr;
|
||||||
Word pad; // to (0 mod 8)
|
Word pad; // to (0 mod 8)
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
} // namespace N_Mach64
|
} // namespace N_Mach64
|
||||||
|
|
||||||
@@ -823,28 +824,28 @@ protected:
|
|||||||
Mach_source_version_command cmdSRCVER; // copied from input
|
Mach_source_version_command cmdSRCVER; // copied from input
|
||||||
Mach_version_min_command cmdVERMIN; // copied from input
|
Mach_version_min_command cmdVERMIN; // copied from input
|
||||||
|
|
||||||
__packed_struct(b_info) // 12-byte header before each compressed block
|
packed_struct(b_info) { // 12-byte header before each compressed block
|
||||||
TE32 sz_unc; // uncompressed_size
|
TE32 sz_unc; // uncompressed_size
|
||||||
TE32 sz_cpr; // compressed_size
|
TE32 sz_cpr; // compressed_size
|
||||||
unsigned char b_method; // compression algorithm
|
unsigned char b_method; // compression algorithm
|
||||||
unsigned char b_ftid; // filter id
|
unsigned char b_ftid; // filter id
|
||||||
unsigned char b_cto8; // filter parameter
|
unsigned char b_cto8; // filter parameter
|
||||||
unsigned char b_segseq; // LC_SEGMENT ordinal
|
unsigned char b_segseq; // LC_SEGMENT ordinal
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(l_info) // 12-byte trailer in header for loader
|
packed_struct(l_info) { // 12-byte trailer in header for loader
|
||||||
TE32 l_checksum;
|
TE32 l_checksum;
|
||||||
LE32 l_magic;
|
LE32 l_magic;
|
||||||
TE16 l_lsize;
|
TE16 l_lsize;
|
||||||
unsigned char l_version;
|
unsigned char l_version;
|
||||||
unsigned char l_format;
|
unsigned char l_format;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(p_info) // 12-byte packed program header
|
packed_struct(p_info) { // 12-byte packed program header
|
||||||
TE32 p_progid;
|
TE32 p_progid;
|
||||||
TE32 p_filesize;
|
TE32 p_filesize;
|
||||||
TE32 p_blocksize;
|
TE32 p_blocksize;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
struct l_info linfo;
|
struct l_info linfo;
|
||||||
|
|
||||||
@@ -878,7 +879,7 @@ protected:
|
|||||||
virtual Linker* newLinker() const override;
|
virtual Linker* newLinker() const override;
|
||||||
virtual void addStubEntrySections(Filter const *) override;
|
virtual void addStubEntrySections(Filter const *) override;
|
||||||
|
|
||||||
__packed_struct(Mach_thread_command)
|
packed_struct(Mach_thread_command) {
|
||||||
TE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
TE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
TE32 cmdsize; /* total size of this command */
|
TE32 cmdsize; /* total size of this command */
|
||||||
TE32 flavor;
|
TE32 flavor;
|
||||||
@@ -886,7 +887,7 @@ protected:
|
|||||||
Mach_ppc_thread_state state;
|
Mach_ppc_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM 1
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
int threado_size() const override { return sizeof(threado); }
|
int threado_size() const override { return sizeof(threado); }
|
||||||
@@ -930,7 +931,7 @@ protected:
|
|||||||
virtual void pack1_setup_threado(OutputFile *const fo) override;
|
virtual void pack1_setup_threado(OutputFile *const fo) override;
|
||||||
virtual Linker* newLinker() const override;
|
virtual Linker* newLinker() const override;
|
||||||
|
|
||||||
__packed_struct(Mach_thread_command)
|
packed_struct(Mach_thread_command) {
|
||||||
BE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
BE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
BE32 cmdsize; /* total size of this command */
|
BE32 cmdsize; /* total size of this command */
|
||||||
BE32 flavor;
|
BE32 flavor;
|
||||||
@@ -938,7 +939,7 @@ protected:
|
|||||||
Mach_ppc_thread_state64 state64;
|
Mach_ppc_thread_state64 state64;
|
||||||
#define WANT_MACH_THREAD_ENUM 1
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
int threado_size() const override { return sizeof(threado); }
|
int threado_size() const override { return sizeof(threado); }
|
||||||
@@ -1012,7 +1013,7 @@ protected:
|
|||||||
virtual Linker* newLinker() const override;
|
virtual Linker* newLinker() const override;
|
||||||
virtual void addStubEntrySections(Filter const *) override;
|
virtual void addStubEntrySections(Filter const *) override;
|
||||||
|
|
||||||
__packed_struct(Mach_thread_command)
|
packed_struct(Mach_thread_command) {
|
||||||
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
LE32 cmdsize; /* total size of this command */
|
LE32 cmdsize; /* total size of this command */
|
||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
@@ -1020,7 +1021,7 @@ protected:
|
|||||||
Mach_i386_thread_state state;
|
Mach_i386_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM 1
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
int threado_size() const override { return sizeof(threado); }
|
int threado_size() const override { return sizeof(threado); }
|
||||||
@@ -1079,7 +1080,7 @@ protected:
|
|||||||
virtual Linker* newLinker() const override;
|
virtual Linker* newLinker() const override;
|
||||||
virtual void addStubEntrySections(Filter const *) override;
|
virtual void addStubEntrySections(Filter const *) override;
|
||||||
|
|
||||||
__packed_struct(Mach_thread_command)
|
packed_struct(Mach_thread_command) {
|
||||||
typedef MachITypes::Word Word;
|
typedef MachITypes::Word Word;
|
||||||
Word cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
Word cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
Word cmdsize; /* total size of this command */
|
Word cmdsize; /* total size of this command */
|
||||||
@@ -1088,7 +1089,7 @@ protected:
|
|||||||
Mach_AMD64_thread_state state;
|
Mach_AMD64_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM 1
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
int threado_size() const override { return sizeof(threado); }
|
int threado_size() const override { return sizeof(threado); }
|
||||||
@@ -1148,7 +1149,7 @@ protected:
|
|||||||
virtual Linker* newLinker() const override;
|
virtual Linker* newLinker() const override;
|
||||||
virtual void addStubEntrySections(Filter const *) override;
|
virtual void addStubEntrySections(Filter const *) override;
|
||||||
|
|
||||||
__packed_struct(Mach_thread_command)
|
packed_struct(Mach_thread_command) {
|
||||||
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
LE32 cmdsize; /* total size of this command */
|
LE32 cmdsize; /* total size of this command */
|
||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
@@ -1156,7 +1157,7 @@ protected:
|
|||||||
Mach_ARM_thread_state state;
|
Mach_ARM_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM 1
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
int threado_size() const override { return sizeof(threado); }
|
int threado_size() const override { return sizeof(threado); }
|
||||||
@@ -1200,7 +1201,7 @@ protected:
|
|||||||
virtual Linker* newLinker() const override;
|
virtual Linker* newLinker() const override;
|
||||||
virtual void addStubEntrySections(Filter const *) override;
|
virtual void addStubEntrySections(Filter const *) override;
|
||||||
|
|
||||||
__packed_struct(Mach_thread_command)
|
packed_struct(Mach_thread_command) {
|
||||||
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
LE32 cmd; /* LC_THREAD or LC_UNIXTHREAD */
|
||||||
LE32 cmdsize; /* total size of this command */
|
LE32 cmdsize; /* total size of this command */
|
||||||
LE32 flavor;
|
LE32 flavor;
|
||||||
@@ -1208,7 +1209,7 @@ protected:
|
|||||||
Mach_ARM64_thread_state state;
|
Mach_ARM64_thread_state state;
|
||||||
#define WANT_MACH_THREAD_ENUM 1
|
#define WANT_MACH_THREAD_ENUM 1
|
||||||
#include "p_mach_enum.h"
|
#include "p_mach_enum.h"
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
Mach_thread_command threado;
|
Mach_thread_command threado;
|
||||||
int threado_size() const override { return sizeof(threado); }
|
int threado_size() const override { return sizeof(threado); }
|
||||||
@@ -1267,10 +1268,10 @@ protected:
|
|||||||
|
|
||||||
enum { N_FAT_ARCH = 5 };
|
enum { N_FAT_ARCH = 5 };
|
||||||
protected:
|
protected:
|
||||||
__packed_struct(Fat_head)
|
packed_struct(Fat_head) {
|
||||||
struct Mach_fat_header fat;
|
struct Mach_fat_header fat;
|
||||||
struct Mach_fat_arch arch[N_FAT_ARCH];
|
struct Mach_fat_arch arch[N_FAT_ARCH];
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
Fat_head fat_head;
|
Fat_head fat_head;
|
||||||
|
|
||||||
|
|||||||
+19
-18
@@ -106,28 +106,28 @@ protected:
|
|||||||
unsigned saved_opt_android_shlib;
|
unsigned saved_opt_android_shlib;
|
||||||
|
|
||||||
// must agree with stub/linux.hh
|
// must agree with stub/linux.hh
|
||||||
__packed_struct(b_info) // 12-byte header before each compressed block
|
packed_struct(b_info) { // 12-byte header before each compressed block
|
||||||
NE32 sz_unc; // uncompressed_size
|
NE32 sz_unc; // uncompressed_size
|
||||||
NE32 sz_cpr; // compressed_size
|
NE32 sz_cpr; // compressed_size
|
||||||
unsigned char b_method; // compression algorithm
|
unsigned char b_method; // compression algorithm
|
||||||
unsigned char b_ftid; // filter id
|
unsigned char b_ftid; // filter id
|
||||||
unsigned char b_cto8; // filter parameter
|
unsigned char b_cto8; // filter parameter
|
||||||
unsigned char b_extra;
|
unsigned char b_extra;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(l_info) // 12-byte trailer in header for loader
|
packed_struct(l_info) { // 12-byte trailer in header for loader
|
||||||
LE32 l_checksum;
|
LE32 l_checksum;
|
||||||
LE32 l_magic;
|
LE32 l_magic;
|
||||||
LE16 l_lsize;
|
LE16 l_lsize;
|
||||||
unsigned char l_version;
|
unsigned char l_version;
|
||||||
unsigned char l_format;
|
unsigned char l_format;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(p_info) // 12-byte packed program header
|
packed_struct(p_info) { // 12-byte packed program header
|
||||||
NE32 p_progid;
|
NE32 p_progid;
|
||||||
NE32 p_filesize;
|
NE32 p_filesize;
|
||||||
NE32 p_blocksize;
|
NE32 p_blocksize;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
struct l_info linfo;
|
struct l_info linfo;
|
||||||
|
|
||||||
@@ -140,6 +140,7 @@ protected:
|
|||||||
// abstract classes encapsulating endian issues
|
// abstract classes encapsulating endian issues
|
||||||
// note: UPX_MAGIC is always stored in le32 format
|
// note: UPX_MAGIC is always stored in le32 format
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
class PackUnixBe32 : public PackUnix
|
class PackUnixBe32 : public PackUnix
|
||||||
{
|
{
|
||||||
typedef PackUnix super;
|
typedef PackUnix super;
|
||||||
@@ -147,28 +148,28 @@ protected:
|
|||||||
PackUnixBe32(InputFile *f) : super(f) { bele = &N_BELE_RTP::be_policy; }
|
PackUnixBe32(InputFile *f) : super(f) { bele = &N_BELE_RTP::be_policy; }
|
||||||
|
|
||||||
// must agree with stub/linux.hh
|
// must agree with stub/linux.hh
|
||||||
__packed_struct(b_info) // 12-byte header before each compressed block
|
packed_struct(b_info) { // 12-byte header before each compressed block
|
||||||
BE32 sz_unc; // uncompressed_size
|
BE32 sz_unc; // uncompressed_size
|
||||||
BE32 sz_cpr; // compressed_size
|
BE32 sz_cpr; // compressed_size
|
||||||
unsigned char b_method; // compression algorithm
|
unsigned char b_method; // compression algorithm
|
||||||
unsigned char b_ftid; // filter id
|
unsigned char b_ftid; // filter id
|
||||||
unsigned char b_cto8; // filter parameter
|
unsigned char b_cto8; // filter parameter
|
||||||
unsigned char b_extra;
|
unsigned char b_extra;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(l_info) // 12-byte trailer in header for loader
|
packed_struct(l_info) { // 12-byte trailer in header for loader
|
||||||
BE32 l_checksum;
|
BE32 l_checksum;
|
||||||
BE32 l_magic;
|
BE32 l_magic;
|
||||||
BE16 l_lsize;
|
BE16 l_lsize;
|
||||||
unsigned char l_version;
|
unsigned char l_version;
|
||||||
unsigned char l_format;
|
unsigned char l_format;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(p_info) // 12-byte packed program header
|
packed_struct(p_info) {// 12-byte packed program header
|
||||||
BE32 p_progid;
|
BE32 p_progid;
|
||||||
BE32 p_filesize;
|
BE32 p_filesize;
|
||||||
BE32 p_blocksize;
|
BE32 p_blocksize;
|
||||||
__packed_struct_end()
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -179,28 +180,28 @@ protected:
|
|||||||
PackUnixLe32(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
PackUnixLe32(InputFile *f) : super(f) { bele = &N_BELE_RTP::le_policy; }
|
||||||
|
|
||||||
// must agree with stub/linux.hh
|
// must agree with stub/linux.hh
|
||||||
__packed_struct(b_info) // 12-byte header before each compressed block
|
packed_struct(b_info) { // 12-byte header before each compressed block
|
||||||
LE32 sz_unc; // uncompressed_size
|
LE32 sz_unc; // uncompressed_size
|
||||||
LE32 sz_cpr; // compressed_size
|
LE32 sz_cpr; // compressed_size
|
||||||
unsigned char b_method; // compression algorithm
|
unsigned char b_method; // compression algorithm
|
||||||
unsigned char b_ftid; // filter id
|
unsigned char b_ftid; // filter id
|
||||||
unsigned char b_cto8; // filter parameter
|
unsigned char b_cto8; // filter parameter
|
||||||
unsigned char b_extra;
|
unsigned char b_extra;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(l_info) // 12-byte trailer in header for loader
|
packed_struct(l_info) { // 12-byte trailer in header for loader
|
||||||
LE32 l_checksum;
|
LE32 l_checksum;
|
||||||
LE32 l_magic;
|
LE32 l_magic;
|
||||||
LE16 l_lsize;
|
LE16 l_lsize;
|
||||||
unsigned char l_version;
|
unsigned char l_version;
|
||||||
unsigned char l_format;
|
unsigned char l_format;
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
__packed_struct(p_info) // 12-byte packed program header
|
packed_struct(p_info) { // 12-byte packed program header
|
||||||
LE32 p_progid;
|
LE32 p_progid;
|
||||||
LE32 p_filesize;
|
LE32 p_filesize;
|
||||||
LE32 p_blocksize;
|
LE32 p_blocksize;
|
||||||
__packed_struct_end()
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -327,7 +327,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
|
|||||||
if (UPX_E_OK!=r || len_unc<=len_cpr) // FIXME: allow no compression
|
if (UPX_E_OK!=r || len_unc<=len_cpr) // FIXME: allow no compression
|
||||||
throwInternalError("Ehdr compression failed");
|
throwInternalError("Ehdr compression failed");
|
||||||
|
|
||||||
__packed_struct(b_info) // 12-byte header before each compressed block
|
packed_struct(b_info) { // 12-byte header before each compressed block
|
||||||
NE32 sz_unc; // uncompressed_size
|
NE32 sz_unc; // uncompressed_size
|
||||||
NE32 sz_cpr; // compressed_size
|
NE32 sz_cpr; // compressed_size
|
||||||
unsigned char b_method; // compression algorithm
|
unsigned char b_method; // compression algorithm
|
||||||
@@ -335,7 +335,7 @@ void PackVmlinuxBase<T>::pack(OutputFile *fo)
|
|||||||
unsigned char b_cto8; // filter parameter
|
unsigned char b_cto8; // filter parameter
|
||||||
unsigned char b_unused; // FIXME: !=0 for partial-block unfilter
|
unsigned char b_unused; // FIXME: !=0 for partial-block unfilter
|
||||||
// NE32 f_offset, f_len; // only if partial-block unfilter
|
// NE32 f_offset, f_len; // only if partial-block unfilter
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
struct b_info hdr_info;
|
struct b_info hdr_info;
|
||||||
set_be32(&hdr_info.sz_unc, len_unc);
|
set_be32(&hdr_info.sz_unc, len_unc);
|
||||||
|
|||||||
+2
-2
@@ -65,7 +65,7 @@ protected:
|
|||||||
// virtual upx_byte *getLoader() const;
|
// virtual upx_byte *getLoader() const;
|
||||||
// virtual int getLoaderSize() const;
|
// virtual int getLoaderSize() const;
|
||||||
|
|
||||||
__packed_struct(boot_sect_t)
|
packed_struct(boot_sect_t) {
|
||||||
char _[0x1f1];
|
char _[0x1f1];
|
||||||
unsigned char setup_sects;
|
unsigned char setup_sects;
|
||||||
char __[2];
|
char __[2];
|
||||||
@@ -88,7 +88,7 @@ protected:
|
|||||||
LE32 payload_length;
|
LE32 payload_length;
|
||||||
// some more uninteresting fields here ...
|
// some more uninteresting fields here ...
|
||||||
// see /usr/src/linux/Documentation/i386/boot.txt
|
// see /usr/src/linux/Documentation/i386/boot.txt
|
||||||
__packed_struct_end()
|
};
|
||||||
|
|
||||||
boot_sect_t h;
|
boot_sect_t h;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user