@@ -7,7 +7,7 @@ use crate::load_commands::{EncryptionInfoCommand, LoadCommand, RoutinesCommand,
77pub fn print_header ( header : & MachHeader ) {
88 let mut table = Table :: new ( ) ;
99 table. add_row ( row ! [ FBbc ->"Header" , c->"-" , c->"-" ] ) ;
10- table. add_row ( row ! [ Bbbc =>"Field" , "Value" , "Info " ] ) ;
10+ table. add_row ( row ! [ Bbbc =>"Field" , "Value" , "Description " ] ) ;
1111
1212 match header {
1313 MachHeader :: MH32 ( header) => print_header_32 ( header, & mut table) ,
@@ -22,8 +22,8 @@ fn print_header_32(header: &MachHeader32, table: &mut Table) {
2222 print_header_cputype ( header. cputype , table) ;
2323 print_header_cpusubtype ( header. cpusubtype , table) ;
2424 print_header_filetype ( header. filetype , table) ;
25- table. add_row ( row ! [ Fcc ->"ncmds" , Fyc ->format!( "0x{:x}" , header. ncmds) , c->"number of load commands " ] ) ;
26- table. add_row ( row ! [ Fcc ->"sizeofcmds" , Fyc ->format!( "0x{:x}" , header. sizeofcmds) , c->"size of all of the load commands in bytes " ] ) ;
25+ table. add_row ( row ! [ Fcc ->"ncmds" , Fyc ->format!( "0x{:x}" , header. ncmds) , c->"- " ] ) ;
26+ table. add_row ( row ! [ Fcc ->"sizeofcmds" , Fyc ->format!( "0x{:x}" , header. sizeofcmds) , c->"- " ] ) ;
2727 print_header_flags ( header. flags , table) ;
2828 table. add_row ( row ! [ c=>"***" , "***" , "***" ] ) ;
2929}
@@ -33,21 +33,21 @@ fn print_header_64(header: &MachHeader64, table: &mut Table) {
3333 print_header_cputype ( header. cputype , table) ;
3434 print_header_cpusubtype ( header. cpusubtype , table) ;
3535 print_header_filetype ( header. filetype , table) ;
36- table. add_row ( row ! [ Fcc ->"ncmds" , Fyc ->format!( "0x{:x}" , header. ncmds) , c->"number of load commands " ] ) ;
37- table. add_row ( row ! [ Fcc ->"sizeofcmds" , Fyc ->format!( "0x{:x}" , header. sizeofcmds) , c->"size of all of the load commands in bytes " ] ) ;
36+ table. add_row ( row ! [ Fcc ->"ncmds" , Fyc ->format!( "0x{:x}" , header. ncmds) , c->"- " ] ) ;
37+ table. add_row ( row ! [ Fcc ->"sizeofcmds" , Fyc ->format!( "0x{:x}" , header. sizeofcmds) , c->"- " ] ) ;
3838 print_header_flags ( header. flags , table) ;
3939 table. add_row ( row ! [ Fcc ->"reserved" , Fyc ->format!( "0x{:x}" , header. reserved) , c->"-" ] ) ;
4040}
4141
4242fn print_header_magic ( magic : u32 , table : & mut Table ) {
43- let magic_string = match magic {
44- MH_MAGIC => "MH_MAGIC ( Big endian, 32 bit Mach-O)" ,
45- MH_CIGAM => "MH_CIGAM ( Little endian, 32 bit Mach-O)" ,
46- MH_MAGIC_64 => "MH_MAGIC_64 ( Big endian, 64 bit Mach-O)" ,
47- MH_CIGAM_64 => "MH_CIGAM_64 ( Little endian, 64 bit Mach-O)" ,
48- _ => " Unrecognized mach-o magic!",
43+ let ( magic_string, info ) = match magic {
44+ MH_MAGIC => ( "MH_MAGIC" , " Big endian, 32 bit Mach-O" ) ,
45+ MH_CIGAM => ( "MH_CIGAM" , " Little endian, 32 bit Mach-O" ) ,
46+ MH_MAGIC_64 => ( "MH_MAGIC_64" , " Big endian, 64 bit Mach-O" ) ,
47+ MH_CIGAM_64 => ( "MH_CIGAM_64" , " Little endian, 64 bit Mach-O" ) ,
48+ _ => ( "" , " Unrecognized mach-o magic!") ,
4949 } ;
50- table. add_row ( row ! [ Fcc ->"magic" , Fyc ->format!( "0x{:x}" , magic) , c->magic_string ] ) ;
50+ table. add_row ( row ! [ Fcc ->"magic" , Fyc ->format!( "0x{:x}\n ({}) " , magic, magic_string ) , c->info ] ) ;
5151}
5252
5353fn print_header_cputype ( cputype : i32 , table : & mut Table ) {
@@ -76,7 +76,7 @@ fn print_header_cputype(cputype: i32, table: &mut Table) {
7676 CPU_TYPE_POWERPC64 => "CPU_TYPE_POWERPC64" ,
7777 _ => "Unrecognized cputype!" ,
7878 } ;
79- table. add_row ( row ! [ Fcc ->"cputype" , Fyc ->format!( "0x{:x}" , cputype) , c->cputype_string ] ) ;
79+ table. add_row ( row ! [ Fcc ->"cputype" , Fyc ->format!( "0x{:x}\n ({}) " , cputype, cputype_string ) , c->"-" ] ) ;
8080}
8181
8282fn print_header_cpusubtype ( cpusubtype : i32 , table : & mut Table ) {
@@ -86,25 +86,25 @@ fn print_header_cpusubtype(cpusubtype: i32, table: &mut Table) {
8686 CPU_SUBTYPE_BIG_ENDIAN => "CPU_SUBTYPE_BIG_ENDIAN" ,
8787 _ => "Unrecogninzed cpusubtype!" ,
8888 } ;
89- table. add_row ( row ! [ Fcc ->"cpusubtype" , Fyc ->format!( "0x{:x}" , cpusubtype) , c->cpusubtype_string ] ) ;
89+ table. add_row ( row ! [ Fcc ->"cpusubtype" , Fyc ->format!( "0x{:x}\n ({}) " , cpusubtype, cpusubtype_string ) , c->"-" ] ) ;
9090}
9191
9292fn print_header_filetype ( filetype : u32 , table : & mut Table ) {
93- let filetype_string = match filetype {
94- MH_OBJECT => "MH_OBJECT ( Relocatable object file)" ,
95- MH_EXECUTE => "MH_EXECUTE ( Demand paged executable file)" ,
96- MH_FVMLIB => "MH_FVMLIB ( Fixed VM shared library file)" ,
97- MH_CORE => "MH_CORE ( Core file)" ,
98- MH_PRELOAD => "MH_PRELOAD ( Preloaded executable file)" ,
99- MH_DYLIB => "MH_DYLIB ( Dynamically bound shared library)" ,
100- MH_DYLINKER => "MH_DYLINKER ( Dynamic link editor)" ,
101- MH_BUNDLE => "MH_BUNDLE ( Dynamically bound bundle file)" ,
102- MH_DYLIB_STUB => "MH_DYLIB_STUB ( Shared library stub for static linking only, no section contents)" ,
103- MH_DSYM => "MH_DSYM ( Companion file with only debug sections)" ,
104- MH_KEXT_BUNDLE => "MH_KEXT_BUNDLE ( x86_64 kexts)" ,
105- _ => " Unrecogninzed filetype!",
93+ let ( filetype_string, info ) = match filetype {
94+ MH_OBJECT => ( "MH_OBJECT" , " Relocatable object file" ) ,
95+ MH_EXECUTE => ( "MH_EXECUTE" , " Demand paged executable file" ) ,
96+ MH_FVMLIB => ( "MH_FVMLIB" , " Fixed VM shared library file" ) ,
97+ MH_CORE => ( "MH_CORE" , " Core file" ) ,
98+ MH_PRELOAD => ( "MH_PRELOAD" , " Preloaded executable file" ) ,
99+ MH_DYLIB => ( "MH_DYLIB" , " Dynamically bound shared library" ) ,
100+ MH_DYLINKER => ( "MH_DYLINKER" , " Dynamic link editor" ) ,
101+ MH_BUNDLE => ( "MH_BUNDLE" , " Dynamically bound bundle file" ) ,
102+ MH_DYLIB_STUB => ( "MH_DYLIB_STUB" , " Shared library stub for static linking only, no section contents" ) ,
103+ MH_DSYM => ( "MH_DSYM" , " Companion file with only debug sections" ) ,
104+ MH_KEXT_BUNDLE => ( "MH_KEXT_BUNDLE" , " x86_64 kexts" ) ,
105+ _ => ( "" , " Unrecogninzed filetype!") ,
106106 } ;
107- table. add_row ( row ! [ Fcc ->"filetype" , Fyc ->format!( "0x{:x}" , filetype) , c->filetype_string ] ) ;
107+ table. add_row ( row ! [ Fcc ->"filetype" , Fyc ->format!( "0x{:x}\n ({}) " , filetype, filetype_string ) , c->info ] ) ;
108108}
109109
110110fn print_header_flags ( flags_combined : u32 , table : & mut Table ) {
@@ -144,13 +144,13 @@ fn print_header_flags(flags_combined: u32, table: &mut Table) {
144144 decomposed_flags. push ( * name) ;
145145 }
146146 }
147- table. add_row ( row ! [ Fcc ->"flags" , Fyc ->format!( "0x{:x}" , flags_combined) , c-> format!( "{}" , decomposed_flags. join( " | " ) ) ] ) ;
147+ table. add_row ( row ! [ Fcc ->"flags" , Fyc ->format!( "0x{:x}\n ({}) " , flags_combined, format!( "{}" , decomposed_flags. join( " | " ) ) ) , c-> "-" ] ) ;
148148}
149149
150150pub fn print_load_commands ( load_commands : & Vec < LoadCommand > ) {
151151 let mut table = Table :: new ( ) ;
152152 table. add_row ( row ! [ FBbc ->"Load Commands" , c->"-" , c->"-" ] ) ;
153- table. add_row ( row ! [ Bbbc =>"Field" , "Value" , "Info " ] ) ;
153+ table. add_row ( row ! [ Bbbc =>"Field" , "Value" , "Description " ] ) ;
154154
155155 for ( index, load_command) in load_commands. iter ( ) . enumerate ( ) {
156156 table. add_row ( row ! [ Fmbc ->format!( "Load Command #{}" , index) , c->"-" , c->"-" ] ) ;
@@ -319,6 +319,6 @@ fn print_lc_cmd_and_cmdsize(cmd: u32, cmdsize: u32, table: &mut Table) {
319319 _ => "" ,
320320 } ;
321321
322- table. add_row ( row ! [ Fcc ->"cmd" , Fyc ->format!( "0x{:x} ({})" , cmd, cmd_string) , c->"-" ] ) ;
322+ table. add_row ( row ! [ Fcc ->"cmd" , Fyc ->format!( "0x{:x}\n ({})" , cmd, cmd_string) , c->"-" ] ) ;
323323 table. add_row ( row ! [ Fcc ->"cmdsize" , Fyc ->format!( "0x{:x}" , cmdsize) , c->"size of the load command in bytes" ] ) ;
324324}
0 commit comments