Improve debug_map_diff.py, handle UNUSED symbols

This commit is contained in:
LagoLunatic
2026-05-28 16:30:56 -04:00
parent ce8aa593df
commit 0d6d429ad1
+21 -7
View File
@@ -83,15 +83,22 @@ def get_rel_symbols(rel_map_data: str):
current_section_name = section_header_match.group(1)
if current_section_name != "text":
continue
symbol_entry_match = re.search(r"^ [0-9a-f]{8} ([0-9a-f]{6}) ([0-9a-f]{8})(?: +\d+)? (.+?)(?: \(entry of [^)]+\))? \t(\S+)", line, re.IGNORECASE)
symbol_entry_match = re.search(r"^ ([0-9a-f]{8}|UNUSED ) ([0-9a-f]{6}) ([0-9a-f]{8}|\.{8})(?: +\d+)? (.+?)(?: \(entry of [^)]+\))? \t?(\S+)", line, re.IGNORECASE)
if symbol_entry_match:
symbol_size = symbol_entry_match.group(1)
symbol_address = symbol_entry_match.group(1)
symbol_size = symbol_entry_match.group(2)
symbol_size = int(symbol_size, 16)
symbol_offset = symbol_entry_match.group(2)
symbol_offset = int(symbol_offset, 16)
symbol_name = symbol_entry_match.group(3)
object_name = symbol_entry_match.group(4)
if object_name in ["global_destructor_chain.o"]:
symbol_offset = symbol_entry_match.group(3)
if symbol_address == "UNUSED ":
assert symbol_offset == "........"
if symbol_offset == "........":
assert symbol_address == "UNUSED "
symbol_offset = None
else:
symbol_offset = int(symbol_offset, 16)
symbol_name = symbol_entry_match.group(4)
object_name = symbol_entry_match.group(5)
if object_name in ["executor.o", "global_destructor_chain.o"]:
continue
symbols[symbol_name] = symbol_size
#print("%08X %s" % (symbol_offset, symbol_name))
@@ -100,6 +107,11 @@ def get_rel_symbols(rel_map_data: str):
return symbols
def is_debug_only_symbol(symbol_name: str):
if "__11JORMContextF" in symbol_name:
return True
return False
if is_rel:
target_symbols = get_rel_symbols(target_map_path.read_text())
base_symbols = get_rel_symbols(base_map_path.read_text())
@@ -154,6 +166,8 @@ for symbol_name, base_size in base_symbols.items():
for symbol_name, target_size, base_size, ratio in symbol_size_diffs:
prefix = ""
if base_size == 0:
if is_debug_only_symbol(symbol_name):
continue
prefix = "MISSING: "
total_missing += 1
print(prefix + symbol_name, "0x%X" % target_size)