-
Notifications
You must be signed in to change notification settings - Fork 56
Detect ELF-32 at runtime, rather than compile time. #25
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
Conversation
I made a quick test and it works. Good job! |
src/elf_sections.rs
Outdated
let section = self.current_section; | ||
let section: &'static ElfSection = match self.entry_size { | ||
40 => unsafe { &*(self.current_section as *const _ as *const ElfSection32) }, | ||
64 => unsafe { &*(self.current_section as *const _ as *const ElfSection64) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the as *const _
nesissary in these lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer core::mem::size_of<ElfSection32|64>()
to comparing with 40
and 60
if they are equivilant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have more changes I'd like to get in that would clean this one up more, but yes, you have to cast twice, once to get a raw pointer of the same type and again to change the type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That isn't possible because match
doesn't accept size_of
in a pattern.
I updated this to be closer to reasonable. Input welcome. |
This PR has been great in my kernel that supports both i686 and x86_64 targets. Any update on whether this will be merged? |
I'm sorry, I didn't have the time for maintaining this crate over the past months. I'm happy to add maintainers to this project, if someone is willing, to avoid such delays in the future. |
Thanks a lot for this PR, @ahmedcharles! From a quick look, it looks good. I don't use 32bit ELFs personally, so I don't have a good way of testing this feature. I don't have the time to do an in-detail review either. Nevertheless, I'm going to merge this PR since it seems to work, according to the comments in this thread. I also decided to give you push access to this repo. Feel free to push and merge any non breaking changes at your own discretion. |
Thanks. |
WIP: don't merge.
This is sort of a hacked up runtime implementation of ELF-32 support, primarily so @jmi2k can take a look and see if it works and satisfies their requirements.
I'm planning other changes that will make this much cleaner, but they're not ready yet.