Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Unified Diff: tools/binary_size/libsupersize/nm.py

Issue 2816093002: FREEZE.unindexed (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/binary_size/libsupersize/models.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/libsupersize/nm.py
diff --git a/tools/binary_size/libsupersize/nm.py b/tools/binary_size/libsupersize/nm.py
new file mode 100644
index 0000000000000000000000000000000000000000..c6811d6b8ff7ac4b6edf3529b81f9e5183022167
--- /dev/null
+++ b/tools/binary_size/libsupersize/nm.py
@@ -0,0 +1,37 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Dealing with "nm" tool."""
+
+import collections
+import subprocess
+
+
+def CollectAliasesByAddress(elf_path, tool_prefix):
+ names_by_address = collections.defaultdict(list)
+
+ # About 60mb of output, but piping takes ~30s, and loading it into RAM
+ # directly takes 3s.
+ args = [tool_prefix + 'nm', '--no-sort', '--defined-only', '--demangle',
+ elf_path]
+ output = subprocess.check_output(args)
+ for line in output.splitlines():
+ address_str, section, name = line.split(' ', 2)
+ if section not in 'tT' or not name or name[0] == '$':
+ continue
+
+ address = int(address_str, 16) & 0xfffffffffffffffe
+ if not address:
+ continue
+ # Constructors often show up twice.
+ name_list = names_by_address[address]
+ if name not in name_list:
+ name_list.append(name)
+
+ # Since this is run in a separate process, minimize data passing by returning
+ # only aliased symbols.
+ names_by_address = {k: v for k, v in names_by_address.iteritems()
+ if len(v) > 1}
+
+ return names_by_address
« no previous file with comments | « tools/binary_size/libsupersize/models.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698