aboutsummaryrefslogtreecommitdiff
path: root/debug_info_test/check_icf.py
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-02-01 11:04:36 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-02-01 11:04:36 +0000
commit9870dd4e6d12bb96b4e78ca9fc6e8e5dbfa71d83 (patch)
tree77dc031614745bb406dbd90cea9a082a1b5cdd54 /debug_info_test/check_icf.py
parentf39a268cec0843ae14d6aa47feb49d32183cf1c5 (diff)
parentd44430951159ca340cd4c4e699917348f82abad8 (diff)
downloadtoolchain-utils-9870dd4e6d12bb96b4e78ca9fc6e8e5dbfa71d83.tar.gz
Snap for 9550355 from d44430951159ca340cd4c4e699917348f82abad8 to sdk-releaseplatform-tools-34.0.1platform-tools-34.0.0platform-tools-33.0.4
Change-Id: I9ee07a3c89be79d32ad2cf53a87531e566b38107
Diffstat (limited to 'debug_info_test/check_icf.py')
-rw-r--r--debug_info_test/check_icf.py81
1 files changed, 41 insertions, 40 deletions
diff --git a/debug_info_test/check_icf.py b/debug_info_test/check_icf.py
index a46968e7..a717d81e 100644
--- a/debug_info_test/check_icf.py
+++ b/debug_info_test/check_icf.py
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
-# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Copyright 2018 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""check whether chrome was built with identical code folding."""
-from __future__ import print_function
import os
import re
@@ -13,41 +12,43 @@ import subprocess
def check_identical_code_folding(dso_path):
- """check whether chrome was built with identical code folding.
-
- Args:
- dso_path: path to the dso.
-
- Returns:
- False if the dso is chrome and it was not built with icf,
- True otherwise.
- """
-
- if not dso_path.endswith('/chrome.debug'):
- return True
-
- # Run 'nm' on the chrome binary and read the output.
- nm = subprocess.Popen(['nm', dso_path],
- stdout=subprocess.PIPE,
- stderr=open(os.devnull, 'w'),
- encoding='utf-8')
- nm_output, _ = nm.communicate()
-
- # Search for addresses of text symbols.
- text_addresses = re.findall('^[0-9a-f]+[ ]+[tT] ', nm_output, re.MULTILINE)
-
- # Calculate number of text symbols in chrome binary.
- num_text_addresses = len(text_addresses)
-
- # Calculate number of unique text symbols in chrome binary.
- num_unique_text_addresses = len(set(text_addresses))
-
- # Check that the number of duplicate symbols is at least 10,000.
- # - https://crbug.com/813272#c18
- if num_text_addresses - num_unique_text_addresses >= 10000:
- return True
-
- print('%s was not built with ICF' % dso_path)
- print(' num_text_addresses = %d' % num_text_addresses)
- print(' num_unique_text_addresses = %d' % num_unique_text_addresses)
- return False
+ """check whether chrome was built with identical code folding.
+
+ Args:
+ dso_path: path to the dso.
+
+ Returns:
+ False if the dso is chrome and it was not built with icf,
+ True otherwise.
+ """
+
+ if not dso_path.endswith("/chrome.debug"):
+ return True
+
+ # Run 'nm' on the chrome binary and read the output.
+ nm = subprocess.Popen(
+ ["nm", dso_path],
+ stdout=subprocess.PIPE,
+ stderr=open(os.devnull, "w"),
+ encoding="utf-8",
+ )
+ nm_output, _ = nm.communicate()
+
+ # Search for addresses of text symbols.
+ text_addresses = re.findall("^[0-9a-f]+[ ]+[tT] ", nm_output, re.MULTILINE)
+
+ # Calculate number of text symbols in chrome binary.
+ num_text_addresses = len(text_addresses)
+
+ # Calculate number of unique text symbols in chrome binary.
+ num_unique_text_addresses = len(set(text_addresses))
+
+ # Check that the number of duplicate symbols is at least 10,000.
+ # - https://crbug.com/813272#c18
+ if num_text_addresses - num_unique_text_addresses >= 10000:
+ return True
+
+ print("%s was not built with ICF" % dso_path)
+ print(" num_text_addresses = %d" % num_text_addresses)
+ print(" num_unique_text_addresses = %d" % num_unique_text_addresses)
+ return False