From 467d7d70a10fe908030e9d18f69241d8f11a5bec Mon Sep 17 00:00:00 2001 From: xcoldhandsx Date: Sun, 27 May 2018 12:57:31 +0300 Subject: [PATCH] treat note alignments as in readelf --- src/elf/note.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/elf/note.rs b/src/elf/note.rs index b4d7a7cfb..2ea894cba 100644 --- a/src/elf/note.rs +++ b/src/elf/note.rs @@ -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::(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::(offset, ctx.le)?.into(), + 4|8 => bytes.gread_with::(offset, ctx.le)?.into(), _ => return Err(error::Error::Malformed(format!("Notes has unimplemented alignment requirement: {:#x}", alignment))) } };