Merge "Tell kati about generated dependencies around crt" am: 37591462fa
am: c91cd8a47f
* commit 'c91cd8a47f14a96e37d9a5054720886bdacf0bd5':
Tell kati about generated dependencies around crt
diff --git a/CleanSpec.mk b/CleanSpec.mk
index 841ad16..9421e26 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -48,6 +48,11 @@
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libc_*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libc_*)
+# Required due to the replacement of a symlink with a shared library
+# (commit b952f42bef69e5c in frameworks/native).
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib/libGLES*)
+$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib64/libGLES*)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/libc/upstream-netbsd/android/include/netbsd-compat.h b/libc/upstream-netbsd/android/include/netbsd-compat.h
index 8d1c46b..0212d16 100644
--- a/libc/upstream-netbsd/android/include/netbsd-compat.h
+++ b/libc/upstream-netbsd/android/include/netbsd-compat.h
@@ -32,6 +32,6 @@
#define __unlockenv() 0
#include <stddef.h>
-__LIBC_HIDDEN__ int reallocarr(void*, size_t, size_t);
+int reallocarr(void*, size_t, size_t);
#endif
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 1c1650e..72e7759 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -153,6 +153,54 @@
nullptr
};
+static bool is_system_library(const std::string& realpath) {
+ for (const auto& dir : g_default_namespace.get_default_library_paths()) {
+ if (file_is_in_dir(realpath, dir)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// TODO(dimitry): This is workaround for http://b/26394120 - it will be removed before the release
+static bool is_greylisted(const char* name, const soinfo* needed_by) {
+ static const char* const kLibraryGreyList[] = {
+ "libandroid_runtime.so",
+ "libbinder.so",
+ "libcrypto.so",
+ "libcutils.so",
+ "libmedia.so",
+ "libnativehelper.so",
+ "libskia.so",
+ "libssl.so",
+ "libstagefright.so",
+ "libui.so",
+ "libutils.so",
+ nullptr
+ };
+
+ // limit greylisting to apps targeting sdk version 23 and below
+ if (get_application_target_sdk_version() > 23) {
+ return false;
+ }
+
+ // if the library needed by a system library - implicitly assume it
+ // is greylisted
+
+ if (needed_by != nullptr && is_system_library(needed_by->get_realpath())) {
+ return true;
+ }
+
+ for (size_t i = 0; kLibraryGreyList[i] != nullptr; ++i) {
+ if (strcmp(name, kLibraryGreyList[i]) == 0) {
+ return true;
+ }
+ }
+
+ return false;
+}
+// END OF WORKAROUND
+
static const ElfW(Versym) kVersymNotNeeded = 0;
static const ElfW(Versym) kVersymGlobal = 1;
@@ -1139,6 +1187,14 @@
extinfo_ = extinfo;
}
+ bool is_dt_needed() const {
+ return is_dt_needed_;
+ }
+
+ void set_dt_needed(bool is_dt_needed) {
+ is_dt_needed_ = is_dt_needed;
+ }
+
const ElfReader& get_elf_reader() const {
CHECK(si_ != nullptr);
return (*elf_readers_map_)[si_];
@@ -1178,7 +1234,8 @@
LoadTask(const char* name, soinfo* needed_by,
std::unordered_map<const soinfo*, ElfReader>* readers_map)
: name_(name), needed_by_(needed_by), si_(nullptr),
- fd_(-1), close_fd_(false), file_offset_(0), elf_readers_map_(readers_map) {}
+ fd_(-1), close_fd_(false), file_offset_(0), elf_readers_map_(readers_map),
+ is_dt_needed_(false) {}
~LoadTask() {
if (fd_ != -1 && close_fd_) {
@@ -1194,6 +1251,9 @@
bool close_fd_;
off64_t file_offset_;
std::unordered_map<const soinfo*, ElfReader>* elf_readers_map_;
+ // TODO(dimitry): workaround for http://b/26394120 - will be removed before the release
+ bool is_dt_needed_;
+ // END OF WORKAROUND
DISALLOW_IMPLICIT_CONSTRUCTORS(LoadTask);
};
@@ -1615,6 +1675,14 @@
fd = open_library_on_paths(zip_archive_cache, name, file_offset, ns->get_default_library_paths(), realpath);
}
+ // TODO(dimitry): workaround for http://b/26394120 - will be removed before the release
+ if (fd == -1 && ns != &g_default_namespace && is_greylisted(name, needed_by)) {
+ // try searching for it on default_namespace default_library_path
+ fd = open_library_on_paths(zip_archive_cache, name, file_offset,
+ g_default_namespace.get_default_library_paths(), realpath);
+ }
+ // END OF WORKAROUND
+
return fd;
}
@@ -1715,10 +1783,21 @@
}
if (!ns->is_accessible(realpath)) {
- // do not load libraries if they are not accessible for the specified namespace.
- DL_ERR("library \"%s\" is not accessible for the namespace \"%s\"",
- name, ns->get_name());
- return false;
+ // TODO(dimitry): workaround for http://b/26394120 - will be removed before the release
+ const soinfo* needed_by = task->is_dt_needed() ? task->get_needed_by() : nullptr;
+ if (is_greylisted(name, needed_by)) {
+ // print warning only if needed by non-system library
+ if (needed_by == nullptr || !is_system_library(needed_by->get_realpath())) {
+ DL_WARN("library \"%s\" (\"%s\") needed by \"%s\" is not accessible for the namespace \"%s\""
+ " - the access is temporarily granted as a workaround for http://b/26394120",
+ name, realpath.c_str(), needed_by->get_realpath(), ns->get_name());
+ }
+ } else {
+ // do not load libraries if they are not accessible for the specified namespace.
+ DL_ERR("library \"%s\" is not accessible for the namespace \"%s\"",
+ name, ns->get_name());
+ return false;
+ }
}
soinfo* si = soinfo_alloc(ns, realpath.c_str(), &file_stat, file_offset, rtld_flags);
@@ -1973,6 +2052,7 @@
bool is_dt_needed = needed_by != nullptr && (needed_by != start_with || add_as_children);
task->set_extinfo(is_dt_needed ? nullptr : extinfo);
+ task->set_dt_needed(is_dt_needed);
if(!find_library_internal(ns, task, &zip_archive_cache, &load_tasks, rtld_flags)) {
return false;