@@ -3,7 +3,7 @@ mod raw_dylib;
33use std:: collections:: BTreeSet ;
44use std:: ffi:: OsString ;
55use std:: fs:: { File , OpenOptions , read} ;
6- use std:: io:: { BufWriter , Write } ;
6+ use std:: io:: { BufReader , BufWriter , Write } ;
77use std:: ops:: { ControlFlow , Deref } ;
88use std:: path:: { Path , PathBuf } ;
99use std:: process:: { ExitStatus , Output , Stdio } ;
@@ -3439,37 +3439,36 @@ fn add_lld_args(
34393439// Additionally, gold miscompiles SHF_GNU_RETAIN sections, which are
34403440// emitted with `#[used(linker)]`.
34413441fn warn_if_linked_with_gold ( sess : & Session , path : & Path ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
3442- fn elf_has_gold_version_note < ' a > (
3443- elf : & impl object:: read:: elf:: FileHeader ,
3444- data : impl object:: read:: ReadRef < ' a > ,
3445- ) -> Result < bool , Box < dyn std:: error:: Error > > {
3446- use object:: read:: elf:: SectionHeader ;
3442+ use object:: read:: elf:: { FileHeader , SectionHeader } ;
3443+ use object:: read:: { ReadCache , ReadRef , Result } ;
3444+ use object:: { Endianness , elf} ;
34473445
3446+ fn elf_has_gold_version_note < ' a > (
3447+ elf : & impl FileHeader ,
3448+ data : impl ReadRef < ' a > ,
3449+ ) -> Result < bool > {
34483450 let endian = elf. endian ( ) ?;
34493451
34503452 let section =
34513453 elf. sections ( endian, data) ?. section_by_name ( endian, b".note.gnu.gold-version" ) ;
34523454 if let Some ( ( _, section) ) = section {
34533455 if let Some ( mut notes) = section. notes ( endian, data) ? {
34543456 return Ok ( notes. any ( |note| {
3455- note. is_ok_and ( |note| note. n_type ( endian) == object :: elf:: NT_GNU_GOLD_VERSION )
3457+ note. is_ok_and ( |note| note. n_type ( endian) == elf:: NT_GNU_GOLD_VERSION )
34563458 } ) ) ;
34573459 }
34583460 }
34593461
34603462 Ok ( false )
34613463 }
34623464
3463- use object:: elf;
3464- use object:: read:: elf:: FileHeader ;
3465-
3466- let data = object:: read:: ReadCache :: new ( std:: io:: BufReader :: new ( std:: fs:: File :: open ( path) ?) ) ;
3465+ let data = ReadCache :: new ( BufReader :: new ( File :: open ( path) ?) ) ;
34673466
34683467 let was_linked_with_gold = if sess. target . pointer_width == 64 {
3469- let elf = elf:: FileHeader64 :: < object :: Endianness > :: parse ( & data) ?;
3468+ let elf = elf:: FileHeader64 :: < Endianness > :: parse ( & data) ?;
34703469 elf_has_gold_version_note ( elf, & data) ?
34713470 } else if sess. target . pointer_width == 32 {
3472- let elf = elf:: FileHeader32 :: < object :: Endianness > :: parse ( & data) ?;
3471+ let elf = elf:: FileHeader32 :: < Endianness > :: parse ( & data) ?;
34733472 elf_has_gold_version_note ( elf, & data) ?
34743473 } else {
34753474 return Ok ( ( ) ) ;
0 commit comments