pr 59.2
This commit is contained in:
parent
f5dafc403f
commit
b6912c4369
@ -230,7 +230,6 @@ impl Linker {
|
|||||||
|
|
||||||
// Final Exports map for ProgramImage (String -> func_idx)
|
// Final Exports map for ProgramImage (String -> func_idx)
|
||||||
// Only including exports from the ROOT project (the last one in build plan usually)
|
// Only including exports from the ROOT project (the last one in build plan usually)
|
||||||
// Wait, the requirement says "emit final PBS v0 image".
|
|
||||||
// In PBS v0, exports are name -> func_id.
|
// In PBS v0, exports are name -> func_id.
|
||||||
let mut final_exports = HashMap::new();
|
let mut final_exports = HashMap::new();
|
||||||
if let Some(root_module) = modules.last() {
|
if let Some(root_module) = modules.last() {
|
||||||
@ -241,8 +240,9 @@ impl Linker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// v0: Fallback export for entrypoint `src/main/modules:frame` (root module)
|
// v0: Fallback export for entrypoint `src/main/modules:frame` (root module)
|
||||||
if !final_exports.contains_key("src/main/modules:frame") {
|
if !final_exports.iter().any(|(name, _)| name.ends_with(":frame")) {
|
||||||
if let Some(&root_offset) = module_function_offsets.last() {
|
if let Some(&root_offset) = module_function_offsets.last() {
|
||||||
if let Some((idx, _)) = combined_function_names.iter().find(|(i, name)| *i >= root_offset && name == "frame") {
|
if let Some((idx, _)) = combined_function_names.iter().find(|(i, name)| *i >= root_offset && name == "frame") {
|
||||||
final_exports.insert("src/main/modules:frame".to_string(), *idx);
|
final_exports.insert("src/main/modules:frame".to_string(), *idx);
|
||||||
|
|||||||
@ -67,7 +67,7 @@ fn test_integration_test01_link() {
|
|||||||
|
|
||||||
let mut vm = VirtualMachine::default();
|
let mut vm = VirtualMachine::default();
|
||||||
// Use initialize to load the ROM and resolve entrypoint
|
// Use initialize to load the ROM and resolve entrypoint
|
||||||
vm.initialize(unit.rom, "src/main/modules:frame").expect("Failed to initialize VM");
|
vm.initialize(unit.rom, "frame").expect("Failed to initialize VM");
|
||||||
|
|
||||||
let mut native = SimpleNative;
|
let mut native = SimpleNative;
|
||||||
let mut hw = SimpleHardware::new();
|
let mut hw = SimpleHardware::new();
|
||||||
|
|||||||
@ -160,6 +160,8 @@ impl VirtualMachine {
|
|||||||
// Try to resolve symbol name via ProgramImage exports
|
// Try to resolve symbol name via ProgramImage exports
|
||||||
if let Some(&func_idx) = program.exports.get(entrypoint) {
|
if let Some(&func_idx) = program.exports.get(entrypoint) {
|
||||||
program.functions[func_idx as usize].code_offset as usize
|
program.functions[func_idx as usize].code_offset as usize
|
||||||
|
} else if let Some(&func_idx) = program.exports.get(&format!("src/main/modules:{}", entrypoint)) {
|
||||||
|
program.functions[func_idx as usize].code_offset as usize
|
||||||
} else {
|
} else {
|
||||||
return Err(VmInitError::EntrypointNotFound);
|
return Err(VmInitError::EntrypointNotFound);
|
||||||
}
|
}
|
||||||
@ -183,6 +185,8 @@ impl VirtualMachine {
|
|||||||
(addr, idx)
|
(addr, idx)
|
||||||
} else if let Some(&func_idx) = self.program.exports.get(entrypoint) {
|
} else if let Some(&func_idx) = self.program.exports.get(entrypoint) {
|
||||||
(self.program.functions[func_idx as usize].code_offset as usize, func_idx as usize)
|
(self.program.functions[func_idx as usize].code_offset as usize, func_idx as usize)
|
||||||
|
} else if let Some(&func_idx) = self.program.exports.get(&format!("src/main/modules:{}", entrypoint)) {
|
||||||
|
(self.program.functions[func_idx as usize].code_offset as usize, func_idx as usize)
|
||||||
} else {
|
} else {
|
||||||
(0, 0)
|
(0, 0)
|
||||||
};
|
};
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user