Merge "Fix bookmark title"
diff --git a/core/Makefile b/core/Makefile
index 36b23ee..f0b1d56 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -766,7 +766,7 @@
 # can be overridden for a particular device by putting a font.png in
 # its private recovery resources.
 
-ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
+ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density)))
 recovery_font := $(call include-path-for, recovery)/fonts/18x32.png
 else
 recovery_font := $(call include-path-for, recovery)/fonts/12x22.png
@@ -1251,49 +1251,48 @@
 # host tools needed to build dist and OTA packages
 
 DISTTOOLS :=  $(HOST_OUT_EXECUTABLES)/minigzip \
-	  $(HOST_OUT_EXECUTABLES)/mkbootfs \
-	  $(HOST_OUT_EXECUTABLES)/mkbootimg \
-	  $(HOST_OUT_EXECUTABLES)/fs_config \
-	  $(HOST_OUT_EXECUTABLES)/zipalign \
-	  $(HOST_OUT_EXECUTABLES)/bsdiff \
-	  $(HOST_OUT_EXECUTABLES)/imgdiff \
-	  $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
-	  $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
-	  $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \
-	  $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
-	  $(HOST_OUT_EXECUTABLES)/make_ext4fs \
-	  $(HOST_OUT_EXECUTABLES)/simg2img \
-	  $(HOST_OUT_EXECUTABLES)/e2fsck \
-	  $(HOST_OUT_EXECUTABLES)/build_verity_tree \
-	  $(HOST_OUT_EXECUTABLES)/verity_signer \
-	  $(HOST_OUT_EXECUTABLES)/append2simg \
-	  $(HOST_OUT_EXECUTABLES)/boot_signer
+  $(HOST_OUT_EXECUTABLES)/mkbootfs \
+  $(HOST_OUT_EXECUTABLES)/mkbootimg \
+  $(HOST_OUT_EXECUTABLES)/fs_config \
+  $(HOST_OUT_EXECUTABLES)/zipalign \
+  $(HOST_OUT_EXECUTABLES)/bsdiff \
+  $(HOST_OUT_EXECUTABLES)/imgdiff \
+  $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \
+  $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \
+  $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \
+  $(HOST_OUT_EXECUTABLES)/make_ext4fs \
+  $(HOST_OUT_EXECUTABLES)/simg2img \
+  $(HOST_OUT_EXECUTABLES)/e2fsck \
+  $(HOST_OUT_EXECUTABLES)/build_verity_tree \
+  $(HOST_OUT_EXECUTABLES)/verity_signer \
+  $(HOST_OUT_EXECUTABLES)/append2simg \
+  $(HOST_OUT_EXECUTABLES)/boot_signer
+
+# Shared libraries.
+DISTTOOLS += \
+  $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \
+  $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX)
 
 OTATOOLS := $(DISTTOOLS) \
-	  $(HOST_OUT_EXECUTABLES)/aapt
+  $(HOST_OUT_EXECUTABLES)/aapt
 
 .PHONY: otatools
 otatools: $(OTATOOLS)
 
 BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip
-$(BUILT_OTATOOLS_PACKAGE): \
-	intermediate := $(call intermediates-dir-for,PACKAGING,otatools)
-$(BUILT_OTATOOLS_PACKAGE): \
-	zip_root := $(intermediate)/otatools
+$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools
 
-otatools_lib_path := $(notdir $(HOST_OUT_SHARED_LIBRARIES))
-$(BUILT_OTATOOLS_PACKAGE): \
-		$(OTATOOLS) \
-		$(HOST_OUT_SHARED_LIBRARIES)/libc++.so
+$(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) | $(ACP)
 	@echo "Package OTA tools: $@"
 	$(hide) rm -rf $@ $(zip_root)
