For the job reason, i need to statistic the stack frame of application binary. Any way, i studied the MIPS16E assembly instruction. And found that there is a set of intruction to save register at the beginning of function, named save.
So, i think only need thing to do is to filt the save instruction.
I am enjoying the feeling for using python. So following code is easy to come the work down.
8 string_file = open('cuncuntong_flash.dasm')
9 tmp = string_file.read()
10
11 stop_pos = tmp.find('Disassembly of section .flashro:')
12 code = tmp[0:stop_pos]
13 #print string
14
15 p = re.compile(r'<(?P<func>.*)>:/s*/n.*save/s*([/w-]+,|)(?P<size>/d+),')
16
17 dest_file = open('func_size.csv','w')
18
19 for i in p.finditer(code):
20 dest_file.write(i.group('func'))
21 dest_file.write(',')
22
23 dest_file.write(i.group('size'))
24 dest_file.write('/n')
Regular expression is excellent facility to accomplish these tasks.
Then put the statistic data to a csv. At last, i get the file as follows.
avl_si_load_chan_table | 2040 |
avl_si_save_chan_table | 2040 |
cct_ui_start | 1056 |
avl_si_load_ts | 848 |
avl_si_save_ts | 824 |
setting_menu_list_pressed_callback | 616 |
avl_printf | 304 |
osd_linklist_update | 240 |
cct_start | 224 |
avl_osd_draw_character | 216 |
tune_to_transponder | 216 |
...................
But, it is very odd to find that the biggest stack frame is 2040. And i can't find anyer larger. While the temporary variable is larger than 2040.
After having several test, i guess that, 2040 is the biggest value for save instruction.
Maybe this the MIPS toolchain's bug.