未验证 提交 14a7119b 编写于 作者: O openharmony_ci 提交者: Gitee

!270 支持asan版本dynamic loader

Merge pull request !270 from Caoruihong/cherry-pick-1647501662
......@@ -497,7 +497,12 @@ template("musl_libs") {
# _libc_shared_outputs = get_target_outputs(":${abi_prefix}_libc_musl_shared")
_libc_shared_so = "${target_out_dir}/${_libs_out_dir}/libc.so"
sources = [ _libc_shared_so ]
_muls_linker_so = "${root_out_dir}/common/common/libc/${_libs_path_prefix}/ld-musl-${musl_arch}${musl_subarch}.so.1"
if (is_asan) {
asan = "-asan"
} else {
asan = ""
}
_muls_linker_so = "${root_out_dir}/common/common/libc/${_libs_path_prefix}/ld-musl-${musl_arch}${musl_subarch}${asan}.so.1"
outputs = [ _muls_linker_so ]
}
}
......@@ -1055,11 +1055,13 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
if (!sys_path) {
char *prefix = 0;
size_t prefix_len;
char *filename = ldso.name;
if (ldso.name[0]=='/') {
char *s, *t, *z;
for (s=t=z=ldso.name; *s; s++)
if (*s=='/') z=t, t=s;
prefix_len = z-ldso.name;
filename = t+1;
if (prefix_len < PATH_MAX)
prefix = ldso.name;
}
......@@ -1067,11 +1069,12 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
prefix = "";
prefix_len = 0;
}
size_t name_len = strchrnul(filename, '.') - filename;
char etc_ldso_path[prefix_len + 1
+ sizeof "/etc/ld-musl-" LDSO_ARCH ".path"];
+ sizeof "/etc/.path" + name_len];
snprintf(etc_ldso_path, sizeof etc_ldso_path,
"%.*s/etc/ld-musl-" LDSO_ARCH ".path",
(int)prefix_len, prefix);
"%.*s/etc/%.*s.path",
(int)prefix_len, prefix, (int)name_len, filename);
FILE *f = fopen(etc_ldso_path, "rbe");
if (f) {
if (getdelim(&sys_path, (size_t[1]){0}, 0, f) <= 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册