1 #-------------------------------------------------------------------------------
2 # elftools example: elfclass_address_size.py
4 # This example explores the ELF class (32 or 64-bit) and address size in each
5 # of the CUs in the DWARF information.
7 # Eli Bendersky (eliben@gmail.com)
8 # This code is in the public domain
9 #-------------------------------------------------------------------------------
11 from elftools
.elf
.elffile
import ELFFile
14 def process_file(filename
):
15 with
open(filename
) as f
:
17 print '%s: elfclass is %s' % (filename
, elffile
.elfclass
)
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'])
27 for filename
in sys
.argv
[1:]:
28 process_file(filename
)
31 if __name__
== '__main__':