aboutsummaryrefslogtreecommitdiffstats
path: root/machoparse/macho.h
blob: 858fdedcf52d131cf20703f9c5952e9da8523535 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <sys/types.h>

typedef int cpu_type_t;
typedef int cpu_subtype_t;

struct mach_header {
	uint32_t	magic;
	cpu_type_t	cputype;
	cpu_subtype_t	cpusubtype;
	uint32_t	filetype;
	uint32_t	ncmds;
	uint32_t	sizeofcmds;
	uint32_t	flags;
};


#define	MH_MAGIC	0xfeedface
#define MH_CIGAM	0xcefaedfe

struct mach_header_64 {
	uint32_t	magic;
	cpu_type_t	cputype;
	cpu_subtype_t	cpusubtype;
	uint32_t	filetype;
	uint32_t	ncmds;
	uint32_t	sizeofcmds;
	uint32_t	flags;
	uint32_t	reserved;
};

#define MH_MAGIC_64 0xfeedfacf
#define MH_CIGAM_64 0xcffaedfe

struct load_command {
	uint32_t cmd;
	uint32_t cmdsize;
};

#define LC_CODE_SIGNATURE 0x1d

struct linkedit_data_command {
	uint32_t	cmd;
	uint32_t	cmdsize;
	uint32_t	dataoff;
	uint32_t	datasize;
};

struct fat_header {
	uint32_t	magic;
	uint32_t	nfat_arch;
};

#define FAT_MAGIC	0xcafebabe
#define FAT_CIGAM	0xbebafeca

struct fat_arch {
	cpu_type_t	cputype;
	cpu_subtype_t	cpusubtype;
	uint32_t	offset;
	uint32_t	size;
	uint32_t	align;
};

#define FAT_MAGIC_64	0xcafebabf
#define FAT_CIGAM_64	0xbfbafeca

struct fat_arch_64 {
	cpu_type_t	cputype;
	cpu_subtype_t	cpusubtype;
	uint32_t	offset;
	uint32_t	size;
	uint32_t	align;
};