Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
00b444e0
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看板
未验证
提交
00b444e0
编写于
10月 24, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 24, 2022
浏览文件
操作
浏览文件
下载
差异文件
!577 Optimize gnu_lookup
Merge pull request !577 from yinchuang/optimize_gnu_lookup
上级
1ab6d340
2ce0b56a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
19 deletion
+34
-19
porting/linux/user/ldso/dynlink.c
porting/linux/user/ldso/dynlink.c
+34
-19
未找到文件。
porting/linux/user/ldso/dynlink.c
浏览文件 @
00b444e0
...
...
@@ -93,6 +93,11 @@ struct verinfo {
uint32_t
vna_hash
;
};
struct
sym_info_pair
{
uint_fast32_t
sym_h
;
uint32_t
sym_l
;
};
struct
dso
{
#if DL_FDPIC
struct
fdpic_loadmap
*
loadmap
;
...
...
@@ -556,35 +561,42 @@ static int check_verinfo(Verdef *def, int16_t *versym, uint32_t index, struct ve
return
ret
;
}
static
uint32_t
sysv_hash
(
const
char
*
s0
)
static
struct
sym_info_pair
sysv_hash
(
const
char
*
s0
)
{
struct
sym_info_pair
s_info_p
;
const
unsigned
char
*
s
=
(
void
*
)
s0
;
uint_fast32_t
h
=
0
;
while
(
*
s
)
{
h
=
16
*
h
+
*
s
++
;
h
^=
h
>>
24
&
0xf0
;
}
return
h
&
0xfffffff
;
s_info_p
.
sym_h
=
h
&
0xfffffff
;
s_info_p
.
sym_l
=
(
char
*
)
s
-
s0
;
return
s_info_p
;
}
static
uint32_t
gnu_hash
(
const
char
*
s0
)
static
struct
sym_info_pair
gnu_hash
(
const
char
*
s0
)
{
struct
sym_info_pair
s_info_p
;
const
unsigned
char
*
s
=
(
void
*
)
s0
;
uint_fast32_t
h
=
5381
;
for
(;
*
s
;
s
++
)
h
+=
h
*
32
+
*
s
;
return
h
;
s_info_p
.
sym_h
=
h
;
s_info_p
.
sym_l
=
(
char
*
)
s
-
s0
;
return
s_info_p
;
}
static
Sym
*
sysv_lookup
(
struct
verinfo
*
verinfo
,
uint32_t
h
,
struct
dso
*
dso
)
static
Sym
*
sysv_lookup
(
struct
verinfo
*
verinfo
,
struct
sym_info_pair
s_info_p
,
struct
dso
*
dso
)
{
size_t
i
;
uint32_t
h
=
s_info_p
.
sym_h
;
Sym
*
syms
=
dso
->
syms
;
Elf_Symndx
*
hashtab
=
dso
->
hashtab
;
char
*
strings
=
dso
->
strings
;
for
(
i
=
hashtab
[
2
+
h
%
hashtab
[
0
]];
i
;
i
=
hashtab
[
2
+
hashtab
[
0
]
+
i
])
{
if
((
!
dso
->
versym
||
(
dso
->
versym
[
i
]
&
0x7fff
)
>=
0
)
&&
(
!
strcmp
(
verinfo
->
s
,
strings
+
syms
[
i
].
st_name
)))
{
&&
(
!
memcmp
(
verinfo
->
s
,
strings
+
syms
[
i
].
st_name
,
s_info_p
.
sym_l
)))
{
if
(
!
check_verinfo
(
dso
->
verdef
,
dso
->
versym
,
i
,
verinfo
,
dso
->
strings
))
{
continue
;
}
...
...
@@ -599,8 +611,9 @@ static Sym *sysv_lookup(struct verinfo *verinfo, uint32_t h, struct dso *dso)
return
0
;
}
static
Sym
*
gnu_lookup
(
uint32_t
h1
,
uint32_t
*
hashtab
,
struct
dso
*
dso
,
struct
verinfo
*
verinfo
)
static
Sym
*
gnu_lookup
(
struct
sym_info_pair
s_info_p
,
uint32_t
*
hashtab
,
struct
dso
*
dso
,
struct
verinfo
*
verinfo
)
{
uint32_t
h1
=
s_info_p
.
sym_h
;
uint32_t
nbuckets
=
hashtab
[
0
];
uint32_t
*
buckets
=
hashtab
+
4
+
hashtab
[
2
]
*
(
sizeof
(
size_t
)
/
4
);
uint32_t
i
=
buckets
[
h1
%
nbuckets
];
...
...
@@ -615,7 +628,7 @@ static Sym *gnu_lookup(uint32_t h1, uint32_t *hashtab, struct dso *dso, struct v
for
(
h1
|=
1
;
;
i
++
)
{
uint32_t
h2
=
*
hashval
++
;
if
((
h1
==
(
h2
|
1
))
&&
(
!
dso
->
versym
||
(
dso
->
versym
[
i
]
&
0x7fff
)
>=
0
)
&&
!
strcmp
(
verinfo
->
s
,
dso
->
strings
+
dso
->
syms
[
i
].
st_name
))
{
&&
!
memcmp
(
verinfo
->
s
,
dso
->
strings
+
dso
->
syms
[
i
].
st_name
,
s_info_p
.
sym_l
))
{
if
(
!
check_verinfo
(
dso
->
verdef
,
dso
->
versym
,
i
,
verinfo
,
dso
->
strings
))
{
continue
;
}
...
...
@@ -632,9 +645,9 @@ static Sym *gnu_lookup(uint32_t h1, uint32_t *hashtab, struct dso *dso, struct v
return
0
;
}
static
Sym
*
gnu_lookup_filtered
(
uint32_t
h1
,
uint32_t
*
hashtab
,
struct
dso
*
dso
,
struct
verinfo
*
verinfo
,
uint32_t
fofs
,
size_t
fmask
)
static
Sym
*
gnu_lookup_filtered
(
struct
sym_info_pair
s_info_p
,
uint32_t
*
hashtab
,
struct
dso
*
dso
,
struct
verinfo
*
verinfo
,
uint32_t
fofs
,
size_t
fmask
)
{
uint32_t
h1
=
s_info_p
.
sym_h
;
const
size_t
*
bloomwords
=
(
const
void
*
)(
hashtab
+
4
);
size_t
f
=
bloomwords
[
fofs
&
(
hashtab
[
2
]
-
1
)];
if
(
!
(
f
&
fmask
))
return
0
;
...
...
@@ -642,7 +655,7 @@ static Sym *gnu_lookup_filtered(uint32_t h1, uint32_t *hashtab, struct dso *dso,
f
>>=
(
h1
>>
hashtab
[
3
])
%
(
8
*
sizeof
f
);
if
(
!
(
f
&
1
))
return
0
;
return
gnu_lookup
(
h1
,
hashtab
,
dso
,
verinfo
);
return
gnu_lookup
(
s_info_p
,
hashtab
,
dso
,
verinfo
);
}
static
bool
check_sym_accessible
(
struct
dso
*
dso
,
ns_t
*
ns
)
...
...
@@ -777,7 +790,8 @@ __attribute__((always_inline))
#endif
static
inline
struct
symdef
find_sym2
(
struct
dso
*
dso
,
struct
verinfo
*
verinfo
,
int
need_def
,
int
use_deps
,
ns_t
*
ns
)
{
uint32_t
h
=
0
,
gh
=
gnu_hash
(
verinfo
->
s
),
gho
=
gh
/
(
8
*
sizeof
(
size_t
)),
*
ght
;
struct
sym_info_pair
s_info_p
=
gnu_hash
(
verinfo
->
s
);
uint32_t
h
=
0
,
gh
=
s_info_p
.
sym_h
,
gho
=
gh
/
(
8
*
sizeof
(
size_t
)),
*
ght
;
size_t
ghm
=
1ul
<<
gh
%
(
8
*
sizeof
(
size_t
));
struct
symdef
def
=
{
0
};
struct
dso
**
deps
=
use_deps
?
dso
->
deps
:
0
;
...
...
@@ -787,10 +801,10 @@ static inline struct symdef find_sym2(struct dso *dso, struct verinfo *verinfo,
continue
;
}
if
((
ght
=
dso
->
ghashtab
))
{
sym
=
gnu_lookup_filtered
(
gh
,
ght
,
dso
,
verinfo
,
gho
,
ghm
);
sym
=
gnu_lookup_filtered
(
s_info_p
,
ght
,
dso
,
verinfo
,
gho
,
ghm
);
}
else
{
if
(
!
h
)
h
=
sysv_hash
(
verinfo
->
s
);
sym
=
sysv_lookup
(
verinfo
,
h
,
dso
);
if
(
!
h
)
s_info_p
=
sysv_hash
(
verinfo
->
s
);
sym
=
sysv_lookup
(
verinfo
,
s_info_p
,
dso
);
}
if
(
!
sym
)
continue
;
if
(
!
sym
->
st_shndx
)
...
...
@@ -812,7 +826,8 @@ static inline struct symdef find_sym2(struct dso *dso, struct verinfo *verinfo,
static
inline
struct
symdef
find_sym_by_saved_so_list
(
int
sym_type
,
struct
dso
*
dso
,
struct
verinfo
*
verinfo
,
int
need_def
,
struct
dso
*
dso_relocating
)
{
uint32_t
h
=
0
,
gh
=
gnu_hash
(
verinfo
->
s
),
gho
=
gh
/
(
8
*
sizeof
(
size_t
)),
*
ght
;
struct
sym_info_pair
s_info_p
=
gnu_hash
(
verinfo
->
s
);
uint32_t
h
=
0
,
gh
=
s_info_p
.
sym_h
,
gho
=
gh
/
(
8
*
sizeof
(
size_t
)),
*
ght
;
size_t
ghm
=
1ul
<<
gh
%
(
8
*
sizeof
(
size_t
));
struct
symdef
def
=
{
0
};
// skip head dso.
...
...
@@ -822,10 +837,10 @@ static inline struct symdef find_sym_by_saved_so_list(
dso_searching
=
dso_relocating
->
reloc_can_search_dso_list
[
i
];
Sym
*
sym
;
if
((
ght
=
dso_searching
->
ghashtab
))
{
sym
=
gnu_lookup_filtered
(
gh
,
ght
,
dso_searching
,
verinfo
,
gho
,
ghm
);
sym
=
gnu_lookup_filtered
(
s_info_p
,
ght
,
dso_searching
,
verinfo
,
gho
,
ghm
);
}
else
{
if
(
!
h
)
h
=
sysv_hash
(
verinfo
->
s
);
sym
=
sysv_lookup
(
verinfo
,
h
,
dso_searching
);
if
(
!
h
)
s_info_p
=
sysv_hash
(
verinfo
->
s
);
sym
=
sysv_lookup
(
verinfo
,
s_info_p
,
dso_searching
);
}
if
(
!
sym
)
continue
;
if
(
!
sym
->
st_shndx
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录