annotate dmd/Library.d @ 114:e28b18c23469

added a module dmd.common for commonly used stuff it currently holds code for consistency checking of predefined versions also added a VisualD project file
author Trass3r
date Wed, 01 Sep 2010 18:21:58 +0200
parents 2cc604139636
children e7769d53e750
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.Library;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
114
e28b18c23469 added a module dmd.common for commonly used stuff
Trass3r
parents: 14
diff changeset
3 import dmd.common;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.File;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.StringTable;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.ObjModule;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.String;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Global;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.File;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.FileName;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.StringValue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.String;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import core.stdc.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import core.stdc.stdlib;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import std.string;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21
4
d706d958e4e8 Step 2 of restoring GC functionality.
korDen
parents: 2
diff changeset
22 import core.memory;
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
23
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 align(1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 struct LibHeader
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 ubyte recTyp; // 0xF0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 ushort pagesize;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 int lSymSeek;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 ushort ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 ubyte flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 align(1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 struct Libheader
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 ubyte recTyp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 ushort recLen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 int trailerPosn;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 ushort ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 ubyte flags;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 char[6] filler;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 struct ObjSymbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 string name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 ObjModule* om;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 /**************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 * Record types:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 enum HASHMOD = 0x25;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 enum BUCKETPAGE = 512;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 enum BUCKETSIZE = (BUCKETPAGE - HASHMOD - 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 #define RHEADR 0x6E
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 #define REGINT 0x70
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 #define REDATA 0x72
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 #define RIDATA 0x74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 #define OVLDEF 0x76
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 #define ENDREC 0x78
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 #define BLKDEF 0x7A
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 #define BLKEND 0x7C
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 #define DEBSYM 0x7E
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 enum THEADR = 0x80;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 enum LHEADR = 0x82;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 /+#define PEDATA 0x84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 #define PIDATA 0x86
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 enum COMENT = 0x88;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 enum MODEND = 0x8A;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 enum M386END = 0x8B; /* 32 bit module end record */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 #define EXTDEF 0x8C
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 #define TYPDEF 0x8E
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 enum PUBDEF = 0x90;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 enum PUB386 = 0x91;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 #define LOCSYM 0x92
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 #define LINNUM 0x94
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 enum LNAMES = 0x96;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 /+
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 #define SEGDEF 0x98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 #define GRPDEF 0x9A
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 #define FIXUPP 0x9C
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 /*#define (none) 0x9E */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 #define LEDATA 0xA0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 #define LIDATA 0xA2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 #define LIBHED 0xA4
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 #define LIBNAM 0xA6
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 #define LIBLOC 0xA8
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 #define LIBDIC 0xAA
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 #define COMDEF 0xB0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 #define LEXTDEF 0xB4
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 #define LPUBDEF 0xB6
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 #define LCOMDEF 0xB8
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 #define CEXTDEF 0xBC
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 enum COMDAT = 0xC2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 /+#define LINSYM 0xC4
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 +/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 enum ALIAS = 0xC6;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 enum LLNAMES = 0xCA;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 enum LIBIDMAX = (512 - 0x25 - 3 - 4); // max size that will fit in dictionary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 extern (C) extern char* strdup(const(char)* ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 static uint parseName(ubyte** pp, char* name)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 ubyte* p = *pp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 uint len = *p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 if (len == 0xFF && *p == 0) // if long name
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 len = p[1] & 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 len |= cast(uint)p[2] << 8;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 p += 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 assert(len <= LIBIDMAX);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 memcpy(name, p, len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 name[len] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 *pp = p + len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134 return len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 static ushort parseIdx(ubyte** pp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 ubyte* p = *pp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 ubyte c = *p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142 ushort idx = cast(ushort)((0x80 & c) ? ((0x7F & c) << 8) + *p++ : c);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 *pp = p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 return idx;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 extern (C) int D_NameCompare(const(void*) a, const(void*) b)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 ObjSymbol** p1 = cast(ObjSymbol**)a;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 ObjSymbol** p2 = cast(ObjSymbol**)b;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 return cmp((*p1).name, (*p2).name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 }
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
154 version (Windows)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
155 {
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 /*******************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 * Write a single entry into dictionary.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 * Returns:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 * 0 failure
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 extern (C) extern uint _rotl(uint value, int shift);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 extern (C) extern uint _rotr(uint value, int shift);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 static int EnterDict(ubyte* bucketsP, ushort ndicpages, ubyte* entry, uint entrylen)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 ushort uStartIndex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 ushort uStep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 ushort uStartPage;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 ushort uPageStep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 ushort uIndex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 ushort uPage;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 ushort n;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 uint u;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 uint nbytes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 ubyte* aP;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 ubyte* zP;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 aP = entry;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 zP = aP + entrylen; // point at last char in identifier
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 uStartPage = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 uPageStep = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 uStartIndex = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 uStep = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 u = entrylen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 while ( u-- )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 uStartPage = cast(ushort)_rotl( uStartPage, 2 ) ^ ( *aP | 0x20 );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 uStep = cast(ushort)_rotr( uStep, 2 ) ^ ( *aP++ | 0x20 );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 uStartIndex = cast(ushort)_rotr( uStartIndex, 2 ) ^ ( *zP | 0x20 );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 uPageStep = cast(ushort)_rotl( uPageStep, 2 ) ^ ( *zP-- | 0x20 );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 uStartPage %= ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 uPageStep %= ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 if ( uPageStep == 0 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 uPageStep++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 uStartIndex %= HASHMOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 uStep %= HASHMOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 if ( uStep == 0 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 uStep++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 uPage = uStartPage;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 uIndex = uStartIndex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 // number of bytes in entry
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 nbytes = 1 + entrylen + 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 if (entrylen > 255)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 nbytes += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 while (1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 aP = &bucketsP[uPage * BUCKETPAGE];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 uStartIndex = uIndex;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 while (1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 if ( 0 == aP[ uIndex ] )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 // n = next available position in this page
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 n = aP[ HASHMOD ] << 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 assert(n > HASHMOD);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 // if off end of this page
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226 if (n + nbytes > BUCKETPAGE )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 { aP[ HASHMOD ] = 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 break; // next page
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 aP[ uIndex ] = cast(ubyte)(n >> 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 memcpy( (aP + n), entry, nbytes );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 aP[ HASHMOD ] += (nbytes + 1) >> 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 if (aP[HASHMOD] == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 aP[HASHMOD] = 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 uIndex += uStep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 uIndex %= 0x25;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 /*if (uIndex > 0x25)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 uIndex -= 0x25;*/
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 if( uIndex == uStartIndex )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 uPage += uPageStep;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 if (uPage >= ndicpages)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 uPage -= ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 if( uPage == uStartPage )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 class Library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 File libfile;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 Array objmodules; // ObjModule[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 Array objsymbols; // ObjSymbol[]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 StringTable tab;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 this()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 libfile = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 objmodules = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 objsymbols = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 tab = new StringTable();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 /***********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 * Set the library file name based on the output directory
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 * and the filename.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 * Add default library file name extension.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 void setFilename(string dir, string filename)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 string arg = filename;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 if (arg.length == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 // Generate lib file name from first obj name
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 string n = (cast(String)global.params.objfiles.data[0]).str;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 n = FileName.name(n);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 FileName fn = FileName.forceExt(n, global.lib_ext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 arg = fn.toChars();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 if (!FileName.absolute(arg))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 arg = FileName.combine(dir, arg);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 FileName libfilename = FileName.defaultExt(arg, global.lib_ext);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 libfile = new File(libfilename);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 /***************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 * Add object module or library to the library.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 * Examine the buffer to see which it is.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 * If the buffer is null, use module_name as the file name
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 * and load the file.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304 void addObject(string module_name, void *buf, size_t buflen)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 version (LOG) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307 printf("Library.addObject(%s)\n", module_name ? module_name : "");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 if (!buf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 assert(module_name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 scope FileName f = new FileName(module_name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 scope File file = new File(f);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 file.readv();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 buf = file.buffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 buflen = file.len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 file.ref_ = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 uint g_page_size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 ubyte* pstart = cast(ubyte*)buf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 int islibrary = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 /* See if it's an OMF library.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 * Don't go by file extension.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 /* Determine if it is an OMF library, an OMF object module,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 * or something else.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 if (buflen < LibHeader.sizeof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 Lcorrupt:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 error("corrupt object module");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 LibHeader* lh = cast(LibHeader*)buf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 if (lh.recTyp == 0xF0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 { /* OMF library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 * The modules are all at buf[g_page_size .. lh.lSymSeek]
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 islibrary = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 g_page_size = lh.pagesize + 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 buf = cast(void*)(pstart + g_page_size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 if (lh.lSymSeek > buflen ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 g_page_size > buflen)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 goto Lcorrupt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 buflen = lh.lSymSeek - g_page_size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 else if (lh.recTyp == '!' && memcmp(lh, "!<arch>\n".ptr, 8) == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 error("COFF libraries not supported");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 // Not a library, assume OMF object module
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 g_page_size = 16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 /* Split up the buffer buf[0..buflen] into multiple object modules,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 * each aligned on a g_page_size boundary.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 ObjModule* om = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 int first_module = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 ubyte* p = cast(ubyte*)buf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 ubyte* pend = p + buflen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 ubyte* pnext;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 for (; p < pend; p = pnext) // for each OMF record
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 if (p + 3 >= pend)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 goto Lcorrupt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 ubyte recTyp = *p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 ushort recLen = *cast(ushort*)(p + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 pnext = p + 3 + recLen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 if (pnext > pend)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 goto Lcorrupt;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 recLen--; /* forget the checksum */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 switch (recTyp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383 case LHEADR :
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 case THEADR :
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 if (!om)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 char name[LIBIDMAX + 1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 om = new ObjModule();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 om.flags = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 om.base = p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 p += 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 parseName(&p, name.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 if (first_module && module_name && !islibrary)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 // Remove path and extension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 string fname = FileName.name(module_name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 string ext = FileName.ext(fname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 if (ext.length != 0) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 fname = fname[0..$-ext.length-1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 om.name = fname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 /* Use THEADR name as module name,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 * removing path and extension.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 string fname = FileName.name(fromStringz(name.ptr));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 string ext = FileName.ext(fname);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 if (ext.length != 0) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412 fname = fname[0..$-ext.length-1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 om.name = fname;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 om.flags |= MFtheadr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418 if (strcmp(name.ptr, "C".ptr) == 0) // old C compilers did this
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 om.flags |= MFgentheadr; // generate our own THEADR
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421 om.base = pnext; // skip past THEADR
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 objmodules.push(cast(void*)om);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 first_module = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 case MODEND :
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 case M386END:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 if (om)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 om.page = cast(ushort)((om.base - pstart) / g_page_size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 om.length = pnext - om.base;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434 om = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 // Round up to next page
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 uint t = pnext - pstart;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 t = (t + g_page_size - 1) & ~cast(uint)(g_page_size - 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 pnext = pstart + t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443 // ignore
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 if (om)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 goto Lcorrupt; // missing MODEND record
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 void addLibrary(void *buf, size_t buflen)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 void write()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 if (global.params.verbose)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 writef("library %s\n", libfile.name.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 scope OutBuffer libbuf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463 WriteLibToBuffer(libbuf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 // Transfer image to file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 libfile.setbuffer(libbuf.data, libbuf.offset);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 libbuf.extractData();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469 string p = FileName.path(libfile.name.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 FileName.ensurePathExists(p);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 libfile.writev();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475 private:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 void addSymbol(ObjModule* om, string name, int pickAny = 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 version (LOG) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 printf("Library.addSymbol(%s, %s, %d)\n", om.name, name, pickAny);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481 StringValue* s = tab.insert(name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 if (!s)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 // already in table
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 if (!pickAny)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487 s = tab.lookup(name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 assert(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 ObjSymbol* os = cast(ObjSymbol*)s.ptrvalue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 error("multiple definition of %s: %s and %s: %s",
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 om.name, name, os.om.name, os.name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 ObjSymbol* os = new ObjSymbol();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 os.name = name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 os.om = om;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 s.ptrvalue = cast(void*)os;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 objsymbols.push(os);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 void scanObjModule(ObjModule* om)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 int easyomf;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 uint u;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 ubyte result = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 char name[LIBIDMAX + 1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 scope Array names = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513 names.push(null); // don't use index 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 assert(om);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 easyomf = 0; // assume not EASY-OMF
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 ubyte* pend = om.base + om.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 ubyte* pnext;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 for (ubyte* p = om.base; 1; p = pnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 assert(p < pend);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 ubyte recTyp = *p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 ushort recLen = *cast(ushort*)p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 p += 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 pnext = p + recLen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527 recLen--; // forget the checksum
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 switch (recTyp)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 case LNAMES:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 case LLNAMES:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 while (p + 1 < pnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 uint len = parseName(&p, name.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
536 names.push(cast(void*)new String(name[0..len].idup));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
537 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
538 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
539
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
540 case PUBDEF:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
541 if (easyomf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
542 recTyp = PUB386; // convert to MS format
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
543 case PUB386:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
544 if (!(parseIdx(&p) | parseIdx(&p)))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
545 p += 2; // skip seg, grp, frame
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
546 while (p + 1 < pnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
547 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
548 uint len = parseName(&p, name.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
549 p += (recTyp == PUBDEF) ? 2 : 4; // skip offset
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
550 parseIdx(&p); // skip type index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
551 addSymbol(om, name[0..len].idup);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
552 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
553 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
554
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
555 case COMDAT:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
556 if (easyomf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
557 recTyp = COMDAT+1; // convert to MS format
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
558 case COMDAT+1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
559 int pickAny = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
560
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
561 if (*p++ & 5) // if continuation or local comdat
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
562 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
563
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
564 ubyte attr = *p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
565 if (attr & 0xF0) // attr: if multiple instances allowed
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
566 pickAny = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
567 p++; // align
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
568
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
569 p += 2; // enum data offset
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
570 if (recTyp == COMDAT+1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
571 p += 2; // enum data offset
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
572
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
573 parseIdx(&p); // type index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
574
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
575 if ((attr & 0x0F) == 0) // if explicit allocation
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
576 { parseIdx(&p); // base group
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
577 parseIdx(&p); // base segment
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
578 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
579
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
580 uint idx = parseIdx(&p); // public name index
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
581 if( idx == 0 || idx >= names.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
582 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
583 //debug(printf("[s] name idx=%d, uCntNames=%d\n", idx, uCntNames));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
584 error("corrupt COMDAT");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
585 return;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
586 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
587
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
588 //printf("[s] name='%s'\n",name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
589 addSymbol(om, (cast(String)names.data[idx]).str, pickAny);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
590 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
591
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
592 case ALIAS:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
593 while (p + 1 < pnext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
594 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
595 uint len = parseName(&p, name.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
596 addSymbol(om, name[0..len].idup);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
597 parseName(&p, name.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
598 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
599 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
600
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
601 case MODEND:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
602 case M386END:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
603 result = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
604 goto Ret;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
605
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
606 case COMENT:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
607 // Recognize Phar Lap EASY-OMF format
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
608 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
609 static ubyte[7] omfstr = [0x80,0xAA,'8','0','3','8','6'];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
610
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
611 if (recLen == omfstr.sizeof)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
612 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
613 for (uint i = 0; i < omfstr.sizeof; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
614 if (*p++ != omfstr[i])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
615 goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
616 easyomf = 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
617 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
618 L1: ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
619 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
620 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
621 // Recognize .IMPDEF Import Definition Records
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
622 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
623 static ubyte[3] omfstr = [0, 0xA0, 1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
624
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
625 if (recLen >= 7)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
626 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
627 p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
628 for (uint i = 1; i < omfstr.sizeof; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
629 if (*p++ != omfstr[i])
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
630 goto L2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
631 p++; // skip OrdFlag field
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
632 uint len = parseName(&p, name.ptr);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
633 addSymbol(om, name[0..len].idup);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
634 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
635 L2: ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
636 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
637 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
638 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
639
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
640 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
641 // ignore
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
642 ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
643 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
644 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
645
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
646 Ret:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
647 ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
648 ///for (u = 1; u < names.dim; u++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
649 /// free(names.data[u]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
650 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
651
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
652 /***********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
653 * Calculates number of pages needed for dictionary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
654 * Returns:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
655 * number of pages
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
656 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
657 ushort numDictPages(uint padding)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
658 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
659 ushort ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
660 ushort bucksForHash;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
661 ushort bucksForSize;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
662 uint symSize = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
663
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
664 for (int i = 0; i < objsymbols.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
665 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
666 ObjSymbol* s = cast(ObjSymbol*)objsymbols.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
667 symSize += ( s.name.length + 4 ) & ~1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
668 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
669
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
670 for (int i = 0; i < objmodules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
671 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
672 ObjModule* om = cast(ObjModule*)objmodules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
673
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
674 size_t len = om.name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
675 if (len > 0xFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
676 len += 2; // Digital Mars long name extension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
677 symSize += ( len + 4 + 1 ) & ~1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
678 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
679
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
680 bucksForHash = cast(ushort)((objsymbols.dim + objmodules.dim + HASHMOD - 3) / (HASHMOD - 2));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
681 bucksForSize = cast(ushort)((symSize + BUCKETSIZE - padding - padding - 1) / (BUCKETSIZE - padding));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
682
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
683 ndicpages = (bucksForHash > bucksForSize ) ? bucksForHash : bucksForSize;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
684 //printf("ndicpages = %u\n",ndicpages);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
685
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
686 // Find prime number greater than ndicpages
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
687 static uint[] primes =
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
688 [ 1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
689 47,53,59,61,67,71,73,79,83,89,97,101,103,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
690 107,109,113,127,131,137,139,149,151,157,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
691 163,167,173,179,181,191,193,197,199,211,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
692 223,227,229,233,239,241,251,257,263,269,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
693 271,277,281,283,293,307,311,313,317,331,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
694 337,347,349,353,359,367,373,379,383,389,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
695 397,401,409,419,421,431,433,439,443,449,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
696 457,461,463,467,479,487,491,499,503,509,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
697 //521,523,541,547,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
698 0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
699 ];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
700
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
701 for (int i = 0; 1; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
702 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
703 if ( primes[i] == 0 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
704 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
705 // Quick and easy way is out.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
706 // Now try and find first prime number > ndicpages
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
707 uint prime;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
708
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
709 for (prime = (ndicpages + 1) | 1; 1; prime += 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
710 { // Determine if prime is prime
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
711 for (uint u = 3; u < prime / 2; u += 2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
712 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
713 if ((prime / u) * u == prime)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
714 goto L1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
715 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
716 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
717
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
718 L1: ;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
719 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
720 ndicpages = cast(ushort)prime;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
721 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
722 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
723
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
724 if (primes[i] > ndicpages)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
725 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
726 ndicpages = cast(ushort)primes[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
727 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
728 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
729 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
730
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
731 return ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
732 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
733
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
734 /*******************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
735 * Write the module and symbol names to the dictionary.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
736 * Returns:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
737 * 0 failure
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
738 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
739 int FillDict(ubyte* bucketsP, ushort ndicpages)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
740 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
741 ubyte entry[4 + LIBIDMAX + 2 + 1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
742
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
743 //printf("FillDict()\n");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
744
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
745 // Add each of the module names
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
746 for (int i = 0; i < objmodules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
747 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
748 ObjModule* om = cast(ObjModule*)objmodules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
749
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
750 ushort n = cast(ushort)om.name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
751 if (n > 255)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
752 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
753 entry[0] = 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
754 entry[1] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
755 *cast(ushort*)(entry.ptr + 2) = cast(ushort)(n + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
756 memcpy(entry.ptr + 4, om.name.ptr, n);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
757 n += 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
758 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
759 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
760 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
761 entry[ 0 ] = cast(ubyte)(1 + n);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
762 memcpy(entry.ptr + 1, om.name.ptr, n );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
763 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
764 entry[ n + 1 ] = '!';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
765 *(cast(ushort*)( n + 2 + entry.ptr )) = om.page;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
766 if ( n & 1 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
767 entry[ n + 2 + 2 ] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
768 if ( !EnterDict( bucketsP, ndicpages, entry.ptr, n + 1 ) )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
769 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
770 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
771
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
772 // Sort the symbols
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
773 qsort( objsymbols.data, objsymbols.dim, 4, /*(cmpfunc_t)*/&D_NameCompare );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
774
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
775 // Add each of the symbols
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
776 for (int i = 0; i < objsymbols.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
777 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
778 ObjSymbol* os = cast(ObjSymbol*)objsymbols.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
779
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
780 ushort n = cast(ushort)os.name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
781 if (n > 255)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
782 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
783 entry[0] = 0xFF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
784 entry[1] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
785 *cast(ushort*)(entry.ptr + 2) = n;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
786 memcpy(entry.ptr + 4, os.name.ptr, n);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
787 n += 3;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
788 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
789 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
790 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
791 entry[ 0 ] = cast(ubyte)n;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
792 memcpy( entry.ptr + 1, os.name.ptr, n );
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
793 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
794 *(cast(ushort*)( n + 1 + entry.ptr )) = os.om.page;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
795 if ( (n & 1) == 0 )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
796 entry[ n + 3] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
797 if ( !EnterDict( bucketsP, ndicpages, entry.ptr, n ) )
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
798 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
799 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
800 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
801 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
802
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
803 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
804 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
805
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
806 /**********************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
807 * Create and write library to libbuf.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
808 * The library consists of:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
809 * library header
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
810 * object modules...
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
811 * dictionary header
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
812 * dictionary pages...
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
813 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
814 void WriteLibToBuffer(OutBuffer libbuf)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
815 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
816 /* Scan each of the object modules for symbols
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
817 * to go into the dictionary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
818 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
819 for (int i = 0; i < objmodules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
820 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
821 ObjModule* om = cast(ObjModule*)objmodules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
822 scanObjModule(om);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
823 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
824
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
825 uint g_page_size = 16;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
826
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
827 /* Calculate page size so that the number of pages
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
828 * fits in 16 bits. This is because object modules
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
829 * are indexed by page number, stored as an unsigned short.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
830 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
831 while (1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
832 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
833 Lagain:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
834 version (LOG) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
835 printf("g_page_size = %d\n", g_page_size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
836 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
837 uint offset = g_page_size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
838
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
839 for (int i = 0; i < objmodules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
840 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
841 ObjModule* om = cast(ObjModule*)objmodules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
842
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
843 uint page = offset / g_page_size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
844 if (page > 0xFFFF)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
845 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
846 // Page size is too small, double it and try again
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
847 g_page_size *= 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
848 goto Lagain;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
849 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
850
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
851 // Write out the object module m
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
852 if (om.flags & MFgentheadr) // if generate THEADR record
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
853 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
854 size_t size = om.name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
855 assert(size <= LIBIDMAX);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
856
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
857 offset += size + 5;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
858 //offset += om.length - (size + 5);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
859 offset += om.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
860 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
861 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
862 offset += om.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
863
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
864 // Round the size of the file up to the next page size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
865 // by filling with 0s
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
866 uint n = (g_page_size - 1) & offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
867 if (n)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
868 offset += g_page_size - n;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
869 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
870 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
871 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
872
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
873
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
874 /* Leave one page of 0s at start as a dummy library header.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
875 * Fill it in later with the real data.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
876 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
877 libbuf.fill0(g_page_size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
878
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
879 /* Write each object module into the library
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
880 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
881 for (int i = 0; i < objmodules.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
882 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
883 ObjModule* om = cast(ObjModule*)objmodules.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
884
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
885 uint page = libbuf.offset / g_page_size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
886 assert(page <= 0xFFFF);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
887 om.page = cast(ushort)page;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
888
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
889 // Write out the object module om
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
890 if (om.flags & MFgentheadr) // if generate THEADR record
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
891 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
892 uint size = om.name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
893 ubyte header[4 + LIBIDMAX + 1];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
894
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
895 header [0] = THEADR;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
896 header [1] = cast(ubyte)(2 + size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
897 header [2] = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
898 header [3] = cast(ubyte)size;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
899 assert(size <= 0xFF - 2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
900
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
901 memcpy(4 + header.ptr, om.name.ptr, size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
902
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
903 // Compute and store record checksum
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
904 uint n = size + 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
905 ubyte checksum = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
906 ubyte* p = header.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
907 while (n--)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
908 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
909 checksum -= *p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
910 p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
911 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
912 *p = checksum;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
913
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
914 libbuf.write(header.ptr, size + 5);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
915 //libbuf.write(om.base, om.length - (size + 5));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
916 libbuf.write(om.base, om.length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
917 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
918 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
919 libbuf.write(om.base, om.length);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
920
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
921 // Round the size of the file up to the next page size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
922 // by filling with 0s
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
923 uint n = (g_page_size - 1) & libbuf.offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
924 if (n)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
925 libbuf.fill0(g_page_size - n);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
926 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
927
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
928 // File offset of start of dictionary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
929 uint offset = libbuf.offset;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
930
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
931 // Write dictionary header, then round it to a BUCKETPAGE boundary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
932 ushort size = (BUCKETPAGE - (cast(short)offset + 3)) & (BUCKETPAGE - 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
933 libbuf.writeByte(0xF1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
934 libbuf.writeword(size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
935 libbuf.fill0(size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
936
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
937 // Create dictionary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
938 ubyte* bucketsP = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
939 ushort ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
940 ushort padding = 32;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
941 for (;;)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
942 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
943 ndicpages = numDictPages(padding);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
944
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
945 version (LOG) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
946 printf("ndicpages = %d\n", ndicpages);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
947 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
948 // Allocate dictionary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
949 if (bucketsP)
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
950 bucketsP = cast(ubyte*)GC.realloc(bucketsP, ndicpages * BUCKETPAGE);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
951 else
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
952 bucketsP = cast(ubyte*)GC.malloc(ndicpages * BUCKETPAGE);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
953 assert(bucketsP);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
954 memset(bucketsP, 0, ndicpages * BUCKETPAGE);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
955 for (uint u = 0; u < ndicpages; u++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
956 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
957 // 'next available' slot
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
958 bucketsP[u * BUCKETPAGE + HASHMOD] = (HASHMOD + 1) >> 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
959 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
960
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
961 if (FillDict(bucketsP, ndicpages))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
962 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
963 padding += 16; // try again with more margins
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
964 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
965
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
966 // Write dictionary
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
967 libbuf.write(bucketsP, ndicpages * BUCKETPAGE);
2
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
968 ///if (bucketsP)
7427ded8caf7 Removed unreferenced modules
korDen
parents: 0
diff changeset
969 /// free(bucketsP);
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
970
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
971 // Create library header
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
972 Libheader libHeader;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
973 memset(&libHeader, 0, Libheader.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
974 libHeader.recTyp = 0xF0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
975 libHeader.recLen = 0x0D;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
976 libHeader.trailerPosn = offset + (3 + size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
977 libHeader.recLen = cast(ushort)(g_page_size - 3);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
978 libHeader.ndicpages = ndicpages;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
979 libHeader.flags = 1; // always case sensitive
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
980
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
981 // Write library header at start of buffer
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
982 memcpy(libbuf.data, &libHeader, libHeader.sizeof);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
983 }
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
984 }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
985 } // version (Windows)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
986 else version(TARGET_LINUX)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
987 {
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
988 class Library
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
989 {
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
990 void setFilename(string dir, string filename)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
991 {
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
992 assert(0);
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
993 }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
994
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
995 void addObject(string module_name, void *buf, size_t buflen)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
996 {
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
997 assert(0);
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
998 }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
999
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1000 void write()
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1001 {
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1002 assert(0);
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1003 }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1004
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1005 }
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 4
diff changeset
1006 }