"""
def __init__(self, stream, elffile, stringtable, position, empty):
"""
- :param stream: The file-like object from which to load data
- :param elffile: The parent elffile object
- :param stringtable: A stringtable reference to use for parsing string references in entries
- :param position: The file offset of the dynamic segment/section
- :param empty: Whether this is a degenerate case with zero entries. Normally, every dynamic table
- will have at least one entry, the DT_NULL terminator.
+ stream:
+ The file-like object from which to load data
+
+ elffile:
+ The parent elffile object
+
+ stringtable:
+ A stringtable reference to use for parsing string references in
+ entries
+
+ position:
+ The file offset of the dynamic segment/section
+
+ empty:
+ Whether this is a degenerate case with zero entries. Normally, every
+ dynamic table will have at least one entry, the DT_NULL terminator.
"""
self.elffile = elffile
self.elfstructs = elffile.structs
class TestDBGFile(unittest.TestCase):
def test_dynamic_segment(self):
- """
- Test that the degenerate case for the dynamic segment does not crash
+ """ Test that the degenerate case for the dynamic segment does not crash
"""
with open(os.path.join('test', 'testfiles_for_unittests',
'debug_info.elf'), 'rb') as f:
seen_dynamic_segment = False
for segment in elf.iter_segments():
- if segment.header.p_type != 'PT_DYNAMIC':
- continue
-
- self.assertEqual(segment.num_tags(), 0, "The dynamic segment in this file should be empty")
- seen_dynamic_segment = True
- break
+ if segment.header.p_type == 'PT_DYNAMIC':
+ self.assertEqual(segment.num_tags(), 0, "The dynamic segment in this file should be empty")
+ seen_dynamic_segment = True
+ break
self.assertTrue(seen_dynamic_segment, "There should be a dynamic segment in this file")
def test_dynamic_section(self):
- """
- Test that the degenerate case for the dynamic section does not crash
+ """ Test that the degenerate case for the dynamic section does not crash
"""
with open(os.path.join('test', 'testfiles_for_unittests',
'debug_info.elf'), 'rb') as f:
self.assertEqual(section.num_tags(), 0, "The dynamic section in this file should be empty")
def test_eh_frame(self):
- """
- Test that parsing .eh_frame with SHT_NOBITS does not crash
+ """ Test that parsing .eh_frame with SHT_NOBITS does not crash
"""
with open(os.path.join('test', 'testfiles_for_unittests',
'debug_info.elf'), 'rb') as f: