Changeset 116
- Timestamp:
- 01/16/06 17:03:08 (3 years ago)
- Files:
-
- trunk/ddl/omf/OMFBinary.d (modified) (5 diffs)
- trunk/ddl/omf/OMFLibrary.d (modified) (1 diff)
- trunk/utils/bless_bn.d (modified) (1 diff)
- trunk/utils/ddlinfo.d (modified) (1 diff)
- trunk/utils/ddlinfo_bn.d (modified) (1 diff)
- trunk/utils/insitu_bn.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ddl/omf/OMFBinary.d
r114 r116 29 29 private import ddl.omf.OMFException; 30 30 31 version(Windows){ 32 extern (Windows) 33 { 34 alias uint HANDLE; 35 alias HANDLE HMODULE; 36 alias int BOOL; 37 alias int (*FARPROC)(); 38 alias void* LPCSTR; 39 FARPROC GetProcAddress(HMODULE hModule, LPCSTR lpProcName); 40 HMODULE LoadLibraryA(LPCSTR lpLibFileName); 41 BOOL FreeLibrary(HMODULE hLibModule); 42 } 43 } 44 31 45 struct Group{ 32 46 char[] name; … … 113 127 Fixup[] unresolvedFixups; 114 128 129 //OS specific bits 130 version(Windows){ 131 HANDLE[char[]] dllHandles; 132 } 133 115 134 public this(){ 116 135 groups.length = 1; … … 118 137 names.length = 1; 119 138 segments.length = 1; 139 } 140 141 public ~this(){ 142 version(Windows){ 143 foreach(HANDLE handle; dllHandles){ 144 FreeLibrary(handle); 145 } 146 } 120 147 } 121 148 … … 192 219 //TODO: store someplace else 193 220 //this.libraryName = comment; 194 break; 221 break; 222 223 case 0xA0: // OMF extensions 224 ubyte extensionType = comment[0]; 225 WordOMFRecordCursor cursor = new WordOMFRecordCursor(cast(ubyte[])comment[1..$],0); 226 227 switch(extensionType){ 228 case 0x01: // import definition record 229 version(Windows){ 230 ubyte ordinalFlag = cursor.getByte(); 231 char[] internalName = cursor.getLString(); 232 char[] moduleName = cursor.getLString(); 233 HANDLE* pHandle = moduleName in dllHandles; 234 HANDLE thisHandle; 235 236 if(!pHandle){ 237 thisHandle = LoadLibraryA((moduleName~"\0").ptr); 238 dllHandles[moduleName] = thisHandle; 239 } 240 else{ 241 thisHandle = *pHandle; 242 } 243 244 if(ordinalFlag == 0){ 245 char[] entryName; 246 if(cursor.peekByte() == 0){ 247 entryName = internalName; 248 } 249 else{ 250 entryName = cursor.getLString(); 251 } 252 debugLog("impdef: [%s] [%s] %s",internalName,moduleName,entryName); 253 254 // store the extern as both its entry name and the internal name 255 PublicSymbol pub; 256 pub.name = internalName; 257 pub.segmentIndex = 0; 258 pub.offset = cast(uint)GetProcAddress(thisHandle,(entryName~"\0").ptr); 259 publics[pub.name] = pub; 260 261 pub.name = entryName; 262 publics[pub.name] = pub; 263 } 264 else{ 265 uint entryOrdinal = cursor.getWord(); 266 debugLog("impdef: [%s] [%s] %d",internalName,moduleName,entryOrdinal); 267 268 // store the extern via its ordinal in the dll 269 PublicSymbol pub; 270 pub.name = internalName; 271 pub.segmentIndex = 0; 272 pub.offset = cast(uint)GetProcAddress(thisHandle,cast(void*)entryOrdinal); 273 publics[pub.name] = pub; 274 } 275 } 276 else{ 277 throw new Exception("Non-Windows operating systems cannot support implib style OMF binaries."); 278 } 279 280 } 281 break; 195 282 196 283 case 0xA8: // Weak extern (dependency) … … 200 287 // default extern index is thrown out 201 288 202 debug writefln("dependency: symbol %d",externIndex);289 debug debugLog("dependency: symbol %d",externIndex); 203 290 204 291 this.dependencies[this.externs[externIndex].name] ~= externIndex; trunk/ddl/omf/OMFLibrary.d
r101 r116 149 149 //skip the dictionary (redundant) 150 150 } 151 152 public char[] toString(){ 153 char[] result = ""; 154 foreach(DynamicModule mod; modules){ 155 result ~= mod.toString(); 156 } 157 return result; 158 } 151 159 } 152 160 trunk/utils/bless_bn.d
r101 r116 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 1 51;4 long auto_build_number = 193; trunk/utils/ddlinfo.d
r92 r116 147 147 } 148 148 } 149 //Stdout.println("%s",lib.toString()); 149 150 150 151 return 0; trunk/utils/ddlinfo_bn.d
r101 r116 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 1 51;4 long auto_build_number = 193; trunk/utils/insitu_bn.d
r101 r116 2 2 // This file is automatically maintained by the BUILD utility, 3 3 // Please refrain from manually editing it. 4 long auto_build_number = 1 51;4 long auto_build_number = 193;
