This commit is contained in:
MonsterDruide1 2025-05-18 14:16:05 +02:00
parent 97763f0d16
commit 589fb51488

View file

@ -38,7 +38,6 @@ for offset in drive_list:
print("Collecting symbols...")
"""
class Symbol:
def __init__(self, name, start, end):
self.name = name
@ -64,6 +63,12 @@ class Segment:
self.name = name
self.file = "split/%s.s" % name
self.symbols = read_global_symbols(self.file)
def dummy(self):
# Dummy function to avoid errors when calling methods on segments
pass
UNDEF_SYMBOLS = []
class Segments:
def __init__(self, segments):
@ -75,10 +80,11 @@ class Segments:
if name in segment.symbols:
segment.symbols[name].add_occurrence(reference)
return
if not name in self.text.symbols:
if not name in self.text.symbols and not name in UNDEF_SYMBOLS:
print("Symbol %s not found in any segment" % name)
UNDEF_SYMBOLS.append(name)
segments = Segments(["data", "rodata", "got"])
segments = Segments(["data", "rodata", "got", "got.plt", "bss"])
print("Resolving references to symbols...")
@ -92,10 +98,15 @@ with open('split/text.s', 'r') as file:
parts = line.split(":lo12:")
if len(parts) != 2:
print(":lo12: does appear more than once in line: %s" % line)
# off_7101E4EAF0
off_name = parts[1][0:14]
if not off_name.startswith("off_"):
print("Invalid offset name: %s" % off_name)
if parts[1].startswith("off_"):
# off_7101E4EAF0
off_name = parts[1][0:14]
elif parts[1].startswith("fn_"):
# fn_7101E4EAF0
off_name = parts[1][0:13]
else:
print("Invalid offset name: %s" % parts[1])
off_name = parts[1]
segments.add_reference(off_name, current_function)
@ -126,7 +137,6 @@ for segment in segments.segments:
unref_symbols += 1
print("Unreferenced symbols in %s: %d" % (segment.name, unref_symbols))
"""
print("Generating .text list...")
# name: {.text: [offset: name], .data: [start, end], ...}