NationalSecurityAgency / ghidra

Ghidra is a software reverse engineering (SRE) framework
https://www.nsa.gov/ghidra
Apache License 2.0
50.85k stars 5.8k forks source link

Fix wrong rcall operand on 8K AVR8 chips #6596

Open piotrva opened 4 months ago

piotrva commented 4 months ago

This PR addresses wrong interpretation of rcall for AVR8 chips with 8K memory. This is resolving #1951 by adding dedicated support for ATMega8 processor. This also defines correctly memory ranges and io registers for ATMega8.

jobermayr commented 3 months ago

To fix build errors:

diff --git a/Ghidra/Processors/Atmel/certification.manifest b/Ghidra/Processors/Atmel/certification.manifest
index 30116f230b..b5d919900e 100644
--- a/Ghidra/Processors/Atmel/certification.manifest
+++ b/Ghidra/Processors/Atmel/certification.manifest
@@ -31,6 +31,9 @@ data/languages/avr8eind.slaspec||GHIDRA||||END|
 data/languages/avr8gcc.cspec||GHIDRA||||END|
 data/languages/avr8iarV1.cspec||GHIDRA||||END|
 data/languages/avr8imgCraftV8.cspec||GHIDRA||||END|
+data/languages/avr8mega8.pspec||GHIDRA||||END|
+data/languages/avr8mega8.sinc||GHIDRA||||END|
+data/languages/avr8mega8.slaspec||GHIDRA||||END|
 data/languages/avr8xmega.pspec||GHIDRA||||END|
 data/languages/avr8xmega.slaspec||GHIDRA||||END|
 data/manuals/AVR32.idx||GHIDRA||||END|
piotrva commented 3 months ago

To fix build errors:

diff --git a/Ghidra/Processors/Atmel/certification.manifest b/Ghidra/Processors/Atmel/certification.manifest
index 30116f230b..b5d919900e 100644
--- a/Ghidra/Processors/Atmel/certification.manifest
+++ b/Ghidra/Processors/Atmel/certification.manifest
@@ -31,6 +31,9 @@ data/languages/avr8eind.slaspec||GHIDRA||||END|
 data/languages/avr8gcc.cspec||GHIDRA||||END|
 data/languages/avr8iarV1.cspec||GHIDRA||||END|
 data/languages/avr8imgCraftV8.cspec||GHIDRA||||END|
+data/languages/avr8mega8.pspec||GHIDRA||||END|
+data/languages/avr8mega8.sinc||GHIDRA||||END|
+data/languages/avr8mega8.slaspec||GHIDRA||||END|
 data/languages/avr8xmega.pspec||GHIDRA||||END|
 data/languages/avr8xmega.slaspec||GHIDRA||||END|
 data/manuals/AVR32.idx||GHIDRA||||END|

What do you mean by this?

jobermayr commented 3 months ago

What do you mean by this?

You need this changes to fix:

$ gradle buildGhidra
> Task :Atmel:ip FAILED

FAILURE: Build failed with an exception.

* Where:
Script '/tmp/ghidra/gradle/support/ip.gradle' line: 169

* What went wrong:
Execution failed for task ':Atmel:ip'.
> No IP found for /tmp/ghidra/Ghidra/Processors/Atmel/data/languages/avr8mega8.pspec in module: /tmp/ghidra/Ghidra/Processors/Atmel. Expression: (ip != null). Values: ip = null