From 34e084b38f8fc265a77e18c9d88ea391b8a3aded Mon Sep 17 00:00:00 2001 From: Han Dai Date: Sat, 2 Mar 2024 19:45:57 -0500 Subject: [PATCH] disable auto arch detect --- src/patcherex2/targets/elf_arm_mimxrt1052.py | 4 ++++ src/patcherex2/targets/elf_leon3_bare.py | 17 +---------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/patcherex2/targets/elf_arm_mimxrt1052.py b/src/patcherex2/targets/elf_arm_mimxrt1052.py index 19bc492..1abf6c0 100644 --- a/src/patcherex2/targets/elf_arm_mimxrt1052.py +++ b/src/patcherex2/targets/elf_arm_mimxrt1052.py @@ -103,6 +103,10 @@ def finalize(self): class ElfArmMimxrt1052(ElfArmLinux): + @staticmethod + def detect_target(binary_path): + return False + def get_binfmt_tool(self, binfmt_tool): binfmt_tool = binfmt_tool or "default" if binfmt_tool == "default": diff --git a/src/patcherex2/targets/elf_leon3_bare.py b/src/patcherex2/targets/elf_leon3_bare.py index 1d626bc..7f87ea5 100644 --- a/src/patcherex2/targets/elf_leon3_bare.py +++ b/src/patcherex2/targets/elf_leon3_bare.py @@ -34,27 +34,12 @@ def _init_memory_analysis(self): unused_funcs = self.p.binary_analyzer.get_unused_funcs() for func in unused_funcs: - file_offset = self.p.binary_analyzer.mem_addr_to_file_offset(func["addr"]) - block = MappedBlock( - file_offset, - func["addr"], - func["size"], - is_free=True, - flag=MemoryFlag.RX, - ) - self.p.allocation_manager.add_block(block) + self.p.allocation_manager.add_free_space(func["addr"], func["size"], "RX") class ElfLeon3Bare(Target): @staticmethod def detect_target(binary_path): - with open(binary_path, "rb") as f: - magic = f.read(0x14) - # NOTE: probably should not default sparc to this target, but it's fine for now - if magic.startswith(b"\x7fELF") and magic.startswith( - b"\x00\x02", 0x12 - ): # EM_SPARC - return True return False def get_assembler(self, assembler):