Skip to content

Commit 5617a2b

Browse files
committed
[aarch64] frankenmerge with dev test_gen.py, fix dc in arm64test.py
1 parent ff8a82f commit 5617a2b

File tree

2 files changed

+34
-95
lines changed

2 files changed

+34
-95
lines changed

arch/arm64/arm64test.py

Lines changed: 32 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -706,78 +706,38 @@
706706
# (b'\x52\x7E\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3F2),LLIL_REG.q(x18)])'),
707707
# # tlbi alle3 TLBI_SYS_CR_systeminstrs
708708
# (b'\x1F\x87\x0E\xD5', 'LLIL_INTRINSIC([],__tlbi,[LLIL_CONST.d(0x3438)])'),
709-
(b'\x35\x76\x08\xd5', ''),
710-
(b'\x55\x76\x08\xd5', ''),
711-
(b'\x75\x76\x08\xd5', ''),
712-
(b'\x95\x76\x08\xd5', ''),
713-
(b'\xb5\x76\x08\xd5', ''),
714-
(b'\xd5\x76\x08\xd5', ''),
715-
(b'\x35\x7a\x08\xd5', ''),
716-
(b'\x55\x7a\x08\xd5', ''),
717-
(b'\x75\x7a\x08\xd5', ''),
718-
(b'\x95\x7a\x08\xd5', ''),
719-
(b'\xb5\x7a\x08\xd5', ''),
720-
(b'\xd5\x7a\x08\xd5', ''),
721-
(b'\x35\x7e\x08\xd5', ''),
722-
(b'\x55\x7e\x08\xd5', ''),
723-
(b'\x75\x7e\x08\xd5', ''),
724-
(b'\x95\x7e\x08\xd5', ''),
725-
(b'\xb5\x7e\x08\xd5', ''),
726-
(b'\xd5\x7e\x08\xd5', ''),
727-
(b'\x35\x74\x08\xd5', ''),
728-
(b'\x55\x74\x08\xd5', ''),
729-
(b'\x75\x74\x08\xd5', ''),
730-
(b'\x95\x74\x08\xd5', ''),
731-
(b'\xb5\x74\x08\xd5', ''),
732-
(b'\xd5\x74\x08\xd5', ''),
733-
(b'\x35\x7b\x08\xd5', ''),
734-
(b'\x55\x7b\x08\xd5', ''),
735-
(b'\x75\x7b\x08\xd5', ''),
736-
(b'\x95\x7b\x08\xd5', ''),
737-
(b'\xb5\x7b\x08\xd5', ''),
738-
(b'\xd5\x7b\x08\xd5', ''),
739-
(b'\x35\x7d\x08\xd5', ''),
740-
(b'\x55\x7d\x08\xd5', ''),
741-
(b'\x75\x7d\x08\xd5', ''),
742-
(b'\x95\x7d\x08\xd5', ''),
743-
(b'\xb5\x7d\x08\xd5', ''),
744-
(b'\xd5\x7d\x08\xd5', ''),
745-
(b'\x35\x76\x0b\xd5', ''),
746-
(b'\x55\x76\x0b\xd5', ''),
747-
(b'\x75\x76\x0b\xd5', ''),
748-
(b'\x95\x76\x0b\xd5', ''),
749-
(b'\xb5\x76\x0b\xd5', ''),
750-
(b'\xd5\x76\x0b\xd5', ''),
751-
(b'\x35\x7a\x0b\xd5', ''),
752-
(b'\x55\x7a\x0b\xd5', ''),
753-
(b'\x75\x7a\x0b\xd5', ''),
754-
(b'\x95\x7a\x0b\xd5', ''),
755-
(b'\xb5\x7a\x0b\xd5', ''),
756-
(b'\xd5\x7a\x0b\xd5', ''),
757-
(b'\x35\x7e\x0b\xd5', ''),
758-
(b'\x55\x7e\x0b\xd5', ''),
759-
(b'\x75\x7e\x0b\xd5', ''),
760-
(b'\x95\x7e\x0b\xd5', ''),
761-
(b'\xb5\x7e\x0b\xd5', ''),
762-
(b'\xd5\x7e\x0b\xd5', ''),
763-
(b'\x35\x74\x0b\xd5', ''),
764-
(b'\x55\x74\x0b\xd5', ''),
765-
(b'\x75\x74\x0b\xd5', ''),
766-
(b'\x95\x74\x0b\xd5', ''),
767-
(b'\xb5\x74\x0b\xd5', ''),
768-
(b'\xd5\x74\x0b\xd5', ''),
769-
(b'\x35\x7b\x0b\xd5', ''),
770-
(b'\x55\x7b\x0b\xd5', ''),
771-
(b'\x75\x7b\x0b\xd5', ''),
772-
(b'\x95\x7b\x0b\xd5', ''),
773-
(b'\xb5\x7b\x0b\xd5', ''),
774-
(b'\xd5\x7b\x0b\xd5', ''),
775-
(b'\x35\x7d\x0b\xd5', ''),
776-
(b'\x55\x7d\x0b\xd5', ''),
777-
(b'\x75\x7d\x0b\xd5', ''),
778-
(b'\x95\x7d\x0b\xd5', ''),
779-
(b'\xb5\x7d\x0b\xd5', ''),
780-
(b'\xd5\x7d\x0b\xd5', ''),
709+
# dc cvadp, x26 DC_SYS_CR_systeminstrs
710+
(b'\x3A\x7D\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BE9),LLIL_REG.q(x26)])'),
711+
# dc zva, x24 DC_SYS_CR_systeminstrs
712+
(b'\x38\x74\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BA1),LLIL_REG.q(x24)])'),
713+
# dc zva, xzr DC_SYS_CR_systeminstrs
714+
(b'\x3F\x74\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BA1),LLIL_CONST.q(0x0)])'),
715+
# dc cisw, x18 DC_SYS_CR_systeminstrs
716+
(b'\x52\x7E\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3F2),LLIL_REG.q(x18)])'),
717+
# dc cvadp, x3 DC_SYS_CR_systeminstrs
718+
(b'\x23\x7D\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BE9),LLIL_REG.q(x3)])'),
719+
# dc csw, x21 DC_SYS_CR_systeminstrs
720+
(b'\x55\x7A\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3D2),LLIL_REG.q(x21)])'),
721+
# dc cvadp, x2 DC_SYS_CR_systeminstrs
722+
(b'\x22\x7D\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BE9),LLIL_REG.q(x2)])'),
723+
# dc cisw, x23 DC_SYS_CR_systeminstrs
724+
(b'\x57\x7E\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3F2),LLIL_REG.q(x23)])'),
725+
# dc csw, x19 DC_SYS_CR_systeminstrs
726+
(b'\x53\x7A\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3D2),LLIL_REG.q(x19)])'),
727+
# dc isw, x5 DC_SYS_CR_systeminstrs
728+
(b'\x45\x76\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3B2),LLIL_REG.q(x5)])'),
729+
# dc civac, x24 DC_SYS_CR_systeminstrs
730+
(b'\x38\x7E\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BF1),LLIL_REG.q(x24)])'),
731+
# dc cvau, x4 DC_SYS_CR_systeminstrs
732+
(b'\x24\x7B\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BD9),LLIL_REG.q(x4)])'),
733+
# dc csw, x14 DC_SYS_CR_systeminstrs
734+
(b'\x4E\x7A\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3D2),LLIL_REG.q(x14)])'),
735+
# dc csw, x5 DC_SYS_CR_systeminstrs
736+
(b'\x45\x7A\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3D2),LLIL_REG.q(x5)])'),
737+
# dc isw, x3 DC_SYS_CR_systeminstrs
738+
(b'\x43\x76\x08\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x3B2),LLIL_REG.q(x3)])'),
739+
# dc cvac, x14 DC_SYS_CR_systeminstrs
740+
(b'\x2E\x7A\x0B\xD5', 'LLIL_INTRINSIC([],__dc,[LLIL_CONST.d(0x1BD1),LLIL_REG.q(x14)])'),
781741
]
782742

