-
Notifications
You must be signed in to change notification settings - Fork 163
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
Implemented a solution for #67 #102
Conversation
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.
@ibabushkin This is really great, thanks for the PR! This looks good to me, modulo the doc comments; in the meantime, can you rebase on latest master, so the build/CI is fixed?
Also, I'll check this is backwards compatible with something like bingrep, but I think it's ok regardless, since we need a lazy iterator on relocs; this is great work!
Thanks for your contribution!
@@ -391,4 +380,111 @@ if_alloc! { | |||
} | |||
} | |||
} | |||
|
|||
#[derive(Default)] | |||
pub struct RelocSection<'a> { |
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.
Doc comments please :)
|
||
impl<'a> RelocSection<'a> { | ||
#[cfg(feature = "endian_fd")] | ||
pub fn parse(bytes: &'a [u8], offset: usize, filesz: usize, is_rela: bool, ctx: Ctx) -> ::error::Result<RelocSection<'a>> { |
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.
Doc comment
if index >= self.count { | ||
None | ||
} else { | ||
Some(self.bytes.pread_with(index * Reloc::size_with(&self.ctx), self.ctx).unwrap()) |
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.
Because constructor checks the size, we're safe to unwrap here and in the iterator, correct?
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.
Yep, pretty much. The Symtab
iterator is constructed in the same way.
d4f3818
to
c497c84
Compare
Alright, I rebased on the new master and added the doc comments you asked for :) |
@ibabushkin Thanks so much! So the PR is techncially backwards incompatible; i used as_slice a couple of times, but I don't think its that big of a deal. However, this one is strange:
I probably just didn't read it carefully; @philipc are you ok with these changes? Is it going to be a pain for object? |
To be clear I don't care much about moving from Vec to iterator, as we need lazy iteration, and this is great! Just not missing anything from the api it is presenting :) |
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.
Awesome, LGTM. This appears to have no effect on object, so merging!
@ibabushkin Thanks for the PR, decided to just merge :) We need lazy relocation iterators |
Great! Glad to help. |
I think the provided iterator implementation and boilerplate does what is needed to lazily parse relocations.