Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing structs from linux/user.h #599

Merged
merged 5 commits into from
May 30, 2017
Merged

Adding missing structs from linux/user.h #599

merged 5 commits into from
May 30, 2017

Conversation

xd009642
Copy link
Contributor

Adding structs from linux/user.h (or sys/user.h depending on OS version). This adds the linux user_regs_struct and user struct from sys/user.h into libc for x86 and x86_64. Also, bumping the version number.

As an aside, I was wondering if this was also the right place to add the bit offsets for the EFLAGS register ? These aren't defined anywhere in the linux system libraries instead the definition seems to just be in the x86 and x86_64 documentation but they are useful for anyone looking to interpret eflags. If libc is the right place for these constants I'd like the opportunity to add them before it's merged in. :)

Added equivalents for user_regs_struct and user_struct from linux/user.h for x86 and x86_64.
@alexcrichton
Copy link
Member

Thanks for the PR! Looks like there's some style errors though?

Could you also back out the version bump? That typically happens through dedicated PRs.

Fixed trailing whitespace in x86.rs and reverted the minor version number in the Cargo.toml
@xd009642
Copy link
Contributor Author

Done and done.

Any thoughts on constants for the EFLAGS register?

Forgot to update cargo.lock before prior commit.
@xd009642
Copy link
Contributor Author

so there appears to still be some errors, it seems some of the generated tests fail? And also "error: requires freeze lang_item". cargo build and test both pass on my own pc and I'm not too familiar with the testing involved. Any guidance would be appreciated although I'll still be looking into it so hopefully will figure it out...

@alexcrichton
Copy link
Member

Any thoughts on constants for the EFLAGS register?

Ah sorry I missed that! If these are constants in glibc or in standard C headers, sure! Otherwise though I'd recommend a separate crate for now.

For the test failures the nightly failures are ok (I'll work around them elsewhere) but for there's a few other non-nightly failures I think?

@philipc
Copy link

philipc commented May 26, 2017

@xd009642 To test on your local PC you can run cd libc-test && cargo run.

You may need to change the test to include <sys/user.h>.

Note that _libc_fpstate is from <sys/ucontext.h>. It's not the same as user_fpregs_struct from <sys/user.h>. It looks like you renamed user_regs_struct to _libc_state to match that, but you should keep the original name instead. You'll have to fix this to get the test to pass.

@xd009642
Copy link
Contributor Author

Ah okay, thanks @philipc, I probably won't have a chance to do this until Tuesday as I'm away from my home pc.

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.
@xd009642
Copy link
Contributor Author

Right I've addressed the issues and everything passes on my home machine. Hopefully it should all be good with travis now. Sorry about the delay!

@alexcrichton
Copy link
Member

@bors: r+

Looks great, thanks!

@bors
Copy link
Contributor

bors commented May 30, 2017

📌 Commit 6acbf87 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented May 30, 2017

⌛ Testing commit 6acbf87 with merge 80e1422...

bors added a commit that referenced this pull request May 30, 2017
Adding missing structs from linux/user.h

Adding structs from linux/user.h (or sys/user.h depending on OS version). This adds the linux user_regs_struct and user struct from sys/user.h into libc for x86 and x86_64. Also, bumping the version number.

As an aside, I was wondering if this was also the right place to add the bit offsets for the [EFLAGS register ](https://en.wikibooks.org/wiki/X86_Assembly/X86_Architecture#EFLAGS_Register)? These aren't defined anywhere in the linux system libraries instead the definition seems to just be in the x86 and x86_64 documentation but they are useful for anyone looking to interpret eflags. If libc is the right place for these constants I'd like the opportunity to add them before it's merged in. :)
@bors
Copy link
Contributor

bors commented May 30, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 80e1422 to master...

@bors bors merged commit 6acbf87 into rust-lang:master May 30, 2017
bors added a commit that referenced this pull request Aug 24, 2019
Copy structs from bits/user.h for musl x86_64

While statically compiling a binary with `musl`, I ran into the following error regarding a missing struct:

```
error[E0412]: cannot find type `user_regs_struct` in crate `libc`
  --> src/debug.rs:37:32
   |
37 | fn show_user_regs(regs: &libc::user_regs_struct) -> String {
   |                                ^^^^^^^^^^^^^^^^ not found in `libc`
```

This struct was previously added for `glibc` in #599, but was never added to `musl`, despite the data format being the same in both.

This fix simply copies `user_regs_struct` into the proper location within the `musl` files.
bors added a commit that referenced this pull request Sep 7, 2019
Copy structs from bits/user.h for musl x86_64

While statically compiling a binary with `musl`, I ran into the following error regarding a missing struct:

```
error[E0412]: cannot find type `user_regs_struct` in crate `libc`
  --> src/debug.rs:37:32
   |
37 | fn show_user_regs(regs: &libc::user_regs_struct) -> String {
   |                                ^^^^^^^^^^^^^^^^ not found in `libc`
```

This struct was previously added for `glibc` in #599, but was never added to `musl`, despite the data format being the same in both.

This fix simply copies `user_regs_struct` into the proper location within the `musl` files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants