Skip to content

Commit 97f3f63

Browse files
fixed a multiple execution bug to avoid redundant execution of analysis passes
1 parent 841c1ec commit 97f3f63

File tree

3 files changed

+40
-21
lines changed

3 files changed

+40
-21
lines changed

shannon_indirect_xref.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
# A lean IDA Pro loader for fancy baseband research
55
# Alexander Pick 2024-2025
66

7-
import os
87
import idc
98
import ida_segment
109
import ida_ua
10+
11+
import os
12+
1113
import shannon_generic
1214

1315
max_ops = 6

shannon_pal_reconstructor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ def find_pal_msg_funcs():
141141
ida_name.SN_NOCHECK | ida_name.SN_FORCE)
142142

143143
find_pal_msg_init(pal_MsgSendTo_addr)
144+
145+
return
144146

145147

146148
# try to find pal_MsgInit() and a few others along
@@ -202,6 +204,8 @@ def find_pal_msg_init(pal_MsgSendTo_addr):
202204
break
203205

204206
func_cnt += 1
207+
208+
return
205209

206210
# try to find Task SCheduler, Task Inits and pal_Init()
207211
def find_pal_init():

shannon_postprocess.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,14 @@ def auto_empty_finally(self):
170170
global post_processed
171171

172172
# avoid this to be triggered twice
173-
if(post_processed):
173+
if(post_processed is True):
174174
return
175-
post_processed = True
175+
else:
176+
post_processed = True
177+
178+
# avoid multiple execution paths if a segment get split due to scatter etc.
179+
boot_processed_once = False
180+
main_processed_once = False
176181

177182
# start calculating runtime
178183
start_time = time.process_time()
@@ -196,40 +201,48 @@ def auto_empty_finally(self):
196201

197202
# add some names
198203
if (seg_name == "BOOT_file"):
204+
205+
if(boot_processed_once is False):
206+
207+
boot_processed_once = True
199208

200-
shannon_generic.get_ref_set_name(seg_start, "start")
209+
shannon_generic.get_ref_set_name(seg_start, "start")
201210

202211
if (seg_name == "MAIN_file"):
212+
213+
if(main_processed_once is False):
214+
215+
main_processed_once = True
203216

204-
shannon_generic.get_ref_set_name(seg_start, "reset_v")
217+
shannon_generic.get_ref_set_name(seg_start, "reset_v")
205218

206-
shannon_generic.get_ref_set_name(seg_start + 4, "undef_inst_v")
219+
shannon_generic.get_ref_set_name(seg_start + 4, "undef_inst_v")
207220

208-
shannon_generic.get_ref_set_name(seg_start + 8, "soft_int_v")
221+
shannon_generic.get_ref_set_name(seg_start + 8, "soft_int_v")
209222

210-
shannon_generic.get_ref_set_name(seg_start + 12, "prefetch_abort_v")
223+
shannon_generic.get_ref_set_name(seg_start + 12, "prefetch_abort_v")
211224

212-
shannon_generic.get_ref_set_name(seg_start + 16, "data_abort_v")
225+
shannon_generic.get_ref_set_name(seg_start + 16, "data_abort_v")
213226

214-
shannon_generic.get_ref_set_name(seg_start + 20, "reserved_v")
227+
shannon_generic.get_ref_set_name(seg_start + 20, "reserved_v")
215228

216-
shannon_generic.get_ref_set_name(seg_start + 24, "irq_v")
229+
shannon_generic.get_ref_set_name(seg_start + 24, "irq_v")
217230

218-
shannon_generic.get_ref_set_name(seg_start + 28, "fiq_v")
231+
shannon_generic.get_ref_set_name(seg_start + 28, "fiq_v")
219232

220-
self.memory_ranges()
233+
self.memory_ranges()
221234

222-
# it is very important to do this in the correct order
223-
# especially for new modems or the result will be left
224-
# in a weird state
235+
# it is very important to do this in the correct order
236+
# especially for new modems or the result will be left
237+
# in a weird state
225238

226-
shannon_mpu.find_hw_init()
227-
shannon_mpu.scan_for_mrc()
239+
shannon_mpu.find_hw_init()
240+
shannon_mpu.scan_for_mrc()
228241

229-
shannon_scatterload.find_scatter()
242+
shannon_scatterload.find_scatter()
230243

231-
shannon_pal_reconstructor.find_pal_msg_funcs()
232-
shannon_pal_reconstructor.find_pal_init()
244+
shannon_pal_reconstructor.find_pal_msg_funcs()
245+
shannon_pal_reconstructor.find_pal_init()
233246

234247
find_rvct()
235248

0 commit comments

Comments
 (0)