reshuf
This commit is contained in:
parent
42ea48b97f
commit
082a52d895
6 changed files with 32 additions and 6 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -55,6 +55,14 @@ dependencies = [
|
|||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "elf"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
|
@ -132,7 +140,7 @@ name = "rsld"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"byteorder",
|
||||
"elf",
|
||||
"structopt",
|
||||
]
|
||||
|
||||
|
|
|
@ -3,7 +3,10 @@ name = "rsld"
|
|||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
members = ["elf"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.41"
|
||||
byteorder = "1.4.3"
|
||||
structopt = "0.3.21"
|
||||
elf = { path = "elf" }
|
||||
|
|
8
elf/Cargo.toml
Normal file
8
elf/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "elf"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.41"
|
||||
byteorder = "1.4.3"
|
|
@ -4,6 +4,8 @@ use std::mem::MaybeUninit;
|
|||
use anyhow::Result;
|
||||
use byteorder::{LittleEndian, ReadBytesExt};
|
||||
|
||||
const EI_DATA: i32 = 5;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Elf {
|
||||
header: Header,
|
||||
|
@ -43,5 +45,10 @@ impl Elf {
|
|||
Ok(elf)
|
||||
}
|
||||
|
||||
pub fn write<W: Write>(&self, mut w: W) {}
|
||||
pub fn write<W: Write>(&self, mut w: W) -> Result<()> {
|
||||
w.write(&self.header.e_ident)?;
|
||||
w.flush()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -2,11 +2,13 @@ use std::fs::{File, OpenOptions};
|
|||
use std::os::unix::fs::OpenOptionsExt;
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use elf::Elf;
|
||||
|
||||
use crate::elf::Elf;
|
||||
use crate::{LinkUnit, Opt};
|
||||
|
||||
pub(crate) fn link(opt: &Opt) -> Result<()> {
|
||||
let res = Elf::default();
|
||||
|
||||
for unit in &opt.units {
|
||||
match unit {
|
||||
LinkUnit::Path(path) => {
|
||||
|
@ -17,7 +19,6 @@ pub(crate) fn link(opt: &Opt) -> Result<()> {
|
|||
}
|
||||
}
|
||||
|
||||
let res = Elf::default();
|
||||
if let Some(path) = &opt.out {
|
||||
let path = crate::utils::normalize_path(path);
|
||||
let file = OpenOptions::new()
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
mod elf;
|
||||
mod link;
|
||||
mod utils;
|
||||
|
||||
|
|
Loading…
Reference in a new issue