Properly locate ProDG .bss sections (partial addressing of #62) (#63)

* Locate ProDG .bss sections (partial addressing of #62)

* Support both correct and incorrect memset calls
This commit is contained in:
First Last 2024-07-17 05:14:46 +00:00 committed by GitHub
parent c484952912
commit c3c7c2b062
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 3 deletions

View File

@ -597,19 +597,27 @@ pub fn locate_bss_memsets(obj: &mut ObjInfo) -> Result<Vec<(u32, u32)>> {
StepResult::Branch(branches) => {
for branch in branches {
if branch.link {
// ProDG bug? Registers are supposed to start at r3
// Some ProDG crt0.s versions use the wrong registers, some don't
if let (
GprValue::Constant(addr),
GprValue::Constant(value),
GprValue::Constant(size),
) = (vm.gpr_value(4), vm.gpr_value(5), vm.gpr_value(6))
{
) = {
if vm.gpr_value(4) == GprValue::Constant(0) {
(vm.gpr_value(3), vm.gpr_value(4), vm.gpr_value(5))
} else {
(vm.gpr_value(4), vm.gpr_value(5), vm.gpr_value(6))
}
} {
if value == 0 && size > 0 {
bss_sections.push((addr, size));
}
}
}
}
if bss_sections.len() >= 2 {
return Ok(ExecCbResult::End(()));
}
Ok(ExecCbResult::Continue)
}
}