| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 # .data 0x0028c600 0x22d3468 | 104 # .data 0x0028c600 0x22d3468 |
| 105 # .data.rel.ro._ZTVN3gvr7android19ScopedJavaGlobalRefIP12_jfloatArrayEE | 105 # .data.rel.ro._ZTVN3gvr7android19ScopedJavaGlobalRefIP12_jfloatArrayEE |
| 106 # 0x02d1e668 0x10 ../../third_party/.../libfoo.a(bar.o) | 106 # 0x02d1e668 0x10 ../../third_party/.../libfoo.a(bar.o) |
| 107 # 0x02d1e668 vtable for gvr::android::GlobalRef<_jfloatArray*> | 107 # 0x02d1e668 vtable for gvr::android::GlobalRef<_jfloatArray*> |
| 108 # ** merge strings | 108 # ** merge strings |
| 109 # 0x0255fb00 0x1f2424 | 109 # 0x0255fb00 0x1f2424 |
| 110 # ** merge constants | 110 # ** merge constants |
| 111 # 0x0255fb00 0x8 | 111 # 0x0255fb00 0x8 |
| 112 # ** common 0x02db5700 0x13ab48 | 112 # ** common 0x02db5700 0x13ab48 |
| 113 syms = self._symbols | 113 syms = self._symbols |
| 114 symbol_gap_count = 0 | |
| 115 while True: | 114 while True: |
| 116 line = self._SkipToLineWithPrefix('.') | 115 line = self._SkipToLineWithPrefix('.') |
| 117 if not line: | 116 if not line: |
| 118 break | 117 break |
| 119 section_name = None | 118 section_name = None |
| 120 try: | 119 try: |
| 121 # Parse section name and size. | 120 # Parse section name and size. |
| 122 parts = self._ParsePossiblyWrappedParts(line, 3) | 121 parts = self._ParsePossiblyWrappedParts(line, 3) |
| 123 if not parts: | 122 if not parts: |
| 124 break | 123 break |
| 125 section_name, section_address_str, section_size_str = parts | 124 section_name, section_address_str, section_size_str = parts |
| 126 section_address = int(section_address_str[2:], 16) | 125 section_address = int(section_address_str[2:], 16) |
| 127 section_size = int(section_size_str[2:], 16) | 126 section_size = int(section_size_str[2:], 16) |
| 128 self._section_sizes[section_name] = section_size | 127 self._section_sizes[section_name] = section_size |
| 129 if (section_name in ('.bss', '.rodata', '.text') or | 128 if (section_name in ('.bss', '.rodata', '.text') or |
| 130 section_name.startswith('.data')): | 129 section_name.startswith('.data')): |
| 131 logging.info('Parsing %s', section_name) | 130 logging.info('Parsing %s', section_name) |
| 132 if section_name == '.bss': | 131 if section_name == '.bss': |
| 133 # Common symbols have no address. | 132 # Common symbols have no address. |
| 134 syms.extend(self._common_symbols) | 133 syms.extend(self._common_symbols) |
| 135 prefix_len = len(section_name) + 1 # + 1 for the trailing . | 134 prefix_len = len(section_name) + 1 # + 1 for the trailing . |
| 135 symbol_gap_count = 0 |
| 136 merge_symbol_start_address = section_address | 136 merge_symbol_start_address = section_address |
| 137 sym_count_at_start = len(syms) | 137 sym_count_at_start = len(syms) |
| 138 line = next(self._lines) | 138 line = next(self._lines) |
| 139 # Parse section symbols. | 139 # Parse section symbols. |
| 140 while True: | 140 while True: |
| 141 if not line or line.isspace(): | 141 if not line or line.isspace(): |
| 142 break | 142 break |
| 143 if line.startswith(' **'): | 143 if line.startswith(' **'): |
| 144 zero_index = line.find('0') | 144 zero_index = line.find('0') |
| 145 if zero_index == -1: | 145 if zero_index == -1: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 address=section_end_address, | 237 address=section_end_address, |
| 238 full_name=( | 238 full_name=( |
| 239 '** symbol gap %d (end of section)' % symbol_gap_count)) | 239 '** symbol gap %d (end of section)' % symbol_gap_count)) |
| 240 syms.append(sym) | 240 syms.append(sym) |
| 241 logging.debug('Symbol count for %s: %d', section_name, | 241 logging.debug('Symbol count for %s: %d', section_name, |
| 242 len(syms) - sym_count_at_start) | 242 len(syms) - sym_count_at_start) |
| 243 except: | 243 except: |
| 244 logging.error('Problem line: %r', line) | 244 logging.error('Problem line: %r', line) |
| 245 logging.error('In section: %r', section_name) | 245 logging.error('In section: %r', section_name) |
| 246 raise | 246 raise |
| OLD | NEW |