Merge "Use generated linker config only" am: 3c0e06d829 am: eafc79a135

Change-Id: Icf62bc33c37580201f7838feb4897697982e6812
This commit is contained in:
Automerger Merge Worker 2019-12-27 00:25:04 +00:00
commit 799f3fe12a
5 changed files with 6 additions and 1307 deletions

View file

@ -156,122 +156,6 @@ $(strip \
)
endef
#######################################
# ld.config.txt selection variables
#
_enforce_vndk_at_runtime := false
ifdef BOARD_VNDK_VERSION
ifneq ($(BOARD_VNDK_RUNTIME_DISABLE),true)
_enforce_vndk_at_runtime := true
endif
endif
_enforce_vndk_lite_at_runtime := false
ifeq ($(_enforce_vndk_at_runtime),false)
ifeq ($(PRODUCT_TREBLE_LINKER_NAMESPACES)|$(SANITIZE_TARGET),true|)
_enforce_vndk_lite_at_runtime := true
endif
endif
#######################################
# ld.config.txt
#
# For VNDK enforced devices that have defined BOARD_VNDK_VERSION, use
# "ld.config.txt" as a source file. This configuration includes strict VNDK
# run-time restrictions for vendor process.
#
# Other treblized devices, that have not defined BOARD_VNDK_VERSION or that
# have set BOARD_VNDK_RUNTIME_DISABLE to true, use "ld.config.vndk_lite.txt"
# as a source file. This configuration does not have strict VNDK run-time
# restrictions.
#
# If the device is not treblized, use "ld.config.legacy.txt" for legacy
# namespace configuration.
#
include $(CLEAR_VARS)
LOCAL_MODULE := ld.config.txt
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
# Start of i18n and ART APEX compatibility.
#
# Meta-comment:
# The placing of this section is somewhat arbitrary. The LOCAL_POST_INSTALL_CMD
# entries need to be associated with something that goes into /system.
# ld.config.txt qualifies but it could be anything else in /system until soong
# supports creation of symlinks. http://b/123333111
#
# Keeping the appearance of files/dirs having old locations for apps that have
# come to rely on them.
# http://b/121248172 - create a link from /system/usr/icu to
# /apex/com.android.i18n/etc/icu so that apps can find the ICU .dat file.
# A symlink can't overwrite a directory and the /system/usr/icu directory once
# existed so the required structure must be created whatever we find.
LOCAL_POST_INSTALL_CMD = mkdir -p $(TARGET_OUT)/usr && rm -rf $(TARGET_OUT)/usr/icu
LOCAL_POST_INSTALL_CMD += && ln -sf /apex/com.android.i18n/etc/icu $(TARGET_OUT)/usr/icu
# TODO(b/124106384): Clean up compat symlinks for ART binaries.
ART_BINARIES := dalvikvm dex2oat
LOCAL_POST_INSTALL_CMD += && mkdir -p $(TARGET_OUT)/bin
$(foreach b,$(ART_BINARIES), \
$(eval LOCAL_POST_INSTALL_CMD += \
&& ln -sf /apex/com.android.art/bin/$(b) $(TARGET_OUT)/bin/$(b)) \
)
# End of i18n and ART APEX compatibilty.
ifeq ($(_enforce_vndk_at_runtime),true)
# for VNDK enforced devices
# This file will be replaced with dynamically generated one from system/linkerconfig
LOCAL_MODULE_STEM := $(LOCAL_MODULE)
LOCAL_SRC_FILES := etc/ld.config.txt
include $(BUILD_PREBUILT)
else ifeq ($(_enforce_vndk_lite_at_runtime),true)
# for treblized but VNDK lightly enforced devices
LOCAL_MODULE_STEM := ld.config.vndk_lite.txt
include $(BUILD_SYSTEM)/base_rules.mk
ld_config_template := $(LOCAL_PATH)/etc/ld.config.vndk_lite.txt
vndk_version := $(PLATFORM_VNDK_VERSION)
libz_is_llndk := true
include $(LOCAL_PATH)/update_and_install_ld_config.mk
else
# for legacy non-treblized devices
LOCAL_MODULE_STEM := $(LOCAL_MODULE)
LOCAL_SRC_FILES := etc/ld.config.legacy.txt
include $(BUILD_PREBUILT)
endif # ifeq ($(_enforce_vndk_at_runtime),true)
#######################################
# ld.config.vndk_lite.txt
#
# This module is only for GSI.
#
ifeq ($(_enforce_vndk_lite_at_runtime),false)
include $(CLEAR_VARS)
LOCAL_MODULE := ld.config.vndk_lite.txt
LOCAL_MODULE_CLASS := ETC
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
LOCAL_MODULE_STEM := $(LOCAL_MODULE)
include $(BUILD_SYSTEM)/base_rules.mk
ld_config_template := $(LOCAL_PATH)/etc/ld.config.vndk_lite.txt
vndk_version := $(PLATFORM_VNDK_VERSION)
libz_is_llndk := true
include $(LOCAL_PATH)/update_and_install_ld_config.mk
endif # ifeq ($(_enforce_vndk_lite_at_runtime),false)
_enforce_vndk_at_runtime :=
_enforce_vndk_lite_at_runtime :=
#######################################
# sanitizer.libraries.txt
include $(CLEAR_VARS)

View file

