Skip to content

Commit

Permalink
Support all CIE versions in eh_frame
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-auer committed May 7, 2020
1 parent 69bad66 commit 70c2490
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions src/read/cfi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,6 @@ pub trait _UnwindSectionPrivate<R: Reader> {
/// underflows, return `None`.
fn resolve_cie_offset(&self, base: R::Offset, offset: R::Offset) -> Option<R::Offset>;

/// Return true if our parser is compatible with the given version.
fn compatible_version(version: u8) -> bool;

/// Does this version of this unwind section encode address and segment
/// sizes in its CIEs?
fn has_address_and_segment_sizes(version: u8) -> bool;
Expand Down Expand Up @@ -721,16 +718,6 @@ impl<R: Reader> _UnwindSectionPrivate<R> for DebugFrame<R> {
Some(offset)
}

fn compatible_version(version: u8) -> bool {
// Version 1 of `.debug_frame` corresponds to DWARF 2, and then for
// DWARF 3 and 4, I think they decided to just match the standard's
// version.
match version {
1 | 3 | 4 => true,
_ => false,
}
}

fn has_address_and_segment_sizes(version: u8) -> bool {
version == 4
}
Expand Down Expand Up @@ -771,16 +758,6 @@ impl<R: Reader> _UnwindSectionPrivate<R> for EhFrame<R> {
base.checked_sub(offset)
}

fn compatible_version(version: u8) -> bool {
// While the `.eh_frame` header can only have version 1, CIEs can also occur in version 3.
// Like in `.debug_frame`, their return address is encoded as a single byte in version 1 and
// LEB128 otherwise.
match version {
1 | 3 => true,
_ => false,
}
}

fn has_address_and_segment_sizes(_version: u8) -> bool {
false
}
Expand Down Expand Up @@ -1262,8 +1239,13 @@ impl<R: Reader> CommonInformationEntry<R> {
mut rest: R,
) -> Result<CommonInformationEntry<R>> {
let version = rest.read_u8()?;
if !Section::compatible_version(version) {
return Err(Error::UnknownVersion(u64::from(version)));

// Version 1 of `.debug_frame` corresponds to DWARF 2, and then for
// DWARF 3 and 4, I think they decided to just match the standard's
// version.
match version {
1 | 3 | 4 => (),
_ => return Err(Error::UnknownVersion(u64::from(version))),
}

let mut augmentation_string = rest.read_null_terminated_slice()?;
Expand Down

0 comments on commit 70c2490

Please sign in to comment.