Update for Ghidra 11.0.2 and various bug fixes. #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Dr. MephistO, I hope life finds you well. I think you've probably moved on from this project, but I figured I would leave this PR here for posterity in case it is useful to someone.
This PR accomplishes:
PcodeEmit.java
implementation, as recent updates to Ghidra have fixed the 8-argument limit.The Psy-Q detections bytes and mask had some errors that prevented them from ever being able to match anything. In particular the third byte and mask (
0x07
and0xE0
) were mutually exclusive and can never match. I believe the intent was to ensure only the lower 5-bits could contain values here, so the byte value is changed to0x0
. The 7th byte/mask would only ever match version 4.7, rather than 4.x. I changed the mask here as well in order to account for detection of versions 3.6.x.x -> 3.7. This was necessary to correctly detect Final Fantasy Tactics which uses 3.6.1.0. I tested against Vagrant Story as well since I know that was a problem and it works.Compiler segment detection for FFT did not work because its
start
function did not contain the instruction pair for callingInitHeap
. This is the only game I've tested that has a start function like this, but it's possible others exist. This caused the detection offsets to miss instructions by 8 bytes. A crude check is at the start of the function to account for this possibility now.The rest of the changes to the compiler segment generation are more complicated. The basic idea is that the assumption that the
.sdata
section starts at thegp
initial value is true frequently, but not strictly. Segment generation for Brigandine and Soul Reaver runs into problems where the.data
block would get an unnamed.data.split
section created that very conspicuously started on the border of smaller data. Later, the.sdata
section got created atgp
in uninitialized data.I changed the code to instead determine
.sdata
as simply starting where.data
ends, and runs to the end of the length of the text/data section as defined in the section table. This has the effect for both games of producing compiler segments like this:where
gp
is located somewhere inside of the uninitialized RAM segment, and the length of the three segments is ~32KB. This matches up with how thegp
register is supposed to be used w/ respect to the.sdata
and.sbss
section and what I've been able to figure out is that this segment layout is produced by the linker when the gp optimization flag is turned on, which is rare for PSX games. I tested this change in emulators and when overlays were loaded for either game, they would immediately dump a ton of data into the RAM segment.I have tested other games where the behavior of
.sdata
lining up withgp
is present and the changes do not harm that.