ARM: Do not use FP reg when on AAPCS

Message ID b2ceb6fd-5df8-4d91-d2e9-1aea26047480@eurecom.fr
State New, archived
Headers

Commit Message

Marius Muench Oct. 23, 2018, 1:03 p.m. UTC
  Hi all,

GDB tries to dereference the frame pointer in arm_scan_prologue as a
last resort to create frame information.
However, the more recent AAPCS ABI does not make use of a frame pointer.

This patch checks whether the specified arm_abi is AAPCS before
dereferencing the "frame pointer". If so, just return as efforts to use
it for restoring frame information won't work.

Cheers,
Marius

gdb/ChangeLog
2018-10-23  Marius Muench  <marius.muench@eurecom.fr>

       * arm-tdeb.c (arm_scan_prologue): Don't dereference FP reg
       when on aapcs.
---
 gdb/arm-tdep.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Kevin Buettner Oct. 23, 2018, 5:16 p.m. UTC | #1
On Tue, 23 Oct 2018 15:03:39 +0200
Marius Muench <munch@eurecom.fr> wrote:

> Hi all,
> 
> GDB tries to dereference the frame pointer in arm_scan_prologue as a
> last resort to create frame information.
> However, the more recent AAPCS ABI does not make use of a frame pointer.
> 
> This patch checks whether the specified arm_abi is AAPCS before
> dereferencing the "frame pointer". If so, just return as efforts to use
> it for restoring frame information won't work.
> 
> Cheers,
> Marius
> 
> gdb/ChangeLog
> 2018-10-23  Marius Muench  <marius.muench@eurecom.fr>
> 
>        * arm-tdeb.c (arm_scan_prologue): Don't dereference FP reg
>        when on aapcs.

Typo on filename above.  (s/tdeb/tdep/)  While you're changing it,
please capitalize AAPCS too.

Otherwise, okay.

Kevin
  

Patch

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 53eee76926..859ce71d6a 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -1801,6 +1801,10 @@  arm_scan_prologue (struct frame_info *this_frame,
       CORE_ADDR frame_loc;
       ULONGEST return_value;

+      /* AAPCS does not use a frame register, so we can abort here. */
+      if (gdbarch_tdep (gdbarch)->arm_abi == ARM_ABI_AAPCS)
+          return;
+
       frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM);
       if (!safe_read_memory_unsigned_integer (frame_loc, 4, byte_order,
                                              &return_value))