Skip to content

Commit ef2fb96

Browse files
committed
Normalize instructions without destination register
1 parent 1802c94 commit ef2fb96

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

diff.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,6 +1795,21 @@ def is_end_of_function(self, mnemonic: str, args: str) -> bool:
17951795
return mnemonic == "blr"
17961796

17971797

1798+
ARM32_DEST_OPTIONAL = {
1799+
"add",
1800+
"sub",
1801+
"rsb",
1802+
"sbc",
1803+
"and",
1804+
"orr",
1805+
"eor",
1806+
"bic",
1807+
"asr",
1808+
"lsl",
1809+
"lsr",
1810+
"ror",
1811+
}
1812+
17981813
# Example: "cmp r0, #0x10"
17991814
ARM32_COMPARE_IMM_PATTERN = r"cmp\s+(r[0-9]|1[0-3]),\s+#(\w+)"
18001815

@@ -1904,6 +1919,18 @@ def _jump_table_entries_count(self, raw_lines: List[str], line_no: int) -> int:
19041919
return value + 1
19051920
return 0
19061921

1922+
def pre_process(
1923+
self, mnemonic: str, args: str, next_row: Optional[str], comment: Optional[str]
1924+
) -> Tuple[str, str]:
1925+
arg_parts = args.split()
1926+
# Normalize instructions that omit the destination register.
1927+
if len(arg_parts) == 2 and any(
1928+
[insn in mnemonic for insn in ARM32_DEST_OPTIONAL]
1929+
):
1930+
arg_parts.insert(1, arg_parts[0])
1931+
return mnemonic, " ".join(arg_parts)
1932+
return mnemonic, args
1933+
19071934
def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]:
19081935
arch = self.config.arch
19091936
if "R_ARM_V4BX" in row:
@@ -2634,6 +2661,7 @@ class ArchSettings:
26342661
M68K_SETTINGS,
26352662
]
26362663

2664+
26372665
def is_hexstring(value: str) -> bool:
26382666
try:
26392667
int(value, 16)

0 commit comments

Comments
 (0)