1

enter image description here enter image description here enter image description here enter image description here enter image description here

enter image description here this is example is from dwarf document. How Can I caculate provious sp(r7) pointer,I mean It didnot save sp somewhere since sp is a callee-save register.

The architectural ABI committee specifies that the stack pointer (R7) is the
same as the CFA

what this means? is this means "r7=cfa" , how come this is help to compute previous sp , and call a function may change sp.

In this example is that r8 is virtual? looks is a virtual.

dwarf pdf.

https://dwarfstd.org/doc/DWARF5.pdf page 325

radong
  • 29
  • 2
  • Generally speaking, you're looking to find out `fsize`, no? – Erik Eidt Aug 04 '22 at 11:56
  • 1
    It must restore `sp` for the caller but that doesn't mean it has to save it to memory, since it can be recomputed. – Erik Eidt Aug 04 '22 at 12:00
  • Nevertheless I find it puzzling why the `R7` column is filled with `s` (same value) all the way when clearly `R7` is changed twice. Also the comment saying `Start epilogue (R7 has been returned to entry value)` is obviously wrong, `R7` is only being restored later at the `add R7, R7, ` – Jester Aug 04 '22 at 12:21
  • yes,sp can be recomputed be compiler , But How debugger compute sp value base on dwarf info? – radong Aug 04 '22 at 23:03
  • sp value can change when executing (call other functions will save caller-save registers and push extra argument on stack ). If I want to do backtracing means I want to restore sp in middle of executing . – radong Aug 05 '22 at 00:49
  • Can you at least link the DWARF doc you're showing images of? Pictures of text aren't good in Stack Overflow questions, but I realize it would be a lot of work to format the tables and code as markdown in a quote block. – Peter Cordes Aug 05 '22 at 02:57
  • Note that DWARF stack unwinding works by using separate metadata in the `.eh_frame` section of the ELF executable or shared library. Not purely the architectural state; without separate metadata (to look up based on the current program counter), you need functions to always make frame pointers. – Peter Cordes Aug 05 '22 at 02:58
  • I just want to know the previous sp pointer at a executing point. I certainly can get this value just look at the table. – radong Aug 05 '22 at 05:40
  • I think I cannot get information about this topic from elf. – radong Aug 05 '22 at 05:49

0 Answers0