Check disasm metadata for missed renames (#2069)

* Check disasm metadata (look for symbols in metadata that no longer exist, indicating renames but the metadata was not updated)

* -us.z64

* Update disasm metadata with renamed functions in #2057

* sort IGNORE_NTSC_1_2_SYMS_MISSING
This commit is contained in:
Dragorn421 2024-08-28 13:28:03 +02:00 committed by GitHub
parent 68818044db
commit 7592bf1e42
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 110 additions and 9 deletions

9
Jenkinsfile vendored
View File

@ -24,6 +24,15 @@ pipeline {
sh 'python3 tools/check_format.py --verbose --compare-to origin/main'
}
}
stage('Build ntsc-1.2, check disasm metadata') {
steps {
sh 'ln -s /usr/local/etc/roms/oot-ntsc-1.2-us.z64 baseroms/ntsc-1.2/baserom.z64'
sh 'make -j setup VERSION=ntsc-1.2'
sh 'make -j RUN_CC_CHECK=0 VERSION=ntsc-1.2'
sh '.venv/bin/python3 tools/check_disasm_metadata_unksyms.py -v ntsc-1.2'
sh 'make clean assetclean VERSION=ntsc-1.2'
}
}
// The ROMs are built in an order that maximizes compiler flags coverage in a "fail fast" approach.
// Specifically we start with a retail ROM for BSS ordering, and make sure we cover all of
// NTSC/PAL/MQ/DEBUG as quickly as possible.

View File

@ -0,0 +1,92 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: © 2024 ZeldaRET
# SPDX-License-Identifier: CC0-1.0
import argparse
from colorama import Fore
from pathlib import Path
import mapfile_parser
# symbols listed here will not be reported as unknown
IGNORE_NTSC_1_2_SYMS_MISSING = """
func_800ADC5C_unknown func_800ADE30_unknown func_80AEEA48_unknown func_80800AD0_unknown func_80800B08_unknown func_800AF4DC_unknown func_800CDDF8_unknown func_800014E8_unknown func_800AE558_unknown func_800AE064_unknown func_800AE1E0_unknown func_800014FC_unknown func_800ADFE4_unknown func_800CDDC4_unknown func_800AF0E0_unknown func_800AE2B8_unknown func_800AF304_unknown func_800AE020_unknown func_800AE05C_unknown func_800AE408_unknown func_8000161C_unknown func_800AF558_unknown func_800AED1C_unknown func_80001640_unknown func_800ADF4C_unknown func_800015E8_unknown func_800ADF90_unknown func_800ADD14_unknown func_800AE998_unknown func_800AE4C0_unknown func_800AF3DC_unknown func_800AF1C4_unknown func_8009D434_unknown func_800AE35C_unknown func_800AF720_unknown func_800AF370_unknown func_800AE258_unknown func_800AF7F0_unknown func_80001714_unknown func_800AEC94_unknown func_800ADDF0_unknown func_800AE1F8_unknown
__osReallocDebug __osMallocRDebug __osFreeDebug __osMallocDebug
guTranslateF guScaleF guMtxL2F
osEPiWriteIo createSpeedParam
AudioDebug_ProcessInput
func_800FF334
n64dd_SetDiskVersion
sJpegTask _n64ddSegmentRomStart _n64ddSegmentRomEnd _n64ddSegmentStart _string_n64dd_c
""".split()
def get_ldscript_syms(ldscript_p: Path):
symbols = set()
for l in ldscript_p.read_text().splitlines():
if "=" not in l:
continue
sym = l.split("=")[0].strip()
symbols.add(sym)
return symbols
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--oot-version", "-v", required=True)
args = parser.parse_args()
version = args.oot_version
ignore_syms_missing = set(
{
"ntsc-1.2": IGNORE_NTSC_1_2_SYMS_MISSING,
}.get(version, ())
)
mapfile = mapfile_parser.mapfile.MapFile()
mapfile_path = Path(f"build/{version}/oot-{version}.map")
mapfile.readMapFile(mapfile_path)
map_symbols = set()
for segment in mapfile:
for file in segment:
for sym in file:
map_symbols.add(sym.name)
has_unknown_metadata_syms = False
undefined_syms_p = Path(f"build/{version}/undefined_syms.txt")
undefined_syms = get_ldscript_syms(undefined_syms_p)
known_syms = map_symbols | undefined_syms
for metadata_p in (
Path(f"tools/disasm/{version}/functions.txt"),
Path(f"tools/disasm/{version}/variables.txt"),
):
metadata_symbols = get_ldscript_syms(metadata_p)
unknown_metadata_syms = metadata_symbols - known_syms
unknown_metadata_syms -= ignore_syms_missing
if unknown_metadata_syms:
print(
f"{Fore.RED}Found",
len(unknown_metadata_syms),
f"symbols in{Fore.RESET}",
metadata_p,
f"{Fore.RED}that are neither in the map",
f"nor in undefined_syms.txt{Fore.RESET}",
)
print("Were they renamed and the disasm metadata not updated? (or is the map out of date?)")
print(" ".join(unknown_metadata_syms))
has_unknown_metadata_syms = True
if has_unknown_metadata_syms:
exit(1)
else:
print(f"{Fore.GREEN}OK{Fore.RESET}")
if __name__ == "__main__":
main()

View File

@ -3268,15 +3268,15 @@ func_80832564 = 0x80830530; // type:func
func_80832594 = 0x80830568; // type:func
func_80832630 = 0x80830608; // type:func
Player_RequestRumble = 0x80830624; // type:func
func_80832698 = 0x80830670; // type:func
Player_PlayVoiceSfx = 0x80830670; // type:func
func_808326F0 = 0x808306D0; // type:func
func_8083275C = 0x8083073C; // type:func
func_80832770 = 0x80830758; // type:func
func_808327A4 = 0x80830790; // type:func
func_808327C4 = 0x808307B8; // type:func
func_808327F8 = 0x808307F0; // type:func
func_80832854 = 0x8083084C; // type:func
func_808328A0 = 0x80830898; // type:func
Player_ApplyFloorSfxOffset = 0x8083073C; // type:func
Player_PlayFloorSfx = 0x80830758; // type:func
Player_ApplyFloorAndAgeSfxOffsets = 0x80830790; // type:func
Player_PlayFloorSfxByAge = 0x808307B8; // type:func
Player_PlaySteppingSfx = 0x808307F0; // type:func
Player_PlayJumpingSfx = 0x8083084C; // type:func
Player_PlayLandingSfx = 0x80830898; // type:func
func_808328EC = 0x808308E4; // type:func
Player_ProcessAnimSfxList = 0x80830918; // type:func
Player_AnimChangeOnceMorph = 0x80830B00; // type:func

View File

@ -3,7 +3,7 @@ gActorOverlayTable = 0x800E8B70; // size:0x3AE0
gMaxActorId = 0x800EC650; // size:0x4
sJpegTask = 0x800F1BB0; // size:0x40 type:OSTask
gSramSlotOffsets = 0x800FC550; // size:0xC type:u16
Player_InitVars = 0x800FCB80; // size:0x20
Player_Profile = 0x800FCB80; // size:0x20
gKaleidoMgrOverlayTable = 0x800FEAD0; // size:0x38 type:KaleidoMgrOverlay
gScreenWidth = 0x800FEB50; // size:0x4 type:s32
gScreenHeight = 0x800FEB54; // size:0x4 type:s32