Skip to content

Commit

Permalink
Make config stage fixes (Xeeynamo#1657)
Browse files Browse the repository at this point in the history
Fixes a few issues found by @bismurphy where certain symbols that were
not supposed to be added, were added.

The major fix is when the second pass found a meaningful symbol name
like `MakeExplosion`, the third pass could add a new symbol with the
same offset but with the default splat name `func_8019055C`. With the
new `add_symbol_unique` the symbol table will stay unique. On top of
that when adding a new symbol `func_8019055C` can be replaced by
`MakeExplosion` but not the other way around. This will ensure only
meaningful names will be resolved.
  • Loading branch information
Xeeynamo authored Sep 22, 2024
1 parent d30e3e0 commit d43a7ae
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tools/make-config.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,43 @@ def get_symbol_table(splat_config, table):
return [int(line, 16) for line in table]


def add_symbol_unique(symbol_file_name: str, name: str, offset: int):
with open(symbol_file_name, "r") as f:
lines = f.readlines()
symbol_already_in_the_list = False
for i in range(len(lines)):
if f"0x{offset:08X}" in lines[i]:
symbol_already_in_the_list = True
if not lines[i].startswith("func_"):
return
if not lines[i].startswith("D_"):
return
if name.startswith("func_"):
return
if name.startswith("D_"):
return
# replace the existing default splat symbol with the good name
lines[i] = f"{name} = 0x{offset:08X}"
with open(symbol_file_name, "w") as f:
f.writelines(lines)
return
if not symbol_already_in_the_list:
with open(symbol_file_name, "a") as f:
f.write(f"{name} = 0x{offset:08X};\n")


def add_symbol(splat_config, version: str, name: str, offset: int):
if offset == 0:
return
# do not add symbols that belongs to the shared area
base_addr = splat_config["segments"][0]["vram"]
if offset < base_addr:
return

# add symbol to the overlay symbol list
symbol_file_name = splat_config["options"]["symbol_addrs_path"][1]
sym_prefix = get_symbol_prefix(splat_config)
with open(symbol_file_name, "a") as f:
f.write(f"{name} = 0x{offset:08X};\n")
add_symbol_unique(symbol_file_name, name, offset)
sort_symbols_from_file(symbol_file_name)

# do a find & replace on the extracted C code
Expand Down

0 comments on commit d43a7ae

Please sign in to comment.