Changeset 274
- Timestamp:
- 11/15/06 21:15:07 (2 years ago)
- Files:
-
- trunk/ddl/omf/OMFModule.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ddl/omf/OMFModule.d
r273 r274 92 92 } 93 93 94 protected bool containsAddress(void* addr){ 95 foreach(seg; this.segmentImages){ 96 debug debugLog("checking addr: [%0.8X] [%0.8X] [%0.8X]",seg.data.ptr,addr,(seg.data.ptr + seg.data.length)); 97 if(addr >= seg.data.ptr && addr <= (seg.data.ptr + seg.data.length)){ 98 return true; 99 } 100 } 101 return false; 102 } 103 94 104 public void resolveFixups(){ 95 105 Fixup[] remainingFixups; … … 108 118 } 109 119 else{ 120 debug debugLog("Fixup dest symbol: %s [%0.8X] %d",destSymbol.name,destSymbol.address,destSymbolOffset); 110 121 destAddress = cast(uint)destSymbol.address + destSymbolOffset; 111 122 } … … 114 125 destAddress = cast(uint)destSegmentAddress; 115 126 } 127 128 if(!containsAddress(cast(void*)destAddress)){ 129 debug debugLog("Module does not contain the destination address for fixup. [%0.8X]",destAddress); 130 debug debugLog("dump: %s",this.toString()); 131 assert(false); 132 } 133 //assert(containsAddress(cast(void*)destAddress),"Module does not contain the destination address for fixup."); 116 134 117 135 // get the fixup value … … 127 145 fixupValue = cast(uint)(segmentImages[targetSegmentIndex].data.ptr); 128 146 } 147 129 148 debug if(destSymbol){ 130 149 debugLog("fixup dest %s:%s [%0.8X] (%0.8X) = fixupValue [%0.8X] rel:%d",destSymbol.name,destSymbol.getTypeName(),destAddress,*cast(uint*)destAddress,fixupValue,cast(uint)isSegmentRelative); … … 185 204 } 186 205 } 187 206 188 207 //build up symbol table 189 208 //NOTE: extern indicies match their OMF counterparts … … 278 297 image.data[offset..offset+dataLength] = ledata.data; 279 298 } 280 281 282 //1st pass for COMDAT records 283 //build up the memory image of the referenced segments 299 300 // establish COMDAT temporary address information and segment data 284 301 foreach(idx,comdat; binary.communalData){ 285 SegmentImagePtr image = &(segmentImages[comdat.segmentIndex]); 302 // data to the segment 303 SegmentImagePtr image = &(segmentImages[comdat.segmentIndex]); 304 305 // set temporary address (offset into the segment image) 306 if(!comdat.isContinuation){ 307 symbolXref[binary.names[comdat.nameIndex]].type = SymbolType.Weak; 308 symbolXref[binary.names[comdat.nameIndex]].address = cast(void*)image.data.length; 309 } 310 286 311 image.data ~= comdat.data; 287 } 288 289 //2nd pass for COMDAT records 290 // establish extern addresses 291 void*[] currentAddress; 292 currentAddress.length = segmentImages.length; 293 294 //2nd pass for COMDAT records 312 } 313 314 // fix COMDAT addresses by adding the starting segment address 295 315 foreach(idx,comdat; binary.communalData){ 296 316 SegmentImagePtr image = &(segmentImages[comdat.segmentIndex]); 297 void** addr = &(currentAddress[comdat.segmentIndex]); 298 if(*addr == null){ 299 //TODO: change to orignal segment size 300 *addr = image.data.ptr + binary.segments[comdat.segmentIndex].dataLength; 301 } 302 303 // set temporary address 304 //NOTE: this is done to calculate the offset on this pass 317 ExportSymbolPtr symbol = symbolXref[binary.names[comdat.nameIndex]]; 318 305 319 if(!comdat.isContinuation){ 306 symbolXref[binary.names[comdat.nameIndex]].type = SymbolType.Strong; 307 symbolXref[binary.names[comdat.nameIndex]].address = *addr; 308 } 309 310 *addr += comdat.data.length; 311 } 320 symbol.address = cast(void*)(cast(uint)symbol.address + cast(uint)image.data.ptr); 321 } 322 } 312 323 313 324 // public symbols (done here so address offsets are valid)
