From a3fb1588f40a0a57350553c1a1afa4dd481438d9 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 16 Aug 2017 18:28:12 +0900 Subject: [PATCH] Prevent vendor libs from depending on private VNDK libraries For module installed to /vendor partition, direct linking to the libs marked as `vendor_available: false` is not allowed. The Bug: 64730695 Test: Add vendor_available: false to libft2 and libcompiler_rt. Add the two libs into LOCAL_SHARED_LIBRARIES of a vendor lib (e.g. libdrm). Build fails with the link_type check error message. Change-Id: Iaf23574ceddb0c087111e1d95997e9ddd60cdf87 --- core/binary.mk | 19 ++++++++++++++++--- core/install_jni_libs_internal.mk | 2 +- core/prebuilt_internal.mk | 11 ++++++++++- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index 45c247799..3e31d9a80 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -1415,9 +1415,22 @@ my_link_type := native:ndk my_warn_types := my_allowed_types := native:ndk else ifdef LOCAL_USE_VNDK -my_link_type := native:vendor -my_warn_types := -my_allowed_types := native:vendor + _name := $(patsubst %.vendor,%,$(LOCAL_MODULE)) + ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),) + ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),) + my_link_type := native:vndk + else + my_link_type := native:vndk_private + endif + my_warn_types := + my_allowed_types := native:vndk native:vndk_private + else + # Modules installed to /vendor cannot directly depend on modules marked + # with vendor_available: false + my_link_type := native:vendor + my_warn_types := + my_allowed_types := native:vendor native:vndk + endif else my_link_type := native:platform my_warn_types := diff --git a/core/install_jni_libs_internal.mk b/core/install_jni_libs_internal.mk index b5f10cfab..265d48241 100644 --- a/core/install_jni_libs_internal.mk +++ b/core/install_jni_libs_internal.mk @@ -116,7 +116,7 @@ my_allowed_types := native:ndk else my_link_type := app:platform my_warn_types := -my_allowed_types := native:ndk native:platform native:vendor +my_allowed_types := native:ndk native:platform native:vendor native:vndk native:vndk_private endif my_link_deps := $(addprefix SHARED_LIBRARIES:,$(LOCAL_JNI_SHARED_LIBRARIES)) diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index f515230e4..5dc46029b 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -155,7 +155,16 @@ export_cflags := ifdef LOCAL_SDK_VERSION my_link_type := native:ndk else ifdef LOCAL_USE_VNDK -my_link_type := native:vendor + _name := $(patsubst %.vendor,%,$(LOCAL_MODULE)) + ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),) + ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),) + my_link_type := native:vndk + else + my_link_type := native:vndk_private + endif + else + my_link_type := native:vendor + endif else my_link_type := native:platform endif