// Use ArchiveRO for speed here, it's backed by LLVM and uses mmap
// internally to read the file. We also avoid even using a memcpy by
// just keeping the archive along while the metadata is in use.
- let archive = ArchiveRO::open(filename).map(|ar| OwningRef::new(box ar)).map_err(|e| {
- debug!("llvm didn't like `{}`: {}", filename.display(), e);
- format!("failed to read rlib metadata in '{}': {}", filename.display(), e)
- })?;
+ let archive =
+ ArchiveRO::open(filename).map(|ar| OwningRef::new(Box::new(ar))).map_err(|e| {
+ debug!("llvm didn't like `{}`: {}", filename.display(), e);
+ format!("failed to read rlib metadata in '{}': {}", filename.display(), e)
+ })?;
let buf: OwningRef<_, [u8]> = archive.try_map(|ar| {
ar.iter()
.filter_map(|s| s.ok())
let buf = path_to_c_string(filename);
let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf.as_ptr())
.ok_or_else(|| format!("error reading library: '{}'", filename.display()))?;
- let of = ObjectFile::new(mb).map(|of| OwningRef::new(box of)).ok_or_else(|| {
- format!("provided path not an object file: '{}'", filename.display())
- })?;
+ let of =
+ ObjectFile::new(mb).map(|of| OwningRef::new(Box::new(of))).ok_or_else(|| {
+ format!("provided path not an object file: '{}'", filename.display())
+ })?;
let buf = of.try_map(|of| search_meta_section(of, target, filename))?;
Ok(rustc_erase_owner!(buf))
}
// > Executable images do not use a string table and do not support
// > section names longer than 8 characters
//
- // https://msdn.microsoft.com/en-us/library/windows/hardware/gg463119.aspx
+ // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
//
// As a result, we choose a slightly shorter name! As to why
// `.note.rustc` works on MinGW, that's another good question...