VirtualBox

Ignore:
Timestamp:
Oct 8, 2018 12:51:07 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/ldr: Mach-O underscore kludge. bugref:9232

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/ldr/ldrMachO.cpp

    r74664 r74676  
    17481748    {
    17491749        /* simplify validation. */
    1750         if (cchStrings <= cchSymbol)
     1750        /** @todo figure out a better way to deal with underscore prefixes. sigh. */
     1751        if (cchStrings <= cchSymbol + 1)
    17511752            return VERR_SYMBOL_NOT_FOUND;
    1752         cchStrings -= cchSymbol;
     1753        cchStrings -= cchSymbol + 1;
    17531754
    17541755        /* external symbols are usually at the end, so search the other way. */
     
    17731774                continue;
    17741775            psz = &pchStrings[paSyms[iSymbol].n_un.n_strx];
    1775             if (psz[cchSymbol])
     1776            if (psz[cchSymbol + 1])
    17761777                continue;
    1777             if (memcmp(psz, pchSymbol, cchSymbol))
     1778            /** @todo figure out a better way to deal with underscore prefixes. sigh. */
     1779            if (*psz != '_' || memcmp(psz + 1, pchSymbol, cchSymbol))
    17781780                continue;
    17791781
     
    18761878    {
    18771879        /* simplify validation. */
    1878         if (cchStrings <= cchSymbol)
     1880        /** @todo figure out a better way to deal with underscore prefixes. sigh. */
     1881        if (cchStrings <= cchSymbol + 1)
    18791882            return VERR_SYMBOL_NOT_FOUND;
    1880         cchStrings -= cchSymbol;
     1883        cchStrings -= cchSymbol + 1;
    18811884
    18821885        /* external symbols are usually at the end, so search the other way. */
     
    19011904                continue;
    19021905            psz = &pchStrings[paSyms[iSymbol].n_un.n_strx];
    1903             if (psz[cchSymbol])
     1906            if (psz[cchSymbol + 1])
    19041907                continue;
    1905             if (memcmp(psz, pchSymbol, cchSymbol))
     1908            if (*psz != '_' || memcmp(psz + 1, pchSymbol, cchSymbol))
    19061909                continue;
    19071910
     
    21282131         * Do callback.
    21292132         */
     2133        /** @todo figure out a better way to deal with underscore prefixes. sigh. */
     2134        if (cch > 1 && *psz == '_')
     2135            psz++;
    21302136        rc = pfnCallback(&pThis->Core, psz, iSym, uValue/*, fKind*/, pvUser);
    21312137        if (rc != VINF_SUCCESS)
     
    22402246         * Do callback.
    22412247         */
     2248        /** @todo figure out a better way to deal with underscore prefixes. sigh. */
     2249        if (cch > 1 && *psz == '_')
     2250            psz++;
    22422251        rc = pfnCallback(&pThis->Core, psz, iSym, uValue/*, fKind*/, pvUser);
    22432252        if (rc != VINF_SUCCESS)
     
    26092618
    26102619                /* Ask the user for an address to the symbol. */
     2620                /** @todo figure out a better way to deal with underscore prefixes. sigh. */
    26112621                if (RT_FAILURE_NP(rc))
    2612                     rc = pfnGetImport(&pThis->Core, NULL /*pszModule*/, pszSymbol, iSym, &Value/*, &fKind*/, pvUser);
     2622                    rc = pfnGetImport(&pThis->Core, NULL /*pszModule*/, pszSymbol + (pszSymbol[0] == '_'),
     2623                                      UINT32_MAX, &Value/*, &fKind*/, pvUser);
    26132624                if (RT_FAILURE(rc))
    26142625                {
     
    26682679
    26692680                /* Ask the user for an address to the symbol. */
     2681                /** @todo figure out a better way to deal with underscore prefixes. sigh. */
    26702682                if (RT_FAILURE_NP(rc))
    2671                     rc = pfnGetImport(&pThis->Core, NULL, pszSymbol, iSym, &Value, /*&fKind,*/ pvUser);
     2683                    rc = pfnGetImport(&pThis->Core, NULL, pszSymbol + (*pszSymbol == '_'),
     2684                                      UINT32_MAX, &Value, /*&fKind,*/ pvUser);
    26722685                if (RT_FAILURE(rc))
    26732686                {
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