VirtualBox

Changeset 64 in kStuff for trunk


Ignore:
Timestamp:
Nov 6, 2013 9:04:11 PM (11 years ago)
Author:
bird
Message:

kLdrModMachO.c: Don't load LINKEDIT.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdrModMachO.c

    r63 r64  
    13151315     */
    13161316    {
     1317        KBOOL               fLoadLinkEdit = K_FALSE;
    13171318        PKLDRMODMACHOSECT   pSectExtraItr;
    13181319        KLDRADDR            uNextRVA = 0;
    13191320        KLDRADDR            cb;
     1321        KU32                cSegmentsToAdjust = cSegments - pModMachO->fMakeGot;
    13201322        KU32                c;
    13211323
     1324        for (;;)
     1325        {
     1326            /* Check if there is __DWARF segment at the end and make sure it's left
     1327               out of the RVA negotiations and image loading. */
     1328            if (   cSegmentsToAdjust > 0
     1329                && !kHlpStrComp(pModMachO->pMod->aSegments[cSegmentsToAdjust - 1].pchName, "__DWARF"))
     1330            {
     1331                cSegmentsToAdjust--;
     1332                pModMachO->pMod->aSegments[cSegmentsToAdjust].RVA = NIL_KLDRADDR;
     1333                pModMachO->pMod->aSegments[cSegmentsToAdjust].cbMapped = 0;
     1334                continue;
     1335            }
     1336
     1337            /* If we're skipping the __LINKEDIT segment, check for it and adjust
     1338               the number of segments we'll be messing with here.  ASSUMES it's
     1339               last (by now anyway). */
     1340            if (   !fLoadLinkEdit
     1341                && cSegmentsToAdjust > 0
     1342                && !kHlpStrComp(pModMachO->pMod->aSegments[cSegmentsToAdjust - 1].pchName, "__LINKEDIT"))
     1343            {
     1344                cSegmentsToAdjust--;
     1345                pModMachO->pMod->aSegments[cSegmentsToAdjust].RVA = NIL_KLDRADDR;
     1346                pModMachO->pMod->aSegments[cSegmentsToAdjust].cbMapped = 0;
     1347                continue;
     1348            }
     1349            break;
     1350        }
     1351
    13221352        /* Adjust RVAs. */
    1323         c = cSegments - pModMachO->fMakeGot;
     1353        c = cSegmentsToAdjust;
    13241354        for (pDstSeg = &pModMachO->pMod->aSegments[0]; c-- > 0; pDstSeg++)
    13251355        {
     
    13341364
    13351365        /* Calculate the cbMapping members. */
    1336         c = cSegments - pModMachO->fMakeGot;
     1366        c = cSegmentsToAdjust;
    13371367        for (pDstSeg = &pModMachO->pMod->aSegments[0]; c-- > 1; pDstSeg++)
    13381368        {
     1369
    13391370            cb = pDstSeg[1].RVA - pDstSeg->RVA;
    13401371            pDstSeg->cbMapped = (KSIZE)cb == cb ? cb : KSIZE_MAX;
     
    13471378        pModMachO->cbImage = pDstSeg->RVA + cb;
    13481379
    1349         /* Fixup the section RVA (internal). */
    1350         c        = cSegments - pModMachO->fMakeGot;
     1380        /* Fixup the section RVAs (internal). */
     1381        c        = cSegmentsToAdjust;
    13511382        uNextRVA = pModMachO->cbImage;
    13521383        pDstSeg  = &pModMachO->pMod->aSegments[0];
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