From d81c53ef91141b66c3bc6fd02269e7d4aee49d81 Mon Sep 17 00:00:00 2001 From: JanLJL Date: Wed, 22 Jun 2022 17:09:24 +0200 Subject: [PATCH] fixed #88 --- osaca/semantics/marker_utils.py | 6 +++--- tests/test_marker_utils.py | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/osaca/semantics/marker_utils.py b/osaca/semantics/marker_utils.py index 5ca09b8..62a28b0 100755 --- a/osaca/semantics/marker_utils.py +++ b/osaca/semantics/marker_utils.py @@ -35,7 +35,7 @@ def find_marked_kernel_AArch64(lines): :param list lines: kernel :returns: `tuple of int` -- start and end line of marked section """ - nop_bytes = ["213", "3", "32", "31"] + nop_bytes = [213, 3, 32, 31] return find_marked_section( lines, ParserAArch64(), @@ -55,7 +55,7 @@ def find_marked_kernel_x86ATT(lines): :param list lines: kernel :returns: `tuple of int` -- start and end line of marked section """ - nop_bytes = ["100", "103", "144"] + nop_bytes = [100, 103, 144] return find_marked_section( lines, ParserX86ATT(), @@ -186,7 +186,7 @@ def match_bytes(lines, index, byte_list): and lines[index].directive.name == "byte" ): line_count += 1 - extracted_bytes += lines[index].directive.parameters + extracted_bytes += [int(x, 0) for x in lines[index].directive.parameters] index += 1 if extracted_bytes[0 : len(byte_list)] == byte_list: return True, line_count diff --git a/tests/test_marker_utils.py b/tests/test_marker_utils.py index d843ec7..88f417a 100755 --- a/tests/test_marker_utils.py +++ b/tests/test_marker_utils.py @@ -53,6 +53,8 @@ class TestMarkerUtils(unittest.TestCase): bytes_3_lines_2 = ".byte 213\n" + ".byte 3,32\n" + ".byte 31\n" bytes_3_lines_3 = ".byte 213\n" + ".byte 3\n" + ".byte 32,31\n" bytes_4_lines = ".byte 213\n" + ".byte 3\n" + ".byte 32\n" + ".byte 31\n" + bytes_hex = ".byte 0xd5, 0x3, 0x20, 0x1f\n" + bytes_mixed = ".byte 0xd5\n.byte 3,0x20\n.byte 31\n" mov_start_1 = "mov x1, #111\n" mov_start_2 = "mov x1, 111 // should work as well\n" mov_end_1 = "mov x1, #222 // preferred way\n" @@ -80,6 +82,8 @@ class TestMarkerUtils(unittest.TestCase): bytes_3_lines_2, bytes_3_lines_3, bytes_4_lines, + bytes_hex, + bytes_mixed ] mov_start_variations = [mov_start_1, mov_start_2] mov_end_variations = [mov_end_1, mov_end_2] @@ -129,6 +133,8 @@ class TestMarkerUtils(unittest.TestCase): + ".byte 103 # IACA MARKER UTILITY\n" + ".byte 144 # IACA MARKER UTILITY\n" ) + bytes_hex_line = ".byte 0x64,0x67,0x90\n" + bytes_mixed = ".byte 0x64 # MARKER\n .byte 103,0x90 # ANOTHER MARKER\n" mov_start_1 = "movl $111, %ebx # IACA START\n" mov_start_2 = "mov $111, %ebx # IACA START\n" mov_end_1 = "movl $222, %ebx # IACA END\n" @@ -148,6 +154,8 @@ class TestMarkerUtils(unittest.TestCase): bytes_2_lines_1, bytes_2_lines_2, bytes_3_lines, + bytes_hex_line, + bytes_mixed ] mov_start_variations = [mov_start_1, mov_start_2] mov_end_variations = [mov_end_1, mov_end_2]