From 7c2e0383f32683807e1ffb6d7d019cf50e7967d2 Mon Sep 17 00:00:00 2001 From: cadmic Date: Sun, 25 Aug 2024 07:43:07 -0700 Subject: [PATCH] In fix_bss.py, really always use BSS section start from map file (#2085) --- src/audio/data.c | 2 ++ src/audio/session_config.c | 1 - tools/fix_bss.py | 15 +++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/audio/data.c b/src/audio/data.c index 1c84d5e704..41d4f75226 100644 --- a/src/audio/data.c +++ b/src/audio/data.c @@ -69,3 +69,5 @@ u8 gSoundModeList[] = { u8 gAudioSpecId = 0; u8 D_80133418 = 0; + +u8 D_8016F0E0[0xA0]; // unused diff --git a/src/audio/session_config.c b/src/audio/session_config.c index 2178a12e88..c8966ad95c 100644 --- a/src/audio/session_config.c +++ b/src/audio/session_config.c @@ -1,6 +1,5 @@ #include "global.h" -u8 D_8016F0E0[0xA0]; // unused AudioContext gAudioCtx; AudioCustomUpdateFunction gAudioCustomUpdateFunction; s32 D_801755D8[3]; // unused diff --git a/tools/fix_bss.py b/tools/fix_bss.py index 9b999d072d..f36f79e3b4 100755 --- a/tools/fix_bss.py +++ b/tools/fix_bss.py @@ -401,9 +401,6 @@ def determine_base_bss_ordering( build_bss_symbols: list[BssSymbol], bss_section: BssSection, ) -> list[BssSymbol]: - # For the baserom, assume that the lowest address is the start of the BSS section. This might - # not be true if the first BSS variable is not referenced, but in practice this doesn't seem - # to happen for the files which typically have BSS ordering issues. base_start_address = min(p.base_value for p in bss_section.pointers) found_symbols: dict[str, BssSymbol] = {} @@ -775,10 +772,16 @@ def main(): for file, bss_section in bss_sections.items(): if not bss_section.pointers: continue - # Try to detect if the section is shifted by comparing the lowest - # address among any pointer into the section between base and build + # The following heuristic doesn't work for z_locale, since the first pointer into BSS is not + # at the start of the section. Fortunately z_locale either has one BSS variable (in GC versions) + # or none (in N64 versions), so we can just skip it. + if str(file) == "src/boot/z_locale.c": + continue + # For the baserom, assume that the lowest address is the start of the BSS section. This might + # not be true if the first BSS variable is not referenced, but in practice this doesn't happen + # (except for z_locale above). base_min_address = min(p.base_value for p in bss_section.pointers) - build_min_address = min(p.build_value for p in bss_section.pointers) + build_min_address = bss_section.start_address if not all( p.build_value - build_min_address == p.base_value - base_min_address for p in bss_section.pointers