ARM Cortex-M detection (#2381)

* Fix detection of Arm Cortex-M

* lint

* order of operations

* add comment for cortex-m
pull/2388/head
OBarronCS 1 year ago committed by GitHub
parent 776f2127d4
commit d59ae31360
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -96,7 +96,13 @@ def _get_arch(ptrsize: int):
for match in ARCHS:
if match in arch:
# 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"
elif match.startswith("riscv:"):
match = match[6:]

Loading…
Cancel
Save