Changeset 2976


Ignore:
Timestamp:
Feb 15, 2007, 4:30:48 AM (18 years ago)
Author:
bird
Message:

More fixup bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kLdr/kLdrModMachO.c

    r2975 r2976  
    19611961             * Calc the symbol value.
    19621962             */
    1963             /* The addend is stored in the code. */
    1964             /** @todo Deal with unaligned accesses on non x86 platforms. */
     1963            /* Calc the linked symbol address / addend. */
    19651964            switch (Fixup.r.r_length)
    19661965            {
     1966                /** @todo Deal with unaligned accesses on non x86 platforms. */
    19671967                case 0: SymAddr = *uFixVirgin.pi8; break;
    19681968                case 1: SymAddr = *uFixVirgin.pi16; break;
     
    19711971            }
    19721972            if (Fixup.r.r_pcrel)
    1973                 SymAddr += Fixup.r.r_address;
     1973                SymAddr += Fixup.r.r_address + pFixupSect->LinkAddress;
    19741974
    19751975            /* Add symbol / section address. */
     
    19931993                        pSymSect = &pModMachO->paSections[pSym->n_sect - 1];
    19941994
    1995                         SymAddr += pSym->n_value - pModMachO->LinkAddress + pSymSect->RVA;
     1995                        SymAddr += pSym->n_value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress;
    19961996                        break;
    19971997                    }
     
    20172017
    20182018                SymAddr -= pSymSect->LinkAddress;
    2019                 SymAddr += NewBaseAddress + pSymSect->RVA;
     2019                SymAddr += pSymSect->RVA + NewBaseAddress;
    20202020            }
    20212021
     
    20552055            SymAddr -= Value;                   /* (-> addend only) */
    20562056
    2057             /* Calc the section number from the r_value and adjust the value in case the section moved. */
     2057            /* Find the section number from the r_value. */
    20582058            pSymSect = NULL;
    20592059            for (iSymSect = 0; iSymSect < pModMachO->cSections; iSymSect++)
     
    20702070            if (!pSymSect)
    20712071                return KLDR_ERR_BAD_FIXUP;
    2072             Value -= pSymSect->LinkAddress;
    20732072
    20742073            /* Calc the symbol address. */
    2075             SymAddr += NewBaseAddress + pSymSect->RVA + Value;
     2074            SymAddr += Value - pSymSect->LinkAddress + pSymSect->RVA + NewBaseAddress;
    20762075            if (Fixup.s.r_pcrel)
    20772076                SymAddr -= Fixup.s.r_address + pFixupSect->RVA + NewBaseAddress;
Note: See TracChangeset for help on using the changeset viewer.