Change wine's dlopen search-patch strategy not using the environment
and added #if:s to seperate the code out if libdl isn't availble.
This commit is contained in:
parent
9bf93c6e19
commit
3b5c29f539
|
@ -4,6 +4,12 @@
|
|||
WINE_MODREF *ELFDLL_LoadLibraryExA(LPCSTR libname, DWORD flags, DWORD *err);
|
||||
HINSTANCE16 ELFDLL_LoadModule16(LPCSTR libname, BOOL implicit);
|
||||
void ELFDLL_UnloadLibrary(WINE_MODREF *wm);
|
||||
|
||||
#if defined(HAVE_LIBDL) && defined(HAVE_DLFCN_H)
|
||||
|
||||
void *ELFDLL_dlopen(const char *libname, int flags);
|
||||
extern char *extra_ld_library_path;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,19 +21,16 @@
|
|||
#include "winerror.h"
|
||||
|
||||
DECLARE_DEBUG_CHANNEL(elfdll)
|
||||
DECLARE_DEBUG_CHANNEL(win32)
|
||||
|
||||
#if defined(HAVE_LIBDL) && defined(HAVE_DLFCN_H)
|
||||
#include <dlfcn.h>
|
||||
|
||||
/*------------------ HACKS -----------------*/
|
||||
#ifndef elfdll
|
||||
#define elfdll win32
|
||||
#endif
|
||||
|
||||
extern DWORD fixup_imports(WINE_MODREF *wm);
|
||||
/*---------------- END HACKS ---------------*/
|
||||
|
||||
char *extra_ld_library_path = NULL; /* The extra search-path set in wine.conf */
|
||||
|
||||
struct elfdll_image
|
||||
{
|
||||
HMODULE pe_module_start;
|
||||
|
@ -46,28 +43,30 @@ struct elfdll_image
|
|||
/****************************************************************************
|
||||
* ELFDLL_dlopen
|
||||
*
|
||||
* Wrapper for dlopen to search the LD_LIBRARY_PATH manually because
|
||||
* libdl.so caches the environment and does not accept our changes.
|
||||
* Wrapper for dlopen to search the EXTRA_LD_LIBRARY_PATH from wine.conf
|
||||
* manually because libdl.so caches the environment and does not accept our
|
||||
* changes.
|
||||
*/
|
||||
void *ELFDLL_dlopen(const char *libname, int flags)
|
||||
{
|
||||
char *ldpath = getenv("LD_LIBRARY_PATH");
|
||||
char buffer[256];
|
||||
int namelen;
|
||||
void *handle;
|
||||
char *ldpath;
|
||||
|
||||
if(!ldpath)
|
||||
{
|
||||
WARN(elfdll, "No LD_LIBRARY_PATH set\n");
|
||||
return dlopen(libname, flags);
|
||||
}
|
||||
/* First try the default path search of dlopen() */
|
||||
handle = dlopen(libname, flags);
|
||||
if(handle)
|
||||
return handle;
|
||||
|
||||
/* Now try to construct searches through our extra search-path */
|
||||
namelen = strlen(libname);
|
||||
while(ldpath)
|
||||
ldpath = extra_ld_library_path;
|
||||
while(ldpath && *ldpath)
|
||||
{
|
||||
int len;
|
||||
char *cptr;
|
||||
char *from;
|
||||
void *handle;
|
||||
|
||||
from = ldpath;
|
||||
cptr = strchr(ldpath, ':');
|
||||
|
@ -84,7 +83,7 @@ void *ELFDLL_dlopen(const char *libname, int flags)
|
|||
|
||||
if(len + namelen + 1 >= sizeof(buffer))
|
||||
{
|
||||
ERR(elfdll, "Buffer overflow! Check LD_LIBRARY_PATH or increase buffer size.\n");
|
||||
ERR(elfdll, "Buffer overflow! Check EXTRA_LD_LIBRARY_PATH or increase buffer size.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -207,7 +206,7 @@ static WINE_MODREF *ELFDLL_CreateModref(HMODULE hModule, LPCSTR path)
|
|||
if(!(nt->FileHeader.Characteristics & IMAGE_FILE_DLL))
|
||||
{
|
||||
if(PROCESS_Current()->exe_modref)
|
||||
FIXME(win32, "overwriting old exe_modref... arrgh\n");
|
||||
FIXME(elfdll, "overwriting old exe_modref... arrgh\n");
|
||||
PROCESS_Current()->exe_modref = wm;
|
||||
}
|
||||
|
||||
|
@ -227,7 +226,7 @@ static WINE_MODREF *ELFDLL_CreateModref(HMODULE hModule, LPCSTR path)
|
|||
}
|
||||
}
|
||||
if(wm == PROCESS_Current()->exe_modref)
|
||||
ERR(win32, "Have to delete current exe_modref. Expect crash now\n");
|
||||
ERR(elfdll, "Have to delete current exe_modref. Expect crash now\n");
|
||||
HeapFree(procheap, 0, wm->shortname);
|
||||
HeapFree(procheap, 0, wm->longname);
|
||||
HeapFree(procheap, 0, wm->modname);
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "windef.h"
|
||||
#include "options.h"
|
||||
#include "debug.h"
|
||||
#include "loadorder.h"
|
||||
#include "heap.h"
|
||||
#include "options.h"
|
||||
#include "module.h"
|
||||
#include "elfdll.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(module)
|
||||
|
||||
|
@ -330,26 +333,16 @@ BOOL MODULE_InitLoadOrder(void)
|
|||
char buffer[BUFFERSIZE];
|
||||
int nbuffer;
|
||||
|
||||
#if defined(HAVE_LIBDL) && defined(HAVE_DLFCN_H)
|
||||
/* Get/set the new LD_LIBRARY_PATH */
|
||||
nbuffer = PROFILE_GetWineIniString("DllDefaults", "EXTRA_LD_LIBRARY_PATH", "", buffer, sizeof(buffer));
|
||||
|
||||
if(nbuffer)
|
||||
{
|
||||
char *ld_lib_path = getenv("LD_LIBRARY_PATH");
|
||||
if(ld_lib_path)
|
||||
{
|
||||
/*
|
||||
* Append new path to current
|
||||
*/
|
||||
char *tmp = HEAP_strdupA(SystemHeap, 0, buffer);
|
||||
sprintf(buffer, "LD_LIBRARY_PATH=%s:%s", ld_lib_path, tmp);
|
||||
HeapFree( SystemHeap, 0, tmp );
|
||||
}
|
||||
|
||||
TRACE(module, "Setting new LD_LIBRARY_PATH=%s\n", buffer);
|
||||
|
||||
putenv(buffer);
|
||||
extra_ld_library_path = HEAP_strdupA(SystemHeap, 0, buffer);
|
||||
TRACE(module, "Setting extra LD_LIBRARY_PATH=%s\n", buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get the default load order */
|
||||
nbuffer = PROFILE_GetWineIniString("DllDefaults", "DefaultLoadOrder", "n,e,s,b", buffer, sizeof(buffer));
|
||||
|
|
Loading…
Reference in New Issue