Why does setjmp (3) not save all registers on AMD64?

I looked at the source of various implementations of setjmp and longjmp and noticed that not all processor registers are stored in the jmp_buf structure. After reviewing the AMD64 ABI, I noticed that only saved registers are saved.

I do not understand how the state of a function can be fully resumed when only some of the registers have been saved. Surely the unsaved registers had to be clogged over and over again until I called longjmp later?

Everything works fine, so I definitely don’t understand. I was hoping that someone could shed light on this.

Thanks!

+6
source share
1 answer

The setjmp function is a function like any other, and therefore it can be assumed to group any registers stored by the caller. Thus, there is no need to save or restore these registers.

+4
source

Source: https://habr.com/ru/post/919450/


All Articles