1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::error::*;
use crate::ir;
pub trait Module {
fn pre_analysis_function(&self, function: &mut ir::Function<ir::Constant>) -> Result<()>;
}
pub struct MipsT9 {}
impl MipsT9 {
pub fn new() -> MipsT9 {
MipsT9 {}
}
pub fn pre_analysis_function(&self, function: &mut ir::Function<ir::Constant>) -> Result<()> {
let entry_index = match function.control_flow_graph().entry() {
Some(index) => index,
None => bail!("Could not find function entrypoint"),
};
println!("Found entry index: 0x{:x}", entry_index);
let function_address = function.address();
let block = function.block_mut(entry_index)?;
let operation = ir::Operation::Assign {
dst: ir::scalar("$t9", 32).into(),
src: ir::Constant::new(function_address, 32).into(),
};
block.prepend_operation(operation);
Ok(())
}
}
impl Module for MipsT9 {
fn pre_analysis_function(&self, mut function: &mut ir::Function<ir::Constant>) -> Result<()> {
self.pre_analysis_function(&mut function)
}
}