[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 16 11:40:06 PST 2019


clayborg added a comment.

As I am reading this, I just wanted to send out a note of something else that can cause crashes in ARM/Thumb code. For anyone working with ARM/Thumb on systems that don't use the ARM and Thumb BKPT instruction when setting software breakpoints (like all lldb linux and android flavors IIRC): if you try to overwrite a 32 bit thumb instruction that is a conditional instruction in a Thumb IT instruction with a 16 bit trap or illegal instruction you can crash your program. The issue arises for code like:

  0x1000: xx xx         ITTTEE
  0x1002: 00 11 22 33   32 bit thumb instruction (if condition)
  0x1006: 44 55 66 77   32 bit thumb instruction (if condition)
  0x100a: 88 99 aa bb   32 bit thumb instruction (else condition) 
  0x100e: cc dd ee ff   32 bit thumb instruction (else condition)

If you try to set a breakpoint at any of the instructions in [0x1002-0x100e) using a 16 bit trap or illegal instruction (I use "bb bb" below for this trap for example purposes), you change the size of the instructions and which instructions are conditional. If we try to write "bb bb" to 0x1002 we now have:

  0x1000: xx xx         ITTTEE
  0x1002: bb bb         (if condition) the first conditional instruction is now 16 bit instead of 32 bit
  0x1004: 22 33 44 55   (if condition) this has the last half of the previous instruction 
  0x1008: 66 77 88 99   (else condition) this has the last half of the previous instruction 
  0x100c: aa bb         (else condition) this has the last half of the previous instruction 
  0x100e: cc dd ee ff   32 bit thumb instruction (NOT conditional anymore)

This will work if using the BKPT instruction only. Sorry for the noise if lldb-server is already using the BKPT instruction. But I just wanted to throw this out there in case this issue if affecting anyone.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71498/new/

https://reviews.llvm.org/D71498





More information about the lldb-commits mailing list