Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
c2bfac38
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c2bfac38
编写于
7月 22, 2022
作者:
W
wangjiahui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix dlopen ld-musl-aarch64.so.1 error
Signed-off-by:
N
wangjiahui
<
wangjiahui27@huawei.com
>
上级
bfeda6a1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
16 deletion
+68
-16
libc-test/src/functionalext/ldso_randomization/ldso_randomization_test.c
...unctionalext/ldso_randomization/ldso_randomization_test.c
+39
-1
porting/linux/user/ldso/dynlink.c
porting/linux/user/ldso/dynlink.c
+29
-15
未找到文件。
libc-test/src/functionalext/ldso_randomization/ldso_randomization_test.c
浏览文件 @
c2bfac38
...
...
@@ -25,7 +25,7 @@
#include "functionalext.h"
#define PIPE_FD 2
#define
NUM_OF_BYTE
8
#define
LEN_OF_POINTER
8
#define BASE_NUM 11
#define TEST_COUNTS 32
...
...
@@ -561,6 +561,42 @@ static void dlclose_randomization_0100(void)
EXPECT_EQ
(
__FUNCTION__
,
-
1
,
ret
);
}
/**
* @tc.name : dlopen_randomization_0800
* @tc.desc : Call the dlopen interface to load libc.so
* @tc.level : Level1
*/
static
void
dlopen_randomization_0800
(
void
)
{
if
(
sizeof
(
void
*
)
==
LEN_OF_POINTER
)
{
system
(
"cp /system/lib64/libc.so ."
);
}
else
{
system
(
"cp /system/lib/libc.so ."
);
}
void
*
handle
=
dlopen
(
"./libc.so"
,
RTLD_NOW
);
EXPECT_PTRNE
(
__FUNCTION__
,
handle
,
0
);
system
(
"rm ./libc.so"
);
}
/**
* @tc.name : dlopen_randomization_0900
* @tc.desc : Call the dlopen interface to load ld.so
* @tc.level : Level1
*/
static
void
dlopen_randomization_0900
(
void
)
{
void
*
handle
=
NULL
;
if
(
sizeof
(
void
*
)
==
LEN_OF_POINTER
)
{
system
(
"cp /system/lib/ld-musl-aarch64.so.1 ."
);
handle
=
dlopen
(
"./ld-musl-aarch64.so.1"
,
RTLD_NOW
);
system
(
"rm ld-musl-aarch64.so.1"
);
}
else
{
system
(
"cp /system/lib/ld-musl-arm.so.1 ."
);
handle
=
dlopen
(
"./ld-musl-arm.so.1"
,
RTLD_NOW
);
system
(
"rm ./ld-musl-arm.so.1"
);
}
EXPECT_PTRNE
(
__FUNCTION__
,
handle
,
0
);
}
TEST_FUNC
test_cases
[]
=
{
dlopen_randomization_0100
,
...
...
@@ -586,6 +622,8 @@ TEST_FUNC test_cases[] = {
dlsym_randomization_0600
,
dlsym_randomization_0700
,
dlclose_randomization_0100
,
dlopen_randomization_0800
,
dlopen_randomization_0900
,
};
int
main
(
int
argc
,
char
*
argv
[])
...
...
porting/linux/user/ldso/dynlink.c
浏览文件 @
c2bfac38
...
...
@@ -2397,6 +2397,7 @@ static void *dlopen_impl(
#ifdef LOAD_ORDER_RANDOMIZATION
struct
loadtasks
*
tasks
=
NULL
;
struct
loadtask
*
task
=
NULL
;
bool
is_task_appended
=
false
;
#endif
if
(
!
file
)
{
...
...
@@ -2498,42 +2499,47 @@ static void *dlopen_impl(
file
);
goto
end
;
}
p
=
task
->
p
;
if
(
reserved_address
)
{
reserved_params
.
target
=
p
;
reserved_params
.
target
=
task
->
p
;
}
#else
p
=
load_library
(
file
,
head
,
ns
,
true
,
reserved_address
?
&
reserved_params
:
NULL
);
#endif
}
if
(
!
p
)
{
if
(
!
task
->
p
)
{
error
(
noload
?
"Library %s is not already loaded"
:
"Error loading shared library %s: %m"
,
file
);
goto
end
;
}
#ifdef LOAD_ORDER_RANDOMIZATION
if
(
!
task
->
isloaded
)
{
append_loadtasks
(
tasks
,
task
);
is_task_appended
=
append_loadtasks
(
tasks
,
task
);
}
preload_deps
(
p
,
ns
,
tasks
);
preload_deps
(
task
->
p
,
ns
,
tasks
);
unmap_preloaded_sections
(
tasks
);
if
(
!
reserved_address_recursive
)
{
shuffle_loadtasks
(
tasks
);
}
run_loadtasks
(
tasks
,
reserved_address
?
&
reserved_params
:
NULL
);
p
=
task
->
p
;
if
(
!
task
->
isloaded
)
{
assign_tls
(
p
);
}
else
{
}
if
(
!
is_task_appended
)
{
free_task
(
task
);
task
=
NULL
;
}
free_loadtasks
(
tasks
);
tasks
=
NULL
;
#else
p
=
load_library
(
file
,
head
,
ns
,
true
,
reserved_address
?
&
reserved_params
:
NULL
);
}
if
(
!
p
)
{
error
(
noload
?
"Library %s is not already loaded"
:
"Error loading shared library %s: %m"
,
file
);
goto
end
;
}
/* First load handling */
load_deps
(
p
,
ns
,
reserved_address
&&
reserved_address_recursive
?
&
reserved_params
:
NULL
);
#endif
...
...
@@ -2588,8 +2594,10 @@ static void *dlopen_impl(
#endif
end
:
#ifdef LOAD_ORDER_RANDOMIZATION
if
(
!
is_task_appended
)
{
free_task
(
task
);
}
free_loadtasks
(
tasks
);
tasks
=
NULL
;
#endif
__release_ptc
();
if
(
p
)
gencnt
++
;
...
...
@@ -3704,11 +3712,17 @@ static void task_load_library(struct loadtask *task, struct reserved_address_par
decode_dyn
(
task
->
p
);
if
(
find_sym
(
task
->
p
,
"__libc_start_main"
,
1
).
sym
&&
find_sym
(
task
->
p
,
"stdin"
,
1
).
sym
)
{
unmap_library
(
task
->
p
);
do_dlclose
(
task
->
p
);
task
->
p
=
NULL
;
free
((
void
*
)
task
->
name
);
task
->
name
=
strdup
(
"libc.so"
);
task
->
check_inherited
=
true
;
load_library_header
(
task
);
if
(
!
load_library_header
(
task
))
{
error
(
"Error loading library %s: failed to load libc.so"
,
task
->
name
);
if
(
runtime
)
{
longjmp
(
*
rtld_fail
,
1
);
}
}
return
;
}
/* Past this point, if we haven't reached runtime yet, ldso has
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录