1 #-------------------------------------------------------------------------------
4 # Seva Alekseyev (sevaa@sprynet.com)
5 # This code is in the public domain
6 #-------------------------------------------------------------------------------
10 from elftools
.elf
.elffile
import ELFFile
12 class TestFormIndirect(unittest
.TestCase
):
13 def test_formindirect(self
):
14 path
= os
.path
.join('test', 'testfiles_for_unittests',
16 with
open(path
, 'rb') as f
:
18 dwarfinfo
= elffile
.get_dwarf_info(follow_links
=False)
19 cu
= next(dwarfinfo
.iter_CUs())
20 # That DIE in that binary has an attribute with form DW_FORM_indirect
21 die
= next(die
for die
in cu
.iter_DIEs() if die
.tag
== 'DW_TAG_pointer_type')
22 attr
= die
.attributes
["DW_AT_type"]
23 self
.assertEqual(attr
.form
, "DW_FORM_ref2") # That's the real form
24 self
.assertEqual(attr
.indirection_length
, 1) # But the fact of indirection is captured
26 if __name__
== '__main__':