File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,15 @@ pub struct SectionHeaders {
169
169
inner : Vec < SectionHeader > ,
170
170
/// Section names.
171
171
names : Vec < String > ,
172
+ /// Human readable format
173
+ human_readable : bool ,
174
+ }
175
+
176
+ impl SectionHeaders {
177
+ /// Toggles the value for human readable format.
178
+ pub fn toggle_readability ( & mut self ) {
179
+ self . human_readable = !self . human_readable ;
180
+ }
172
181
}
173
182
174
183
impl < ' a >
@@ -209,6 +218,7 @@ impl<'a>
209
218
. unwrap_or_else ( |_| String :: from ( "unknown" ) )
210
219
} )
211
220
. collect ( ) ,
221
+ human_readable : true ,
212
222
} )
213
223
}
214
224
}
@@ -226,7 +236,11 @@ impl<'a> Property<'a> for SectionHeaders {
226
236
. to_string( ) ,
227
237
format!( "{:#x}" , header. sh_addr) ,
228
238
format!( "{:#x}" , header. sh_offset) ,
229
- format!( "{:#x}" , header. sh_size) ,
239
+ if self . human_readable {
240
+ format!( "{}" , ByteSize ( header. sh_size) )
241
+ } else {
242
+ format!( "{:#x}" , header. sh_size)
243
+ } ,
230
244
header. sh_entsize. to_string( ) ,
231
245
format!( "{:#x}" , header. sh_flags) ,
232
246
header. sh_link. to_string( ) ,
Original file line number Diff line number Diff line change @@ -350,6 +350,7 @@ impl<'a> State<'a> {
350
350
Command :: HumanReadable => {
351
351
if self . tab == Tab :: StaticAnalysis {
352
352
self . analyzer . elf . program_headers . toggle_readability ( ) ;
353
+ self . analyzer . elf . section_headers . toggle_readability ( ) ;
353
354
self . handle_tab ( ) ?;
354
355
}
355
356
}
You can’t perform that action at this time.
0 commit comments