Don't fail if default namespace isn't found

This fixes a regression caused by 8f4afc8298
that libnativeloader can't no longer handle the case that it has failed
to find the default namespace. Previously before the change,
libnativeloader continued to use nullptr as the parent namespace which
is reconized as the default namespace inside the linker.

This change recovers the previous behavior. When the default namespace
is not found, NativeLoaderNamespace object is constructed from nullptr.

Bug: 138607234
Test: run app-compat/app-startup-gce on cf_x86_phone using forrest
Change-Id: If518fbc055399b73e7d3a6b45ace0f71e9c25dae
(cherry picked from commit db825ceba6)
Merged-In: If518fbc055399b73e7d3a6b45ace0f71e9c25dae
This commit is contained in:
Jiyong Park 2019-07-30 15:27:39 +09:00
parent 47757e93aa
commit c5e85bf9ba

View file

@ -69,10 +69,18 @@ Result<NativeLoaderNamespace> NativeLoaderNamespace::GetExportedNamespace(const
// "default" always exists.
Result<NativeLoaderNamespace> NativeLoaderNamespace::GetPlatformNamespace(bool is_bridged) {
auto ns = GetExportedNamespace(kPlatformNamespaceName, is_bridged);
if (!ns) {
ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged);
if (ns) return ns;
ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged);
if (ns) return ns;
// If nothing is found, return NativeLoaderNamespace constructed from nullptr.
// nullptr also means default namespace to the linker.
if (!is_bridged) {
return NativeLoaderNamespace(kDefaultNamespaceName, static_cast<android_namespace_t*>(nullptr));
} else {
return NativeLoaderNamespace(kDefaultNamespaceName,
static_cast<native_bridge_namespace_t*>(nullptr));
}
return ns;
}
Result<NativeLoaderNamespace> NativeLoaderNamespace::Create(