0

I have a piece of code that performs unwind in x86_64, I am trying to step forward in c code like this:

frame->rsp = frame->rbp+2;
frame->rip = *(frame->rbp+1);
frame->rbp = *frame->rbp;

However, I don't know if this is correct in the situation of aarch64. I found aarch64 have x29(fp), x30(lr), and SP. Are they same to bp, ip and sp? Thanks a lot!!

shenmufeng
  • 67
  • 1
  • 7
  • ARM's "ip" isn't the instruction pointer. For that you want PC, the program counter. Also no, LR (the link register) is not the frame pointer (rBP), it's the return address (which x86-64 keeps on the stack.) – Peter Cordes Jul 12 '23 at 13:23
  • thank, I want to perform step forward(aka: up unwinding) just like what we do in x86_64, but I can't figure out how. Could you please help further? Thanks a lot!! – shenmufeng Aug 03 '23 at 07:34
  • Just like on x86-64, debuggers should know how to read the metadata (e.g. from the `.eh_frame` DWARF metadata in ELF executables) that tells it how to unwind the stack in normal builds (`-fomit-frame-pointer` is on at `-O1` and higher in GCC). `frame 1` vs. `frame 0` should work in GDB. And other commands like `bt full`. – Peter Cordes Aug 03 '23 at 07:43

0 Answers0