Update loaders for Ghidra 12.x Loader API#23
Conversation
Ghidra 12 replaced AbstractProgramWrapperLoader.load(ByteProvider, LoadSpec, List<Option>, Program, TaskMonitor, MessageLog) with load(Program, Loader.ImporterSettings), bundling the old parameters into a single ImporterSettings record. Updates every loader's load() signature accordingly, and Trs80Model100RlcLoader's getDefaultOptions override for its new mirrorFsLayout parameter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
AtariStLoader, X68KXLoader, and X68KZLoader queried the opinion file for any "68000" processor match, which resolves to multiple installed language variants (default, MC68020, MC68030, Coldfire) with no defined ordering - in practice this surfaced as Ghidra prompting to pick a language/compiler on import, and headless import silently picking Coldfire, which doesn't match real Atari ST/X68000 68000 CPUs. Hardcode the language/compiler spec instead, matching the existing pattern used by ClassicMacResourceForkLoader and AppleLisaObjectFileLoader. Also drops the now-unused opinion file entries for these three loaders. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks so much for this!
I haven't touched this in over a year and don't even have Ghidra installed at the moment so I'm a bit vague on some things so pardon my dumb question but I just want to make sure that in non-headless mode a user can still choose '020 or '030 for ST files since unlike the X68000 and Lisa there were machines with upgraded CPUs and probably 3rd party accelerators too? I do remember that I doubled checked that those other machines never had fancier CPUs. When I was working on this I never tried running headless.
That should be fine as I don't think there's many active users. |
Real ST-family hardware (TT, Falcon030, third-party accelerator cards) shipped with 68020/68030 in place of the standard 68000, so collapsing AtariStLoader to a single hardcoded language variant removed a legitimate choice. Offer all three real variants, with default preferred, and continue excluding Coldfire, which no ST ever had. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Have you tested it works?
I suck at CI. Another user contributed it a few months ago and I trusted them as the community is only a tiny handful of people. |
The load() API change in this PR is 12.x-only, so testing against 11.x would just fail. Covers 12.0 through 12.1.2. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Yes, tested! Built against 12.1.2, imported a couple of real Also added the CI matrix update in the latest commit, so the build now covers 12.0 through 12.1.2 instead of the old 11.x range (which would all fail against the new API anyway). One thing to know: because this PR comes from a fork, GitHub won't run the CI automatically — it needs a one-time approval from you. You should see a yellow banner on the PR's Checks tab saying something like "Workflow runs from fork pull requests require approval" with an Approve and run button. Just a click and it'll kick off. |
Ghidra 12 changed the
Loaderinterface —load()now takes a singleLoader.ImporterSettingsrecord instead of the old(ByteProvider, LoadSpec, List<Option>, Program, TaskMonitor, MessageLog)params. This updates every loader'sload()(andTrs80Model100RlcLoader'sgetDefaultOptions, which gained amirrorFsLayoutparam) to match, so the extension builds and runs again on 12.x. Should be a no-op behavior-wise, just signature plumbing.While I was in there testing with real Atari ST binaries, I also hit a latent bug in
AtariStLoader/X68KXLoader/X68KZLoader: they query the opinion file for any 68000-family language, which on my Ghidra install resolves to 4 installed variants (default,MC68020,MC68030,Coldfire) with no defined ordering. In the GUI this shows up as an unexpected language/compiler picker on import, and headless import silently pickedColdfire, which isn't right for real ST/X68000 68000 CPUs. Hardcoded68000:BE:32:defaultinstead, matching whatClassicMacResourceForkLoaderandAppleLisaObjectFileLoaderalready do, and dropped the now-dead opinion file entries for these three.Tested by building against Ghidra 12.1.2 and running headless imports of a couple of real Atari ST
.PRGfiles —Atari STloader and the right language now get picked automatically and the binaries load and disassemble cleanly.Heads up on compatibility: this only builds against Ghidra 12.x... 11.x users aren't stuck, since the existing
v0.0.1release predates this and still works fine for them, butmainitself would only target 12.x from here on. Wanted to flag that trade-off rather than have it land as a surprise — happy to also update the CI matrix to 12.x in this PR if that's the direction you want, or rework this differently if you'd rather keep 11.x building onmain.