-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Control flow issues when attempting to analyze or merge F-Zero GX DOL with REL files #50
Comments
Looks like GX has two functions that are effectively the same here and they overlap, possibly to save on space. The function at What sort of change might be necessary to fix dtk's analysis of this kind of scenario? |
After investigating, FZGX appears to have many functions with odd control flow. It's possible it was a big ASM file with branches that confuse the analyzer. I was able to get further by manually adding function symbols + sizes to symbols.txt for affected functions (though I don't think they're 100% accurate). Here is the configuration I'm currently using: GFZE01.zip However, now the analysis is stuck because there are RELs that are missing in the final game:
Looking at the game's |
The other RELs I think are used but I think are mostly mentioned in The list is: These all correlate to the modes in the game, of which there are 18. Thankfully there's a table of modes, and the modes have the corresponding enum label stored. This table is in At From what I could glean, |
Ah, nice, JP does have fz.test and fz.testmode unlike US, so I should be able to work from there. Where is line__.rel? |
After decryption and decompression the JP version should have a CRC32 hash of As for |
It's worth noting that GFZJ01 is the "most complete" ROM in terms of REL files. Speaking with Lawn Meower that figure out the decryption, With As for |
OK so I ended up accidentally tackling understanding the exact function that causes the primary issue while trying to name some F-Zero GX maths functions. It's three functions that all share a main body but start differently. Here's what a rough minimum ASM example would look like of code that causes the issue seen in the image up top (I've never really written proper PowerPC ASM before): .global math_sincos_in_sincos
.global math_sincos_in_sin_in_cos
.global math_sincos_registers_only
; All functions have an angle param in r3, and return in r4
math_sincos_in_sincos:
; r4 is pointer to two floats
addi r5, r4, 0x4 # Set second param to the 2nd (index 1) index of what r4 points to
math_sincos_in_sin_in_cos:
; r4 is pointer to float, r5 is pointer to float
crclr 4*cr1+eq # Clear eq bit in cr1
b math_sincos_base
math_sincos_registers_only:
; r4 and r5 don't matter
; This function/instruction is the equivalent of 1:8006D1C4 in the top image
crset 4*cr1+eq # Set eq bit in cr1
math_sincos_base:
; Do maths stuff here using r3 so that f1 and f2 have the sine and cosine in them
; This instruction is the equivalent of 1:8006D1C8 in the top image
; There's three additional breaks in here (a ble, bge, and bne) but I am assuming they won't affect the control flow analysis?
beqlr cr1 # math_sincos_registers_only bails out here
stfs f1, 0x0(r4) # float version of f1 into address pointed to by r4
stfs f2, 0x0(r5) # float version of f1 into address pointed to by r5
blr
; The first instruction in the function after this is the equivalent of 1:0x8006D21C in the top image Long-winded text explanation:At `0x8006d1b4` we have what I call `math_sincos_in_sincos`, which look like this in : * `8006d1b4: f1_f2 math_sincos_in_sincos(ushort angle, float *sincos)` * `8006d1b8: f1_f2 math_sincos_in_sin_in_cos(ushort angle, float *out_sin, float *out_cos)` * `8006d1c0: f1_f2 math_sincos_registers_only(ushort angle)`All return the sine and cosine of the angle in From here on in they all share the same code in |
OK I peered into dtk's code a bit. Looks like
None of these solutions seem all that trivial to me, though maybe somebody with more understanding of the codebase would find it easier. FWIW swapping for if first_end > second {
match skip_alignment(section, second, first_end) {
Some(addr) => addr,
None => continue,
}
} else {
match skip_alignment(section, first_end, second) {
Some(addr) => addr,
None => continue,
}
}; seems to work specifically for doing |
Repository URL
No response
Game Name
F-Zero GX
Game Version
USA, Japan
Description
When attempting to analyze the F-Zero GX dol with the
dol info
command, control flow errors are returned. Furthermore, when attempting to merge the DOL and REL files together to create an ELF which can be statically analyzed, even more control flow errors are returned, along with a "Tail call analysis" failure.The text was updated successfully, but these errors were encountered: