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

Side by Side Diff: tools/binary_size/linker_map_parser.py

Issue 2792403002: //tools/binary_size: Change merge symbols to have their size as padding (Closed)
Patch Set: rebase 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 unified diff | Download patch
« no previous file with comments | « tools/binary_size/describe.py ('k') | tools/binary_size/map2size.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 6
7 import models 7 import models
8 8
9 9
10 class MapFileParser(object): 10 class MapFileParser(object):
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 elif name is None: 168 elif name is None:
169 address_str2, name = self._ParsePossiblyWrappedParts(line, 2) 169 address_str2, name = self._ParsePossiblyWrappedParts(line, 2)
170 170
171 if address_str == '0xffffffffffffffff': 171 if address_str == '0xffffffffffffffff':
172 # The section needs special handling (e.g., a merge section) 172 # The section needs special handling (e.g., a merge section)
173 # It also generally has a large offset after it, so don't 173 # It also generally has a large offset after it, so don't
174 # penalize the subsequent symbol for this gap (e.g. a 50kb gap). 174 # penalize the subsequent symbol for this gap (e.g. a 50kb gap).
175 # There seems to be no corelation between where these gaps occur 175 # There seems to be no corelation between where these gaps occur
176 # and the symbols they come in-between. 176 # and the symbols they come in-between.
177 # TODO(agrieve): Learn more about why this happens. 177 # TODO(agrieve): Learn more about why this happens.
178 address = -1 178 if address_str2:
179 if syms and syms[-1].address > 0: 179 address = int(address_str2[2:], 16) - 1
180 merge_symbol_start_address = syms[-1].end_address 180 elif syms and syms[-1].address > 0:
181 merge_symbol_start_address += size 181 # Merge sym with no second line showing real address.
182 address = syms[-1].end_address
183 else:
184 logging.warning('First symbol of section had address -1')
185 address = 0
186
187 merge_symbol_start_address = address + size
182 else: 188 else:
183 address = int(address_str[2:], 16) 189 address = int(address_str[2:], 16)
184 # Finish off active address gap / merge section. 190 # Finish off active address gap / merge section.
185 if merge_symbol_start_address: 191 if merge_symbol_start_address:
186 merge_size = address - merge_symbol_start_address 192 merge_size = address - merge_symbol_start_address
187 logging.debug('Merge symbol of size %d found at:\n %r', 193 logging.debug('Merge symbol of size %d found at:\n %r',
188 merge_size, syms[-1]) 194 merge_size, syms[-1])
195 # Set size=0 so that it will show up as padding.
189 sym = models.Symbol( 196 sym = models.Symbol(
190 section_name, merge_size, 197 section_name, 0,
191 address=merge_symbol_start_address, 198 address=address,
192 name='** symbol gap %d' % symbol_gap_count, 199 name='** symbol gap %d' % symbol_gap_count,
193 object_path=path) 200 object_path=path)
194 symbol_gap_count += 1 201 symbol_gap_count += 1
195 syms.append(sym) 202 syms.append(sym)
196 merge_symbol_start_address = 0 203 merge_symbol_start_address = 0
197 204
198 if address == -1 and address_str2:
199 address = int(address_str2[2:], 16) - 1
200 # Merge sym with no second line showing real address.
201 if address == -1:
202 address = syms[-1].end_address
203 syms.append(models.Symbol(section_name, size, address=address, 205 syms.append(models.Symbol(section_name, size, address=address,
204 name=name or mangled_name, 206 name=name or mangled_name,
205 object_path=path)) 207 object_path=path))
206 logging.debug('Symbol count for %s: %d', section_name, 208 logging.debug('Symbol count for %s: %d', section_name,
207 len(syms) - sym_count_at_start) 209 len(syms) - sym_count_at_start)
208 except: 210 except:
209 logging.error('Problem line: %r', line) 211 logging.error('Problem line: %r', line)
210 logging.error('In section: %r', section_name) 212 logging.error('In section: %r', section_name)
211 raise 213 raise
OLDNEW
« no previous file with comments | « tools/binary_size/describe.py ('k') | tools/binary_size/map2size.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698