diff --git a/mwccgap/preprocessor.py b/mwccgap/preprocessor.py index af1c775..132e579 100644 --- a/mwccgap/preprocessor.py +++ b/mwccgap/preprocessor.py @@ -67,10 +67,12 @@ def preprocess_s_file( if line.startswith("enddlabel") or line.startswith("nmlabel"): continue - if line.startswith("glabel") or line.startswith("dlabel"): + if any(line.startswith(x) for x in ["glabel", "dlabel", "jlabel"]): _, current_symbol = line.removesuffix(LOCAL_SUFFIX).split(" ") is_local = ( - line.endswith(LOCAL_SUFFIX) or DOLLAR_SIGN in current_symbol + line.endswith(LOCAL_SUFFIX) + or DOLLAR_SIGN in current_symbol + or line.startswith("jlabel") ) rodata_entries[current_symbol] = Symbol( current_symbol, local=is_local @@ -125,7 +127,11 @@ def preprocess_s_file( if line.startswith(".align") or line.startswith(".balign"): # ignore alignment continue - if line.startswith("glabel") or line.startswith("jlabel") or line.startswith("alabel"): + if ( + line.startswith("glabel") + or line.startswith("jlabel") + or line.startswith("alabel") + ): # ignore function / jumptable labels continue if line.startswith("endlabel") or line.startswith("enddlabel"): diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index 26ffa42..c50dd40 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -173,6 +173,27 @@ def test_dollar_symbol(self): self.assertTrue(rodata_entries[expected_symbol_name].local) self.assertTrue(c_lines[0].startswith("static ")) + def test_rodata_jlabel(self): + asm_contents = """ +.section .rodata + +jlabel D_psp_0893C06C + /* 3D760 0893C06C 28D59A08 */ .word D_psp_089AD528 + /* 3D764 0893C070 00000000 */ .word 0x00000000 +.size D_psp_0893C06C, . - D_psp_0893C06C +""" + c_lines, rodata_entries = Preprocessor().preprocess_s_file( + "jlabel.s", asm_contents.splitlines() + ) + expected_symbol_name = "D_psp_0893C06C" + + self.assertEqual(1, len(c_lines)) + self.assertEqual(1, len(rodata_entries)) + self.assertIn(expected_symbol_name, rodata_entries) + self.assertEqual(2 * 4, rodata_entries[expected_symbol_name].size) + self.assertTrue(rodata_entries[expected_symbol_name].local) + self.assertTrue(c_lines[0].startswith("static ")) + class TestPreprocessSFileExceptions(unittest.TestCase): def test_rodata_unknown_directive(self):