From fbcd9df1cf002b9e4c07b0d793a102c2bbde69ad Mon Sep 17 00:00:00 2001 From: Daniel McKenna Date: Tue, 23 May 2017 17:18:55 +0100 Subject: [PATCH 1/5] Added missing linux/user.h structures. Added equivalents for user_regs_struct and user_struct from linux/user.h for x86 and x86_64. --- src/unix/notbsd/linux/other/b32/x86.rs | 38 ++++++++++++++++++ src/unix/notbsd/linux/other/b64/x86_64.rs | 48 +++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 263e1406b7d41..2b2d16560caec 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -19,6 +19,44 @@ s! { pub _st: [_libc_fpreg; 8], pub status: ::c_ulong, } + + pub struct _libc_state { + pub ebx: ::c_long, + pub ecx: ::c_long, + pub edx: ::c_long, + pub esi: ::c_long, + pub edi: ::c_long, + pub ebp: ::c_long, + pub eax: ::c_long, + pub xds: ::c_long, + pub xes: ::c_long, + pub xfs: ::c_long, + pub xgs: ::c_long, + pub orig_eax: ::c_long, + pub eip: ::c_long, + pub xcs: ::c_long, + pub eflags: u32, + pub esp: ::c_long, + pub xss: ::c_long, + } + + pub struct _libc_user { + pub regs: _libc_state, + pub u_fpvalid: i32, + pub i387: _libc_fpstate, + pub u_tsize: u32, + pub u_dsize: u32, + pub u_ssize: u32, + pub start_code: u32, + pub start_stack: u32, + pub signal: i32, + __reserved: i32, + pub u_ar0: *mut _libc_state, + pub u_fpstate: *mut _libc_fpstate, + pub magic: u32, + pub u_comm: [c_char; 32], + pub u_debugreg: [i32; 8], + } pub struct mcontext_t { pub gregs: [greg_t; 19], diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index b39ccb3916bee..7d2766da4ac85 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -78,6 +78,54 @@ s! { __private: [u64; 12], } + pub struct _libc_state { + pub r15: u64, + pub r14: u64, + pub r13: u64, + pub r12: u64, + pub rbp: u64, + pub rbx: u64, + pub r11: u64, + pub r10: u64, + pub r9: u64, + pub r8: u64, + pub rax: u64, + pub rcx: u64, + pub rdx: u64, + pub rsi: u64, + pub rdi: u64, + pub orig_rax: u64, + pub rip: u64, + pub cs: u64, + pub eflags: u64, + pub rsp: u64, + pub ss: u64, + pub fs_base: u64, + pub gs_base: u64, + pub ds: u64, + pub es: u64, + pub fs: u64, + pub gs: u64, + } + + pub struct _libc_user { + pub regs: _libc_state, + pub u_fpvalid: ::c_int, + pub i387: _libc_fpstate, + pub u_tsize: u64, + pub u_dsize: u64, + pub u_ssize: u64, + pub start_code: u64, + pub start_stack: u64, + pub signal: i64, + __reserved: ::c_int, + pub u_ar0: *mut _libc_state, + pub u_fpstate: *mut _libc_fpstate, + pub magic: u64, + pub u_comm: [::c_char; 32], + pub u_debugreg: [u64; 8], + } + pub struct mcontext_t { pub gregs: [greg_t; 23], pub fpregs: *mut _libc_fpstate, From 9766d50f4ac8cff0bfdbed1233d6212ef4749bd6 Mon Sep 17 00:00:00 2001 From: Daniel McKenna Date: Tue, 23 May 2017 17:23:10 +0100 Subject: [PATCH 2/5] Updated cargo.lock and toml for release. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 19d2108b73555..fb2d6a78f3bf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "libc-test" version = "0.1.0" dependencies = [ "ctest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.23", + "libc 0.2.24", ] [[package]] @@ -48,7 +48,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.23" +version = "0.2.24" [[package]] name = "log" diff --git a/Cargo.toml b/Cargo.toml index 3914fd6aa8008..ecebaed935bbf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libc" -version = "0.2.23" +version = "0.2.24" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" From ca117fee875205162e9ba9fe2023c8595d6ec4ea Mon Sep 17 00:00:00 2001 From: Daniel McKenna Date: Wed, 24 May 2017 17:25:03 +0100 Subject: [PATCH 3/5] Fixed style issues and reverted version number. Fixed trailing whitespace in x86.rs and reverted the minor version number in the Cargo.toml --- Cargo.toml | 2 +- src/unix/notbsd/linux/other/b32/x86.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ecebaed935bbf..3914fd6aa8008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libc" -version = "0.2.24" +version = "0.2.23" authors = ["The Rust Project Developers"] license = "MIT/Apache-2.0" readme = "README.md" diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index 2b2d16560caec..c8cc5cc3239ae 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -19,7 +19,7 @@ s! { pub _st: [_libc_fpreg; 8], pub status: ::c_ulong, } - + pub struct _libc_state { pub ebx: ::c_long, pub ecx: ::c_long, From 3522d8b529fcb1b8b8c2c898822357885623590b Mon Sep 17 00:00:00 2001 From: Daniel McKenna Date: Wed, 24 May 2017 18:33:18 +0100 Subject: [PATCH 4/5] Updated cargo.lock Forgot to update cargo.lock before prior commit. --- Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb2d6a78f3bf5..da8cdf8cb7869 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "libc-test" version = "0.1.0" dependencies = [ "ctest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.24", + "libc 0.2.23", ] [[package]] @@ -48,11 +48,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.24" +version = "0.2.23" [[package]] name = "log" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -67,7 +67,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-xid 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -103,7 +103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum gcc 0.3.46 (registry+https://github.com/rust-lang/crates.io-index)" = "181e3cebba1d663bd92eb90e2da787e10597e027eb00de8d742b260a7850948f" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "e32a70cf75e5846d53a673923498228bbec6a8624708a9ea5645f075d6276122" -"checksum log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "5141eca02775a762cc6cd564d8d2c50f67c0ea3a372cbf1c51592b3e029e10ad" +"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum syntex_syntax 0.19.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8739e1a8b53efe7349917259f8ced15f797c89bf788a86e44f61addc0d1ecf68" "checksum term 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "f2077e54d38055cf1ca0fd7933a2e00cd3ec8f6fed352b2a377f06dcdaaf3281" From 6acbf873dbc9fe3d3cd751bd58b26d742eaf994b Mon Sep 17 00:00:00 2001 From: Daniel McKenna Date: Mon, 29 May 2017 18:27:27 +0100 Subject: [PATCH 5/5] Fixed issues in test and struct names. Fixed the issues that prevented the libc_tests that are generated from passing. Also, fixed struct names and types to be representative of the linux source files. --- libc-test/build.rs | 1 + src/unix/notbsd/linux/other/b32/x86.rs | 61 ++++++++++---- src/unix/notbsd/linux/other/b64/x86_64.rs | 96 +++++++++++++---------- 3 files changed, 100 insertions(+), 58 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 6506d8d41a0ed..d2268732abce1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -175,6 +175,7 @@ fn main() { cfg.header("sys/ipc.h"); cfg.header("sys/msg.h"); cfg.header("sys/shm.h"); + cfg.header("sys/user.h"); cfg.header("sys/fsuid.h"); cfg.header("pty.h"); cfg.header("shadow.h"); diff --git a/src/unix/notbsd/linux/other/b32/x86.rs b/src/unix/notbsd/linux/other/b32/x86.rs index c8cc5cc3239ae..04a3caad12ac1 100644 --- a/src/unix/notbsd/linux/other/b32/x86.rs +++ b/src/unix/notbsd/linux/other/b32/x86.rs @@ -20,7 +20,34 @@ s! { pub status: ::c_ulong, } - pub struct _libc_state { + pub struct user_fpregs_struct { + pub cwd: ::c_long, + pub swd: ::c_long, + pub twd: ::c_long, + pub fip: ::c_long, + pub fcs: ::c_long, + pub foo: ::c_long, + pub fos: ::c_long, + pub st_space: [::c_long; 20], + } + + pub struct user_fpxregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub twd: ::c_ushort, + pub fop: ::c_ushort, + pub fip: ::c_long, + pub fcs: ::c_long, + pub foo: ::c_long, + pub fos: ::c_long, + pub mxcsr: ::c_long, + __reserved: ::c_long, + pub st_space: [::c_long; 32], + pub xmm_space: [::c_long; 32], + padding: [::c_long; 56], + } + + pub struct user_regs_struct { pub ebx: ::c_long, pub ecx: ::c_long, pub edx: ::c_long, @@ -35,27 +62,27 @@ s! { pub orig_eax: ::c_long, pub eip: ::c_long, pub xcs: ::c_long, - pub eflags: u32, + pub eflags: ::c_long, pub esp: ::c_long, pub xss: ::c_long, } - pub struct _libc_user { - pub regs: _libc_state, - pub u_fpvalid: i32, - pub i387: _libc_fpstate, - pub u_tsize: u32, - pub u_dsize: u32, - pub u_ssize: u32, - pub start_code: u32, - pub start_stack: u32, - pub signal: i32, - __reserved: i32, - pub u_ar0: *mut _libc_state, - pub u_fpstate: *mut _libc_fpstate, - pub magic: u32, + pub struct user { + pub regs: user_regs_struct, + pub u_fpvalid: ::c_int, + pub i387: user_fpregs_struct, + pub u_tsize: ::c_ulong, + pub u_dsize: ::c_ulong, + pub u_ssize: ::c_ulong, + pub start_code: ::c_ulong, + pub start_stack: ::c_ulong, + pub signal: ::c_long, + __reserved: ::c_int, + pub u_ar0: *mut user_regs_struct, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: ::c_ulong, pub u_comm: [c_char; 32], - pub u_debugreg: [i32; 8], + pub u_debugreg: [::c_int; 8], } pub struct mcontext_t { diff --git a/src/unix/notbsd/linux/other/b64/x86_64.rs b/src/unix/notbsd/linux/other/b64/x86_64.rs index 7d2766da4ac85..ac72359980ad7 100644 --- a/src/unix/notbsd/linux/other/b64/x86_64.rs +++ b/src/unix/notbsd/linux/other/b64/x86_64.rs @@ -78,52 +78,66 @@ s! { __private: [u64; 12], } - pub struct _libc_state { - pub r15: u64, - pub r14: u64, - pub r13: u64, - pub r12: u64, - pub rbp: u64, - pub rbx: u64, - pub r11: u64, - pub r10: u64, - pub r9: u64, - pub r8: u64, - pub rax: u64, - pub rcx: u64, - pub rdx: u64, - pub rsi: u64, - pub rdi: u64, - pub orig_rax: u64, - pub rip: u64, - pub cs: u64, - pub eflags: u64, - pub rsp: u64, - pub ss: u64, - pub fs_base: u64, - pub gs_base: u64, - pub ds: u64, - pub es: u64, - pub fs: u64, - pub gs: u64, + pub struct user_fpregs_struct { + pub cwd: ::c_ushort, + pub swd: ::c_ushort, + pub ftw: ::c_ushort, + pub fop: ::c_ushort, + pub rip: ::c_ulonglong, + pub rdp: ::c_ulonglong, + pub mxcsr: ::c_uint, + pub mxcr_mask: ::c_uint, + pub st_space: [::c_uint; 32], + pub xmm_space: [::c_uint; 64], + padding: [::c_uint; 24], + } + + pub struct user_regs_struct { + pub r15: ::c_ulonglong, + pub r14: ::c_ulonglong, + pub r13: ::c_ulonglong, + pub r12: ::c_ulonglong, + pub rbp: ::c_ulonglong, + pub rbx: ::c_ulonglong, + pub r11: ::c_ulonglong, + pub r10: ::c_ulonglong, + pub r9: ::c_ulonglong, + pub r8: ::c_ulonglong, + pub rax: ::c_ulonglong, + pub rcx: ::c_ulonglong, + pub rdx: ::c_ulonglong, + pub rsi: ::c_ulonglong, + pub rdi: ::c_ulonglong, + pub orig_rax: ::c_ulonglong, + pub rip: ::c_ulonglong, + pub cs: ::c_ulonglong, + pub eflags: ::c_ulonglong, + pub rsp: ::c_ulonglong, + pub ss: ::c_ulonglong, + pub fs_base: ::c_ulonglong, + pub gs_base: ::c_ulonglong, + pub ds: ::c_ulonglong, + pub es: ::c_ulonglong, + pub fs: ::c_ulonglong, + pub gs: ::c_ulonglong, } - pub struct _libc_user { - pub regs: _libc_state, + pub struct user { + pub regs: user_regs_struct, pub u_fpvalid: ::c_int, - pub i387: _libc_fpstate, - pub u_tsize: u64, - pub u_dsize: u64, - pub u_ssize: u64, - pub start_code: u64, - pub start_stack: u64, - pub signal: i64, + pub i387: user_fpregs_struct, + pub u_tsize: ::c_ulonglong, + pub u_dsize: ::c_ulonglong, + pub u_ssize: ::c_ulonglong, + pub start_code: ::c_ulonglong, + pub start_stack: ::c_ulonglong, + pub signal: ::c_longlong, __reserved: ::c_int, - pub u_ar0: *mut _libc_state, - pub u_fpstate: *mut _libc_fpstate, - pub magic: u64, + pub u_ar0: *mut user_regs_struct, + pub u_fpstate: *mut user_fpregs_struct, + pub magic: ::c_ulonglong, pub u_comm: [::c_char; 32], - pub u_debugreg: [u64; 8], + pub u_debugreg: [::c_ulonglong; 8], } pub struct mcontext_t {