Skip to content

Commit abf06be

Browse files
author
Name1e5s
authored
linux: don't panic for note sections with invalid alignment (gimli-rs#74)
Some Android versions use an alignment of 2. We don't need the notes in these sections, so ignore them.
1 parent 5dd2640 commit abf06be

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/linux/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ impl<'a> Segment<'a> {
8888
&self,
8989
shlib: &SharedLibrary<'a>,
9090
) -> impl Iterator<Item = (libc::Elf32_Word, &'a [u8], &'a [u8])> {
91-
assert!(self.is_note());
92-
9391
// `man 5 readelf` says that all of the `Nhdr`, name, and descriptor are
9492
// always 4-byte aligned, but we copy this alignment behavior from
9593
// `readelf` since that seems to match reality in practice.
@@ -113,7 +111,9 @@ impl<'a> Segment<'a> {
113111
let mut data = self.data(shlib);
114112

115113
iter::from_fn(move || {
116-
assert_eq!(data.as_ptr() as usize % alignment, 0);
114+
if (data.as_ptr() as usize % alignment) != 0 {
115+
return None;
116+
}
117117

118118
// Each entry in a `PT_NOTE` segment begins with a
119119
// fixed-size header `Nhdr`.

0 commit comments

Comments
 (0)