diff --git a/tools/extract_function/extract_function.py b/tools/extract_function/extract_function.py index df56f45a..20cd6fc6 100644 --- a/tools/extract_function/extract_function.py +++ b/tools/extract_function/extract_function.py @@ -113,8 +113,8 @@ def get_line_address(line: str): lsf_lines[i] += f'\tObject asm/{file_prefix}{new_file_address}.o\n' break - -BRANCH_LABEL_INSTRUCTION = '\tbl ' +BRANCH_LINK_INSTRUCTION = '\tbl ' +BRANCH_LINK_EXCHANGE_INSTRUCTION = '\tblx ' BRANCH_INSTRUCTION = '\tb ' WORD_KEY = '.word ' WORD_PLUS_OFFSET = ' + 0x' @@ -124,13 +124,19 @@ def write_inc_file(lines: List[str], file_path: str): for line in lines: if line.startswith(ARM_FUNC_START): defined_functions.add(line[len(ARM_FUNC_START) : -1]) - elif line.startswith(BRANCH_LABEL_INSTRUCTION): - used_functions.add(line[len(BRANCH_LABEL_INSTRUCTION) : -1]) + elif line.startswith(BRANCH_LINK_INSTRUCTION): + used_functions.add(line[len(BRANCH_LINK_INSTRUCTION) : -1]) elif line.startswith(BRANCH_INSTRUCTION): function = line[len(BRANCH_INSTRUCTION) : -1] if function[0] != '_': semicolon_index = function.index(' ; ') used_functions.add(function[:semicolon_index]) + elif line.startswith(BRANCH_LINK_EXCHANGE_INSTRUCTION): + function = line[len(BRANCH_LINK_EXCHANGE_INSTRUCTION) : -1] + if function not in {'fp', 'ip', 'lr', 'sb', 'sl'} and not ( + function.startswith('r') and function[1:].isdigit() # rN + ): + used_functions.add(function) else: word_index = line.find(WORD_KEY) if word_index >= 0 and f'{WORD_KEY}0x' not in line: