OLD | NEW |
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 # About linker maps: | 9 # About linker maps: |
10 # * "Discarded input sections" include symbols merged with other symbols | 10 # * "Discarded input sections" include symbols merged with other symbols |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 # 0x20000 obj/third_party/<snip> | 72 # 0x20000 obj/third_party/<snip> |
73 ret = [] | 73 ret = [] |
74 next(self._lines) # Skip past blank line | 74 next(self._lines) # Skip past blank line |
75 | 75 |
76 name, size_str, path = None, None, None | 76 name, size_str, path = None, None, None |
77 for l in self._lines: | 77 for l in self._lines: |
78 parts = self._ParsePossiblyWrappedParts(l, 3) | 78 parts = self._ParsePossiblyWrappedParts(l, 3) |
79 if not parts: | 79 if not parts: |
80 break | 80 break |
81 name, size_str, path = parts | 81 name, size_str, path = parts |
82 sym = models.Symbol('.bss', int(size_str[2:], 16), name=name, | 82 sym = models.Symbol('.bss', int(size_str[2:], 16), full_name=name, |
83 object_path=path) | 83 object_path=path) |
84 ret.append(sym) | 84 ret.append(sym) |
85 return ret | 85 return ret |
86 | 86 |
87 def _ParseSections(self): | 87 def _ParseSections(self): |
88 # .text 0x0028c600 0x22d3468 | 88 # .text 0x0028c600 0x22d3468 |
89 # .text.startup._GLOBAL__sub_I_bbr_sender.cc | 89 # .text.startup._GLOBAL__sub_I_bbr_sender.cc |
90 # 0x0028c600 0x38 obj/net/net/bbr_sender.o | 90 # 0x0028c600 0x38 obj/net/net/bbr_sender.o |
91 # .text._reset 0x00339d00 0xf0 obj/third_party/icu/icuuc/ucnv.o | 91 # .text._reset 0x00339d00 0xf0 obj/third_party/icu/icuuc/ucnv.o |
92 # ** fill 0x0255fb00 0x02 | 92 # ** fill 0x0255fb00 0x02 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 line = line[zero_index:] | 152 line = line[zero_index:] |
153 address_str, size_str = self._ParsePossiblyWrappedParts(line, 2) | 153 address_str, size_str = self._ParsePossiblyWrappedParts(line, 2) |
154 line = next(self._lines) | 154 line = next(self._lines) |
155 # These bytes are already accounted for. | 155 # These bytes are already accounted for. |
156 if name == '** common': | 156 if name == '** common': |
157 continue | 157 continue |
158 address = int(address_str[2:], 16) | 158 address = int(address_str[2:], 16) |
159 size = int(size_str[2:], 16) | 159 size = int(size_str[2:], 16) |
160 path = None | 160 path = None |
161 sym = models.Symbol(section_name, size, address=address, | 161 sym = models.Symbol(section_name, size, address=address, |
162 name=name, object_path=path) | 162 full_name=name, object_path=path) |
163 syms.append(sym) | 163 syms.append(sym) |
164 else: | 164 else: |
165 # A normal symbol entry. | 165 # A normal symbol entry. |
166 subsection_name, address_str, size_str, path = ( | 166 subsection_name, address_str, size_str, path = ( |
167 self._ParsePossiblyWrappedParts(line, 4)) | 167 self._ParsePossiblyWrappedParts(line, 4)) |
168 size = int(size_str[2:], 16) | 168 size = int(size_str[2:], 16) |
169 assert subsection_name.startswith(section_name), ( | 169 assert subsection_name.startswith(section_name), ( |
170 'subsection name was: ' + subsection_name) | 170 'subsection name was: ' + subsection_name) |
171 mangled_name = subsection_name[prefix_len:] | 171 mangled_name = subsection_name[prefix_len:] |
172 name = None | 172 name = None |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 merge_size = address - merge_symbol_start_address | 211 merge_size = address - merge_symbol_start_address |
212 merge_symbol_start_address = 0 | 212 merge_symbol_start_address = 0 |
213 if merge_size > 0: | 213 if merge_size > 0: |
214 # merge_size == 0 for the initial symbol generally. | 214 # merge_size == 0 for the initial symbol generally. |
215 logging.debug('Merge symbol of size %d found at:\n %r', | 215 logging.debug('Merge symbol of size %d found at:\n %r', |
216 merge_size, syms[-1]) | 216 merge_size, syms[-1]) |
217 # Set size=0 so that it will show up as padding. | 217 # Set size=0 so that it will show up as padding. |
218 sym = models.Symbol( | 218 sym = models.Symbol( |
219 section_name, 0, | 219 section_name, 0, |
220 address=address, | 220 address=address, |
221 name='** symbol gap %d' % symbol_gap_count) | 221 full_name='** symbol gap %d' % symbol_gap_count) |
222 symbol_gap_count += 1 | 222 symbol_gap_count += 1 |
223 syms.append(sym) | 223 syms.append(sym) |
224 | 224 |
225 sym = models.Symbol(section_name, size, address=address, | 225 sym = models.Symbol(section_name, size, address=address, |
226 name=name or mangled_name, object_path=path) | 226 full_name=name or mangled_name, |
| 227 object_path=path) |
227 syms.append(sym) | 228 syms.append(sym) |
228 section_end_address = section_address + section_size | 229 section_end_address = section_address + section_size |
229 if section_name != '.bss' and ( | 230 if section_name != '.bss' and ( |
230 syms[-1].end_address < section_end_address): | 231 syms[-1].end_address < section_end_address): |
231 # Set size=0 so that it will show up as padding. | 232 # Set size=0 so that it will show up as padding. |
232 sym = models.Symbol( | 233 sym = models.Symbol( |
233 section_name, 0, | 234 section_name, 0, |
234 address=section_end_address, | 235 address=section_end_address, |
235 name='** symbol gap %d (end of section)' % symbol_gap_count) | 236 full_name=( |
| 237 '** symbol gap %d (end of section)' % symbol_gap_count)) |
236 syms.append(sym) | 238 syms.append(sym) |
237 logging.debug('Symbol count for %s: %d', section_name, | 239 logging.debug('Symbol count for %s: %d', section_name, |
238 len(syms) - sym_count_at_start) | 240 len(syms) - sym_count_at_start) |
239 except: | 241 except: |
240 logging.error('Problem line: %r', line) | 242 logging.error('Problem line: %r', line) |
241 logging.error('In section: %r', section_name) | 243 logging.error('In section: %r', section_name) |
242 raise | 244 raise |
OLD | NEW |