@ -1,198 +1,3 @@
# Copyright (C) 2017 The Android Open Source Project
#
# Bionic loader config file.
# This gives the exactly the same namespace setup in pre-O.
#
# All binaries gets the same configuration 'legacy'
dir.legacy = /system
dir.legacy = /product
dir.legacy = /vendor
dir.legacy = /odm
dir.legacy = /sbin
# Except for /postinstall, where only /system and /product are searched
dir.postinstall = /postinstall
# Fallback entry to provide APEX namespace lookups for binaries anywhere else.
# This must be last.
dir.legacy = /data
[legacy]
namespace.default.isolated = false
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.default.visible = true
namespace.default.search.paths = /system/${LIB}
namespace.default.search.paths += /product/${LIB}
namespace.default.search.paths += /vendor/${LIB}
namespace.default.search.paths += /odm/${LIB}
namespace.default.asan.search.paths = /data/asan/system/${LIB}
namespace.default.asan.search.paths += /system/${LIB}
namespace.default.asan.search.paths += /data/asan/product/${LIB}
namespace.default.asan.search.paths += /product/${LIB}
namespace.default.asan.search.paths += /data/asan/vendor/${LIB}
namespace.default.asan.search.paths += /vendor/${LIB}
namespace.default.asan.search.paths += /data/asan/odm/${LIB}
namespace.default.asan.search.paths += /odm/${LIB}
###############################################################################
# APEX related namespaces.
###############################################################################
additional.namespaces = art,conscrypt,media,neuralnetworks,resolv
# Keep in sync with the "platform" namespace in art/build/apex/ld.config.txt.
# If a shared library or an executable requests a shared library that
# cannot be loaded into the default namespace, the dynamic linker tries
# to load the shared library from the art namespace. And then, if the
# shared library cannot be loaded from the art namespace either, the
# dynamic linker tries to load the shared library from the resolv namespace.
# Finally, if all attempts fail, the dynamic linker returns an error.
namespace.default.links = art,resolv,neuralnetworks
namespace.default.asan.links = art,resolv,neuralnetworks
namespace.default.link.art.shared_libs = libandroidicu.so
namespace.default.link.art.shared_libs += libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.art.shared_libs += libpac.so
# When libnetd_resolv.so can't be found in the default namespace, search for it
# in the resolv namespace. Don't allow any other libraries from the resolv namespace
# to be loaded in the default namespace.
namespace.default.link.resolv.shared_libs = libnetd_resolv.so
# LLNDK library moved into apex
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "art" APEX namespace
#
# This namespace exposes externally accessible libraries from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
namespace.art.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.art.visible = true
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default,neuralnetworks
# Need allow_all_shared_libs because libart.so can dlopen oat files in
# /system/framework and /data.
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
namespace.art.link.default.allow_all_shared_libs = true
namespace.art.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "media" APEX namespace
#
# This namespace is for libraries within the media APEX.
###############################################################################
namespace.media.isolated = true
namespace.media.visible = true
namespace.media.search.paths = /apex/com.android.media/${LIB}
namespace.media.asan.search.paths = /apex/com.android.media/${LIB}
namespace.media.permitted.paths = /apex/com.android.media/${LIB}/extractors
namespace.media.links = default
namespace.media.link.default.shared_libs = libbinder_ndk.so
namespace.media.link.default.shared_libs += libc.so
namespace.media.link.default.shared_libs += libcgrouprc.so
namespace.media.link.default.shared_libs += libdl.so
namespace.media.link.default.shared_libs += liblog.so
namespace.media.link.default.shared_libs += libmediametrics.so
namespace.media.link.default.shared_libs += libmediandk.so
namespace.media.link.default.shared_libs += libm.so
namespace.media.link.default.shared_libs += libvndksupport.so
namespace.media.link.default.shared_libs += libclang_rt.asan-aarch64-android.so
namespace.media.link.default.shared_libs += libclang_rt.asan-arm-android.so
namespace.media.link.default.shared_libs += libclang_rt.asan-i686-android.so
namespace.media.link.default.shared_libs += libclang_rt.asan-x86_64-android.so
namespace.media.link.default.shared_libs += libclang_rt.hwasan-aarch64-android.so
###############################################################################
# "conscrypt" APEX namespace
#
# This namespace is for libraries within the conscrypt APEX.
# Keep in sync with the "conscrypt" namespace in art/build/apex/ld.config.txt.
###############################################################################
namespace.conscrypt.isolated = true
namespace.conscrypt.visible = true
namespace.conscrypt.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.asan.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.links = art,default
namespace.conscrypt.link.art.shared_libs = libandroidio.so
namespace.conscrypt.link.default.shared_libs = libc.so
namespace.conscrypt.link.default.shared_libs += libm.so
namespace.conscrypt.link.default.shared_libs += libdl.so
namespace.conscrypt.link.default.shared_libs += liblog.so
###############################################################################
# "resolv" APEX namespace
#
# This namespace is for libraries within the resolv APEX.
###############################################################################
namespace.resolv.isolated = true
namespace.resolv.visible = true
namespace.resolv.search.paths = /apex/com.android.resolv/${LIB}
namespace.resolv.asan.search.paths = /apex/com.android.resolv/${LIB}
namespace.resolv.links = default
namespace.resolv.link.default.shared_libs = libc.so
namespace.resolv.link.default.shared_libs += libcgrouprc.so
namespace.resolv.link.default.shared_libs += libm.so
namespace.resolv.link.default.shared_libs += libdl.so
namespace.resolv.link.default.shared_libs += libbinder_ndk.so
namespace.resolv.link.default.shared_libs += liblog.so
namespace.resolv.link.default.shared_libs += libvndksupport.so
###############################################################################
# "neuralnetworks" APEX namespace
#
# This namespace is for libraries within the NNAPI APEX.
###############################################################################
namespace.neuralnetworks.isolated = true
namespace.neuralnetworks.visible = true
namespace.neuralnetworks.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.asan.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.links = default
namespace.neuralnetworks.link.default.shared_libs = libc.so
namespace.neuralnetworks.link.default.shared_libs += libcgrouprc.so
namespace.neuralnetworks.link.default.shared_libs += libdl.so
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
###############################################################################
# Namespace config for binaries under /postinstall.
# Only one default namespace is defined and it has no directories other than
# /system/lib and /product/lib in the search paths. This is because linker
# calls realpath on the search paths and this causes selinux denial if the
# paths (/vendor, /odm) are not allowed to the poinstall binaries.
# There is no reason to allow the binaries to access the paths.
###############################################################################
[postinstall]
namespace.default.isolated = false
namespace.default.search.paths = /system/${LIB}
namespace.default.search.paths += /product/${LIB}
# This file is no longer in use.
# Please update linker configuration generator instead.
# You can find the code from /system/linkerconfig

View file

