OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
| 3 # Copyright 2010 The Native Client Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can |
| 5 # be found in the LICENSE file. |
| 6 |
| 7 |
3 """ | 8 """ |
4 This module contains utilities and constants needed to parse ELF headers. | 9 This module contains utilities and constants needed to parse ELF headers. |
5 """ | 10 """ |
6 | 11 |
7 import exceptions | 12 import exceptions |
8 import struct | 13 import struct |
9 | 14 |
10 # maps yielding actual sizes of various abstract types | 15 # maps yielding actual sizes of various abstract types |
11 | 16 |
12 e32_size = { | 17 e32_size = { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 ('ehsize', 'Half'), | 56 ('ehsize', 'Half'), |
52 ('phentsize', 'Half'), | 57 ('phentsize', 'Half'), |
53 ('phnum', 'Half'), | 58 ('phnum', 'Half'), |
54 ('shentsize', 'Half'), | 59 ('shentsize', 'Half'), |
55 ('shnum', 'Half'), | 60 ('shnum', 'Half'), |
56 ('shstndx', 'Half'), | 61 ('shstndx', 'Half'), |
57 ] | 62 ] |
58 | 63 |
59 ehdr_member_type = dict(ehdr_member_and_type) | 64 ehdr_member_type = dict(ehdr_member_and_type) |
60 | 65 |
| 66 def MemberPositionMap(member_and_type): |
| 67 return dict((m,i) for i,(m,t) in enumerate(member_and_type)) |
| 68 |
61 elf32_phdr_member_and_type = [ | 69 elf32_phdr_member_and_type = [ |
62 ('type', 'Word'), | 70 ('type', 'Word'), |
63 ('offset', 'Off'), | 71 ('offset', 'Off'), |
64 ('vaddr', 'Addr'), | 72 ('vaddr', 'Addr'), |
65 ('paddr', 'Addr'), | 73 ('paddr', 'Addr'), |
66 ('filesz', 'Word'), | 74 ('filesz', 'Word'), |
67 ('memsz', 'Word'), | 75 ('memsz', 'Word'), |
68 ('flags', 'Word'), | 76 ('flags', 'Word'), |
69 ('align', 'Word'), | 77 ('align', 'Word'), |
70 ] | 78 ] |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 print ehdr_machine_name; | 385 print ehdr_machine_name; |
378 print ehdr_version; | 386 print ehdr_version; |
379 print ehdr_version_name; | 387 print ehdr_version_name; |
380 print ehdr_ident; | 388 print ehdr_ident; |
381 print ehdr_ident_class; | 389 print ehdr_ident_class; |
382 print ehdr_ident_data; | 390 print ehdr_ident_data; |
383 print phdr_type; | 391 print phdr_type; |
384 print phdr_type_name; | 392 print phdr_type_name; |
385 print phdr_flags; | 393 print phdr_flags; |
386 print shdr_flags; | 394 print shdr_flags; |
OLD | NEW |