@@ -3,7 +3,7 @@ mod raw_dylib;
3
3
use std:: collections:: BTreeSet ;
4
4
use std:: ffi:: OsString ;
5
5
use std:: fs:: { File , OpenOptions , read} ;
6
- use std:: io:: { BufWriter , Write } ;
6
+ use std:: io:: { BufReader , BufWriter , Write } ;
7
7
use std:: ops:: { ControlFlow , Deref } ;
8
8
use std:: path:: { Path , PathBuf } ;
9
9
use std:: process:: { ExitStatus , Output , Stdio } ;
@@ -3439,37 +3439,36 @@ fn add_lld_args(
3439
3439
// Additionally, gold miscompiles SHF_GNU_RETAIN sections, which are
3440
3440
// emitted with `#[used(linker)]`.
3441
3441
fn 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} ;
3447
3445
3446
+ fn elf_has_gold_version_note < ' a > (
3447
+ elf : & impl FileHeader ,
3448
+ data : impl ReadRef < ' a > ,
3449
+ ) -> Result < bool > {
3448
3450
let endian = elf. endian ( ) ?;
3449
3451
3450
3452
let section =
3451
3453
elf. sections ( endian, data) ?. section_by_name ( endian, b".note.gnu.gold-version" ) ;
3452
3454
if let Some ( ( _, section) ) = section {
3453
3455
if let Some ( mut notes) = section. notes ( endian, data) ? {
3454
3456
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 )
3456
3458
} ) ) ;
3457
3459
}
3458
3460
}
3459
3461
3460
3462
Ok ( false )
3461
3463
}
3462
3464
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) ?) ) ;
3467
3466
3468
3467
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) ?;
3470
3469
elf_has_gold_version_note ( elf, & data) ?
3471
3470
} else if sess. target . pointer_width == 32 {
3472
- let elf = elf:: FileHeader32 :: < object :: Endianness > :: parse ( & data) ?;
3471
+ let elf = elf:: FileHeader32 :: < Endianness > :: parse ( & data) ?;
3473
3472
elf_has_gold_version_note ( elf, & data) ?
3474
3473
} else {
3475
3474
return Ok ( ( ) ) ;
0 commit comments