From 62870e295d575885c4d9fc8b227d2ef021a02014 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 1 Oct 2019 17:58:23 +0900 Subject: [PATCH] public libs from APEXes are pre-loadable This change fixes a bug that public libs from APEXes are never pre-loaded. This was happening because those libs are removed by InitDefaultPublicLibraries which was originaly designed for listing up the libs that needs to be provided to the app namespace from the default namespace. Since the libs from APEXes are not available from the default namespace, but from their own namespaces (e.g."runtime", etc.), the removal was fine. But the problem happend when the same function is parameterized (with bool for_preload) and used to get the libs for preloading. This change fixes the problem by not removing the libs from APEXes when the function is called with for_preload == true. Bug: 141847343 Test: m Change-Id: I9edf2f94bac473ac7d0651514a2dabe976f81058 --- libnativeloader/public_libraries.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libnativeloader/public_libraries.cpp b/libnativeloader/public_libraries.cpp index 93df1d05a..010e8cc3b 100644 --- a/libnativeloader/public_libraries.cpp +++ b/libnativeloader/public_libraries.cpp @@ -176,6 +176,11 @@ static std::string InitDefaultPublicLibraries(bool for_preload) { std::copy(vec.begin(), vec.end(), std::back_inserter(*sonames)); } + // If this is for preloading libs, don't remove the libs from APEXes. + if (for_preload) { + return android::base::Join(*sonames, ':'); + } + // Remove the public libs in the runtime namespace. // These libs are listed in public.android.txt, but we don't want the rest of android // in default namespace to dlopen the libs.