コード例 #1
0
 def setUp(self):
     symbols = [
         sa.Symbol(0x1000, 'F', 0x15C, 'hook_task'),
         sa.Symbol(0x2000, 'F', 0x51C, 'console_task'),
         sa.Symbol(0x3200, 'O', 0x124, '__just_data'),
         sa.Symbol(0x4000, 'F', 0x11C, 'touchpad_calc'),
         sa.Symbol(0x5000, 'F', 0x12C, 'touchpad_calc.constprop.42'),
         sa.Symbol(0x12000, 'F', 0x13C, 'trackpad_range'),
         sa.Symbol(0x13000, 'F', 0x200, 'inlined_mul'),
         sa.Symbol(0x13100, 'F', 0x200, 'inlined_mul'),
         sa.Symbol(0x13100, 'F', 0x200, 'inlined_mul_alias'),
         sa.Symbol(0x20000, 'O', 0x0, '__array'),
         sa.Symbol(0x20010, 'O', 0x0, '__array_end'),
     ]
     tasklist = [
         sa.Task('HOOKS', 'hook_task', 2048, 0x1000),
         sa.Task('CONSOLE', 'console_task', 460, 0x2000)
     ]
     # Array at 0x20000 that contains pointers to hook_task and console_task,
     # with stride=8, offset=4
     rodata = (0x20000, [0xDEAD1000, 0x00001000, 0xDEAD2000, 0x00002000])
     options = mock.MagicMock(elf_path='./ec.RW.elf',
                              export_taskinfo='fake',
                              section='RW',
                              objdump='objdump',
                              addr2line='addr2line',
                              annotation=None)
     self.analyzer = sa.StackAnalyzer(options, symbols, rodata, tasklist,
                                      {})
コード例 #2
0
 def setUp(self):
   symbols = [sa.Symbol(0x1000, 'F', 0x15C, 'hook_task'),
              sa.Symbol(0x2000, 'F', 0x51C, 'console_task'),
              sa.Symbol(0x3200, 'O', 0x124, '__just_data'),
              sa.Symbol(0x4000, 'F', 0x11C, 'touchpad_calc'),
              sa.Symbol(0x5000, 'F', 0x12C, 'touchpad_calc.constprop.42'),
              sa.Symbol(0x12000, 'F', 0x13C, 'trackpad_range'),
              sa.Symbol(0x13000, 'F', 0x200, 'inlined_mul'),
              sa.Symbol(0x13100, 'F', 0x200, 'inlined_mul'),
              sa.Symbol(0x13100, 'F', 0x200, 'inlined_mul_alias')]
   tasklist = [sa.Task('HOOKS', 'hook_task', 2048, 0x1000),
               sa.Task('CONSOLE', 'console_task', 460, 0x2000)]
   options = mock.MagicMock(elf_path='./ec.RW.elf',
                            export_taskinfo='fake',
                            section='RW',
                            objdump='objdump',
                            addr2line='addr2line',
                            annotation=None)
   self.analyzer = sa.StackAnalyzer(options, symbols, tasklist, {})
コード例 #3
0
    def testLoadTasklist(self):
        def tasklist_to_taskinfos(pointer, tasklist):
            taskinfos = []
            for task in tasklist:
                taskinfos.append(
                    sa.TaskInfo(name=task.name.encode('utf-8'),
                                routine=task.routine_name.encode('utf-8'),
                                stack_size=task.stack_max_size))

            TaskInfoArray = sa.TaskInfo * len(taskinfos)
            pointer.contents.contents = TaskInfoArray(*taskinfos)
            return len(taskinfos)

        def ro_taskinfos(pointer):
            return tasklist_to_taskinfos(pointer, expect_ro_tasklist)

        def rw_taskinfos(pointer):
            return tasklist_to_taskinfos(pointer, expect_rw_tasklist)

        expect_ro_tasklist = [
            sa.Task('HOOKS', 'hook_task', 2048, 0x1000),
        ]

        expect_rw_tasklist = [
            sa.Task('HOOKS', 'hook_task', 2048, 0x1000),
            sa.Task('WOOKS', 'hook_task', 4096, 0x1000),
            sa.Task('CONSOLE', 'console_task', 460, 0x2000),
        ]

        export_taskinfo = mock.MagicMock(
            get_ro_taskinfos=mock.MagicMock(side_effect=ro_taskinfos),
            get_rw_taskinfos=mock.MagicMock(side_effect=rw_taskinfos))

        tasklist = sa.LoadTasklist('RO', export_taskinfo,
                                   self.analyzer.symbols)
        self.assertEqual(tasklist, expect_ro_tasklist)
        tasklist = sa.LoadTasklist('RW', export_taskinfo,
                                   self.analyzer.symbols)
        self.assertEqual(tasklist, expect_rw_tasklist)
コード例 #4
0
 def testTask(self):
     task_a = sa.Task('a', 'a_task', 1234)
     task_b = sa.Task('b', 'b_task', 5678, 0x1000)
     self.assertEqual(task_a, task_a)
     self.assertNotEqual(task_a, task_b)
     self.assertNotEqual(task_a, None)