VirtualBox

Changeset 79003 in vbox


Ignore:
Timestamp:
Jun 5, 2019 3:49:08 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131144
Message:

IPRT: Implemented rtldrNativeLoadSystem for posix systems. bugref:8352 ticketref:18682

Location:
trunk/src/VBox/Runtime
Files:
2 edited

Legend:

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

    r76553 r79003  
    196196    AssertMsgReturn(cchFilename < (RTPATH_MAX / 4) * 3, ("%zu\n", cchFilename), VERR_INVALID_PARAMETER);
    197197
    198     const char *pszSuffix = "";
     198    const char *pszSuffix = NULL;
    199199    if (!RTPathHasSuffix(pszFilename))
    200200        pszSuffix = RTLdrGetSuff();
  • trunk/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp

    r76553 r79003  
    4242
    4343
     44/*********************************************************************************************************************************
     45*   Global Variables                                                                                                             *
     46*********************************************************************************************************************************/
     47#if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
     48static const char g_szSuff[] = ".DLL";
     49#elif defined(RT_OS_L4)
     50static const char g_szSuff[] = ".s.so";
     51#elif defined(RT_OS_DARWIN)
     52static const char g_szSuff[] = ".dylib";
     53#else
     54static const char g_szSuff[] = ".so";
     55#endif
     56
     57
    4458DECLHIDDEN(int) rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo)
    4559{
     
    4963    if (!RTPathHasSuffix(pszFilename) && !(fFlags & RTLDRLOAD_FLAGS_NO_SUFFIX))
    5064    {
    51 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
    52         static const char s_szSuff[] = ".DLL";
    53 #elif defined(RT_OS_L4)
    54         static const char s_szSuff[] = ".s.so";
    55 #elif defined(RT_OS_DARWIN)
    56         static const char s_szSuff[] = ".dylib";
    57 #else
    58         static const char s_szSuff[] = ".so";
    59 #endif
    6065        size_t cch = strlen(pszFilename);
    61         char *psz = (char *)alloca(cch + sizeof(s_szSuff));
     66        char *psz = (char *)alloca(cch + sizeof(g_szSuff));
    6267        if (!psz)
    6368            return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed");
    6469        memcpy(psz, pszFilename, cch);
    65         memcpy(psz + cch, s_szSuff, sizeof(s_szSuff));
     70        memcpy(psz + cch, g_szSuff, sizeof(g_szSuff));
    6671        pszFilename = psz;
    6772    }
     
    128133DECLHIDDEN(int) rtldrNativeLoadSystem(const char *pszFilename, const char *pszExt, uint32_t fFlags, PRTLDRMOD phLdrMod)
    129134{
    130     RT_NOREF_PV(pszFilename); RT_NOREF_PV(pszExt); RT_NOREF_PV(fFlags); RT_NOREF_PV(phLdrMod);
    131     /** @todo implement this in some sensible fashion. */
    132     return VERR_NOT_SUPPORTED;
     135    /*
     136     * For the present we ASSUME that we can trust dlopen to load what we want
     137     * when not specifying a path.  There seems to be very little we can do to
     138     * restrict the places dlopen will search for library without doing
     139     * auditing (linux) or something like that.
     140     */
     141    Assert(strchr(pszFilename, '/') == NULL);
     142
     143    /* Easy if suffix was included. */
     144    if (!pszExt)
     145        return RTLdrLoadEx(pszFilename, phLdrMod, fFlags, NULL);
     146
     147    /* Combine filename and suffix and then do the loading. */
     148    size_t const cchFilename = strlen(pszFilename);
     149    size_t const cchSuffix   = strlen(pszExt);
     150    char *pszTmp = (char *)alloca(cchFilename + cchSuffix + 1);
     151    memcpy(pszTmp, pszFilename, cchFilename);
     152    memcpy(&pszTmp[cchFilename], pszExt, cchSuffix);
     153    pszTmp[cchFilename + cchSuffix] = '\0';
     154
     155    return RTLdrLoadEx(pszTmp, phLdrMod, fFlags, NULL);
    133156}
    134157
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