VirtualBox

Changeset 41311 in vbox


Ignore:
Timestamp:
May 15, 2012 1:12:02 PM (12 years ago)
Author:
vboxsync
Message:

Work around 10.6.x or ld64-97.17 issue with relocations in the VTGObj.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxTpG.h

    r41130 r41311  
    380380     * modules easier. */
    381381    RTUUID              Uuid;
     382    /** Mac 10.6.x load workaround.
     383     * The linker or/and load messes up the uProbeLocs and uProbeLocsEnd fields
     384     * so that they will be link addresses instead of load addresses.  To be
     385     * able to work around it we store the start address of the __VTGObj section
     386     * here and uses it to validate the probe location addresses. */
     387    uint64_t            u64VtgObjSectionStart;
    382388    /** Reserved / alignment. */
    383     uint32_t            au32Reserved1[4];
     389    uint32_t            au32Reserved1[2];
    384390} VTGOBJHDR;
    385391AssertCompileSize(VTGOBJHDR, 128);
  • trunk/src/VBox/HostDrivers/Support/Makefile.kmk

    r41117 r41311  
    311311        win/VBoxDrv.rc
    312312 VBoxDrv_SOURCES          = \
     313        SUPDrv.d \
    313314        SUPDrv.c \
    314315        SUPDrvSem.c \
    315         SUPDrvTracer.cpp \
    316         SUPDrv.d
     316        SUPDrvTracer.cpp
    317317 ifdef VBOX_WITH_NATIVE_DTRACE
    318318  VBoxDrv_SOURCES        += \
  • trunk/src/VBox/HostDrivers/Support/SUPDrvTracer.cpp

    r41156 r41311  
    336336        if (u64Tmp >= UINT32_MAX)
    337337        {
    338             SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH - u64Tmp=%#llx ProbeLocs=%#llx ProbeLocsEnd=%#llx\n", 
     338            SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH - u64Tmp=%#llx ProbeLocs=%#llx ProbeLocsEnd=%#llx\n",
    339339                        u64Tmp, pVtgHdr->uProbeLocs.u64, pVtgHdr->uProbeLocsEnd.u64);
    340340            return VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH;
     
    343343
    344344        u64Tmp = pVtgHdr->uProbeLocs.u64 - uVtgHdrAddr;
     345#ifdef RT_OS_DARWIN
     346        /* The loader and/or ld64-97.17 seems not to generate fixups for our
     347           __VTGObj section. Detect this by comparing them with the
     348           u64VtgObjSectionStart member and assume max image size of 4MB. */
     349        if (   (int64_t)u64Tmp != (int32_t)u64Tmp
     350            && pVtgHdr->u64VtgObjSectionStart != uVtgHdrAddr
     351            && pVtgHdr->u64VtgObjSectionStart < _4M
     352            && pVtgHdr->uProbeLocsEnd.u64     < _4M
     353            && !fUmod)
     354        {
     355            uint64_t offDelta = uVtgHdrAddr - pVtgHdr->u64VtgObjSectionStart;
     356            pVtgHdr->uProbeLocs.u64        += offDelta;
     357            pVtgHdr->uProbeLocsEnd.u64     += offDelta;
     358            u64Tmp += offDelta;
     359        }
     360#endif
    345361        if ((int64_t)u64Tmp != (int32_t)u64Tmp)
    346362        {
    347             SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_PTR - u64Tmp=%#llx uProbeLocs=%#llx uVtgHdrAddr=%RTptr\n", 
     363            SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_PTR - u64Tmp=%#llx uProbeLocs=%#llx uVtgHdrAddr=%RTptr\n",
    348364                        u64Tmp, pVtgHdr->uProbeLocs.u64, uVtgHdrAddr);
    349365            return VERR_SUPDRV_VTG_BAD_HDR_PTR;
     
    362378                && pVtgHdr->cBits != 64)) )
    363379        return VERR_SUPDRV_VTG_BITS;
    364     if (   pVtgHdr->au32Reserved1[0]
    365         || pVtgHdr->au32Reserved1[1]
    366         || pVtgHdr->au32Reserved1[2]
    367         || pVtgHdr->au32Reserved1[3])
    368         return VERR_SUPDRV_VTG_BAD_HDR_MISC;
    369     if (RTUuidIsNull(&pVtgHdr->Uuid))
    370         return VERR_SUPDRV_VTG_BAD_HDR_MISC;
     380    MY_CHECK_RET(pVtgHdr->au32Reserved1[0] == 0, VERR_SUPDRV_VTG_BAD_HDR_MISC);
     381    MY_CHECK_RET(pVtgHdr->au32Reserved1[1] == 0, VERR_SUPDRV_VTG_BAD_HDR_MISC);
     382    MY_CHECK_RET(!RTUuidIsNull(&pVtgHdr->Uuid), VERR_SUPDRV_VTG_BAD_HDR_MISC);
    371383
    372384    /*
     
    617629     */
    618630    {
    619         PCVTGPROBELOC paProbeLocs = (PCVTGPROBELOC)((intptr_t)pVtgHdr + pVtgHdr->offProbeLocs);
     631        PVTGPROBELOC paProbeLocs = (PVTGPROBELOC)((intptr_t)pVtgHdr + pVtgHdr->offProbeLocs);
    620632        i = pVtgHdr->cbProbeLocs / sizeof(VTGPROBELOC);
    621633        while (i-- > 0)
     
    626638            MY_WITHIN_IMAGE(paProbeLocs[i].pszFunction, VERR_SUPDRV_VTG_BAD_PROBE_LOC);
    627639            offTmp = (uintptr_t)paProbeLocs[i].pProbe - (uintptr_t)pVtgHdr->offProbes - (uintptr_t)pVtgHdr;
     640#ifdef RT_OS_DARWIN /* See header validation code. */
     641            if (   offTmp >= pVtgHdr->cbProbes
     642                && pVtgHdr->u64VtgObjSectionStart != uVtgHdrAddr
     643                && pVtgHdr->u64VtgObjSectionStart   < _4M
     644                && (uintptr_t)paProbeLocs[i].pProbe < _4M
     645                && !fUmod )
     646            {
     647                uint64_t offDelta = uVtgHdrAddr - pVtgHdr->u64VtgObjSectionStart;
     648                paProbeLocs[i].pProbe = (PVTGDESCPROBE)((uintptr_t)paProbeLocs[i].pProbe + offDelta);
     649                offTmp += offDelta;
     650            }
     651#endif
    628652            MY_CHECK_RET(offTmp < pVtgHdr->cbProbes, VERR_SUPDRV_VTG_BAD_PROBE_LOC);
    629653            MY_CHECK_RET(offTmp / sizeof(VTGDESCPROBE) * sizeof(VTGDESCPROBE) == offTmp, VERR_SUPDRV_VTG_BAD_PROBE_LOC);
  • trunk/src/bldprogs/VBoxTpG.cpp

    r41186 r41311  
    439439                    "  NAME(%%1):\n"
    440440                    " %%endmacro\n"
    441                     " [section __VTG __VTGObj        align=64]\n"
     441                    " ; Section order hack!\n"
     442                    " ; With the ld64-97.17 linker there was a problem with it determin the section\n"
     443                    " ; order based on symbol references. The references to the start and end of the\n"
     444                    " ; __VTGPrLc section forced it in front of __VTGObj. \n"
     445                    " extern section$start$__VTG$__VTGObj\n"
     446                    " extern section$end$__VTG$__VTGObj\n"
     447                    " [section __VTG __VTGObj        align=1024]\n"
    442448                    "\n"
    443449                    "%%elifdef ASM_FORMAT_PE\n"
     
    522528    ScmStreamPrintf(pStrm,
    523529                    "    dd 0%08xh, 0%08xh, 0%08xh, 0%08xh\n"
    524                     "    dd 0, 0, 0, 0\n"
     530                    "%%ifdef ASM_FORMAT_MACHO\n"
     531                    "    RTCCPTR_DEF section$start$__VTG$__VTGObj\n"
     532                    " %%if ARCH_BITS == 32\n"
     533                    "    dd          0\n"
     534                    " %%endif\n"
     535                    "%%else\n"
     536                    "    dd 0, 0\n"
     537                    "%%endif\n"
     538                    "    dd 0, 0\n"
    525539                    , Uuid.au32[0], Uuid.au32[1], Uuid.au32[2], Uuid.au32[3]);
    526540
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