mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
use mmap
This commit is contained in:
parent
56bf57dab1
commit
2631970851
1 changed files with 6 additions and 5 deletions
|
@ -60,7 +60,7 @@ pub(crate) fn preprocess_windows(
|
|||
let exec_file = std::fs::File::open(exec_filename).unwrap_or_else(|e| internal_error!("{}", e));
|
||||
let exec_mmap = unsafe { Mmap::map(&exec_file).unwrap_or_else(|e| internal_error!("{}", e)) };
|
||||
let exec_data = &*exec_mmap;
|
||||
let exec_obj = match object::read::pe::PeFile64::parse(exec_data) {
|
||||
let _exec_obj = match object::read::pe::PeFile64::parse(exec_data) {
|
||||
Ok(obj) => obj,
|
||||
Err(err) => {
|
||||
internal_error!("Failed to parse executable file: {}", err);
|
||||
|
@ -71,10 +71,9 @@ pub(crate) fn preprocess_windows(
|
|||
|
||||
let data = std::fs::read(exec_filename).unwrap();
|
||||
let new_sections = [*b".text\0\0\0", *b".rdata\0\0"];
|
||||
increase_number_of_sections_help(&data, &new_sections, out_filename);
|
||||
let executable = increase_number_of_sections_help(&data, &new_sections, out_filename);
|
||||
|
||||
let exec_data = std::fs::read(out_filename).unwrap();
|
||||
let exec_data = exec_data.as_slice();
|
||||
let exec_data: &[u8] = &*executable;
|
||||
let exec_obj = match object::read::pe::PeFile64::parse(exec_data) {
|
||||
Ok(obj) => obj,
|
||||
Err(err) => {
|
||||
|
@ -1025,7 +1024,7 @@ fn increase_number_of_sections_help(
|
|||
input_data: &[u8],
|
||||
new_sections: &[[u8; 8]],
|
||||
output_file: &Path,
|
||||
) {
|
||||
) -> MmapMut {
|
||||
use object::read::pe::ImageNtHeaders;
|
||||
|
||||
let dos_header = object::pe::ImageDosHeader::parse(input_data).unwrap();
|
||||
|
@ -1065,6 +1064,8 @@ fn increase_number_of_sections_help(
|
|||
.collect();
|
||||
|
||||
assert_eq!(new_sections, names.as_slice());
|
||||
|
||||
mmap
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue