11use std:: { collections:: HashSet , fs, io:: Cursor , path:: Path } ;
22
33use anyhow:: { anyhow, bail, ensure, Context , Result } ;
4- use byteorder:: { BigEndian , ReadBytesExt } ;
54use cwextab:: decode_extab;
65use filetime:: FileTime ;
76use flagset:: Flags ;
@@ -18,6 +17,7 @@ use crate::{
1817 ObjExtab , ObjInfo , ObjReloc , ObjSection , ObjSectionKind , ObjSymbol , ObjSymbolFlagSet ,
1918 ObjSymbolFlags ,
2019 } ,
20+ util:: { read_u16, read_u32} ,
2121} ;
2222
2323fn to_obj_section_kind ( kind : SectionKind ) -> Option < ObjSectionKind > {
@@ -415,8 +415,8 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection]) -> Result<()> {
415415 . index ( )
416416 . 0 ;
417417 let start = reader. position ( ) ;
418- let size = reader . read_u32 :: < BigEndian > ( ) ?;
419- let base_address = reader . read_u32 :: < BigEndian > ( ) ? as u64 ;
418+ let size = read_u32 ( obj_file , & mut reader ) ?;
419+ let base_address = read_u32 ( obj_file , & mut reader ) ? as u64 ;
420420 let Some ( out_section) =
421421 sections. iter_mut ( ) . find ( |s| s. orig_index == text_section_index)
422422 else {
@@ -426,12 +426,12 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection]) -> Result<()> {
426426 } ;
427427 let end = start + size as u64 ;
428428 while reader. position ( ) < end {
429- let line_number = reader . read_u32 :: < BigEndian > ( ) ? as u64 ;
430- let statement_pos = reader . read_u16 :: < BigEndian > ( ) ?;
429+ let line_number = read_u32 ( obj_file , & mut reader ) ? as u64 ;
430+ let statement_pos = read_u16 ( obj_file , & mut reader ) ?;
431431 if statement_pos != 0xFFFF {
432432 log:: warn!( "Unhandled statement pos {}" , statement_pos) ;
433433 }
434- let address_delta = reader . read_u32 :: < BigEndian > ( ) ? as u64 ;
434+ let address_delta = read_u32 ( obj_file , & mut reader ) ? as u64 ;
435435 out_section. line_info . insert ( base_address + address_delta, line_number) ;
436436 log:: debug!( "Line: {:#x} -> {}" , base_address + address_delta, line_number) ;
437437 }
0 commit comments