Commit ad23ed6f authored by Peter Collingbourne's avatar Peter Collingbourne Committed by Commit Bot

Reland "Add a flag for building HWASAN splits."

This is a reland of 27453d76

Split out the is_a_target_toolchain change to another change.

Original change's description:
> Add a flag for building HWASAN splits.
>
> The new build_hwasan_splits flag causes HWASAN splits to be created for
> the Monochrome6432 and TrichromeChrome6432 bundles, as well as any of its
> DFMs that contain native code. The intent is that this flag will eventually
> default to true in official builds.
>
> The library is deliberately installed in TrichromeChrome6432 rather than
> TrichromeLibrary6432 (where the regular native library lives) because the
> Android platform does not support splits for the library containing the
> WebView implementation. This means that only Chrome will use the HWASANified
> native library, and WebView will use the regular native library.
>
> Bug: 916828
> Change-Id: Ie92bb36e83df245ab431b0123a44b0f0a3182100
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1769731
> Commit-Queue: Peter Collingbourne <pcc@chromium.org>
> Reviewed-by: Andrew Grieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#729945}

Bug: 916828
Change-Id: I2c64720b72572a1c718cbd44d79d3fb2a44afcac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994671Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Peter Collingbourne <pcc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732689}
parent 584d3c52
...@@ -238,7 +238,11 @@ def _AddNativeLibraries(out_apk, native_libs, android_abi, uncompress, ...@@ -238,7 +238,11 @@ def _AddNativeLibraries(out_apk, native_libs, android_abi, uncompress,
if has_crazy_linker and not has_monochrome: if has_crazy_linker and not has_monochrome:
basename = 'crazy.' + basename basename = 'crazy.' + basename
apk_path = 'lib/%s/%s' % (android_abi, basename) lib_android_abi = android_abi
if path.startswith('android_clang_arm64_hwasan/'):
lib_android_abi = 'arm64-v8a-hwasan'
apk_path = 'lib/%s/%s' % (lib_android_abi, basename)
zipalign.AddToZipHermetic( zipalign.AddToZipHermetic(
out_apk, out_apk,
apk_path, apk_path,
......
...@@ -789,7 +789,8 @@ def _CreateJavaLibrariesList(library_paths): ...@@ -789,7 +789,8 @@ def _CreateJavaLibrariesList(library_paths):
"""Returns a java literal array with the "base" library names: """Returns a java literal array with the "base" library names:
e.g. libfoo.so -> foo e.g. libfoo.so -> foo
""" """
return ('{%s}' % ','.join(['"%s"' % s[3:-3] for s in library_paths])) names = ['"%s"' % os.path.basename(s)[3:-3] for s in library_paths]
return ('{%s}' % ','.join(sorted(set(names))))
def _CreateJavaLocaleListFromAssets(assets, locale_paks): def _CreateJavaLocaleListFromAssets(assets, locale_paks):
......
...@@ -26,6 +26,9 @@ declare_args() { ...@@ -26,6 +26,9 @@ declare_args() {
# Only effective if use_order_profiling = true. When this is true the call # Only effective if use_order_profiling = true. When this is true the call
# graph based instrumentation is used. # graph based instrumentation is used.
use_call_graph = false use_call_graph = false
# Build additional browser splits with HWASAN instrumentation enabled.
build_hwasan_splits = false
} }
assert(!devtools_instrumentation_dumping || use_order_profiling, assert(!devtools_instrumentation_dumping || use_order_profiling,
......
...@@ -253,7 +253,11 @@ config("common_sanitizer_flags") { ...@@ -253,7 +253,11 @@ config("common_sanitizer_flags") {
if (using_sanitizer) { if (using_sanitizer) {
assert(is_clang, "sanitizers only supported with clang") assert(is_clang, "sanitizers only supported with clang")
assert(!is_official_build, "sanitizers not supported in official builds")
# Allow non-default toolchains to enable sanitizers in toolchain_args even
# in official builds.
assert(current_toolchain != default_toolchain || !is_official_build,
"sanitizers not supported in official builds")
cflags += [ cflags += [
# Column info in debug data confuses Visual Studio's debugger, so don't # Column info in debug data confuses Visual Studio's debugger, so don't
......
...@@ -113,8 +113,8 @@ declare_args() { ...@@ -113,8 +113,8 @@ declare_args() {
archive_seed_corpus = true archive_seed_corpus = true
} }
# Disable sanitizers for non-default toolchains. # Disable sanitizers for non-target toolchains.
if (current_toolchain != default_toolchain) { if (!is_a_target_toolchain) {
is_asan = false is_asan = false
is_cfi = false is_cfi = false
is_hwasan = false is_hwasan = false
......
...@@ -99,6 +99,15 @@ android_clang_toolchain("android_clang_arm64") { ...@@ -99,6 +99,15 @@ android_clang_toolchain("android_clang_arm64") {
} }
} }
android_clang_toolchain("android_clang_arm64_hwasan") {
binary_prefix = "aarch64-linux-android"
toolchain_args = {
current_cpu = "arm64"
is_hwasan = true
android64_ndk_api_level = 29
}
}
android_clang_toolchain("android_clang_mips64el") { android_clang_toolchain("android_clang_mips64el") {
binary_prefix = "mips64el-linux-android" binary_prefix = "mips64el-linux-android"
toolchain_args = { toolchain_args = {
......
...@@ -332,6 +332,7 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -332,6 +332,7 @@ template("monochrome_public_common_apk_or_module_tmpl") {
defined(invoker.use_trichrome_library) && invoker.use_trichrome_library defined(invoker.use_trichrome_library) && invoker.use_trichrome_library
is_monochrome = !is_trichrome is_monochrome = !is_trichrome
shared_libraries = []
loadable_modules = [] loadable_modules = []
secondary_abi_loadable_modules = [] secondary_abi_loadable_modules = []
...@@ -444,6 +445,18 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -444,6 +445,18 @@ template("monochrome_public_common_apk_or_module_tmpl") {
use_chromium_linker = is_trichrome && chromium_linker_supported use_chromium_linker = is_trichrome && chromium_linker_supported
use_modern_linker = use_chromium_linker use_modern_linker = use_chromium_linker
if (build_hwasan_splits && android_64bit_target_cpu &&
invoker.is_64_bit_browser) {
_hwasan_toolchain = "//build/toolchain/android:android_clang_arm64_hwasan"
shared_libraries +=
[ "//chrome/android:libmonochrome_64($_hwasan_toolchain)" ]
if (use_chromium_linker) {
shared_libraries +=
[ "//base/android/linker:chromium_android_linker($_hwasan_toolchain)" ]
}
}
# Resources config for blocklisting resource names from obfuscation # Resources config for blocklisting resource names from obfuscation
resources_config_path = "//android_webview/aapt2.config" resources_config_path = "//android_webview/aapt2.config"
......
...@@ -54,6 +54,12 @@ template("chrome_feature_module") { ...@@ -54,6 +54,12 @@ template("chrome_feature_module") {
_shared_libraries += [ _shared_libraries += [
"//chrome/android:${_base_target_name}_${_module_desc.name}${_toolchain}", "//chrome/android:${_base_target_name}_${_module_desc.name}${_toolchain}",
] ]
if (android_64bit_target_cpu && _is_monochrome_or_trichrome &&
invoker.is_64_bit_browser && build_hwasan_splits) {
_hwasan_toolchain = "//build/toolchain/android:android_clang_arm64_hwasan"
_shared_libraries += [ "//chrome/android:${_base_target_name}_${_module_desc.name}($_hwasan_toolchain)" ]
}
} else { } else {
not_needed([ "_is_monochrome_or_trichrome" ]) not_needed([ "_is_monochrome_or_trichrome" ])
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment