2nd draft of merging with develop branch: Weird rustfmt errors solved

parent 04173f14
......@@ -3754,7 +3754,7 @@ fn write_align(f: &mut File, align: ByteSize) {
fn write_align(f: &mut File, align: ByteSize) {
use std::io::Write;
f.write_fmt(format_args!("\t.align {}\n", check_align(align)))
.unwrap();
.unwrap();
}
/// writes a constant to assembly output
......@@ -3845,12 +3845,13 @@ fn write_const_value(f: &mut File, constant: P<Value>) {
#[cfg(not(feature = "sel4-rumprun"))]
pub fn emit_sym_table(vm: &VM) {
debug!("Currently nothing to emit for --!");
}
debug!("Currently nothing to emit for --!");
}
fn mangle_all(name_vec: &mut Vec<String>){
for i in 0..name_vec.len(){
name_vec[i] = name_vec[i].replace('.', "Zd")
fn mangle_all(name_vec: &mut Vec<String>) {
for i in 0..name_vec.len() {
name_vec[i] = name_vec[i]
.replace('.', "Zd")
.replace('-', "Zh")
.replace(':', "Zc")
.replace('#', "Za");
......@@ -3859,15 +3860,15 @@ fn mangle_all(name_vec: &mut Vec<String>){
}
#[cfg(feature = "sel4-rumprun")]
pub fn emit_sym_table(vm: &VM){
pub fn emit_sym_table(vm: &VM) {
use std::path;
use std::io::Write;
// Here goes the code to generate an asm file to resolve symbol addresses at link time
// in this stage, a single sym_file is generated for the test
// these sym_files will be compiled in build.rs in the parent directory of sel4 side
//**************************************************
// first create the asm file in the correct path
// _st added file name and path stands for _SymTable
......@@ -3875,13 +3876,18 @@ pub fn emit_sym_table(vm: &VM){
debug!("Going to emit Sym table for sel4-rumprun");
let mut file_path_st = path::PathBuf::new();
file_path_st.push(&vm.vm_options.flag_aot_emit_dir);
// vm file name is: "mu_sym_table.s"
file_path_st.push(format!("{}", AOT_EMIT_SYM_TABLE_FILE));
let mut file_st = match File::create(file_path_st.as_path()) {
Err(why) => panic!("couldn't create SYM TABLE file {}: {}",
file_path_st.to_str().unwrap(), why),
Err(why) => {
panic!(
"couldn't create SYM TABLE file {}: {}",
file_path_st.to_str().unwrap(),
why
)
}
Ok(file) => file
};
......@@ -3900,71 +3906,82 @@ pub fn emit_sym_table(vm: &VM){
// *************************************************
let mut sym_vec: Vec<String> = Vec::new();
let compiled_funcs : &HashMap<_, _> = &vm.compiled_funcs().read().unwrap();
let compiled_funcs: &HashMap<_, _> = &vm.compiled_funcs().read().unwrap();
for (theID, theCFs) in compiled_funcs.iter() {
let theCF : &CompiledFunction = &theCFs.read().unwrap();
let theCF: &CompiledFunction = &theCFs.read().unwrap();
match theCF.start {
// CF.start can only be relocatable , otherwise panic
ValueLocation::Relocatable(_, ref symbol) => {
// debug!("theCF.start, symbol = {}\n", *symbol);
// debug!("theCF.start, symbol = {}\n", *symbol);
sym_vec.push((*symbol).clone());
},
}
// CF.start can't reach this state
_ => panic!("Sym_Table_start: expecting Relocatable location, found {}", theCF.start)
_ => {
panic!(
"Sym_Table_start: expecting Relocatable location, found {}",
theCF.start
)
}
}
match theCF.end {
// CF.start can only be relocatable , otherwise panic
ValueLocation::Relocatable(_, ref symbol) => {
// debug!("theCF.end, symbol = {}\n", *symbol);
// debug!("theCF.end, symbol = {}\n", *symbol);
sym_vec.push((*symbol).clone());
},
}
// CF.end can't reach this state
_ => panic!("Sym_Table_end: expecting Relocatable location, found {}", theCF.end)
_ => {
panic!(
"Sym_Table_end: expecting Relocatable location, found {}",
theCF.end
)
}
}
// for &(ref callsite, ref dest) in theCF.frame.get_exception_callsites().iter(){
// match *callsite {
// ValueLocation::Relocatable(_, ref symbol) => {
// sym_vec.push((*symbol).clone());
// },
// // can't reach this state
// _ => panic!("Sym_Table_callsite: expecting Relocatable location, found {}",
// callsite)
// }
// match *dest {
// ValueLocation::Relocatable(_, ref symbol) => {
// sym_vec.push((*symbol).clone());
// },
// // can't reach this state
// _ => panic!("Sym_Table_callsite: expecting Relocatable location, found {}", dest)
// }
// }
// for &(ref callsite, ref dest) in theCF.frame.get_exception_callsites().iter(){
// match *callsite {
// ValueLocation::Relocatable(_, ref symbol) => {
// sym_vec.push((*symbol).clone());
// },
// // can't reach this state
// _ => panic!("Sym_Table_callsite: expecting Relocatable location, found {}",
// callsite)
// }
// match *dest {
// ValueLocation::Relocatable(_, ref symbol) => {
// sym_vec.push((*symbol).clone());
// },
// // can't reach this state
// _ => panic!("Sym_Table_callsite: expecting Relocatable location, found {}",
// dest)
// }
// }
}
// **************************************************
// Generate the following code:
// .data
// .globl mu_sym_table
// mu_sym_table:
// for each symbol {
// .quad "symbol_name".length()
// __symbol_name:
// .ascii "symbol_name"
// .quad 0
// }
// *************************************************
mangle_all(&mut sym_vec);
file_st.write("\t.data\n".as_bytes()).unwrap();
file_st.write_fmt(format_args!("\t{}\n",
directive_globl("mu_sym_table".to_string()))).unwrap();
file_st
.write_fmt(format_args!(
"\t{}\n",
directive_globl("mu_sym_table".to_string())
))
.unwrap();
file_st.write_fmt(format_args!("mu_sym_table:\n")).unwrap();
file_st.write_fmt(format_args!(".quad {}\n", sym_vec.len())).unwrap();
for i in 0..sym_vec.len(){
file_st.write_fmt(format_args!(".quad {}\n", sym_vec[i].len())).unwrap();
file_st.write_fmt(format_args!(".ascii \"{}\"\n", sym_vec[i])).unwrap();
file_st.write_fmt(format_args!(".quad {}\n", sym_vec[i])).unwrap();
file_st
.write_fmt(format_args!(".quad {}\n", sym_vec.len()))
.unwrap();
for i in 0..sym_vec.len() {
file_st
.write_fmt(format_args!(".quad {}\n", sym_vec[i].len()))
.unwrap();
file_st
.write_fmt(format_args!(".ascii \"{}\"\n", sym_vec[i]))
.unwrap();
file_st
.write_fmt(format_args!(".quad {}\n", sym_vec[i]))
.unwrap();
}
}
......@@ -4161,9 +4178,9 @@ pub fn emit_context_with_reloc(
dumper.dump("HYBRID_TAG_MAP", hybrid_tag_map);
dumper.finish();
emit_sym_table(vm);
debug!("---finish---");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment