Index: /trunk/include/VBox/VBoxTpG.h
===================================================================
--- /trunk/include/VBox/VBoxTpG.h	(revision 41310)
+++ /trunk/include/VBox/VBoxTpG.h	(revision 41311)
@@ -380,6 +380,12 @@
      * modules easier. */
     RTUUID              Uuid;
+    /** Mac 10.6.x load workaround.
+     * The linker or/and load messes up the uProbeLocs and uProbeLocsEnd fields
+     * so that they will be link addresses instead of load addresses.  To be
+     * able to work around it we store the start address of the __VTGObj section
+     * here and uses it to validate the probe location addresses. */
+    uint64_t            u64VtgObjSectionStart;
     /** Reserved / alignment. */
-    uint32_t            au32Reserved1[4];
+    uint32_t            au32Reserved1[2];
 } VTGOBJHDR;
 AssertCompileSize(VTGOBJHDR, 128);
Index: /trunk/src/VBox/HostDrivers/Support/Makefile.kmk
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/Makefile.kmk	(revision 41310)
+++ /trunk/src/VBox/HostDrivers/Support/Makefile.kmk	(revision 41311)
@@ -311,8 +311,8 @@
 	win/VBoxDrv.rc
  VBoxDrv_SOURCES          = \
+ 	SUPDrv.d \
  	SUPDrv.c \
  	SUPDrvSem.c \
-  	SUPDrvTracer.cpp \
- 	SUPDrv.d
+  	SUPDrvTracer.cpp
  ifdef VBOX_WITH_NATIVE_DTRACE
   VBoxDrv_SOURCES        += \
Index: /trunk/src/VBox/HostDrivers/Support/SUPDrvTracer.cpp
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPDrvTracer.cpp	(revision 41310)
+++ /trunk/src/VBox/HostDrivers/Support/SUPDrvTracer.cpp	(revision 41311)
@@ -336,5 +336,5 @@
         if (u64Tmp >= UINT32_MAX)
         {
-            SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH - u64Tmp=%#llx ProbeLocs=%#llx ProbeLocsEnd=%#llx\n", 
+            SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH - u64Tmp=%#llx ProbeLocs=%#llx ProbeLocsEnd=%#llx\n",
                         u64Tmp, pVtgHdr->uProbeLocs.u64, pVtgHdr->uProbeLocsEnd.u64);
             return VERR_SUPDRV_VTG_BAD_HDR_TOO_MUCH;
@@ -343,7 +343,23 @@
 
         u64Tmp = pVtgHdr->uProbeLocs.u64 - uVtgHdrAddr;
+#ifdef RT_OS_DARWIN
+        /* The loader and/or ld64-97.17 seems not to generate fixups for our
+           __VTGObj section. Detect this by comparing them with the
+           u64VtgObjSectionStart member and assume max image size of 4MB. */
+        if (   (int64_t)u64Tmp != (int32_t)u64Tmp
+            && pVtgHdr->u64VtgObjSectionStart != uVtgHdrAddr
+            && pVtgHdr->u64VtgObjSectionStart < _4M
+            && pVtgHdr->uProbeLocsEnd.u64     < _4M
+            && !fUmod)
+        {
+            uint64_t offDelta = uVtgHdrAddr - pVtgHdr->u64VtgObjSectionStart;
+            pVtgHdr->uProbeLocs.u64        += offDelta;
+            pVtgHdr->uProbeLocsEnd.u64     += offDelta;
+            u64Tmp += offDelta;
+        }
+#endif
         if ((int64_t)u64Tmp != (int32_t)u64Tmp)
         {
-            SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_PTR - u64Tmp=%#llx uProbeLocs=%#llx uVtgHdrAddr=%RTptr\n", 
+            SUPR0Printf("supdrvVtgValidateHdr: VERR_SUPDRV_VTG_BAD_HDR_PTR - u64Tmp=%#llx uProbeLocs=%#llx uVtgHdrAddr=%RTptr\n",
                         u64Tmp, pVtgHdr->uProbeLocs.u64, uVtgHdrAddr);
             return VERR_SUPDRV_VTG_BAD_HDR_PTR;
@@ -362,11 +378,7 @@
                 && pVtgHdr->cBits != 64)) )
         return VERR_SUPDRV_VTG_BITS;
