Why does getcontext and setjmp save different registers in glibc-x86-64

515 views Asked by At

Here are their source codes: https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/unix/sysv/linux/x86_64/getcontext.S;hb=HEAD https://sourceware.org/git/?p=glibc.git;a=blob_plain;f=sysdeps/x86_64/setjmp.S;hb=HEAD

As you can see, getcontext also saves floating point context and registers r8 and r9 which setjmp does not. What is the reason for this?

1

There are 1 answers

3
tohava On BEST ANSWER

It seems like both routines are wrong. Setjmp should not ignore floating point state and getcontext should not save r8,r9.

Reference:

http://www.boost.org/doc/libs/1_57_0/libs/context/doc/html/context/rationale/x86_and_floating_point_env.html