Changeset 2968 for trunk


Ignore:
Timestamp:
Feb 13, 2007, 11:59:34 PM (18 years ago)
Author:
bird
Message:

Made tst-3 load.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdrModMachO.c

    r2964 r2968  
    6262    /** The size of the section (in bytes). */
    6363    KLDRSIZE                cb;
     64    /** The link address of this section. */
     65    KLDRADDR                LinkAddress;
    6466    /** The RVA of this section. */
    6567    KLDRADDR                RVA;
     
    835837                            pSectExtra->cb = pSect->size;
    836838                            pSectExtra->RVA = pSect->addr;
     839                            pSectExtra->LinkAddress = pSect->addr;
    837840                            pSectExtra->offFile = pSect->offset ? pSect->offset : -1;
    838841                            pSectExtra->cFixups = pSect->nreloc;
     
    19651968                case 3: SymAddr = *uFixVirgin.pi64; break;
    19661969            }
     1970            if (Fixup.r.r_pcrel)
     1971                SymAddr += Fixup.r.r_address;
    19671972
    19681973            /* Add symbol / section address. */
     
    20082013                    return KLDR_ERR_BAD_FIXUP;
    20092014                pSymSect = &pModMachO->paSections[Fixup.r.r_symbolnum - 1];
     2015
     2016                SymAddr -= pSymSect->LinkAddress;
    20102017                SymAddr += NewBaseAddress + pSymSect->RVA;
    20112018            }
     
    20412048                case 3: SymAddr = *uFixVirgin.pi64; break;
    20422049            }
     2050            if (Fixup.s.r_pcrel)
     2051                Value += Fixup.s.r_address;
    20432052
    20442053            /* Calc the section number from the r_value and adjust the value. */
    20452054            pSymSect = NULL;
    2046             Value = Fixup.s.r_value - pModMachO->LinkAddress;
     2055            Value = Fixup.s.r_value;
    20472056            for (iSymSect = 0; iSymSect < pModMachO->cSections; iSymSect++)
    20482057            {
    2049                 KLDRADDR off = Value - pModMachO->paSections[iSymSect].RVA;
     2058                KLDRADDR off = Value - pModMachO->paSections[iSymSect].LinkAddress;
    20502059                if (off < pModMachO->paSections[iSymSect].cb)
    20512060                {
     
    20582067            if (!pSymSect)
    20592068                return KLDR_ERR_BAD_FIXUP;
    2060 
    2061             /** @todo this looking up of the r_value section isn't strictly required unless we're going to remove sections from the link. */
    2062             SymAddr += NewBaseAddress + pSymSect->RVA + (Value - pSymSect->RVA);
    2063 
    2064             /* adjust for PC relative */
     2069            Value -= pSymSect->LinkAddress;
     2070
     2071            /* Calc the symbol address. */
     2072            SymAddr += NewBaseAddress + pSymSect->RVA + Value;
    20652073            if (Fixup.s.r_pcrel)
    20662074                SymAddr -= Fixup.s.r_address + pFixupSect->RVA + NewBaseAddress;
Note: See TracChangeset for help on using the changeset viewer.