| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2016 The Chromium Authors. All rights reserved. | 3 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """ | 7 """ |
| 8 Prints the contents of the __DATA,__mod_init_func section of a Mach-O image. | 8 Prints the contents of the __DATA,__mod_init_func section of a Mach-O image. |
| 9 | 9 |
| 10 Usage: | 10 Usage: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 # of the initializer pointer. | 47 # of the initializer pointer. |
| 48 # out/gn/Chromium Framework.unstripped: | 48 # out/gn/Chromium Framework.unstripped: |
| 49 # Contents of (__DATA,__mod_init_func) section | 49 # Contents of (__DATA,__mod_init_func) section |
| 50 # 0x0000000008761498 0x000000000385d120 | 50 # 0x0000000008761498 0x000000000385d120 |
| 51 return [line.split(' ')[1] for line in lines[2:]] | 51 return [line.split(' ')[1] for line in lines[2:]] |
| 52 | 52 |
| 53 | 53 |
| 54 def SymbolizeAddresses(binary, addresses): | 54 def SymbolizeAddresses(binary, addresses): |
| 55 """Given a |binary| and a list of |addresses|, symbolizes them using atos. | 55 """Given a |binary| and a list of |addresses|, symbolizes them using atos. |
| 56 """ | 56 """ |
| 57 atos = ['atos', '-o', binary] + addresses | 57 atos = ['xcrun', 'atos', '-o', binary] + addresses |
| 58 lines = subprocess.check_output(atos).strip().split('\n') | 58 lines = subprocess.check_output(atos).strip().split('\n') |
| 59 return lines | 59 return lines |
| 60 | 60 |
| 61 | 61 |
| 62 def Main(): | 62 def Main(): |
| 63 parser = optparse.OptionParser(usage='%prog filename') | 63 parser = optparse.OptionParser(usage='%prog filename') |
| 64 opts, args = parser.parse_args() | 64 opts, args = parser.parse_args() |
| 65 if len(args) != 1: | 65 if len(args) != 1: |
| 66 parser.error('missing binary filename') | 66 parser.error('missing binary filename') |
| 67 return 1 | 67 return 1 |
| 68 | 68 |
| 69 ShowModuleInitializers(args[0]) | 69 ShowModuleInitializers(args[0]) |
| 70 return 0 | 70 return 0 |
| 71 | 71 |
| 72 if __name__ == '__main__': | 72 if __name__ == '__main__': |
| 73 sys.exit(Main()) | 73 sys.exit(Main()) |
| OLD | NEW |