Index: trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp	(revision 46134)
+++ trunk/src/VBox/Runtime/common/dbg/dbgmodcontainer.cpp	(revision 46149)
@@ -488,5 +488,14 @@
         if (   uRva      <= uCurRvaLast
             && uRvaLast  >= uCurRva
-            && (cb != 0 || pThis->paSegs[iSeg].cb != 0)) /* HACK ALERT! Allow empty segments to share space (bios/watcom). */
+            && (   /* HACK ALERT! Allow empty segments to share space (bios/watcom, elf). */
+                   (cb != 0 && pThis->paSegs[iSeg].cb != 0)
+                || (   cb == 0
+                    && uRva != uCurRva
+                    && uRva != uCurRvaLast)
+                || (    pThis->paSegs[iSeg].cb == 0
+                    && uCurRva != uRva
+                    && uCurRva != uRvaLast)
+               )
+           )
             AssertMsgFailedReturn(("uRva=%RTptr uRvaLast=%RTptr (cb=%RTptr) \"%s\";\n"
                                    "uRva=%RTptr uRvaLast=%RTptr (cb=%RTptr) \"%s\" iSeg=%#x\n",
@@ -600,5 +609,5 @@
             else
             {
-                /* between iSeg and iLast. */
+                /* between iSeg and iLast. paSeg[iSeg].cb == 0 ends up here too. */
                 if (iSeg == iLast)
                     break;
Index: trunk/src/VBox/Runtime/common/dbg/dbgmoddeferred.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dbg/dbgmoddeferred.cpp	(revision 46134)
+++ trunk/src/VBox/Runtime/common/dbg/dbgmoddeferred.cpp	(revision 46149)
@@ -451,9 +451,9 @@
 
 /** @interface_method_impl{RTDBGMODVTIMG,pfnMapPart} */
-static DECLCALLBACK(int) rtDbgModDeferredImg_MapPart(PRTDBGMODINT pMod, RTFOFF off, size_t cb, void const **ppvMap)
-{
-    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
-    if (RT_SUCCESS(rc))
-        rc = pMod->pImgVt->pfnMapPart(pMod, off, cb, ppvMap);
+static DECLCALLBACK(int) rtDbgModDeferredImg_MapPart(PRTDBGMODINT pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void const **ppvMap)
+{
+    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
+    if (RT_SUCCESS(rc))
+        rc = pMod->pImgVt->pfnMapPart(pMod, iDbgInfo, off, cb, ppvMap);
     return rc;
 }
@@ -465,4 +465,15 @@
     PRTDBGMODDEFERRED pThis = (PRTDBGMODDEFERRED)pMod->pvImgPriv;
     return pThis->cbImage;
+}
+
+
+/** @interface_method_impl{RTDBGMODVTIMG,pfnRvaToSegOffset} */
+static DECLCALLBACK(int) rtDbgModDeferredImg_RvaToSegOffset(PRTDBGMODINT pMod, RTLDRADDR uRva,
+                                                            PRTDBGSEGIDX piSeg, PRTLDRADDR poffSeg)
+{
+    int rc = rtDbgModDeferredDoIt(pMod, false /*fForceRetry*/);
+    if (RT_SUCCESS(rc))
+        rc = pMod->pImgVt->pfnRvaToSegOffset(pMod, uRva, piSeg, poffSeg);
+    return rc;
 }
 
@@ -538,4 +549,5 @@
     /*.pfnGetLoadedSize = */            rtDbgModDeferredImg_ImageSize,
     /*.pfnLinkAddressToSegOffset = */   rtDbgModDeferredImg_LinkAddressToSegOffset,
+    /*.pfnRvaToSegOffset = */           rtDbgModDeferredImg_RvaToSegOffset,
     /*.pfnMapPart = */                  rtDbgModDeferredImg_MapPart,
     /*.pfnUnmapPart = */                rtDbgModDeferredImg_UnmapPart,
Index: trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp	(revision 46134)
+++ trunk/src/VBox/Runtime/common/dbg/dbgmoddwarf.cpp	(revision 46149)
@@ -434,4 +434,6 @@
         /** Set if present. */
         bool                fPresent;
+        /** The debug info ordinal number in the image file. */
+        uint32_t            iDbgInfo;
     } aSections[krtDbgModDwarfSect_End];
 
@@ -750,5 +752,5 @@
     RTDWARFADDRRANGE    PcRange;
     /** The language name. */
-    uint8_t             uLanguage;
+    uint16_t            uLanguage;
     /** The identifier case. */
     uint8_t             uIdentifierCase;
@@ -1179,10 +1181,7 @@
         return RTDbgModSegmentAdd(pThis->hCnt, 0, 0, pSeg->pchName, 0 /*fFlags*/, NULL);
 
+    /* The link address is 0 for all segments in a relocatable ELF image. */
     RTLDRADDR cb = RT_MAX(pSeg->cb, pSeg->cbMapped);
-#if 1
     return RTDbgModSegmentAdd(pThis->hCnt, pSeg->RVA, cb, pSeg->pchName, 0 /*fFlags*/, NULL);
-#else
-    return RTDbgModSegmentAdd(pThis->hCnt, pSeg->LinkAddress, cb, pSeg->pchName, 0 /*fFlags*/, NULL);
-#endif
 }
 
@@ -1383,5 +1382,8 @@
      * Do the job.
      */
-    return pThis->pMod->pImgVt->pfnMapPart(pThis->pMod, pThis->aSections[enmSect].offFile, pThis->aSections[enmSect].cb,
+    return pThis->pMod->pImgVt->pfnMapPart(pThis->pMod,
+                                           pThis->aSections[enmSect].iDbgInfo,
+                                           pThis->aSections[enmSect].offFile,
+                                           pThis->aSections[enmSect].cb,
                                            &pThis->aSections[enmSect].pv);
 }
@@ -1449,5 +1451,6 @@
     }
 
