Merge "Store soname as a std::string."
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index ec6850a..772e7b8 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -328,11 +328,12 @@
__libdl_info->ref_count_ = 1;
__libdl_info->strtab_size_ = linker_si.strtab_size_;
__libdl_info->local_group_root_ = __libdl_info;
- __libdl_info->soname_ = linker_si.soname_;
+ __libdl_info->soname_ = linker_si.soname_.c_str();
__libdl_info->target_sdk_version_ = __ANDROID_API__;
__libdl_info->generate_handle();
#if defined(__work_around_b_24465209__)
- strlcpy(__libdl_info->old_name_, __libdl_info->soname_, sizeof(__libdl_info->old_name_));
+ strlcpy(__libdl_info->old_name_, __libdl_info->soname_.c_str(),
+ sizeof(__libdl_info->old_name_));
#endif
}
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 2481be4..77824f6 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -1339,8 +1339,7 @@
const char* name,
soinfo** candidate) {
return !ns->soinfo_list().visit([&](soinfo* si) {
- const char* soname = si->get_soname();
- if (soname != nullptr && (strcmp(name, soname) == 0)) {
+ if (strcmp(name, si->get_soname()) == 0) {
*candidate = si;
return false;
}
@@ -2571,9 +2570,8 @@
const char* target_soname = si_from->get_string(verneed->vn_file);
// find it in dependencies
- soinfo* target_si = si_from->get_children().find_if([&](const soinfo* si) {
- return si->get_soname() != nullptr && strcmp(si->get_soname(), target_soname) == 0;
- });
+ soinfo* target_si = si_from->get_children().find_if(
+ [&](const soinfo* si) { return strcmp(si->get_soname(), target_soname) == 0; });
if (target_si == nullptr) {
DL_ERR("cannot find \"%s\" from verneed[%zd] in DT_NEEDED list for \"%s\"",
@@ -3214,15 +3212,12 @@
// for apps targeting sdk version < M.) Make an exception for
// the main executable and linker; they do not need to have dt_soname.
// TODO: >= O the linker doesn't need this workaround.
- if (soname_ == nullptr &&
- this != solist_get_somain() &&
- (flags_ & FLAG_LINKER) == 0 &&
+ if (soname_.empty() && this != solist_get_somain() && (flags_ & FLAG_LINKER) == 0 &&
get_application_target_sdk_version() < 23) {
soname_ = basename(realpath_.c_str());
- DL_WARN_documented_change(23,
- "missing-soname-enforced-for-api-level-23",
- "\"%s\" has no DT_SONAME (will use %s instead)",
- get_realpath(), soname_);
+ DL_WARN_documented_change(23, "missing-soname-enforced-for-api-level-23",
+ "\"%s\" has no DT_SONAME (will use %s instead)", get_realpath(),
+ soname_.c_str());
// Don't call add_dlwarning because a missing DT_SONAME isn't important enough to show in the UI
}
diff --git a/linker/linker_cfi.cpp b/linker/linker_cfi.cpp
index 87b5d34..6bc2615 100644
--- a/linker/linker_cfi.cpp
+++ b/linker/linker_cfi.cpp
@@ -133,8 +133,7 @@
static soinfo* find_libdl(soinfo* solist) {
for (soinfo* si = solist; si != nullptr; si = si->next) {
- const char* soname = si->get_soname();
- if (soname && strcmp(soname, "libdl.so") == 0) {
+ if (strcmp(si->get_soname(), "libdl.so") == 0) {
return si;
}
}
diff --git a/linker/linker_namespaces.h b/linker/linker_namespaces.h
index 77b6622..6817901 100644
--- a/linker/linker_namespaces.h
+++ b/linker/linker_namespaces.h
@@ -56,9 +56,6 @@
}
bool is_accessible(const char* soname) const {
- if (soname == nullptr) {
- return false;
- }
return allow_all_shared_libs_ || shared_lib_sonames_.find(soname) != shared_lib_sonames_.end();
}
diff --git a/linker/linker_soinfo.cpp b/linker/linker_soinfo.cpp
index 60fd242..f44cb1c 100644
--- a/linker/linker_soinfo.cpp
+++ b/linker/linker_soinfo.cpp
@@ -695,7 +695,7 @@
if (has_min_version(2)) {
soname_ = soname;
}
- strlcpy(old_name_, soname_, sizeof(old_name_));
+ strlcpy(old_name_, soname_.c_str(), sizeof(old_name_));
#else
soname_ = soname;
#endif
@@ -704,12 +704,12 @@
const char* soinfo::get_soname() const {
#if defined(__work_around_b_24465209__)
if (has_min_version(2)) {
- return soname_;
+ return soname_.c_str();
} else {
return old_name_;
}
#else
- return soname_;
+ return soname_.c_str();
#endif
}
diff --git a/linker/linker_soinfo.h b/linker/linker_soinfo.h
index 7372a51..9c589d6 100644
--- a/linker/linker_soinfo.h
+++ b/linker/linker_soinfo.h
@@ -401,7 +401,7 @@
uint8_t* android_relocs_;
size_t android_relocs_size_;
- const char* soname_;
+ std::string soname_;
std::string realpath_;
const ElfW(Versym)* versym_;