Support syncing BSS symbols to pmdsky-debug

These data symbols can be added to ram.yml. Since information is lost,
it's not possible to go in the other direction, so RAM syncing can only
be done TO pmdsky-debug.
This commit is contained in:
UsernameFodder 2023-12-28 23:37:51 -06:00
parent eb600a887d
commit 3d87a95850
4 changed files with 13 additions and 1 deletions

View File

@ -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

View File

@ -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:

View File

@ -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'

View File

@ -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)