Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
20c4ae45
Commit
20c4ae45
authored
Mar 22, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add refcounting for .so builtin dlls.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
89340bb7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
18 deletions
+45
-18
loader.c
dlls/ntdll/unix/loader.c
+3
-1
unix_private.h
dlls/ntdll/unix/unix_private.h
+1
-0
virtual.c
dlls/ntdll/unix/virtual.c
+41
-17
No files found.
dlls/ntdll/unix/loader.c
View file @
20c4ae45
...
...
@@ -1456,7 +1456,9 @@ static void CDECL init_builtin_dll( void *module )
#endif
if
(
!
(
handle
=
get_builtin_so_handle
(
module
)))
return
;
if
(
dlinfo
(
handle
,
RTLD_DI_LINKMAP
,
&
map
))
return
;
if
(
dlinfo
(
handle
,
RTLD_DI_LINKMAP
,
&
map
))
map
=
NULL
;
release_builtin_module
(
module
);
if
(
!
map
)
return
;
for
(
dyn
=
map
->
l_ld
;
dyn
->
d_tag
;
dyn
++
)
{
...
...
dlls/ntdll/unix/unix_private.h
View file @
20c4ae45
...
...
@@ -202,6 +202,7 @@ extern void virtual_set_force_exec( BOOL enable ) DECLSPEC_HIDDEN;
extern
void
virtual_set_large_address_space
(
void
)
DECLSPEC_HIDDEN
;
extern
void
virtual_fill_image_information
(
const
pe_image_info_t
*
pe_info
,
SECTION_IMAGE_INFORMATION
*
info
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
release_builtin_module
(
void
*
module
)
DECLSPEC_HIDDEN
;
extern
void
*
get_builtin_so_handle
(
void
*
module
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
get_builtin_unix_info
(
void
*
module
,
const
char
**
name
,
void
**
handle
,
void
**
entry
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
set_builtin_unix_info
(
void
*
module
,
const
char
*
name
,
void
*
handle
,
void
*
entry
)
DECLSPEC_HIDDEN
;
...
...
dlls/ntdll/unix/virtual.c
View file @
20c4ae45
...
...
@@ -85,14 +85,15 @@ static struct list reserved_areas = LIST_INIT(reserved_areas);
struct
builtin_module
{
struct
list
entry
;
dev_t
dev
;
ino_t
ino
;
void
*
handle
;
void
*
module
;
char
*
unix_name
;
void
*
unix_handle
;
void
*
unix_entry
;
struct
list
entry
;
unsigned
int
refcount
;
dev_t
dev
;
ino_t
ino
;
void
*
handle
;
void
*
module
;
char
*
unix_name
;
void
*
unix_handle
;
void
*
unix_entry
;
};
static
struct
list
builtin_modules
=
LIST_INIT
(
builtin_modules
);
...
...
@@ -569,8 +570,9 @@ static void add_builtin_module( void *module, void *handle, const struct stat *s
struct
builtin_module
*
builtin
;
if
(
!
(
builtin
=
malloc
(
sizeof
(
*
builtin
)
)))
return
;
builtin
->
handle
=
handle
;
builtin
->
module
=
module
;
builtin
->
handle
=
handle
;
builtin
->
module
=
module
;
builtin
->
refcount
=
1
;
builtin
->
unix_name
=
NULL
;
builtin
->
unix_handle
=
NULL
;
builtin
->
unix_entry
=
NULL
;
...
...
@@ -589,19 +591,23 @@ static void add_builtin_module( void *module, void *handle, const struct stat *s
/***********************************************************************
* re
mov
e_builtin_module
* re
leas
e_builtin_module
*/
static
NTSTATUS
remov
e_builtin_module
(
void
*
module
)
NTSTATUS
releas
e_builtin_module
(
void
*
module
)
{
struct
builtin_module
*
builtin
;
LIST_FOR_EACH_ENTRY
(
builtin
,
&
builtin_modules
,
struct
builtin_module
,
entry
)
{
if
(
builtin
->
module
!=
module
)
continue
;
list_remove
(
&
builtin
->
entry
);
if
(
builtin
->
handle
)
dlclose
(
builtin
->
handle
);
if
(
builtin
->
unix_handle
)
dlclose
(
builtin
->
unix_handle
);
free
(
builtin
);
if
(
!--
builtin
->
refcount
)
{
list_remove
(
&
builtin
->
entry
);
if
(
builtin
->
handle
)
dlclose
(
builtin
->
handle
);
if
(
builtin
->
unix_handle
)
dlclose
(
builtin
->
unix_handle
);
free
(
builtin
->
unix_name
);
free
(
builtin
);
}
return
STATUS_SUCCESS
;
}
return
STATUS_INVALID_PARAMETER
;
...
...
@@ -635,6 +641,7 @@ void *get_builtin_so_handle( void *module )
{
if
(
builtin
->
module
!=
module
)
continue
;
ret
=
builtin
->
handle
;
if
(
ret
)
builtin
->
refcount
++
;
break
;
}
server_leave_uninterrupted_section
(
&
virtual_mutex
,
&
sigset
);
...
...
@@ -4374,6 +4381,23 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
server_enter_uninterrupted_section
(
&
virtual_mutex
,
&
sigset
);
if
((
view
=
find_view
(
addr
,
0
))
&&
!
is_view_valloc
(
view
))
{
if
(
view
->
protect
&
VPROT_SYSTEM
)
{
struct
builtin_module
*
builtin
;
LIST_FOR_EACH_ENTRY
(
builtin
,
&
builtin_modules
,
struct
builtin_module
,
entry
)
{
if
(
builtin
->
module
!=
view
->
base
)
continue
;
if
(
builtin
->
refcount
>
1
)
{
TRACE
(
"not freeing in-use builtin %p
\n
"
,
view
->
base
);
builtin
->
refcount
--
;
server_leave_uninterrupted_section
(
&
virtual_mutex
,
&
sigset
);
return
STATUS_SUCCESS
;
}
}
}
SERVER_START_REQ
(
unmap_view
)
{
req
->
base
=
wine_server_client_ptr
(
view
->
base
);
...
...
@@ -4382,7 +4406,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
SERVER_END_REQ
;
if
(
!
status
)
{
if
(
view
->
protect
&
SEC_IMAGE
)
re
mov
e_builtin_module
(
view
->
base
);
if
(
view
->
protect
&
SEC_IMAGE
)
re
leas
e_builtin_module
(
view
->
base
);
delete_view
(
view
);
}
else
FIXME
(
"failed to unmap %p %x
\n
"
,
view
->
base
,
status
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment