Result<NativeLoaderNamespace> NativeLoaderNamespace::GetExportedNamespace(const std::string& name, bool is_bridged) { if (!is_bridged) {
android_namespace_t* raw = android_get_exported_namespace(name.c_str()); if (raw != nullptr) { return NativeLoaderNamespace(name, raw);
}
} else {
native_bridge_namespace_t* raw = NativeBridgeGetExportedNamespace(name.c_str()); if (raw != nullptr) { return NativeLoaderNamespace(name, raw);
}
} return Errorf("namespace {} does not exist or exported", name);
}
// The system namespace is called "default" for binaries in /system and // "system" for those in the Runtime APEX. Try "system" first since // "default" always exists.
Result<NativeLoaderNamespace> NativeLoaderNamespace::GetSystemNamespace(bool is_bridged) { if (Result<NativeLoaderNamespace> ns = GetExportedNamespace(kSystemNamespaceName, is_bridged);
ns.ok()) { return ns;
} if (Result<NativeLoaderNamespace> ns = GetExportedNamespace(kDefaultNamespaceName, is_bridged);
ns.ok()) { 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));
}
}
// Fall back to the system namespace if no parent is set.
Result<NativeLoaderNamespace> system_ns = GetSystemNamespace(is_bridged); if (!system_ns.ok()) { return system_ns.error();
} const NativeLoaderNamespace& effective_parent = parent != nullptr ? *parent : *system_ns;
// All namespaces for apps are isolated
uint64_t type = ANDROID_NAMESPACE_TYPE_ISOLATED;
// The namespace is also used as the anonymous namespace // which is used when the linker fails to determine the caller address if (also_used_as_anonymous) {
type |= ANDROID_NAMESPACE_TYPE_ALSO_USED_AS_ANONYMOUS;
}
// Bundled apps have access to all system libraries that are currently loaded // in the default namespace if (is_shared) {
type |= ANDROID_NAMESPACE_TYPE_SHARED;
} if (is_exempt_list_enabled) {
type |= ANDROID_NAMESPACE_TYPE_EXEMPT_LIST_ENABLED;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.