Changeset 58808 in vbox
- Timestamp:
- Nov 20, 2015 11:00:58 PM (9 years ago)
- Location:
- trunk/src/VBox/ValidationKit/bootsectors/bs3kit
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk
r58806 r58808 160 160 # to rename intrinsic functions so they don't clash with the 16-bit compiler. 161 161 # 162 TOOL_Bs3Ow32 := Visual C++ 64-bit162 TOOL_Bs3Ow32 := OpenWatcom C/C++ 32-bit with object convertsion 163 163 TOOL_Bs3Ow32_CC = $(TOOL_OPENWATCOM_CC) 164 164 TOOL_Bs3Ow32_CXX = $(TOOL_OPENWATCOM_CXX) … … 177 177 define TOOL_Bs3Ow32_COMPILE_C_CMDS 178 178 $(TOOL_OPENWATCOM_COMPILE_C_CMDS) 179 $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) -vvv"$(obj)"179 $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" 180 180 endef 181 181 … … 194 194 define TOOL_Bs3Ow32_COMPILE_CXX_CMDS 195 195 $(TOOL_OPENWATCOM_COMPILE_CXX_CMDS) 196 $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" 196 $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" 197 endef 198 199 200 # 201 # 16-bit OpenWatcom C/C++ tool variant that runs the object converter afterwards 202 # to rename intrinsic functions so they don't clash with the 16-bit compiler. 203 # 204 TOOL_Bs3Ow16 := OpenWatcom C/C++ 16-bit with object convertsion 205 TOOL_Bs3Ow16_CC = $(TOOL_OPENWATCOM-16_CC) 206 TOOL_Bs3Ow16_CXX = $(TOOL_OPENWATCOM-16_CXX) 207 TOOL_Bs3Ow16_COBJSUFF = $(TOOL_OPENWATCOM-16_COBJSUFF) 208 TOOL_Bs3Ow16_CFLAGS = $(TOOL_OPENWATCOM-16_CFLAGS) 209 TOOL_Bs3Ow16_CFLAGS.debug = $(TOOL_OPENWATCOM-16_CFLAGS.debug) 210 TOOL_Bs3Ow16_CFLAGS.dbgopt = $(TOOL_OPENWATCOM-16_CFLAGS.dbgopt) 211 TOOL_Bs3Ow16_CFLAGS.profile = $(TOOL_OPENWATCOM-16_CFLAGS.profile) 212 TOOL_Bs3Ow16_CFLAGS.release = $(TOOL_OPENWATCOM-16_CFLAGS.release) 213 TOOL_Bs3Ow16_CINCS = $(TOOL_OPENWATCOM-16_CINCS) 214 TOOL_Bs3Ow16_CDEFS = 215 TOOL_Bs3Ow16_COMPILE_C_DEPEND = $(TOOL_OPENWATCOM-16_COMPILE_C_DEPEND) $(VBoxBs3ObjConverter_1_TARGET) 216 TOOL_Bs3Ow16_COMPILE_C_DEPORD = $(TOOL_OPENWATCOM-16_COMPILE_C_DEPORD) 217 TOOL_Bs3Ow16_COMPILE_C_OUTPUT = $(TOOL_OPENWATCOM-16_COMPILE_C_OUTPUT) 218 TOOL_Bs3Ow16_COMPILE_C_OUTPUT_MAYBE = $(TOOL_OPENWATCOM-16_COMPILE_C_OUTPUT_MAYBE) 219 define TOOL_Bs3Ow16_COMPILE_C_CMDS 220 $(TOOL_OPENWATCOM-16_COMPILE_C_CMDS) 221 $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" 222 endef 223 224 TOOL_Bs3Ow16_CXXOBJSUFF = $(TOOL_OPENWATCOM-16_CXXOBJSUFF) 225 TOOL_Bs3Ow16_CXXFLAGS = $(TOOL_OPENWATCOM-16_CXXFLAGS) 226 TOOL_Bs3Ow16_CXXFLAGS.debug = $(TOOL_OPENWATCOM-16_CXXFLAGS.debug) 227 TOOL_Bs3Ow16_CXXFLAGS.dbgopt = $(TOOL_OPENWATCOM-16_CXXFLAGS.dbgopt) 228 TOOL_Bs3Ow16_CXXFLAGS.profile = $(TOOL_OPENWATCOM-16_CXXFLAGS.profile) 229 TOOL_Bs3Ow16_CXXFLAGS.release = $(TOOL_OPENWATCOM-16_CXXFLAGS.release) 230 TOOL_Bs3Ow16_CXXINCS = $(TOOL_OPENWATCOM-16_CXXINCS) 231 TOOL_Bs3Ow16_CXXDEFS = 232 TOOL_Bs3Ow16_COMPILE_CXX_DEPEND = $(TOOL_OPENWATCOM-16_COMPILE_CXX_DEPEND) $(VBoxBs3ObjConverter_1_TARGET) 233 TOOL_Bs3Ow16_COMPILE_CXX_DEPORD = $(TOOL_OPENWATCOM-16_COMPILE_CXX_DEPORD) 234 TOOL_Bs3Ow16_COMPILE_CXX_OUTPUT = $(TOOL_OPENWATCOM-16_COMPILE_CXX_OUTPUT) 235 TOOL_Bs3Ow16_COMPILE_CXX_OUTPUT_MAYBE = $(TOOL_OPENWATCOM-16_COMPILE_CXX_OUTPUT_MAYBE) 236 define TOOL_Bs3Ow16_COMPILE_CXX_CMDS 237 $(TOOL_OPENWATCOM-16_COMPILE_CXX_CMDS) 238 $(QUIET)$(VBoxBs3ObjConverter_1_TARGET) "$(obj)" 197 239 endef 198 240 … … 250 292 TEMPLATE_VBoxBS3KitImg_DEFS = ARCH_BITS=16 IN_BS3KIT 251 293 TEMPLATE_VBoxBS3KitImg_ARTOOL = OPENWATCOM-16 252 TEMPLATE_VBoxBS3KitImg_CTOOL = OPENWATCOM-16253 TEMPLATE_VBoxBS3KitImg_CXXTOOL = OPENWATCOM-16294 TEMPLATE_VBoxBS3KitImg_CTOOL = Bs3Ow16 295 TEMPLATE_VBoxBS3KitImg_CXXTOOL = Bs3Ow16 254 296 TEMPLATE_VBoxBS3KitImg_CFLAGS = \ 255 297 -nt=BS3TEXT16 -nd=BS3DATA16 -nc=BS3CODE16 -ecw -q -3 -wx -zl -zu -mc $(BS3_OW_DBG_OPT) -d1 -s -oa -ob -of -oi -ol -or -os -
trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp
r58806 r58808 496 496 497 497 498 /** @name Selected OMF record types. 499 * @{ */ 498 500 #define PUBDEF UINT8_C(0x90) 501 #define LPUBDEF UINT8_C(0xb6) 499 502 #define THEADR UINT8_C(0x80) 500 #define EXTDEF UINT8_C(0x8 8)503 #define EXTDEF UINT8_C(0x8c) 501 504 #define SEGDEF UINT8_C(0x98) 502 505 #define LNAMES UINT8_C(0x96) 503 506 #define GRPDEF UINT8_C(0x9a) 504 507 #define REC32 UINT8_C(0x01) /**< Flag indicating 32-bit record. */ 508 /** @} */ 509 510 /** Watcom intrinsics we need to modify so we can mix 32-bit and 16-bit 511 * code, since the 16 and 32 bit compilers share several names. 512 * The names are length prefixed. 513 */ 514 static const char * const g_apszExtDefRenames[] = 515 { 516 "\x05" "__I4D", 517 "\x05" "__I4M", 518 "\x06" "__I8DQ", 519 "\x07" "__I8DQE", 520 "\x06" "__I8DR", 521 "\x07" "__I8DRE", 522 "\x06" "__I8LS", 523 "\x05" "__I8M", 524 "\x06" "__I8ME", 525 "\x06" "__I8RS", 526 "\x05" "__PIA", 527 "\x05" "__PIS", 528 "\x05" "__PTC", 529 "\x05" "__PTS", 530 "\x05" "__U4D", 531 "\x05" "__U4M", 532 "\x06" "__U8DQ", 533 "\x07" "__U8DQE", 534 "\x06" "__U8DR", 535 "\x07" "__U8DRE", 536 "\x06" "__U8LS", 537 "\x05" "__U8M", 538 "\x06" "__U8ME", 539 "\x06" "__U8RS", 540 }; 505 541 506 542 /** … … 513 549 * @param cbFile Size of the file content. 514 550 */ 515 static bool convertomf(const char *pszFile, uint8_t *pbFile, size_t cbFile) 516 { 517 const char **papchLNames = (const char **)calloc(sizeof(*papchLNames), _64K); 551 static bool convertomf(const char *pszFile, uint8_t *pbFile, size_t cbFile, const char **papchLNames, uint32_t cLNamesMax) 552 { 518 553 uint32_t cLNames = 0; 554 uint32_t cExtDefs = 0; 555 uint32_t cPubDefs = 0; 519 556 bool fProbably32bit = false; 520 uint32_t off ;557 uint32_t off = 0; 521 558 522 559 while (off + 3 < cbFile) … … 534 571 uint32_t offRec = 0; 535 572 uint8_t *pbRec = &pbFile[off + 3]; 573 #define OMF_CHECK_RET(a_cbReq, a_Name) /* Not taking the checksum into account, so we're good with 1 or 2 byte fields. */ \ 574 if (offRec + (a_cbReq) <= cbRec) {/*likely*/} \ 575 else return error(pszFile, "Malformed " #a_Name "! off=%#x offRec=%#x cbRec=%#x cbNeeded=%#x line=%d\n", \ 576 off, offRec, cbRec, (a_cbReq), __LINE__) 536 577 switch (bRecType) 537 578 { … … 541 582 case EXTDEF: 542 583 { 584 while (offRec + 1 < cbRec) 585 { 586 uint8_t cch = pbRec[offRec++]; 587 OMF_CHECK_RET(cch, EXTDEF); 588 char *pchName = (char *)&pbRec[offRec]; 589 offRec += cch; 590 591 OMF_CHECK_RET(2, EXTDEF); 592 uint16_t idxType = pbRec[offRec++]; 593 if (idxType & 0x80) 594 idxType = ((idxType & 0x7f) << 8) | pbRec[offRec++]; 595 596 if (g_cVerbose > 2) 597 printf(" EXTDEF [%u]: %-*.*s type=%#x\n", cExtDefs, cch, cch, pchName, idxType); 598 else if (g_cVerbose > 0) 599 printf(" U %-*.*s\n", cch, cch, pchName); 600 601 /* Look for g_apszExtDefRenames entries that requires changing. */ 602 if ( cch >= 5 603 && cch <= 7 604 && pchName[0] == '_' 605 && pchName[1] == '_' 606 && ( pchName[2] == 'U' 607 || pchName[2] == 'I' 608 || pchName[2] == 'P') 609 && ( pchName[3] == '4' 610 || pchName[3] == '8' 611 || pchName[3] == 'I' 612 || pchName[3] == 'T') ) 613 { 614 uint32_t i = RT_ELEMENTS(g_apszExtDefRenames); 615 while (i-- > 0) 616 if ( cch == (uint8_t)g_apszExtDefRenames[i][0] 617 && memcmp(&g_apszExtDefRenames[i][1], pchName, cch) == 0) 618 { 619 pchName[0] = fProbably32bit ? '3' : '1'; 620 pchName[1] = fProbably32bit ? '2' : '6'; 621 break; 622 } 623 } 624 625 cExtDefs++; 626 } 543 627 break; 544 628 } … … 551 635 while (offRec + 1 < cbRec) 552 636 { 553 uint8_t cch = *pbRec[offRec]; 554 if (offRec + 1 + cch >= cb) 555 { 556 } 637 uint8_t cch = pbRec[offRec]; 638 if (offRec + 1 + cch >= cbRec) 639 return error(pszFile, "Invalid LNAME string length at %#x+3+%#x: %#x (cbFile=%#lx)\n", 640 off, offRec, cch, (unsigned long)cbFile); 641 if (cLNames + 1 >= cLNamesMax) 642 return error(pszFile, "Too many LNAME strings\n"); 643 644 if (g_cVerbose > 2) 645 printf(" LNAME[%u]: %-*.*s\n", cLNames, cch, cch, &pbRec[offRec + 1]); 646 647 papchLNames[cLNames++] = (const char *)&pbRec[offRec]; 648 if (cch == 4 && memcmp(&pbRec[offRec + 1], "FLAT", 4) == 0) 649 fProbably32bit = true; 650 651 offRec += cch + 1; 557 652 } 558 653 break; … … 564 659 case PUBDEF: 565 660 case PUBDEF | REC32: 661 case LPUBDEF: 662 case LPUBDEF | REC32: 663 { 566 664 if (g_cVerbose > 0) 567 665 { 568 666 char const chType = bRecType == PUBDEF || bRecType == (PUBDEF | REC32) ? 'T' : 't'; 667 const char *pszRec = "LPUBDEF"; 668 if (chType == 'T') 669 pszRec++; 670 671 OMF_CHECK_RET(2, [L]PUBDEF); 672 uint16_t idxGrp = pbRec[offRec++]; 673 if (idxGrp & 0x80) 674 idxGrp = ((idxGrp & 0x7f) << 8) | pbRec[offRec++]; 675 676 OMF_CHECK_RET(2, [L]PUBDEF); 677 uint16_t idxSeg = pbRec[offRec++]; 678 if (idxSeg & 0x80) 679 idxSeg = ((idxSeg & 0x7f) << 8) | pbRec[offRec++]; 680 681 uint16_t uFrameBase = 0; 682 if (idxSeg == 0) 683 { 684 OMF_CHECK_RET(2, [L]PUBDEF); 685 uFrameBase = RT_MAKE_U16(pbRec[offRec], pbRec[offRec + 1]); 686 offRec += 2; 687 } 688 if (g_cVerbose > 2) 689 printf(" %s: idxGrp=%#x idxSeg=%#x uFrameBase=%#x\n", pszRec, idxGrp, idxSeg, uFrameBase); 690 uint16_t const uSeg = idxSeg ? idxSeg : uFrameBase; 691 692 while (offRec + 1 < cbRec) 693 { 694 uint8_t cch = pbRec[offRec++]; 695 OMF_CHECK_RET(cch, [L]PUBDEF); 696 const char *pchName = (const char *)&pbRec[offRec]; 697 offRec += cch; 698 699 uint32_t offSeg; 700 if (bRecType & REC32) 701 { 702 OMF_CHECK_RET(4, [L]PUBDEF); 703 offSeg = RT_MAKE_U32_FROM_U8(pbRec[offRec], pbRec[offRec + 1], pbRec[offRec + 2], pbRec[offRec + 3]); 704 offRec += 4; 705 } 706 else 707 { 708 OMF_CHECK_RET(2, [L]PUBDEF); 709 offSeg = RT_MAKE_U16(pbRec[offRec], pbRec[offRec + 1]); 710 offRec += 2; 711 } 712 713 OMF_CHECK_RET(2, [L]PUBDEF); 714 uint16_t idxType = pbRec[offRec++]; 715 if (idxType & 0x80) 716 idxType = ((idxType & 0x7f) << 8) | pbRec[offRec++]; 717 718 if (g_cVerbose > 2) 719 printf(" %s[%u]: off=%#010x type=%#x %-*.*s\n", pszRec, cPubDefs, offSeg, idxType, cch, cch, pchName); 720 else if (g_cVerbose > 0) 721 printf("%04x:%08x %c %-*.*s\n", uSeg, offSeg, chType, cch, cch, pchName); 722 723 cPubDefs++; 724 } 569 725 } 570 726 break; 727 } 571 728 } 572 729 … … 607 764 && pbFile[0] == THEADR 608 765 && RT_MAKE_U16(pbFile[1], pbFile[2]) < cbFile) 609 fRc = convertomf(pszFile, pbFile, cbFile); 766 { 767 const char **papchLNames = (const char **)calloc(sizeof(*papchLNames), _32K); 768 fRc = convertomf(pszFile, pbFile, cbFile, papchLNames, _32K); 769 free(papchLNames); 770 } 610 771 else 611 772 fprintf(stderr, "error: Don't recognize format of '%s' (%#x %#x %#x %#x, cbFile=%lu)\n",
Note:
See TracChangeset
for help on using the changeset viewer.