-    return pThis->pMod->pImgVt->pfnLinkAddressToSegOffset(pThis->pMod, LinkAddress, piSeg, poffSeg);
+    return pThis->pMod->pImgVt->pfnRvaToSegOffset(pThis->pMod, LinkAddress, piSeg, poffSeg);
+    //return pThis->pMod->pImgVt->pfnLinkAddressToSegOffset(pThis->pMod, LinkAddress, piSeg, poffSeg);
 }
 
@@ -2011,4 +2014,5 @@
     if (offRet != off)
     {
+        AssertFailed();
         pCursor->rc = VERR_OUT_OF_RANGE;
         offRet = UINT32_MAX;
@@ -2311,5 +2315,5 @@
         RTUINTPTR   offSeg;
         rc = rtDbgModDwarfLinkAddressToSegOffset(pLnState->pDwarfMod, pLnState->Regs.uSegment, pLnState->Regs.uAddress,
-                                                 &iSeg, &offSeg);
+                                                 &iSeg, &offSeg); AssertRC(rc);
         if (RT_SUCCESS(rc))
         {
@@ -3134,5 +3138,5 @@
 {
     AssertReturn(ATTR_GET_SIZE(pDesc) == sizeof(RTDWARFADDRRANGE), VERR_INTERNAL_ERROR_3);
-    AssertReturn(pDesc->uAttr == DW_AT_low_pc || pDesc->uAttr == DW_AT_high_pc, VERR_INTERNAL_ERROR_3);
+    AssertReturn(pDesc->uAttr == DW_AT_ranges, VERR_INTERNAL_ERROR_3);
     NOREF(pDie);
 
@@ -3280,5 +3284,5 @@
         /* Watcom generates offset past the end of the section, increasing the
            offset by one for each compile unit. So, just fudge it. */
-        Log(("rtDwarfDecode_SectOff: bad off=%#llx, attr %#x (%s), enmSect=%d cb=%#llx; Assuming watcom.\n", off,
+        Log(("rtDwarfDecode_SectOff: bad off=%#llx, attr %#x (%s), enmSect=%d cb=%#llx; Assuming watcom/gcc.\n", off,
              pDesc->uAttr, rtDwarfLog_AttrName(pDesc->uAttr), enmSect, cbSect));
         off = cbSect;
@@ -3346,5 +3350,8 @@
             *pbMember = (uint8_t)u64Val;
             if (*pbMember != u64Val)
+            {
+                AssertFailed();
                 return VERR_OUT_OF_RANGE;
+            }
             break;
 
@@ -3352,5 +3359,8 @@
             *(uint16_t *)pbMember = (uint16_t)u64Val;
             if (*(uint16_t *)pbMember != u64Val)
+            {
+                AssertFailed();
                 return VERR_OUT_OF_RANGE;
+            }
             break;
 
@@ -3358,5 +3368,8 @@
             *(uint32_t *)pbMember = (uint32_t)u64Val;
             if (*(uint32_t *)pbMember != u64Val)
+            {
+                AssertFailed();
                 return VERR_OUT_OF_RANGE;
+            }
             break;
 
@@ -3364,5 +3377,8 @@
             *(uint64_t *)pbMember = (uint64_t)u64Val;
             if (*(uint64_t *)pbMember != u64Val)
+            {
+                AssertFailed();
                 return VERR_OUT_OF_RANGE;
+            }
             break;
 
@@ -3670,8 +3686,12 @@
                                                                      pSubProgram->PcRange.uLowAddress,
                                                                      &iSeg, &offSeg);
+                            AssertRC(rc);
                             if (RT_SUCCESS(rc))
+                            {
                                 rc = RTDbgModSymbolAdd(pThis->hCnt, pSubProgram->pszName, iSeg, offSeg,
                                                        pSubProgram->PcRange.uHighAddress - pSubProgram->PcRange.uLowAddress,
                                                        0 /*fFlags*/, NULL /*piOrdinal*/);
+                                AssertRC(rc);
+                            }
                             else
                                 Log5(("rtDbgModDwarfLinkAddressToSegOffset failed: %Rrc\n", rc));
@@ -3699,7 +3719,11 @@
                     rc = rtDbgModDwarfLinkAddressToSegOffset(pThis, pLabel->uSegment, pLabel->Address.uAddress,
                                                              &iSeg, &offSeg);
+                    AssertRC(rc);
                     if (RT_SUCCESS(rc))
+                    {
                         rc = RTDbgModSymbolAdd(pThis->hCnt, pLabel->pszName, iSeg, offSeg, 0 /*cb*/,
                                                0 /*fFlags*/, NULL /*piOrdinal*/);
+                        AssertRC(rc);
+                    }
                     else
                         Log5(("rtDbgModDwarfLinkAddressToSegOffset failed: %Rrc\n", rc));
@@ -4369,4 +4393,5 @@
     pThis->aSections[enmSect].pv        = NULL;
     pThis->aSections[enmSect].cb        = (size_t)pDbgInfo->cb;
+    pThis->aSections[enmSect].iDbgInfo  = pDbgInfo->iDbgInfo;
     if (pThis->aSections[enmSect].cb != pDbgInfo->cb)
         pThis->aSections[enmSect].cb    = ~(size_t)0;
Index: trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp	(revision 46134)
+++ trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp	(revision 46149)
@@ -71,5 +71,5 @@
 
 /** @interface_method_impl{RTDBGMODVTIMG,pfnMapPart} */
-static DECLCALLBACK(int) rtDbgModLdr_MapPart(PRTDBGMODINT pMod, RTFOFF off, size_t cb, void const **ppvMap)
+static DECLCALLBACK(int) rtDbgModLdr_MapPart(PRTDBGMODINT pMod, uint32_t iDbgInfo, RTFOFF off, size_t cb, void const **ppvMap)
 {
     PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
@@ -79,5 +79,5 @@
         return VERR_NO_MEMORY;
 
-    int rc = rtLdrReadAt(pThis->hLdrMod, pvMap, off, cb);
+    int rc = rtLdrReadAt(pThis->hLdrMod, pvMap, iDbgInfo, off, cb);
     if (RT_SUCCESS(rc))
         *ppvMap = pvMap;
@@ -96,4 +96,13 @@
     PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
     return RTLdrSize(pThis->hLdrMod);
+}
+
+
+/** @interface_method_impl{RTDBGMODVTIMG,pfnRvaToSegOffset} */
+static DECLCALLBACK(int) rtDbgModLdr_RvaToSegOffset(PRTDBGMODINT pMod, RTLDRADDR uRva,
+                                                    PRTDBGSEGIDX piSeg, PRTLDRADDR poffSeg)
+{
+    PRTDBGMODLDR pThis = (PRTDBGMODLDR)pMod->pvImgPriv;
+    return RTLdrRvaToSegOffset(pThis->hLdrMod, uRva, piSeg, poffSeg);
 }
 
@@ -176,4 +185,5 @@
     /*.pfnGetLoadedSize = */            rtDbgModLdr_GetLoadedSize,
     /*.pfnLinkAddressToSegOffset = */   rtDbgModLdr_LinkAddressToSegOffset,
+    /*.pfnRvaToSegOffset= */            rtDbgModLdr_RvaToSegOffset,
     /*.pfnMapPart = */                  rtDbgModLdr_MapPart,
     /*.pfnUnmapPart = */                rtDbgModLdr_UnmapPart,
