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

treat note alignments as in readelf #91

Merged
merged 1 commit into from
May 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/elf/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,13 @@ if_alloc! {
type Size = usize;
fn try_from_ctx(bytes: &'a [u8], (alignment, ctx): (usize, container::Ctx)) -> Result<(Self, Self::Size), Self::Error> {
let offset = &mut 0;
let mut alignment = alignment;
if alignment < 4 {
alignment = 4;
}
let header: NoteHeader = {
match alignment {
4 => bytes.gread_with::<Nhdr32>(offset, ctx.le)?.into(),
// this is a guess; i haven't seen gcc/clang compilers emit 64-bit notes, and i don't have any non gcc/clang compilers
8 => bytes.gread_with::<Nhdr64>(offset, ctx.le)?.into(),
4|8 => bytes.gread_with::<Nhdr32>(offset, ctx.le)?.into(),
_ => return Err(error::Error::Malformed(format!("Notes has unimplemented alignment requirement: {:#x}", alignment)))
}
};
Expand Down