-	$(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/$(otatools_lib_path)
-	$(hide) $(ACP) -p $(OTATOOLS) $(zip_root)/bin
-	$(hide) mv $(zip_root)/bin/*.jar $(zip_root)/framework/
-	$(hide) $(ACP) $(HOST_OUT_SHARED_LIBRARIES)/libc++.so $(zip_root)/$(otatools_lib_path)
+	$(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools
+	$(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root))
 	$(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools
 	$(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc
-	$(hide) (cd $(zip_root) && zip -qry $(abspath $@) bin framework releasetools $(otatools_lib_path))
+	$(hide) (cd $(zip_root) && zip -qry $(abspath $@) *)
 	$(hide) zip -qry $(abspath $@) build/target/product/security/
 	$(hide) find device vendor -name \*.pk8 -o -name \*.x509.pem -o -name oem.prop | xargs zip -qry $(abspath $@)>/dev/null || true
 
diff --git a/core/binary.mk b/core/binary.mk
index 69131c3..8eefa76 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -204,7 +204,7 @@
 endif
 
 # Add in libcompiler_rt for all regular device builds
-ifeq (,$(LOCAL_SDK_VERSION)$(LOCAL_IS_HOST_MODULE)$(WITHOUT_LIBCOMPILER_RT))
+ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT))
   my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
 endif
 
diff --git a/core/clang/config.mk b/core/clang/config.mk
index 13a5ba1..e2a4c08 100644
--- a/core/clang/config.mk
+++ b/core/clang/config.mk
@@ -49,6 +49,11 @@
 CLANG_CONFIG_EXTRA_CFLAGS += \
   -Wno-reserved-id-macro
 
+# Disable overly aggressive warning for format strings.
+# Bug: 20148343
+CLANG_CONFIG_EXTRA_CFLAGS += \
+  -Wno-format-pedantic
+
 # Workaround for ccache with clang.
 # See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
 CLANG_CONFIG_EXTRA_CFLAGS += \
@@ -115,7 +120,7 @@
 
 # Address sanitizer clang config
 ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan_$(TARGET_ARCH)_android
-ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fsanitize=address -fno-omit-frame-pointer
+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)
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index 7837ae3..51cdc5b 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -173,6 +173,7 @@
 LOCAL_NATIVE_COVERAGE :=
 LOCAL_DPI_VARIANTS:=
 LOCAL_DPI_FILE_STEM:=
+LOCAL_SANITIZE:=
 
 # arch specific variables
 LOCAL_SRC_FILES_$(TARGET_ARCH):=
diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk
index 7fa48ff..8389bb8 100644
--- a/core/combo/HOST_darwin-x86.mk
+++ b/core/combo/HOST_darwin-x86.mk
@@ -56,12 +56,6 @@
 $(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += \
     -include $(call select-android-config-h,darwin-x86)
 
-ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
-       $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := false
-else
-       $(combo_2nd_arch_prefix)HOST_RUN_RANLIB_AFTER_COPYING := true
-       PRE_LION_DYNAMIC_LINKER_OPTIONS := -Wl,-dynamic
-endif
 $(combo_2nd_arch_prefix)HOST_GLOBAL_ARFLAGS := cqs
 
 ############################################################
@@ -91,7 +85,7 @@
 $(hide) $(PRIVATE_CXX) \
         -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
         -o $@ \
-        $(PRE_LION_DYNAMIC_LINKER_OPTIONS) -Wl,-headerpad_max_install_names \
+        -Wl,-headerpad_max_install_names \
         $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \
         $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
            $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
diff --git a/core/combo/HOST_darwin-x86_64.mk b/core/combo/HOST_darwin-x86_64.mk
index c06933d..0efa78f 100644
--- a/core/combo/HOST_darwin-x86_64.mk
+++ b/core/combo/HOST_darwin-x86_64.mk
@@ -55,11 +55,6 @@
 HOST_GLOBAL_CFLAGS += \
     -include $(call select-android-config-h,darwin-x86)
 
-ifneq ($(filter 10.7 10.7.% 10.8 10.8.%, $(build_mac_version)),)
-       HOST_RUN_RANLIB_AFTER_COPYING := false
-else
-       HOST_RUN_RANLIB_AFTER_COPYING := true
-endif
 HOST_GLOBAL_ARFLAGS := cqs
 
 # We Reuse the following functions with the same name from HOST_darwin-x86.mk:
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
index d535afc..99f17aa 100644
--- a/core/combo/arch/arm/armv7-a-neon.mk
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -16,14 +16,23 @@
 	# Fake an ARM compiler flag as these processors support LPAE which GCC/clang
 	# don't advertise.
 	arch_variant_cflags += -D__ARM_FEATURE_LPAE=1
+	arch_variant_ldflags := \
+		-Wl,--no-fix-cortex-a8
 else
 ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a8)
 	arch_variant_cflags := -mcpu=cortex-a8
+	arch_variant_ldflags := \
+		-Wl,--fix-cortex-a8
 else
 ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a7)
 	arch_variant_cflags := -mcpu=cortex-a7
+	arch_variant_ldflags := \
+		-Wl,--no-fix-cortex-a8
 else
 	arch_variant_cflags := -march=armv7-a
+	# Generic ARM might be a Cortex A8 -- better safe than sorry
+	arch_variant_ldflags := \
+		-Wl,--fix-cortex-a8
 endif
 endif
 endif
@@ -31,6 +40,3 @@
 arch_variant_cflags += \
     -mfloat-abi=softfp \
     -mfpu=neon
-
-arch_variant_ldflags := \
-	-Wl,--fix-cortex-a8
diff --git a/core/combo/include/arch/darwin-x86/AndroidConfig.h b/core/combo/include/arch/darwin-x86/AndroidConfig.h
index 2673640..c28a7f8 100644
--- a/core/combo/include/arch/darwin-x86/AndroidConfig.h
+++ b/core/combo/include/arch/darwin-x86/AndroidConfig.h
@@ -35,7 +35,7 @@
 /*
  * Define if we have <malloc.h> header
  */
-/* #define HAVE_MALLOC_H */
+/* #define HAVE_MALLOC_H 1 */
 
 /*
  * The default path separator for the platform
diff --git a/core/combo/include/arch/linux-arm/AndroidConfig.h b/core/combo/include/arch/linux-arm/AndroidConfig.h
index 5f107bf..e819535 100644
--- a/core/combo/include/arch/linux-arm/AndroidConfig.h
+++ b/core/combo/include/arch/linux-arm/AndroidConfig.h
@@ -35,7 +35,7 @@
 /*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
diff --git a/core/combo/include/arch/linux-arm64/AndroidConfig.h b/core/combo/include/arch/linux-arm64/AndroidConfig.h
index baa59fd..cee484d 100644
--- a/core/combo/include/arch/linux-arm64/AndroidConfig.h
+++ b/core/combo/include/arch/linux-arm64/AndroidConfig.h
@@ -35,7 +35,7 @@
 /*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
diff --git a/core/combo/include/arch/linux-mips/AndroidConfig.h b/core/combo/include/arch/linux-mips/AndroidConfig.h
index 999dfe6..a5dcef1 100644
--- a/core/combo/include/arch/linux-mips/AndroidConfig.h
+++ b/core/combo/include/arch/linux-mips/AndroidConfig.h
@@ -35,7 +35,7 @@
 /*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
diff --git a/core/combo/include/arch/linux-mips64/AndroidConfig.h b/core/combo/include/arch/linux-mips64/AndroidConfig.h
index c85dbec..62d569e 100644
--- a/core/combo/include/arch/linux-mips64/AndroidConfig.h
+++ b/core/combo/include/arch/linux-mips64/AndroidConfig.h
@@ -35,7 +35,7 @@
 /*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
diff --git a/core/combo/include/arch/linux-x86/AndroidConfig.h b/core/combo/include/arch/linux-x86/AndroidConfig.h
index ab77f6b..89b29fe 100644
--- a/core/combo/include/arch/linux-x86/AndroidConfig.h
+++ b/core/combo/include/arch/linux-x86/AndroidConfig.h
@@ -43,7 +43,7 @@
 /*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * The default path separator for the platform
diff --git a/core/combo/include/arch/target_linux-x86/AndroidConfig.h b/core/combo/include/arch/target_linux-x86/AndroidConfig.h
index afa1bc6..41e4df9 100644
--- a/core/combo/include/arch/target_linux-x86/AndroidConfig.h
+++ b/core/combo/include/arch/target_linux-x86/AndroidConfig.h
@@ -21,7 +21,7 @@
 /*
  * Define if we have <malloc.h> header
  */
-#define HAVE_MALLOC_H
+#define HAVE_MALLOC_H 1
 
 /*
  * Define if we're running on *our* linux on device or emulator.
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index a1964a9..3c07f69 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -7,26 +7,62 @@
 ifeq ($(SANITIZE_HOST),true)
 ifneq ($(strip $(LOCAL_CLANG)),false)
 ifneq ($(strip $(LOCAL_ADDRESS_SANITIZER)),false)
-    LOCAL_ADDRESS_SANITIZER := true
+  LOCAL_SANITIZE := address
 endif
 endif
 endif
 endif
 
-# Configure address sanitizer.
+my_sanitize := $(LOCAL_SANITIZE)
+
+# Keep compatibility for LOCAL_ADDRESS_SANITIZER until all targets have moved to
+# `LOCAL_SANITIZE := address`.
 ifeq ($(strip $(LOCAL_ADDRESS_SANITIZER)),true)
+  my_sanitize += address
+endif
+
+# Don't apply sanitizers to NDK code.
+ifdef LOCAL_SDK_VERSION
+  my_sanitize :=
+endif
+
+unknown_sanitizers := $(filter-out address, \
+                      $(filter-out undefined,$(my_sanitize)))
+
+ifneq ($(unknown_sanitizers),)
+  $(error Unknown sanitizers: $(unknown_sanitizers))
+endif
+
+ifneq ($(my_sanitize),)
   my_clang := true
+
+  fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize)),
+  my_cflags += -fsanitize=$(fsanitize_arg)
+
+  ifdef LOCAL_IS_HOST_MODULE
+    my_ldflags += -fsanitize=$(fsanitize_arg)
+  endif
+endif
+
+ifneq ($(filter address,$(my_sanitize)),)
   # Frame pointer based unwinder in ASan requires ARM frame setup.
   LOCAL_ARM_MODE := arm
   my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
   my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
   ifdef LOCAL_IS_HOST_MODULE
-      my_ldflags += -fsanitize=address
-      # -nodefaultlibs (provided with libc++) prevents the driver from linking
-      # libraries needed with -fsanitize=address. http://b/18650275
-      my_ldlibs += -ldl -lpthread
+    # -nodefaultlibs (provided with libc++) prevents the driver from linking
+    # libraries needed with -fsanitize=address. http://b/18650275 (WAI)
+    my_ldlibs += -ldl -lpthread
   else
-      my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
-      my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+    my_shared_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
+    my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+  endif
+endif
+
+ifneq ($(filter undefined,$(my_sanitize)),)
+  ifdef LOCAL_IS_HOST_MODULE
+    my_ldlibs += -ldl
+  else
+    $(error ubsan is not yet supported on the target)
   endif
 endif
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
index 7961801..da84bdd 100644
--- a/core/cxx_stl_setup.mk
+++ b/core/cxx_stl_setup.mk
@@ -68,8 +68,6 @@
     else
         ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
             my_static_libraries += libunwind_llvm
-        else
-            my_static_libraries += libunwindbacktrace
         endif
 
         ifeq ($(my_link_type),static)
diff --git a/core/definitions.mk b/core/definitions.mk
index 2cdd3f5..4f0daae 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2080,31 +2080,16 @@
 $(copy-file-to-target-strip-comments)
 endef
 
-###########################################################
-## On some platforms (MacOS), after copying a static
-## library, ranlib must be run to update an internal
-## timestamp!?!?!
-###########################################################
-
-ifeq ($(HOST_RUN_RANLIB_AFTER_COPYING),true)
-define transform-host-ranlib-copy-hack
-    $(hide) ranlib $@ || true
+# Copy a list of files/directories to target location, with sub dir structure preserved.
+# For example $(HOST_OUT_EXECUTABLES)/aapt -> $(staging)/bin/aapt .
+# $(1): the source list of files/directories.
+# $(2): the path prefix to strip. In the above example it would be $(HOST_OUT).
+# $(3): the target location.
+define copy-files-with-structure
+$(foreach t,$(1),\
+  $(eval s := $(patsubst $(2)%,%,$(t)))\
+  $(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline))
 endef
-else
-define transform-host-ranlib-copy-hack
-@true
-endef
-endif
-
-ifeq ($(TARGET_RUN_RANLIB_AFTER_COPYING),true)
-define transform-ranlib-copy-hack
-    $(hide) ranlib $@
-endef
-else
-define transform-ranlib-copy-hack
-@true
-endef
-endif
 
 
 ###########################################################
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index fb62e0c..6f598be 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -105,7 +105,7 @@
 	--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
 	--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
 	--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
-	--include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols \
+	--include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols --no-include-cfi \
 	--abort-on-hard-verifier-error \
 	$(PRIVATE_DEX_PREOPT_FLAGS)
 endef
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index 2569d73..cfc7653 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -62,5 +62,5 @@
 		--instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
 		--instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
 		--instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
-		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols \
+		--android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-include-debug-symbols --no-include-cfi \
 		$(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(COMPILED_CLASSES_FLAGS)
diff --git a/core/host_shared_library.mk b/core/host_shared_library.mk
index 438a9ce..e840780 100644
--- a/core/host_shared_library.mk
+++ b/core/host_shared_library.mk
@@ -6,8 +6,8 @@
 ifeq ($(HOST_PREFER_32_BIT),true)
 my_module_multilib := 32
 else
-# By default we only build host module for the first arch.
-my_module_multilib := first
+# libraries default to building for both architecturess
+my_module_multilib := both
 endif
 endif
 endif
diff --git a/core/host_static_library.mk b/core/host_static_library.mk
index 74ac2ea..52c42ef 100644
--- a/core/host_static_library.mk
+++ b/core/host_static_library.mk
@@ -6,8 +6,8 @@
 ifeq ($(HOST_PREFER_32_BIT),true)
 my_module_multilib := 32
 else
-# By default we only build host module for the first arch.
-my_module_multilib := first
+# libraries default to building for both architecturess
+my_module_multilib := both
 endif
 endif
 endif
diff --git a/core/package_internal.mk b/core/package_internal.mk
index 5dac455..016e23f 100644
--- a/core/package_internal.mk
+++ b/core/package_internal.mk
@@ -402,12 +402,12 @@
 else
 	$(add-dex-to-package)
 endif
-	$(sign-package)
 ifdef LOCAL_DEX_PREOPT
 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
 	$(call dexpreopt-remove-classes.dex,$@)
 endif
 endif
+	$(sign-package)
 	@# Alignment must happen after all other zip operations.
 	$(align-package)
 
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
index 47e21ef..8595bce 100644
--- a/core/prebuilt_internal.mk
+++ b/core/prebuilt_internal.mk
@@ -193,17 +193,18 @@
 $(built_module) : PRIVATE_PAGE_ALIGN_JNI_SHARED_LIBRARIES := $(LOCAL_PAGE_ALIGN_JNI_SHARED_LIBRARIES)
 $(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR)
 	$(transform-prebuilt-to-target)
+ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
+	@# Only strip out files if we can re-sign the package.
 ifdef extracted_jni_libs
 	$(hide) zip -d $@ 'lib/*.so'  # strip embedded JNI libraries.
 endif
-ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
-	$(sign-package)
-endif
 ifdef LOCAL_DEX_PREOPT
 ifneq (nostripping,$(LOCAL_DEX_PREOPT))
 	$(call dexpreopt-remove-classes.dex,$@)
 endif
 endif
+	$(sign-package)
+endif
 	$(align-package)
 
 ###############################
@@ -256,13 +257,6 @@
 else
 $(built_module) : $(my_prebuilt_src_file) | $(ACP)
 	$(transform-prebuilt-to-target)
-ifneq ($(prebuilt_module_is_a_library),)
-  ifneq ($(LOCAL_IS_HOST_MODULE),)
-	$(transform-host-ranlib-copy-hack)
-  else
-	$(transform-ranlib-copy-hack)
-  endif
-endif
 endif
 endif # LOCAL_MODULE_CLASS != APPS
 
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
index 96c0b77..a408860 100644
--- a/target/product/embedded.mk
+++ b/target/product/embedded.mk
@@ -25,6 +25,7 @@
     debuggerd \
     dumpstate \
     dumpsys \
+    fastboot \
     gralloc.default \
     grep \
     gzip \
diff --git a/tools/fs_config/Android.mk b/tools/fs_config/Android.mk
index f4c871a..34a3522 100644
--- a/tools/fs_config/Android.mk
+++ b/tools/fs_config/Android.mk
@@ -13,12 +13,73 @@
 # limitations under the License.
 
 LOCAL_PATH := $(call my-dir)
+
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := fs_config.c
 LOCAL_MODULE := fs_config
-LOCAL_STATIC_LIBRARIES := libcutils liblog libselinux
-LOCAL_FORCE_STATIC_EXECUTABLE := true
+LOCAL_SHARED_LIBRARIES := libcutils libselinux
 LOCAL_CFLAGS := -Werror
 
 include $(BUILD_HOST_EXECUTABLE)
+
+# To Build the custom target binary for the host to generate the fs_config
+# override files. The executable is hard coded to include the
+# $(TARGET_ANDROID_FILESYSTEM_CONFIG_H) file if it exists.
+# Expectations:
+#    device/<vendor>/<device>/android_filesystem_config.h
+#        fills in struct fs_path_config android_device_dirs[] and
+#                 struct fs_path_config android_device_files[]
+#    device/<vendor>/<device>/device.mk
+#        PRODUCT_PACKAGES += fs_config_dirs fs_config_files
+
+# If not specified, check if default one to be found
+ANDROID_FS_CONFIG_H := android_filesystem_config.h
+
+ifneq ($(TARGET_ANDROID_FILESYSTEM_CONFIG_H),)
+ifeq ($(filter %/$(ANDROID_FS_CONFIG_H),$(TARGET_ANDROID_FILESYSTEM_CONFIG_H)),)
+$(error TARGET_ANDROID_FILESYSTEM_CONFIG_H file name must be $(ANDROID_FS_CONFIG_H), \
+ see "$(notdir $(TARGET_ANDROID_FILESYSTEM_CONFIG_H))".)
+endif
+
+my_fs_config_h := $(TARGET_ANDROID_FILESYSTEM_CONFIG_H)
+else ifneq ($(wildcard $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)),)
+my_fs_config_h := $(TARGET_DEVICE_DIR)/$(ANDROID_FS_CONFIG_H)
+else
+my_fs_config_h := $(LOCAL_PATH)/default/$(ANDROID_FS_CONFIG_H)
+endif
+
+include $(CLEAR_VARS)
+LOCAL_SRC_FILES := fs_config_generate.c
+LOCAL_MODULE := fs_config_generate_$(TARGET_DEVICE)
+LOCAL_SHARED_LIBRARIES := libcutils
+LOCAL_CFLAGS := -Werror -Wno-error=\#warnings
+LOCAL_C_INCLUDES := $(dir $(my_fs_config_h))
+include $(BUILD_HOST_EXECUTABLE)
+fs_config_generate_bin := $(LOCAL_INSTALLED_MODULE)
+
+# Generate the system/etc/fs_config_dirs binary file for the target
+# Add fs_config_dirs to PRODUCT_PACKAGES in the device make file to enable
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := fs_config_dirs
+LOCAL_MODULE_CLASS := ETC
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
+	@mkdir -p $(dir $@)
+	$< -D -o $@
+
+# Generate the system/etc/fs_config_files binary file for the target
+# Add fs_config_files to PRODUCT_PACKAGES in the device make file to enable
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := fs_config_files
+LOCAL_MODULE_CLASS := ETC
+include $(BUILD_SYSTEM)/base_rules.mk
+$(LOCAL_BUILT_MODULE): $(fs_config_generate_bin)
+	@mkdir -p $(dir $@)
+	$< -F -o $@
+
+ANDROID_FS_CONFIG_H :=
+my_fs_config_h :=
+fs_config_generate_bin :=
diff --git a/tools/fs_config/default/android_filesystem_config.h b/tools/fs_config/default/android_filesystem_config.h
new file mode 100644
index 0000000..820b04a
--- /dev/null
+++ b/tools/fs_config/default/android_filesystem_config.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+/* This file is used to enhance the properties of the filesystem
+** images generated by build tools (mkbootfs and mkyaffs2image) and
+** by the device side of adb.
+*/
+
+/*
+** Resorting to the default file means someone requested fs_config_dirs or
+** fs_config_files in their device configuration without providing an
+** associated header.
+*/
+#warning No device-supplied android_filesystem_config.h, using empty default.
+
+/* Rules for directories.
+** These rules are applied based on "first match", so they
+** should start with the most specific path and work their
+** way up to the root.
+*/
+
+#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS 1 /* opt out of specifying */
+
+/* Rules for files.
+** These rules are applied based on "first match", so they
+** should start with the most specific path and work their
+** way up to the root. Prefixes ending in * denotes wildcard
+** and will allow partial matches.
+*/
+
+#define NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_FILES 1 /* opt out of specifying */
diff --git a/tools/fs_config/fs_config_generate.c b/tools/fs_config/fs_config_generate.c
new file mode 100644
index 0000000..c06213f
--- /dev/null
+++ b/tools/fs_config/fs_config_generate.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <private/android_filesystem_config.h>
+
+/*
+ * This program expects android_device_dirs and android_device_files
+ * to be defined in the supplied android_filesystem_config.h file in
+ * the device/<vendor>/<product> $(TARGET_DEVICE_DIR). Then generates
+ * the binary format used in the /system/etc/fs_config_dirs and
+ * the /system/etc/fs_config_files to be used by the runtimes.
+ */
+#include "android_filesystem_config.h"
+
+#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS
+  static const struct fs_path_config android_device_dirs[] = {
+};
+#endif
+
+#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_FILES
+static const struct fs_path_config android_device_files[] = {
+#ifdef NO_ANDROID_FILESYSTEM_CONFIG_DEVICE_DIRS
+    { 0, AID_ROOT, AID_ROOT, 0, "system/etc/fs_config_dirs" },
+#endif
+    { 0, AID_ROOT, AID_ROOT, 0, "system/etc/fs_config_files" },
+};
+#endif
+
+static void usage() {
+  fprintf(stderr,
+    "Generate binary content for fs_config_dirs (-D) and fs_config_files (-F)\n"
+    "from device-specific android_filesystem_config.h override\n\n"
+    "Usage: fs_config_generate -D|-F [-o output-file]\n");
+}
+
+int main(int argc, char** argv) {
+  const struct fs_path_config *pc;
+  const struct fs_path_config *end;
+  bool dir = false, file = false;
+  FILE *fp = stdout;
+  int opt;
+
+  while((opt = getopt(argc, argv, "DFho:")) != -1) {
+    switch(opt) {
+    case 'D':
+      if (file) {
+        fprintf(stderr, "Must specify only -D or -F\n");
+        usage();
+        exit(EXIT_FAILURE);
+      }
+      dir = true;
+      break;
+    case 'F':
+      if (dir) {
+        fprintf(stderr, "Must specify only -F or -D\n");
+        usage();
+        exit(EXIT_FAILURE);
+      }
+      file = true;
+      break;
+    case 'o':
+      if (fp != stdout) {
+        fprintf(stderr, "Specify only one output file\n");
+        usage();
+        exit(EXIT_FAILURE);
+      }
+      fp = fopen(optarg, "wb");
+      if (fp == NULL) {
+        fprintf(stderr, "Can not open \"%s\"\n", optarg);
+        exit(EXIT_FAILURE);
+      }
+      break;
+    case 'h':
+      usage();
+      exit(EXIT_SUCCESS);
+    default:
+      usage();
+      exit(EXIT_FAILURE);
+    }
+  }
+
+  if (!file && !dir) {
+    fprintf(stderr, "Must specify either -F or -D\n");
+    usage();
+    exit(EXIT_FAILURE);
+  }
+
+  if (dir) {
+    pc = android_device_dirs;
+    end = &android_device_dirs[sizeof(android_device_dirs) / sizeof(android_device_dirs[0])];
+  } else {
+    pc = android_device_files;
+    end = &android_device_files[sizeof(android_device_files) / sizeof(android_device_files[0])];
+  }
+  for(; (pc < end) && pc->prefix; pc++) {
+    char buffer[512];
+    ssize_t len = fs_config_generate(buffer, sizeof(buffer), pc);
+    if (len < 0) {
+      fprintf(stderr, "Entry too large\n");
+      exit(EXIT_FAILURE);
+    }
+    if (fwrite(buffer, 1, len, fp) != (size_t)len) {
+      fprintf(stderr, "Write failure\n");
+      exit(EXIT_FAILURE);
+    }
+  }
+  fclose(fp);
+
+  return 0;
+}
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 26fbaf0..21565fc 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -556,6 +556,10 @@
 else if get_stage("%(bcb_dev)s") == "3/3" then
 """ % bcb_dev)
 
+  # Dump fingerprints
+  script.Print("Target: %s" % CalculateFingerprint(
+      oem_props, oem_dict, OPTIONS.info_dict))
+
   device_specific.FullOTA_InstallBegin()
 
   system_progress = 0.75
@@ -731,6 +735,12 @@
       metadata=metadata,
       info_dict=OPTIONS.info_dict)
 
+  # TODO: Currently this works differently from WriteIncrementalOTAPackage().
+  # This function doesn't consider thumbprints when writing
+  # metadata["pre/post-build"]. One possible reason is that the current
+  # devices with thumbprints are all using file-based OTAs. Long term we
+  # should factor out the common parts into a shared one to avoid further
+  # divergence.
   source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
   target_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.target_info_dict)
   metadata["pre-build"] = source_fp
@@ -828,6 +838,12 @@
 else if get_stage("%(bcb_dev)s") != "3/3" then
 """ % bcb_dev)
 
+  # Dump fingerprints
+  script.Print("Source: %s" % CalculateFingerprint(
+      oem_props, oem_dict, OPTIONS.source_info_dict))
+  script.Print("Target: %s" % CalculateFingerprint(
+      oem_props, oem_dict, OPTIONS.target_info_dict))
+
   script.Print("Verifying current system...")
 
   device_specific.IncrementalOTA_VerifyBegin()
@@ -1206,6 +1222,10 @@
 else if get_stage("%(bcb_dev)s") != "3/3" then
 """ % bcb_dev)
 
+  # Dump fingerprints
+  script.Print("Source: %s" % (source_fp,))
+  script.Print("Target: %s" % (target_fp,))
+
   script.Print("Verifying current system...")
 
   device_specific.IncrementalOTA_VerifyBegin()