@@ -8,13 +8,14 @@ use binaryninja::debuginfo::{
88 CustomDebugInfoParser , DebugFunctionInfo , DebugInfo , DebugInfoParser ,
99} ;
1010
11- use idb_rs:: id0:: { ID0Section , IDBParam1 , IDBParam2 } ;
11+ use idb_rs:: id0:: { ID0Section , ID0SectionVariants , IDBParam1 , IDBParam2 } ;
1212use idb_rs:: til:: section:: TILSection ;
1313use idb_rs:: til:: TypeVariant as TILTypeVariant ;
1414
1515use log:: { error, trace, warn, LevelFilter } ;
1616
1717use anyhow:: Result ;
18+ use idb_rs:: { IDAKind , IDAUsize } ;
1819use binaryninja:: logger:: Logger ;
1920
2021struct IDBDebugInfoParser ;
@@ -118,7 +119,7 @@ fn parse_idb_info(
118119 } ;
119120 trace ! ( "Parsing a IDB file" ) ;
120121 let file = std:: io:: BufReader :: new ( file) ;
121- let mut parser = idb_rs:: IDBParser :: new ( file) ?;
122+ let mut parser = idb_rs:: IDAVariants :: new ( file) ?;
122123 if let Some ( til_section) = parser. til_section_offset ( ) {
123124 trace ! ( "Parsing the TIL section" ) ;
124125 let til = parser. read_til_section ( til_section) ?;
@@ -128,9 +129,16 @@ fn parse_idb_info(
128129
129130 if let Some ( id0_section) = parser. id0_section_offset ( ) {
130131 trace ! ( "Parsing the ID0 section" ) ;
131- let id0 = parser. read_id0_section ( id0_section) ?;
132+ let id0_variant = parser. read_id0_section ( id0_section) ?;
132133 // progress 50%-100%
133- parse_id0_section_info ( debug_info, bv, debug_file, & id0) ?;
134+ match id0_variant {
135+ ID0SectionVariants :: IDA32 ( id0) => {
136+ parse_id0_section_info ( debug_info, bv, debug_file, & id0) ?;
137+ }
138+ ID0SectionVariants :: IDA64 ( id0) => {
139+ parse_id0_section_info ( debug_info, bv, debug_file, & id0) ?;
140+ }
141+ }
134142 }
135143
136144 Ok ( ( ) )
@@ -148,7 +156,7 @@ fn parse_til_info(
148156 } ;
149157 let mut file = std:: io:: BufReader :: new ( file) ;
150158 trace ! ( "Parsing the TIL section" ) ;
151- let til = TILSection :: read ( & mut file, idb_rs :: IDBSectionCompression :: None ) ?;
159+ let til = TILSection :: read ( & mut file) ?;
152160 import_til_section ( debug_info, debug_file, & til, progress)
153161}
154162
@@ -218,18 +226,19 @@ pub fn import_til_section(
218226 Ok ( ( ) )
219227}
220228
221- fn parse_id0_section_info (
229+ fn parse_id0_section_info < K : IDAKind > (
222230 debug_info : & mut DebugInfo ,
223231 bv : & BinaryView ,
224232 debug_file : & BinaryView ,
225- id0 : & ID0Section ,
233+ id0 : & ID0Section < K > ,
226234) -> Result < ( ) > {
227235 let version = match id0. ida_info ( ) ? {
228236 idb_rs:: id0:: IDBParam :: V1 ( IDBParam1 { version, .. } )
229237 | idb_rs:: id0:: IDBParam :: V2 ( IDBParam2 { version, .. } ) => version,
230238 } ;
231239
232240 for ( addr, info) in get_info ( id0, version) ? {
241+ let addr = addr. into_u64 ( ) ;
233242 // just in case we change this struct in the future, this line will for us to review this code
234243 // TODO merge this data with folder locations
235244 let AddrInfo {
@@ -264,15 +273,15 @@ fn parse_id0_section_info(
264273 }
265274 } ) ;
266275
267- match ( label, & ty, bnty) {
276+ match ( & label, & ty, bnty) {
268277 ( _, Some ( ty) , bnty) if matches ! ( & ty. type_variant, TILTypeVariant :: Function ( _) ) => {
269278 if bnty. is_none ( ) {
270279 error ! ( "Unable to convert the function type at {addr:#x}" , )
271280 }
272281 if !debug_info. add_function ( & DebugFunctionInfo :: new (
273282 None ,
274283 None ,
275- label. map ( str:: to_string) ,
284+ label. as_deref ( ) . map ( str:: to_string) ,
276285 bnty,
277286 Some ( addr) ,
278287 None ,
@@ -283,15 +292,15 @@ fn parse_id0_section_info(
283292 }
284293 }
285294 ( _, Some ( _ty) , Some ( bnty) ) => {
286- if !debug_info. add_data_variable ( addr, & bnty, label, & [ ] ) {
295+ if !debug_info. add_data_variable ( addr, & bnty, label. as_deref ( ) , & [ ] ) {
287296 error ! ( "Unable to add the type at {addr:#x}" )
288297 }
289298 }
290299 ( _, Some ( _ty) , None ) => {
291300 // TODO types come from the TIL sections, can we make all types be just NamedTypes?
292301 error ! ( "Unable to convert type {addr:#x}" ) ;
293302 // TODO how to add a label without a type associacted with it?
294- if let Some ( name) = label {
303+ if let Some ( name) = label. as_deref ( ) {
295304 if !debug_info. add_data_variable (
296305 addr,
297306 & binaryninja:: types:: Type :: void ( ) ,
0 commit comments