783743
# tests_uxtl_uxtl2 = [

arch/arm64/test_gen.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
# TODO: proper command line argument parsing, and help
55

66
import re, sys, codecs
7-
import binaryninja
87

98
N_SAMPLES = 4 # number of samples for each encoding
109

1110
from arm64test import lift, ATTR_PTR_AUTH, path_il_h
12-
from disassembler import disasm_test
1311

1412
if not sys.argv[1:]:
1513
sys.exit(-1)
@@ -153,14 +151,14 @@ def gather_samples(mnems, encodings):
153151
if sys.argv[1] == "mnemonic":
154152
mnems = sys.argv[2:]
155153
for mnem in mnems:
156-
print("searching for mnemonic -%s-" % mnem)
154+
print("searching for mnemonic -%s-" % mnem, file=sys.stderr)
157155
gather_samples([mnem], [])
158156

159157
# exact match (ignoring case) for encodings
160158
elif sys.argv[1] == "encoding":
161159
encnames = sys.argv[2:]
162160
for encname in encnames:
163-
print("searching for encoding -%s-" % encname)
161+
print("searching for encoding -%s-" % encname, file=sys.stderr)
164162
gather_samples([], [encname])
165163

166164
elif sys.argv[1] == "mte":
@@ -231,25 +229,6 @@ def gather_samples(mnems, encodings):
231229
comment = m.group(1)
232230

233231
data = codecs.decode(b0 + b1 + b2 + b3, "hex_codec")
234-
new_asm = disassemble(0, data)
235-
if new_asm:
236-
new_asm = ' '.join(new_asm.split())
237-
test_comment = comment and ' '.join(comment.split())
238-
header_line = None
239-
if i - 1 and lines[i - 1].strip():
240-
header_line = ' '.join(lines[i - 1].strip().split())
241-
header_line = re.sub(r'^# ([0-9a-fA-F]{8} ?)?', '', header_line)
242-
# print(f'{header_line=}')
243-
if not header_line or not header_line.startswith(new_asm):
244-
if test_comment and not test_comment.strip().startswith(new_asm):
245-
if comment.strip():
246-
comment += ' // ' + new_asm
247-
if not comment or not comment.strip():
248-
comment = new_asm
249-
# if i - 1 and lines[i - 1] and not lines[i - 1].strip().startswith('# ' + new_asm):
250-
# print(f'\n # {new_asm}')
251-
else:
252-
comment = (comment or '') + f" no disasm for {data.hex()}"
253232
print_case(data, comment)
254233

255234
i += 1

0 commit comments

Comments
 (0)