starting tests for callframes
[pyelftools.git] / examples / elfclass_address_size.py
1 #-------------------------------------------------------------------------------
2 # elftools example: elfclass_address_size.py
3 #
4 # This example explores the ELF class (32 or 64-bit) and address size in each
5 # of the CUs in the DWARF information.
6 #
7 # Eli Bendersky (eliben@gmail.com)
8 # This code is in the public domain
9 #-------------------------------------------------------------------------------
10 import sys
11 from elftools.elf.elffile import ELFFile
12
13
14 def process_file(filename):
15 with open(filename) as f:
16 elffile = ELFFile(f)
17 print '%s: elfclass is %s' % (filename, elffile.elfclass)
18
19 if elffile.has_dwarf_info():
20 dwarfinfo = elffile.get_dwarf_info()
21 for CU in dwarfinfo.iter_CUs():
22 print ' CU at offset 0x%x. address_size is %s' % (
23 CU.cu_offset, CU['address_size'])
24
25 if __name__ == '__main__':
26 for filename in sys.argv[1:]:
27 process_file(filename)
28