mirror of https://github.com/zeldaret/mm.git
Adjust disasm automatic behavior. Print out symbol names for function and data pointers
This commit is contained in:
parent
9fe4f51f97
commit
dbb90b579e
4106
include/functions.h
4106
include/functions.h
File diff suppressed because it is too large
Load Diff
2479
include/variables.h
2479
include/variables.h
File diff suppressed because it is too large
Load Diff
|
@ -308,13 +308,19 @@ class Disassembler:
|
||||||
else:
|
else:
|
||||||
return "%s" % filename
|
return "%s" % filename
|
||||||
|
|
||||||
def guess_functions_from_data(self):
|
def guess_functions_and_variables_from_data(self):
|
||||||
for file in self.files:
|
for file in self.files:
|
||||||
for i in range(0, file.size // 4):
|
for i in range(0, file.size // 4):
|
||||||
word = file.get_inst(i)
|
word = file.get_inst(i)
|
||||||
addr = file.vaddr + i*4
|
addr = file.vaddr + i*4
|
||||||
if self.is_in_data(addr) and self.is_in_code(word):
|
if self.is_in_data(addr):
|
||||||
self.add_function(word)
|
if self.is_in_code(word) and (word % 4) == 0:
|
||||||
|
None
|
||||||
|
# TODO functions are disabled for now due to behaving poorly with switches. This should be a flag.
|
||||||
|
#self.add_function(word)
|
||||||
|
elif self.is_in_data(word):
|
||||||
|
self.add_variable(word)
|
||||||
|
|
||||||
|
|
||||||
def disassemble(self, path):
|
def disassemble(self, path):
|
||||||
self.first_pass()
|
self.first_pass()
|
||||||
|
@ -347,7 +353,7 @@ class Disassembler:
|
||||||
# don't split if it's the start of a data section, it's probably the same object
|
# don't split if it's the start of a data section, it's probably the same object
|
||||||
if not self.is_in_data_or_undef(new_object_start):
|
if not self.is_in_data_or_undef(new_object_start):
|
||||||
self.add_object(new_object_start)
|
self.add_object(new_object_start)
|
||||||
self.guess_functions_from_data()
|
self.guess_functions_and_variables_from_data()
|
||||||
self.has_done_first_pass = True
|
self.has_done_first_pass = True
|
||||||
|
|
||||||
def second_pass(self, path):
|
def second_pass(self, path):
|
||||||
|
@ -378,6 +384,10 @@ class Disassembler:
|
||||||
|
|
||||||
if not self.is_in_data_or_undef(addr):
|
if not self.is_in_data_or_undef(addr):
|
||||||
f.write("/* %06d 0x%08X %08X */ %s\n" % (i, addr, inst, self.disassemble_inst(inst, addr, i, file)))
|
f.write("/* %06d 0x%08X %08X */ %s\n" % (i, addr, inst, self.disassemble_inst(inst, addr, i, file)))
|
||||||
|
elif inst in self.functions:
|
||||||
|
f.write("/* %06d 0x%08X */ .word\t%s\n" % (i, addr, get_func_name(inst)))
|
||||||
|
elif self.is_in_data(inst):
|
||||||
|
f.write("/* %06d 0x%08X */ .word\t%s\n" % (i, addr, get_symbol_name(inst)))
|
||||||
else:
|
else:
|
||||||
f.write("/* %06d 0x%08X */ .word\t0x%08X\n" % (i, addr, inst))
|
f.write("/* %06d 0x%08X */ .word\t0x%08X\n" % (i, addr, inst))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue