Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
853e795d
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
853e795d
编写于
8月 23, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 23, 2023
浏览文件
操作
浏览文件
下载
差异文件
!1027 Fix weak symbol dlclose
Merge pull request !1027 from guzhihao4/fix_weak_dlclose
上级
f147aa58
711283b6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
62 addition
and
4 deletion
+62
-4
libc-test/src/functional/BUILD.gn
libc-test/src/functional/BUILD.gn
+7
-0
libc-test/src/functional/dlopen.c
libc-test/src/functional/dlopen.c
+18
-0
libc-test/src/functional/dlopen_weak.c
libc-test/src/functional/dlopen_weak.c
+11
-0
libc-test/src/functional/dlopen_weak_deps.c
libc-test/src/functional/dlopen_weak_deps.c
+9
-0
libc-test/src/functional/dlopen_weak_deps.h
libc-test/src/functional/dlopen_weak_deps.h
+2
-0
porting/linux/user/ldso/dynlink.c
porting/linux/user/ldso/dynlink.c
+15
-4
未找到文件。
libc-test/src/functional/BUILD.gn
浏览文件 @
853e795d
...
...
@@ -39,6 +39,11 @@ test_sharedlib("tls_align_dso") {
}
test_sharedlib("atexit_dlclose_dso") {
}
test_sharedlib("dlopen_weak_deps") {
}
test_sharedlib("dlopen_weak") {
deps = [ ":dlopen_weak_deps" ]
}
group("dso_shared") {
testonly = true
...
...
@@ -51,6 +56,8 @@ group("dso_shared") {
":dlopen_for_load_by_local_dso",
":dlopen_ns_dso",
":dlopen_so_dep_dlopen_ns_dso",
":dlopen_weak",
":dlopen_weak_deps",
":tls_align_dso",
":tls_init_dso",
]
...
...
libc-test/src/functional/dlopen.c
浏览文件 @
853e795d
...
...
@@ -121,6 +121,23 @@ void dlopen_dlclose()
}
}
#define DLOPEN_WEAK "libdlopen_weak.so"
typedef
int
(
*
FuncPtr_TestNumber
)(
int
input
);
void
dlopen_dlclose_weak
()
{
void
*
handle
=
dlopen
(
DLOPEN_WEAK
,
RTLD_LAZY
|
RTLD_GLOBAL
);
if
(
!
handle
)
t_error
(
"dlopen(name=%s, mode=%d) failed: %s
\n
"
,
DLOPEN_WEAK
,
RTLD_LAZY
|
RTLD_GLOBAL
,
dlerror
());
FuncPtr_TestNumber
fn
=
(
FuncPtr_TestNumber
)
dlsym
(
handle
,
"TestNumber"
);
if
(
fn
)
{
int
ret
=
fn
(
12
);
if
(
ret
!=
0
)
t_error
(
"weak symbol relocation error: so_name: %s, symbol: TestNumber
\n
"
,
DLOPEN_WEAK
);
}
dlclose
(
handle
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
void
*
h
,
*
g
;
...
...
@@ -179,6 +196,7 @@ int main(int argc, char *argv[])
dlopen_so_used_by_dlsym
();
dlopen_nodelete_and_noload
();
dlopen_dlclose
();
dlopen_dlclose_weak
();
return
t_status
;
}
libc-test/src/functional/dlopen_weak.c
0 → 100644
浏览文件 @
853e795d
#include "dlopen_weak_deps.h"
__attribute__
((
weak
))
int
TestFunction
(
int
input
)
{
return
input
%
2
;
}
int
TestNumber
(
int
input
)
{
return
TestNumber2
(
input
);
}
libc-test/src/functional/dlopen_weak_deps.c
0 → 100644
浏览文件 @
853e795d
__attribute__
((
weak
))
int
TestFunction
(
int
input
)
{
return
input
%
5
;
}
int
TestNumber2
(
int
input
)
{
return
TestFunction
(
input
)
==
2
;
}
libc-test/src/functional/dlopen_weak_deps.h
0 → 100644
浏览文件 @
853e795d
int
TestNumber2
(
int
input
);
__attribute__
((
weak
))
int
TestFunction
(
int
input
);
porting/linux/user/ldso/dynlink.c
浏览文件 @
853e795d
...
...
@@ -3754,7 +3754,7 @@ static void *do_dlsym(struct dso *p, const char *s, const char *v, void *ra)
extern
int
invalidate_exit_funcs
(
struct
dso
*
p
);
static
int
dlclose_impl
(
struct
dso
*
p
)
static
int
dlclose_impl
(
struct
dso
*
p
,
struct
dso
**
dso_close_list
,
int
*
dso_close_list_size
)
{
size_t
n
;
struct
dso
*
d
;
...
...
@@ -3864,7 +3864,9 @@ static int dlclose_impl(struct dso *p)
if
(
p
->
deps
!=
no_deps
)
free
(
p
->
deps
);
LD_LOGD
(
"dlclose unloading %{public}s @%{public}p"
,
p
->
name
,
p
);
unmap_library
(
p
);
dso_close_list
[
*
dso_close_list_size
]
=
p
;
*
dso_close_list_size
+=
1
;
if
(
p
->
parents
)
{
free
(
p
->
parents
);
...
...
@@ -3906,16 +3908,25 @@ static int do_dlclose(struct dso *p)
memcpy
(
deps_bak
,
p
->
deps
,
deps_num
*
sizeof
(
struct
dso
*
));
}
struct
dso
**
dso_close_list
=
malloc
((
deps_num
+
1
)
*
sizeof
(
struct
dso
*
));
memset
(
dso_close_list
,
0
,
deps_num
+
1
);
int
dso_close_list_size
=
0
;
LD_LOGI
(
"do_dlclose name=%{public}s count=%{public}d by_dlopen=%{public}d"
,
p
->
name
,
p
->
nr_dlopen
,
p
->
by_dlopen
);
dlclose_impl
(
p
);
dlclose_impl
(
p
,
dso_close_list
,
&
dso_close_list_size
);
if
(
ldclose_deps
)
{
for
(
size_t
i
=
0
;
i
<
deps_num
;
i
++
)
{
LD_LOGI
(
"do_dlclose name=%{public}s count=%{public}d by_dlopen=%{public}d"
,
deps_bak
[
i
]
->
name
,
deps_bak
[
i
]
->
nr_dlopen
,
deps_bak
[
i
]
->
by_dlopen
);
dlclose_impl
(
deps_bak
[
i
]);
dlclose_impl
(
deps_bak
[
i
]
,
dso_close_list
,
&
dso_close_list_size
);
}
}
for
(
size_t
i
=
0
;
i
<
dso_close_list_size
;
i
++
)
{
unmap_library
(
dso_close_list
[
i
]);
}
free
(
dso_close_list
);
free
(
deps_bak
);
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录