fixes
This commit is contained in:
@@ -76,6 +76,7 @@ impl Code {
|
|||||||
if src > u32::MAX as u64 {
|
if src > u32::MAX as u64 {
|
||||||
return Err("cannot move 64 bit immediate into memory".into());
|
return Err("cannot move 64 bit immediate into memory".into());
|
||||||
}
|
}
|
||||||
|
let src = src as u32;
|
||||||
|
|
||||||
self.bytes.extend([rex(1, dst.reg, 0, 0), 0xc7]);
|
self.bytes.extend([rex(1, dst.reg, 0, 0), 0xc7]);
|
||||||
self.modrm_regdisp(dst.reg, dst.disp);
|
self.modrm_regdisp(dst.reg, dst.disp);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use crate::{
|
|||||||
use std::{fs::OpenOptions, io::Write, os::unix::fs::OpenOptionsExt, process::Command};
|
use std::{fs::OpenOptions, io::Write, os::unix::fs::OpenOptionsExt, process::Command};
|
||||||
|
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
if let Err(err) = linux() {
|
if let Err(err) = windows() {
|
||||||
println!("{err:?}");
|
println!("{err:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,13 +109,13 @@ fn windows() -> Result<(), CompilerMsg> {
|
|||||||
let path = "./x86_64_test.exe";
|
let path = "./x86_64_test.exe";
|
||||||
write(path, &binary);
|
write(path, &binary);
|
||||||
|
|
||||||
let mut cmd = Command::new("wine");
|
// let mut cmd = Command::new("wine");
|
||||||
cmd.arg("x86_64_test");
|
// cmd.arg("x86_64_test");
|
||||||
let mut proc = cmd.spawn().expect("failed to run");
|
// let mut proc = cmd.spawn().expect("failed to run");
|
||||||
let status = proc.wait().expect("failed to wait");
|
// let status = proc.wait().expect("failed to wait");
|
||||||
if let Some(code) = status.code() {
|
// if let Some(code) = status.code() {
|
||||||
std::process::exit(code);
|
// std::process::exit(code);
|
||||||
}
|
// }
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ mod header;
|
|||||||
mod import;
|
mod import;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::backend::{LibImport, LinkedProgram};
|
use crate::backend::LinkedProgram;
|
||||||
|
|
||||||
use data_dir::*;
|
use data_dir::*;
|
||||||
use header::*;
|
use header::*;
|
||||||
@@ -48,6 +48,7 @@ pub fn create(program: &LinkedProgram<u64>) -> Vec<u8> {
|
|||||||
|
|
||||||
let code_start = data.pos();
|
let code_start = data.pos();
|
||||||
data.extend(&program.code);
|
data.extend(&program.code);
|
||||||
|
println!("entry: 0x{:x}", (code_start as u64 + program.entry.unwrap()) as u32);
|
||||||
|
|
||||||
if !program.imports.is_empty() {
|
if !program.imports.is_empty() {
|
||||||
let import_rva = import::encode(&mut data, &program.imports, code_start);
|
let import_rva = import::encode(&mut data, &program.imports, code_start);
|
||||||
|
|||||||
Reference in New Issue
Block a user