@@ -79,14 +79,14 @@ func (i Cpu) GoString() string { return stringName(uint32(i), cpuStrings, true)
79
79
type LoadCmd uint32
80
80
81
81
const (
82
- LoadCmdSegment LoadCmd = 1
83
- LoadCmdSymtab LoadCmd = 2
84
- LoadCmdThread LoadCmd = 4
85
- LoadCmdUnixThread LoadCmd = 5 // thread+stack
86
- LoadCmdDysymtab LoadCmd = 11
87
- LoadCmdDylib LoadCmd = 12
88
- LoadCmdDylinker LoadCmd = 15
89
- LoadCmdSegment64 LoadCmd = 25
82
+ LoadCmdSegment LoadCmd = 0x1
83
+ LoadCmdSymtab LoadCmd = 0x2
84
+ LoadCmdThread LoadCmd = 0x4
85
+ LoadCmdUnixThread LoadCmd = 0x5 // thread+stack
86
+ LoadCmdDysymtab LoadCmd = 0xb
87
+ LoadCmdDylib LoadCmd = 0xc
88
+ LoadCmdDylinker LoadCmd = 0xf
89
+ LoadCmdSegment64 LoadCmd = 0x19
90
90
)
91
91
92
92
var cmdStrings = []intName {
@@ -100,53 +100,97 @@ var cmdStrings = []intName{
100
100
func (i LoadCmd ) String () string { return stringName (uint32 (i ), cmdStrings , false ) }
101
101
func (i LoadCmd ) GoString () string { return stringName (uint32 (i ), cmdStrings , true ) }
102
102
103
+ type (
104
+ // A Segment32 is a 32-bit Mach-O segment load command.
105
+ Segment32 struct {
106
+ Cmd LoadCmd
107
+ Len uint32
108
+ Name [16 ]byte
109
+ Addr uint32
110
+ Memsz uint32
111
+ Offset uint32
112
+ Filesz uint32
113
+ Maxprot uint32
114
+ Prot uint32
115
+ Nsect uint32
116
+ Flag uint32
117
+ }
118
+
119
+ // A Segment64 is a 64-bit Mach-O segment load command.
120
+ Segment64 struct {
121
+ Cmd LoadCmd
122
+ Len uint32
123
+ Name [16 ]byte
124
+ Addr uint64
125
+ Memsz uint64
126
+ Offset uint64
127
+ Filesz uint64
128
+ Maxprot uint32
129
+ Prot uint32
130
+ Nsect uint32
131
+ Flag uint32
132
+ }
133
+
134
+ // A SymtabCmd is a Mach-O symbol table command.
135
+ SymtabCmd struct {
136
+ Cmd LoadCmd
137
+ Len uint32
138
+ Symoff uint32
139
+ Nsyms uint32
140
+ Stroff uint32
141
+ Strsize uint32
142
+ }
143
+
144
+ // A DysymtabCmd is a Mach-O dynamic symbol table command.
145
+ DysymtabCmd struct {
146
+ Cmd LoadCmd
147
+ Len uint32
148
+ Ilocalsym uint32
149
+ Nlocalsym uint32
150
+ Iextdefsym uint32
151
+ Nextdefsym uint32
152
+ Iundefsym uint32
153
+ Nundefsym uint32
154
+ Tocoffset uint32
155
+ Ntoc uint32
156
+ Modtaboff uint32
157
+ Nmodtab uint32
158
+ Extrefsymoff uint32
159
+ Nextrefsyms uint32
160
+ Indirectsymoff uint32
161
+ Nindirectsyms uint32
162
+ Extreloff uint32
163
+ Nextrel uint32
164
+ Locreloff uint32
165
+ Nlocrel uint32
166
+ }
167
+
168
+ // A DylibCmd is a Mach-O load dynamic library command.
169
+ DylibCmd struct {
170
+ Cmd LoadCmd
171
+ Len uint32
172
+ Name uint32
173
+ Time uint32
174
+ CurrentVersion uint32
175
+ CompatVersion uint32
176
+ }
177
+
178
+ // A Thread is a Mach-O thread state command.
179
+ Thread struct {
180
+ Cmd LoadCmd
181
+ Len uint32
182
+ Type uint32
183
+ Data []uint32
184
+ }
185
+ )
186
+
103
187
const (
104
188
FlagNoUndefs uint32 = 0x1
105
189
FlagDyldLink uint32 = 0x4
106
190
FlagTwoLevel uint32 = 0x80
107
191
FlagPIE uint32 = 0x200000
108
192
)
109
193
110
- // A Segment64 is a 64-bit Mach-O segment load command.
111
- type Segment64 struct {
112
- Cmd LoadCmd
113
- Len uint32
114
- Name [16 ]byte
115
- Addr uint64
116
- Memsz uint64
117
- Offset uint64
118
- Filesz uint64
119
- Maxprot uint32
120
- Prot uint32
121
- Nsect uint32
122
- Flag uint32
123
- }
124
-
125
- // A Segment32 is a 32-bit Mach-O segment load command.
126
- type Segment32 struct {
127
- Cmd LoadCmd
128
- Len uint32
129
- Name [16 ]byte
130
- Addr uint32
131
- Memsz uint32
132
- Offset uint32
133
- Filesz uint32
134
- Maxprot uint32
135
- Prot uint32
136
- Nsect uint32
137
- Flag uint32
138
- }
139
-
140
- // A DylibCmd is a Mach-O load dynamic library command.
141
- type DylibCmd struct {
142
- Cmd LoadCmd
143
- Len uint32
144
- Name uint32
145
- Time uint32
146
- CurrentVersion uint32
147
- CompatVersion uint32
148
- }
149
-
150
194
// A Section32 is a 32-bit Mach-O section header.
151
195
type Section32 struct {
152
196
Name [16 ]byte
@@ -178,40 +222,6 @@ type Section64 struct {
178
222
Reserve3 uint32
179
223
}
180
224
181
- // A SymtabCmd is a Mach-O symbol table command.
182
- type SymtabCmd struct {
183
- Cmd LoadCmd
184
- Len uint32
185
- Symoff uint32
186
- Nsyms uint32
187
- Stroff uint32
188
- Strsize uint32
189
- }
190
-
191
- // A DysymtabCmd is a Mach-O dynamic symbol table command.
192
- type DysymtabCmd struct {
193
- Cmd LoadCmd
194
- Len uint32
195
- Ilocalsym uint32
196
- Nlocalsym uint32
197
- Iextdefsym uint32
198
- Nextdefsym uint32
199
- Iundefsym uint32
200
- Nundefsym uint32
201
- Tocoffset uint32
202
- Ntoc uint32
203
- Modtaboff uint32
204
- Nmodtab uint32
205
- Extrefsymoff uint32
206
- Nextrefsyms uint32
207
- Indirectsymoff uint32
208
- Nindirectsyms uint32
209
- Extreloff uint32
210
- Nextrel uint32
211
- Locreloff uint32
212
- Nlocrel uint32
213
- }
214
-
215
225
// An Nlist32 is a Mach-O 32-bit symbol table entry.
216
226
type Nlist32 struct {
217
227
Name uint32
@@ -230,23 +240,6 @@ type Nlist64 struct {
230
240
Value uint64
231
241
}
232
242
233
- // A Symbol is a Mach-O 32-bit or 64-bit symbol table entry.
234
- type Symbol struct {
235
- Name string
236
- Type uint8
237
- Sect uint8
238
- Desc uint16
239
- Value uint64
240
- }
241
-
242
- // A Thread is a Mach-O thread state command.
243
- type Thread struct {
244
- Cmd LoadCmd
245
- Len uint32
246
- Type uint32
247
- Data []uint32
248
- }
249
-
250
243
// Regs386 is the Mach-O 386 register structure.
251
244
type Regs386 struct {
252
245
AX uint32
0 commit comments