summaryrefslogtreecommitdiffstats
path: root/libnativeloader
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2016-06-21 16:11:23 -0700
committerChristopher Ferris <cferris@google.com>2016-06-22 11:21:21 -0700
commit39da84b06cf53f87ae535a685b315c1584bba7cb (patch)
tree1fd6d1ad57a1eb458b7cad941b8c683ed0cfd001 /libnativeloader
parent57bbedc036e298878f7a3af57492123393879e0e (diff)
downloadsystem_core-39da84b06cf53f87ae535a685b315c1584bba7cb.tar.gz
system_core-39da84b06cf53f87ae535a685b315c1584bba7cb.tar.bz2
system_core-39da84b06cf53f87ae535a685b315c1584bba7cb.zip
Add support to indicate bitness of public library.
For public vendor libraries, a vendor might have only a 32 bit or only a 64 bit version of the library. Add a way to indicate this in the public.libraries.txt files. The new format is: library.so 32 This indicates that this is a 32 bit only public library. library.so 64 This indicates that this is a 64 bit only public library. Bug: 29370721 Bug: 29512261 (cherry picked from commit 6664a805cae6983c7a19caf8abbe88ad2d918bcb) Change-Id: Id52c8b61d5c802ce62edda7e25f2755f6f93d6b7
Diffstat (limited to 'libnativeloader')
-rw-r--r--libnativeloader/native_loader.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 713a59df2..d0e07dd17 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -133,9 +133,10 @@ class LibraryNamespaces {
std::string public_native_libraries_system_config =
root_dir + kPublicNativeLibrariesSystemConfigPathFromRoot;
- LOG_ALWAYS_FATAL_IF(!ReadConfig(public_native_libraries_system_config, &sonames),
+ std::string error_msg;
+ LOG_ALWAYS_FATAL_IF(!ReadConfig(public_native_libraries_system_config, &sonames, &error_msg),
"Error reading public native library list from \"%s\": %s",
- public_native_libraries_system_config.c_str(), strerror(errno));
+ public_native_libraries_system_config.c_str(), error_msg.c_str());
// For debuggable platform builds use ANDROID_ADDITIONAL_PUBLIC_LIBRARIES environment
// variable to add libraries to the list. This is intended for platform tests only.
@@ -172,20 +173,42 @@ class LibraryNamespaces {
}
private:
- bool ReadConfig(const std::string& configFile, std::vector<std::string>* sonames) {
+ bool ReadConfig(const std::string& configFile, std::vector<std::string>* sonames,
+ std::string* error_msg = nullptr) {
// Read list of public native libraries from the config file.
std::string file_content;
if(!base::ReadFileToString(configFile, &file_content)) {
+ if (error_msg) *error_msg = strerror(errno);
return false;
}
std::vector<std::string> lines = base::Split(file_content, "\n");
- for (const auto& line : lines) {
+ for (auto& line : lines) {
auto trimmed_line = base::Trim(line);
if (trimmed_line[0] == '#' || trimmed_line.empty()) {
continue;
}
+ size_t space_pos = trimmed_line.rfind(' ');
+ if (space_pos != std::string::npos) {
+ std::string type = trimmed_line.substr(space_pos + 1);
+ if (type != "32" && type != "64") {
+ if (error_msg) *error_msg = "Malformed line: " + line;
+ return false;
+ }
+#if defined(__LP64__)
+ // Skip 32 bit public library.
+ if (type == "32") {
+ continue;
+ }
+#else
+ // Skip 64 bit public library.
+ if (type == "64") {
+ continue;
+ }
+#endif
+ trimmed_line.resize(space_pos);
+ }
sonames->push_back(trimmed_line);
}