mirror of
https://github.com/alfishe/amiga-bootcamp.git
synced 2026-06-12 16:16:28 +00:00
3.6 KiB
3.6 KiB
Ghidra Setup for Amiga 68k Binaries
Requirements
| Component | Version / Notes |
|---|---|
| Ghidra | 10.x+ or 11.x+ recommended |
| Processor module | M68k — included in Ghidra standard install |
| HUNK loader & Amiga extensions | ghidra-amiga by BartmanAbyss |
Step 1: Install the Amiga Extension
Ghidra natively supports the M68000 architecture and includes a powerful decompiler for it, but it does not understand the Amiga OS executable format (HUNK) out of the box.
- Download the latest release of
ghidra-amigafrom: https://github.com/BartmanAbyss/ghidra-amiga - Open Ghidra.
- Go to
File → Install Extensions... - Click the green
+(Add extension) button. - Select the downloaded
.zipfile (do not extract it). - Restart Ghidra.
This essential extension provides:
- A complete Amiga HUNK format loader.
- Custom chipset register definitions mapped to
$DFF000. - OS library LVO (Library Vector Offset) definitions.
- Analyzer scripts specifically for resolving Amiga binaries.
Step 2: Importing and Analyzing
- Create a new project or open an existing one.
- Select
File → Import File...and choose your Amiga executable or library. - The format should automatically be detected as
Amiga Executable(thanks to the extension). - Double-click the imported file to open it in the CodeBrowser.
- When prompted to analyze, click Yes.
- Ensure the
Amigaanalyzers (provided by the extension) are enabled in the analysis options list before hitting Analyze.
Step 3: Decompilation and M68k Specifics
Unlike IDA Pro (which lacks Hex-Rays support for M68k), Ghidra's built-in decompiler fully supports the Motorola 68000 family.
- The
ghidra-amigaextension actively assists the decompiler by automatically annotating library calls (likeexec/AllocMemordos/Open) when it detects jumps to negative offsets onA6. - The decompiler will translate these
JSRinstructions directly into C pseudocode function calls with the correct parameters, making it vastly superior for analyzing C/C++ compiled Amiga software.
Step 4: Custom Hardware Registers ($DFF000)
The ghidra-amiga extension automatically creates memory blocks for Amiga custom chips and CIA registers.
- Go to
Window → Memory Map. You will seecustom($DFF000),ciaa($BFE001), andciab($BFD000) accurately mapped into the address space. - The extension automatically defines the Amiga Custom Chip data types.
- When analyzing code that bangs the hardware (e.g.,
move.w d0, $096(A4)), if Ghidra knowsA4is$DFF000, it will automatically format it ascustom->dmaconin the C pseudocode! - If it fails to detect the base register automatically, you can manually set the register value by highlighting the start of the function, right-clicking, and selecting
Set Register Values(orCtrl-R), then definingA4 = 0xDFF000.
Step 5: Dynamic Analysis
Ghidra is purely for static analysis. For dynamic debugging, the workflow is identical to IDA:
- Do your mapping and decompilation in Ghidra.
- Note the physical addresses and offsets.
- Run the binary in WinUAE and drop into the native debugger (
Shift+F12) to set breakpoints and step through the hardware state live.
References
- ghidra-amiga by BartmanAbyss — The definitive Amiga loader and extension suite for Ghidra.
- Ghidra Official Website
- vscode-amiga-debug — Excellent extension for source-level Amiga debugging if you are writing modern Amiga patches.