Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
11277cdf
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看板
未验证
提交
11277cdf
编写于
9月 08, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 08, 2022
浏览文件
操作
浏览文件
下载
差异文件
!524 修复symbol version问题(20220816分支)
Merge pull request !524 from dhy308/cherry-pick-1662544127
上级
6b0f2293
d13af198
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
148 addition
and
39 deletion
+148
-39
libc-test/src/functionalext/symver/BUILD.gn
libc-test/src/functionalext/symver/BUILD.gn
+8
-0
libc-test/src/functionalext/symver/reloc_symver.c
libc-test/src/functionalext/symver/reloc_symver.c
+50
-0
libc-test/src/functionalext/symver/reloc_symver_dso.c
libc-test/src/functionalext/symver/reloc_symver_dso.c
+23
-0
libc-test/src/functionalext/symver/test_src_functionalext_symver.gni
...rc/functionalext/symver/test_src_functionalext_symver.gni
+1
-0
libc-test/test_template.gni
libc-test/test_template.gni
+4
-0
porting/linux/user/ldso/dynlink.c
porting/linux/user/ldso/dynlink.c
+62
-39
未找到文件。
libc-test/src/functionalext/symver/BUILD.gn
浏览文件 @
11277cdf
...
...
@@ -37,6 +37,7 @@ group("dso_shared") {
":dso_hard_symver",
":dso_no_symver",
":dso_symver",
":reloc_symver_dso",
]
}
...
...
@@ -53,3 +54,10 @@ test_sharedlib("dso_no_symver") {
test_sharedlib("dso_symver") {
}
test_sharedlib("reloc_symver_dso") {
deps = [
":dso_easy_symver",
":dso_no_symver",
]
}
libc-test/src/functionalext/symver/reloc_symver.c
0 → 100644
浏览文件 @
11277cdf
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <dlfcn.h>
#include "dso_symver.h"
/**
* @tc.name : reloc_symver_0100
* @tc.desc : find versioning symbol while relocating.
* load libreloc_symver_dso.so that deps on libdso_no_symver.so and libdso_easy_symver.so.
* @tc.level : Level 1
*/
static
void
reloc_symver_0100
(
void
)
{
symver_log
(
"start"
);
void
*
so
=
dlopen
(
"libreloc_symver_dso.so"
,
RTLD_NOW
);
if
(
so
)
{
dlclose
(
so
);
}
else
{
symver_error
(
"%s"
,
dlerror
());
}
symver_log
(
"end"
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
symver_log
(
"start"
);
reloc_symver_0100
();
symver_log
(
"t_status = %d"
,
t_status
);
symver_log
(
"end"
);
return
t_status
;
}
\ No newline at end of file
libc-test/src/functionalext/symver/reloc_symver_dso.c
0 → 100644
浏览文件 @
11277cdf
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "dso_no_symver.h"
#include "dso_easy_symver.h"
void
test_func
()
{
(
void
)
dso_no_symver
();
(
void
)
dso_easy_symver
();
}
\ No newline at end of file
libc-test/src/functionalext/symver/test_src_functionalext_symver.gni
浏览文件 @
11277cdf
...
...
@@ -16,4 +16,5 @@ functionalext_symver_list = [
"dlvsym",
"dynlink_default",
"dynlink",
"reloc_symver",
]
libc-test/test_template.gni
浏览文件 @
11277cdf
...
...
@@ -265,6 +265,10 @@ template("test_sharedlib") {
ldflags += [ "-Wl,--version-script=${_version_script}" ]
}
if (defined(invoker.deps)) {
deps = invoker.deps
}
libs = [ "//${out_test_dir}/src/common/libtest.a" ]
output_name = "${target_name}"
...
...
porting/linux/user/ldso/dynlink.c
浏览文件 @
11277cdf
...
...
@@ -82,7 +82,8 @@ struct td_index {
struct
verinfo
{
const
char
*
s
;
const
char
*
v
;
Verneed
*
verneed
;
bool
use_vna_hash
;
uint32_t
vna_hash
;
};
struct
dso
{
...
...
@@ -462,45 +463,23 @@ static int search_vec(size_t *v, size_t *r, size_t key)
return
1
;
}
static
int
check_v
erneed
(
Verdef
*
def
,
int
vsym
,
struct
verinfo
*
verinfo
)
static
int
check_v
na_hash
(
Verdef
*
def
,
int16_t
vsym
,
uint32_t
vna_hash
)
{
int
matched
=
0
;
Verneed
*
verneed
=
verinfo
->
verneed
;
vsym
&=
0x7fff
;
Verdef
*
verdef
=
def
;
for
(;;)
{
Vernaux
*
vernaux
=
(
Vernaux
*
)((
char
*
)
verneed
+
verneed
->
vn_aux
);
for
(
size_t
cnt
=
0
;
cnt
<
verneed
->
vn_cnt
;
cnt
++
)
{
Verdef
*
verdef
=
def
;
/* find the version of symbol for verneed. */
for
(;;)
{
if
(
vernaux
->
vna_hash
==
verdef
->
vd_hash
)
{
if
((
verdef
->
vd_ndx
&
0x7fff
)
==
vsym
)
{
matched
=
1
;
}
break
;
}
if
(
verdef
->
vd_next
==
0
)
{
break
;
}
verdef
=
(
Verdef
*
)((
char
*
)
verdef
+
verdef
->
vd_next
);
}
if
(
matched
)
{
break
;
if
((
verdef
->
vd_ndx
&
0x7fff
)
==
vsym
)
{
if
(
vna_hash
==
verdef
->
vd_hash
)
{
matched
=
1
;
}
vernaux
=
(
Vernaux
*
)((
char
*
)
vernaux
+
vernaux
->
vna_next
);
break
;
}
if
(
verneed
->
vn_next
==
0
)
{
if
(
verdef
->
vd_next
==
0
)
{
break
;
}
verneed
=
(
Verneed
*
)((
char
*
)
verneed
+
verneed
->
vn_next
);
verdef
=
(
Verdef
*
)((
char
*
)
verdef
+
verdef
->
vd_next
);
}
return
matched
;
...
...
@@ -517,12 +496,13 @@ static int check_verinfo(Verdef *def, int16_t *versym, uint32_t index, struct ve
}
}
int
vsym
=
versym
[
index
];
int
16_t
vsym
=
versym
[
index
];
/* if the verneed is not null , find the verneed symbol. */
Verneed
*
verneed
=
verinfo
->
verneed
;
if
(
verneed
)
{
return
check_verneed
(
def
,
vsym
,
verinfo
);
/* find the verneed symbol. */
if
(
verinfo
->
use_vna_hash
)
{
if
(
vsym
!=
VER_NDX_LOCAL
&&
versym
!=
VER_NDX_GLOBAL
)
{
return
check_vna_hash
(
def
,
vsym
,
verinfo
->
vna_hash
);
}
}
/* if the version length is zero and vsym not less than zero, then library hava default version symbol. */
...
...
@@ -748,10 +728,52 @@ static inline struct symdef find_sym2(struct dso *dso, struct verinfo *verinfo,
static
struct
symdef
find_sym
(
struct
dso
*
dso
,
const
char
*
s
,
int
need_def
)
{
struct
verinfo
verinfo
=
{
.
s
=
s
,
.
v
=
""
,
.
verneed
=
dso
->
verneed
};
struct
verinfo
verinfo
=
{
.
s
=
s
,
.
v
=
""
,
.
use_vna_hash
=
false
};
return
find_sym2
(
dso
,
&
verinfo
,
need_def
,
0
,
NULL
);
}
static
bool
get_vna_hash
(
struct
dso
*
dso
,
int
sym_index
,
uint32_t
*
vna_hash
)
{
if
(
!
dso
->
versym
||
!
dso
->
verneed
)
{
return
false
;
}
uint16_t
vsym
=
dso
->
versym
[
sym_index
];
if
(
vsym
==
VER_NDX_LOCAL
||
vsym
==
VER_NDX_GLOBAL
)
{
return
false
;
}
bool
result
=
false
;
Verneed
*
verneed
=
dso
->
verneed
;
Vernaux
*
vernaux
;
vsym
&=
0x7fff
;
for
(;;)
{
vernaux
=
(
Vernaux
*
)((
char
*
)
verneed
+
verneed
->
vn_aux
);
for
(
size_t
cnt
=
0
;
cnt
<
verneed
->
vn_cnt
;
cnt
++
)
{
if
((
vernaux
->
vna_other
&
0x7fff
)
==
vsym
)
{
result
=
true
;
*
vna_hash
=
vernaux
->
vna_hash
;
break
;
}
vernaux
=
(
Vernaux
*
)((
char
*
)
vernaux
+
vernaux
->
vna_next
);
}
if
(
result
)
{
break
;
}
if
(
verneed
->
vn_next
==
0
)
{
break
;
}
verneed
=
(
Verneed
*
)((
char
*
)
verneed
+
verneed
->
vn_next
);
}
return
result
;
}
static
void
do_relocs
(
struct
dso
*
dso
,
size_t
*
rel
,
size_t
rel_size
,
size_t
stride
)
{
unsigned
char
*
base
=
dso
->
base
;
...
...
@@ -802,7 +824,8 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri
sym
=
syms
+
sym_index
;
name
=
strings
+
sym
->
st_name
;
ctx
=
type
==
REL_COPY
?
head
->
syms_next
:
head
;
struct
verinfo
vinfo
=
{
.
s
=
name
,
.
v
=
""
,
.
verneed
=
dso
->
verneed
};
struct
verinfo
vinfo
=
{
.
s
=
name
,
.
v
=
""
};
vinfo
.
use_vna_hash
=
get_vna_hash
(
dso
,
sym_index
,
&
vinfo
.
vna_hash
);
def
=
(
sym
->
st_info
>>
4
)
==
STB_LOCAL
?
(
struct
symdef
){
.
dso
=
dso
,
.
sym
=
sym
}
:
find_sym2
(
ctx
,
&
vinfo
,
type
==
REL_PLT
,
0
,
dso
->
namespace
);
...
...
@@ -3044,7 +3067,7 @@ static void *do_dlsym(struct dso *p, const char *s, const char *v, void *ra)
ns
=
caller
->
namespace
;
}
}
struct
verinfo
verinfo
=
{
.
s
=
s
,
.
v
=
v
,
.
verneed
=
NULL
};
struct
verinfo
verinfo
=
{
.
s
=
s
,
.
v
=
v
,
.
use_vna_hash
=
false
};
struct
symdef
def
=
find_sym2
(
p
,
&
verinfo
,
0
,
use_deps
,
ns
);
if
(
!
def
.
sym
)
{
error
(
"Symbol not found: %s, version: %s"
,
s
,
strlen
(
v
)
>
0
?
v
:
"null"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录