From 7802ff10869e1e48aed5c009e53b9023f66bbe09 Mon Sep 17 00:00:00 2001 From: Gillou68310 Date: Mon, 10 Feb 2025 09:54:53 +0100 Subject: [PATCH] Optional 0x prefix --- diff.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/diff.py b/diff.py index ae24ce0..9e34a7a 100755 --- a/diff.py +++ b/diff.py @@ -2080,14 +2080,14 @@ def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]: # Example movb $0x0,0x0(%si) if not addr_imm: - addr_imm = re.search(r"(?<=,)0x0+(?=\(.*\))", args) + addr_imm = re.search(r"(?<=,)(?:0x)?0+(?=\(.*\))", args) # Example 0x0,0x8(%edi) # Example 0x0,%edi # Example *0x0(,%edx,4) # Example $0x0,0x4(%edi) if not addr_imm: - addr_imm = re.search(r"(^\$?|(?<=\*))0x0", args) + addr_imm = re.search(r"(^\$?|(?<=\*))(?:0x)?0", args) # Offset value @@ -2099,17 +2099,19 @@ def process_reloc(self, row: str, prev: str) -> Tuple[str, Optional[str]]: # Example movb $0x0,0x4(%si) if not addr_imm: - addr_imm = re.search(r"(?<=,)0x[0-9a-f]+", args) + addr_imm = re.search(r"(?<=,)(?:0x)?[0-9a-f]+", args) offset = True # Example 0x4,%eax # Example $0x4,%eax if not addr_imm: - addr_imm = re.search(r"(^|(?<=\*)|(?:\$))0x[0-9a-f]+", args) + addr_imm = re.search(r"(^|(?<=\*)|(?:\$))(?:0x)?[0-9a-f]+", args) offset = True if not addr_imm: - addr_imm = re.search(r"(^|(?<=\*)|(?<=\%[fgdecs]s\:))0x[0-9a-f]+", args) + addr_imm = re.search( + r"(^|(?<=\*)|(?<=\%[fgdecs]s\:))(?:0x)?[0-9a-f]+", args + ) offset = True if not addr_imm: