Skip to content

Commit

Permalink
feat(static): add human readable option for Static/Section headers/ S…
Browse files Browse the repository at this point in the history
…ize (#96)
  • Loading branch information
dacianpascu06 authored Oct 29, 2024
1 parent 419feae commit 09137d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/elf/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ pub struct SectionHeaders {
inner: Vec<SectionHeader>,
/// Section names.
names: Vec<String>,
/// Human readable format
human_readable: bool,
}

impl SectionHeaders {
/// Toggles the value for human readable format.
pub fn toggle_readability(&mut self) {
self.human_readable = !self.human_readable;
}
}

impl<'a>
Expand Down Expand Up @@ -209,6 +218,7 @@ impl<'a>
.unwrap_or_else(|_| String::from("unknown"))
})
.collect(),
human_readable: true,
})
}
}
Expand All @@ -226,7 +236,11 @@ impl<'a> Property<'a> for SectionHeaders {
.to_string(),
format!("{:#x}", header.sh_addr),
format!("{:#x}", header.sh_offset),
format!("{:#x}", header.sh_size),
if self.human_readable {
format!("{}", ByteSize(header.sh_size))
} else {
format!("{:#x}", header.sh_size)
},
header.sh_entsize.to_string(),
format!("{:#x}", header.sh_flags),
header.sh_link.to_string(),
Expand Down
1 change: 1 addition & 0 deletions src/tui/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ impl<'a> State<'a> {
Command::HumanReadable => {
if self.tab == Tab::StaticAnalysis {
self.analyzer.elf.program_headers.toggle_readability();
self.analyzer.elf.section_headers.toggle_readability();
self.handle_tab()?;
}
}
Expand Down

0 comments on commit 09137d2

Please sign in to comment.