-    if (   pVtgHdr->au32Reserved1[0]
-        || pVtgHdr->au32Reserved1[1]
-        || pVtgHdr->au32Reserved1[2]
-        || pVtgHdr->au32Reserved1[3])
-        return VERR_SUPDRV_VTG_BAD_HDR_MISC;
-    if (RTUuidIsNull(&pVtgHdr->Uuid))
-        return VERR_SUPDRV_VTG_BAD_HDR_MISC;
+    MY_CHECK_RET(pVtgHdr->au32Reserved1[0] == 0, VERR_SUPDRV_VTG_BAD_HDR_MISC);
+    MY_CHECK_RET(pVtgHdr->au32Reserved1[1] == 0, VERR_SUPDRV_VTG_BAD_HDR_MISC);
+    MY_CHECK_RET(!RTUuidIsNull(&pVtgHdr->Uuid), VERR_SUPDRV_VTG_BAD_HDR_MISC);
 
     /*
@@ -617,5 +629,5 @@
      */
     {
-        PCVTGPROBELOC paProbeLocs = (PCVTGPROBELOC)((intptr_t)pVtgHdr + pVtgHdr->offProbeLocs);
+        PVTGPROBELOC paProbeLocs = (PVTGPROBELOC)((intptr_t)pVtgHdr + pVtgHdr->offProbeLocs);
         i = pVtgHdr->cbProbeLocs / sizeof(VTGPROBELOC);
         while (i-- > 0)
@@ -626,4 +638,16 @@
             MY_WITHIN_IMAGE(paProbeLocs[i].pszFunction, VERR_SUPDRV_VTG_BAD_PROBE_LOC);
             offTmp = (uintptr_t)paProbeLocs[i].pProbe - (uintptr_t)pVtgHdr->offProbes - (uintptr_t)pVtgHdr;
+#ifdef RT_OS_DARWIN /* See header validation code. */
+            if (   offTmp >= pVtgHdr->cbProbes
+                && pVtgHdr->u64VtgObjSectionStart != uVtgHdrAddr
+                && pVtgHdr->u64VtgObjSectionStart   < _4M
+                && (uintptr_t)paProbeLocs[i].pProbe < _4M
+                && !fUmod )
+            {
+                uint64_t offDelta = uVtgHdrAddr - pVtgHdr->u64VtgObjSectionStart;
+                paProbeLocs[i].pProbe = (PVTGDESCPROBE)((uintptr_t)paProbeLocs[i].pProbe + offDelta);
+                offTmp += offDelta;
+            }
+#endif
             MY_CHECK_RET(offTmp < pVtgHdr->cbProbes, VERR_SUPDRV_VTG_BAD_PROBE_LOC);
             MY_CHECK_RET(offTmp / sizeof(VTGDESCPROBE) * sizeof(VTGDESCPROBE) == offTmp, VERR_SUPDRV_VTG_BAD_PROBE_LOC);
Index: /trunk/src/bldprogs/VBoxTpG.cpp
===================================================================
--- /trunk/src/bldprogs/VBoxTpG.cpp	(revision 41310)
+++ /trunk/src/bldprogs/VBoxTpG.cpp	(revision 41311)
@@ -439,5 +439,11 @@
                     "  NAME(%%1):\n"
                     " %%endmacro\n"
-                    " [section __VTG __VTGObj        align=64]\n"
+                    " ; Section order hack!\n"
+                    " ; With the ld64-97.17 linker there was a problem with it determin the section\n"
+                    " ; order based on symbol references. The references to the start and end of the\n"
+                    " ; __VTGPrLc section forced it in front of __VTGObj. \n"
+                    " extern section$start$__VTG$__VTGObj\n"
+                    " extern section$end$__VTG$__VTGObj\n"
+                    " [section __VTG __VTGObj        align=1024]\n"
                     "\n"
                     "%%elifdef ASM_FORMAT_PE\n"
@@ -522,5 +528,13 @@
     ScmStreamPrintf(pStrm,
                     "    dd 0%08xh, 0%08xh, 0%08xh, 0%08xh\n"
-                    "    dd 0, 0, 0, 0\n"
+                    "%%ifdef ASM_FORMAT_MACHO\n"
+                    "    RTCCPTR_DEF section$start$__VTG$__VTGObj\n"
+                    " %%if ARCH_BITS == 32\n"
+                    "    dd          0\n"
+                    " %%endif\n"
+                    "%%else\n"
+                    "    dd 0, 0\n"
+                    "%%endif\n"
+                    "    dd 0, 0\n"
                     , Uuid.au32[0], Uuid.au32[1], Uuid.au32[2], Uuid.au32[3]);
 