@ -1,609 +1,3 @@
# Copyright (C) 2017 The Android Open Source Project
#
# Bionic loader config file.
#
# Don't change the order here. The first pattern that matches with the
# absolute path of an executable is selected.
dir.system = /system/bin/
dir.system = /system/xbin/
dir.system = /%SYSTEM_EXT%/bin/
dir.system = /%PRODUCT%/bin/
dir.vendor = /odm/bin/
dir.vendor = /vendor/bin/
dir.vendor = /data/nativetest/odm
dir.vendor = /data/nativetest64/odm
dir.vendor = /data/benchmarktest/odm
dir.vendor = /data/benchmarktest64/odm
dir.vendor = /data/nativetest/vendor
dir.vendor = /data/nativetest64/vendor
dir.vendor = /data/benchmarktest/vendor
dir.vendor = /data/benchmarktest64/vendor
dir.unrestricted = /data/nativetest/unrestricted
dir.unrestricted = /data/nativetest64/unrestricted
# TODO(b/123864775): Ensure tests are run from /data/nativetest{,64} or (if
# necessary) the unrestricted subdirs above. Then clean this up.
dir.unrestricted = /data/local/tmp
dir.postinstall = /postinstall
# Fallback entry to provide APEX namespace lookups for binaries anywhere else.
# This must be last.
dir.system = /data
[system]
additional.namespaces = art,conscrypt,media,neuralnetworks,resolv,sphal,vndk,rs
###############################################################################
# "default" namespace
#
# Framework-side code runs in this namespace. However, libs from other
# partitions are also allowed temporarily.
###############################################################################
namespace.default.isolated = false
# Visible because some libraries are dlopen'ed, e.g. libopenjdk is dlopen'ed by
# libart.
namespace.default.visible = true
namespace.default.search.paths = /system/${LIB}
namespace.default.search.paths += /%SYSTEM_EXT%/${LIB}
namespace.default.search.paths += /%PRODUCT%/${LIB}
namespace.default.search.paths += /odm/${LIB}
namespace.default.search.paths += /vendor/${LIB}
namespace.default.asan.search.paths = /data/asan/system/${LIB}
namespace.default.asan.search.paths += /system/${LIB}
namespace.default.asan.search.paths += /data/asan/%SYSTEM_EXT%/${LIB}
namespace.default.asan.search.paths += /%SYSTEM_EXT%/${LIB}
namespace.default.asan.search.paths += /data/asan/%PRODUCT%/${LIB}
namespace.default.asan.search.paths += /%PRODUCT%/${LIB}
namespace.default.asan.search.paths += /data/asan/odm/${LIB}
namespace.default.asan.search.paths += /odm/${LIB}
namespace.default.asan.search.paths += /data/asan/vendor/${LIB}
namespace.default.asan.search.paths += /vendor/${LIB}
# Keep in sync with the "platform" namespace in art/build/apex/ld.config.txt.
# If a shared library or an executable requests a shared library that
# cannot be loaded into the default namespace, the dynamic linker tries
# to load the shared library from the art namespace. And then, if the
# shared library cannot be loaded from the art namespace either, the
# dynamic linker tries to load the shared library from the resolv namespace.
# Finally, if all attempts fail, the dynamic linker returns an error.
namespace.default.links = art,resolv,neuralnetworks
namespace.default.link.art.shared_libs = libandroidicu.so
namespace.default.link.art.shared_libs += libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.art.shared_libs += libpac.so
# When libnetd_resolv.so can't be found in the default namespace, search for it
# in the resolv namespace. Don't allow any other libraries from the resolv namespace
# to be loaded in the default namespace.
namespace.default.link.resolv.shared_libs = libnetd_resolv.so
# LLNDK library moved into apex
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "art" APEX namespace
#
# This namespace pulls in externally accessible libs from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
namespace.art.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.art.visible = true
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default,neuralnetworks
# Need allow_all_shared_libs because libart.so can dlopen oat files in
# /system/framework and /data.
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
namespace.art.link.default.allow_all_shared_libs = true
namespace.art.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "media" APEX namespace
#
# This namespace is for libraries within the media APEX.
###############################################################################
namespace.media.isolated = true
namespace.media.visible = true
namespace.media.search.paths = /apex/com.android.media/${LIB}
namespace.media.asan.search.paths = /apex/com.android.media/${LIB}
namespace.media.permitted.paths = /apex/com.android.media/${LIB}/extractors
namespace.media.links = default,neuralnetworks
namespace.media.link.default.shared_libs = %LLNDK_LIBRARIES%
namespace.media.link.default.shared_libs += libbinder_ndk.so
namespace.media.link.default.shared_libs += libmediametrics.so
namespace.media.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
# LLNDK library moved into apex
namespace.media.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "conscrypt" APEX namespace
#
# This namespace is for libraries within the conscrypt APEX.
# Keep in sync with the "conscrypt" namespace in art/build/apex/ld.config.txt.
###############################################################################
namespace.conscrypt.isolated = true
namespace.conscrypt.visible = true
namespace.conscrypt.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.asan.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.links = art,default
namespace.conscrypt.link.art.shared_libs = libandroidio.so
namespace.conscrypt.link.default.shared_libs = libc.so
namespace.conscrypt.link.default.shared_libs += libm.so
namespace.conscrypt.link.default.shared_libs += libdl.so
namespace.conscrypt.link.default.shared_libs += liblog.so
namespace.conscrypt.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
###############################################################################
# "resolv" APEX namespace
#
# This namespace is for libraries within the resolv APEX.
###############################################################################
namespace.resolv.isolated = true
namespace.resolv.visible = true
namespace.resolv.search.paths = /apex/com.android.resolv/${LIB}
namespace.resolv.asan.search.paths = /apex/com.android.resolv/${LIB}
namespace.resolv.links = default
namespace.resolv.link.default.shared_libs = libc.so
namespace.resolv.link.default.shared_libs += libcgrouprc.so
namespace.resolv.link.default.shared_libs += libm.so
namespace.resolv.link.default.shared_libs += libdl.so
namespace.resolv.link.default.shared_libs += libbinder_ndk.so
namespace.resolv.link.default.shared_libs += liblog.so
namespace.resolv.link.default.shared_libs += libvndksupport.so
namespace.resolv.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
###############################################################################
# "sphal" namespace
#
# SP-HAL(Sameprocess-HAL)s are the only vendor libraries that are allowed to be
# loaded inside system processes. libEGL_<chipset>.so, libGLESv2_<chipset>.so,
# android.hardware.graphics.mapper@2.0-impl.so, etc are SP-HALs.
#
# This namespace is exclusivly for SP-HALs. When the framework tries to dynami-
# cally load SP-HALs, android_dlopen_ext() is used to explicitly specifying
# that they should be searched and loaded from this namespace.
#
# Note that there is no link from the default namespace to this namespace.
###############################################################################
namespace.sphal.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.sphal.visible = true
namespace.sphal.search.paths = /odm/${LIB}
namespace.sphal.search.paths += /vendor/${LIB}
namespace.sphal.search.paths += /vendor/${LIB}/hw
namespace.sphal.permitted.paths = /odm/${LIB}
namespace.sphal.permitted.paths += /vendor/${LIB}
namespace.sphal.permitted.paths += /system/vendor/${LIB}
namespace.sphal.asan.search.paths = /data/asan/odm/${LIB}
namespace.sphal.asan.search.paths += /odm/${LIB}
namespace.sphal.asan.search.paths += /data/asan/vendor/${LIB}
namespace.sphal.asan.search.paths += /vendor/${LIB}
namespace.sphal.asan.permitted.paths = /data/asan/odm/${LIB}
namespace.sphal.asan.permitted.paths += /odm/${LIB}
namespace.sphal.asan.permitted.paths += /data/asan/vendor/${LIB}
namespace.sphal.asan.permitted.paths += /vendor/${LIB}
# Once in this namespace, access to libraries in /system/lib is restricted. Only
# libs listed here can be used. Order is important here as the namespaces are
# tried in this order. rs should be before vndk because both are capable
# of loading libRS_internal.so
namespace.sphal.links = rs,default,vndk,neuralnetworks
# Renderscript gets separate namespace
namespace.sphal.link.rs.shared_libs = libRS_internal.so
namespace.sphal.link.default.shared_libs = %LLNDK_LIBRARIES%
namespace.sphal.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
namespace.sphal.link.vndk.shared_libs = %VNDK_SAMEPROCESS_LIBRARIES%
# LLNDK library moved into apex
namespace.sphal.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "rs" namespace
#
# This namespace is exclusively for Renderscript internal libraries.
# This namespace has slightly looser restriction than the vndk namespace because
# of the genuine characteristics of Renderscript; /data is in the permitted path
# to load the compiled *.so file and libmediandk.so can be used here.
###############################################################################
namespace.rs.isolated = true
namespace.rs.visible = true
namespace.rs.search.paths = /odm/${LIB}/vndk-sp
namespace.rs.search.paths += /vendor/${LIB}/vndk-sp
namespace.rs.search.paths += /system/${LIB}/vndk-sp%VNDK_VER%
namespace.rs.search.paths += /odm/${LIB}
namespace.rs.search.paths += /vendor/${LIB}
namespace.rs.permitted.paths = /odm/${LIB}
namespace.rs.permitted.paths += /vendor/${LIB}
namespace.rs.permitted.paths += /system/vendor/${LIB}
namespace.rs.permitted.paths += /data
namespace.rs.asan.search.paths = /data/asan/odm/${LIB}/vndk-sp
namespace.rs.asan.search.paths += /odm/${LIB}/vndk-sp
namespace.rs.asan.search.paths += /data/asan/vendor/${LIB}/vndk-sp
namespace.rs.asan.search.paths += /vendor/${LIB}/vndk-sp
namespace.rs.asan.search.paths += /data/asan/system/${LIB}/vndk-sp%VNDK_VER%
namespace.rs.asan.search.paths += /system/${LIB}/vndk-sp%VNDK_VER%
namespace.rs.asan.search.paths += /data/asan/odm/${LIB}
namespace.rs.asan.search.paths += /odm/${LIB}
namespace.rs.asan.search.paths += /data/asan/vendor/${LIB}
namespace.rs.asan.search.paths += /vendor/${LIB}
namespace.rs.asan.permitted.paths = /data/asan/odm/${LIB}
namespace.rs.asan.permitted.paths += /odm/${LIB}
namespace.rs.asan.permitted.paths += /data/asan/vendor/${LIB}
namespace.rs.asan.permitted.paths += /vendor/${LIB}
namespace.rs.asan.permitted.paths += /data
namespace.rs.links = default,neuralnetworks
namespace.rs.link.default.shared_libs = %LLNDK_LIBRARIES%
namespace.rs.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
# Private LLNDK libs (e.g. libft2.so) are exceptionally allowed to this
# namespace because RS framework libs are using them.
namespace.rs.link.default.shared_libs += %PRIVATE_LLNDK_LIBRARIES%
# LLNDK library moved into apex
namespace.rs.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "vndk" namespace
#
# This namespace is exclusively for vndk-sp libs.
###############################################################################
namespace.vndk.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.vndk.visible = true
namespace.vndk.search.paths = /odm/${LIB}/vndk-sp
namespace.vndk.search.paths += /vendor/${LIB}/vndk-sp
namespace.vndk.search.paths += /system/${LIB}/vndk-sp%VNDK_VER%
namespace.vndk.permitted.paths = /odm/${LIB}/hw
namespace.vndk.permitted.paths += /odm/${LIB}/egl
namespace.vndk.permitted.paths += /vendor/${LIB}/hw
namespace.vndk.permitted.paths += /vendor/${LIB}/egl
namespace.vndk.permitted.paths += /system/vendor/${LIB}/egl
# This is exceptionally required since android.hidl.memory@1.0-impl.so is here
namespace.vndk.permitted.paths += /system/${LIB}/vndk-sp%VNDK_VER%/hw
namespace.vndk.asan.search.paths = /data/asan/odm/${LIB}/vndk-sp
namespace.vndk.asan.search.paths += /odm/${LIB}/vndk-sp
namespace.vndk.asan.search.paths += /data/asan/vendor/${LIB}/vndk-sp
namespace.vndk.asan.search.paths += /vendor/${LIB}/vndk-sp
namespace.vndk.asan.search.paths += /data/asan/system/${LIB}/vndk-sp%VNDK_VER%
namespace.vndk.asan.search.paths += /system/${LIB}/vndk-sp%VNDK_VER%
namespace.vndk.asan.permitted.paths = /data/asan/odm/${LIB}/hw
namespace.vndk.asan.permitted.paths += /odm/${LIB}/hw
namespace.vndk.asan.permitted.paths += /data/asan/odm/${LIB}/egl
namespace.vndk.asan.permitted.paths += /odm/${LIB}/egl
namespace.vndk.asan.permitted.paths += /data/asan/vendor/${LIB}/hw
namespace.vndk.asan.permitted.paths += /vendor/${LIB}/hw
namespace.vndk.asan.permitted.paths += /data/asan/vendor/${LIB}/egl
namespace.vndk.asan.permitted.paths += /vendor/${LIB}/egl
namespace.vndk.asan.permitted.paths += /data/asan/system/${LIB}/vndk-sp%VNDK_VER%/hw
namespace.vndk.asan.permitted.paths += /system/${LIB}/vndk-sp%VNDK_VER%/hw
# When these NDK libs are required inside this namespace, then it is redirected
# to the default namespace. This is possible since their ABI is stable across
# Android releases.
namespace.vndk.links = default,neuralnetworks
namespace.vndk.link.default.shared_libs = %LLNDK_LIBRARIES%
namespace.vndk.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
namespace.vndk.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "neuralnetworks" APEX namespace
#
# This namespace is for libraries within the NNAPI APEX.
###############################################################################
namespace.neuralnetworks.isolated = true
namespace.neuralnetworks.visible = true
namespace.neuralnetworks.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.asan.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.links = default
namespace.neuralnetworks.link.default.shared_libs = libc.so
namespace.neuralnetworks.link.default.shared_libs += libcgrouprc.so
namespace.neuralnetworks.link.default.shared_libs += libdl.so
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
namespace.neuralnetworks.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
###############################################################################
# Namespace config for vendor processes. In O, no restriction is enforced for
# them. However, in O-MR1, access to /system/${LIB} will not be allowed to
# the default namespace. 'system' namespace will be added to give limited
# (LL-NDK only) access.
###############################################################################
[vendor]
additional.namespaces = art,neuralnetworks
namespace.default.isolated = false
namespace.default.search.paths = /odm/${LIB}
namespace.default.search.paths += /odm/${LIB}/vndk
namespace.default.search.paths += /odm/${LIB}/vndk-sp
namespace.default.search.paths += /vendor/${LIB}
namespace.default.search.paths += /vendor/${LIB}/vndk
namespace.default.search.paths += /vendor/${LIB}/vndk-sp
# Access to system libraries is allowed
namespace.default.search.paths += /system/${LIB}/vndk-sp%VNDK_VER%
namespace.default.search.paths += /system/${LIB}
namespace.default.search.paths += /%SYSTEM_EXT%/${LIB}
namespace.default.search.paths += /%PRODUCT%/${LIB}
# Put /system/lib/vndk at the last search order in vndk_lite for GSI
namespace.default.search.paths += /system/${LIB}/vndk%VNDK_VER%
namespace.default.asan.search.paths = /data/asan/odm/${LIB}
namespace.default.asan.search.paths += /odm/${LIB}
namespace.default.asan.search.paths += /data/asan/odm/${LIB}/vndk
namespace.default.asan.search.paths += /odm/${LIB}/vndk
namespace.default.asan.search.paths += /data/asan/odm/${LIB}/vndk-sp
namespace.default.asan.search.paths += /odm/${LIB}/vndk-sp
namespace.default.asan.search.paths += /data/asan/vendor/${LIB}
namespace.default.asan.search.paths += /vendor/${LIB}
namespace.default.asan.search.paths += /data/asan/vendor/${LIB}/vndk
namespace.default.asan.search.paths += /vendor/${LIB}/vndk
namespace.default.asan.search.paths += /data/asan/vendor/${LIB}/vndk-sp
namespace.default.asan.search.paths += /vendor/${LIB}/vndk-sp
namespace.default.asan.search.paths += /data/asan/system/${LIB}/vndk-sp%VNDK_VER%
namespace.default.asan.search.paths += /system/${LIB}/vndk-sp%VNDK_VER%
namespace.default.asan.search.paths += /data/asan/system/${LIB}
namespace.default.asan.search.paths += /system/${LIB}
namespace.default.asan.search.paths += /data/asan/%SYSTEM_EXT%/${LIB}
namespace.default.asan.search.paths += /%SYSTEM_EXT%/${LIB}
namespace.default.asan.search.paths += /data/asan/%PRODUCT%/${LIB}
namespace.default.asan.search.paths += /%PRODUCT%/${LIB}
namespace.default.asan.search.paths += /data/asan/system/${LIB}/vndk%VNDK_VER%
namespace.default.asan.search.paths += /system/${LIB}/vndk%VNDK_VER%
namespace.default.links = art,neuralnetworks
namespace.default.link.art.shared_libs = libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# Workaround for b/124772622
namespace.default.link.art.shared_libs += libandroidicu.so
# LLNDK library moved into apex
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "art" APEX namespace
#
# This namespace exposes externally accessible libraries from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
namespace.art.isolated = true
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
namespace.art.link.default.allow_all_shared_libs = true
###############################################################################
# "neuralnetworks" APEX namespace
#
# This namespace is for libraries within the NNAPI APEX.
###############################################################################
namespace.neuralnetworks.isolated = true
namespace.neuralnetworks.visible = true
namespace.neuralnetworks.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.asan.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.links = default
namespace.neuralnetworks.link.default.shared_libs = libc.so
namespace.neuralnetworks.link.default.shared_libs += libcgrouprc.so
namespace.neuralnetworks.link.default.shared_libs += libdl.so
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
namespace.neuralnetworks.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
###############################################################################
# Namespace config for native tests that need access to both system and vendor
# libraries. This replicates the default linker config (done by
# init_default_namespace_no_config in bionic/linker/linker.cpp), except that it
# includes the requisite namespace setup for APEXes.
###############################################################################
[unrestricted]
additional.namespaces = art,media,conscrypt,resolv,neuralnetworks
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.default.visible = true
namespace.default.search.paths = /system/${LIB}
namespace.default.search.paths += /odm/${LIB}
namespace.default.search.paths += /vendor/${LIB}
namespace.default.asan.search.paths = /data/asan/system/${LIB}
namespace.default.asan.search.paths += /system/${LIB}
namespace.default.asan.search.paths += /data/asan/odm/${LIB}
namespace.default.asan.search.paths += /odm/${LIB}
namespace.default.asan.search.paths += /data/asan/vendor/${LIB}
namespace.default.asan.search.paths += /vendor/${LIB}
# Keep in sync with the "platform" namespace in art/build/apex/ld.config.txt.
namespace.default.links = art,resolv,neuralnetworks
namespace.default.link.art.shared_libs = libandroidicu.so
namespace.default.link.art.shared_libs += libdexfile_external.so
namespace.default.link.art.shared_libs += libdexfiled_external.so
# TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept for app compat.
namespace.default.link.art.shared_libs += libicui18n.so
namespace.default.link.art.shared_libs += libicuuc.so
namespace.default.link.art.shared_libs += libnativebridge.so
namespace.default.link.art.shared_libs += libnativehelper.so
namespace.default.link.art.shared_libs += libnativeloader.so
# TODO(b/122876336): Remove libpac.so once it's migrated to Webview
namespace.default.link.art.shared_libs += libpac.so
namespace.default.link.resolv.shared_libs = libnetd_resolv.so
# LLNDK library moved into apex
namespace.default.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "art" APEX namespace
#
# This namespace exposes externally accessible libraries from the ART APEX.
# Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
###############################################################################
namespace.art.isolated = true
# Visible to allow links to be created at runtime, e.g. through
# android_link_namespaces in libnativeloader.
namespace.art.visible = true
namespace.art.search.paths = /apex/com.android.art/${LIB}
namespace.art.asan.search.paths = /apex/com.android.art/${LIB}
namespace.art.links = default
# TODO(b/130340935): Use a dynamically created linker namespace similar to
# classloader-namespace for oat files, and tighten this up.
namespace.runtime.link.default.allow_all_shared_libs = true
###############################################################################
# "media" APEX namespace
#
# This namespace is for libraries within the media APEX.
###############################################################################
namespace.media.isolated = true
namespace.media.visible = true
namespace.media.search.paths = /apex/com.android.media/${LIB}
namespace.media.asan.search.paths = /apex/com.android.media/${LIB}
namespace.media.permitted.paths = /apex/com.android.media/${LIB}/extractors
namespace.media.links = default,neuralnetworks
namespace.media.link.default.shared_libs = %LLNDK_LIBRARIES%
namespace.media.link.default.shared_libs += libbinder_ndk.so
namespace.media.link.default.shared_libs += libmediametrics.so
namespace.media.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
# LLNDK library moved into apex
namespace.media.link.neuralnetworks.shared_libs = libneuralnetworks.so
###############################################################################
# "conscrypt" APEX namespace
#
# This namespace is for libraries within the conscrypt APEX.
# Keep in sync with the "conscrypt" namespace in art/build/apex/ld.config.txt.
###############################################################################
namespace.conscrypt.isolated = true
namespace.conscrypt.visible = true
namespace.conscrypt.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.asan.search.paths = /apex/com.android.conscrypt/${LIB}
namespace.conscrypt.links = art,default
namespace.conscrypt.link.art.shared_libs = libandroidio.so
namespace.conscrypt.link.default.shared_libs = libc.so
namespace.conscrypt.link.default.shared_libs += libm.so
namespace.conscrypt.link.default.shared_libs += libdl.so
namespace.conscrypt.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
###############################################################################
# "resolv" APEX namespace
#
# This namespace is for libraries within the resolv APEX.
###############################################################################
namespace.resolv.isolated = true
namespace.resolv.visible = true
namespace.resolv.search.paths = /apex/com.android.resolv/${LIB}
namespace.resolv.asan.search.paths = /apex/com.android.resolv/${LIB}
namespace.resolv.links = default
namespace.resolv.link.default.shared_libs = libc.so
namespace.resolv.link.default.shared_libs += libcgrouprc.so
namespace.resolv.link.default.shared_libs += libm.so
namespace.resolv.link.default.shared_libs += libdl.so
namespace.resolv.link.default.shared_libs += libbinder_ndk.so
namespace.resolv.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
###############################################################################
# "neuralnetworks" APEX namespace
#
# This namespace is for libraries within the NNAPI APEX.
###############################################################################
namespace.neuralnetworks.isolated = true
namespace.neuralnetworks.visible = true
namespace.neuralnetworks.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.asan.search.paths = /apex/com.android.neuralnetworks/${LIB}
namespace.neuralnetworks.links = default
namespace.neuralnetworks.link.default.shared_libs = libc.so
namespace.neuralnetworks.link.default.shared_libs += libcgrouprc.so
namespace.neuralnetworks.link.default.shared_libs += libdl.so
namespace.neuralnetworks.link.default.shared_libs += liblog.so
namespace.neuralnetworks.link.default.shared_libs += libm.so
namespace.neuralnetworks.link.default.shared_libs += libnativewindow.so
namespace.neuralnetworks.link.default.shared_libs += libneuralnetworks_packageinfo.so
namespace.neuralnetworks.link.default.shared_libs += libsync.so
namespace.neuralnetworks.link.default.shared_libs += libvndksupport.so
namespace.neuralnetworks.link.default.shared_libs += %SANITIZER_RUNTIME_LIBRARIES%
###############################################################################
# Namespace config for binaries under /postinstall.
# Only default namespace is defined and default has no directories
# other than /system/lib in the search paths. This is because linker calls
# realpath on the search paths and this causes selinux denial if the paths
# (/vendor, /odm) are not allowed to the postinstall binaries. There is no
# reason to allow the binaries to access the paths.
###############################################################################
[postinstall]
namespace.default.isolated = false
namespace.default.search.paths = /system/${LIB}
namespace.default.search.paths += /%SYSTEM_EXT%/${LIB}
namespace.default.search.paths += /%PRODUCT%/${LIB}
# This file is no longer in use.
# Please update linker configuration generator instead.
# You can find the code from /system/linkerconfig

