Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

static int kldrModLXDoReloc ( KU8 *  pbPage,
int  off,
KLDRADDR  PageAddress,
const struct r32_rlc prlc,
int  iSelector,
KLDRADDR  uValue,
KU32  fKind 
) [static]

Applies the relocation to one 'source' in a page.

This takes care of the more esotic case while the common cases are dealt with seperately.

Returns:
0 on success, non-zero kLdr status code on failure.
Parameters:
pbPage The page in which to apply the fixup.
off Page relative offset of where to apply the offset.
uValue The target value.
fKind The target kind.

Todo:
fix error, add more checks!

Definition at line 2530 of file kLdrModLX.c.

References KLDR_ERR_LX_BAD_FIXUP_SECTION, r32_rlc::nr_stype, and OBJPAGELEN.

Referenced by kldrModLXRelocateBits().

{
#pragma pack(1) /* just to be sure */
    union
    {
        KU8         ab[6];
        KU32        off32;
        KU16        off16;
        KU8         off8;
        struct
        {
            KU16    off;
            KU16    Sel;
        }           Far16;
        struct
        {
            KU32    off;
            KU16    Sel;
        }           Far32;
    }               uData;
#pragma pack()
    const KU8      *pbSrc;
    KU8            *pbDst;
    KU8             cb;

    /*
     * Compose the fixup data.
     */
    switch (prlc->nr_stype & NRSRCMASK)
    {
        case NRSBYT:
            uData.off8 = (KU8)uValue;
            cb = 1;
            break;
        case NRSSEG:
            if (iSelector == -1)
            {
                /* fixme */
            }
            uData.off16 = iSelector;
            cb = 2;
            break;
        case NRSPTR:
            if (iSelector == -1)
            {
                /* fixme */
            }
            uData.Far16.off = (KU16)uValue;
            uData.Far16.Sel = iSelector;
            cb = 4;
            break;
        case NRSOFF:
            uData.off16 = (KU16)uValue;
            cb = 2;
            break;
        case NRPTR48:
            if (iSelector == -1)
            {
                /* fixme */
            }
            uData.Far32.off = (KU32)uValue;
            uData.Far32.Sel = iSelector;
            cb = 6;
            break;
        case NROFF32:
            uData.off32 = (KU32)uValue;
            cb = 4;
            break;
        case NRSOFF32:
            uData.off32 = (KU32)uValue - (PageAddress + off + 4);
            cb = 4;
            break;
        default:
            return KLDR_ERR_LX_BAD_FIXUP_SECTION; /** @todo fix error, add more checks! */
    }

    /*
     * Apply it. This is sloooow...
     */
    pbSrc = &uData.ab[0];
    pbDst = pbPage + off;
    while (cb-- > 0)
    {
        if (off > OBJPAGELEN)
            break;
        if (off >= 0)
            *pbDst = *pbSrc;
        pbSrc++;
        pbDst++;
    }

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index