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

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

Issue 2858793002: Create a star symbol for gaps at the start & end of sections (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/describe.py ('k') | tools/binary_size/libsupersize/models.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/libsupersize/linker_map_parser.py
diff --git a/tools/binary_size/libsupersize/linker_map_parser.py b/tools/binary_size/libsupersize/linker_map_parser.py
index c88827c90f94473920440b7357f7c0eea0a9b43b..9bdf9b2b096e3d2cea5dc9c6ebfb31268ac8ac43 100644
--- a/tools/binary_size/libsupersize/linker_map_parser.py
+++ b/tools/binary_size/libsupersize/linker_map_parser.py
@@ -35,16 +35,22 @@ class MapFileParser(object):
A tuple of (section_sizes, symbols).
"""
self._lines = iter(lines)
- logging.info('Parsing common symbols')
- self._common_symbols = self._ParseCommonSymbols()
- logging.debug('.bss common entries: %d', len(self._common_symbols))
- logging.info('Parsing section symbols')
- self._ParseSections()
+ logging.debug('Scanning for Header')
+
+ while True:
+ line = self._SkipToLineWithPrefix('Common symbol', 'Memory map')
+ if line.startswith('Common symbol'):
+ self._common_symbols = self._ParseCommonSymbols()
+ logging.debug('.bss common entries: %d', len(self._common_symbols))
+ continue
+ elif line.startswith('Memory map'):
+ self._ParseSections()
+ break
return self._section_sizes, self._symbols
- def _SkipToLineWithPrefix(self, prefix):
+ def _SkipToLineWithPrefix(self, prefix, prefix2=None):
for l in self._lines:
- if l.startswith(prefix):
+ if l.startswith(prefix) or (prefix2 and l.startswith(prefix2)):
return l
def _ParsePossiblyWrappedParts(self, line, count):
@@ -65,7 +71,6 @@ class MapFileParser(object):
# ff_cos_131072_fixed
# 0x20000 obj/third_party/<snip>
ret = []
- self._SkipToLineWithPrefix('Common symbol')
next(self._lines) # Skip past blank line
name, size_str, path = None, None, None
@@ -105,7 +110,6 @@ class MapFileParser(object):
# ** merge constants
# 0x0255fb00 0x8
# ** common 0x02db5700 0x13ab48
- self._SkipToLineWithPrefix('Memory map')
syms = self._symbols
symbol_gap_count = 0
while True:
@@ -118,15 +122,18 @@ class MapFileParser(object):
parts = self._ParsePossiblyWrappedParts(line, 3)
if not parts:
break
- section_name, address, size_str = parts
- self._section_sizes[section_name] = int(size_str[2:], 16)
+ section_name, section_address_str, section_size_str = parts
+ section_address = int(section_address_str[2:], 16)
+ section_size = int(section_size_str[2:], 16)
+ self._section_sizes[section_name] = section_size
if (section_name in ('.bss', '.rodata', '.text') or
section_name.startswith('.data')):
logging.info('Parsing %s', section_name)
if section_name == '.bss':
+ # Common symbols have no address.
syms.extend(self._common_symbols)
prefix_len = len(section_name) + 1 # + 1 for the trailing .
- merge_symbol_start_address = 0
+ merge_symbol_start_address = section_address
sym_count_at_start = len(syms)
line = next(self._lines)
# Parse section symbols.
@@ -202,21 +209,32 @@ class MapFileParser(object):
# Finish off active address gap / merge section.
if merge_symbol_start_address:
merge_size = address - merge_symbol_start_address
- logging.debug('Merge symbol of size %d found at:\n %r',
- merge_size, syms[-1])
- # Set size=0 so that it will show up as padding.
- sym = models.Symbol(
- section_name, 0,
- address=address,
- name='** symbol gap %d' % symbol_gap_count,
- object_path=path)
- symbol_gap_count += 1
- syms.append(sym)
merge_symbol_start_address = 0
+ if merge_size > 0:
+ # merge_size == 0 for the initial symbol generally.
+ logging.debug('Merge symbol of size %d found at:\n %r',
+ merge_size, syms[-1])
+ # Set size=0 so that it will show up as padding.
+ sym = models.Symbol(
+ section_name, 0,
+ address=address,
+ name='** symbol gap %d' % symbol_gap_count,
+ object_path=path)
+ symbol_gap_count += 1
+ syms.append(sym)
sym = models.Symbol(section_name, size, address=address,
name=name or mangled_name, object_path=path)
syms.append(sym)
+ section_end_address = section_address + section_size
+ if section_name != '.bss' and (
+ syms[-1].end_address < section_end_address):
+ # Set size=0 so that it will show up as padding.
+ sym = models.Symbol(
+ section_name, 0,
+ address=section_end_address,
+ name='** symbol gap %d (end of section)' % symbol_gap_count)
+ syms.append(sym)
logging.debug('Symbol count for %s: %d', section_name,
len(syms) - sym_count_at_start)
except:
« no previous file with comments | « tools/binary_size/libsupersize/describe.py ('k') | tools/binary_size/libsupersize/models.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698