From ecc703c792651c1406592eed9f730c8e97ebc3cf Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Fri, 4 Aug 2017 19:08:06 +0900 Subject: [PATCH] templatize ld.config.txt Lists of libraries in between the linker namespaces are no longer hard-coded in ld.config.txt, but instead come from Soong. Bug: 37139976 Test: build 2017 pixel device with BOARD_VNDK_VERSION=current m -j Test: the device is bootable, basic functionalities (camera, camcorder, wifi, bt, gps, etc.) work. Merged-In: I8170e6c3f6ee04b16359791d64cc46bd2714a073 Change-Id: I8170e6c3f6ee04b16359791d64cc46bd2714a073 (cherry picked from commit 367984602abab743630d1fba8e4940f0a69e678b) --- rootdir/Android.mk | 52 ++++++++++++++++--- .../{ld.config.vndk.txt => ld.config.txt.in} | 13 +++-- 2 files changed, 50 insertions(+), 15 deletions(-) rename rootdir/etc/{ld.config.vndk.txt => ld.config.txt.in} (81%) diff --git a/rootdir/Android.mk b/rootdir/Android.mk index ae75ae299..f747a96ca 100644 --- a/rootdir/Android.mk +++ b/rootdir/Android.mk @@ -178,17 +178,52 @@ bcp_dep := # ld.config.txt include $(CLEAR_VARS) +_enforce_vndk_at_runtime := false + +ifdef BOARD_VNDK_VERSION +ifneq ($(BOARD_VNDK_RUNTIME_DISABLE),true) + _enforce_vndk_at_runtime := true +endif +endif + +ifeq ($(_enforce_vndk_at_runtime),true) +LOCAL_MODULE := ld.config.txt +LOCAL_MODULE_CLASS := ETC +LOCAL_MODULE_PATH := $(TARGET_OUT_ETC) +LOCAL_MODULE_STEM := $(LOCAL_MODULE) +include $(BUILD_SYSTEM)/base_rules.mk +vndk_lib_md5 := $(word 1, $(shell echo $(LLNDK_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) | $(MD5SUM))) +vndk_lib_dep := $(intermediates)/$(vndk_lib_md5).dep +$(vndk_lib_dep): + $(hide) mkdir -p $(dir $@) && rm -rf $(dir $@)*.dep && touch $@ + +llndk_libraries := $(subst $(space),:,$(addsuffix .so,$(LLNDK_LIBRARIES))) + +vndk_sameprocess_libraries := $(subst $(space),:,$(addsuffix .so,$(VNDK_SAMEPROCESS_LIBRARIES))) + +vndk_core_libraries := $(subst $(space),:,$(addsuffix .so,$(VNDK_CORE_LIBRARIES))) + +$(LOCAL_BUILT_MODULE): PRIVATE_LLNDK_LIBRARIES := $(llndk_libraries) +$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_SAMEPROCESS_LIBRARIES := $(vndk_sameprocess_libraries) +$(LOCAL_BUILT_MODULE): PRIVATE_LLNDK_PRIVATE_LIBRARIES := $(llndk_private_libraries) +$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_CORE_LIBRARIES := $(vndk_core_libraries) +$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/etc/ld.config.txt.in $(vndk_lib_dep) + @echo "Generate: $< -> $@" + @mkdir -p $(dir $@) + $(hide) sed -e 's?%LLNDK_LIBRARIES%?$(PRIVATE_LLNDK_LIBRARIES)?g' $< >$@ + $(hide) sed -i -e 's?%VNDK_SAMEPROCESS_LIBRARIES%?$(PRIVATE_VNDK_SAMEPROCESS_LIBRARIES)?g' $@ + $(hide) sed -i -e 's?%VNDK_CORE_LIBRARIES%?$(PRIVATE_VNDK_CORE_LIBRARIES)?g' $@ + +vndk_lib_md5 := +vndk_lib_dep := +llndk_libraries := +vndk_sameprocess_libraries := +vndk_core_libraries := +else # if _enforce_vndk_at_runtime is not true + LOCAL_MODULE := ld.config.txt ifeq ($(PRODUCT_FULL_TREBLE)|$(SANITIZE_TARGET),true|) -ifdef BOARD_VNDK_VERSION - ifeq ($(BOARD_VNDK_RUNTIME_DISABLE),true) - LOCAL_SRC_FILES := etc/ld.config.txt - else - LOCAL_SRC_FILES := etc/ld.config.vndk.txt - endif -else LOCAL_SRC_FILES := etc/ld.config.txt -endif else LOCAL_SRC_FILES := etc/ld.config.legacy.txt endif @@ -196,3 +231,4 @@ LOCAL_MODULE_CLASS := ETC LOCAL_MODULE_PATH := $(TARGET_OUT_ETC) LOCAL_MODULE_STEM := $(LOCAL_MODULE) include $(BUILD_PREBUILT) +endif diff --git a/rootdir/etc/ld.config.vndk.txt b/rootdir/etc/ld.config.txt.in similarity index 81% rename from rootdir/etc/ld.config.vndk.txt rename to rootdir/etc/ld.config.txt.in index adffd92e1..401b0341b 100644 --- a/rootdir/etc/ld.config.vndk.txt +++ b/rootdir/etc/ld.config.txt.in @@ -65,10 +65,10 @@ namespace.sphal.asan.permitted.paths = /data/asan/vendor/${LIB}:/vendor/${LIB} namespace.sphal.links = default,vndk,rs # WARNING: only NDK libs can be listed here. -namespace.sphal.link.default.shared_libs = libEGL.so:libm.so:libandroid_net.so:libvndksupport.so:libc.so:libGLESv1_CM.so:liblog.so:libsync.so:libnativewindow.so:libGLESv3.so:libdl.so:libGLESv2.so +namespace.sphal.link.default.shared_libs = %LLNDK_LIBRARIES% # WARNING: only VNDK-SP libs can be listed here. DO NOT EDIT this line. -namespace.sphal.link.vndk.shared_libs = libhardware.so:libc++.so:libhidlbase.so:libhwbinder.so:libhidltransport.so:libbase.so:libhidlmemory.so:libRS.so:libRSDriver.so:libcutils.so:libion.so:libRSCpuRef.so:android.hardware.graphics.common@1.0.so:android.hardware.graphics.mapper@2.0.so:android.hidl.memory@1.0.so:libbcinfo.so:android.hardware.graphics.allocator@2.0.so:android.hardware.renderscript@1.0.so:libutils.so:libz.so +namespace.sphal.link.vndk.shared_libs = %VNDK_SAMEPROCESS_LIBRARIES% # Renderscript gets separate namespace namespace.sphal.link.rs.shared_libs = libRS_internal.so @@ -90,8 +90,8 @@ namespace.rs.asan.search.paths = /data/asan/vendor/${LIB}/vndk-sp:/vendor/${LIB} namespace.rs.asan.permitted.paths = /data/asan/vendor/${LIB}:/vendor/${LIB}:/data namespace.rs.links = default,vndk -namespace.rs.link.default.shared_libs = libEGL.so:libm.so:libandroid_net.so:libvndksupport.so:libc.so:libGLESv1_CM.so:liblog.so:libsync.so:libnativewindow.so:libGLESv3.so:libdl.so:libGLESv2.so:libmediandk.so:libft2.so -namespace.rs.link.vndk.shared_libs = libhardware.so:libc++.so:libhidlbase.so:libhwbinder.so:libhidltransport.so:libbase.so:libhidlmemory.so:libRS.so:libRSDriver.so:libcutils.so:libion.so:libRSCpuRef.so:android.hardware.graphics.common@1.0.so:android.hardware.graphics.mapper@2.0.so:android.hidl.memory@1.0.so:libbcinfo.so:android.hardware.graphics.allocator@2.0.so:android.hardware.renderscript@1.0.so:libutils.so:libz.so +namespace.rs.link.default.shared_libs = %LLNDK_LIBRARIES% +namespace.rs.link.vndk.shared_libs = %VNDK_SAMEPROCESS_LIBRARIES% ############################################################################### # "vndk" namespace @@ -109,7 +109,7 @@ namespace.vndk.asan.permitted.paths = /data/asan/vendor/${LIB}/hw:/vendor/${LIB} # to the default namespace. This is possible since their ABI is stable across # Android releases. namespace.vndk.links = default -namespace.vndk.link.default.shared_libs = libEGL.so:libm.so:libandroid_net.so:libvndksupport.so:libc.so:libGLESv1_CM.so:liblog.so:libsync.so:libnativewindow.so:libGLESv3.so:libdl.so:libGLESv2.so +namespace.vndk.link.default.shared_libs = %LLNDK_LIBRARIES% ############################################################################### # Namespace config for vendor processes. In O, no restriction is enforced for @@ -135,7 +135,7 @@ namespace.default.asan.search.paths = /data/asan/vendor/${LIB}/hw:/vendor/${LIB} namespace.default.asan.permitted.paths = /data/asan/vendor:/vendor:/data/asan/system/${LIB}/vndk:/system/${LIB}/vndk:/data/asan/system/${LIB}/vndk-sp:/system/${LIB}/vndk-sp namespace.default.links = system -namespace.default.link.system.shared_libs = libEGL.so:libm.so:libandroid_net.so:libvndksupport.so:libc.so:libGLESv1_CM.so:liblog.so:libsync.so:libnativewindow.so:libGLESv3.so:libdl.so:libGLESv2.so:libmedia.so:libandroid_runtime.so +namespace.default.link.system.shared_libs = %LLNDK_LIBRARIES%:libmedia.so:libandroid_runtime.so # libmedia.so must be removed after we have fix for lib-dplmedia.so (b/64427765) # libandroid_runtime.so must be removed after we have a fix for qseeproxydaemon (b/64820887) @@ -150,4 +150,3 @@ namespace.system.permitted.paths = /system/${LIB} namespace.system.asan.search.paths = /data/asan/system/${LIB}:/system/${LIB} namespace.system.asan.permitted.paths = /data/asan/system/${LIB}:/system/${LIB} -