OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Patch an orderfile. | 6 """Patch an orderfile. |
7 | 7 |
8 Starting with a list of symbols in a binary and an orderfile (ordered list of | 8 Starting with a list of symbols in a binary and an orderfile (ordered list of |
9 symbols), matches the symbols in the orderfile and augments each symbol with the | 9 symbols), matches the symbols in the orderfile and augments each symbol with the |
10 symbols residing at the same address (due to having identical code). | 10 symbols residing at the same address (due to having identical code). |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 Returns: | 52 Returns: |
53 The same output as _GroupSymbolInfosFromBinary. | 53 The same output as _GroupSymbolInfosFromBinary. |
54 """ | 54 """ |
55 # Map the addresses to symbols. | 55 # Map the addresses to symbols. |
56 offset_to_symbol_infos = collections.defaultdict(list) | 56 offset_to_symbol_infos = collections.defaultdict(list) |
57 name_to_symbol_infos = collections.defaultdict(list) | 57 name_to_symbol_infos = collections.defaultdict(list) |
58 for symbol in symbol_infos: | 58 for symbol in symbol_infos: |
59 symbol = symbol_extractor.SymbolInfo(name=_RemoveClone(symbol.name), | 59 symbol = symbol_extractor.SymbolInfo(name=_RemoveClone(symbol.name), |
60 offset=symbol.offset, | 60 offset=symbol.offset, |
61 size=symbol.size) | 61 size=symbol.size, |
| 62 section=symbol.section) |
62 offset_to_symbol_infos[symbol.offset].append(symbol) | 63 offset_to_symbol_infos[symbol.offset].append(symbol) |
63 name_to_symbol_infos[symbol.name].append(symbol) | 64 name_to_symbol_infos[symbol.name].append(symbol) |
64 return (dict(offset_to_symbol_infos), dict(name_to_symbol_infos)) | 65 return (dict(offset_to_symbol_infos), dict(name_to_symbol_infos)) |
65 | 66 |
66 | 67 |
67 def _GroupSymbolInfosFromBinary(binary_filename): | 68 def _GroupSymbolInfosFromBinary(binary_filename): |
68 """Group all the symbols from a binary by name and offset. | 69 """Group all the symbols from a binary by name and offset. |
69 | 70 |
70 Args: | 71 Args: |
71 binary_filename: path to the binary. | 72 binary_filename: path to the binary. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 _PrintSymbolsWithPrefixes(expanded_symbols, sys.stdout) | 217 _PrintSymbolsWithPrefixes(expanded_symbols, sys.stdout) |
217 # The following is needed otherwise Gold only applies a partial sort. | 218 # The following is needed otherwise Gold only applies a partial sort. |
218 print '.text' # gets methods not in a section, such as assembly | 219 print '.text' # gets methods not in a section, such as assembly |
219 print '.text.*' # gets everything else | 220 print '.text.*' # gets everything else |
220 return 0 | 221 return 0 |
221 | 222 |
222 | 223 |
223 if __name__ == '__main__': | 224 if __name__ == '__main__': |
224 logging.basicConfig(level=logging.INFO) | 225 logging.basicConfig(level=logging.INFO) |
225 sys.exit(main(sys.argv)) | 226 sys.exit(main(sys.argv)) |
OLD | NEW |