-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.rs
33 lines (29 loc) · 931 Bytes
/
build.rs
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
use std::fs::File;
use std::io::{Result, Write};
use std::path::PathBuf;
fn main() -> Result<()> {
gen_vector_asm()?;
Ok(())
}
/// Generate assembly file for x86_64 trap vector
fn gen_vector_asm() -> Result<()> {
let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
let mut f = File::create(out_path.join("exception.S"))?;
writeln!(f, "# generated by build.rs - do not edit")?;
writeln!(f, ".section .text")?;
for i in 0..256 {
writeln!(f, "__entry{}:", i)?;
if !(i == 8 || (10..=14).contains(&i) || i == 17) {
writeln!(f, "\tpush 0")?;
}
writeln!(f, "\tpush {}", i)?;
writeln!(f, "\tjmp common_exception_entry")?;
}
writeln!(f, "\n.section .rodata")?;
writeln!(f, ".global exception_entries")?;
writeln!(f, "exception_entries:")?;
for i in 0..256 {
writeln!(f, "\t.quad __entry{}", i)?;
}
Ok(())
}