From 787322c55f997c1ab88f01f031e189d8fbb3378b Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 1 Jun 2018 19:26:42 +0900 Subject: [PATCH] Build init with shared libraries recovery partition now supports shared librarys. Therefore, init can now be built as a dynamic executable both for normal and recovery modes. To save save in the recovery mode, not all libs are dynamically linked. Libs that are only used by init in the recovery mode are still statically linked. Note: init is still a static executable for legacy devices where system-as-root is not on, because the dynamic linker and shared libs which are in /system are not available when init starts. Bug: 63673171 Test: `adb reboot recovery; adb devices` shows the device ID Test: device boots to the UI in normal mode. Test: do that for both walleye (system-as-root) and bullhead (legacy ramdisk). Change-Id: I30c84ae6a8e507e507ad0bb71acad281316d9e90 --- init/Android.bp | 22 +++++++++++----------- init/Android.mk | 30 ++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/init/Android.bp b/init/Android.bp index 25877c083..7d863c884 100644 --- a/init/Android.bp +++ b/init/Android.bp @@ -67,24 +67,26 @@ cc_defaults { "libsquashfs_utils", "liblogwrap", "libext4_utils", - "libcutils", - "libbase", - "libc", "libseccomp_policy", - "libselinux", - "liblog", "libcrypto_utils", - "libcrypto", - "libc++_static", - "libdl", "libsparse", - "libz", "libprocessgroup", "libavb", "libkeyutils", "libprotobuf-cpp-lite", "libpropertyinfoserializer", "libpropertyinfoparser", + "libselinux", + ], + shared_libs: [ + "libcutils", + "libbase", + "libc", + "liblog", + "libcrypto", + "libc++", + "libdl", + "libz", ], } @@ -166,7 +168,6 @@ cc_binary { cc_test { name: "init_tests", defaults: ["init_defaults"], - static_executable: true, srcs: [ "devices_test.cpp", "init_test.cpp", @@ -187,7 +188,6 @@ cc_test { cc_benchmark { name: "init_benchmarks", - static_executable: true, defaults: ["init_defaults"], srcs: [ "subcontext_benchmark.cpp", diff --git a/init/Android.mk b/init/Android.mk index c4a6a50e5..da27a73f4 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -45,7 +45,6 @@ LOCAL_SRC_FILES := main.cpp LOCAL_MODULE:= init -LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) @@ -59,18 +58,10 @@ LOCAL_STATIC_LIBRARIES := \ libsquashfs_utils \ liblogwrap \ libext4_utils \ - libcutils \ - libbase \ - libc \ libseccomp_policy \ - libselinux \ - liblog \ libcrypto_utils \ - libcrypto \ - libc++_static \ - libdl \ libsparse \ - libz \ + libselinux \ libprocessgroup \ libavb \ libkeyutils \ @@ -78,6 +69,25 @@ LOCAL_STATIC_LIBRARIES := \ libpropertyinfoserializer \ libpropertyinfoparser \ +shared_libs := \ + libcutils \ + libbase \ + liblog \ + libcrypto \ + libdl \ + libz \ + +ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) +# init is static executable for non-system-as-root devices, because the dynamic linker +# and shared libs are not available before /system is mounted, but init has to run +# before the partition is mounted. +LOCAL_STATIC_LIBRARIES += $(shared_libs) libc++_static +LOCAL_FORCE_STATIC_EXECUTABLE := true +else +LOCAL_SHARED_LIBRARIES := $(shared_libs) libc++ +endif +shared_libs := + LOCAL_REQUIRED_MODULES := \ e2fsdroid \ mke2fs \