Skip to content

Commit

Permalink
[CFI] Skip zeros when entry length is zero
Browse files Browse the repository at this point in the history
Only skip null bytes when format is Dwarf32

Remove skip_null
  • Loading branch information
calixteman committed Apr 9, 2020
1 parent f5486d0 commit f8c6f49
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/read/cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,23 @@ where
R: Reader,
Section: UnwindSection<R>,
{
let offset = input.offset_from(section.section());
let (length, format) = input.read_initial_length()?;
let (offset, length, format) = loop {
let offset = input.offset_from(section.section());
let (length, format) = input.read_initial_length()?;

if Section::length_value_is_end_of_entries(length) {
return Ok(None);
}
if Section::length_value_is_end_of_entries(length) {
return Ok(None);
}

// Hack: skip zero padding inserted by buggy compilers/linkers.
// We require that the padding is a multiple of 32-bits, otherwise
// there is no reliable way to determine when the padding ends. This
// should be okay since CFI entries must be aligned to the address size.

if length.into_u64() != 0 || format != Format::Dwarf32 {
break (offset, length, format);
}
};

let mut rest = input.split(length)?;
let cie_offset_base = rest.offset_from(section.section());
Expand Down

0 comments on commit f8c6f49

Please sign in to comment.