am 37c9b500: Merge "Don\'t extract jni from prebuilt apks." into mnc-dev
* commit '37c9b500ed8c739ca4b47b41bc77863d0971f9f4':
Don't extract jni from prebuilt apks.
diff --git a/core/clang/TARGET_arm.mk b/core/clang/TARGET_arm.mk
index 6f6d624..62ce242 100644
--- a/core/clang/TARGET_arm.mk
+++ b/core/clang/TARGET_arm.mk
@@ -66,3 +66,7 @@
$(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := armv7-none-linux-gnueabi
$(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-arm-android.a
+
+# Address sanitizer clang config
+$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-arm-android
+$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_RPATH := /system/lib/asan
diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk
index b67d458..ea4d937 100644
--- a/core/clang/TARGET_arm64.mk
+++ b/core/clang/TARGET_arm64.mk
@@ -64,3 +64,7 @@
RS_COMPAT_TRIPLE := aarch64-linux-android
TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a
+
+# Address sanitizer clang config
+ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-arm64-android
+ADDRESS_SANITIZER_RPATH := /system/lib64/asan
diff --git a/core/clang/config.mk b/core/clang/config.mk
index 505d441..1e99675 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -146,12 +146,10 @@
include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
endif
-# Address sanitizer clang config
-ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android
ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer
ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit
-ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl $(ADDRESS_SANITIZER_RUNTIME_LIBRARY)
+ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := libdl
ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan
# This allows us to use the superset of functionality that compiler-rt
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 7b3f1c5..a350416 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -180,6 +180,7 @@
LOCAL_DPI_VARIANTS:=
LOCAL_DPI_FILE_STEM:=
LOCAL_SANITIZE:=
+LOCAL_SANITIZE_RECOVER:=
# arch specific variables
LOCAL_SRC_FILES_$(TARGET_ARCH):=
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index 210d442..e13790b 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -78,17 +78,37 @@
ifdef LOCAL_IS_HOST_MODULE
# -nodefaultlibs (provided with libc++) prevents the driver from linking
# libraries needed with -fsanitize=address. http://b/18650275 (WAI)
- my_ldlibs += -ldl -lpthread
+ my_ldlibs += -lm -ldl -lpthread
+ my_ldflags += -Wl,--no-as-needed
else
- my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
+ # ASan runtime library must be the first in the link order.
+ my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
+ $(my_shared_libraries) \
+ $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+ my_ldflags += -Wl,-rpath,$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RPATH)
+
+ # http://b/20665974
+ # The relocation packer is causing the kernel to load the executable
+ # overlapping ASAN's shadow space.
+ ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+ LOCAL_PACK_MODULE_RELOCATIONS := false
+ endif
endif
endif
ifneq ($(filter undefined,$(my_sanitize)),)
+ my_cflags += -fno-sanitize-recover=all
+
ifdef LOCAL_IS_HOST_MODULE
my_ldlibs += -ldl
else
$(error ubsan is not yet supported on the target)
endif
endif
+
+
+ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),)
+ recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
+ my_cflags += -fsanitize-recover=$(recover_arg)
+endif
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
index c98624d..4b6136d 100644
--- a/target/board/generic_arm64/BoardConfig.mk
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -82,3 +82,5 @@
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_FLASH_BLOCK_SIZE := 512
TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
diff --git a/target/board/generic_mips64/BoardConfig.mk b/target/board/generic_mips64/BoardConfig.mk
index 7fe6cd3..5c13447 100644
--- a/target/board/generic_mips64/BoardConfig.mk
+++ b/target/board/generic_mips64/BoardConfig.mk
@@ -71,3 +71,5 @@
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_FLASH_BLOCK_SIZE := 512
TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk
index 192bbb2..55bafd5 100755
--- a/target/board/generic_x86_64/BoardConfig.mk
+++ b/target/board/generic_x86_64/BoardConfig.mk
@@ -47,3 +47,7 @@
BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
BOARD_FLASH_BLOCK_SIZE := 512
TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += \
+ build/target/board/generic/sepolicy \
+ build/target/board/generic_x86/sepolicy