33 lines
740 B
Rust

use crate::{error::Error, mapping::Mapping, object::ResolvedSymbol, state::State};
#[cfg(any(target_arch = "x86_64", rust_analyzer))]
mod x86_64;
pub enum RelaValue {
QWord(i64),
}
pub trait RelocationValue {
fn write(&self, mapping: &mut Mapping, offset: u64);
}
pub trait Relocation {
type Value: RelocationValue;
fn resolve(
&self,
state: &State,
name: &str,
symbol: &ResolvedSymbol,
load_base: usize,
) -> Result<Option<Self::Value>, Error>;
}
impl RelocationValue for RelaValue {
fn write(&self, mapping: &mut Mapping, offset: u64) {
match *self {
Self::QWord(value) => unsafe { mapping.qword(offset).write_unaligned(value) },
}
}
}