Skip to content

Commit 8bb09e2

Browse files
committed
Auto merge of #1202 - acfoltzer:greg-offsets, r=alexcrichton
glibc x86: add the register offset constants for mcontext_t.gregs Constants calculated from the [glibc source](https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/x86/sys/ucontext.h;h=3d883c2bf1220ef50cedc6b1491d699c0727c508;hb=HEAD). These are needed when using `mcontext_t`. Thanks!
2 parents 86a091c + 696b8b7 commit 8bb09e2

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/unix/notbsd/linux/other/b32/x86.rs

+21
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,27 @@ pub const EFL: ::c_int = 14;
758758
pub const UESP: ::c_int = 15;
759759
pub const SS: ::c_int = 16;
760760

761+
// offsets in mcontext_t.gregs from sys/ucontext.h
762+
pub const REG_GS: ::c_int = 0;
763+
pub const REG_FS: ::c_int = 1;
764+
pub const REG_ES: ::c_int = 2;
765+
pub const REG_DS: ::c_int = 3;
766+
pub const REG_EDI: ::c_int = 4;
767+
pub const REG_ESI: ::c_int = 5;
768+
pub const REG_EBP: ::c_int = 6;
769+
pub const REG_ESP: ::c_int = 7;
770+
pub const REG_EBX: ::c_int = 8;
771+
pub const REG_EDX: ::c_int = 9;
772+
pub const REG_ECX: ::c_int = 10;
773+
pub const REG_EAX: ::c_int = 11;
774+
pub const REG_TRAPNO: ::c_int = 12;
775+
pub const REG_ERR: ::c_int = 13;
776+
pub const REG_EIP: ::c_int = 14;
777+
pub const REG_CS: ::c_int = 15;
778+
pub const REG_EFL: ::c_int = 16;
779+
pub const REG_UESP: ::c_int = 17;
780+
pub const REG_SS: ::c_int = 18;
781+
761782
extern {
762783
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
763784
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;

src/unix/notbsd/linux/other/b64/x86_64.rs

+25
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,31 @@ pub const ES: ::c_int = 24;
644644
pub const FS: ::c_int = 25;
645645
pub const GS: ::c_int = 26;
646646

647+
// offsets in mcontext_t.gregs from sys/ucontext.h
648+
pub const REG_R8: ::c_int = 0;
649+
pub const REG_R9: ::c_int = 1;
650+
pub const REG_R10: ::c_int = 2;
651+
pub const REG_R11: ::c_int = 3;
652+
pub const REG_R12: ::c_int = 4;
653+
pub const REG_R13: ::c_int = 5;
654+
pub const REG_R14: ::c_int = 6;
655+
pub const REG_R15: ::c_int = 7;
656+
pub const REG_RDI: ::c_int = 8;
657+
pub const REG_RSI: ::c_int = 9;
658+
pub const REG_RBP: ::c_int = 10;
659+
pub const REG_RBX: ::c_int = 11;
660+
pub const REG_RDX: ::c_int = 12;
661+
pub const REG_RAX: ::c_int = 13;
662+
pub const REG_RCX: ::c_int = 14;
663+
pub const REG_RSP: ::c_int = 15;
664+
pub const REG_RIP: ::c_int = 16;
665+
pub const REG_EFL: ::c_int = 17;
666+
pub const REG_CSGSFS: ::c_int = 18;
667+
pub const REG_ERR: ::c_int = 19;
668+
pub const REG_TRAPNO: ::c_int = 20;
669+
pub const REG_OLDMASK: ::c_int = 21;
670+
pub const REG_CR2: ::c_int = 22;
671+
647672
extern {
648673
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
649674
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;

0 commit comments

Comments
 (0)