Enable extracting unwind table on official builds without channel

The original cl was here:
https://chromium-review.googlesource.com/c/chromium/src/+/990092
This CL fixes the following problems with the original CL:
1. The apk_merger script fails because the unwind tables were only added
   in 32-bit apk. The merger script expects all the files to be same and
   the ones different should be checked.
 1a. The resources.arsc is non-hermetic and ordering is affected by
     adding file to only one apk. As a workaround for crbug/828528,
     add an empty (valid) unwind table file to the 64 bit monochrome
     apk to make the resource.arsc consistent.
 1b. The merger script simply adds all the files in apk which are not
     same. To keep the script simple and functional, the unwind resource
     is renamed to unwind_cfi_32 and unwind_cfi_empty in respective
     builds and the app_merger is updated to specify this file is
     expected to be different and included. This causes an extra file
     (4 byte) in the merged apk.

2. The unwind tables were always generated for "libchrome.so" for all
   chrome apks. The different chrome_apk(s) have different shared
   libraries like libchromefortest, etc.. So, update the unwind asset to
   get unwind table for the right library for each apk. Only adds assets
   to *_public_apk(s).

3. The monochrome_apk_checker was failing because the unwind file
   included was different in chrome_apk and monochrome_apk. This CL adds
   the asset to all apk at the same time and adds exception for this
   file.

BUG=819888
TBR=dpranke@chromium.org

Change-Id: Ibceeeacc19fa424d519891b8c17e349ee6c2dfd6
Reviewed-on: https://chromium-review.googlesource.com/991236
Commit-Queue: Siddhartha S <ssid@chromium.org>
Reviewed-by: Maria Khomenko <mariakhomenko@chromium.org>
Reviewed-by: Bo <boliu@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#547993}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 16e808d789d05fcc2bfcc8b00e002d11405adb1a
This commit is contained in:
Siddhartha 2018-04-04 06:00:46 +00:00 коммит произвёл Commit Bot
Родитель 3429367139
Коммит e65999a451
2 изменённых файлов: 45 добавлений и 15 удалений

Просмотреть файл

@ -57,6 +57,9 @@ C4: Some functions do not have unwind information defined in dwarf info. These
Usage:
extract_unwind_tables.py --input_path [root path to unstripped chrome.so]
--output_path [output path] --dump_syms_path [path to dump_syms binary]
[OR]
extract_unwind_tables.py --generate-empty-tables
--output_path [output path] --dump_syms_path [path to dump_syms binary]
"""
import argparse
@ -264,9 +267,6 @@ def _ParseCfiData(sym_file, output_path):
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--input_path', required=True,
help='The input path of the unstripped binary')
parser.add_argument(
'--output_path', required=True,
help='The path of the output file')
@ -274,8 +274,22 @@ def main():
'--dump_syms_path', required=True,
help='The path of the dump_syms binary')
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--input_path', required=False,
help='The input path of the unstripped binary')
group.add_argument(
'--generate-empty-tables', required=False,
help='Generates an empty valid unwind table file.',
action="store_true")
args = parser.parse_args()
if args.generate_empty_tables:
with open(args.output_path, 'wb') as out_file:
_WriteCfiData({}, out_file)
return 0
with tempfile.NamedTemporaryFile() as sym_file:
out = subprocess.call(
['./' +args.dump_syms_path, args.input_path], stdout=sym_file)

Просмотреть файл

@ -3,10 +3,19 @@
# found in the LICENSE file.
import("//build/config/android/rules.gni")
import("//build/config/compiler/compiler.gni")
template("unwind_table_asset") {
_unwind_action = "${target_name}__extract"
_asset_path = "${target_gen_dir}/${target_name}/unwind_cfi"
# Monochrome 64 bit apk needs to include an empty unwind file with different
# name so that the resource table matches when merging monochrome apk.
if (can_unwind_with_cfi_table) {
assert(current_cpu == "arm")
_asset_path = "${target_gen_dir}/${target_name}/unwind_cfi_32"
} else {
_asset_path = "${target_gen_dir}/${target_name}/unwind_cfi_empty"
}
action(_unwind_action) {
if (defined(invoker.testonly)) {
@ -17,25 +26,32 @@ template("unwind_table_asset") {
outputs = [
_asset_path,
]
inputs = [
"$root_out_dir/lib.unstripped/$shlib_prefix${invoker.library_target}$shlib_extension",
]
args = [
"--input_path",
rebase_path(
"$root_out_dir/lib.unstripped/$shlib_prefix${invoker.library_target}$shlib_extension",
root_build_dir),
"--output_path",
rebase_path(_asset_path, root_build_dir),
"--dump_syms_path",
rebase_path("$root_out_dir/dump_syms", root_build_dir),
]
deps = [
":${invoker.library_target}",
"//third_party/breakpad:dump_syms",
]
if (can_unwind_with_cfi_table) {
_input_lib = "$root_out_dir/lib.unstripped/$shlib_prefix${invoker.library_target}$shlib_extension"
inputs = [
_input_lib,
]
args += [
"--input_path",
rebase_path(_input_lib, root_build_dir),
]
} else {
args += [ "--generate-empty-tables" ]
}
deps = invoker.deps
deps += [ "//third_party/breakpad:dump_syms" ]
}
android_assets(target_name) {
if (defined(invoker.testonly)) {
testonly = invoker.testonly