|
|
|
@ -96,7 +96,13 @@ def _get_arch(ptrsize: int):
|
|
|
|
for match in ARCHS:
|
|
|
|
for match in ARCHS:
|
|
|
|
if match in arch:
|
|
|
|
if match in arch:
|
|
|
|
# Distinguish between Cortex-M and other ARM
|
|
|
|
# Distinguish between Cortex-M and other ARM
|
|
|
|
if match == "arm" and "-m" in arch:
|
|
|
|
# When GDB detects correctly Cortex-M processes, it will label them with `arm*-m`, such as armv7e-m
|
|
|
|
|
|
|
|
# However, GDB will sometimes fail to correctly label Cortex-M binaries properly, and says it's simply 'arm'.
|
|
|
|
|
|
|
|
# Internally, GDB still detects the processes as Cortex-M, as it can access .xpsr, but it doesn't
|
|
|
|
|
|
|
|
# appear to expose this in information through any command/API. Since Cortex-M has the .xpsr flags register
|
|
|
|
|
|
|
|
# instead of .cpsr, we will check if it's present.
|
|
|
|
|
|
|
|
# See: https://github.com/pwndbg/pwndbg/issues/2153
|
|
|
|
|
|
|
|
if match == "arm" and ("-m" in arch or pwndbg.gdblib.regs.xpsr is not None):
|
|
|
|
match = "armcm"
|
|
|
|
match = "armcm"
|
|
|
|
elif match.startswith("riscv:"):
|
|
|
|
elif match.startswith("riscv:"):
|
|
|
|
match = match[6:]
|
|
|
|
match = match[6:]
|
|
|
|
|