[go: nahoru, domu]

Add a script to extract and add unwind table to apk

The unwind tables are stripped from release builds. This CL adds a
script to extract the unwind table sections from unstripped binary and
adds it as an asset file in the apk.
This script is first used in the test apk, when add_unwind_tables_in_apk
is specified. Will be used later added to chrome apk.

BUG=819888

Change-Id: I68d2ea843ed0c7a7a3ee60c48f683e01809ff217
Reviewed-on: https://chromium-review.googlesource.com/954421
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Siddhartha S <ssid@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542699}
diff --git a/testing/test.gni b/testing/test.gni
index f9f8c91..251b003fa 100644
--- a/testing/test.gni
+++ b/testing/test.gni
@@ -10,6 +10,7 @@
   import("//build/config/android/config.gni")
   import("//build/config/android/rules.gni")
   import("//build/config/sanitizers/sanitizers.gni")
+  import("//build/config/android/extract_unwind_tables.gni")
 }
 
 if (is_fuchsia) {
@@ -100,6 +101,18 @@
         "write_asset_list",
         "use_native_activity",
       ]
+
+      # Adds the unwind tables from unstripped binary as an asset file in the
+      # apk, if |add_unwind_tables_in_apk| is specified by the test.
+      if (defined(invoker.add_unwind_tables_in_apk) &&
+          invoker.add_unwind_tables_in_apk) {
+        _unwind_table_asset_name = "${target_name}_unwind_assets"
+        unwind_table_asset(_unwind_table_asset_name) {
+          testonly = true
+          library_target = _library_target
+        }
+      }
+
       shared_library(_library_target) {
         # Configs will always be defined since we set_defaults in BUILDCONFIG.gn.
         configs = []  # Prevent list overwriting warning.
@@ -129,6 +142,10 @@
         # Add the Java classes so that each target does not have to do it.
         deps += [ "//base/test:test_support_java" ]
 
+        if (defined(_unwind_table_asset_name)) {
+          deps += [ ":${_unwind_table_asset_name}" ]
+        }
+
         # TODO(agrieve): Remove this data_dep once bots don't build the _apk
         #     target (post-GYP).
         # It's a bit backwards for the apk to depend on the runner script, since