Umberto Allievi Soluzioni Informatiche
TheCortexMDiff

TheCortexMDiff

Version 0.2.0

ARM Cortex-M firmware comparison tool — disassemble, diff, and analyze firmware changes.

C++20GTK4libadwaitaGtkSourceViewARMVibe Coded
TheCortexMDiff screenshot

Features

Automatic File Format Detection

Detects ELF, Intel HEX, and raw binary formats from file content, not extensions. Load .elf, .hex, .ihex, .bin, .axf, .o, or .out files.

Selectable Instruction Set

Cortex-M (Thumb), Auto-detect, or ARM mode. Controls how arm-none-eabi-objdump interprets the binary. Changing the selection re-disassembles both files.

Multiple Diff Algorithms

Default (Myers), Minimal (precise but slower), and Speed (optimized for large files with 100k+ lines). Select the right tradeoff for your firmware size.

3-Mode Address Stripping

No stripping, strip leading addresses, or strip all addresses (including inline branch targets and .word data). Reduces false diffs when comparing firmware at different base addresses.

Syntax-Highlighted Diff View

GtkSourceView-powered unified diff with word-level change highlighting. Added lines in green, removed in red, with context lines for orientation.

Async Disassembly

Disassembly and diff run asynchronously with a spinner and cancellation support. The UI stays responsive even for large firmware images.

Drag and Drop

Drop two files to load both at once, or drop a single file on the left/right half of the window. Also supports command-line arguments.

Meld Integration

Export the current disassembly to temporary files and open in Meld for full-featured external comparison with Ctrl+M.

Use Cases

Comparing Firmware Builds

Compare two firmware builds to verify that compiler changes, flag adjustments, or source modifications produce the expected disassembly differences.

Bootloader Relocation Analysis

Compare firmware built with and without a bootloader offset. Address stripping eliminates false diffs from different base addresses, showing only real code changes.

Compiler Optimization Comparison

Compare the same source compiled with -O2 vs -O3 to analyze how optimization levels affect generated ARM Thumb instructions.

Firmware Patch Verification

Load original and patched firmware to verify exactly which instructions changed. The diff view highlights modifications at the instruction level.

CI/CD Firmware Validation

Compare firmware artifacts from different CI pipeline runs to detect unexpected changes in the generated binary.

User Manual

Quick Start

  1. Launch TheCortexMDiff from GNOME Activities or terminal
  2. Click File A to open the first firmware file
  3. Click File B to open the second firmware file
  4. Disassembly and comparison start automatically
  5. Use Ctrl+D / Ctrl+Shift+D to jump between differences

From the command line:

the-cortexmdiff firmware_v1.elf firmware_v2.elf

Opening Files

There are three ways to load firmware files:

  • Buttons: Click "File A" or "File B" in the header bar. The filter defaults to firmware extensions (.elf, .hex, .ihex, .bin, .axf, .o, .out).
  • Drag and drop: Drop two files to load both at once, or drop a single file on the left half (File A) or right half (File B).
  • Command line: the-cortexmdiff file_a.elf file_b.elf

When both files are loaded, disassembly and comparison start automatically.

Supported File Formats

FormatExtensionsDetection
ELF.elf, .axf, .o, .outMagic bytes \x7FELF
Intel HEX.hex, .ihexFirst byte :
Raw binary.binFallback for all other files

File format is auto-detected from content, not from the file extension.

Instruction Set

The instruction set dropdown controls how arm-none-eabi-objdump interprets the binary:

ModeDescription
Cortex-M (Thumb)Forces Thumb decoding (-M force-thumb). Default, correct for all Cortex-M cores.
Auto-detectNo -M flag. Lets objdump decide from ELF metadata. Useful for mixed ARM/Thumb ELFs.
ARMForces ARM decoding (-M no-force-thumb). Use for ARM7/ARM9 firmware.

Changing the selection re-disassembles both files and re-runs the diff.

Diff Algorithm

The diff algorithm dropdown selects the GNU diff strategy:

AlgorithmDescription
DefaultStandard Myers O(ND) algorithm (diff -u). Best for most cases.
MinimalGuarantees minimal edit distance (diff -u -d). Slower but more precise.
Speed (large files)Optimised heuristic for large files (diff -u --speed-large-files). Use for very large disassemblies (100k+ lines).

Address Stripping

When comparing firmware built at different base addresses, every line differs because hex addresses change. Address stripping controls how addresses are handled during comparison:

ModeWhat it stripsWhen to use
No strippingNothing. Lines compared as-is.Comparing identical base addresses.
Strip leadingRemoves the hex address prefix at the start of each line.Most firmware comparisons where only the base address differs.
Strip allStrips leading addresses plus inline addresses: branch targets, annotations, .word data, and 0x-prefixed values.Maximum noise reduction when builds differ only in link-time addresses.

The original lines (with addresses) are always displayed in the diff view; stripping only affects what is considered "equal" during comparison.

Keyboard Shortcuts

ShortcutAction
Ctrl+OOpen File A
Ctrl+Shift+OOpen File B
Ctrl+DJump to next difference
Ctrl+Shift+DJump to previous difference
F5Reload (re-disassemble and diff)
Ctrl+MOpen current disassembly in Meld

Troubleshooting

ProblemSolution
"arm-none-eabi-objdump not found"Install: sudo dnf install arm-none-eabi-binutils-cs
"Could not detect file format"File may be empty or corrupted. Check with file <path>.
Too many false diffsSwitch address stripping to "Strip leading" or "Strip all".
Diff takes too longSwitch diff algorithm to "Speed (large files)".
Meld button greyed outLoad both files and wait for the diff to complete first.