From 2c608b32db9bad7b9c24f902591404bcd3e9e860 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Tue, 3 Mar 2020 16:12:36 +0900 Subject: [PATCH 1/2] libbase uses liblog symbols via dlsym when it is built for APEX libbase is a popular library that is used by many APEXes either directly or transitively. It is being used by several Mainline modules that were launched with Q, in which case everything in the APEX - including libbase - shouldn't use new APIs that are added post Q, i.e. R. libbase however is using a few new R symbols from liblog, and this is preventing those Q-launching Mainline modules that are built in R source tree from being installed to Q devices. Fortunately, the dependencies to the new R symbols are guarded with a flag; when the existence of the symbols are not guaranteed, it uses dlsym. This change fixes the aforementioned problem by turning on the flag also when libbase is built for an APEX. Exempt-From-Owner-Approval: cherry-pick rvc-dev Bug: 149569129 Test: TARGET_BUILD_APPS=com.android.media vendor/google/build/build_mainline_modules.sh adb install --staged out/dist/mainline_modules_arm64/com.android.media.apex adb reboot The APEX is installed and mediaextractor process doesn't crash Merged-In: I44b5ec028850613cb45fc3e792f43cd8e87cfd00 (cherry picked from commit 5280b5c03ee1dc4bc60a579626190dcbcbd9849a) Change-Id: I44b5ec028850613cb45fc3e792f43cd8e87cfd00 --- base/liblog_symbols.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/base/liblog_symbols.cpp b/base/liblog_symbols.cpp index d5dfcd28b..8d5917907 100644 --- a/base/liblog_symbols.cpp +++ b/base/liblog_symbols.cpp @@ -16,14 +16,20 @@ #include "liblog_symbols.h" -#if defined(__ANDROID__) && !defined(NO_LIBLOG_DLSYM) +#if defined(__ANDROID__) +#if !defined(NO_LIBLOG_DLSYM) || defined(__ANDROID_APEX__) +#define USE_DLSYM +#endif +#endif + +#ifdef USE_DLSYM #include #endif namespace android { namespace base { -#if defined(__ANDROID__) && !defined(NO_LIBLOG_DLSYM) +#ifdef USE_DLSYM const std::optional& GetLibLogFunctions() { static std::optional liblog_functions = []() -> std::optional { From cc26bbd232cd08e02971adde63afbd54a0405472 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 6 Mar 2020 20:47:30 +0900 Subject: [PATCH 2/2] Whole static link libasync_safe to libbacktrace.a When libbacktrace.a is statically lined to somewhere, that library had to add libasync_safe.a to static_libs because libbacktrace.a has references to libasync_safe.a. But libbacktace depending on libasync_safe is an implementation detail of libbacktrace, and therefore its client shouldn't be affected by it. Fixing this by doing the whole static link to libasync_safe to libbacktrace.a so that the former is included in libbacktrace.a Exempt-From-Owner-Approval: cherry-pick rvc-dev Bug: 149569129 Test: m Merged-In: If7366a240bc945dda9944fe7c111e10d328165bb (cherry picked from commit 7c8e2b247d2411d76196dc8a56656d39fe40214e) Change-Id: If7366a240bc945dda9944fe7c111e10d328165bb --- libbacktrace/Android.bp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libbacktrace/Android.bp b/libbacktrace/Android.bp index 57531c848..76caadcca 100644 --- a/libbacktrace/Android.bp +++ b/libbacktrace/Android.bp @@ -97,6 +97,9 @@ cc_library { }, android: { static_libs: ["libasync_safe"], + static: { + whole_static_libs: ["libasync_safe"], + }, }, vendor: { cflags: ["-DNO_LIBDEXFILE_SUPPORT"],