Skip to content

Commit

Permalink
Fix extract_function including numbers in includes
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousRandomPerson committed Oct 29, 2024
1 parent 5ebc834 commit 83244da
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tools/extract_function/extract_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_line_address(line: str):
WORD_KEY = '.word '
WORD_PLUS_OFFSET = ' + 0x'
"""
Searches through an ASM file's contents for all external symbosl, then populates a .inc file with all the necessary .public definitions.
Searches through an ASM file's contents for all external symbols, then populates a .inc file with all the necessary .public definitions.
"""
def write_inc_file(lines: List[str], file_path: str):
defined_functions = set()
Expand All @@ -152,9 +152,12 @@ def write_inc_file(lines: List[str], file_path: str):
if word_index >= 0 and f'{WORD_KEY}0x' not in line:
word_plus_offset_index = line.find(WORD_PLUS_OFFSET)
if word_plus_offset_index >= 0:
used_functions.add(line[word_index + len(WORD_KEY) : word_plus_offset_index])
new_word = line[word_index + len(WORD_KEY) : word_plus_offset_index]
else:
used_functions.add(line[word_index + len(WORD_KEY) : -1])
new_word = line[word_index + len(WORD_KEY) : -1]

if new_word[0] < '0' or new_word > '9':
used_functions.add(new_word)

for function in defined_functions:
if function in used_functions:
Expand Down

0 comments on commit 83244da

Please sign in to comment.