Skip to content

Ghidra is a software reverse engineering (SRE) framework

GT-2909_emteere_Xmega made memory access registers non-volatile so references could be made

emteere599dc0a1d1e3
diff --git a/Ghidra/Processors/Atmel/data/languages/atmega256.pspec b/Ghidra/Processors/Atmel/data/languages/atmega256.pspec
index 8fcaa0cc49..f77f889310 100644
--- a/Ghidra/Processors/Atmel/data/languages/atmega256.pspec
+++ b/Ghidra/Processors/Atmel/data/languages/atmega256.pspec
@@ -9,10 +9,14 @@
- NOTE: The settings within this file may be specific to a particular
- processor variant and will likely need to be changed to reflect
- the specific target processor.
+ The RAMPx, EIND, SREG registers are not marked volatile, even though they could be changed
+ indirectly with memory references. If they are made volatile, then the addressing
+ won't work in decompiler or reference recovery.
+ Some registers only appear in newer avr8's, or with large memory spaces
-->
<volatile outputop="write_volatile" inputop="read_volatile">
- <range space="mem" first="0x20" last="0x5a"/>
+ <range space="mem" first="0x20" last="0x57"/>
<range space="mem" first="0x60" last="0xff"/>
</volatile>
diff --git a/Ghidra/Processors/Atmel/data/languages/avr8.pspec b/Ghidra/Processors/Atmel/data/languages/avr8.pspec
index d878787d33..01cb20db50 100644
--- a/Ghidra/Processors/Atmel/data/languages/avr8.pspec
+++ b/Ghidra/Processors/Atmel/data/languages/avr8.pspec
@@ -13,10 +13,14 @@
- NOTE: The settings within this file may be specific to a particular
- processor variant and will likely need to be changed to reflect
- the specific target processor.
+ The RAMPx, EIND, SREG registers are not marked volatile, even though they could be changed
+ indirectly with memory references. If they are made volatile, then the addressing
+ won't work in decompiler or reference recovery.
+ Some registers only appear in newer avr8's, or with large memory spaces
-->
<volatile outputop="write_volatile" inputop="read_volatile">
- <range space="mem" first="0x20" last="0x5a"/>
+ <range space="mem" first="0x20" last="0x57"/>
<range space="mem" first="0x60" last="0xff"/>
</volatile>
diff --git a/Ghidra/Processors/Atmel/data/languages/avr8.sinc b/Ghidra/Processors/Atmel/data/languages/avr8.sinc
index 782f4b9b30..63a6365ce4 100644
--- a/Ghidra/Processors/Atmel/data/languages/avr8.sinc
+++ b/Ghidra/Processors/Atmel/data/languages/avr8.sinc
@@ -76,10 +76,15 @@ define register offset=0x80 size=1 [
# to act as the high bits where the X, Y, or Z registers are used, or in direct
# addressing instructions.
#
+# TODO: incorporate the use of RAMPX, RAMPY, RAMPZ in the LD, ST instructions
+# ELPM, and LDS instructions use RAMPZ and RAMPD
+#
# These IO registers need to be accessible to sleigh instruction PCODE
# so they are defined here. The bulk of the IO registers are defined
# as labels in the appropriate .pspec file.
+
+
define mem offset=$(IO_START) size = 1 [
# IO_START + 0x00
_ _ _ _ _ _ _ _
diff --git a/Ghidra/Processors/Atmel/data/languages/avr8xmega.pspec b/Ghidra/Processors/Atmel/data/languages/avr8xmega.pspec
index 35b1d62315..5ab6644e0c 100644
--- a/Ghidra/Processors/Atmel/data/languages/avr8xmega.pspec
+++ b/Ghidra/Processors/Atmel/data/languages/avr8xmega.pspec
@@ -9,6 +9,10 @@
- NOTE: The settings within this file may be specific to a particular
- processor variant and will likely need to be changed to reflect
- the specific target processor.
+ The RAMPx, EIND, SREG registers are not marked volatile, even though they could be changed
+ indirectly with memory references. If they are made volatile, then the addressing
+ won't work in decompiler or reference recovery.
+ Some registers only appear in newer avr8's, or with large memory spaces
-->
<volatile outputop="write_volatile" inputop="read_volatile">