diff --git a/tools/sync_pmdsky_debug/pmdsky_debug_reader.py b/tools/sync_pmdsky_debug/pmdsky_debug_reader.py index d54ddbd5..1a9e61a0 100644 --- a/tools/sync_pmdsky_debug/pmdsky_debug_reader.py +++ b/tools/sync_pmdsky_debug/pmdsky_debug_reader.py @@ -114,5 +114,6 @@ def read_pmdsky_debug_symbols() -> Dict[str, Dict[str, Dict[int, SymbolDetails]] for file in os.listdir(overlay_folder): if file.endswith('.yml'): read_yaml_symbols(os.path.join(overlay_name, file), str(i)) + read_yaml_symbols('ram.yml', 'ram') return pmdsky_debug_symbols diff --git a/tools/sync_pmdsky_debug/sync_from_pmdsky_debug.py b/tools/sync_pmdsky_debug/sync_from_pmdsky_debug.py index 199b0a5e..7c404c09 100644 --- a/tools/sync_pmdsky_debug/sync_from_pmdsky_debug.py +++ b/tools/sync_pmdsky_debug/sync_from_pmdsky_debug.py @@ -39,6 +39,10 @@ replaced_symbols = set() for language, pmdsky_debug_language_symbols in pmdsky_debug_symbols.items(): xmap_language_symbols = xmap_symbols[language] for section_name, pmdsky_debug_section in pmdsky_debug_language_symbols.items(): + if section_name == 'ram': + # We can't distinguish between different types of RAM symbols. + # E.g., they could be in the BSS, heap, etc. + continue if section_name in xmap_language_symbols: xmap_section = xmap_language_symbols[section_name] else: diff --git a/tools/sync_pmdsky_debug/sync_to_pmdsky_debug.py b/tools/sync_pmdsky_debug/sync_to_pmdsky_debug.py index 7aac60e4..aea84896 100644 --- a/tools/sync_pmdsky_debug/sync_to_pmdsky_debug.py +++ b/tools/sync_pmdsky_debug/sync_to_pmdsky_debug.py @@ -70,6 +70,8 @@ def sync_xmap_symbol(address: int, symbol: SymbolDetails, language: str, yaml_ma base_symbol_path = 'arm7.yml' elif section_name == 'ITCM': base_symbol_path = os.path.join('arm9', 'itcm.yml') + elif section_name == 'ram': + base_symbol_path = 'ram.yml' else: base_symbol_path = f'overlay{int(section_name):02d}.yml' diff --git a/tools/sync_pmdsky_debug/xmap_reader.py b/tools/sync_pmdsky_debug/xmap_reader.py index b948d652..e74da77d 100644 --- a/tools/sync_pmdsky_debug/xmap_reader.py +++ b/tools/sync_pmdsky_debug/xmap_reader.py @@ -56,6 +56,9 @@ def read_xmap_symbols_for_language(language: str) -> Dict[str, Dict[int, SymbolD for line in xmap_lines: if line.startswith(SECTION_START): section_name = line[len(SECTION_START) : -1] + # The corresponding BSS sections can contain RAM data symbols + is_ram = section_name.endswith('.bss') + section_name = section_name.removesuffix('.bss') if section_name in overlay_names: current_section = str(overlay_names[section_name]) elif section_name == 'main' or section_name == 'ITCM' or section_name == 'arm7': @@ -64,10 +67,12 @@ def read_xmap_symbols_for_language(language: str) -> Dict[str, Dict[int, SymbolD current_section = 'arm7' else: current_section = None + if current_section is not None and is_ram: + current_section = 'ram' if current_section is not None and current_section not in xmap_symbols: xmap_symbols[current_section]: Dict[str, int] = {} - elif current_section is not None and line.startswith(' ') and ('.text' in line or '.data' in line) and len(line) > 28 and line[28] not in NON_FUNCTION_SYMBOLS: + elif current_section is not None and line.startswith(' ') and ('.text' in line or '.data' in line or '.bss' in line) and len(line) > 28 and line[28] not in NON_FUNCTION_SYMBOLS: symbol_split = line[28:-1].split('\t') symbol_name = symbol_split[0] symbol_address = int(line[2:10], 16)