View file

@ -1,177 +0,0 @@
#!/usr/bin/env python
#
# Copyright (C) 2018 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import glob
import os.path
import re
import sys
PREBUILTS_VNDK_DIR = "prebuilts/vndk"
VENDOR_DIRECTORIES = ('/vendor', '/odm')
def find_latest_vndk_snapshot_version():
"""Returns latest vndk snapshot version in current source tree.
It will skip the test if the snapshot directories are not found.
Returns:
latest_version: string
"""
vndk_dir_list = glob.glob(PREBUILTS_VNDK_DIR + "/v*")
if not vndk_dir_list:
"""Exit without error because we may have source trees that do not include
VNDK snapshot directories in it.
"""
sys.exit(0)
vndk_ver_list = [re.match(r".*/v(\d+)", vndk_dir).group(1)
for vndk_dir in vndk_dir_list]
latest_version = max(vndk_ver_list)
if latest_version == '27':
"""Exit without error because VNDK v27 is not using ld.config.txt template
"""
sys.exit(0)
return latest_version
def get_vendor_configuration(ld_config_file):
"""Reads the ld.config.txt file to parse the namespace configurations.
It finds the configurations that include vendor directories.
Args:
ld_config_file: string, path (relative to build top) of the ld.config.txt
file.
Returns:
configs: dict{string:[string]}, dictionary of namespace configurations.
it has 'section + property' names as keys and the directory list
as values.
"""
try:
conf_file = open(ld_config_file)
except IOError:
print("error: could not read %s" % ld_config_file)
sys.exit(1)
configs = dict()
current_section = None
with conf_file:
for line in conf_file:
# ignore comments
found = line.find('#')
if found != -1:
line = line[:found]
line = line.strip()
if not line:
continue
if line[0] == '[' and line[-1] == ']':
# new section started
current_section = line[1:-1]
continue
if current_section == None:
continue
found = line.find('+=')
opr_len = 2
if found == -1:
found = line.find('=')
opr_len = 1
if found == -1:
continue
namespace = line[:found].strip()
if not namespace.endswith(".paths"):
# check ".paths" only
continue
namespace = '[' + current_section + ']' + namespace
values = line[found + opr_len:].strip()
directories = values.split(':')
for directory in directories:
if any(vendor_dir in directory for vendor_dir in VENDOR_DIRECTORIES):
if namespace in configs:
configs[namespace].append(directory)
else:
configs[namespace] = [directory]
return configs
def get_snapshot_config(version):
"""Finds the ld.config.{version}.txt file from the VNDK snapshot directory.
In the vndk prebuilt directory (prebuilts/vndk/v{version}), it searches
{arch}/configs/ld.config.{version}.txt file, where {arch} is one of ('arm64',
'arm', 'x86_64', 'x86').
Args:
version: string, the VNDK snapshot version to search.
Returns:
ld_config_file: string, relative path to ld.config.{version}.txt
"""
arch_list = ('arm64', 'arm', 'x86_64', 'x86')
for arch in arch_list:
ld_config_file = (PREBUILTS_VNDK_DIR
+ "/v{0}/{1}/configs/ld.config.{0}.txt".format(version, arch))
if os.path.isfile(ld_config_file):
return ld_config_file
print("error: cannot find ld.config.{0}.txt file in snapshot v{0}"
.format(version))
sys.exit(1)
def check_backward_compatibility(ld_config, vndk_snapshot_version):
"""Checks backward compatibility for current ld.config.txt file with the
old ld.config.txt file. If any of the vendor directories in the old namespace
configurations are missing, the test will fail. It is allowed to have new
vendor directories in current ld.config.txt file.
Args:
ld_config: string, relative path to current ld.config.txt file.
vndk_snapshot_version: string, the VNDK snapshot version that has an old
ld.config.txt file to compare.
Returns:
result: bool, True if the current configuration is backward compatible.
"""
current_config = get_vendor_configuration(ld_config)
old_config = get_vendor_configuration(
get_snapshot_config(vndk_snapshot_version))
for namespace in old_config:
if namespace not in current_config:
print("error: cannot find %s which was provided in ld.config.%s.txt"
% (namespace, vndk_snapshot_version))
return False
for path in old_config[namespace]:
if not path in current_config[namespace]:
print("error: %s for %s in ld.config.%s.txt are missing in %s"
% (path, namespace, vndk_snapshot_version, ld_config))
return False
return True
def main():
if len(sys.argv) != 2:
print ("Usage: %s target_ld_config_txt_file_name" % sys.argv[0])
sys.exit(1)
latest_vndk_snapshot_version = find_latest_vndk_snapshot_version()
if not check_backward_compatibility(sys.argv[1],
latest_vndk_snapshot_version):
print("error: %s has backward incompatible changes to old "
"vendor partition." % sys.argv[1])
sys.exit(1)
# Current ld.config.txt file is backward compatible
sys.exit(0)
if __name__ == '__main__':
main()

