- Timestamp:
- Jul 29, 2020 2:28:59 PM (4 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPLibLdr.cpp
r85517 r85525 374 374 AssertReturn(pSeg->RVA < _1G, VERR_INTERNAL_ERROR_3); 375 375 uint32_t uRvaSeg = (uint32_t)pSeg->RVA; 376 Log2(("supLoadModuleCompileSegmentsCB: %RTptr/%RTptr LB %RTptr prot %#x %s\n",377 pSeg->LinkAddress, pSeg->RVA, pSeg->cbMapped, pSeg-> fProt, pSeg->pszName));376 Log2(("supLoadModuleCompileSegmentsCB: %RTptr/%RTptr LB %RTptr/%RTptr prot %#x %s\n", 377 pSeg->LinkAddress, pSeg->RVA, pSeg->cbMapped, pSeg->cb, pSeg->fProt, pSeg->pszName)); 378 378 379 379 /* -
trunk/src/VBox/Runtime/common/ldr/ldrELFRelocatable.cpp.h
r85503 r85525 134 134 * re-used the NULL entry for .elf.headers in ET_EXEC/ET_DYN. */ 135 135 unsigned iFirstSect; 136 /** Set if the SHF_ALLOC section headers are in order of sh_addr. */ 137 bool fShdrInOrder; 136 138 /** The size of the loaded image. */ 137 139 size_t cbImage; … … 1377 1379 } 1378 1380 1381 /** 1382 * Helper that locates the next allocated section logically by RVA (sh_addr). 1383 * 1384 * @returns Pointer to the section header if found, NULL if none. 1385 * @param pModElf The module instance. 1386 * @param iCur The current section header. 1387 */ 1388 static const Elf_Shdr *RTLDRELF_NAME(GetNextAllocatedSection)(PRTLDRMODELF pModElf, unsigned iCur) 1389 { 1390 unsigned const cShdrs = pModElf->Ehdr.e_shnum; 1391 const Elf_Shdr * const paShdrs = pModElf->paShdrs; 1392 if (pModElf->fShdrInOrder) 1393 { 1394 for (; iCur < cShdrs; iCur++) 1395 if (paShdrs[iCur].sh_flags & SHF_ALLOC) 1396 return &paShdrs[iCur]; 1397 } 1398 else 1399 { 1400 Elf_Addr const uEndCur = paShdrs[iCur].sh_addr + paShdrs[iCur].sh_size; 1401 Elf_Addr offBest = ~(Elf_Addr)0; 1402 unsigned iBest = cShdrs; 1403 for (iCur = pModElf->iFirstSect; iCur < cShdrs; iCur++) 1404 if (paShdrs[iCur].sh_flags & SHF_ALLOC) 1405 { 1406 Elf_Addr const offDelta = paShdrs[iCur].sh_addr - uEndCur; 1407 if ( offDelta < offBest 1408 && paShdrs[iCur].sh_addr >= uEndCur) 1409 { 1410 offBest = offDelta; 1411 iBest = iCur; 1412 } 1413 } 1414 if (iBest < cShdrs) 1415 return &paShdrs[iBest]; 1416 } 1417 return NULL; 1418 } 1419 1379 1420 /** @copydoc RTLDROPS::pfnEnumSegments. */ 1380 1421 static DECLCALLBACK(int) RTLDRELF_NAME(EnumSegments)(PRTLDRMODINTERNAL pMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser) … … 1428 1469 Seg.LinkAddress = paOrgShdrs[iShdr].sh_addr; 1429 1470 Seg.RVA = paShdrs[iShdr].sh_addr; 1430 const Elf_Shdr *pShdr2 = RTLDRELF_NAME(GetFirstAllocatedSection)(&paShdrs[iShdr + 1], 1431 pModElf->Ehdr.e_shnum - iShdr - 1); 1432 if ( pShdr2 1433 && pShdr2->sh_addr >= paShdrs[iShdr].sh_addr 1434 && Seg.RVA >= uPrevMappedRva) 1471 const Elf_Shdr *pShdr2 = RTLDRELF_NAME(GetNextAllocatedSection)(pModElf, iShdr); 1472 if (pShdr2) 1435 1473 Seg.cbMapped = pShdr2->sh_addr - paShdrs[iShdr].sh_addr; 1436 1474 else 1437 Seg.cbMapped = RT_MAX(paShdrs[iShdr].sh_size, paShdrs[iShdr].sh_addralign);1475 Seg.cbMapped = pModElf->cbImage - paShdrs[iShdr].sh_addr; 1438 1476 uPrevMappedRva = Seg.RVA; 1439 1477 } … … 2838 2876 //pModElf->Dyn.pStr = NULL; 2839 2877 //pModElf->iFirstSect = 0; 2878 //pModElf->fShdrInOrder = false; 2840 2879 //pModElf->cbImage = 0; 2841 2880 pModElf->LinkAddress = ~(Elf_Addr)0; … … 2940 2979 } 2941 2980 2942 Log2(("RTLdrElf: iSymSh=%u cSyms=%u iStrSh=%u cbStr=%u rc=%Rrc cbImage=%#zx LinkAddress=" FMT_ELF_ADDR "\n", 2981 /* 2982 * Check if the sections are in order by address, as that will simplify 2983 * enumeration and address translation. 2984 */ 2985 pModElf->fShdrInOrder = true; 2986 Elf_Addr uEndAddr = 0; 2987 for (unsigned i = pModElf->iFirstSect; i < pModElf->Ehdr.e_shnum; i++) 2988 if (paShdrs[i].sh_flags & SHF_ALLOC) 2989 { 2990 if (uEndAddr <= paShdrs[i].sh_addr) 2991 uEndAddr = paShdrs[i].sh_addr + paShdrs[i].sh_size; 2992 else 2993 { 2994 pModElf->fShdrInOrder = false; 2995 break; 2996 } 2997 } 2998 2999 Log2(("RTLdrElf: iSymSh=%u cSyms=%u iStrSh=%u cbStr=%u rc=%Rrc cbImage=%#zx LinkAddress=" FMT_ELF_ADDR " fShdrInOrder=%RTbool\n", 2943 3000 pModElf->Rel.iSymSh, pModElf->Rel.cSyms, pModElf->Rel.iStrSh, pModElf->Rel.cbStr, rc, 2944 pModElf->cbImage, pModElf->LinkAddress ));3001 pModElf->cbImage, pModElf->LinkAddress, pModElf->fShdrInOrder)); 2945 3002 if (RT_SUCCESS(rc)) 2946 3003 {
Note:
See TracChangeset
for help on using the changeset viewer.