1
1
use std:: { collections:: HashSet , fs, io:: Cursor , path:: Path } ;
2
2
3
3
use anyhow:: { anyhow, bail, ensure, Context , Result } ;
4
- use byteorder:: { BigEndian , ReadBytesExt } ;
5
4
use cwextab:: decode_extab;
6
5
use filetime:: FileTime ;
7
6
use flagset:: Flags ;
@@ -18,6 +17,7 @@ use crate::{
18
17
ObjExtab , ObjInfo , ObjReloc , ObjSection , ObjSectionKind , ObjSymbol , ObjSymbolFlagSet ,
19
18
ObjSymbolFlags ,
20
19
} ,
20
+ util:: { read_u16, read_u32} ,
21
21
} ;
22
22
23
23
fn to_obj_section_kind ( kind : SectionKind ) -> Option < ObjSectionKind > {
@@ -415,8 +415,8 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection]) -> Result<()> {
415
415
. index ( )
416
416
. 0 ;
417
417
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 ;
420
420
let Some ( out_section) =
421
421
sections. iter_mut ( ) . find ( |s| s. orig_index == text_section_index)
422
422
else {
@@ -426,12 +426,12 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection]) -> Result<()> {
426
426
} ;
427
427
let end = start + size as u64 ;
428
428
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 ) ?;
431
431
if statement_pos != 0xFFFF {
432
432
log:: warn!( "Unhandled statement pos {}" , statement_pos) ;
433
433
}
434
- let address_delta = reader . read_u32 :: < BigEndian > ( ) ? as u64 ;
434
+ let address_delta = read_u32 ( obj_file , & mut reader ) ? as u64 ;
435
435
out_section. line_info . insert ( base_address + address_delta, line_number) ;
436
436
log:: debug!( "Line: {:#x} -> {}" , base_address + address_delta, line_number) ;
437
437
}
0 commit comments