In thumb mode, how to enable frame-pointer

Asked by fei chen

Dear,

I want to implement a call stack dump feature on cortex-m4 using frame poiner.
I use the following the command to do an experiment.
arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -c -fno-omit-frame-pointer test2.c -o test2.o

I disassemble test2.o as following. r7, which should be the frame-pointer, does not point to the stack frame. In stead, the value is same as sp. It is very appreciated of any suggestion.
00000000 <func1>:
   0: b480 push {r7}
   2: b097 sub sp, #92 ; 0x5c
   4: af00 add r7, sp, #0
   6: f04f 0300 mov.w r3, #0
   a: 657b str r3, [r7, #84] ; 0x54
   c: e00e b.n 2c <func1+0x2c>
   e: 6d7b ldr r3, [r7, #84] ; 0x54
  10: f103 0201 add.w r2, r3, #1
  14: 6d7b ldr r3, [r7, #84] ; 0x54
  16: ea4f 0383 mov.w r3, r3, lsl #2
  1a: f107 0158 add.w r1, r7, #88 ; 0x58
  1e: 18cb adds r3, r1, r3
  20: f843 2c54 str.w r2, [r3, #-84]
  24: 6d7b ldr r3, [r7, #84] ; 0x54
  26: f103 0301 add.w r3, r3, #1
  2a: 657b str r3, [r7, #84] ; 0x54
  2c: 6d7b ldr r3, [r7, #84] ; 0x54
  2e: 2b09 cmp r3, #9
  30: dded ble.n e <func1+0xe>
  32: f04f 0300 mov.w r3, #0
  36: 4618 mov r0, r3
  38: f107 075c add.w r7, r7, #92 ; 0x5c
  3c: 46bd mov sp, r7
  3e: bc80 pop {r7}
  40: 4770 bx lr
  42: bf00 nop

00000044 <func2>:
  44: b580 push {r7, lr}
  46: b0aa sub sp, #168 ; 0xa8
  48: af00 add r7, sp, #0
  4a: f107 0204 add.w r2, r7, #4
  4e: f04f 0350 mov.w r3, #80 ; 0x50
  52: 4610 mov r0, r2
  54: f04f 0100 mov.w r1, #0
  58: 461a mov r2, r3
  5a: f7ff fffe bl 0 <memset>
  5e: f04f 0300 mov.w r3, #0
  62: f8c7 30a4 str.w r3, [r7, #164] ; 0xa4
  66: e01f b.n a8 <func2+0x64>
  68: f8d7 30a4 ldr.w r3, [r7, #164] ; 0xa4
  6c: f103 030a add.w r3, r3, #10
  70: ea4f 0383 mov.w r3, r3, lsl #2
  74: f107 01a8 add.w r1, r7, #168 ; 0xa8
  78: 18cb adds r3, r1, r3
  7a: f853 3ca4 ldr.w r3, [r3, #-164]
  7e: f8d7 20a4 ldr.w r2, [r7, #164] ; 0xa4
  82: fb02 f203 mul.w r2, r2, r3
  86: f8d7 30a4 ldr.w r3, [r7, #164] ; 0xa4
  8a: f103 030a add.w r3, r3, #10
  8e: ea4f 0383 mov.w r3, r3, lsl #2
  92: f107 01a8 add.w r1, r7, #168 ; 0xa8
  96: 18cb adds r3, r1, r3
  98: f843 2c54 str.w r2, [r3, #-84]
  9c: f8d7 30a4 ldr.w r3, [r7, #164] ; 0xa4
  a0: f103 0301 add.w r3, r3, #1
  a4: f8c7 30a4 str.w r3, [r7, #164] ; 0xa4
  a8: f8d7 30a4 ldr.w r3, [r7, #164] ; 0xa4
  ac: 2b09 cmp r3, #9
  ae: dddb ble.n 68 <func2+0x24>
  b0: f7ff fffe bl 0 <func1>
  b4: f04f 0300 mov.w r3, #0
  b8: 4618 mov r0, r3
  ba: f107 07a8 add.w r7, r7, #168 ; 0xa8
  be: 46bd mov sp, r7
  c0: bd80 pop {r7, pc}
  c2: bf00 nop

Question information

Language:
English Edit question
Status:
Expired
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.