VirtualBox

Changeset 66446 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Apr 5, 2017 6:00:17 PM (8 years ago)
Author:
vboxsync
Message:

bs3kit: Various fixes related to using the BS3X0TEXT16, BS3X1TEXT16, and BS3RMTEXT16 segments. Ran into problems with switch jump tables lookups being off by 0x10 bytes (or 0x1c, at least it should've been) because the fixups were relative to BS3X0TEXT16 and not the BS3GROUPX0TEXT16 group, meaning that the eye-catcher in BS3X0TEXT16_START offsetted all addressing made by the compiler. Wanted to adjust the framing of the FIXUPP records to be relative to the the group instead of target, but gave up as it would've a couple of days. Not sure if removing the data from BS3X0TEXT16_START is problem free either, but for not it seems to work for bs3-cpu-generated-1.

Location:
trunk/src/VBox/ValidationKit/bootsectors
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/Config.kmk

    r64704 r66446  
    575575#       -oi                    Inline instrinsics functions.
    576576#       -ol                    Loop optimizations.
     577#       -oh                    Expensive optimizations. (saves a byte or two)
    577578#       -or                    Reorder for best pipeline.
    578579#       -os                    Favor size over speed.
     
    602603TEMPLATE_VBoxBS3KitImg_CXXTOOL      = Bs3Ow16
    603604TEMPLATE_VBoxBS3KitImg_CFLAGS       = $(if $(BS3KIT_SEGNM_DATA16),-nd=$(BS3KIT_SEGNM_DATA16),) \
    604         -nt=BS3TEXT16 -nc=$(BS3KIT_CLASS_CODE16) -ecc -q -0 -wx -zl -zdp -zu -ml $(BS3_OW_DBG_OPT) -s -oa -ob -of -oi -ol -or -os -d+
     605        -nt=BS3TEXT16 -nc=$(BS3KIT_CLASS_CODE16) -ecc -q -0 -wx -zl -zdp -zu -ml $(BS3_OW_DBG_OPT) -s -oa -ob -of -oi -ol -or -os -oh -d+
    605606TEMPLATE_VBoxBS3KitImg_CXXFLAGS     = $(if $(BS3KIT_SEGNM_DATA16),-nd=$(BS3KIT_SEGNM_DATA16),) \
    606         -nt=BS3TEXT16 -nc=$(BS3KIT_CLASS_CODE16) -ecc -q -0 -wx -zl -zdp -zu -ml $(BS3_OW_DBG_OPT) -s -oa -ob -of -oi -ol -or -os -d+
     607        -nt=BS3TEXT16 -nc=$(BS3KIT_CLASS_CODE16) -ecc -q -0 -wx -zl -zdp -zu -ml $(BS3_OW_DBG_OPT) -s -oa -ob -of -oi -ol -or -os -oh -d+
    607608TEMPLATE_VBoxBS3KitImg_CDEFS        = ARCH_BITS=16 RT_ARCH_X86
    608609
  • trunk/src/VBox/ValidationKit/bootsectors/Makefile.kmk

    r65971 r66446  
    323323        bs3-cpu-generated-1.c \
    324324        bs3-cpu-generated-1-asm.asm \
    325        bs3kit/bs3-cmn-instantiate.c16 \
     325       bs3kit/bs3-cmn-instantiate-x0.c16 \
    326326       bs3kit/bs3-cmn-instantiate.c32 \
    327327       bs3kit/bs3-cmn-instantiate.c64 \
     
    330330
    331331bs3-cpu-generated-1-template.o:: \
    332         $$(bs3-cpu-generated-1_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o16 \
     332        $$(bs3-cpu-generated-1_0_OUTDIR)/bs3kit/bs3-cmn-instantiate-x0.o16 \
    333333        $$(bs3-cpu-generated-1_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o32 \
    334334        $$(bs3-cpu-generated-1_0_OUTDIR)/bs3kit/bs3-cmn-instantiate.o64 \
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-generated-1-template.c

    r66422 r66446  
    10441044 * @param   enmXcptType         The type to check.
    10451045 */
    1046 static bool Bs3Cg1XcptTypeIsUnaligned(BS3CG1XCPTTYPE enmXcptType)
     1046static bool BS3_NEAR_CODE Bs3Cg1XcptTypeIsUnaligned(BS3CG1XCPTTYPE enmXcptType)
    10471047{
    10481048    switch (enmXcptType)
     
    10671067 * @param   uVexR       The VEX.R value (caller inverted it already).
    10681068 */
    1069 DECLINLINE(unsigned) Bs3Cg1InsertVex2bPrefix(PBS3CG1STATE pThis, unsigned offDst, uint8_t uVexV, uint8_t uVexL, uint8_t uVexR)
     1069DECLINLINE(unsigned) BS3_NEAR_CODE Bs3Cg1InsertVex2bPrefix(PBS3CG1STATE pThis, unsigned offDst,
     1070                                                           uint8_t uVexV, uint8_t uVexL, uint8_t uVexR)
    10701071{
    10711072    uint8_t b = uVexR << 7;
     
    11021103 * @param   uVexR       The VEX.W value (straight).
    11031104 */
    1104 DECLINLINE(unsigned) Bs3Cg1InsertVex3bPrefix(PBS3CG1STATE pThis, unsigned offDst, uint8_t uVexV, uint8_t uVexL,
    1105                                              uint8_t uVexR, uint8_t uVexX, uint8_t uVexB, uint8_t uVexW)
     1105DECLINLINE(unsigned) BS3_NEAR_CODE Bs3Cg1InsertVex3bPrefix(PBS3CG1STATE pThis, unsigned offDst, uint8_t uVexV, uint8_t uVexL,
     1106                                                           uint8_t uVexR, uint8_t uVexX, uint8_t uVexB, uint8_t uVexW)
    11061107{
    11071108    uint8_t b1;
     
    11211122        case BS3CG1PFXKIND_REQ_F2:          b2 |= 3; break;
    11221123        default:
    1123             Bs3TestFailedF("enmPrefixKind=%d not supported for VEX!\n");
     1124            Bs3TestFailedF("enmPrefixKind=%d not supported for VEX!\n", pThis->enmPrefixKind);
    11241125            break;
    11251126    }
     
    11321133
    11331134
    1134 DECLINLINE(unsigned) Bs3Cg1InsertReqPrefix(PBS3CG1STATE pThis, unsigned offDst)
     1135DECLINLINE(unsigned) BS3_NEAR_CODE Bs3Cg1InsertReqPrefix(PBS3CG1STATE pThis, unsigned offDst)
    11351136{
    11361137    switch (pThis->enmPrefixKind)
     
    11521153
    11531154
    1154 DECLINLINE(unsigned) Bs3Cg1InsertOpcodes(PBS3CG1STATE pThis, unsigned offDst)
     1155DECLINLINE(unsigned) BS3_NEAR_CODE Bs3Cg1InsertOpcodes(PBS3CG1STATE pThis, unsigned offDst)
    11551156{
    11561157    switch (pThis->cbOpcodes)
     
    11741175 * @param   pThis       The state.
    11751176 */
    1176 static void Bs3Cg1EncodeCleanup(PBS3CG1STATE pThis)
     1177static void BS3_NEAR_CODE Bs3Cg1EncodeCleanup(PBS3CG1STATE pThis)
    11771178{
    11781179    /* Restore the DS registers in the contexts. */
     
    11901191
    11911192
    1192 static unsigned Bs3Cfg1EncodeMemMod0Disp(PBS3CG1STATE pThis, bool fAddrOverride, unsigned off, uint8_t iReg,
    1193                                          uint8_t cbOp, uint8_t cbMissalign, BS3CG1OPLOC enmLocation)
     1193static unsigned BS3_NEAR_CODE Bs3Cfg1EncodeMemMod0Disp(PBS3CG1STATE pThis, bool fAddrOverride, unsigned off, uint8_t iReg,
     1194                                                       uint8_t cbOp, uint8_t cbMissalign, BS3CG1OPLOC enmLocation)
    11941195{
    11951196    pThis->aOperands[pThis->iRmOp].idxField     = BS3CG1DST_INVALID;
     
    12551256        case 0: break;
    12561257        default:
     1258        {
     1259            BS3CG1_DPRINTF(("Bs3MemSet(%p,%#x,%#x)\n", &pThis->pbDataPg[X86_PAGE_SIZE - cbOp - cbMissalign], 0xcc, cbOp - cbMissalign));
     1260            ASMHalt();
    12571261            Bs3MemSet(&pThis->pbDataPg[X86_PAGE_SIZE - cbOp - cbMissalign], 0xcc, cbOp - cbMissalign);
    12581262            break;
     1263        }
    12591264    }
    12601265
     
    12631268
    12641269
    1265 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Eb_Gb(PBS3CG1STATE pThis, unsigned iEncoding)
     1270static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Eb_Gb(PBS3CG1STATE pThis, unsigned iEncoding)
    12661271{
    12671272    unsigned off;
     
    12941299
    12951300
    1296 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Gb_Eb(PBS3CG1STATE pThis, unsigned iEncoding)
     1301static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Gb_Eb(PBS3CG1STATE pThis, unsigned iEncoding)
    12971302{
    12981303    unsigned off;
     
    13251330
    13261331
    1327 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Gv_Ev__OR__BS3CG1ENC_MODRM_Ev_Gv(PBS3CG1STATE pThis, unsigned iEncoding)
     1332static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Gv_Ev__OR__BS3CG1ENC_MODRM_Ev_Gv(PBS3CG1STATE pThis, unsigned iEncoding)
    13281333{
    13291334    unsigned off;
     
    14041409
    14051410
    1406 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Wss_Vss(PBS3CG1STATE pThis, unsigned iEncoding)
     1411static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Wss_Vss(PBS3CG1STATE pThis, unsigned iEncoding)
    14071412{
    14081413    unsigned off;
     
    14331438
    14341439
    1435 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Wsd_Vsd(PBS3CG1STATE pThis, unsigned iEncoding)
     1440static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Wsd_Vsd(PBS3CG1STATE pThis, unsigned iEncoding)
    14361441{
    14371442    unsigned off;
     
    14621467
    14631468
    1464 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Wps_Vps__OR__BS3CG1ENC_MODRM_Wpd_Vpd(PBS3CG1STATE pThis, unsigned iEncoding)
     1469static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Wps_Vps__OR__BS3CG1ENC_MODRM_Wpd_Vpd(PBS3CG1STATE pThis, unsigned iEncoding)
    14651470{
    14661471    unsigned off;
     
    14931498
    14941499
    1495 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_WqZxReg_Vq(PBS3CG1STATE pThis, unsigned iEncoding)
     1500static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_WqZxReg_Vq(PBS3CG1STATE pThis, unsigned iEncoding)
    14961501{
    14971502    unsigned off;
     
    15221527
    15231528
    1524 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Vq_UqHi(PBS3CG1STATE pThis, unsigned iEncoding)
     1529static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Vq_UqHi(PBS3CG1STATE pThis, unsigned iEncoding)
    15251530{
    15261531    unsigned off;
     
    15461551
    15471552
    1548 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Vq_Mq(PBS3CG1STATE pThis, unsigned iEncoding)
     1553static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Vq_Mq(PBS3CG1STATE pThis, unsigned iEncoding)
    15491554{
    15501555    unsigned off;
     
    15681573
    15691574
    1570 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Vdq_Wdq(PBS3CG1STATE pThis, unsigned iEncoding)
     1575static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Vdq_Wdq(PBS3CG1STATE pThis, unsigned iEncoding)
    15711576{
    15721577    unsigned off;
     
    15991604
    16001605
    1601 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Gv_Ma(PBS3CG1STATE pThis, unsigned iEncoding)
     1606static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_Gv_Ma(PBS3CG1STATE pThis, unsigned iEncoding)
    16021607{
    16031608    unsigned off;
     
    16421647
    16431648
    1644 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MbRO(PBS3CG1STATE pThis, unsigned iEncoding)
     1649static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MbRO(PBS3CG1STATE pThis, unsigned iEncoding)
    16451650{
    16461651    unsigned off;
     
    16591664
    16601665
    1661 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MdRO(PBS3CG1STATE pThis, unsigned iEncoding)
     1666static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MdRO(PBS3CG1STATE pThis, unsigned iEncoding)
    16621667{
    16631668    unsigned off;
     
    16761681
    16771682
    1678 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MdWO(PBS3CG1STATE pThis, unsigned iEncoding)
     1683static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MdWO(PBS3CG1STATE pThis, unsigned iEncoding)
    16791684{
    16801685    unsigned off;
     
    16931698
    16941699
    1695 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_VEX_MODRM_MdWO(PBS3CG1STATE pThis, unsigned iEncoding)
     1700static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_VEX_MODRM_MdWO(PBS3CG1STATE pThis, unsigned iEncoding)
    16961701{
    16971702    unsigned off;
     
    17931798
    17941799
    1795 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_FIXED(PBS3CG1STATE pThis, unsigned iEncoding)
     1800static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_FIXED(PBS3CG1STATE pThis, unsigned iEncoding)
    17961801{
    17971802    unsigned off;
     
    18081813
    18091814
    1810 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_FIXED_AL_Ib(PBS3CG1STATE pThis, unsigned iEncoding)
     1815static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_FIXED_AL_Ib(PBS3CG1STATE pThis, unsigned iEncoding)
    18111816{
    18121817    unsigned off;
     
    18241829
    18251830
    1826 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_FIXED_rAX_Iz(PBS3CG1STATE pThis, unsigned iEncoding)
     1831static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_FIXED_rAX_Iz(PBS3CG1STATE pThis, unsigned iEncoding)
    18271832{
    18281833    unsigned off;
     
    18891894
    18901895
    1891 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MOD_EQ_3(PBS3CG1STATE pThis, unsigned iEncoding)
     1896static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MOD_EQ_3(PBS3CG1STATE pThis, unsigned iEncoding)
    18921897{
    18931898    unsigned off;
     
    19121917
    19131918
    1914 static unsigned Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MOD_NE_3(PBS3CG1STATE pThis, unsigned iEncoding)
     1919static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext_BS3CG1ENC_MODRM_MOD_NE_3(PBS3CG1STATE pThis, unsigned iEncoding)
    19151920{
    19161921    unsigned off;
     
    19491954 *                          internal.
    19501955 */
    1951 static unsigned Bs3Cg1EncodeNext(PBS3CG1STATE pThis, unsigned iEncoding)
     1956static unsigned BS3_NEAR_CODE Bs3Cg1EncodeNext(PBS3CG1STATE pThis, unsigned iEncoding)
    19521957{
    19531958    pThis->bAlignmentXcpt = UINT8_MAX;
     
    20242029 * @param   pThis           The state.
    20252030 */
    2026 static bool Bs3Cg1EncodePrep(PBS3CG1STATE pThis)
     2031#define Bs3Cg1EncodePrep BS3_CMN_NM(Bs3Cg1EncodePrep)
     2032bool BS3_NEAR_CODE Bs3Cg1EncodePrep(PBS3CG1STATE pThis)
    20272033{
    20282034    unsigned iRing = 4;
     
    21892195
    21902196        default:
    2191             return Bs3TestFailedF("Invalid/unimplemented enmEncoding for instruction #%RU32 (%.*s): %d",
    2192                                   pThis->iInstr, pThis->cchMnemonic, pThis->pchMnemonic, pThis->enmEncoding);
     2197            ASMHalt();
     2198            Bs3TestFailedF("Invalid/unimplemented enmEncoding for instruction #%RU32 (%.*s): %d",
     2199                           pThis->iInstr, pThis->cchMnemonic, pThis->pchMnemonic, pThis->enmEncoding);
     2200            return false;
    21932201    }
    21942202    return true;
     
    22032211 * @param   pThis               The state.
    22042212 */
    2205 static bool Bs3Cg3SetupSseAndAvx(PBS3CG1STATE pThis)
     2213static bool BS3_NEAR_CODE Bs3Cg3SetupSseAndAvx(PBS3CG1STATE pThis)
    22062214{
    22072215    if (!pThis->fWorkExtCtx)
     
    22542262 *                          input to avoid unnecessary CPUID work.
    22552263 */
    2256 static bool Bs3Cg1CpuSetupNext(PBS3CG1STATE pThis, unsigned iCpuSetup, bool BS3_FAR *pfInvalidInstr)
     2264static bool BS3_NEAR_CODE Bs3Cg1CpuSetupNext(PBS3CG1STATE pThis, unsigned iCpuSetup, bool BS3_FAR *pfInvalidInstr)
    22572265{
    22582266    if (   (pThis->fFlags & BS3CG1INSTR_F_INVALID_64BIT)
     
    23012309 * @param   pThis               The state.
    23022310 */
    2303 static bool Bs3Cg1CpuSetupFirst(PBS3CG1STATE pThis)
     2311static bool BS3_NEAR_CODE Bs3Cg1CpuSetupFirst(PBS3CG1STATE pThis)
    23042312{
    23052313    uint32_t fEax;
     
    24202428 * @param   pHdr        The test header.
    24212429 */
    2422 static bool Bs3Cg1RunSelector(PBS3CG1STATE pThis, PCBS3CG1TESTHDR pHdr)
     2430static bool BS3_NEAR_CODE Bs3Cg1RunSelector(PBS3CG1STATE pThis, PCBS3CG1TESTHDR pHdr)
    24232431{
    24242432
     
    24742482 * @param   bOpcode             The context modifier program opcode.
    24752483 */
    2476 static const char BS3_FAR *Bs3Cg1CtxOpToString(uint8_t bOpcode)
     2484static const char BS3_FAR * BS3_NEAR_CODE Bs3Cg1CtxOpToString(uint8_t bOpcode)
    24772485{
    24782486    switch (bOpcode & BS3CG1_CTXOP_OPERATOR_MASK)
     
    25032511 *                      NULL for output contexts.
    25042512 */
    2505 static bool Bs3Cg1RunContextModifier(PBS3CG1STATE pThis, PBS3REGCTX pCtx, PCBS3CG1TESTHDR pHdr, unsigned off, unsigned cb,
    2506                                      PCBS3REGCTX pEflCtx, uint8_t BS3_FAR *pbInstr)
     2513static bool BS3_NEAR_CODE Bs3Cg1RunContextModifier(PBS3CG1STATE pThis, PBS3REGCTX pCtx, PCBS3CG1TESTHDR pHdr,
     2514                                                   unsigned off, unsigned cb,
     2515                                                   PCBS3REGCTX pEflCtx, uint8_t BS3_FAR *pbInstr)
    25072516{
    25082517    uint8_t const BS3_FAR *pbCode = (uint8_t const BS3_FAR *)(pHdr + 1) + off;
     
    28982907 * @param   iEncoding           For error reporting.
    28992908 */
    2900 static bool Bs3Cg1CheckResult(PBS3CG1STATE pThis, uint8_t bTestXcptExpected, unsigned iEncoding)
     2909static bool BS3_NEAR_CODE Bs3Cg1CheckResult(PBS3CG1STATE pThis, uint8_t bTestXcptExpected, unsigned iEncoding)
    29012910{
    29022911    unsigned iOperand;
     
    31533162 * @param   pThis               The state.
    31543163 */
    3155 static void Bs3Cg1Destroy(PBS3CG1STATE pThis)
     3164static void BS3_NEAR_CODE Bs3Cg1Destroy(PBS3CG1STATE pThis)
    31563165{
    31573166    if (BS3_MODE_IS_PAGED(pThis->bMode))
     
    31863195 * @param   bMode               The mode being tested.
    31873196 */
    3188 bool BS3_CMN_NM(Bs3Cg1Init)(PBS3CG1STATE pThis, uint8_t bMode)
     3197bool BS3_NEAR_CODE BS3_CMN_NM(Bs3Cg1Init)(PBS3CG1STATE pThis, uint8_t bMode)
    31893198{
    31903199    BS3MEMKIND const    enmMemKind = BS3_MODE_IS_RM_OR_V86(bMode) ? BS3MEMKIND_REAL
     
    32943303    }
    32953304#endif
     3305    BS3CG1_DPRINTF(("pbDataPg=%p %04x:%04x  pbCodePg=%p %04x:%04x\n",
     3306                    pThis->pbDataPg, pThis->DataPgFar.sel, pThis->DataPgFar.off,
     3307                    pThis->pbCodePg, pThis->CodePgFar.sel, pThis->CodePgFar.off));
    32963308
    32973309    /*
     
    34073419
    34083420
    3409 static uint8_t BS3_CMN_NM(Bs3Cg1WorkerInner)(PBS3CG1STATE pThis)
     3421static uint8_t BS3_NEAR_CODE BS3_CMN_NM(Bs3Cg1WorkerInner)(PBS3CG1STATE pThis)
    34103422{
    34113423    uint8_t  iRing;
     
    34453457        switch (pThis->cOperands)
    34463458        {
    3447             case 3: pThis->aenmOperands[3] = (BS3CG1OP)pThis->pabOperands[3];
    3448             case 2: pThis->aenmOperands[2] = (BS3CG1OP)pThis->pabOperands[2];
    3449             case 1: pThis->aenmOperands[1] = (BS3CG1OP)pThis->pabOperands[1];
    3450             case 0: pThis->aenmOperands[0] = (BS3CG1OP)pThis->pabOperands[0];
     3459            case 4: pThis->aenmOperands[3] = (BS3CG1OP)pThis->pabOperands[3];
     3460            case 3: pThis->aenmOperands[2] = (BS3CG1OP)pThis->pabOperands[2];
     3461            case 2: pThis->aenmOperands[1] = (BS3CG1OP)pThis->pabOperands[1];
     3462            case 1: pThis->aenmOperands[0] = (BS3CG1OP)pThis->pabOperands[0];
    34513463        }
    34523464
    34533465        switch (pThis->cbOpcodes)
    34543466        {
    3455             case 3: pThis->abOpcodes[3] = pThis->pabOpcodes[3];
    3456             case 2: pThis->abOpcodes[2] = pThis->pabOpcodes[2];
    3457             case 1: pThis->abOpcodes[1] = pThis->pabOpcodes[1];
    3458             case 0: pThis->abOpcodes[0] = pThis->pabOpcodes[0];
     3467            case 4: pThis->abOpcodes[3] = pThis->pabOpcodes[3];
     3468            case 3: pThis->abOpcodes[2] = pThis->pabOpcodes[2];
     3469            case 2: pThis->abOpcodes[1] = pThis->pabOpcodes[1];
     3470            case 1: pThis->abOpcodes[0] = pThis->pabOpcodes[0];
    34593471        }
    34603472
     
    35993611#if 0
    36003612    /* (for debugging) */
    3601     if (bMode < BS3_MODE_PE32)
     3613    if (bMode >= BS3_MODE_PE16)
    36023614        return BS3TESTDOMODE_SKIPPED;
    36033615#endif
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/Makefile.kmk

    r66334 r66446  
    239239$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,ASMMemFirstMismatchingU8,8)
    240240$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,ASMMemFirstNonZero,6)
     241$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,ASMCpuIdExSlow,32)
     242$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,ASMCpuId,20)
     243$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,ASMSetXcr0,8)
     244$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,ASMGetXcr0,0)
    241245-include $(PATH_SUB_CURRENT)/bs3kit-autostubs.kmk # manually generated from headers, see bottom of this file.
    242246
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/VBoxBs3ObjConverter.cpp

    r65928 r66446  
    7171/** Verbosity level. */
    7272static unsigned g_cVerbose = 0;
     73/** Indicates that it's output from the 16-bit watcom C or C++ compiler.
     74 * We will do some massaging for fixup records when this is used.  */
     75static bool     g_f16BitWatcomC = false;
    7376
    7477
     
    629632
    630633
    631 static bool omfWriter_SegDef(POMFWRITER pThis, uint8_t bSegAttr, uint32_t cbSeg, uint16_t idxSegName, uint16_t idxSegClass)
     634static bool omfWriter_SegDef(POMFWRITER pThis, uint8_t bSegAttr, uint32_t cbSeg, uint16_t idxSegName, uint16_t idxSegClass,
     635                             uint16_t idxOverlay = 1 /* NULL entry */)
    632636{
    633637    return omfWriter_RecBegin(pThis, OMF_SEGDEF32)
     
    636640        && omfWriter_RecAddIdx(pThis, idxSegName)
    637641        && omfWriter_RecAddIdx(pThis, idxSegClass)
    638         && omfWriter_RecAddIdx(pThis, 1) /* overlay name index = NULL entry */
     642        && omfWriter_RecAddIdx(pThis, idxOverlay)
     643        && omfWriter_RecEndWithCrc(pThis);
     644}
     645
     646static bool omfWriter_SegDef16(POMFWRITER pThis, uint8_t bSegAttr, uint32_t cbSeg, uint16_t idxSegName, uint16_t idxSegClass,
     647                               uint16_t idxOverlay = 1 /* NULL entry */)
     648{
     649    Assert(cbSeg <= UINT16_MAX);
     650    return omfWriter_RecBegin(pThis, OMF_SEGDEF16)
     651        && omfWriter_RecAddU8(pThis, bSegAttr)
     652        && omfWriter_RecAddU16(pThis, cbSeg)
     653        && omfWriter_RecAddIdx(pThis, idxSegName)
     654        && omfWriter_RecAddIdx(pThis, idxSegClass)
     655        && omfWriter_RecAddIdx(pThis, idxOverlay)
    639656        && omfWriter_RecEndWithCrc(pThis);
    640657}
     
    37013718    const char *pchOverlay;
    37023719    bool        fUse32;
     3720    bool        f32bitRec;
    37033721} OMFSEGDEF;
    37043722typedef OMFSEGDEF *POMFSEGDEF;
     
    37133731    uint8_t     cchName;
    37143732    uint16_t    cSegDefs;
    3715     uint16_t   *pidxSegDefs;
     3733    uint16_t   *paidxSegDefs;
    37163734} OMFGRPDEF;
    37173735typedef OMFGRPDEF *POMFGRPDEF;
     
    37623780
    37633781/**
     3782 * OMF details allocation that needs to be freed when done.
     3783 */
     3784typedef struct OMFDETAILSALLOC
     3785{
     3786    /** Pointer to the next allocation. */
     3787    struct OMFDETAILSALLOC *pNext;
     3788    /** The allocated bytes. */
     3789    uint8_t                 abData[RT_FLEXIBLE_ARRAY];
     3790} OMFDETAILSALLOC;
     3791typedef OMFDETAILSALLOC *POMFDETAILSALLOC;
     3792
     3793/**
    37643794 * OMF conversion details.
    37653795 *
     
    37683798typedef struct OMFDETAILS
    37693799{
     3800    /** The input file name. */
     3801    const char     *pszFile;
     3802
    37703803    /** Set if it has line numbers. */
    37713804    bool            fLineNumbers;
     
    38043837        /** The secondary class name. */
    38053838        const char *pszClass2;
     3839        /** The main segment name, NULL if not applicable (CGROUP16). */
     3840        const char *pszSeg;
    38063841        /** The name length. */
    38073842        uint8_t     cchName;
     
    38363871    /** Segment line numbers, indexed by segment number. */
    38373872    POMFSEGLINES    paSegLines;
     3873
     3874    /** List of allocations that needs freeing. */
     3875    POMFDETAILSALLOC    pAllocHead;
    38383876} OMFDETAILS;
    38393877typedef OMFDETAILS *POMFDETAILS;
     
    38723910    } while (0)
    38733911
     3912#define OMF_EXPLODE_LNAME(a_pOmfStuff, a_idxName, a_pchName, a_cchName, a_Name) \
     3913            do { \
     3914                if ((a_idxName) < (a_pOmfStuff)->cLNames) \
     3915                { \
     3916                    a_cchName = (uint8_t)*(a_pOmfStuff)->papchLNames[(a_idxName)]; \
     3917                    a_pchName = (a_pOmfStuff)->papchLNames[(a_idxName)] + 1; \
     3918                } \
     3919                else return error((a_pOmfStuff)->pszFile, "Invalid LNAME reference %#x in " #a_Name "!\n", a_idxName); \
     3920            } while (0)
     3921
     3922
     3923/**
     3924 * Allocates memory that will be freed when we're done converting.
     3925 *
     3926 * @returns Pointer tot he memory.
     3927 * @param   pOmfStuff   The OMF details data.
     3928 * @param   cbNeeded    The amount of memory required.
     3929 */
     3930static void *omfDetails_Alloc(POMFDETAILS pOmfStuff, size_t cbNeeded)
     3931{
     3932    POMFDETAILSALLOC pAlloc = (POMFDETAILSALLOC)malloc(RT_OFFSETOF(OMFDETAILSALLOC, abData[cbNeeded]));
     3933    if (pAlloc)
     3934    {
     3935        pAlloc->pNext = pOmfStuff->pAllocHead;
     3936        pOmfStuff->pAllocHead = pAlloc;
     3937        return &pAlloc->abData[0];
     3938    }
     3939    return NULL;
     3940}
    38743941
    38753942/**
     
    40744141
    40754142    memset(pOmfStuff, 0, sizeof(*pOmfStuff));
     4143    pOmfStuff->pszFile      = pszFile;
    40764144    pOmfStuff->iDebSymNm    = UINT16_MAX;
    40774145    pOmfStuff->iSymbolsNm   = UINT16_MAX;
     
    40904158
    40914159    /* Groups we seek. */
    4092 #define OMF_INIT_WANTED_GROUP(a_idx, a_szName, a_szClass1, a_szClass2, a_idxReplace) \
     4160#define OMF_INIT_WANTED_GROUP(a_idx, a_szName, a_szClass1, a_szClass2, a_pszSeg, a_idxReplace) \
    40934161        pOmfStuff->aGroups[a_idx].pszName   = a_szName; \
    40944162        pOmfStuff->aGroups[a_idx].cchName   = sizeof(a_szName) - 1; \
     
    40974165        pOmfStuff->aGroups[a_idx].pszClass2 = a_szClass2; \
    40984166        pOmfStuff->aGroups[a_idx].cchClass2 = sizeof(a_szClass2) - 1; \
     4167        pOmfStuff->aGroups[a_idx].pszSeg    = a_pszSeg; \
    40994168        pOmfStuff->aGroups[a_idx].fNeeded   = false; \
    41004169        pOmfStuff->aGroups[a_idx].idxGroup  = UINT16_MAX; \
    41014170        pOmfStuff->aGroups[a_idx].idxName   = UINT16_MAX; \
    41024171        pOmfStuff->aGroups[a_idx].idxReplaceGrp = a_idxReplace
    4103     OMF_INIT_WANTED_GROUP(0, "CGROUP16",         "BS3CLASS16CODE",   "CODE", OMF_REPLACE_GRP_CGROUP16);
    4104     OMF_INIT_WANTED_GROUP(1, "BS3GROUPRMTEXT16", "BS3CLASS16RMCODE", "",     OMF_REPLACE_GRP_RMCODE);
    4105     OMF_INIT_WANTED_GROUP(2, "BS3GROUPX0TEXT16", "BS3CLASS16X0CODE", "",     OMF_REPLACE_GRP_X0CODE);
    4106     OMF_INIT_WANTED_GROUP(3, "BS3GROUPX1TEXT16", "BS3CLASS16X1CODE", "",     OMF_REPLACE_GRP_X1CODE);
     4172    OMF_INIT_WANTED_GROUP(0, "CGROUP16",         "BS3CLASS16CODE",   "CODE", NULL,          OMF_REPLACE_GRP_CGROUP16);
     4173    OMF_INIT_WANTED_GROUP(1, "BS3GROUPRMTEXT16", "BS3CLASS16RMCODE", "",     "BS3RMTEXT16", OMF_REPLACE_GRP_RMCODE);
     4174    OMF_INIT_WANTED_GROUP(2, "BS3GROUPX0TEXT16", "BS3CLASS16X0CODE", "",     "BS3X0TEXT16", OMF_REPLACE_GRP_X0CODE);
     4175    OMF_INIT_WANTED_GROUP(3, "BS3GROUPX1TEXT16", "BS3CLASS16X1CODE", "",     "BS3X1TEXT16", OMF_REPLACE_GRP_X1CODE);
    41074176
    41084177    /*
     
    41434212                a_u32 = RT_MAKE_U32_FROM_U8(pbRec[offRec], pbRec[offRec + 1], pbRec[offRec + 2], pbRec[offRec + 3]); \
    41444213                offRec += 4; \
    4145             } while (0)
    4146 #define OMF_EXPLODE_LNAME(a_idxName, a_pchName, a_cchName, a_Name) \
    4147             do { \
    4148                 if ((a_idxName) < pOmfStuff->cLNames) \
    4149                 { \
    4150                     a_cchName = (uint8_t)*pOmfStuff->papchLNames[(a_idxName)]; \
    4151                     a_pchName = pOmfStuff->papchLNames[(a_idxName)] + 1; \
    4152                 } \
    4153                 else return error(pszFile, "Invalid LNAME reference %#x in " #a_Name "!\n", a_idxName); \
    41544214            } while (0)
    41554215
     
    43084368
    43094369                OMF_CHECK_RET(1 + (bRecType == OMF_SEGDEF16 ? 2 : 4) + 1 + 1 + 1, SEGDEF);
    4310                 pSegDef->bSegAttr = pbRec[offRec++];
    4311                 pSegDef->fUse32   = pSegDef->bSegAttr & 1;
     4370                pSegDef->f32bitRec  = bRecType == OMF_SEGDEF32;
     4371                pSegDef->bSegAttr   = pbRec[offRec++];
     4372                pSegDef->fUse32     = pSegDef->bSegAttr & 1;
    43124373                if ((pSegDef->bSegAttr >> 5) == 0)
    43134374                {
     
    43234384                OMF_READ_IDX(pSegDef->idxClass, SEGDEF);
    43244385                OMF_READ_IDX(pSegDef->idxOverlay, SEGDEF);
    4325                 OMF_EXPLODE_LNAME(pSegDef->idxName, pSegDef->pchName, pSegDef->cchName, SEGDEF);
    4326                 OMF_EXPLODE_LNAME(pSegDef->idxClass, pSegDef->pchClass, pSegDef->cchClass, SEGDEF);
    4327                 OMF_EXPLODE_LNAME(pSegDef->idxOverlay, pSegDef->pchOverlay, pSegDef->cchOverlay, SEGDEF);
     4386                OMF_EXPLODE_LNAME(pOmfStuff, pSegDef->idxName, pSegDef->pchName, pSegDef->cchName, SEGDEF);
     4387                OMF_EXPLODE_LNAME(pOmfStuff, pSegDef->idxClass, pSegDef->pchClass, pSegDef->cchClass, SEGDEF);
     4388                OMF_EXPLODE_LNAME(pOmfStuff, pSegDef->idxOverlay, pSegDef->pchOverlay, pSegDef->cchOverlay, SEGDEF);
    43284389                break;
    43294390            }
    43304391
    43314392            /*
    4332              * Must count segment definitions to figure the index of our segment.
     4393             * Must count segment definitions to figure the index of our group.
    43334394             */
    43344395            case OMF_GRPDEF:
     
    43384399
    43394400                OMF_READ_IDX(pGrpDef->idxName, GRPDEF);
    4340                 OMF_EXPLODE_LNAME(pGrpDef->idxName, pGrpDef->pchName, pGrpDef->cchName, GRPDEF);
     4401                OMF_EXPLODE_LNAME(pOmfStuff, pGrpDef->idxName, pGrpDef->pchName, pGrpDef->cchName, GRPDEF);
    43414402
    43424403                unsigned j = RT_ELEMENTS(pOmfStuff->aGroups);
     
    43494410
    43504411                pGrpDef->cSegDefs    = 0;
    4351                 pGrpDef->pidxSegDefs = NULL;
    4352                 while (offRec + 2 + 1 < cbRec)
     4412                pGrpDef->paidxSegDefs = NULL;
     4413                while (offRec + 2 + 1 <= cbRec)
    43534414                {
    43544415                    if (pbRec[offRec] != 0xff)
    43554416                        return error(pszFile, "Unsupported GRPDEF member type: %#x\n", pbRec[offRec]);
    43564417                    offRec++;
    4357                     OMF_GROW_TABLE_RET_ERR(uint16_t, pGrpDef->pidxSegDefs, pGrpDef->cSegDefs, 16);
    4358                     OMF_READ_IDX(pGrpDef->pidxSegDefs[pGrpDef->cSegDefs], GRPDEF);
     4418                    OMF_GROW_TABLE_RET_ERR(uint16_t, pGrpDef->paidxSegDefs, pGrpDef->cSegDefs, 16);
     4419                    OMF_READ_IDX(pGrpDef->paidxSegDefs[pGrpDef->cSegDefs], GRPDEF);
    43594420                    pGrpDef->cSegDefs++;
    43604421                }
     
    44454506
    44464507/**
    4447  * Writes the debug segment definitions (names too).
     4508 * Adds a LNAMES entry (returns existing).
    44484509 *
    44494510 * @returns success indicator.
    4450  * @param   pThis       The OMF writer.
     4511 * @param   pOmfStuff       The OMF stuff.
     4512 * @param   pszName         The name to add.
     4513 * @param   pidxName        Where to return the name index.
     4514 */
     4515static bool omfDetails_AddLName(POMFDETAILS pOmfStuff, const char *pszName, uint16_t *pidxName)
     4516{
     4517    size_t const cchName = strlen(pszName);
     4518
     4519    /*
     4520     * Check if we've already got the name.
     4521     */
     4522    for (unsigned iName = 1; iName < pOmfStuff->cLNames; iName++)
     4523        if (   pOmfStuff->papchLNames[iName][0] == cchName
     4524            && memcmp(pOmfStuff->papchLNames[iName] + 1, pszName, cchName) == 0)
     4525        {
     4526            *pidxName = iName;
     4527            return true;
     4528        }
     4529
     4530    /*
     4531     * Not found, append it.
     4532     */
     4533    char *pszCopy = (char *)omfDetails_Alloc(pOmfStuff, cchName + 2);
     4534    if (!pszCopy)
     4535        return false;
     4536    *(unsigned char *)&pszCopy[0] = (unsigned char)cchName;
     4537    memcpy(pszCopy + 1, pszName, cchName + 1);
     4538
     4539    OMF_GROW_TABLE_RET_ERR(char *, pOmfStuff->papchLNames, pOmfStuff->cLNames, 16);
     4540    pOmfStuff->papchLNames[pOmfStuff->cLNames] = (char *)pszCopy;
     4541    *pidxName = pOmfStuff->cLNames;
     4542    pOmfStuff->cLNames++;
     4543    return true;
     4544}
     4545
     4546
     4547/**
     4548 * Adds a SEGDEF (always adds a new one).
     4549 *
     4550 * @returns success indicator.
     4551 * @param   pOmfStuff   The OMF stuff.
     4552 * @param   bSegAttr    The OMF segment attributes.
     4553 * @param   cbSeg       The segment size.
     4554 * @param   idxSegName  The LNAMES index of the segment name.
     4555 * @param   idxSegClas  The LNAMES index of the segment class.
     4556 * @param   idxOverlay  The LNAMES index of the overlay name; pass 1.
     4557 * @param   fRec32      Set if SEGDEF32 should be emitted, clear for SEGDEF16.
     4558 * @param   pidxSeg     Where to return the segment index.
     4559 */
     4560static bool omfDetails_AddSegDef(POMFDETAILS pOmfStuff, uint8_t bSegAttr, uint32_t cbSeg, uint16_t idxSegName,
     4561                                 uint16_t idxSegClass, uint16_t idxOverlay, bool fRec32, uint16_t *pidxSeg)
     4562{
     4563    Assert(cbSeg <= UINT16_MAX || fRec32);
     4564    Assert(idxSegName < pOmfStuff->cLNames);
     4565    Assert(idxSegClass < pOmfStuff->cLNames);
     4566
     4567    OMF_GROW_TABLE_RET_ERR(OMFSEGDEF, pOmfStuff->paSegDefs, pOmfStuff->cSegDefs, 16);
     4568    POMFSEGDEF pSegDef = &pOmfStuff->paSegDefs[pOmfStuff->cSegDefs];
     4569
     4570    pSegDef->bSegAttr   = bSegAttr;
     4571    pSegDef->fUse32     = bSegAttr & 1;
     4572    pSegDef->f32bitRec  = fRec32;
     4573    pSegDef->cbSeg      = cbSeg;
     4574    pSegDef->idxName    = idxSegName;
     4575    pSegDef->idxClass   = idxSegClass;
     4576    pSegDef->idxOverlay = idxOverlay;
     4577
     4578    OMF_EXPLODE_LNAME(pOmfStuff, pSegDef->idxName, pSegDef->pchName, pSegDef->cchName, SEGDEF);
     4579    OMF_EXPLODE_LNAME(pOmfStuff, pSegDef->idxClass, pSegDef->pchClass, pSegDef->cchClass, SEGDEF);
     4580    OMF_EXPLODE_LNAME(pOmfStuff, pSegDef->idxOverlay, pSegDef->pchOverlay, pSegDef->cchOverlay, SEGDEF);
     4581
     4582    *pidxSeg = pOmfStuff->cSegDefs;
     4583    pOmfStuff->cSegDefs++;
     4584    return true;
     4585}
     4586
     4587
     4588/**
     4589 * Adds a SEGDEF if not found.
     4590 *
     4591 * @returns success indicator.
     4592 * @param   pOmfStuff   The OMF stuff.
     4593 * @param   bSegAttr    The OMF segment attributes.
     4594 * @param   cbSeg       The segment size.
     4595 * @param   idxSegName  The LNAMES index of the segment name.
     4596 * @param   idxSegClas  The LNAMES index of the segment class.
     4597 * @param   idxOverlay  The LNAMES index of the overlay name; pass 1.
     4598 * @param   fRec32      Set if SEGDEF32 should be emitted, clear for SEGDEF16.
     4599 * @param   pidxSeg     Where to return the segment index.
     4600 */
     4601static bool omfDetails_AddSegDefIfNeeded(POMFDETAILS pOmfStuff, uint8_t bSegAttr, uint32_t cbSeg, uint16_t idxSegName,
     4602                                         uint16_t idxSegClass, uint16_t idxOverlay, bool fRec32, uint16_t *pidxSeg)
     4603{
     4604    /* Search for name */
     4605    for (unsigned iSegDef = 1; iSegDef < pOmfStuff->cSegDefs; iSegDef++)
     4606    {
     4607        POMFSEGDEF pSegDef = &pOmfStuff->paSegDefs[iSegDef];
     4608        if (pSegDef->idxName == idxSegName)
     4609        {
     4610            if (   pSegDef->bSegAttr   != bSegAttr
     4611                || pSegDef->f32bitRec  != fRec32
     4612                || pSegDef->idxName    != idxSegName
     4613                || pSegDef->idxClass   != idxSegClass
     4614                || pSegDef->idxOverlay != idxOverlay)
     4615                return error(pOmfStuff->pszFile,
     4616                             "Existing SEGDEF differs: bSegAttr=%#x vs %#x, f32bitRec=%d vs %d, idxName=%#x vs %#x, idxClass=%#x vs %#x, idxOverlay=%#x vs %#x\n",
     4617                             pSegDef->bSegAttr,   bSegAttr,
     4618                             pSegDef->f32bitRec,  fRec32,
     4619                             pSegDef->idxName,    idxSegName,
     4620                             pSegDef->idxClass,   idxSegClass,
     4621                             pSegDef->idxOverlay, idxOverlay);
     4622            *pidxSeg = iSegDef;
     4623            return true;
     4624        }
     4625    }
     4626    return omfDetails_AddSegDef(pOmfStuff, bSegAttr, cbSeg, idxSegName, idxSegClass, idxOverlay, fRec32, pidxSeg);
     4627}
     4628
     4629
     4630/**
     4631 * Looks up a GRPDEF in the .
     4632 *
     4633 * @returns Index (0..32K) if found, UINT16_MAX if not found.
     4634 * @param   pOmfStuff   The OMF stuff.
     4635 * @param   pchName     The name to look up.
     4636 * @param   cchName     The length of the name.
     4637 */
     4638static uint16_t omfDetails_GrpDefLookupN(POMFDETAILS pOmfStuff, const char *pchName, size_t cchName)
     4639{
     4640    unsigned iGrpDef = pOmfStuff->cGrpDefs;
     4641    while (iGrpDef-- > 0)
     4642    {
     4643        if (   pOmfStuff->paGrpDefs[iGrpDef].cchName == cchName
     4644            && memcmp(pOmfStuff->paGrpDefs[iGrpDef].pchName, pchName, cchName) == 0)
     4645            return iGrpDef;
     4646    }
     4647    return UINT16_MAX;
     4648}
     4649
     4650
     4651/**
     4652 * Adds an empty GRPDEF (always adds a new one).
     4653 *
     4654 * @returns success indicator.
     4655 * @param   pOmfStuff   The OMF stuff.
     4656 * @param   idxGrpName  The LNAMES index of the group name.
     4657 * @param   pidxGrp     Where to return the group index.
     4658 */
     4659static bool omfDetails_AddGrpDef(POMFDETAILS pOmfStuff, uint16_t idxGrpName, uint16_t *pidxGrp)
     4660{
     4661    Assert(idxGrpName < pOmfStuff->cLNames);
     4662
     4663    OMF_GROW_TABLE_RET_ERR(OMFGRPDEF, pOmfStuff->paGrpDefs, pOmfStuff->cGrpDefs, 8);
     4664    POMFGRPDEF pGrpDef = &pOmfStuff->paGrpDefs[pOmfStuff->cGrpDefs];
     4665
     4666    pGrpDef->idxName      = idxGrpName;
     4667    pGrpDef->cSegDefs     = 0;
     4668    pGrpDef->paidxSegDefs = NULL;
     4669
     4670    *pidxGrp = pOmfStuff->cGrpDefs;
     4671    pOmfStuff->cGrpDefs++;
     4672    return true;
     4673}
     4674
     4675
     4676/**
     4677 * Adds a segment to an existing GRPDEF.
     4678 *
     4679 * @returns success indicator.
     4680 * @param   pOmfStuff   The OMF stuff.
     4681 * @param   idxGrp      The GRPDEF index of the group to append a member to.
     4682 * @param   idxSeg      The SEGDEF index of the segment name.
     4683 */
     4684static bool omfDetails_AddSegToGrpDef(POMFDETAILS pOmfStuff, uint16_t idxGrp, uint16_t idxSeg)
     4685{
     4686    Assert(idxGrp < pOmfStuff->cGrpDefs && idxGrp > 0);
     4687    Assert(idxSeg < pOmfStuff->cSegDefs && idxSeg > 0);
     4688
     4689    POMFGRPDEF pGrpDef = &pOmfStuff->paGrpDefs[idxGrp];
     4690    OMF_GROW_TABLE_RET_ERR(uint16_t, pGrpDef->paidxSegDefs, pGrpDef->cSegDefs, 16);
     4691    pGrpDef->paidxSegDefs[pGrpDef->cSegDefs] = idxSeg;
     4692    pGrpDef->cSegDefs++;
     4693
     4694    return true;
     4695}
     4696
     4697
     4698/**
     4699 * Marks 16-bit code segment groups that is used in the object file as needed.
     4700 *
     4701 * @param   pOmfStuff   The OMF stuff.
     4702 */
     4703static void convertOmfLookForNeededGroups(POMFDETAILS pOmfStuff)
     4704{
     4705    /*
     4706     * Consult the groups in question.  We mark the groups which segments are
     4707     * included in the segment definitions as needed.
     4708     */
     4709    unsigned i = RT_ELEMENTS(pOmfStuff->aGroups);
     4710    while (i-- > 0)
     4711        if (pOmfStuff->aGroups[i].pszSeg)
     4712        {
     4713            const char * const  pszSegNm = pOmfStuff->aGroups[i].pszSeg;
     4714            size_t const        cchSegNm = strlen(pszSegNm);
     4715            for (unsigned iSegDef = 0; iSegDef < pOmfStuff->cSegDefs; iSegDef++)
     4716                if (   pOmfStuff->paSegDefs[iSegDef].cchName == cchSegNm
     4717                    && memcmp(pOmfStuff->paSegDefs[iSegDef].pchName, pszSegNm, cchSegNm) == 0)
     4718                {
     4719                    pOmfStuff->aGroups[i].fNeeded = true;
     4720                    break;
     4721                }
     4722        }
     4723}
     4724
     4725
     4726/**
     4727 * Adds necessary group and segment definitions.
     4728 *
     4729 * @returns success indicator.
     4730 * @param   pOmfStuff   The OMF stuff.
     4731 */
     4732static bool convertOmfAddNeededGrpDefs(POMFDETAILS pOmfStuff)
     4733{
     4734    /*
     4735     * Process the groups.
     4736     */
     4737    unsigned j = RT_ELEMENTS(pOmfStuff->aGroups);
     4738    while (j-- > 0)
     4739        if (pOmfStuff->aGroups[j].fNeeded)
     4740        {
     4741            if (pOmfStuff->aGroups[j].idxName == UINT16_MAX)
     4742            {
     4743                Assert(pOmfStuff->aGroups[j].idxGroup == UINT16_MAX);
     4744                if (!omfDetails_AddLName(pOmfStuff, pOmfStuff->aGroups[j].pszName, &pOmfStuff->aGroups[j].idxName))
     4745                    return false;
     4746            }
     4747            if (pOmfStuff->aGroups[j].idxGroup == UINT16_MAX)
     4748            {
     4749                if (!omfDetails_AddGrpDef(pOmfStuff, pOmfStuff->aGroups[j].idxName, &pOmfStuff->aGroups[j].idxGroup))
     4750                    return false;
     4751
     4752                if (pOmfStuff->aGroups[j].pszSeg)
     4753                {
     4754                    /* We need the segment class name. */
     4755                    uint16_t idxSegClass;
     4756                    if (!omfDetails_AddLName(pOmfStuff, pOmfStuff->aGroups[j].pszClass1, &idxSegClass))
     4757                        return false;
     4758
     4759                    /* Prep segment name buffer. */
     4760                    size_t   cchSegNm = strlen(pOmfStuff->aGroups[j].pszSeg);
     4761                    char     szSegNm[256+16];
     4762                    Assert(cchSegNm < 256);
     4763                    memcpy(szSegNm, pOmfStuff->aGroups[j].pszSeg, cchSegNm);
     4764
     4765                    /* Add the three segments. */
     4766                    static RTSTRTUPLE const s_aSuffixes[3] = { RT_STR_TUPLE("_START"), RT_STR_TUPLE(""), RT_STR_TUPLE("_END"), };
     4767                    for (unsigned iSuffix = 0; iSuffix < RT_ELEMENTS(s_aSuffixes); iSuffix++)
     4768                    {
     4769                        uint16_t idxSegNm;
     4770                        memcpy(&szSegNm[cchSegNm], s_aSuffixes[iSuffix].psz, s_aSuffixes[iSuffix].cch + 1);
     4771                        if (!omfDetails_AddLName(pOmfStuff, szSegNm, &idxSegNm))
     4772                            return false;
     4773                        uint8_t  const  fAlign = iSuffix == 1 ? OMF_SEG_ATTR_ALIGN_BYTE : OMF_SEG_ATTR_ALIGN_PARA;
     4774                        uint16_t        idxSeg;
     4775                        if (!omfDetails_AddSegDefIfNeeded(pOmfStuff, fAlign | OMF_SEG_ATTR_COMB_PUBLIC | OMF_SEG_ATTR_USE16,
     4776                                                          0, idxSegNm, idxSegClass, 1, false /*fRec*/, &idxSeg))
     4777                            return false;
     4778                        if (!omfDetails_AddSegToGrpDef(pOmfStuff, pOmfStuff->aGroups[j].idxGroup, idxSeg))
     4779                            return false;
     4780                    }
     4781                }
     4782            }
     4783        }
     4784
     4785    /*
     4786     * Replace group references in the segment lines table.
     4787     */
     4788    j = RT_ELEMENTS(pOmfStuff->aGroups);
     4789    while (j-- > 0)
     4790        if (pOmfStuff->aGroups[j].fNeeded)
     4791            for (unsigned i = 0; i < pOmfStuff->cSegLines; i++)
     4792                if (pOmfStuff->paSegLines[i].idxGrp == pOmfStuff->aGroups[j].idxReplaceGrp)
     4793                    pOmfStuff->paSegLines[i].idxGrp = pOmfStuff->aGroups[j].idxGroup;
     4794    return true;
     4795}
     4796
     4797
     4798/**
     4799 * Adds the debug segment definitions (names too) to the OMF state.
     4800 *
     4801 * @returns success indicator.
    44514802 * @param   pOmfStuff   The OMF stuff with CV8 line number info.
    44524803 */
    4453 static bool convertOmfWriteDebugSegDefs(POMFWRITER pThis, POMFDETAILS pOmfStuff)
     4804static bool convertOmfAddDebugSegDefs(POMFDETAILS pOmfStuff)
    44544805{
    44554806    if (   pOmfStuff->cSegLines == 0
     
    44584809
    44594810    /*
    4460      * Emit the LNAMES we need.
    4461      */
    4462 #if 1
     4811     * Add the names we need.
     4812     */
    44634813    if (   pOmfStuff->iSymbolsNm == UINT16_MAX
    4464         || pOmfStuff->iDebSymNm == UINT16_MAX)
    4465     {
    4466         if (   !omfWriter_LNamesBegin(pThis, true /*fAddZeroEntry*/)
    4467             || (   pOmfStuff->iSymbolsNm == UINT16_MAX
    4468                 && !omfWriter_LNamesAdd(pThis, "$$SYMBOLS", &pOmfStuff->iSymbolsNm))
    4469             || (   pOmfStuff->iDebSymNm == UINT16_MAX
    4470                 && !omfWriter_LNamesAdd(pThis, "DEBSYM", &pOmfStuff->iDebSymNm))
    4471             || !omfWriter_LNamesEnd(pThis) )
    4472             return false;
    4473     }
    4474 #else
    4475     if (   !omfWriter_LNamesBegin(pThis, true /*fAddZeroEntry*/)
    4476         || !omfWriter_LNamesAdd(pThis, "$$SYMBOLS2", &pOmfStuff->iSymbolsNm)
    4477         || !omfWriter_LNamesAdd(pThis, "DEBSYM2", &pOmfStuff->iDebSymNm)
    4478         || !omfWriter_LNamesEnd(pThis) )
     4814        && !omfDetails_AddLName(pOmfStuff, "$$SYMBOLS", &pOmfStuff->iSymbolsNm))
    44794815        return false;
    4480 #endif
    4481 
    4482     /*
    4483      * Emit the segment definitions.
    4484      */
    4485     pOmfStuff->iSymbolsSeg = pOmfStuff->cSegDefs++;
    4486 
     4816    if (   pOmfStuff->iDebSymNm == UINT16_MAX
     4817        && !omfDetails_AddLName(pOmfStuff, "DEBSYM", &pOmfStuff->iDebSymNm))
     4818        return false;
     4819
     4820    /*
     4821     * Add the segment definition.
     4822     */
    44874823    uint8_t   bSegAttr = 0;
    44884824    bSegAttr |= 5 << 5; /* A: dword alignment */
     
    44994835        if (pOmfStuff->paSegLines[i].cFiles > 0)
    45004836            cbSeg += 4 + 4 + pOmfStuff->paSegLines[i].cb;
    4501     return omfWriter_SegDef(pThis, bSegAttr, cbSeg, pOmfStuff->iSymbolsNm, pOmfStuff->iDebSymNm);
    4502 }
    4503 
    4504 
    4505 /**
    4506  * Writes additional segment group definitions.
    4507  *
    4508  * @returns success indicator.
    4509  * @param   pThis       The OMF writer.
    4510  * @param   pOmfStuff   The OMF stuff with CV8 line number info.
    4511  */
    4512 static bool convertOmfWriteDebugGrpDefs(POMFWRITER pThis, POMFDETAILS pOmfStuff)
    4513 {
    4514     if (pOmfStuff->cSegLines == 0)
    4515         return true;
    4516 
    4517     /*
    4518      * See what (if anything) we need.
    4519      */
    4520     uint8_t cNames  = 0;
    4521     uint8_t cGroups = 0;
    4522     unsigned j = RT_ELEMENTS(pOmfStuff->aGroups);
    4523     while (j-- > 0)
    4524         if (pOmfStuff->aGroups[j].fNeeded)
    4525         {
    4526             cNames  += pOmfStuff->aGroups[j].idxName  == UINT16_MAX;
    4527             cGroups += pOmfStuff->aGroups[j].idxGroup == UINT16_MAX;
    4528         }
    4529 
    4530     /*
    4531      * Add any names we need.
    4532      */
    4533     if (cNames)
    4534     {
    4535         if (!omfWriter_LNamesBegin(pThis, true))
    4536             return false;
    4537         j = RT_ELEMENTS(pOmfStuff->aGroups);
    4538         while (j-- > 0)
    4539             if (   pOmfStuff->aGroups[j].fNeeded
    4540                 && pOmfStuff->aGroups[j].idxName == UINT16_MAX)
    4541                 if (!omfWriter_LNamesAdd(pThis, pOmfStuff->aGroups[j].pszName, &pOmfStuff->aGroups[j].idxName))
    4542                     return false;
    4543         if (!omfWriter_LNamesEnd(pThis))
    4544             return false;
    4545     }
    4546 
    4547     /*
    4548      * Add any groups we need.
    4549      */
    4550     if (cNames)
    4551     {
    4552         uint16_t iGrp = pOmfStuff->cGrpDefs; /* Shouldn't update cGrpDefs as it governs paGrpDefs. */
    4553         j = RT_ELEMENTS(pOmfStuff->aGroups);
    4554         while (j-- > 0)
    4555         {
    4556             if (   pOmfStuff->aGroups[j].fNeeded
    4557                 && pOmfStuff->aGroups[j].idxGroup == UINT16_MAX)
    4558             {
    4559                 if (   !omfWriter_GrpDefBegin(pThis, pOmfStuff->aGroups[j].idxName)
    4560                     || !omfWriter_GrpDefEnd(pThis))
    4561                     return false;
    4562                 pOmfStuff->aGroups[j].idxGroup = iGrp++;
    4563             }
    4564         }
    4565     }
    4566 
    4567     /*
    4568      * Replace group references in the segment lines table.
    4569      */
    4570     j = RT_ELEMENTS(pOmfStuff->aGroups);
    4571     while (j-- > 0)
    4572         if (pOmfStuff->aGroups[j].fNeeded)
    4573             for (unsigned i = 0; i < pOmfStuff->cSegLines; i++)
    4574                 if (pOmfStuff->paSegLines[i].idxGrp == pOmfStuff->aGroups[j].idxReplaceGrp)
    4575                     pOmfStuff->paSegLines[i].idxGrp = pOmfStuff->aGroups[j].idxGroup;
    4576     return true;
     4837    return omfDetails_AddSegDef(pOmfStuff, bSegAttr, cbSeg, pOmfStuff->iSymbolsNm, pOmfStuff->iDebSymNm, 1 /*idxOverlay*/,
     4838                                true /*fRec32*/, &pOmfStuff->iSymbolsSeg);
    45774839}
    45784840
     
    45894851    if (pOmfStuff->cSegLines == 0)
    45904852        return true;
     4853    Assert(pOmfStuff->iSymbolsSeg != UINT16_MAX);
    45914854
    45924855    /* Begin and write the CV version signature. */
     
    46804943
    46814944    return omfWriter_LEDataEnd(pThis);
     4945}
     4946
     4947
     4948/**
     4949 * Writes out all the segment group definitions.
     4950 *
     4951 * @returns success indicator.
     4952 * @param   pThis           The OMF writer.
     4953 * @param   pOmfStuff       The OMF stuff containing the segment defs.
     4954 * @param   pfFlushState    Pointer to the flush state variable.
     4955 */
     4956static bool convertOmfWriteAllSegDefs(POMFWRITER pThis, POMFDETAILS pOmfStuff, int *pfFlushState)
     4957{
     4958    if (*pfFlushState > 0)
     4959    {
     4960        for (unsigned iSegDef = 1; iSegDef < pOmfStuff->cSegDefs; iSegDef++)
     4961        {
     4962            if (!(pOmfStuff->paSegDefs[iSegDef].f32bitRec
     4963                  ? omfWriter_SegDef : omfWriter_SegDef16)(pThis, pOmfStuff->paSegDefs[iSegDef].bSegAttr,
     4964                                                           pOmfStuff->paSegDefs[iSegDef].cbSeg,
     4965                                                           pOmfStuff->paSegDefs[iSegDef].idxName,
     4966                                                           pOmfStuff->paSegDefs[iSegDef].idxClass,
     4967                                                           pOmfStuff->paSegDefs[iSegDef].idxOverlay))
     4968                    return false;
     4969        }
     4970        *pfFlushState = -1;
     4971    }
     4972    return true;
     4973}
     4974
     4975
     4976/**
     4977 * Writes out all the segment group definitions.
     4978 *
     4979 * @returns success indicator.
     4980 * @param   pThis       The OMF writer.
     4981 * @param   pOmfStuff   The OMF stuff containing the group defs.
     4982 * @param   pfFlushState    Pointer to the flush state variable.
     4983 */
     4984static bool convertOmfWriteAllGrpDefs(POMFWRITER pThis, POMFDETAILS pOmfStuff, int *pfFlushState)
     4985{
     4986    if (*pfFlushState > 0)
     4987    {
     4988        for (unsigned iGrpDef = 1; iGrpDef < pOmfStuff->cGrpDefs; iGrpDef++)
     4989        {
     4990            if (!omfWriter_GrpDefBegin(pThis, pOmfStuff->paGrpDefs[iGrpDef].idxName))
     4991                return false;
     4992            for (unsigned iSegDef = 0; iSegDef < pOmfStuff->paGrpDefs[iGrpDef].cSegDefs; iSegDef++)
     4993                if (!omfWriter_GrpDefAddSegDef(pThis, pOmfStuff->paGrpDefs[iGrpDef].paidxSegDefs[iSegDef]))
     4994                    return false;
     4995            if (!omfWriter_GrpDefEnd(pThis))
     4996                return false;
     4997        }
     4998        *pfFlushState = -1;
     4999    }
     5000    return true;
    46825001}
    46835002
     
    46955014 * @param   pOmfStuff   The OMF stuff we've gathered during the first pass,
    46965015 *                      contains CV8 line number info if we converted anything.
    4697  */
    4698 static bool convertOmfPassthru(POMFWRITER pThis, uint8_t const *pbFile, size_t cbFile, POMFDETAILS pOmfStuff)
    4699 {
    4700     bool const  fConvertLineNumbers = true;
    4701     bool        fSeenTheAdr         = false;
     5016 * @param   fConvertLineNumbers     Whether we're converting line numbers and stuff.
     5017 */
     5018static bool convertOmfPassthru(POMFWRITER pThis, uint8_t const *pbFile, size_t cbFile, POMFDETAILS pOmfStuff,
     5019                               bool fConvertLineNumbers)
     5020{
     5021    int         fFlushLNames   = 1;
     5022    int         fFlushSegDefs  = 1;
     5023    int         fFlushGrpDefs  = 1;
     5024    bool        fSeenTheAdr    = false;
     5025    bool        fConvertFixupp = false;
     5026
    47025027    uint32_t    off = 0;
    47035028    while (off + 3 < cbFile)
     
    47135038                if ((a_idx) & 0x80) \
    47145039                    a_idx = (((a_idx) & 0x7f) << 8) | pbRec[offRec++]; \
     5040            } while (0)
     5041
     5042#define OMF_PEEK_IDX(a_idx, a_offRec) \
     5043            do { \
     5044                a_idx = pbRec[a_offRec]; \
     5045                if ((a_idx) & 0x80) \
     5046                    a_idx = (((a_idx) & 0x7f) << 8) | pbRec[(a_offRec) + 1]; \
    47155047            } while (0)
    47165048
     
    47945126
    47955127            /*
    4796              * Remove borland source file changes. Also, emit our SEGDEF
    4797              * before the pass marker.
     5128             * Remove borland source file changes. Also, make sure the group
     5129             * definitions are written out.
    47985130             */
    47995131            case OMF_COMENT:
     5132                if (pbRec[1] == OMF_CCLS_LINK_PASS_SEP)
     5133                {
     5134                    Assert(fFlushSegDefs <= 0);
     5135                    if (   fFlushGrpDefs > 0
     5136                        && !convertOmfWriteAllGrpDefs(pThis, pOmfStuff, &fFlushGrpDefs))
     5137                        return false;
     5138                }
    48005139                if (fConvertLineNumbers)
    4801                 {
    48025140                    fSkip = pbRec[1] == OMF_CCLS_BORLAND_SRC_FILE;
    4803                     if (pbRec[1] == OMF_CCLS_LINK_PASS_SEP)
    4804                         if (   !convertOmfWriteDebugSegDefs(pThis, pOmfStuff)
    4805                             || !convertOmfWriteDebugGrpDefs(pThis, pOmfStuff))
    4806                             return false;
    4807                 }
    48085141                break;
    48095142
    48105143            /*
    4811              * Redo these to the OMF writer is on top of the index thing.
     5144             * Redo these so the OMF writer is on top of the index thing.
    48125145             */
    48135146            case OMF_LNAMES:
    4814                 if (!omfWriter_LNamesBegin(pThis, false /*fAddZeroEntry*/))
     5147                if (fFlushLNames >= 0)
     5148                {
     5149                    if (!omfWriter_LNamesBegin(pThis, false /*fAddZeroEntry*/))
     5150                        return false;
     5151                    if (!fFlushLNames)
     5152                    {
     5153                        while (offRec + 1 < cbRec)
     5154                        {
     5155                            uint8_t     cch = pbRec[offRec];
     5156                            const char *pch = (const char *)&pbRec[offRec + 1];
     5157                            if (!omfWriter_LNamesAddN(pThis, pch, cch, NULL))
     5158                                return false;
     5159                            offRec += cch + 1;
     5160                        }
     5161                    }
     5162                    else
     5163                    {
     5164                        /* Flush all LNAMES in one go. */
     5165                        for (unsigned i = 1; i < pOmfStuff->cLNames; i++)
     5166                            if (!omfWriter_LNamesAddN(pThis, pOmfStuff->papchLNames[i] + 1, *pOmfStuff->papchLNames[i], NULL))
     5167                                return false;
     5168                        fFlushLNames = -1;
     5169                    }
     5170                    if (!omfWriter_LNamesEnd(pThis))
     5171                        return false;
     5172                }
     5173                fSkip = true;
     5174                break;
     5175
     5176            /*
     5177             * We may want to flush all the segments when we see the first one.
     5178             */
     5179            case OMF_SEGDEF16:
     5180            case OMF_SEGDEF32:
     5181                fSkip = fFlushSegDefs != 0;
     5182                if (!convertOmfWriteAllSegDefs(pThis, pOmfStuff, &fFlushSegDefs))
    48155183                    return false;
    4816                 while (offRec + 1 < cbRec)
     5184                break;
     5185
     5186            /*
     5187             * We may want to flush all the groups when we see the first one.
     5188             */
     5189            case OMF_GRPDEF:
     5190                fSkip = fFlushGrpDefs != 0;
     5191                if (!convertOmfWriteAllGrpDefs(pThis, pOmfStuff, &fFlushGrpDefs))
     5192                    return false;
     5193                break;
     5194
     5195            /*
     5196             * Hook LEDATA to flush groups and figure out when to convert FIXUPP records.
     5197             */
     5198            case OMF_LEDATA16:
     5199            case OMF_LEDATA32:
     5200                if (   fFlushGrpDefs > 0
     5201                    && !convertOmfWriteAllGrpDefs(pThis, pOmfStuff, &fFlushGrpDefs))
     5202                    return false;
     5203                fConvertFixupp = false;
     5204#if 0
     5205                if (   g_f16BitWatcomC
     5206                    && bRecType == OMF_LEDATA16)
    48175207                {
    4818                     uint8_t     cch = pbRec[offRec];
    4819                     const char *pch = (const char *)&pbRec[offRec + 1];
    4820                     if (!omfWriter_LNamesAddN(pThis, pch, cch, NULL))
    4821                         return false;
    4822                     offRec += cch + 1;
     5208                    /* Check if this is a code segment. */
     5209                    uint16_t idxSeg;
     5210                    OMF_PEEK_IDX(idxSeg, offRec);
     5211
    48235212                }
    4824                 if (!omfWriter_LNamesEnd(pThis))
    4825                     return false;
    4826 
    4827                 fSkip = true;
     5213#endif
     5214                break;
     5215
     5216
     5217            /*
     5218             * Convert fixups for 16-bit code segments to groups.
     5219             * Deals with switch table trouble.
     5220             */
     5221            case OMF_FIXUPP16:
     5222                if (fConvertFixupp)
     5223                {
     5224                    /* Gave up on this for now, easier to drop the eyecatcher in the _START segments. */
     5225                }
    48285226                break;
    48295227
     
    48345232            case OMF_MODEND32:
    48355233                if (fConvertLineNumbers)
    4836                 {
    4837                     if (   convertOmfWriteDebugSegDefs(pThis, pOmfStuff)
    4838                         && convertOmfWriteDebugGrpDefs(pThis, pOmfStuff)
    4839                         && convertOmfWriteDebugData(pThis, pOmfStuff))
    4840                     { /* likely */ }
    4841                     else return false;
    4842                 }
     5234                    if (!convertOmfWriteDebugData(pThis, pOmfStuff))
     5235                        return false;
    48435236                break;
    48445237        }
     
    48855278static bool convertOmfToOmf(const char *pszFile, uint8_t const *pbFile, size_t cbFile, FILE *pDst)
    48865279{
    4887     /*
    4888      * Collect line number information.
     5280    bool const fConvertLineNumbers = true;
     5281
     5282    /*
     5283     * Collect line number information, names, segment defintions, groups definitions and such.
    48895284     */
    48905285    OMFDETAILS OmfStuff;
     
    48925287        return false;
    48935288
    4894     /*
    4895      * Instantiate the OMF writer and do pass-thru modifications.
    4896      */
    4897     bool fRc;
    4898     POMFWRITER pThis = omfWriter_Create(pszFile, 0, 0, pDst);
    4899     if (pThis)
    4900     {
    4901         fRc = convertOmfPassthru(pThis, pbFile, cbFile, &OmfStuff);
    4902         omfWriter_Destroy(pThis);
    4903     }
    4904     else
    4905         fRc = false;
    4906 
     5289    /* Mark groups for 16-bit code segments used by this object file as needed
     5290       so we can reframe fixups to these segments correctly. */
     5291    convertOmfLookForNeededGroups(&OmfStuff);
     5292
     5293    /* Add debug segments definitions. */
     5294    bool fRc = true;
     5295    if (fConvertLineNumbers)
     5296        fRc = convertOmfAddDebugSegDefs(&OmfStuff);
     5297
     5298    /* Add any additional group defintions we may need (for 16-bit code segs). */
     5299    if (fRc)
     5300        fRc = convertOmfAddNeededGrpDefs(&OmfStuff);
     5301    if (fRc)
     5302    {
     5303        /*
     5304         * Instantiate the OMF writer and do pass-thru modifications.
     5305         */
     5306        POMFWRITER pThis = omfWriter_Create(pszFile, 0, 0, pDst);
     5307        if (pThis)
     5308        {
     5309            fRc = convertOmfPassthru(pThis, pbFile, cbFile, &OmfStuff, fConvertLineNumbers);
     5310            omfWriter_Destroy(pThis);
     5311        }
     5312        else
     5313            fRc = false;
     5314    }
    49075315
    49085316    /*
     
    49205328    free(OmfStuff.paSrcInfo);
    49215329    free(OmfStuff.pchStrTab);
     5330
     5331    while (OmfStuff.pAllocHead)
     5332    {
     5333        POMFDETAILSALLOC pFreeMe = OmfStuff.pAllocHead;
     5334        OmfStuff.pAllocHead = OmfStuff.pAllocHead->pNext;
     5335        free(pFreeMe);
     5336    }
     5337
    49225338    return fRc;
    49235339}
     
    50265442                /* Convert long options to short ones. */
    50275443                pszOpt--;
    5028                 if (!strcmp(pszOpt, "--verbose"))
     5444                if (!strcmp(pszOpt, "--wcc"))
     5445                    pszOpt = "w";
     5446                else if (!strcmp(pszOpt, "--verbose"))
    50295447                    pszOpt = "v";
    50305448                else if (!strcmp(pszOpt, "--version"))
     
    50445462                switch (*pszOpt++)
    50455463                {
     5464                    case 'w':
     5465                        g_f16BitWatcomC = true;
     5466                        break;
     5467
    50465468                    case 'v':
    50475469                        g_cVerbose++;
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3-first-common.mac

    r66054 r66446  
    159159section BS3RMTEXT16_START   align=16 CLASS=BS3CLASS16RMCODE PUBLIC USE16
    160160BS3_GLOBAL_DATA Bs3RmText16_StartOfSegment, 0
    161     db      10,13,'eye-catcher: BS3RMTEXT16',10,13
     161    ;db      10,13,'eye-catcher: BS3RMTEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
    162162BS3_BEGIN_RMTEXT16
    163163section BS3RMTEXT16_END   align=1 CLASS=BS3CLASS16RMCODE PUBLIC USE16
     
    171171section BS3X0TEXT16_START   align=16 CLASS=BS3CLASS16X0CODE PUBLIC USE16
    172172BS3_GLOBAL_DATA Bs3X0Text16_StartOfSegment, 0
    173     db      10,13,'eye-catcher: BS3X0TEXT16',10,13
     173    ;db      10,13,'eye-catcher: BS3X0TEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
    174174BS3_BEGIN_X0TEXT16 4
    175175section BS3X0TEXT16_END   align=16 CLASS=BS3CLASS16X0CODE PUBLIC USE16
     
    183183section BS3X1TEXT16_START   align=16 CLASS=BS3CLASS16X1CODE PUBLIC USE16
    184184BS3_GLOBAL_DATA Bs3X1Text16_StartOfSegment, 0
    185     db      10,13,'eye-catcher: BS3X1TEXT16',10,13
     185    ;db      10,13,'eye-catcher: BS3X1TEXT16',10,13 - messes up switch in C code. Alt. is fConvertFixupp VBoxBs3ObjConverter.cpp.
    186186BS3_BEGIN_X1TEXT16 4
    187187section BS3X1TEXT16_END   align=16 CLASS=BS3CLASS16X1CODE PUBLIC USE16
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit-autostubs.kmk

    r66240 r66446  
    3232$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelRealModeDataToFlat,4)
    3333$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelRealModeDataToProtFar16,4)
     34$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3ExtCtxRestore,4)
     35$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3ExtCtxSave,4)
    3436$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3SelFar32ToFlat32NoClobber,6)
    3537$(call BS3KIT_FN_GEN_CMN_FARSTUB,bs3kit-common-16,Bs3RegCtxSaveEx,8)
     
    8183$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3SlabListAllocEx)
    8284$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxFree)
    83 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxRestore)
    84 $(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3ExtCtxSave)
    8585$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemFree)
    8686$(call BS3KIT_FN_GEN_CMN_NEARSTUB,bs3kit-common-16,Bs3MemGuardedTestPageFree)
  • trunk/src/VBox/ValidationKit/bootsectors/bs3kit/bs3kit.h

    r66240 r66446  
    27552755 * @remarks All GPRs preserved.
    27562756 */
    2757 BS3_CMN_PROTO_STUB(void,      Bs3ExtCtxSave,(PBS3EXTCTX pExtCtx));
     2757BS3_CMN_PROTO_FARSTUB(4, void, Bs3ExtCtxSave,(PBS3EXTCTX pExtCtx));
    27582758
    27592759/**
     
    27632763 * @remarks All GPRs preserved.
    27642764 */
    2765 BS3_CMN_PROTO_STUB(void,      Bs3ExtCtxRestore,(PBS3EXTCTX pExtCtx));
     2765BS3_CMN_PROTO_FARSTUB(4, void, Bs3ExtCtxRestore,(PBS3EXTCTX pExtCtx));
    27662766
    27672767/**
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette