1

I am inspecting a process (which has no bugs actually) with gdb.

However I noticed, when doing info registers, that RSP is higher than RBP, which is not consistent with the fact that the stack grows downwards. Is this perhaps some optimization by the compiler?

rbp            0x7fabaf9ba290      0x7fabaf9ba290
rsp            0x7ffdf1ffa1b0      0x7ffdf1ffa1b0
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Aaa Bbb
  • 627
  • 4
  • 12

1 Answers1

3

There's no requirement that rbp be used as a frame pointer. When -fomit-frame-pointer is active, as is the default in optimized programs, it's just used the same as any other call-saved register (e.g., rbx).

  • You're probably right since the process was actually Apache2 which should be optimized, though I can't understnd its makefiles to confirm. – Aaa Bbb Nov 28 '21 at 19:42
  • 1
    @AaaBbb: If the functions don't all start with `push rbp` / `mov rbp, rsp`, and aren't full of loads/stores to keep every variable in memory at locations like `[rbp - 16]`, then it's not a debug build. The difference in asm is very obvious in most code. [Why does clang produce inefficient asm with -O0 (for this simple floating point sum)?](https://stackoverflow.com/q/53366394) / [How to remove "noise" from GCC/clang assembly output?](https://stackoverflow.com/q/38552116) – Peter Cordes Nov 28 '21 at 21:44
  • @PeterCordes thanks, indeed the prologue is non conventional, at some oint it moves rdi in rbp and seems to use rbp as a "normal" register. – Aaa Bbb Nov 28 '21 at 23:29