コード例 #1
0
 def test_overlapping_sections(self):
     """ Check that overlapping sections are detected """
     obj = ObjectFile(get_arch('msp430'))
     obj.get_section('s1', create=True).add_data(bytes(range(100)))
     obj.get_section('s2', create=True).add_data(bytes(range(100)))
     obj.add_image(Image('x', 0))
     obj.get_image('x').add_section(obj.get_section('s1'))
     obj.get_image('x').add_section(obj.get_section('s2'))
     with self.assertRaisesRegex(ValueError, 'overlap'):
         obj.get_image('x').data
コード例 #2
0
 def make_twins(self):
     """ Make two object files that have equal contents """
     arch = get_arch('arm')
     object1 = ObjectFile(arch)
     object2 = ObjectFile(arch)
     object2.get_section('code', create=True).add_data(bytes(range(55)))
     object1.get_section('code', create=True).add_data(bytes(range(55)))
     object1.add_symbol(10, 'A', 'global', None, None, 'object', 0)
     object2.add_symbol(10, 'A', 'global', None, None, 'object', 0)
     object1.gen_relocation('rel8', 10, 'code', 0x2)
     object2.gen_relocation('rel8', 10, 'code', 0x2)
     object1.add_symbol(0, 'A2', 'global', 0x90, 'code', 'object', 0)
     object2.add_symbol(0, 'A2', 'global', 0x90, 'code', 'object', 0)
     object1.add_symbol(1, 'A3', 'global', 0x90, 'code', 'object', 0)
     object2.add_symbol(1, 'A3', 'global', 0x90, 'code', 'object', 0)
     object1.add_image(Image('a', 0x0))
     object1.get_image('a').add_section(object1.get_section('code'))
     object2.add_image(Image('a', 0x0))
     object2.get_image('a').add_section(object2.get_section('code'))
     return object1, object2