[go: nahoru, domu]

Reland "android: Make the orderfile gold and lld compatible."

Original change's description:
> android: Make the orderfile gold and lld compatible.
>
> Gold wants an orderfile of sections, while lld wants it to contain
> symbols. In both cases unmatched entries are ignored in the orderfile,
> and the generation starts from sections.
>
> This CL changes the orderfile generation pipeline to create orderfiles
> with both sections and symbols.
>
> Also minor cleanups in patch_orderfile.py.
>
> Bug: 778087
> Change-Id: I4219313c40b925d7706064f1f252a692662dfeef
> Reviewed-on: https://chromium-review.googlesource.com/866847
> Commit-Queue: Benoit L <lizeb@chromium.org>
> Reviewed-by: Matthew Cary <mattcary@chromium.org>

Changes made: none, updated downstream scripts.

Bug: 778087
Change-Id: Iec4545590250b66605a28587baec69f672bf3617
Reviewed-on: https://chromium-review.googlesource.com/870115
Reviewed-by: Matthew Cary <mattcary@chromium.org>
Reviewed-by: Egor Pasko <pasko@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#529727}
diff --git a/tools/cygprofile/orderfile_generator_backend.py b/tools/cygprofile/orderfile_generator_backend.py
index 0a33f75..1b44988 100755
--- a/tools/cygprofile/orderfile_generator_backend.py
+++ b/tools/cygprofile/orderfile_generator_backend.py
@@ -27,8 +27,10 @@
 import time
 
 import cygprofile_utils
+import patch_orderfile
 import process_profiles
 import profile_android_startup
+import symbol_extractor
 
 
 _SRC_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)),
@@ -423,8 +425,6 @@
   _CYGLOG_TO_ORDERFILE_SCRIPT = os.path.join(
       constants.DIR_SOURCE_ROOT, 'tools', 'cygprofile',
       'cyglog_to_orderfile.py')
-  _PATCH_ORDERFILE_SCRIPT = os.path.join(
-      constants.DIR_SOURCE_ROOT, 'tools', 'cygprofile', 'patch_orderfile.py')
   _CHECK_ORDERFILE_SCRIPT = os.path.join(
       constants.DIR_SOURCE_ROOT, 'tools', 'cygprofile', 'check_orderfile.py')
   _BUILD_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(
@@ -434,8 +434,6 @@
       _CLANK_REPO, 'orderfiles', 'unpatched_orderfile.%s')
   _MERGED_CYGLOG_FILENAME = os.path.join(
       constants.GetOutDirectory(), 'merged_cyglog')
-  _TEMP_ORDERFILE_FILENAME = os.path.join(
-      constants.GetOutDirectory(), 'tmp_orderfile')
 
   _PATH_TO_ORDERFILE = os.path.join(_CLANK_REPO, 'orderfiles',
                                     'orderfile.%s.out')
@@ -486,6 +484,7 @@
                                                       options.branch,
                                                       options.netrc)
     assert os.path.isdir(constants.DIR_SOURCE_ROOT), 'No src directory found'
+    symbol_extractor.SetArchitecture(options.arch)
 
   def _RunCygprofileUnitTests(self):
     """Builds, deploys and runs cygprofile_unittests."""
@@ -581,25 +580,9 @@
   def _PatchOrderfile(self):
     """Patches the orderfile using clean version of libchrome.so."""
     self._step_recorder.BeginStep('Patch Orderfile')
-    try:
-      tmp_out = open(self._TEMP_ORDERFILE_FILENAME, 'w')
-      self._step_recorder.RunCommand([self._PATCH_ORDERFILE_SCRIPT,
-                                      self._GetUnpatchedOrderfileFilename(),
-                                      self._compiler.lib_chrome_so,
-                                      '--target-arch=' + self._options.arch],
-                                     constants.DIR_SOURCE_ROOT, stdout=tmp_out)
-      tmp_out.close()
-
-      self._RemoveBlanks(self._TEMP_ORDERFILE_FILENAME,
-                         self._GetPathToOrderfile())
-    except CommandError:
-      self._SaveForDebugging(self._GetUnpatchedOrderfileFilename())
-      self._SaveForDebuggingWithOverwrite(self._compiler.lib_chrome_so)
-      raise
-    finally:
-      tmp_out.close()
-      if os.path.isfile(self._TEMP_ORDERFILE_FILENAME):
-        os.unlink(self._TEMP_ORDERFILE_FILENAME)
+    patch_orderfile.GeneratePatchedOrderfile(
+        self._GetUnpatchedOrderfileFilename(), self._compiler.lib_chrome_so,
+        self._GetPathToOrderfile())
 
   def _VerifySymbolOrder(self):
     self._step_recorder.BeginStep('Verify Symbol Order')