Skip to content

Commit

Permalink
read/cfi: implement DW_CFA_AARCH64_negate_ra_state
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc committed Aug 11, 2023
1 parent 1555c68 commit 0b6670f
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 39 deletions.
11 changes: 11 additions & 0 deletions crates/examples/src/bin/dwarfdump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,11 @@ fn dump_eh_frame<R: Reader, W: Write>(
.unwrap_or(mem::size_of::<usize>() as u8);
eh_frame.set_address_size(address_size);

match file.architecture() {
object::Architecture::Aarch64 => eh_frame.set_vendor(gimli::Vendor::AArch64),
_ => {}
}

fn register_name_none(_: gimli::Register) -> Option<&'static str> {
None
}
Expand Down Expand Up @@ -1050,9 +1055,15 @@ fn dump_cfi_instructions<R: Reader, W: Write>(
ArgsSize { size } => {
writeln!(w, " DW_CFA_GNU_args_size ({})", size)?;
}
NegateRaState => {
writeln!(w, " DW_CFA_AARCH64_negate_ra_state")?;
}
Nop => {
writeln!(w, " DW_CFA_nop")?;
}
_ => {
writeln!(w, " {:?}", op)?;
}
},
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ impl Format {
}
}

/// Which vendor extensions to support.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Vendor {
/// A default set of extensions, including some common GNU extensions.
Default,
/// AAarch64 extensions.
AArch64,
}

/// Encoding parameters that are commonly used for multiple DWARF sections.
///
/// This is intended to be small enough to pass by value.
Expand Down
11 changes: 10 additions & 1 deletion src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,20 @@ use core::fmt;
// }
// }
macro_rules! dw {
($(#[$meta:meta])* $struct_name:ident($struct_type:ty) { $($name:ident = $val:expr),+ $(,)? }) => {
($(#[$meta:meta])* $struct_name:ident($struct_type:ty)
{ $($name:ident = $val:expr),+ $(,)? }
$(, aliases { $($alias_name:ident = $alias_val:expr),+ $(,)? })?
) => {
$(#[$meta])*
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct $struct_name(pub $struct_type);

$(
pub const $name: $struct_name = $struct_name($val);
)+
$($(
pub const $alias_name: $struct_name = $struct_name($alias_val);
)+)*

impl $struct_name {
pub fn static_string(&self) -> Option<&'static str> {
Expand Down Expand Up @@ -182,6 +188,9 @@ DwCfa(u8) {
DW_CFA_GNU_window_save = 0x2d,
DW_CFA_GNU_args_size = 0x2e,
DW_CFA_GNU_negative_offset_extended = 0x2f,
},
aliases {
DW_CFA_AARCH64_negate_ra_state = 0x2d,
});

dw!(
Expand Down
Loading

0 comments on commit 0b6670f

Please sign in to comment.