diff --git a/src/elf/header.rs b/src/elf/header.rs index 789236b..5fb2531 100644 --- a/src/elf/header.rs +++ b/src/elf/header.rs @@ -169,6 +169,15 @@ pub struct SectionHeaders { inner: Vec, /// Section names. names: Vec, + /// 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> @@ -209,6 +218,7 @@ impl<'a> .unwrap_or_else(|_| String::from("unknown")) }) .collect(), + human_readable: true, }) } } @@ -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(), diff --git a/src/tui/state.rs b/src/tui/state.rs index c78638f..81707ce 100644 --- a/src/tui/state.rs +++ b/src/tui/state.rs @@ -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()?; } }