Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Johnny Cai
wine
Commits
94bb5bb1
Commit
94bb5bb1
authored
25 years ago
by
Bertho Stultiens
Committed by
Alexandre Julliard
25 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Removed non-portable hacks and replaced them with more general
versions.
parent
0e8d8cc9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/elfdll.h
+1
-0
1 addition, 0 deletions
include/elfdll.h
loader/elf.c
+2
-1
2 additions, 1 deletion
loader/elf.c
loader/elfdll.c
+67
-5
67 additions, 5 deletions
loader/elfdll.c
loader/loadorder.c
+3
-13
3 additions, 13 deletions
loader/loadorder.c
with
73 additions
and
19 deletions
include/elfdll.h
+
1
−
0
View file @
94bb5bb1
...
...
@@ -4,5 +4,6 @@
WINE_MODREF
*
ELFDLL_LoadLibraryExA
(
LPCSTR
libname
,
DWORD
flags
,
DWORD
*
err
);
HINSTANCE16
ELFDLL_LoadModule16
(
LPCSTR
libname
,
BOOL
implicit
);
void
ELFDLL_UnloadLibrary
(
WINE_MODREF
*
wm
);
void
*
ELFDLL_dlopen
(
const
char
*
libname
,
int
flags
);
#endif
This diff is collapsed.
Click to expand it.
loader/elf.c
+
2
−
1
View file @
94bb5bb1
...
...
@@ -25,6 +25,7 @@
#include
"pe_image.h"
#include
"debug.h"
#include
"winerror.h"
#include
"elfdll.h"
DEFAULT_DEBUG_CHANNEL
(
win32
)
...
...
@@ -138,7 +139,7 @@ WINE_MODREF *ELF_LoadLibraryExA( LPCSTR libname, DWORD flags, DWORD *err)
/* FIXME: make UNIX filename from DOS fn? */
/* ... and open it */
dlhandle
=
dlopen
(
t
,
RTLD_NOW
);
dlhandle
=
ELFDLL_
dlopen
(
t
,
RTLD_NOW
);
if
(
!
dlhandle
)
{
HeapFree
(
GetProcessHeap
(),
0
,
t
);
*
err
=
ERROR_FILE_NOT_FOUND
;
...
...
This diff is collapsed.
Click to expand it.
loader/elfdll.c
+
67
−
5
View file @
94bb5bb1
...
...
@@ -6,6 +6,7 @@
#include
<string.h>
#include
<ctype.h>
#include
<stdlib.h>
#include
"config.h"
#include
"windef.h"
...
...
@@ -42,6 +43,70 @@ 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.
*/
void
*
ELFDLL_dlopen
(
const
char
*
libname
,
int
flags
)
{
char
*
ldpath
=
getenv
(
"LD_LIBRARY_PATH"
);
char
buffer
[
256
];
int
namelen
;
if
(
!
ldpath
)
{
WARN
(
elfdll
,
"No LD_LIBRARY_PATH set
\n
"
);
return
dlopen
(
libname
,
flags
);
}
namelen
=
strlen
(
libname
);
while
(
ldpath
)
{
int
len
;
char
*
cptr
;
char
*
from
;
void
*
handle
;
from
=
ldpath
;
cptr
=
strchr
(
ldpath
,
':'
);
if
(
!
cptr
)
{
len
=
strlen
(
ldpath
);
ldpath
=
NULL
;
}
else
{
len
=
cptr
-
ldpath
;
ldpath
=
cptr
+
1
;
}
if
(
len
+
namelen
+
1
>=
sizeof
(
buffer
))
{
ERR
(
elfdll
,
"Buffer overflow! Check LD_LIBRARY_PATH or increase buffer size.
\n
"
);
return
NULL
;
}
strncpy
(
buffer
,
from
,
len
);
if
(
len
)
{
buffer
[
len
]
=
'/'
;
strcpy
(
buffer
+
len
+
1
,
libname
);
}
else
strcpy
(
buffer
+
len
,
libname
);
TRACE
(
elfdll
,
"Trying dlopen('%s', %d)
\n
"
,
buffer
,
flags
);
handle
=
dlopen
(
buffer
,
flags
);
if
(
handle
)
return
handle
;
}
return
NULL
;
}
/****************************************************************************
* get_sobasename (internal)
*
...
...
@@ -221,11 +286,8 @@ WINE_MODREF *ELFDLL_LoadLibraryExA(LPCSTR path, DWORD flags, DWORD *err)
strcpy
(
soname
,
name
);
strcat
(
soname
,
".so"
);
/* Try to open the elf-dll.
* The dlopen will search the correct path and our extended
* LD_LIBRARY as well.
*/
dlhandle
=
dlopen
(
soname
,
RTLD_LAZY
);
/* Try to open the elf-dll */
dlhandle
=
ELFDLL_dlopen
(
soname
,
RTLD_LAZY
);
if
(
!
dlhandle
)
{
WARN
(
elfdll
,
"Could not load %s (%s)
\n
"
,
soname
,
dlerror
());
...
...
This diff is collapsed.
Click to expand it.
loader/loadorder.c
+
3
−
13
View file @
94bb5bb1
...
...
@@ -50,7 +50,7 @@ static char *get_tok(const char *str, const char *delim)
static
char
*
buf
=
NULL
;
char
*
cptr
;
if
(
!
str
&&
(
!
buf
||
!
index
)
)
if
(
!
str
&&
!
buf
)
return
NULL
;
if
(
str
&&
buf
)
...
...
@@ -335,7 +335,6 @@ BOOL MODULE_InitLoadOrder(void)
if
(
nbuffer
)
{
extern
char
*
_dl_library_path
;
char
*
ld_lib_path
=
getenv
(
"LD_LIBRARY_PATH"
);
if
(
ld_lib_path
)
{
...
...
@@ -343,22 +342,13 @@ BOOL MODULE_InitLoadOrder(void)
* Append new path to current
*/
char
*
tmp
=
HEAP_strdupA
(
SystemHeap
,
0
,
buffer
);
sprintf
(
buffer
,
"%s:%s"
,
ld_lib_path
,
tmp
);
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
);
setenv
(
"LD_LIBRARY_PATH"
,
buffer
,
1
);
/*
* This is a cruel hack required to have libdl check this path.
* The problem is that libdl caches the environment variable
* and we won't get our modifications applied. We ensure the
* the correct search path by explicitely modifying the libdl
* internal variable which holds the path.
*/
_dl_library_path
=
HEAP_strdupA
(
SystemHeap
,
0
,
buffer
);
putenv
(
buffer
);
}
/* Get the default load order */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment