From 361589e3ae692db27161410309b92c6b89e1ec6c Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 2 Jan 2011 10:58:34 +0100 Subject: Imported Upstream version 4.0.0-dfsg --- src/VBox/Runtime/r3/posix/ldrNative-posix.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/VBox/Runtime/r3/posix/ldrNative-posix.cpp') diff --git a/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp b/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp index f146f0d6a..62cc939d8 100644 --- a/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp +++ b/src/VBox/Runtime/r3/posix/ldrNative-posix.cpp @@ -1,4 +1,4 @@ -/* $Id: ldrNative-posix.cpp $ */ +/* $Id: ldrNative-posix.cpp 35191 2010-12-16 15:25:20Z vboxsync $ */ /** @file * IPRT - Binary Image Loader, POSIX native. */ @@ -40,7 +40,7 @@ #include "internal/ldr.h" -int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle) +int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle, uint32_t fFlags, PRTERRINFO pErrInfo) { /* * Do we need to add an extension? @@ -59,7 +59,7 @@ int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle) size_t cch = strlen(pszFilename); char *psz = (char *)alloca(cch + sizeof(s_szSuff)); if (!psz) - return VERR_NO_MEMORY; + return RTErrInfoSet(pErrInfo, VERR_NO_MEMORY, "alloca failed"); memcpy(psz, pszFilename, cch); memcpy(psz + cch, s_szSuff, sizeof(s_szSuff)); pszFilename = psz; @@ -68,14 +68,21 @@ int rtldrNativeLoad(const char *pszFilename, uintptr_t *phHandle) /* * Attempt load. */ - - void *pvMod = dlopen(pszFilename, RTLD_NOW | RTLD_LOCAL); + int fFlagsNative = RTLD_NOW; + if (fFlags & RTLDRLOAD_FLAGS_GLOBAL) + fFlagsNative |= RTLD_GLOBAL; + else + fFlagsNative |= RTLD_LOCAL; + void *pvMod = dlopen(pszFilename, fFlagsNative); if (pvMod) { *phHandle = (uintptr_t)pvMod; return VINF_SUCCESS; } - LogRel(("rtldrNativeLoad: dlopen('%s', RTLD_NOW | RTLD_LOCAL) failed: %s\n", pszFilename, dlerror())); + + const char *pszDlError = dlerror(); + RTErrInfoSet(pErrInfo, VERR_FILE_NOT_FOUND, pszDlError); + LogRel(("rtldrNativeLoad: dlopen('%s', RTLD_NOW | RTLD_LOCAL) failed: %s\n", pszFilename, pszDlError)); return VERR_FILE_NOT_FOUND; } -- cgit v1.2.3