summaryrefslogtreecommitdiff
path: root/libnativeloader/native_loader.cpp
diff options
context:
space:
mode:
authorJooyung Han <jooyung@google.com>2020-02-08 03:53:54 +0900
committerTreehugger Robot <treehugger-gerrit@google.com>2020-02-11 19:00:38 +0000
commit98cf82f227fa8fab694674e72a9a2ca95face4b5 (patch)
tree104b438ec54707e44648ad2e26a65a9774a0a50f /libnativeloader/native_loader.cpp
parent089c1357c6e5457a7bd5e76f70cead52517d9b0b (diff)
Use apex name for apex linker namespace
Linkerconfig now uses apex_names to automatically generate linker namespaces from apexes. Bug: 148826508 Test: build / boot Change-Id: Id7fa68531033124727e618284af4fd2a61bdd85f
Diffstat (limited to 'libnativeloader/native_loader.cpp')
-rw-r--r--libnativeloader/native_loader.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/libnativeloader/native_loader.cpp b/libnativeloader/native_loader.cpp
index 4e5189b4bf..3998f61eaa 100644
--- a/libnativeloader/native_loader.cpp
+++ b/libnativeloader/native_loader.cpp
@@ -52,17 +52,15 @@ LibraryNamespaces* g_namespaces = new LibraryNamespaces;
android_namespace_t* FindExportedNamespace(const char* caller_location) {
std::string location = caller_location;
// Lots of implicit assumptions here: we expect `caller_location` to be of the form:
- // /apex/com.android...modulename/...
+ // /apex/modulename/...
//
// And we extract from it 'modulename', which is the name of the linker namespace.
if (android::base::StartsWith(location, kApexPath)) {
- size_t slash_index = location.find_first_of('/', strlen(kApexPath));
+ size_t start_index = strlen(kApexPath);
+ size_t slash_index = location.find_first_of('/', start_index);
LOG_ALWAYS_FATAL_IF((slash_index == std::string::npos),
"Error finding namespace of apex: no slash in path %s", caller_location);
- size_t dot_index = location.find_last_of('.', slash_index);
- LOG_ALWAYS_FATAL_IF((dot_index == std::string::npos),
- "Error finding namespace of apex: no dot in apex name %s", caller_location);
- std::string name = location.substr(dot_index + 1, slash_index - dot_index - 1);
+ std::string name = location.substr(start_index, slash_index - start_index);
android_namespace_t* boot_namespace = android_get_exported_namespace(name.c_str());
LOG_ALWAYS_FATAL_IF((boot_namespace == nullptr),
"Error finding namespace of apex: no namespace called %s", name.c_str());