View file

@ -1,207 +0,0 @@
#####################################################################
# Builds linker config file, ld.config.txt, from the specified template
# under $(LOCAL_PATH)/etc/*.
#
# Inputs:
# (expected to follow an include of $(BUILD_SYSTEM)/base_rules.mk)
# ld_config_template: template linker config file to use,
# e.g. $(LOCAL_PATH)/etc/ld.config.txt
# vndk_version: version of the VNDK library lists used to update the
# template linker config file, e.g. 28
# lib_list_from_prebuilts: should be set to 'true' if the VNDK library
# lists should be read from /prebuilts/vndk/*
# libz_is_llndk: should be set to 'true' if libz must be included in
# llndk and not in vndk-sp
# Outputs:
# Builds and installs ld.config.$VER.txt or ld.config.vndk_lite.txt
#####################################################################
# Read inputs
ld_config_template := $(strip $(ld_config_template))
check_backward_compatibility := $(strip $(check_backward_compatibility))
vndk_version := $(strip $(vndk_version))
lib_list_from_prebuilts := $(strip $(lib_list_from_prebuilts))
libz_is_llndk := $(strip $(libz_is_llndk))
my_vndk_use_core_variant := $(TARGET_VNDK_USE_CORE_VARIANT)
ifeq ($(lib_list_from_prebuilts),true)
my_vndk_use_core_variant := false
endif
compatibility_check_script := \
$(LOCAL_PATH)/ld_config_backward_compatibility_check.py
intermediates_dir := $(call intermediates-dir-for,ETC,$(LOCAL_MODULE))
library_lists_dir := $(intermediates_dir)
ifeq ($(lib_list_from_prebuilts),true)
library_lists_dir := prebuilts/vndk/v$(vndk_version)/$(TARGET_ARCH)/configs
endif
llndk_libraries_file := $(library_lists_dir)/llndk.libraries.$(vndk_version).txt
vndksp_libraries_file := $(library_lists_dir)/vndksp.libraries.$(vndk_version).txt
vndkcore_libraries_file := $(library_lists_dir)/vndkcore.libraries.$(vndk_version).txt
vndkprivate_libraries_file := $(library_lists_dir)/vndkprivate.libraries.$(vndk_version).txt
llndk_moved_to_apex_libraries_file := $(library_lists_dir)/llndkinapex.libraries.txt
ifeq ($(my_vndk_use_core_variant),true)
vndk_using_core_variant_libraries_file := $(library_lists_dir)/vndk_using_core_variant.libraries.$(vndk_version).txt
endif
sanitizer_runtime_libraries := $(call normalize-path-list,$(addsuffix .so,\
$(ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
$(HWADDRESS_SANITIZER_RUNTIME_LIBRARY) \
$(UBSAN_RUNTIME_LIBRARY) \
$(TSAN_RUNTIME_LIBRARY) \
$(2ND_ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
$(2ND_HWADDRESS_SANITIZER_RUNTIME_LIBRARY) \
$(2ND_UBSAN_RUNTIME_LIBRARY) \
$(2ND_TSAN_RUNTIME_LIBRARY)))
# If BOARD_VNDK_VERSION is not defined, VNDK version suffix will not be used.
vndk_version_suffix := $(if $(vndk_version),-$(vndk_version))
ifneq ($(lib_list_from_prebuilts),true)
ifeq ($(libz_is_llndk),true)
llndk_libraries_list := $(LLNDK_LIBRARIES) libz
vndksp_libraries_list := $(filter-out libz,$(VNDK_SAMEPROCESS_LIBRARIES))
else
llndk_libraries_list := $(LLNDK_LIBRARIES)
vndksp_libraries_list := $(VNDK_SAMEPROCESS_LIBRARIES)
endif
# LLNDK libraries that has been moved to an apex package and no longer are present on
# /system image.
llndk_libraries_moved_to_apex_list:=$(LLNDK_MOVED_TO_APEX_LIBRARIES)
# Returns the unique installed basenames of a module, or module.so if there are
# none. The guess is to handle cases like libc, where the module itself is
# marked uninstallable but a symlink is installed with the name libc.so.
# $(1): list of libraries
# $(2): suffix to to add to each library (not used for guess)
define module-installed-files-or-guess
$(foreach lib,$(1),$(or $(strip $(sort $(notdir $(call module-installed-files,$(lib)$(2))))),$(lib).so))
endef
# $(1): list of libraries
# $(2): suffix to add to each library
# $(3): output file to write the list of libraries to
define write-libs-to-file
$(3): PRIVATE_LIBRARIES := $(1)
$(3): PRIVATE_SUFFIX := $(2)
$(3):
echo -n > $$@ && $$(foreach so,$$(call module-installed-files-or-guess,$$(PRIVATE_LIBRARIES),$$(PRIVATE_SUFFIX)),echo $$(so) >> $$@;)
endef
$(eval $(call write-libs-to-file,$(llndk_libraries_list),,$(llndk_libraries_file)))
$(eval $(call write-libs-to-file,$(vndksp_libraries_list),.vendor,$(vndksp_libraries_file)))
$(eval $(call write-libs-to-file,$(VNDK_CORE_LIBRARIES),.vendor,$(vndkcore_libraries_file)))
$(eval $(call write-libs-to-file,$(VNDK_PRIVATE_LIBRARIES),.vendor,$(vndkprivate_libraries_file)))
ifeq ($(my_vndk_use_core_variant),true)
$(eval $(call write-libs-to-file,$(VNDK_USING_CORE_VARIANT_LIBRARIES),,$(vndk_using_core_variant_libraries_file)))
endif
endif # ifneq ($(lib_list_from_prebuilts),true)
# Given a file with a list of libs, filter-out the VNDK private libraries
# and write resulting list to a new file in "a:b:c" format
#
# $(1): libs file from which to filter-out VNDK private libraries
# $(2): output file with the filtered list of lib names
$(LOCAL_BUILT_MODULE): private-filter-out-private-libs = \
paste -sd ":" $(1) > $(2) && \
while read -r privatelib; do sed -i.bak "s/$$privatelib//" $(2) ; done < $(PRIVATE_VNDK_PRIVATE_LIBRARIES_FILE) && \
sed -i.bak -e 's/::\+/:/g ; s/^:\+// ; s/:\+$$//' $(2) && \
rm -f $(2).bak
# # Given a file with a list of libs in "a:b:c" format, filter-out the LLNDK libraries migrated into apex file
# # and write resulting list to a new file in "a:b:c" format
$(LOCAL_BUILT_MODULE): private-filter-out-llndk-in-apex-libs = \
for lib in $(PRIVATE_LLNDK_LIBRARIES_MOVED_TO_APEX_LIST); do sed -i.bak s/$$lib.so// $(1); done && \
sed -i.bak -e 's/::\+/:/g ; s/^:\+// ; s/:\+$$//' $(1) && \
rm -f $(1).bak
$(LOCAL_BUILT_MODULE): PRIVATE_LLNDK_LIBRARIES_FILE := $(llndk_libraries_file)
$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_SP_LIBRARIES_FILE := $(vndksp_libraries_file)
$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_CORE_LIBRARIES_FILE := $(vndkcore_libraries_file)
$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_PRIVATE_LIBRARIES_FILE := $(vndkprivate_libraries_file)
$(LOCAL_BUILT_MODULE): PRIVATE_SANITIZER_RUNTIME_LIBRARIES := $(sanitizer_runtime_libraries)
$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_VERSION_SUFFIX := $(vndk_version_suffix)
$(LOCAL_BUILT_MODULE): PRIVATE_INTERMEDIATES_DIR := $(intermediates_dir)
$(LOCAL_BUILT_MODULE): PRIVATE_COMP_CHECK_SCRIPT := $(compatibility_check_script)
$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_VERSION_TAG := \#VNDK$(vndk_version)\#
$(LOCAL_BUILT_MODULE): PRIVATE_LLNDK_LIBRARIES_MOVED_TO_APEX_LIST := $(llndk_libraries_moved_to_apex_list)
deps := $(llndk_libraries_file) $(vndksp_libraries_file) $(vndkcore_libraries_file) \
$(vndkprivate_libraries_file)
ifeq ($(check_backward_compatibility),true)
deps += $(compatibility_check_script) $(wildcard prebuilts/vndk/*/*/configs/ld.config.*.txt)
endif
ifeq ($(my_vndk_use_core_variant),true)
$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_USING_CORE_VARIANT_LIBRARIES_FILE := $(vndk_using_core_variant_libraries_file)
deps += $(vndk_using_core_variant_libraries_file)
endif
$(LOCAL_BUILT_MODULE): $(ld_config_template) $(deps)
@echo "Generate: $< -> $@"
ifeq ($(check_backward_compatibility),true)
@echo "Checking backward compatibility..."
$(hide) $(PRIVATE_COMP_CHECK_SCRIPT) $<
endif
@mkdir -p $(dir $@)
$(call private-filter-out-private-libs,$(PRIVATE_LLNDK_LIBRARIES_FILE),$(PRIVATE_INTERMEDIATES_DIR)/llndk_filtered)
$(call private-filter-out-llndk-in-apex-libs,$(PRIVATE_INTERMEDIATES_DIR)/llndk_filtered)
$(hide) sed -e "s?%LLNDK_LIBRARIES%?$$(cat $(PRIVATE_INTERMEDIATES_DIR)/llndk_filtered)?g" $< >$@
$(call private-filter-out-private-libs,$(PRIVATE_VNDK_SP_LIBRARIES_FILE),$(PRIVATE_INTERMEDIATES_DIR)/vndksp_filtered)
$(hide) sed -i.bak -e "s?%VNDK_SAMEPROCESS_LIBRARIES%?$$(cat $(PRIVATE_INTERMEDIATES_DIR)/vndksp_filtered)?g" $@
$(call private-filter-out-private-libs,$(PRIVATE_VNDK_CORE_LIBRARIES_FILE),$(PRIVATE_INTERMEDIATES_DIR)/vndkcore_filtered)
$(hide) sed -i.bak -e "s?%VNDK_CORE_LIBRARIES%?$$(cat $(PRIVATE_INTERMEDIATES_DIR)/vndkcore_filtered)?g" $@
ifeq ($(my_vndk_use_core_variant),true)
$(call private-filter-out-private-libs,$(PRIVATE_VNDK_USING_CORE_VARIANT_LIBRARIES_FILE),$(PRIVATE_INTERMEDIATES_DIR)/vndk_using_core_variant_filtered)
$(hide) sed -i.bak -e "s?%VNDK_IN_SYSTEM_NS%?,vndk_in_system?g" $@
$(hide) sed -i.bak -e "s?%VNDK_USING_CORE_VARIANT_LIBRARIES%?$$(cat $(PRIVATE_INTERMEDIATES_DIR)/vndk_using_core_variant_filtered)?g" $@
else
$(hide) sed -i.bak -e "s?%VNDK_IN_SYSTEM_NS%??g" $@
# Unlike LLNDK or VNDK-SP, VNDK_USING_CORE_VARIANT_LIBRARIES can be nothing
# if TARGET_VNDK_USE_CORE_VARIANT is not set. In this case, we need to remove
# the entire line in the linker config so that we are not left with a line
# like:
# namespace.vndk.link.vndk_in_system.shared_libs =
$(hide) sed -i.bak -e 's?^.*= %VNDK_USING_CORE_VARIANT_LIBRARIES%$$??' $@
endif
$(hide) echo -n > $(PRIVATE_INTERMEDIATES_DIR)/private_llndk && \
while read -r privatelib; \
do (grep $$privatelib $(PRIVATE_LLNDK_LIBRARIES_FILE) || true) >> $(PRIVATE_INTERMEDIATES_DIR)/private_llndk ; \
done < $(PRIVATE_VNDK_PRIVATE_LIBRARIES_FILE) && \
paste -sd ":" $(PRIVATE_INTERMEDIATES_DIR)/private_llndk | \
sed -i.bak -e "s?%PRIVATE_LLNDK_LIBRARIES%?$$(cat -)?g" $@
$(hide) sed -i.bak -e "s?%SANITIZER_RUNTIME_LIBRARIES%?$(PRIVATE_SANITIZER_RUNTIME_LIBRARIES)?g" $@
$(hide) sed -i.bak -e "s?%VNDK_VER%?$(PRIVATE_VNDK_VERSION_SUFFIX)?g" $@
$(hide) sed -i.bak -e "s?%PRODUCT%?$(TARGET_COPY_OUT_PRODUCT)?g" $@
$(hide) sed -i.bak -e "s?%SYSTEM_EXT%?$(TARGET_COPY_OUT_SYSTEM_EXT)?g" $@
$(hide) sed -i.bak -e "s?^$(PRIVATE_VNDK_VERSION_TAG)??g" $@
$(hide) sed -i.bak "/^\#VNDK[0-9]\{2\}\#.*$$/d" $@
$(hide) rm -f $@.bak
ld_config_template :=
check_backward_compatibility :=
vndk_version :=
lib_list_from_prebuilts :=
libz_is_llndk :=
compatibility_check_script :=
intermediates_dir :=
library_lists_dir :=
llndk_libraries_file :=
llndk_moved_to_apex_libraries_file :=
vndksp_libraries_file :=
vndkcore_libraries_file :=
vndkprivate_libraries_file :=
deps :=
sanitizer_runtime_libraries :=
vndk_version_suffix :=
llndk_libraries_list :=
vndksp_libraries_list :=
write-libs-to-file :=
ifeq ($(my_vndk_use_core_variant),true)
vndk_using_core_variant_libraries_file :=
vndk_using_core_variant_libraries_list :=
endif
my_vndk_use_core_variant :=