diff --git a/pwndbg/aglib/disasm/aarch64.py b/pwndbg/aglib/disasm/aarch64.py index 8248a5b90..04d373c3b 100644 --- a/pwndbg/aglib/disasm/aarch64.py +++ b/pwndbg/aglib/disasm/aarch64.py @@ -281,7 +281,7 @@ class DisassemblyAssistant(pwndbg.aglib.disasm.arch.DisassemblyAssistant): def _handle_adrp(self, instruction: PwndbgInstruction, emu: Emulator) -> None: result_operand, right = instruction.operands if result_operand.str and right.before_value is not None: - address = right.before_value + address = right.before_value & pwndbg.aglib.arch.ptrmask TELESCOPE_DEPTH = max(0, int(pwndbg.config.disasm_telescope_depth)) @@ -348,7 +348,9 @@ class DisassemblyAssistant(pwndbg.aglib.disasm.arch.DisassemblyAssistant): if len(instruction.operands) > 0: # For all AArch64 branches, the target is either an immediate or a register and is the last operand - return instruction.operands[-1].before_value + if (val := instruction.operands[-1].before_value) is not None: + return val & pwndbg.aglib.arch.ptrmask + return None elif instruction.id == ARM64_INS_RET: # If this is a ret WITHOUT an operand, it means we should read from the LR/x30 register return super()._read_register_name(instruction, "lr", emu) diff --git a/pwndbg/aglib/disasm/arch.py b/pwndbg/aglib/disasm/arch.py index 2d35d571f..aebd3dae2 100644 --- a/pwndbg/aglib/disasm/arch.py +++ b/pwndbg/aglib/disasm/arch.py @@ -691,7 +691,7 @@ class DisassemblyAssistant: if instruction.target is None: instruction.target = instruction.next - if instruction.has_jump_target: + if instruction.has_jump_target and instruction.target >= 0: # Only bother doing the symbol lookup if this is a jump instruction.target_string = MemoryColor.get_address_or_symbol(instruction.target) diff --git a/pwndbg/emu/emulator.py b/pwndbg/emu/emulator.py index 52a63ed70..d981c8e5a 100644 --- a/pwndbg/emu/emulator.py +++ b/pwndbg/emu/emulator.py @@ -190,6 +190,7 @@ BANNED_INSTRUCTIONS = { "mips": {C.mips.MIPS_INS_RDHWR}, "arm": ARM_BANNED_INSTRUCTIONS, "armcm": ARM_BANNED_INSTRUCTIONS, + "aarch64": {C.arm64.ARM64_INS_MRS}, } # https://github.com/unicorn-engine/unicorn/issues/550