Changeset 299
- Timestamp:
- 04/22/08 19:43:11 (9 months ago)
- Files:
-
- trunk/ddl/Linker.d (modified) (2 diffs)
- trunk/ddl/PathLibrary.d (modified) (3 diffs)
- trunk/ddl/omf/OMFBinary.d (modified) (2 diffs)
- trunk/ddl/omf/OMFLibrary.d (modified) (5 diffs)
- trunk/ddl/omf/OMFModule.d (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ddl/Linker.d
r298 r299 238 238 } else { 239 239 char[] ext = sym.isExternal ? "external" : "local"; 240 bool isWeak = sym.type == SymbolType.Weak; 241 throw new DDLException("cannot resolve symbol: [{0:X}] {1} {2} {3}" ~ (isWeak ? " the symbol is weak" : "") ~ \n,cast(uint)sym.address, sym.getTypeName(), ext, sym.name); 240 throw new DDLException("cannot resolve symbol: [{0:X}] {1} {2}"\n, cast(uint)sym.address, sym.getTypeName(), ext, sym.name); 242 241 } 243 242 } … … 287 286 } 288 287 289 auto otherSym = otherMod.getSymbol(sym.name);288 auto otherSym = lib.getSymbol(sym.name);//otherMod.getSymbol(sym.name); 290 289 291 290 //if (SymbolType.Unresolved != otherSym.type) { trunk/ddl/PathLibrary.d
r287 r299 235 235 } 236 236 237 public override ExportSymbolPtr getSymbol(char[] name){237 /+public override ExportSymbolPtr getSymbol(char[] name){ 238 238 DynamicModule mod = this.getModuleForSymbol(name); 239 239 if(mod) return mod.getSymbol(name); 240 240 return null; 241 } 241 }+/ 242 242 243 243 public override DynamicModule[] getModules(){ … … 257 257 public override char[][char[]] getAttributes(){ 258 258 return this.attributes; 259 } 260 261 public override ExportSymbolPtr getSymbol(char[] name){ 262 if(name.length > 2 && name[0..2] == "_D"){ 263 for (char[] namespace = parseNamespace(name); namespace !is null; namespace = getParentNamespace(namespace)) { 264 // try a namespace lookup first 265 DynamicLibrary* xrefLib = namespace in namespaceXref; 266 if(xrefLib){ 267 return (*xrefLib).getSymbol(name); 268 } 269 270 // dig through the root libs 271 foreach(DynamicLibrary lib; getRootLibraries()){ 272 ExportSymbolPtr sym = lib.getSymbol(name); 273 namespaceXref[namespace] = lib; 274 if (sym !is &ExportSymbol.NONE) return sym; 275 } 276 277 foreach (xlat; namespaceTranslators) { 278 char[] path = FilePath.join(this.root.toString(), xlat(namespace.dup)); 279 if(isFullyLoaded){ 280 //don't bother with path matching because we're already loaded 281 foreach(libPath,lib; pathXref){ 282 if(libPath == path){ 283 ExportSymbolPtr sym = lib.getSymbol(name); 284 namespaceXref[namespace] = lib; 285 if (sym !is &ExportSymbol.NONE) return sym; 286 } 287 } 288 } 289 else{ 290 // look for a path match 291 if(path != ""){ 292 auto test = new FilePath(path); 293 if (test.exists && !test.isFolder){ 294 DynamicLibrary lib = loaderRegistry.load(path); 295 if(lib) { 296 cachedLibraries ~= lib; 297 namespaceXref[namespace] = lib; 298 return lib.getSymbol(name); 299 } 300 } 301 302 //find first loadable library file that matches <root-path><path>/* and contains 'name' 303 ExportSymbolPtr sym; 304 (new FilePath(path)).toList(delegate bool(FilePath path_, bool isDirectory){ 305 DynamicLibrary lib = loaderRegistry.load(path_.toString); 306 if (lib) { 307 cachedLibraries ~= lib; 308 namespaceXref[namespace] = lib; 309 sym = lib.getSymbol(name); 310 return 0; 311 } 312 return 1; 313 }); 314 return sym; 315 } 316 } 317 } 318 } 319 } 320 // match a non-D symbol 321 else{ 322 // dig through the root libs 323 foreach(DynamicLibrary lib; getRootLibraries()){ 324 auto sym = lib.getSymbol(name); 325 if (sym !is &ExportSymbol.NONE) return sym; 326 } 327 } 328 //failed to find the module 329 debug debugLog("PathLibrary.getSymbol - failed to find: {0}",name); 330 return null; 259 331 } 260 332 … … 331 403 } 332 404 405 333 406 // expects resource in file-path format 334 407 public override ubyte[] getResource(char[] name){ trunk/ddl/omf/OMFBinary.d
r297 r299 567 567 568 568 // use the repeat count repeat rawData 569 ubyte[] tempData; 569 570 // BUG? This code didn't do anything meaningful - h3 571 /+ubyte[] tempData; 570 572 for(uint i=0; i<repeatCount; i++){ 571 573 tempData ~= result; 572 } 574 }+/ 575 573 576 // use rawData to store the result of the repeat 574 577 return result; … … 941 944 thisRecord.parse(mainReader); 942 945 943 OMFReader reader = thisRecord.getOMFReader();946 scope OMFReader reader = thisRecord.getOMFReader(); 944 947 945 948 debug debugLog("record: {0:X} ({1:X}) data: {2} {3} length: {4}",thisRecord.recordType,thisRecord.type,thisRecord.data,recordNameLookup[thisRecord.recordType], thisRecord.length); trunk/ddl/omf/OMFLibrary.d
r292 r299 40 40 class OMFLibrary : DynamicLibrary{ 41 41 DynamicModule[] modules; 42 DynamicModule[char[]] crossReference; // modules by symbol name 43 ExportSymbolPtr[char[]] dictionary; // symbols by symbol name 42 43 struct SymInfo { 44 DynamicModule mod; 45 ExportSymbolPtr sym; 46 } 47 SymInfo[char[]] crossReference; 48 44 49 Attributes attributes; 45 50 … … 70 75 71 76 public ExportSymbolPtr getSymbol(char[] name){ 72 ExportSymbolPtr* sym = name in dictionary;73 if (sym) return *sym;77 auto sym = name in crossReference; 78 if (sym) return sym.sym; 74 79 else return &ExportSymbol.NONE; 75 80 } … … 81 86 public DynamicModule getModuleForSymbol(char[] name){ 82 87 debug debugLog("[OMF] looking for {0} in {1}",name,attributes["omf.filename"]); 83 DynamicModule*mod = name in crossReference;88 auto mod = name in crossReference; 84 89 debug debugLog("[OMF] Result: {0:X}",mod); 85 if (mod) return *mod;90 if (mod) return mod.mod; 86 91 return null; 87 92 } … … 96 101 for(uint i=0; i<symbols.length; i++){ 97 102 ExportSymbolPtr exp = &(symbols[i]); 98 if (exp.name in crossReference){103 if (auto found = exp.name in crossReference){ 99 104 switch(exp.type){ 100 105 case SymbolType.Weak: // replace extern only 101 if (dictionary[exp.name].type == SymbolType.Unresolved){102 crossReference[exp.name]= mod;103 dictionary[exp.name]= exp;106 if (found.sym.type == SymbolType.Unresolved){ 107 found.mod = mod; 108 found.sym = exp; 104 109 } 105 110 break; 106 111 case SymbolType.Strong: // always overwrite 107 crossReference[exp.name] = mod; 108 dictionary[exp.name] = exp; 112 crossReference[exp.name] = SymInfo(mod, exp); 113 /+crossReference[exp.name] = mod; 114 dictionary[exp.name] = exp;+/ 109 115 break; 110 116 default: … … 113 119 } 114 120 else{ 115 crossReference[exp.name] = mod; 116 dictionary[exp.name] = exp; 121 /+crossReference[exp.name] = mod; 122 dictionary[exp.name] = exp;+/ 123 crossReference[exp.name] = SymInfo(mod, exp); 117 124 } 118 125 } trunk/ddl/omf/OMFModule.d
r292 r299 36 36 37 37 private import Text = tango.text.Util; 38 import tango.stdc.stdio;38 //import tango.stdc.stdio; 39 39 40 40 version(Windows){ … … 65 65 SegmentImage[] segmentImages; 66 66 ExportSymbol[] symbols; 67 ExportSymbolPtr[char[]] symbolXref;68 67 char[] moduleName; 69 68 bool resolved; … … 88 87 89 88 public ExportSymbol* getSymbol(char[] name){ 90 if(name in symbolXref) return symbolXref[name]; 91 else return &ExportSymbol.NONE; 89 /+if(name in symbolXref) return symbolXref[name]; 90 else return &ExportSymbol.NONE;+/ 91 foreach (ref sym; symbols) { 92 if (sym.name == name) { 93 return &sym; 94 } 95 } 96 97 return &ExportSymbol.NONE; 92 98 } 93 99 … … 189 195 190 196 protected void loadBinary(DDLReader reader){ 197 ExportSymbolPtr[char[]] symbolXref; 198 191 199 debug{} else{ 192 200 OMFBinary binary;
