comparison dstep/coreservices/carboncore/PEFBinaryFormat.d @ 11:07194b026fa4

Added bindings to a couple of frameworks, new license + some other things
author Jacob Carlborg <doob@me.com>
date Sat, 01 Aug 2009 15:03:28 +0200
parents
children 19885b43130e
comparison
equal deleted inserted replaced
10:27e00625790b 11:07194b026fa4
1 /**
2 * Copyright: Copyright (c) 2009 Jacob Carlborg.
3 * Authors: Jacob Carlborg
4 * Version: Initial created: Jul 21, 2009
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
6 */
7 module dstep.coreservices.carboncore.PEFBinaryFormat;
8
9 //import dstep.AvailabilityMacros;
10 import dstep.coreservices.carboncore.MacTypes;
11 import dstep.internal.Types;
12 import dstep.objc.bridge.TypeEncoding;
13
14 alias ushort PEFRelocChunk;
15 alias PEFExportedSymbolHashSlot XLibExportedSymbolHashSlot;
16 alias PEFExportedSymbolKey XLibExportedSymbolKey;
17
18 struct PEFContainerHeader
19 {
20 uint tag1;
21 uint tag2;
22 uint architecture;
23 uint formatVersion;
24 uint dateTimeStamp;
25 uint oldDefVersion;
26 uint oldImpVersion;
27 uint currentVersion;
28 ushort sectionCount;
29 ushort instSectionCount;
30 uint reservedA;
31 }
32
33 // This is needed otherwise the enums will fail compiling with gdc
34 version (GNU)
35 {
36 private
37 {
38 const __kPEFTag1 = getOSType!("Joy!");
39 const __kPEFTag2 = getOSType!("peff");
40 const __kPEFVersion = getOSType!("x0000000");
41
42 }
43 }
44
45 // This is needed otherwise the enums will fail compiling with gdc
46 version (GNU)
47 {
48 private
49 {
50 const __kVLibTag2 = getOSType!("VLib");
51 const __kBLibTag2 = getOSType!("BLib");
52 const __kXLibVersion = getOSType!("x0000000");
53
54 }
55 }
56
57 enum
58 {
59 kPEFTag1 = getOSType!("Joy!"),
60 kPEFTag2 = getOSType!("peff"),
61 kPEFVersion = 0x00000001
62 }
63
64 enum
65 {
66 kPEFFirstSectionHeaderOffset = PEFContainerHeader.sizeof
67 }
68
69 enum
70 {
71 kPEFCodeSection = 0,
72 kPEFUnpackedDataSection = 1,
73 kPEFPackedDataSection = 2,
74 kPEFConstantSection = 3,
75 kPEFExecDataSection = 6,
76 kPEFLoaderSection = 4,
77 kPEFDebugSection = 5,
78 kPEFExceptionSection = 7,
79 kPEFTracebackSection = 8
80 }
81
82 enum
83 {
84 kPEFProcessShare = 1,
85 kPEFGlobalShare = 4,
86 kPEFProtectedShare = 5
87 }
88
89 enum
90 {
91 kPEFPkDataZero = 0,
92 kPEFPkDataBlock = 1,
93 kPEFPkDataRepeat = 2,
94 kPEFPkDataRepeatBlock = 3,
95 kPEFPkDataRepeatZero = 4
96 }
97
98 enum
99 {
100 kPEFPkDataOpcodeShift = 5,
101 kPEFPkDataCount5Mask = 0x1F,
102 kPEFPkDataMaxCount5 = 31,
103 kPEFPkDataVCountShift = 7,
104 kPEFPkDataVCountMask = 0x7F,
105 kPEFPkDataVCountEndMask = 0x80
106 }
107
108 enum
109 {
110 kPEFWeakImportLibMask = 0x40,
111 kPEFInitLibBeforeMask = 0x80
112 }
113
114 enum
115 {
116 kPEFImpSymClassShift = 24,
117 kPEFImpSymNameOffsetMask = 0x00FFFFFF,
118 kPEFImpSymMaxNameOffset = 0x00FFFFFF
119 }
120
121 enum
122 {
123 kPEFCodeSymbol = 0x00,
124 kPEFDataSymbol = 0x01,
125 kPEFTVectorSymbol = 0x02,
126 kPEFTOCSymbol = 0x03,
127 kPEFGlueSymbol = 0x04,
128 kPEFUndefinedSymbol = 0x0F,
129 kPEFWeakImportSymMask = 0x80
130 }
131
132 enum
133 {
134 kPEFHashSlotSymCountShift = 18,
135 kPEFHashSlotFirstKeyMask = 0x0003FFFF,
136 kPEFHashSlotMaxSymbolCount = 0x00003FFF,
137 kPEFHashSlotMaxKeyIndex = 0x0003FFFF
138 }
139
140 enum
141 {
142 kPEFHashLengthShift = 16,
143 kPEFHashValueMask = 0x0000FFFF,
144 kPEFHashMaxLength = 0x0000FFFF
145 }
146
147 enum
148 {
149 kPEFExpSymClassShift = 24,
150 kPEFExpSymNameOffsetMask = 0x00FFFFFF,
151 kPEFExpSymMaxNameOffset = 0x00FFFFFF
152 }
153
154 enum
155 {
156 kPEFAbsoluteExport = -2,
157 kPEFReexportedImport = -3
158 }
159
160 enum
161 {
162 kPEFRelocBasicOpcodeRange = 128
163 }
164
165 enum
166 {
167 kPEFRelocBySectDWithSkip = 0x00,
168 kPEFRelocBySectC = 0x20,
169 kPEFRelocBySectD = 0x21,
170 kPEFRelocTVector12 = 0x22,
171 kPEFRelocTVector8 = 0x23,
172 kPEFRelocVTable8 = 0x24,
173 kPEFRelocImportRun = 0x25,
174 kPEFRelocSmByImport = 0x30,
175 kPEFRelocSmSetSectC = 0x31,
176 kPEFRelocSmSetSectD = 0x32,
177 kPEFRelocSmBySection = 0x33,
178 kPEFRelocIncrPosition = 0x40,
179 kPEFRelocSmRepeat = 0x48,
180 kPEFRelocSetPosition = 0x50,
181 kPEFRelocLgByImport = 0x52,
182 kPEFRelocLgRepeat = 0x58,
183 kPEFRelocLgSetOrBySection = 0x5A,
184 kPEFRelocUndefinedOpcode = 0xFF
185 }
186
187 enum
188 {
189 kPEFRelocLgBySectionSubopcode = 0x00,
190 kPEFRelocLgSetSectCSubopcode = 0x01,
191 kPEFRelocLgSetSectDSubopcode = 0x02
192 }
193
194 enum
195 {
196 kPEFRelocWithSkipMaxSkipCount = 255,
197 kPEFRelocWithSkipMaxRelocCount = 63
198 }
199
200 enum
201 {
202 kPEFRelocRunMaxRunLength = 512
203 }
204
205 enum
206 {
207 kPEFRelocSmIndexMaxIndex = 511
208 }
209
210 enum
211 {
212 kPEFRelocIncrPositionMaxOffset = 4096
213 }
214
215 enum
216 {
217 kPEFRelocSmRepeatMaxChunkCount = 16,
218 kPEFRelocSmRepeatMaxRepeatCount = 256
219 }
220
221 enum
222 {
223 kPEFRelocSetPosMaxOffset = 0x03FFFFFF
224 }
225
226 enum
227 {
228 kPEFRelocLgByImportMaxIndex = 0x03FFFFFF
229 }
230
231 enum
232 {
233 kPEFRelocLgRepeatMaxChunkCount = 16,
234 kPEFRelocLgRepeatMaxRepeatCount = 0x003FFFFF
235 }
236
237 enum
238 {
239 kPEFRelocLgSetOrBySectionMaxIndex = 0x003FFFFF
240 }
241
242 enum
243 {
244 kXLibTag1 = cast(c_long)0xF04D6163,
245 kVLibTag2 = getOSType!("VLib"),
246 kBLibTag2 = getOSType!("BLib"),
247 kXLibVersion = 0x00000001
248 }
249
250 struct PEFSectionHeader
251 {
252 int nameOffset;
253 uint defaultAddress;
254 uint totalLength;
255 uint unpackedLength;
256 uint containerLength;
257 uint containerOffset;
258 ubyte sectionKind;
259 ubyte shareKind;
260 ubyte alignment;
261 ubyte reservedA;
262 }
263
264
265 struct PEFLoaderInfoHeader
266 {
267 int mainSection;
268 uint mainOffset;
269 int initSection;
270 uint initOffset;
271 int termSection;
272 uint termOffset;
273 uint importedLibraryCount;
274 uint totalImportedSymbolCount;
275 uint relocSectionCount;
276 uint relocInstrOffset;
277 uint loaderStringsOffset;
278 uint exportHashOffset;
279 uint exportHashTablePower;
280 uint exportedSymbolCount;
281 }
282
283
284 struct PEFImportedLibrary
285 {
286 uint nameOffset;
287 uint oldImpVersion;
288 uint currentVersion;
289 uint importedSymbolCount;
290 uint firstImportedSymbol;
291 ubyte options;
292 ubyte reservedA;
293 ushort reservedB;
294 }
295
296
297 struct PEFImportedSymbol
298 {
299 uint classAndName;
300 }
301
302
303 struct PEFExportedSymbolHashSlot
304 {
305 uint countAndStart;
306 }
307
308
309 struct PEFSplitHashWord
310 {
311 ushort nameLength;
312 ushort hashValue;
313 }
314
315
316 struct PEFExportedSymbolKey
317 {
318 union
319 {
320 uint fullHashWord;
321 PEFSplitHashWord splitHashWord;
322 }
323 }
324
325 struct PEFExportedSymbol
326 {
327 uint classAndName;
328 short symbolValue;
329 SInt16 sectionIndex;
330 }
331
332
333 struct PEFLoaderRelocationHeader
334 {
335 ushort sectionIndex;
336 uint reservedA;
337 uint relocCount;
338 UInt32 firstRelocOffset;
339 }
340
341
342 struct XLibContainerHeader
343 {
344 uint tag1;
345 uint tag2;
346 uint currentFormat;
347 uint containerStringsOffset;
348 uint exportHashOffset;
349 uint exportKeyOffset;
350 uint exportSymbolOffset;
351 uint exportNamesOffset;
352 uint exportHashTablePower;
353 uint exportedSymbolCount;
354 uint fragNameOffset;
355 uint fragNameLength;
356 uint dylibPathOffset;
357 uint dylibPathLength;
358 uint cpuFamily;
359 uint cpuModel;
360 uint dateTimeStamp;
361 uint currentVersion;
362 uint oldDefVersion;
363 UInt32 oldImpVersion;
364 }
365
366
367 struct XLibExportedSymbol
368 {
369 uint classAndName;
370 UInt32 bpOffset;
371 }
372