Changeset 58673 in vbox
- Timestamp:
- Nov 12, 2015 1:58:36 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp
r58655 r58673 356 356 return error(pszFile, "Relocation beyond the end of the file or overlapping the headers (section #%u)\n", i); 357 357 358 uint32_t const cbRawData = paShdrs[i].SizeOfRawData; 359 if ( paShdrs[i].PointerToRawData < cbHeaders 360 || paShdrs[i].PointerToRawData >= cbFile 361 || paShdrs[i].PointerToRawData + cbRawData > cbFile) 362 return error(pszFile, "Raw data beyond the end of the file or overlapping the headers (section #%u)\n", i); 363 uint8_t *pbRawData = &pbFile[paShdrs[i].PointerToRawData]; 364 358 365 /* 359 366 * Convert from AMD64 fixups to I386 ones, assuming 64-bit addresses … … 364 371 for (uint32_t j = 0; j < cRelocs; j++) 365 372 { 373 RTPTRUNION uLoc; 374 uLoc.pu8 = paRelocs[j].u.VirtualAddress < cbRawData ? &pbRawData[paRelocs[j].u.VirtualAddress] : NULL; 375 376 /* Print it. */ 366 377 if (g_cVerbose > 1) 367 printf("%#010x %#010x %s\n", 368 paRelocs[j].u.VirtualAddress, 369 paRelocs[j].SymbolTableIndex, 378 { 379 size_t off = printf("%#010x %#010x", paRelocs[j].u.VirtualAddress, paRelocs[j].SymbolTableIndex); 380 switch (paRelocs[j].Type) 381 { 382 case IMAGE_REL_AMD64_ADDR64: 383 if (uLoc.pu64) 384 off += printf(" %#018llx", *uLoc.pu64); 385 break; 386 case IMAGE_REL_AMD64_ADDR32: 387 case IMAGE_REL_AMD64_ADDR32NB: 388 case IMAGE_REL_AMD64_REL32: 389 case IMAGE_REL_AMD64_REL32_1: 390 case IMAGE_REL_AMD64_REL32_2: 391 case IMAGE_REL_AMD64_REL32_3: 392 case IMAGE_REL_AMD64_REL32_4: 393 case IMAGE_REL_AMD64_REL32_5: 394 case IMAGE_REL_AMD64_SECREL: 395 if (uLoc.pu32) 396 off += printf(" %#010x", *uLoc.pu32); 397 break; 398 case IMAGE_REL_AMD64_SECTION: 399 if (uLoc.pu16) 400 off += printf(" %#06x", *uLoc.pu16); 401 break; 402 case IMAGE_REL_AMD64_SECREL7: 403 if (uLoc.pu8) 404 off += printf(" %#04x", *uLoc.pu8); 405 break; 406 } 407 while (off < 36) 408 off += printf(" "); 409 printf(" %s\n", 370 410 paRelocs[j].Type < RT_ELEMENTS(g_apszCoffAmd64RelTypes) 371 411 ? g_apszCoffAmd64RelTypes[paRelocs[j].Type] : "unknown"); 412 } 413 414 /* Convert it. */ 372 415 switch (paRelocs[j].Type) 373 416 { 374 case IMAGE_REL_AMD64_ABSOLUTE:375 paRelocs[j].Type = IMAGE_REL_I386_ABSOLUTE; /* same */376 break;377 417 case IMAGE_REL_AMD64_ADDR64: 378 /** @todo check the high dword. */ 418 { 419 uint64_t uAddend = 0; 420 if (uLoc.pu64) 421 { 422 if (paRelocs[j].u.VirtualAddress + 8 > cbRawData) 423 return error(pszFile, "ADDR64 at %#x in section %u '%-8.8s' not fully in raw data\n", 424 paRelocs[j].u.VirtualAddress, i, paShdrs[i].Name); 425 uAddend = *uLoc.pu64; 426 } 427 if (uAddend > _1G) 428 return error(pszFile, "ADDR64 with large addend (%#llx) at %#x in section %u '%-8.8s'\n", 429 uAddend, paRelocs[j].u.VirtualAddress, i, paShdrs[i].Name); 379 430 paRelocs[j].Type = IMAGE_REL_I386_DIR32; 380 431 break; 432 } 433 434 case IMAGE_REL_AMD64_REL32_1: 435 case IMAGE_REL_AMD64_REL32_2: 436 case IMAGE_REL_AMD64_REL32_3: 437 case IMAGE_REL_AMD64_REL32_4: 438 case IMAGE_REL_AMD64_REL32_5: 439 { 440 if (paRelocs[j].u.VirtualAddress + 4 > cbRawData) 441 return error(pszFile, "%s at %#x in section %u '%-8.8s' is not (fully) in raw data\n", 442 g_apszCoffAmd64RelTypes[paRelocs[j].Type], paRelocs[j].u.VirtualAddress, i, 443 paShdrs[i].Name); 444 *uLoc.pu32 += paRelocs[j].Type - IMAGE_REL_AMD64_REL32; 445 paRelocs[j].Type = IMAGE_REL_I386_REL32; 446 break; 447 } 448 449 /* These are 1:1 conversions: */ 381 450 case IMAGE_REL_AMD64_ADDR32: 382 451 paRelocs[j].Type = IMAGE_REL_I386_DIR32; … … 389 458 break; 390 459 case IMAGE_REL_AMD64_SECTION: 391 /** @todo check the high dword. */392 460 paRelocs[j].Type = IMAGE_REL_I386_SECTION; 393 461 break; 394 462 case IMAGE_REL_AMD64_SECREL: 395 /** @todo check the high dword. */396 463 paRelocs[j].Type = IMAGE_REL_I386_SECREL; 397 464 break; 398 465 case IMAGE_REL_AMD64_SECREL7: 399 466 paRelocs[j].Type = IMAGE_REL_I386_SECREL7; 467 break; 468 case IMAGE_REL_AMD64_ABSOLUTE: /* no-op for alignment. */ 469 paRelocs[j].Type = IMAGE_REL_I386_ABSOLUTE; 400 470 break; 401 471
Note:
See TracChangeset
for help on using the changeset viewer.