Ghidra is a software reverse engineering (SRE) framework
GP-4055: Corrected AVR 8 Hflag usage in DES instruction
ghidorahrex79d775e6a50f
diff --git a/Ghidra/Processors/Atmel/data/languages/avr8.sinc b/Ghidra/Processors/Atmel/data/languages/avr8.sincindex c7e0661540..45ef6ecf56 100644--- a/Ghidra/Processors/Atmel/data/languages/avr8.sinc+++ b/Ghidra/Processors/Atmel/data/languages/avr8.sinc@@ -739,11 +739,16 @@ define pcodeop decrypt;:des op4to7 is phase=1 & ophi8=0x94 & oplow4=0xb & op4to7 {val:1 = op4to7;- if (Hflg) goto <enc>;- R15R14R13R12R11R10R9R8 = decrypt(R7R6R5R4R3R2R1R0, val);- goto inst_next;- <enc>- R15R14R13R12R11R10R9R8 = encrypt(R7R6R5R4R3R2R1R0, val);+ local key:8 = R15R14R13R12R11R10R9R8;+ local result:16 = 0;+ if (!Hflg) goto <enc>;+ result = decrypt(R7R6R5R4R3R2R1R0, key, val);+ goto <des_end>;+<enc>+ result = encrypt(R7R6R5R4R3R2R1R0, key, val);+<des_end>+ R7R6R5R4R3R2R1R0 = result(0);+ R15R14R13R12R11R10R9R8 = result(8);}@if HASEIND == "1"diff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O0_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O0_EmulatorTest.javaindex 71aaf11790..5a8097b2dc 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O0_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O0_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_31_GCC_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {testRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Overridediff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O3_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O3_EmulatorTest.javaindex 499e88c039..c3d7af73bc 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O3_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_31_GCC_O3_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_31_GCC_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {testRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Overridediff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O0_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O0_EmulatorTest.javaindex 1b98b6c8ae..91ec6b5d42 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O0_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O0_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_51_GCC_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {testRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Overridediff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O3_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O3_EmulatorTest.javaindex 33b3907a57..78f0d47400 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O3_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_51_GCC_O3_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_51_GCC_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {testRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Overridediff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O0_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O0_EmulatorTest.javaindex 9163c42ea4..81b7fef79d 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O0_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O0_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_6_GCC_O0_EmulatorTest extends ProcessorEmulatorTestAdapter {testRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Overridediff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O3_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O3_EmulatorTest.javaindex e346813cbd..4ff0d21932 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O3_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_6_GCC_O3_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_6_GCC_O3_EmulatorTest extends ProcessorEmulatorTestAdapter {testRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Overridediff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O0_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O0_EmulatorTest.javaindex 772b9cd58c..c759239ebb 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O0_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O0_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_xmega_GCC_O0_EmulatorTest extends ProcessorEmulatorTestAdaptertestRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Overridediff --git a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O3_EmulatorTest.java b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O3_EmulatorTest.javaindex ee75b0aeb5..cda349e5c0 100644--- a/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O3_EmulatorTest.java+++ b/Ghidra/Processors/Atmel/src/test.processors/java/ghidra/test/processors/AVR8_xmega_GCC_O3_EmulatorTest.java@@ -44,7 +44,7 @@ public class AVR8_xmega_GCC_O3_EmulatorTest extends ProcessorEmulatorTestAdaptertestRunner.setRegister("SP", 0x0);testRunner.setRegister("R1", 0x0);testRunner.setRegister("Y", 0x0);- testRunner.setRegister("W", 0x0);+ testRunner.setRegister("R25R24", 0x0);}@Override