Ghidra is a software reverse engineering (SRE) framework
PR 5442 revisions to original PR 1407
Austin Tyler Connd8c578d99d62
diff --git a/Ghidra/Processors/Xtensa/build.gradle b/Ghidra/Processors/Xtensa/build.gradleindex 701baafa3b..9dadac96d0 100644--- a/Ghidra/Processors/Xtensa/build.gradle+++ b/Ghidra/Processors/Xtensa/build.gradle@@ -6,6 +6,5 @@ apply plugin: 'eclipse'eclipse.project.name = 'Processors Xtensa'dependencies {- compile project(':Base')+ api project(':Base')}-diff --git a/Ghidra/Processors/Xtensa/certification.manifest b/Ghidra/Processors/Xtensa/certification.manifestnew file mode 100644index 0000000000..8d447e56a9--- /dev/null+++ b/Ghidra/Processors/Xtensa/certification.manifest@@ -0,0 +1,20 @@+##VERSION: 2.0+Module.manifest||GHIDRA||||END|+build.gradle||GHIDRA||||END|+data/languages/xtensa.cspec||GHIDRA||||END|+data/languages/xtensa.dwarf||GHIDRA||||END|+data/languages/xtensa.ldefs||GHIDRA||||END|+data/languages/xtensa.opinion||GHIDRA||||END|+data/languages/xtensa.pspec||GHIDRA||||END|+data/languages/xtensa.sinc||GHIDRA||||END|+data/languages/xtensa.slaspec||GHIDRA||||END|+data/languages/xtensaInstructions.sinc||GHIDRA||||END|+data/manuals/xtensa.idx||GHIDRA||||END|+data/patterns/patternconstraints.xml||GHIDRA||||END|+data/patterns/xtensa_patterns.xml||GHIDRA||||END|+src/main/help/help/topics/xtensa/help.html||GHIDRA||||END|+src/main/help/help/TOC_Source.xml||GHIDRA||||END|+src/main/java/ghidra/app/util/bin/format/elf/relocation/Xtensa_ElfRelocationHandler.java||GHIDRA||||END|+src/main/java/ghidra/app/util/bin/format/elf/relocation/Xtensa_ElfRelocationConstants.java||GHIDRA||||END|+src/test.processors/java/ghidra/test/processors/Xtensa_O0_EmulatorTest.java||GHIDRA||||END|+src/test.processors/java/ghidra/test/processors/Xtensa_O3_EmulatorTest.java||GHIDRA||||END|diff --git a/Ghidra/Processors/Xtensa/data/languages/xtensa.cspec b/Ghidra/Processors/Xtensa/data/languages/xtensa.cspecindex f7049a22ba..81a5b3a373 100644--- a/Ghidra/Processors/Xtensa/data/languages/xtensa.cspec+++ b/Ghidra/Processors/Xtensa/data/languages/xtensa.cspec@@ -77,4 +77,69 @@</unaffected></prototype></default_proto>++ <!-- TODO: Evaluate calling convention introduced with PR 5442 -->+ <prototype name="__stdcall_windowed" extrapop="0" stackshift="0">+ <input>+ <!-- TODO: These might be named a2, a3, a4, etc. -->+ <pentry minsize="1" maxsize="4" extension="inttype">+ <register name="i2"/>+ </pentry>+ <pentry minsize="1" maxsize="4" extension="inttype">+ <register name="i3"/>+ </pentry>+ <pentry minsize="1" maxsize="4" extension="inttype">+ <register name="i4"/>+ </pentry>+ <pentry minsize="1" maxsize="4" extension="inttype">+ <register name="i5"/>+ </pentry>+ <pentry minsize="1" maxsize="4" extension="inttype">+ <register name="i6"/>+ </pentry>+ <pentry minsize="1" maxsize="4" extension="inttype">+ <register name="i7"/>+ </pentry>+ <pentry minsize="1" maxsize="500" align="4">+ <addr offset="0" space="stack"/>+ </pentry>+ </input>+ <output>+ <!-- TODO: Verify minsize and maxsize values -->+ <!-- TODO: Consider need to name registers -->+ <pentry minsize="1" maxsize="4" extension="inttype">+ <register name="o2"/>+ </pentry>+ <pentry minsize="5" maxsize="8" extension="inttype">+ <addr space="join" piece1="o3" piece2="o2"/>+ </pentry>+ <pentry minsize="9" maxsize="12" extension="inttype">+ <addr space="join" piece1="o4" piece2="o3" piece3="o2"/>+ </pentry>+ <pentry minsize="13" maxsize="16" extension="inttype">+ <addr space="join" piece1="o5" piece2="o4" piece3="o3" piece4="o2"/>+ </pentry>+ </output>+ <returnaddress>+ <register name="a0"/>+ </returnaddress>+ <unaffected>+ <register name="a1"/>+ <register name="a2"/>+ <register name="a3"/>+ <register name="a4"/>+ <register name="a5"/>+ <register name="a6"/>+ <register name="a7"/>+ <register name="a8"/>+ <register name="a9"/>+ <register name="a10"/>+ <register name="a11"/>+ <register name="a12"/>+ <register name="a13"/>+ <register name="a14"/>+ <register name="a15"/>+ </unaffected>+ </prototype>+</compiler_spec>diff --git a/Ghidra/Processors/Xtensa/data/languages/xtensa.sinc b/Ghidra/Processors/Xtensa/data/languages/xtensa.sincindex b322f131b8..219302428c 100644--- a/Ghidra/Processors/Xtensa/data/languages/xtensa.sinc+++ b/Ghidra/Processors/Xtensa/data/languages/xtensa.sinc@@ -4,28 +4,65 @@ define alignment=1;define space ram type=ram_space size=4 default;define space register type=register_space size=4;+# Special registers (SR). Not all are actually 32 bit, but for the sake of+# simplicity they are here.+define register offset=0x00 size=4 [ LBEG LEND LCOUNT SAR BR LITBASE ];+define register offset=0x30 size=4 [ SCOMPARE1 ];+define register offset=0x40 size=4 [ ACCLO ACCHI ];+define register offset=0x80 size=4 [ M0 M1 M2 M3 ];+define register offset=0x120 size=4 [ WindowBase WindowStart ];+define register offset=0x14c size=4 [ PTEVADDR ];+define register offset=0x164 size=4 [ MMID RASID ITLBCFG DTLBCFG ];+define register offset=0x180 size=4 [ IBREAKENABLE ];+define register offset=0x184 size=4 [ MEMCTL ];+define register offset=0x188 size=4 [ CACHEATTR ATOMCTL ];+define register offset=0x1a0 size=4 [ DDR ];+define register offset=0x1a8 size=4 [ MEPC MEPS MESAVE MESR MECR MEVADDR ];+define register offset=0x200 size=4 [ IBREAKA0 IBREAKA1 ];+define register offset=0x240 size=4 [ DBREAKA0 DBREAKA1 ];+define register offset=0x280 size=4 [ DBREAKC0 DBREAKC1 ];+define register offset=0x2c4 size=4 [ EPC1 EPC2 EPC3 EPC4 EPC5 EPC6 EPC7 ];+define register offset=0x300 size=4 [ DEPC ];+define register offset=0x308 size=4 [ EPS2 EPS3 EPS4 EPS5 EPS6 EPS7 ];+define register offset=0x344 size=4 [ EXCSAVE1 EXCSAVE2 EXCSAVE3 EXCSAVE4 EXCSAVE5 EXCSAVE6 EXCSAVE7 ];+define register offset=0x380 size=4 [ CPENABLE ];+define register offset=0x384 size=4 [ INTERRUPT INTSET INTCLEAR INTENABLE ];+define register offset=0x398 size=4 [ PS VECBASE EXCCAUSE DEBUGCAUSE CCOUNT PRID ICOUNT ICOUNTLEVEL EXCVADDR ];+define register offset=0x3c0 size=4 [ CCOMPARE0 CCOMPARE1 CCOMPARE2 ];+define register offset=0x3d0 size=4 [ MISC0 MISC1 MISC2 MISC3 ];++# TODO: Register offsets *might* be firmware specific?+# Address registers (AR).-define register offset=0x0000 size=4 [+define register offset=0x8000 size=4 [a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15+ i2 i3 i4 i5 i6 i7+ o2 o3 o4 o5 o6 o7];# Floating Point registers (FR + FCR (control) + FSR (status)).-# TODO: FCR and FSR seem unused?-define register offset=0x0100 size=4 [+define register offset=0x8100 size=4 [f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15fcr fsr];# Boolean registers (BR).-define register offset=0x0200 size=1 [+define register offset=0x8200 size=1 [b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15];# Program counter.-define register offset=0x1000 size=4 [ pc ];+# TODO: offset could also be 0x1300 or 0x8300+define register offset=0x8300 size=4 [ pc ];# Shift amount register. (TODO: other special registers)-define register offset=0x2000 size=1 [ sar ];+# define register offset=0x2000 size=1 [ SAR ];++define register offset=0x8400 size=4 contextreg;+define context contextreg+ phase=(0,0)+ loopEnd=(1,1) noflow+;# Regular 24-bit instruction.define token insn(24)@@ -37,42 +74,43 @@ define token insn(24)as = (8,11)fs = (8,11)bs = (8,11)+ sr = (8,15)at = (4,7)ft = (4,7)bt = (4,7)op1 = (16,19)op0 = (0,3)- # Signed and unsigned immediates. Named [us]N_L.M, where u and s denote signedness, L and M the+ # Signed and unsigned immediates. Named [us]N_L_M, where u and s denote signedness, L and M the# least and most significant bit of the immediate in the instruction word, and N the length# (i.e. M-L+1).- u3_21.23 = (21,23)- u4_20.23 = (20,23)- s8_16.23 = (16,23) signed- u8_16.23 = (16,23)- u12_12.23 = (12,23)- s12_12.23 = (12,23) signed- u16_8.23 = (8,23)- s8_6.23 = (6,23) signed+ u3_21_23 = (21,23)+ u4_20_23 = (20,23)+ s8_16_23 = (16,23) signed+ u8_16_23 = (16,23)+ u12_12_23 = (12,23)+ s12_12_23 = (12,23) signed+ u16_8_23 = (8,23)+ s8_6_23 = (6,23) signedu1_20 = (20,20)- u2_18.19 = (18,19)- u3_17.19 = (17,19)- u2_16.17 = (16,17)+ u2_18_19 = (18,19)+ u3_17_19 = (17,19)+ u2_16_17 = (16,17)u1_16 = (16,16)- u2_14.15 = (14,15)- u3_13.15 = (13,15)- u4_12.15 = (12,15)- u8_8.15 = (8,15)- u2_12.13 = (12,13)+ u2_14_15 = (14,15)+ u3_13_15 = (13,15)+ u4_12_15 = (12,15)+ u8_8_15 = (8,15)+ u2_12_13 = (12,13)u1_12 = (12,12)- u4_8.11 = (8,11)- u8_4.11 = (4,11)- s4_8.11 = (8,11) signed- u2_6.7 = (6,7)- u3_5.7 = (5,7)- u4_4.7 = (4,7)- s4_4.7 = (4,7)- u2_4.5 = (4,5)+ u4_8_11 = (8,11)+ u8_4_11 = (4,11)+ s4_8_11 = (8,11) signed+ u2_6_7 = (6,7)+ u3_5_7 = (5,7)+ u4_4_7 = (4,7)+ s4_4_7 = (4,7)+ u2_4_5 = (4,5)u1_4 = (4,4);@@ -83,17 +121,96 @@ define token narrowinsn(16)n_at = (4,7)n_op0 = (0, 3)- n_u4_12.15 = (12,15)- n_s4_12.15 = (12,15) signed- n_u4_8.11 = (8,11)+ n_u4_12_15 = (12,15)+ n_s4_12_15 = (12,15) signed+ n_u4_8_11 = (8,11)n_u1_7 = (7,7)- n_u2_6.7 = (6,7)- n_u4_4.7 = (4,7)- n_s3_4.6 = (4,6)- n_u2_4.5 = (4,5)+ n_u2_6_7 = (6,7)+ n_u4_4_7 = (4,7)+ n_s3_4_6 = (4,6)+ n_u2_4_5 = (4,5)+;++define token opbyte (8)+ op0_8 = (0,7)+;+define token opword (16)+ op0_16 = (0,15);+attach variables [ sr ] [+# 0x...0 0x...4 0x...8 0x...c+ LBEG LEND LCOUNT SAR # 0x0_+ BR LITBASE _ _ # 0x1_+ _ _ _ _ # 0x2_+ SCOMPARE1 _ _ _ # 0x3_+ ACCLO ACCHI _ _ # 0x4_+ _ _ _ _ # 0x5_+ _ _ _ _ # 0x6_+ _ _ _ _ # 0x7_+ M0 M1 M2 M3 # 0x8_+ _ _ _ _ # 0x9_+ _ _ _ _ # 0xa_+ _ _ _ _ # 0xb_+ _ _ _ _ # 0xc_+ _ _ _ _ # 0xd_+ _ _ _ _ # 0xe_+ _ _ _ _ # 0xf_+# 0x...0 0x...4 0x...8 0x...c+ _ _ _ _ # 0x10_+ _ _ _ _ # 0x11_+ WindowBase WindowStart _ _ # 0x12_+ _ _ _ _ # 0x13_+ _ _ _ PTEVADDR # 0x14_+ _ _ _ _ # 0x15_+ _ MMID RASID ITLBCFG # 0x16_+ DTLBCFG _ _ _ # 0x17_+ IBREAKENABLE MEMCTL CACHEATTR ATOMCTL # 0x18_+ _ _ _ _ # 0x19_+ DDR _ MEPC MEPS # 0x1a_+ MESAVE MESR MECR MEVADDR # 0x1b_+ _ _ _ _ # 0x1c_+ _ _ _ _ # 0x1d_+ _ _ _ _ # 0x1e_+ _ _ _ _ # 0x1f_+# 0x...0 0x...4 0x...8 0x...c+ IBREAKA0 IBREAKA1 _ _ # 0x20_+ _ _ _ _ # 0x21_+ _ _ _ _ # 0x22_+ _ _ _ _ # 0x23_+ DBREAKA0 DBREAKA1 _ _ # 0x24_+ _ _ _ _ # 0x25_+ _ _ _ _ # 0x26_+ _ _ _ _ # 0x27_+ DBREAKC0 DBREAKC1 _ _ # 0x28_+ _ _ _ _ # 0x29_+ _ _ _ _ # 0x2a_+ _ _ _ _ # 0x2b_+ _ EPC1 EPC2 EPC3 # 0x2c_+ EPC4 EPC5 EPC6 EPC7 # 0x2d_+ _ _ _ _ # 0x2e_+ _ _ _ _ # 0x2f_+# 0x...0 0x...4 0x...8 0x...c+ DEPC _ EPS2 EPS3 # 0x30_+ EPS4 EPS5 EPS6 EPS7 # 0x31_+ _ _ _ _ # 0x32_+ _ _ _ _ # 0x33_+ _ EXCSAVE1 EXCSAVE2 EXCSAVE3 # 0x34_+ EXCSAVE4 EXCSAVE5 EXCSAVE6 EXCSAVE7 # 0x35_+ _ _ _ _ # 0x36_+ _ _ _ _ # 0x37_+ CPENABLE INTERRUPT INTSET INTCLEAR # 0x38_+ INTENABLE _ PS VECBASE # 0x39_+ EXCCAUSE DEBUGCAUSE CCOUNT PRID # 0x3a_+ ICOUNT ICOUNTLEVEL EXCVADDR _ # 0x3b_+ CCOMPARE0 CCOMPARE1 CCOMPARE2 _ # 0x3c_+ MISC0 MISC1 MISC2 MISC3 # 0x3d_+ _ _ _ _ # 0x3e_+ _ _ _ _ # 0x3f_+# 0x...0 0x...4 0x...8 0x...c+];+attach variables [ ar as at n_ar n_as n_at ] [a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15];@@ -106,68 +223,146 @@ attach variables [ br bs bt ] [b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 b10 b11 b12 b13 b14 b15];+attach variables [ u8_8_15 ] [+# 0x...0 0x...4 0x...8 0x...c+ LBEG LEND LCOUNT SAR # 0x0_+ BR LITBASE _ _ # 0x1_+ _ _ _ _ # 0x2_+ SCOMPARE1 _ _ _ # 0x3_+ ACCLO ACCHI _ _ # 0x4_+ _ _ _ _ # 0x5_+ _ _ _ _ # 0x6_+ _ _ _ _ # 0x7_+ M0 M1 M2 M3 # 0x8_+ _ _ _ _ # 0x9_+ _ _ _ _ # 0xa_+ _ _ _ _ # 0xb_+ _ _ _ _ # 0xc_+ _ _ _ _ # 0xd_+ _ _ _ _ # 0xe_+ _ _ _ _ # 0xf_+# 0x...0 0x...4 0x...8 0x...c+ _ _ _ _ # 0x10_+ _ _ _ _ # 0x11_+ WindowBase WindowStart _ _ # 0x12_+ _ _ _ _ # 0x13_+ _ _ _ PTEVADDR # 0x14_+ _ _ _ _ # 0x15_+ _ MMID RASID ITLBCFG # 0x16_+ DTLBCFG _ _ _ # 0x17_+ IBREAKENABLE MEMCTL CACHEATTR ATOMCTL # 0x18_+ _ _ _ _ # 0x19_+ DDR _ MEPC MEPS # 0x1a_+ MESAVE MESR MECR MEVADDR # 0x1b_+ _ _ _ _ # 0x1c_+ _ _ _ _ # 0x1d_+ _ _ _ _ # 0x1e_+ _ _ _ _ # 0x1f_+# 0x...0 0x...4 0x...8 0x...c+ IBREAKA0 IBREAKA1 _ _ # 0x20_+ _ _ _ _ # 0x21_+ _ _ _ _ # 0x22_+ _ _ _ _ # 0x23_+ DBREAKA0 DBREAKA1 _ _ # 0x24_+ _ _ _ _ # 0x25_+ _ _ _ _ # 0x26_+ _ _ _ _ # 0x27_+ DBREAKC0 DBREAKC1 _ _ # 0x28_+ _ _ _ _ # 0x29_+ _ _ _ _ # 0x2a_+ _ _ _ _ # 0x2b_+ _ EPC1 EPC2 EPC3 # 0x2c_+ EPC4 EPC5 EPC6 EPC7 # 0x2d_+ _ _ _ _ # 0x2e_+ _ _ _ _ # 0x2f_+# 0x...0 0x...4 0x...8 0x...c+ DEPC _ EPS2 EPS3 # 0x30_+ EPS4 EPS5 EPS6 EPS7 # 0x31_+ _ _ _ _ # 0x32_+ _ _ _ _ # 0x33_+ _ EXCSAVE1 EXCSAVE2 EXCSAVE3 # 0x34_+ EXCSAVE4 EXCSAVE5 EXCSAVE6 EXCSAVE7 # 0x35_+ _ _ _ _ # 0x36_+ _ _ _ _ # 0x37_+ CPENABLE INTERRUPT INTSET INTCLEAR # 0x38_+ INTENABLE _ PS VECBASE # 0x39_+ EXCCAUSE DEBUGCAUSE CCOUNT PRID # 0x3a_+ ICOUNT ICOUNTLEVEL EXCVADDR _ # 0x3b_+ CCOMPARE0 CCOMPARE1 CCOMPARE2 _ # 0x3c_+ MISC0 MISC1 MISC2 MISC3 # 0x3d_+ _ _ _ _ # 0x3e_+ _ _ _ _ # 0x3f_+# 0x...0 0x...4 0x...8 0x...c+];+# Various 32-bit pointers relative to PC. Any operands that are split across non-consecutive# bits are named foo_LL.LM_ML.MM, where LL is the least significant bits of the least# singificant operand half, LM the most significant bits of the least significant operand half, etc.-urel_16.23: rel is u8_16.23 [ rel = inst_start + u8_16.23 + 4; ] { export *:4 rel; }+urel_16_23: rel is u8_16_23 [ rel = inst_start + u8_16_23 + 4; ] { export *:4 rel; }-srel_16.23: rel is s8_16.23 [ rel = inst_start + s8_16.23 + 4; ] { export *:4 rel; }+srel_16_23: rel is s8_16_23 [ rel = inst_start + s8_16_23 + 4; ] { export *:4 rel; }-srel_12.23: rel is s12_12.23 [ rel = inst_start + s12_12.23 + 4; ] { export *:4 rel; }+srel_12_23: rel is s12_12_23 [ rel = inst_start + s12_12_23 + 4; ] { export *:4 rel; }-srel_6.23: rel is s8_6.23 [ rel = inst_start + s8_6.23 + 4; ] { export *:4 rel; }+srel_6_23: rel is s8_6_23 [ rel = inst_start + s8_6_23 + 4; ] { export *:4 rel; }-urel_12.15_4.5: rel is n_u2_4.5 & n_u4_12.15 [- rel = inst_start + ((n_u2_4.5 << 4) | n_u4_12.15) + 4;+urel_12_15_4_5: rel is n_u2_4_5 & n_u4_12_15 [+ rel = inst_start + ((n_u2_4_5 << 4) | n_u4_12_15) + 4;] { export *:4 rel; }-srel_6.23_sb2: rel is s8_6.23 [- rel = (inst_start & ~3) + ( s8_6.23 << 2 ) + 4;+srel_6_23_sb2: rel is s8_6_23 [+ rel = (inst_start & ~3) + ( s8_6_23 << 2 ) + 4;] { export *:4 rel; }-srel_8.23_oex_sb2: rel is u16_8.23 [- rel = ((inst_start + 3) & ~3) + ((u16_8.23 | 0xffff0000) << 2);+srel_8_23_oex_sb2: rel is u16_8_23 [+ rel = ((inst_start + 3) & ~3) + ((u16_8_23 | 0xfffc0000) << 2);+ # Below might indicate firmware specific:+ # rel = 0x9fa000 + 0x40000 + ((u16_8_23 | 0xffff0000) << 2);] { export *:4 rel; }# Immediates split across the instruction.-u5_8.11_20: tmp is u1_20 & u4_8.11 [ tmp = (u1_20 << 4) | u4_8.11; ] { export *[const]:1 tmp; }-u5_4.7_20: tmp is u1_20 & u4_4.7 [ tmp = (u1_20 << 4) | u4_4.7; ] { export *[const]:1 tmp; }-u5_8.11_16: tmp is u1_16 & u4_8.11 [ tmp = (u1_16 << 4) | u4_8.11; ] { export *[const]:1 tmp; }-u5_4.7_12: tmp is u1_12 & u4_4.7 [ tmp = (u1_12 << 4) | u4_4.7; ] { export *[const]:1 tmp; }-u5_8.11_4: tmp is u1_4 & u4_8.11 [ tmp = (u1_4 << 4) | u4_8.11; ] { export *[const]:1 tmp; }+u5_8_11_20: tmp is u1_20 & u4_8_11 [ tmp = (u1_20 << 4) | u4_8_11; ] { export *[const]:1 tmp; }+u5_4_7_20: tmp is u1_20 & u4_4_7 [ tmp = (u1_20 << 4) | u4_4_7; ] { export *[const]:1 tmp; }+u5_8_11_16: tmp is u1_16 & u4_8_11 [ tmp = (u1_16 << 4) | u4_8_11; ] { export *[const]:1 tmp; }+u5_4_7_12: tmp is u1_12 & u4_4_7 [ tmp = (u1_12 << 4) | u4_4_7; ] { export *[const]:1 tmp; }+u5_8_11_4: tmp is u1_4 & u4_8_11 [ tmp = (u1_4 << 4) | u4_8_11; ] { export *[const]:1 tmp; }# Signed 12-bit (extended to 16) immediate, used by MOVI.-s16_16.23_8.11: tmp is s4_8.11 & u8_16.23 [- tmp = (s4_8.11 << 8) | u8_16.23;+s16_16_23_8_11: tmp is s4_8_11 & u8_16_23 [+ tmp = (s4_8_11 << 8) | u8_16_23;] { export *[const]:2 tmp; }# An “asymmetric” immediate from -32..95, used by MOVI.N.-n_s8_12.15_4.6_asymm: tmp is n_s3_4.6 & n_s4_12.15 [- tmp = ((((n_s3_4.6 & 7) << 4) | (n_s4_12.15 & 15)) |- ((((n_s3_4.6 >> 2) & 1) & ((n_s3_4.6 >> 1) & 1)) << 7));+n_s8_12_15_4_6_asymm: tmp is n_s3_4_6 & n_s4_12_15 [+ tmp = ((((n_s3_4_6 & 7) << 4) | (n_s4_12_15 & 15)) |+ ((((n_s3_4_6 >> 2) & 1) & ((n_s3_4_6 >> 1) & 1)) << 7));] { export *[const]:1 tmp; }# Immediates shifted or with offset.-s16_16.23_sb8: tmp is s8_16.23 [ tmp = s8_16.23 << 8; ] { export *[const]:2 tmp; }-u15_12.23_sb3: tmp is u12_12.23 [ tmp = u12_12.23 << 3; ] { export *[const]:2 tmp; }-u10_16.23_sb2: tmp is u8_16.23 [ tmp = u8_16.23 << 2; ] { export *[const]:2 tmp; }-u9_16.23_sb1: tmp is u8_16.23 [ tmp = u8_16.23 << 1; ] { export *[const]:2 tmp; }-u5_20.23_plus1: tmp is u4_20.23 [ tmp = u4_20.23 + 1; ] { export *[const]:1 tmp; }-u8_20.23_sb4: tmp is u4_20.23 [ tmp = u4_20.23 << 4; ] { export *[const]:1 tmp; }-u5_4.7_plus7: tmp is u4_4.7 [ tmp = u4_4.7 + 7; ] { export *[const]:1 tmp; }+s16_16_23_sb8: tmp is s8_16_23 [ tmp = s8_16_23 << 8; ] { export *[const]:2 tmp; }+u15_12_23_sb3: tmp is u12_12_23 [ tmp = u12_12_23 << 3; ] { export *[const]:2 tmp; }+u10_16_23_sb2: tmp is u8_16_23 [ tmp = u8_16_23 << 2; ] { export *[const]:2 tmp; }+u9_16_23_sb1: tmp is u8_16_23 [ tmp = u8_16_23 << 1; ] { export *[const]:2 tmp; }+u5_20_23_plus1: tmp is u4_20_23 [ tmp = u4_20_23 + 1; ] { export *[const]:1 tmp; }+u8_20.23_sb4: tmp is u4_20_23 [ tmp = u4_20_23 << 4; ] { export *[const]:1 tmp; }+u5_4_7_plus7: tmp is u4_4_7 [ tmp = u4_4_7 + 7; ] { export *[const]:1 tmp; }-n_u6_12.15_sb2: tmp is n_u4_12.15 [ tmp = n_u4_12.15 << 2; ] { export *[const]:1 tmp; }+n_u6_12_15_sb2: tmp is n_u4_12_15 [ tmp = n_u4_12_15 << 2; ] { export *[const]:1 tmp; }# One-extended. FIXME: Verify this. Only used by [LS]32E (window extension), which aren’t yet# implemented.-s5_12.15_oex: tmp is u4_12.15 [ tmp = (2 << u4_12.15) * -1; ] { export *[const]:2 tmp; }+s5_12_15_oex: tmp is u4_12_15 [ tmp = (2 << u4_12_15) * -1; ] { export *[const]:2 tmp; }# Some 4-bit immediates with mappings that can’t be (easily) expressed in a single disassembly action.-# n_u4_4.7 with 0 being -1, used by ADDI.N.-n_s4_4.7_nozero: tmp is n_u4_4.7 = 0 [ tmp = -1; ] { export *[const]:4 tmp; }-n_s4_4.7_nozero: tmp is n_u4_4.7 [ tmp = n_u4_4.7+0; ] { export *[const]:4 tmp; }+# n_u4_4_7 with 0 being -1, used by ADDI.N.+n_s4_4_7_nozero: tmp is n_u4_4_7 = 0 [ tmp = -1; ] { export *[const]:4 tmp; }+n_s4_4_7_nozero: tmp is n_u4_4_7 [ tmp = n_u4_4_7+0; ] { export *[const]:4 tmp; }++# imm stored in sa for slli is 32-shift.+# TODO why can't we use subtable output for this instead of repeating u5_4_7_20 calc?+u5_4_7_20_slli: tmp is u1_20 & u4_4_7 [ tmp = 32 - ((u1_20 << 4) | u4_4_7); ] { export *[const]:1 tmp; }# B4CONST(ar) (Branch Immediate) encodings, pg. 41 f.r_b4const: tmp is ar = 0 [ tmp = 0xffffffff; ] { export *[const]:4 tmp; }@@ -238,7 +433,6 @@ define pcodeop ldct;define pcodeop lict;define pcodeop licw;define pcodeop memw;-define pcodeop nsa;define pcodeop pdtlb;define pcodeop pitlb;define pcodeop rdtlb0;diff --git a/Ghidra/Processors/Xtensa/data/languages/xtensa.slaspec b/Ghidra/Processors/Xtensa/data/languages/xtensa.slaspecindex 16a64f3f6e..523420d04f 100644--- a/Ghidra/Processors/Xtensa/data/languages/xtensa.slaspec+++ b/Ghidra/Processors/Xtensa/data/languages/xtensa.slaspec@@ -1,3 +1,25 @@@include "xtensa.sinc"++# NOTE: This is quite a big hack; a real processor will compare nextPC to LEND on every ifetch.+# As we only inject the branch-back check on addresses marked by loop insns, we may miss+# strange things like loop registers being written directly or loop registers being overwritten+# by a "nested" loop instruction. We also don't check CLOOPENABLE (PS.EXCM).+# For code that hasn't been intentially crafted for anti-analysis this should be fine.+:^instruction is phase=0 & loopEnd=1 & instruction [phase=1;] {+ if (LCOUNT == 0) goto <done>;+ LCOUNT = LCOUNT - 1;+ goto [LBEG];+ <done>+ build instruction;+}++:^instruction is phase=0 & loopEnd=0 & instruction [phase=1;] {+ build instruction;+}++with : phase=1 {@include "xtensaInstructions.sinc"-@include "xtensaTodo.sinc"+}++# TODO: Evaluate+# @include "xtensaTodo.sinc"diff --git a/Ghidra/Processors/Xtensa/data/languages/xtensaInstructions.sinc b/Ghidra/Processors/Xtensa/data/languages/xtensaInstructions.sincindex e3e4766a66..027733a3bc 100644--- a/Ghidra/Processors/Xtensa/data/languages/xtensaInstructions.sinc+++ b/Ghidra/Processors/Xtensa/data/languages/xtensaInstructions.sinc@@ -27,18 +27,18 @@}# ADDI - Add Immediate (RRI8), pg. 251.-:addi at, as, s8_16.23 is s8_16.23 & ar = 0b1100 & as & at & op0 = 0b0010 {- at = as + sext(s8_16.23:1);+:addi at, as, s8_16_23 is s8_16_23 & ar = 0b1100 & as & at & op0 = 0b0010 {+ at = as + s8_16_23;}# ADDI.N - Narrow Add Immediate (RRRN), pg. 252.-:addi.n n_ar, n_as, n_s4_4.7_nozero is n_ar & n_as & n_s4_4.7_nozero & n_op0 = 0b1011 {- n_ar = n_as + n_s4_4.7_nozero;+:addi.n n_ar, n_as, n_s4_4_7_nozero is n_ar & n_as & n_s4_4_7_nozero & n_op0 = 0b1011 {+ n_ar = n_as + n_s4_4_7_nozero;}# ADDMI - Add Immediate with Shift by 8, pg. 253.-:addmi at, as, s16_16.23_sb8 is s16_16.23_sb8 & ar = 0b1101 & as & at & op0 = 0b0010 {- at = as + sext(s16_16.23_sb8);+:addmi at, as, s16_16_23_sb8 is s16_16_23_sb8 & ar = 0b1101 & as & at & op0 = 0b0010 {+ at = as + sext(s16_16_23_sb8);}# ADDX2 - Add with Shift by 1, pg. 254.@@ -112,15 +112,15 @@}# BALL - Branch if All Bits Set, pg. 264.-:ball srel_16.23, as, at is srel_16.23 & ar = 0b0100 & as & at & op0 = 0b0111 {+:ball srel_16_23, as, at is srel_16_23 & ar = 0b0100 & as & at & op0 = 0b0111 {if ((~as & at) == 0)- goto srel_16.23;+ goto srel_16_23;}# BANY - Branch if Any Bit Set, pg. 265.-:bany srel_16.23, as, at, is srel_16.23 & ar = 0b1000 & as & at & op0 = 0b0111 {+:bany srel_16_23, as, at, is srel_16_23 & ar = 0b1000 & as & at & op0 = 0b0111 {if ((as & at) != 0)- goto srel_16.23;+ goto srel_16_23;}macro extract_bit(val, bit, result) {@@ -128,203 +128,290 @@ macro extract_bit(val, bit, result) {}# BBC - Branch if Bit Clear, pg. 266.-:bbc as, at, srel_16.23 is srel_16.23 & ar = 0b0101 & as & at & op0 = 0b0111 {+:bbc as, at, srel_16_23 is srel_16_23 & ar = 0b0101 & as & at & op0 = 0b0111 {local bval;extract_bit(as, at[0,5], bval);if (bval == 0)- goto srel_16.23;+ goto srel_16_23;}# BBCI - Branch if Bit Clear immediate, pg. 267-:bbci as, u5_4.7_12, srel_16.23 is srel_16.23 & u3_13.15 = 0b011 & as & u5_4.7_12 & op0 = 0b0111 {+:bbci as, u5_4_7_12, srel_16_23 is srel_16_23 & u3_13_15 = 0b011 & as & u5_4_7_12 & op0 = 0b0111 {local bval;- extract_bit(as, u5_4.7_12, bval);+ extract_bit(as, u5_4_7_12, bval);if (bval == 0)- goto srel_16.23;+ goto srel_16_23;}# BBS - Branch if Bit Set, pg. 269.-:bbs as, at, srel_16.23 is srel_16.23 & ar = 0b1101 & as & at & op0 = 0b0111 {+:bbs as, at, srel_16_23 is srel_16_23 & ar = 0b1101 & as & at & op0 = 0b0111 {local bval;extract_bit(as, at[0,5], bval);if (bval != 0)- goto srel_16.23;+ goto srel_16_23;}# BBSI - Branch if Bit Set immediate, pg. 270.-:bbsi as, u5_4.7_12, srel_16.23 is srel_16.23 & u3_13.15 = 0b111 & as & u5_4.7_12 & op0 = 0b0111 {+:bbsi as, u5_4_7_12, srel_16_23 is srel_16_23 & u3_13_15 = 0b111 & as & u5_4_7_12 & op0 = 0b0111 {local bval;- extract_bit(as, u5_4.7_12, bval);- if (bval == 0)- goto srel_16.23;+ extract_bit(as, u5_4_7_12, bval);+ if (bval != 0)+ goto srel_16_23;}# BEQ - Branch if Equal, pg. 272.-:beq as, at, srel_16.23 is srel_16.23 & ar = 0b0001 & as & at & op0 = 0b0111 {+:beq as, at, srel_16_23 is srel_16_23 & ar = 0b0001 & as & at & op0 = 0b0111 {if (as == at)- goto srel_16.23;+ goto srel_16_23;}# BEQI - Branch if Equal Immediate, pg. 273.-:beqi as, r_b4const, srel_16.23 is srel_16.23 & r_b4const & as & u2_6.7 = 0 & u2_4.5 = 0b10 & op0 = 0b0110 {+:beqi as, r_b4const, srel_16_23 is srel_16_23 & r_b4const & as & u2_6_7 = 0 & u2_4_5 = 0b10 & op0 = 0b0110 {if (as == r_b4const)- goto srel_16.23;+ goto srel_16_23;}# BEQZ - Branch if Equal Zero, pg. 274.-:beqz as, srel_12.23 is srel_12.23 & as & u2_6.7 = 0 & u2_4.5 = 0b01 & op0 = 0b0110 {+:beqz as, srel_12_23 is srel_12_23 & as & u2_6_7 = 0 & u2_4_5 = 0b01 & op0 = 0b0110 {if (as == 0)- goto srel_12.23;+ goto srel_12_23;}# BEQZ.N - Narrow Branch if Equal Zero, pg. 275.-:beqz.n n_as, urel_12.15_4.5 is urel_12.15_4.5 & n_as & n_u2_6.7 = 0b10 & n_op0 = 0b1100 {+:beqz.n n_as, urel_12_15_4_5 is urel_12_15_4_5 & n_as & n_u2_6_7 = 0b10 & n_op0 = 0b1100 {if (n_as == 0)- goto urel_12.15_4.5;+ goto urel_12_15_4_5;}# BF - Branch if False, pg. 276.-:bf bs, srel_16.23 is srel_16.23 & ar = 0 & bs & at = 0b0111 & op0 = 0b0110 {+:bf bs, srel_16_23 is srel_16_23 & ar = 0 & bs & at = 0b0111 & op0 = 0b0110 {if (!bs)- goto srel_16.23;+ goto srel_16_23;}# BGE - Branch if Greater Than or Equal, pg. 277.-:bge as, at, srel_16.23 is srel_16.23 & ar = 0b1010 & as & at & op0 = 0b0111 {+:bge as, at, srel_16_23 is srel_16_23 & ar = 0b1010 & as & at & op0 = 0b0111 {if (as s>= at)- goto srel_16.23;+ goto srel_16_23;}# BGEI - Branch if Greater Than or Equal Immediate, pg. 278.-:bgei as, r_b4const, srel_16.23 is srel_16.23 & r_b4const & as & u2_6.7 = 0b11 & u2_4.5 = 0b10 & op0 = 0b0110 {+:bgei as, r_b4const, srel_16_23 is srel_16_23 & r_b4const & as & u2_6_7 = 0b11 & u2_4_5 = 0b10 & op0 = 0b0110 {if (as s>= r_b4const)- goto srel_16.23;+ goto srel_16_23;}# BGEU - Branch if Greater Than or Equal Unsigned, pg. 279.-:bgeu as, at, srel_16.23 is srel_16.23 & ar = 0b1011 & as & at & op0 = 0b0111 {+:bgeu as, at, srel_16_23 is srel_16_23 & ar = 0b1011 & as & at & op0 = 0b0111 {if (as >= at)- goto srel_16.23;+ goto srel_16_23;}# BGEUI - Branch if Greater Than or Equal Unsigned Immediate, pg. 280.-:bgeui as, r_b4constu, srel_16.23 is srel_16.23 & r_b4constu & as & u2_6.7 = 0b11 & u2_4.5 = 0b11 & op0 = 0b0110 {+:bgeui as, r_b4constu, srel_16_23 is srel_16_23 & r_b4constu & as & u2_6_7 = 0b11 & u2_4_5 = 0b11 & op0 = 0b0110 {if (as >= r_b4constu)- goto srel_16.23;+ goto srel_16_23;}# BGEZ - Branch if Greater Than or Equal Zero, pg. 281.-:bgez as, srel_12.23 is srel_12.23 & as & u2_6.7 = 0b11 & u2_4.5 = 0b01 & op0 = 0b0110 {+:bgez as, srel_12_23 is srel_12_23 & as & u2_6_7 = 0b11 & u2_4_5 = 0b01 & op0 = 0b0110 {if (as s>= 0)- goto srel_12.23;+ goto srel_12_23;}# BLT - Branch if Less Than, pg. 282.-:blt as, at, srel_16.23 is srel_16.23 & ar = 0b0010 & as & at & op0 = 0b0111 {+:blt as, at, srel_16_23 is srel_16_23 & ar = 0b0010 & as & at & op0 = 0b0111 {if (as s< at)- goto srel_16.23;+ goto srel_16_23;}# BLTI - Branch if Less Than Immediate, pg. 283.-:blti as, r_b4const, srel_16.23 is srel_16.23 & r_b4const & as & u2_6.7 = 0b10 & u2_4.5 = 0b10 & op0 = 0b0110 {+:blti as, r_b4const, srel_16_23 is srel_16_23 & r_b4const & as & u2_6_7 = 0b10 & u2_4_5 = 0b10 & op0 = 0b0110 {if (as s< r_b4const)- goto srel_16.23;+ goto srel_16_23;}# BLTU - Branch if Less Than Unsigned, pg. 284.-:bltu as, at, srel_16.23 is srel_16.23 & ar = 0b0011 & as & at & op0 = 0b0111 {+:bltu as, at, srel_16_23 is srel_16_23 & ar = 0b0011 & as & at & op0 = 0b0111 {if (as < at)- goto srel_16.23;+ goto srel_16_23;}# BLTUI - Branch if Less Than Unsigned Immediate, pg. 285.-:bltui as, r_b4constu, srel_16.23 is srel_16.23 & r_b4constu & as & u2_6.7 = 0b10 & u2_4.5 = 0b11 & op0 = 0b0110 {+:bltui as, r_b4constu, srel_16_23 is srel_16_23 & r_b4constu & as & u2_6_7 = 0b10 & u2_4_5 = 0b11 & op0 = 0b0110 {if (as < r_b4constu)- goto srel_16.23;+ goto srel_16_23;}# BLTZ - Branch if Less Than Zero, pg. 286.-:bltz as, srel_12.23 is srel_12.23 & as & u2_6.7 = 0b10 & u2_4.5 = 0b01 & op0 = 0b0110 {+:bltz as, srel_12_23 is srel_12_23 & as & u2_6_7 = 0b10 & u2_4_5 = 0b01 & op0 = 0b0110 {if (as s< 0)- goto srel_12.23;+ goto srel_12_23;}# BNALL - Branch if Not-All Bits Set, pg. 287.-:bnall srel_16.23, as, at is srel_16.23 & ar = 0b1100 & as & at & op0 = 0b0111 {+:bnall srel_16_23, as, at is srel_16_23 & ar = 0b1100 & as & at & op0 = 0b0111 {if ((~as & at) != 0)- goto srel_16.23;+ goto srel_16_23;}# BNE - Branch if Not Equal, pg. 288.-:bne as, at, srel_16.23 is srel_16.23 & ar = 0b1001 & as & at & op0 = 0b0111 {+:bne as, at, srel_16_23 is srel_16_23 & ar = 0b1001 & as & at & op0 = 0b0111 {if (as != at)- goto srel_16.23;+ goto srel_16_23;}# BNEI - Branch if Not EquaL Immediate, pg. 289.-:bnei as, r_b4const, srel_16.23 is srel_16.23 & r_b4const & as & u2_6.7 = 0b01 & u2_4.5 = 0b10 & op0 = 0b0110 {+:bnei as, r_b4const, srel_16_23 is srel_16_23 & r_b4const & as & u2_6_7 = 0b01 & u2_4_5 = 0b10 & op0 = 0b0110 {if (as != r_b4const)- goto srel_16.23;+ goto srel_16_23;}# BNEZ - Branch if Not Equal Zero, pg. 290.-:bnez as, srel_12.23 is srel_12.23 & as & u2_6.7 = 0b01 & u2_4.5 = 0b01 & op0 = 0b0110 {+:bnez as, srel_12_23 is srel_12_23 & as & u2_6_7 = 0b01 & u2_4_5 = 0b01 & op0 = 0b0110 {if (as != 0)- goto srel_12.23;+ goto srel_12_23;}# BNEZ.N - Narrow Branch if Not Equal Zero, pg. 291.-:bnez.n n_as, urel_12.15_4.5 is urel_12.15_4.5 & n_as & n_u2_6.7 = 0b11 & n_op0 = 0b1100 {+:bnez.n n_as, urel_12_15_4_5 is urel_12_15_4_5 & n_as & n_u2_6_7 = 0b11 & n_op0 = 0b1100 {if (n_as != 0)- goto urel_12.15_4.5;+ goto urel_12_15_4_5;}# BNONE - Branch if No Bit Set, pg. 292.-:bnone srel_16.23, as, at, is srel_16.23 & ar = 0 & as & at & op0 = 0b0111 {+:bnone srel_16_23, as, at, is srel_16_23 & ar = 0 & as & at & op0 = 0b0111 {if ((as & at) == 0)- goto srel_16.23;+ goto srel_16_23;}# BREAK - Breakpoint, pg. 293.-:break u4_8.11, u4_4.7 is op2 = 0 & op1 = 0 & ar = 0b0100 & u4_8.11 & u4_4.7 & op0 = 0 {- breakpoint(0x001000:4, u4_8.11:1, u4_4.7:1);+:break u4_8_11, u4_4_7 is op2 = 0 & op1 = 0 & ar = 0b0100 & u4_8_11 & u4_4_7 & op0 = 0 {+ breakpoint(0x001000:4, u4_8_11:1, u4_4_7:1);}# BREAK.N - Narrow Breakpoint, pg. 295.-:break.n n_u4_8.11 is n_ar = 0b1111 & n_u4_8.11 & n_at = 0b0010 & n_op0 = 0b1101 {- breakpoint(0x010000:4, n_u4_8.11:1, 0:1);+:break.n n_u4_8_11 is n_ar = 0b1111 & n_u4_8_11 & n_at = 0b0010 & n_op0 = 0b1101 {+ breakpoint(0x010000:4, n_u4_8_11:1, 0:1);}# BT - Branch if True, pg. 296.-:bt bs, srel_16.23 is srel_16.23 & ar = 0b0001 & bs & at = 0b0111 & op0 = 0b0110 {+:bt bs, srel_16_23 is srel_16_23 & ar = 0b0001 & bs & at = 0b0111 & op0 = 0b0110 {if (bs)- goto srel_16.23;+ goto srel_16_23;}# CALL0 - Non-windowed Call, pg. 297.-:call0 srel_6.23_sb2 is srel_6.23_sb2 & u2_4.5 = 0 & op0 = 0b0101 {+:call0 srel_6_23_sb2 is srel_6_23_sb2 & u2_4_5 = 0 & op0 = 0b0101 {+ #local dst = srel_6_23_sb2;+ i2 = a2;+ i3 = a3;+ i4 = a4;+ i5 = a5;+ i6 = a6;+ i7 = a7;+ a0 = inst_start + 3;+ call srel_6_23_sb2;+}++# CALL4 - Call PC-relative, Rotate Window by 4, pg. 298.+:call4 srel_6_23_sb2 is srel_6_23_sb2 & u2_4_5 = 0b01 & op0 = 0b0101 {+ #local dst = srel_6_23_sb2;+ i2=a6;+ i3=a7;+ i4=a8;+ i5=a9;+ a0 = inst_start + 3;+ call srel_6_23_sb2;+ a6=o2;+}++# CALL8 - Call PC-relative, Rotate Window by 8, pg. 300.+:call8 srel_6_23_sb2 is srel_6_23_sb2 & u2_4_5 = 0b10 & op0 = 0b0101 {+ #local dst:4 =+ i2=a10;+ i3=a11;+ i4=a12;+ i5=a13;+ i6=a14;+ i7=a15;+ a0 = inst_start + 3;+ call srel_6_23_sb2;+ a10=o2;+}++# CALL12 - Call PC-relative, Rotate Window by 12, pg. 302.+:call12 srel_6_23_sb2 is srel_6_23_sb2 & u2_4_5 = 0b11 & op0 = 0b0101 {+ #local dst = srel_6_23_sb2;+ i2=a14;+ i3=a15;a0 = inst_start + 3;- call srel_6.23_sb2;+ call srel_6_23_sb2;+ a14=o2;}# CALLX0 - Non-windowed Call Register, pg. 304.-:callx0 as is op2 = 0 & op1 = 0 & ar = 0 & as & u2_6.7 = 0b11 & u2_4.5 = 0 & op0 = 0 {+:callx0 as is op2 = 0 & op1 = 0 & ar = 0 & as & u2_6_7 = 0b11 & u2_4_5 = 0 & op0 = 0 {local dst = as;+ i2 = a2;+ i3 = a3;+ i4 = a4;+ i5 = a5;+ i6 = a6;+ i7 = a7;a0 = inst_start + 3;call [dst];}+# CALLX4 - Call Register, Rotate Window by 4, pg. 305.+:callx4 as is op2 = 0 & op1 = 0 & ar = 0 & as & u2_6_7 = 0b11 & u2_4_5 = 0b01 & op0 = 0 {+ local dst = as;+ i2=a6;+ i3=a7;+ i4=a8;+ i5=a9;+ i6=a10;+ i7=a11;+ a0 = inst_start + 3;+ call [dst];+ a6=o2;+}++# CALLX8 - Call Register, Rotate Window by 8, pg. 307.+:callx8 as is op2 = 0 & op1 = 0 & ar = 0 & as & u2_6_7 = 0b11 & u2_4_5 = 0b10 & op0 = 0 {+ local dst = as;+ i2=a10;+ i3=a11;+ i4=a12;+ i5=a13;+ i6=a14;+ i7=a15;+ a0 = inst_start + 3;+ call [dst];+ a10=o2;+}++# CALLX12 - Call Register, Rotate Window by 12, pg. 308.+:callx12 as is op2 = 0 & op1 = 0 & ar = 0 & as & u2_6_7 = 0b11 & u2_4_5 = 0b11 & op0 = 0 {+ local dst = as;+ i2=a14;+ i3=a15;+ a0 = inst_start + 3;+ call [dst];+ a14=o2;+}+# CEIL.S - Ceiling Single to Fixed, pg. 311.-:ceil.s ar, fs, u4_4.7 is op2 = 0b1011 & op1 = 0b1010 & ar & fs & u4_4.7 & op0 = 0 {- local scale:4 = int2float(1:1 << u4_4.7:1);+:ceil.s ar, fs, u4_4_7 is op2 = 0b1011 & op1 = 0b1010 & ar & fs & u4_4_7 & op0 = 0 {+ local scale:4 = int2float(1:1 << u4_4_7:1);ar = ceil(fs f* scale);}# CLAMPS - Signed Clamp, pg. 312.-:clamps ar, as, u5_4.7_plus7 is op2 = 0b0011 & op1 = 0b0011 & ar & as & u5_4.7_plus7 & op0 = 0 {- # ar ← min(max(as, -2^{u5_4.7_plus7}), 2^{u5_4.7_plus7}-1)- local maxval:4 = (1 << u5_4.7_plus7) - 1;- local minval:4 = -(1 << u5_4.7_plus7);+:clamps ar, as, u5_4_7_plus7 is op2 = 0b0011 & op1 = 0b0011 & ar & as & u5_4_7_plus7 & op0 = 0 {+ # ar ← min(max(as, -2^{u5_4_7_plus7}), 2^{u5_4_7_plus7}-1)+ local maxval:4 = (1 << u5_4_7_plus7) - 1;+ local minval:4 = -(1 << u5_4_7_plus7);if (as s< minval)goto <write_minval>;if (as s> maxval)@@ -343,8 +430,8 @@ macro extract_bit(val, bit, result) {}# DHI - Data Cache Hit Invalidate, pg. 313.-:dhi as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b0110 & op0 = 0b0010 {- dhi(as + zext(u10_16.23_sb2));+:dhi as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b0110 & op0 = 0b0010 {+ dhi(as + zext(u10_16_23_sb2));}# DHU - Data Cache Hit Unlock, pg. 315.@@ -353,18 +440,18 @@ macro extract_bit(val, bit, result) {}# DHWB - Data Cache Hit Writeback, pg. 317.-:dhwb as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b0100 & op0 = 0b0010 {- dhwb(as + zext(u10_16.23_sb2));+:dhwb as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b0100 & op0 = 0b0010 {+ dhwb(as + zext(u10_16_23_sb2));}# DHWBI - Data Cache Hit Writeback Invalidate, pg. 319.-:dhwbi as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b0101 & op0 = 0b0010 {- dhwbi(as + zext(u10_16.23_sb2));+:dhwbi as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b0101 & op0 = 0b0010 {+ dhwbi(as + zext(u10_16_23_sb2));}# DII - Data Cache Index Invalidate, pg. 321.-:dii as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b0111 & op0 = 0b0010 {- dii(as + zext(u10_16.23_sb2));+:dii as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b0111 & op0 = 0b0010 {+ dii(as + zext(u10_16_23_sb2));}# DIU - Data Cache Index Unlock, pg. 323.@@ -388,23 +475,23 @@ macro extract_bit(val, bit, result) {}# DPFR - Data Cache Prefetch for Read, pg. 331.-:dpfr as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0 & op0 = 0b0010 {- dpfr(as + zext(u10_16.23_sb2));+:dpfr as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0 & op0 = 0b0010 {+ dpfr(as + zext(u10_16_23_sb2));}# DPFRO - Data Cache Prefetch for Read Once, pg. 333.-:dpfro as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b0010 & op0 = 0b0010 {- dpfro(as + zext(u10_16.23_sb2));+:dpfro as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b0010 & op0 = 0b0010 {+ dpfro(as + zext(u10_16_23_sb2));}# DPFW - Data Cache Prefetch for Write, pg. 335.-:dpfw as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b0001 & op0 = 0b0010 {- dpfw(as + zext(u10_16.23_sb2));+:dpfw as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b0001 & op0 = 0b0010 {+ dpfw(as + zext(u10_16_23_sb2));}# DPFWO - Data Cache Prefetch for Write Once, pg. 337.-:dpfwo as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b0011 & op0 = 0b0010 {- dpfwo(as + zext(u10_16.23_sb2));+:dpfwo as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b0011 & op0 = 0b0010 {+ dpfwo(as + zext(u10_16_23_sb2));}# DSYNC - Load/Store Synchronize, pg. 339.@@ -412,6 +499,20 @@ macro extract_bit(val, bit, result) {dsync();}+# ENTRY - Subroutine Entry, pg. 340.+:entry as, u15_12_23_sb3 is u15_12_23_sb3 & as & u2_6_7 = 0b00 & u2_4_5 = 0b11 & op0 = 0b0110 {+ local amn = sext(u15_12_23_sb3);+ a2=i2;+ a3=i3;+ a4=i4;+ a5=i5;+ a6=i6;+ a7=i7;+ #as = as + amn;+ WindowBase = amn;+ a1 = a1 - amn;+}+# ESYNC - Execute Synchronize, pg. 342.:esync is op2 = 0 & op1 = 0 & ar = 0b0010 & as = 0 & at = 0b0010 & op0 = 0 {esync();@@ -423,9 +524,9 @@ macro extract_bit(val, bit, result) {}# EXTUI - Extract Unsigned Immediate, pg. 344.-:extui ar, at, u5_8.11_16, u5_20.23_plus1 is u5_20.23_plus1 & u3_17.19 = 0b010 & u5_8.11_16 & ar & at & op0 = 0 {- local shifted:4 = at >> u5_8.11_16;- local mask:4 = (1:4 << (u5_20.23_plus1))-1;+:extui ar, at, u5_8_11_16, u5_20_23_plus1 is u5_20_23_plus1 & u3_17_19 = 0b010 & u5_8_11_16 & ar & at & op0 = 0 {+ local shifted:4 = at >> u5_8_11_16;+ local mask:4 = (1:4 << (u5_20_23_plus1))-1;ar = shifted & mask;}@@ -435,15 +536,15 @@ macro extract_bit(val, bit, result) {}# FLOAT.S - Convert Fixed to Single, pg. 346.-:float.s fr, as, u4_4.7 is op2 = 0b1100 & op1 = 0b1010 & fr & as & u4_4.7 & op0 = 0 {+:float.s fr, as, u4_4_7 is op2 = 0b1100 & op1 = 0b1010 & fr & as & u4_4_7 & op0 = 0 {local f = int2float(as);- local d = int2float(1:2 << u4_4.7:2);+ local d = int2float(1:2 << u4_4_7:2);fr = d f/ f;}# FLOOR.S - Floor Single to Fixed, pg. 347.-:floor.s ar, fs, u4_4.7 is op2 = 0b1010 & op1 = 0b1010 & ar & fs & u4_4.7 & op0 = 0 {- local scale:4 = int2float(1:2 << u4_4.7:2);+:floor.s ar, fs, u4_4_7 is op2 = 0b1010 & op1 = 0b1010 & ar & fs & u4_4_7 & op0 = 0 {+ local scale:4 = int2float(1:2 << u4_4_7:2);ar = floor(fs f* scale);}@@ -453,8 +554,8 @@ macro extract_bit(val, bit, result) {}# IHI - Instruction Cache Hit Invalidate, pg. 349.-:ihi as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b1110 & op0 = 0b0010 {- ihi(as + zext(u10_16.23_sb2));+:ihi as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b1110 & op0 = 0b0010 {+ ihi(as + zext(u10_16_23_sb2));}# IHU - Instruction Cache Hit Unlock, pg. 351.@@ -463,8 +564,8 @@ macro extract_bit(val, bit, result) {}# III - Instruction Cache Index Invalidate, pg. 353.-:iii as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b1111 & op0 = 0b0010 {- iii(as + zext(u10_16.23_sb2));+:iii as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b1111 & op0 = 0b0010 {+ iii(as + zext(u10_16_23_sb2));}# IITLB - Invalidate Instruction TLB Entry, pg. 355.@@ -480,18 +581,16 @@ macro extract_bit(val, bit, result) {# ILL - Illegal Instruction, pg. 358.:ill is op2 = 0 & op1 = 0 & ar = 0 & as = 0 & at = 0 & op0 = 0 {ill();- goto inst_start;}# ILL.N - Narrow Illegal Instruction, pg. 359.:ill.n is n_ar = 0b1111 & n_as = 0 & n_at = 0b0110 & n_op0 = 0b1101 {ill();- goto inst_start;}# IPF - Instruction Cache Prefetch, pg. 360.-:ipf as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0111 & as & at = 0b1100 & op0 = 0b0010 {- ipf(as + zext(u10_16.23_sb2));+:ipf as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0111 & as & at = 0b1100 & op0 = 0b0010 {+ ipf(as + zext(u10_16_23_sb2));}# IPFL - Instruction Cache Prefetch and Lock, pg. 362.@@ -505,67 +604,82 @@ macro extract_bit(val, bit, result) {}# J - Unconditional Jump, pg. 366.-:j srel_6.23 is srel_6.23 & u2_4.5 = 0 & op0 = 0b0110 {- goto srel_6.23;+:j srel_6_23 is srel_6_23 & u2_4_5 = 0 & op0 = 0b0110 {+ goto srel_6_23;}# J.L is a macro.# RET (JX A0) - Non-Windowed Return, pg. 478.-:ret is op2 = 0 & op1 = 0 & ar = 0 & as = 0 & u2_6.7 = 0b10 & u2_4.5 = 0b10 & op0 = 0 {+:ret is op2 = 0 & op1 = 0 & ar = 0 & as = 0 & u2_6_7 = 0b10 & u2_4_5 = 0b10 & op0 = 0 {+ return [a0];+}++# RETW - Windowed Return, pg. 480.+:retw is op2 = 0 & op1 = 0 & ar = 0 & as = 0 & u2_6_7 = 0b10 & u2_4_5 = 0b01 & op0 = 0 {+# Assume call8+ o2=a2;+ a1 = a1 + WindowBase;+ return [a0];+}++# RETW.N - Narrow Windowed Return, pg. 482.+:retw.n is n_ar = 0b1111 & n_as = 0 & n_at = 0b0001 & n_op0 = 0b1101 {+ o2=a2;+ a1 = a1 + WindowBase;return [a0];}# The manual suggests that RET is equivalent to JX A0, yet RET has bit 5 unset, JX doesn’t.-:ret is op2 = 0 & op1 = 0 & ar = 0 & as = 0 & u2_6.7 = 0b10 & u2_4.5 = 0b00 & op0 = 0 {+:ret is op2 = 0 & op1 = 0 & ar = 0 & as = 0 & u2_6_7 = 0b10 & u2_4_5 = 0b00 & op0 = 0 {return [a0];}# JX - Uncoditional Jump Register, pg. 368.-:jx as is op2 = 0 & op1 = 0 & ar = 0 & as & u2_6.7 = 0b10 & u2_4.5 = 0b10 & op0 = 0 {+:jx as is op2 = 0 & op1 = 0 & ar = 0 & as & u2_6_7 = 0b10 & u2_4_5 = 0b10 & op0 = 0 {goto [as];}# L8UI - Load 8-bit Unsigned, pg. 369.-:l8ui at, as, u8_16.23 is u8_16.23 & ar = 0 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u8_16.23:1);+:l8ui at, as, u8_16_23 is u8_16_23 & ar = 0 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u8_16_23:1);at = zext(*:1 addr);}# L16SI - Load 16-bit Signed, pg. 370.-:l16si at, as, u9_16.23_sb1 is u9_16.23_sb1 & ar = 0b1001 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u9_16.23_sb1);+:l16si at, as, u9_16_23_sb1 is u9_16_23_sb1 & ar = 0b1001 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u9_16_23_sb1);at = sext(*:2 addr);}# L16UI - Load 16-bit Unsigned, pg. 372.-:l16ui at, as, u9_16.23_sb1 is u9_16.23_sb1 & ar = 0b001 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u9_16.23_sb1);+:l16ui at, as, u9_16_23_sb1 is u9_16_23_sb1 & ar = 0b001 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u9_16_23_sb1);at = zext(*:2 addr);}# L32AI - Load 32-bit Acquire, pg. 374.-:l32ai at, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b1011 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u10_16.23_sb2);+:l32ai at, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b1011 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u10_16_23_sb2);at = *:4 addr;acquire(addr);}# L32I - Load 32-bit, pg. 378.-:l32i at, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0010 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u10_16.23_sb2);+:l32i at, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0010 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u10_16_23_sb2);at = *:4 addr;}# L32I.N - Narrow Load 32-bit, pg. 380.-:l32i.n n_at, n_as, n_u6_12.15_sb2 is n_u6_12.15_sb2 & n_as & n_at & n_op0 = 0b1000 {- local addr:4 = n_as + zext(n_u6_12.15_sb2);+:l32i.n n_at, n_as, n_u6_12_15_sb2 is n_u6_12_15_sb2 & n_as & n_at & n_op0 = 0b1000 {+ local addr:4 = n_as + zext(n_u6_12_15_sb2);n_at = *:4 addr;}# L32R - Load 32-bit PC-relative, pg. 382.-:l32r at, srel_8.23_oex_sb2 is srel_8.23_oex_sb2 & at & op0 = 0b0001 {- at = srel_8.23_oex_sb2;+:l32r at, srel_8_23_oex_sb2 is srel_8_23_oex_sb2 & at & op0 = 0b0001 {+ at = srel_8_23_oex_sb2;}# LDCT - Load Data Cache Tag, pg. 384.@@ -583,15 +697,42 @@ macro extract_bit(val, bit, result) {at = licw(as);}+macro loopSetup(as, end, doit) {+ LCOUNT = as - 1;+ LBEG = inst_next;+ #LEND = end;+ if (doit) goto <body>;+ goto end;+ <body>+}++# LOOP - Loop, pg. 392.+:loop as, urel_16_23 is urel_16_23 & ar=0b1000 & as & at=0b0111 & op0=0b0110+[loopEnd=1; globalset(urel_16_23, loopEnd);] {+ loopSetup(as, urel_16_23, 1:1);+}++# LOOPGTZ - Loop if Greater Than Zero, pg. 394.+:loopgtz as, urel_16_23 is urel_16_23 & ar=0b1010 & as & at=0b0111 & op0=0b0110+[loopEnd=1; globalset(urel_16_23, loopEnd);] {+ loopSetup(as, urel_16_23, as s> 0);+}++# LOOPNEZ - Loop if Not Equal Zero, pg. 396.+:loopnez as, urel_16_23 is urel_16_23 & ar=0b1001 & as & at=0b0111 & op0=0b0110+[loopEnd=1; globalset(urel_16_23, loopEnd);] {+ loopSetup(as, urel_16_23, as != 0);+}+# LSI - Load Single Immediate, pg. 398.-:lsi ft, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0 & as & ft & op0 = 0b0011 {- local addr:4 = as + zext(u10_16.23_sb2);+:lsi ft, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0 & as & ft & op0 = 0b0011 {+ local addr:4 = as + zext(u10_16_23_sb2);ft = *:4 addr;}# LSIU - Load Single Immediate with Update, pg. 400.-:lsiu ft, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b1000 & as & ft & op0 = 0b0011 {- local addr:4 = as + zext(u10_16.23_sb2);+:lsiu ft, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b1000 & as & ft & op0 = 0b0011 {+ local addr:4 = as + zext(u10_16_23_sb2);ft = *:4 addr;as = addr;}@@ -712,15 +853,15 @@ macro extract_bit(val, bit, result) {}# MOVI - Move Immediate, pg. 421.-:movi at, s16_16.23_8.11 is s16_16.23_8.11 & ar = 0b1010 & at & op0 = 0b0010 {- local val:4 = sext(s16_16.23_8.11);+:movi at, s16_16_23_8_11 is s16_16_23_8_11 & ar = 0b1010 & at & op0 = 0b0010 {+ local val:4 = sext(s16_16_23_8_11);at = val;}# MOVI.N - Narrow Move Immediate, pg. 422.-:movi.n n_as, n_s8_12.15_4.6_asymm is n_s8_12.15_4.6_asymm & n_as & n_u1_7 = 0 & n_op0 = 0b1100 {- local val:4 = sext(n_s8_12.15_4.6_asymm);+:movi.n n_as, n_s8_12_15_4_6_asymm is n_s8_12_15_4_6_asymm & n_as & n_u1_7 = 0 & n_op0 = 0b1100 {+ local val:4 = sext(n_s8_12_15_4_6_asymm);n_as = val;}@@ -825,27 +966,12 @@ macro extract_bit(val, bit, result) {# NSA - Normalization Shift Amount, pg. 461.:nsa at, as is op2 = 0b0100 & op1 = 0 & ar = 0b1110 & as & at & op0 = 0 {- # https://stackoverflow.com/questions/54772520/normalizing-a-two-complement-number- at = nsa(as);+ at = lzcount(~as);}# NSAU - Normalization Shift Amount Unsigned, pg. 462. (Count leading zeros):nsau at, as is op2 = 0b0100 & op1 = 0 & ar = 0b1111 & as & at & op0 = 0 {- local z4 = as[16,16] == 0;-- local t3 = zext(z4)*as[0,16] + zext(!z4)*as[16,16];- local z3 = t3[8,8] == 0;-- local t2 = (z3)*t3[0,8] + (!z3)*t3[8,8];- local z2 = t2[4,4] == 0;-- local t1 = (z2)*t2[0,4] + (!z2)*t2[4,4];- local z1 = t1[2,2] == 0;-- local z0 = (z1)*(t1[1,1] == 0) + (!z1)*(t1[3,1] == 0);- local all0 = as == 0;-- at = zext((all0)*32 + (!all0)*(z4<<4 | z3<<3 | z2<<2 | z1<<1 | z0));+ at = lzcount(as);}# OEQ.S - Compare Single Equal, pg. 463.@@ -931,36 +1057,43 @@ macro extract_bit(val, bit, result) {# RET.N - Narrow Non-Windowed Return, pg. 479.:ret.n is n_ar = 0b1111 & n_as = 0 & n_at = 0 & n_op0 = 0b1101 {return [a0];+ o2=a2;}# RFDD - Return from Debug and Dispatch, pg. 484.:rfdd is op2 = 0b1111 & op1 = 0b0001 & ar = 0b1110 & (as = 0b0000 | as = 0b0001) & at = 0b0001 & op0 = 0 {- rfdd();+ local tmp:4 = rfdd();+ return [tmp];}# RFDE _ Return From Double Exception, pg. 485.:rfde is op2 = 0 & op1 = 0 & ar = 0b0011 & as =0b0010 & at = 0 & op0 = 0 {- rfde();+ local tmp:4 = rfde();+ return [tmp];}# RFDO - Return from Debug Operation, pg. 486.:rfdo is op2 = 0b1111 & op1 = 0b0001 & ar = 0b1110 & as = 0 & at = 0 & op0 = 0 {- rfdo();+ local tmp:4 = rfdo();+ return [tmp];}# RFE - Return From Exception, pg. 487.:rfe is op2 = 0 & op1 = 0 & ar = 0b0011 & as = 0 & at = 0 & op0 = 0 {- rfe();+ local tmp:4 = rfe();+ return [tmp];}# RFI - Return from High-Priority Interrupt, pg. 488.-:rfi u4_8.11 is op2 = 0 & op1 = 0 & ar = 0b0011 & u4_8.11 & at = 0b0001 & op0 = 0 {- rfi(u4_8.11:1);+:rfi u4_8_11 is op2 = 0 & op1 = 0 & ar = 0b0011 & u4_8_11 & at = 0b0001 & op0 = 0 {+ local tmp:4 = rfi(u4_8_11:1);+ return [tmp];}# RFME - Return from Memory Error, pg. 489.:rfme is op2 = 0 & op1 = 0 & ar = 0b0011 & as = 0 & at = 0b0010 & op0 = 0 {- rfme();+ local tmp:4 = rfme();+ return [tmp];}# RFR - Move FR to AR, pg. 490.@@ -970,17 +1103,20 @@ macro extract_bit(val, bit, result) {# RFUE - Return from User-Mode Exception, pg. 491.:rfue is op2 = 0 & op1 = 0 & ar = 0b0011 & as = 0b0001 & at = 0 & op0 = 0 {- rfue();+ local tmp:4 = rfue();+ return [tmp];}# RFWO - Return from Window Overflow, pg. 492.:rfwo is op2 = 0 & op1 = 0 & ar = 0b0011 & as = 0b0100 & at = 0 & op0 = 0 {- rfwo();+ local tmp:4 = rfwo();+ return [tmp];}# RFWU - Return from Window Underflow, pg. 493.:rfwu is op2 = 0 & op1 = 0 & ar = 0b0011 & as = 0b0101 & at = 0 & op0 = 0 {- rfwu();+ local tmp:4 = rfwu();+ return [tmp];}# RITLB0 - Read Instruction TLB Virtual Entry, pg. 494.@@ -993,20 +1129,26 @@ macro extract_bit(val, bit, result) {at = ritlb1(as);}+# ROTW - Rotate Window, pg. 496.+:rotw s4_4_7 is op2 = 0b0100 & op1 = 0 & ar = 0b1000 & as = 0 & s4_4_7 & op0 = 0 {+ WindowBase = WindowBase + s4_4_7;+}+# ROUND.S - Round Single to Fixed, pg. 497.-:round.s ar, fs, u4_4.7 is op2 = 0b1000 & op1 = 0b1010 & ar & fs & u4_4.7 & op0 = 0 {- local scale:4 = int2float(1:2 << u4_4.7:2);+:round.s ar, fs, u4_4_7 is op2 = 0b1000 & op1 = 0b1010 & ar & fs & u4_4_7 & op0 = 0 {+ local scale:4 = int2float(1:2 << u4_4_7:2);ar = round(fs f* scale);}# RSIL - Read and Set Interrupt Level, pg. 498.-:rsil at, u4_8.11 is op2 = 0 & op1 = 0 & ar = 0b0110 & u4_8.11 & at & op0 = 0 {- at = rsil(u4_8.11:1);+:rsil at, u4_8_11 is op2 = 0 & op1 = 0 & ar = 0b0110 & u4_8_11 & at & op0 = 0 {+ at = rsil(u4_8_11:1);}# RSR - Read Special Register, pg. 500.-:rsr at, u8_8.15 is op0 = 0 & op1 = 0b0011 & u8_8.15 & at & op0 = 0 {- at = rsr(u8_8.15:1);+:rsr at, sr is op0 = 0 & op1 = 0b0011 & sr & at & op0 = 0 {+ local src:4 = zext(sr);+ at = *[register]:4 src;}# RSYNC - Register Read Synchronize, pg. 502.@@ -1015,43 +1157,49 @@ macro extract_bit(val, bit, result) {}# RUR - Read User Register, pg. 503.-:rur ar, u8_4.11 is op2 = 0b1110 & op1 = 0b0011 & ar & u8_4.11 & op0 = 0 {- ar = rur(u8_4.11:1);+:rur ar, u8_4_11 is op2 = 0b1110 & op1 = 0b0011 & ar & u8_4_11 & op0 = 0 {+ ar = rur(u8_4_11:1);}# S8I - Store 8-bit, pg. 504.-:s8i at, as, u8_16.23 is u8_16.23 & ar = 0b0100 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u8_16.23:1);+:s8i at, as, u8_16_23 is u8_16_23 & ar = 0b0100 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u8_16_23:1);*:1 addr = at:1;}# S16I - Store 16-bit, pg. 505.-:s16i at, as, u9_16.23_sb1 is u9_16.23_sb1 & ar = 0b0101 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u9_16.23_sb1);+:s16i at, as, u9_16_23_sb1 is u9_16_23_sb1 & ar = 0b0101 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u9_16_23_sb1);*:2 addr = at:2;}# S32C1I - Store 32-bit Compare Conditional, pg. 506-:s32c1i at, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b1110 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u10_16.23_sb2);+:s32c1i at, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b1110 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u10_16_23_sb2);at = s32c1i(addr);}+# S32E - Store 32-bit for Window Exceptions, pg. 508.+:s32e at, as, s5_12_15_oex is op2 = 0b0100 & op1 = 0b1001 & s5_12_15_oex & as & at & op0 = 0 {+ #local vAddr:4 = as + s5_12_15_oex;+ #*:4 vAddr = at;+}+# S32I - Store 32-bit, pg. 510.-:s32i at, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0110 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u10_16.23_sb2);+:s32i at, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0110 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u10_16_23_sb2);*:4 addr = at;}# S32I.N - Narrow Store 32-bit, pg. 512.-:s32i.n n_at, n_as, n_u6_12.15_sb2 is n_u6_12.15_sb2 & n_as & n_at & n_op0 = 0b1001 {- local addr:4 = n_as + zext(n_u6_12.15_sb2);+:s32i.n n_at, n_as, n_u6_12_15_sb2 is n_u6_12_15_sb2 & n_as & n_at & n_op0 = 0b1001 {+ local addr:4 = n_as + zext(n_u6_12_15_sb2);*:4 addr = n_at;}# S32RI - Store 32-bit Release, pg. 514.-:s32ri at, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b1111 & as & at & op0 = 0b0010 {- local addr:4 = as + zext(u10_16.23_sb2);+:s32ri at, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b1111 & as & at & op0 = 0b0010 {+ local addr:4 = as + zext(u10_16_23_sb2);*:4 addr = at;release(addr);}@@ -1062,8 +1210,8 @@ macro extract_bit(val, bit, result) {}# SEXT - Sign Extend, pg. 518.-:sext ar, as, u5_4.7_plus7 is op2 = 0b0010 & op1 = 0b0011 & ar & as & u5_4.7_plus7 & op0 = 0 {- local shift:1 = 31:1 - u5_4.7_plus7;+:sext ar, as, u5_4_7_plus7 is op2 = 0b0010 & op1 = 0b0011 & ar & as & u5_4_7_plus7 & op0 = 0 {+ local shift:1 = 31:1 - u5_4_7_plus7;local tmp:4 = as << shift;ar = tmp s>> shift;}@@ -1085,24 +1233,23 @@ macro extract_bit(val, bit, result) {# SLL - Shift Left Logical, pg. 524.:sll ar, as is op2 = 0b1010 & op1 = 0b0001 & ar & as & at = 0 & op0 = 0 {- local sa:1 = 32 - sar;+ local sa = 32 - SAR;ar = as << sa;}# SLLI - Shift Left Logical Immediate, pg. 525.-:slli ar, as, u5_4.7_20 is u3_21.23 = 0 & u5_4.7_20 & op1 = 0b0001 & ar & as & op0 = 0 {- local sa:1 = 32 - u5_4.7_20;- ar = as << sa;+:slli ar, as, u5_4_7_20_slli is u3_21_23 = 0 & u5_4_7_20_slli & op1 = 0b0001 & ar & as & op0 = 0 {+ ar = as << u5_4_7_20_slli;}# SRA - Shift Right Arithmetic, pg. 526.:sra ar, at is op2 = 0b1011 & op1 = 0b0001 & ar & as = 0 & at & op0 = 0 {- ar = at s>> sar;+ ar = at s>> SAR;}# SRAI - Shift Right Arithmetic Immediate, pg. 527.-:srai ar, at, u5_8.11_20 is u3_21.23 = 0b001 & u5_8.11_20 & op1 = 0b0001 & ar & at & op0 = 0 {- ar = at s>> u5_8.11_20;+:srai ar, at, u5_8_11_20 is u3_21_23 = 0b001 & u5_8_11_20 & op1 = 0b0001 & ar & at & op0 = 0 {+ ar = at s>> u5_8_11_20;}# SRC - Shift Right Combined, pg. 528.@@ -1110,67 +1257,66 @@ macro extract_bit(val, bit, result) {local s64:8 = zext(as);local t64:8 = zext(at);local combined:8 = (s64 << 32) | t64;- local shifted:8 = combined >> sar;+ local shifted:8 = combined >> SAR;ar = shifted:4;}# SRL - Shift Right Logical, pg. 529.:srl ar, at is op2 = 0b1001 & op1 = 0b0001 & ar & as = 0 & at & op0 = 0 {- ar = at >> sar;+ ar = at >> SAR;}# SRLI - Shift Right Logical Immediate, pg. 530.-:srli ar, at, u4_8.11 is op2 = 0b0100 & op1 = 0b0001 & ar & u4_8.11 & at & op0 = 0 {- ar = at >> u4_8.11;+:srli ar, at, u4_8_11 is op2 = 0b0100 & op1 = 0b0001 & ar & u4_8_11 & at & op0 = 0 {+ ar = at >> u4_8_11;}# SSA8B - Set Shift Amount for BE Byte Shift, pg. 531.:ssa8b as is op2 = 0b0100 & op1 = 0 & ar = 0b0011 & as & at = 0 & op0 = 0 {local lsa:4 = (as&3)*8;- sar = 32 - lsa:1;+ SAR = 32 - lsa;}# SSA8L - Set Shift Amount for LE Byte Shift, pg. 532.:ssa8l as is op2 = 0b0100 & op1 = 0 & ar = 0b0010 & as & at = 0 & op0 = 0 {- local rsa:4 = (as&3)*8;- sar = rsa:1;+ SAR = (as&3)*8;}# SSAI - Set Shift Amount Immediate, pg. 533.-:ssai u5_8.11_4 is op2 = 0b0100 & op1 = 0 & ar = 0b0100 & u5_8.11_4 & u3_5.7 = 0 & op0 = 0 {- sar = u5_8.11_4:1;+:ssai u5_8_11_4 is op2 = 0b0100 & op1 = 0 & ar = 0b0100 & u5_8_11_4 & u3_5_7 = 0 & op0 = 0 {+ SAR = zext(u5_8_11_4);}# SSI - Store Single Immediate, pg. 534.-:ssi ft, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b0100 & as & ft & op0 = 0b0011 {- local addr:4 = as + zext(u10_16.23_sb2);+:ssi ft, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b0100 & as & ft & op0 = 0b0011 {+ local addr:4 = as + zext(u10_16_23_sb2);*:4 addr = ft;}# SSIU - Store Single Immediate with Update, pg. 536.-:ssiu ft, as, u10_16.23_sb2 is u10_16.23_sb2 & ar = 0b1100 & as & ft & op0 = 0b0011 {- local addr:4 = as + zext(u10_16.23_sb2);+:ssiu ft, as, u10_16_23_sb2 is u10_16_23_sb2 & ar = 0b1100 & as & ft & op0 = 0b0011 {+ local addr:4 = as + zext(u10_16_23_sb2);*:4 addr = ft;as = addr;}# SSL - Set Shift Amount for Left Shift, pg. 538.:ssl as is op2 = 0b0100 & op1 = 0 & ar = 0b0001 & as & at = 0 & op0 = 0 {- sar = 32 - (as:1 & 0x1f);+ SAR = 32 - (as & 0x1f);}# SSR - Set Shift Amount for Right Shift, pg. 539.:ssr as is op2 = 0b0100 & op1 = 0 & ar = 0 & as & at = 0 & op0 = 0 {- sar = (as:1 & 0x1f);+ SAR = (as & 0x1f);}-# SSX - Store Singe Indexed, pg. 540.+# SSX - Store Single Indexed, pg. 540.:ssx fr, as, at is op2 = 0b0100 & op1 = 0b1000 & fr & as & at & op0 = 0 {local addr:4 = as+at;*:4 addr = fr;}-# SSXU - Store Singe Indexed with Update, pg. 541.+# SSXU - Store Single Indexed with Update, pg. 541.:ssxu fr, as, at is op2 = 0b0101 & op1 = 0b1000 & fr & as & at & op0 = 0 {local addr:4 = as+at;*:4 addr = fr;@@ -1208,8 +1354,8 @@ macro extract_bit(val, bit, result) {}# TRUNC.S - Truncate Single to Fixed, pg. 548-:trunc.s ar, fs, u4_4.7 is op2 = 0b1001 & op1 = 0b1010 & ar & fs & u4_4.7 & op0 = 0 {- local scale:4 = int2float(1:2 << u4_4.7:2);+:trunc.s ar, fs, u4_4_7 is op2 = 0b1001 & op1 = 0b1010 & ar & fs & u4_4_7 & op0 = 0 {+ local scale:4 = int2float(1:2 << u4_4_7:2);ar = trunc(fs f* scale);}@@ -1219,10 +1365,10 @@ macro extract_bit(val, bit, result) {}# UFLOAT.S - Convert Unsigned Fixed to Single, pg. 550.-:ufloat.s fr, as, u4_4.7 is op2 = 0b1101 & op1 = 0b1010 & fr & as & u4_4.7 & op0 = 0 {+:ufloat.s fr, as, u4_4_7 is op2 = 0b1101 & op1 = 0b1010 & fr & as & u4_4_7 & op0 = 0 {local tmp:8 = zext(as);local f = int2float(tmp);- local d = int2float(1:2 << u4_4.7:2);+ local d = int2float(1:2 << u4_4_7:2);fr = d f/ f;}@@ -1244,8 +1390,8 @@ macro extract_bit(val, bit, result) {}# UTRUNC.S - Truncate Single to Fixed Unsigned, pg. 555.-:utrunc.s ar, fs, u4_4.7 is op2 = 0b1110 & op1 = 0b1010 & ar & fs & u4_4.7 & op0 = 0 {- local scale:4 = int2float(1:2 << u4_4.7:2);+:utrunc.s ar, fs, u4_4_7 is op2 = 0b1110 & op1 = 0b1010 & ar & fs & u4_4_7 & op0 = 0 {+ local scale:4 = int2float(1:2 << u4_4_7:2);local tmp:8 = trunc(fs f* scale);local posof = nan(fs) || (tmp >> 16) != 0;local negof = tmp s< 0;@@ -1254,8 +1400,8 @@ macro extract_bit(val, bit, result) {}# WAITI - Wait Interrupt, pg. 556.-:waiti u4_8.11 is op2 = 0 & op1 = 0 & ar = 0b0111 & u4_8.11 & at = 0 & op0 = 0 {- waiti(u4_8.11:4);+:waiti u4_8_11 is op2 = 0 & op1 = 0 & ar = 0b0111 & u4_8_11 & at = 0 & op0 = 0 {+ waiti(u4_8_11:4);}# WDTLB - Write Data TLB Entry, pg. 557.@@ -1279,13 +1425,14 @@ macro extract_bit(val, bit, result) {}# WSR - Write Special Register, pg. 561.-:wsr at, u8_8.15 is op2 = 0b0001 & op1 = 0b0011 & u8_8.15 & at & op0 = 0 {- wsr(u8_8.15:1, at);+:wsr at, sr is op2 = 0b0001 & op1 = 0b0011 & sr & at & op0 = 0 {+ local dst:4 = zext(sr);+ *[register]:4 dst = at;}# WUR - Write User Register, pg. 563.-:wur at, u8_8.15 is op2 = 0b1111 & op1 = 0b0011 & u8_8.15 & at & op0 = 0 {- wur(u8_8.15:1, at);+:wur at, u8_8_15 is op2 = 0b1111 & op1 = 0b0011 & u8_8_15 & at & op0 = 0 {+ wur(u8_8_15:1, at);}# XOR - Bitwise Exclusive Or, pg. 564.@@ -1299,6 +1446,56 @@ macro extract_bit(val, bit, result) {}# XSR - Exchange Special Register, pg. 566.-:xsr at, u8_8.15 is op2 = 0b0110 & op1 = 0b0001 & u8_8.15 & at & op0 = 0 {- at = xsr(u8_8.15:1, at);+:xsr at, u8_8_15 is op2 = 0b0110 & op1 = 0b0001 & u8_8_15 & at & op0 = 0 {+ at = xsr(u8_8_15:1, at);+}++# PAD, dummy+:pad is op0_16=0x0 {+}++# PAD, dummy+:pad is op0_8=0x0 {+}++## MAC16 option ##++# This produces correct pcode, tho it would be nicer to display the float in disasm as well+# +0.0 +1.0 +2.0 +0.5+const.s_imm: tmp is as=0 [ tmp = 0x00000000; ] { export *[const]:4 tmp; }+const.s_imm: tmp is as=1 [ tmp = 0x3F800000; ] { export *[const]:4 tmp; }+const.s_imm: tmp is as=2 [ tmp = 0x40000000; ] { export *[const]:4 tmp; }+const.s_imm: tmp is as=3 [ tmp = 0x3F000000; ] { export *[const]:4 tmp; }++:const.s fr, const.s_imm is op2=0b1111 & op1=0b1010 & fr & const.s_imm & at=0b0011 & op0=0 {+ fr = float2float(const.s_imm);}++# Stub out some insns which mainly appear in boilerplate library functions...+:div0.s fr, fs is op2=0b1111 & op1=0b1010 & fr & fs & at=0b0111 & op0=0 unimpl+:sqrt0.s fr, fs is op2=0b1111 & op1=0b1010 & fr & fs & at=0b1001 & op0=0 unimpl+:nexp01.s fr, fs is op2=0b1111 & op1=0b1010 & fr & fs & at=0b1011 & op0=0 unimpl+:mksadj.s fr, fs is op2=0b1111 & op1=0b1010 & fr & fs & at=0b1100 & op0=0 unimpl+:mkdadj.s fr, fs is op2=0b1111 & op1=0b1010 & fr & fs & at=0b1101 & op0=0 unimpl+:addexp.s fr, fs is op2=0b1111 & op1=0b1010 & fr & fs & at=0b1110 & op0=0 unimpl+:addexpm.s fr, fs is op2=0b1111 & op1=0b1010 & fr & fs & at=0b1111 & op0=0 unimpl+:maddn.s fr, fs, ft is op2=0b0110 & op1=0b1010 & fr & fs & ft & op0=0 unimpl+:divn.s fr, fs, ft is op2=0b0111 & op1=0b1010 & fr & fs & ft & op0=0 unimpl++# UNIMPLEMENTED+# - Windowed Register Option++# L32E - Load 32-bit for Window Exceptions, pg. 376.+:l32e at, as, s5_12_15_oex is op2 = 0 & op1 = 0b1001 & s5_12_15_oex & as & at & op0 = 0 unimpl++# MOVSP - Move to Stack Pointer, pg. 427.+:movsp at, as is op2 = 0 & op1 = 0 & ar = 0b0001 & as & at & op0 = 0 unimpl++# LDDEC - Load with Autodecrement, pg. 386.+:lddec "MAC16_REGS[" u2_12_13 "]", as is op2 = 0b1001 & op1 = 0 & u2_14_15 = 0 & u2_12_13 & as & at = 0 & op0 = 0b0100 unimpl++# LDINC - Load with Autoincrement, pg. 387.+:ldinc "MAC16_REGS[" u2_12_13 "]", as is op2 = 0b1000 & op1 = 0 & u2_14_15 = 0 & u2_12_13 & as & at = 0 & op0 = 0b0100 unimpl++# MULA.AA.* - Signed Multiply, pg. 431.+:mula.aa.* as, at is op2 = 0b0001 & u2_18_19 = 0b01 & ar = 0 & as & at & op0 = 0b0100 unimpldiff --git a/Ghidra/Processors/Xtensa/data/patterns/patternconstraints.xml b/Ghidra/Processors/Xtensa/data/patterns/patternconstraints.xmlnew file mode 100644index 0000000000..d8bd431b9c--- /dev/null+++ b/Ghidra/Processors/Xtensa/data/patterns/patternconstraints.xml@@ -0,0 +1,7 @@+<patternconstraints>+ <language id="Xtensa:LE:32:default">+ <compiler id="default">+ <patternfile>xtensa_patterns.xml</patternfile>+ </compiler>+ </language>+</patternconstraints>\ No newline at end of filediff --git a/Ghidra/Processors/Xtensa/data/patterns/xtensa_patterns.xml b/Ghidra/Processors/Xtensa/data/patterns/xtensa_patterns.xmlnew file mode 100644index 0000000000..497a9d7b6d--- /dev/null+++ b/Ghidra/Processors/Xtensa/data/patterns/xtensa_patterns.xml@@ -0,0 +1,253 @@+<patternlist>+ <patternpairs totalbits="32" postbits="16">+ <prepatterns>+ <data>0x1d 0xf0</data> <!-- retw.n -->+ <data>0x1d 0xf0 0x00</data> <!-- retw.n -->+ <data>0x1d 0xf0 0x00 0x00</data> <!-- retw.n -->+ <data>0x1d 0xf0 0x00 0x00 0x00 </data><!-- retw.n -->+ </prepatterns>+ <postpatterns>+ <data>0x36 ...00001 0x00</data> <!-- entry a1, constant // this only includes stack frame size 0x10->0x80 -->+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="40" postbits="24">+ <prepatterns>+ <data>00001101 11110000</data> <!-- ret.n //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="48" postbits="24">+ <prepatterns>+ <data>00001101 11110000 00000000</data> <!-- ret.n //1 filler -->+ <data>..000110 ........ 1.......</data> <!-- j -off //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="48" postbits="24">+ <prepatterns>+ <data>10000000 00000000 00000000</data> <!-- ret //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="56" postbits="24">+ <prepatterns>+ <data>10000000 00000000 00000000 00000000</data> <!-- ret //1 filler -->+ <data>00001101 11110000 00000000 00000000</data> <!-- ret.n //2 filler -->+ <data>..000110 ........ 1....... 00000000</data> <!-- j -off //1 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="56" postbits="24">+ <prepatterns>+ <data>....1010 00010001 00001101 11110000</data> <!-- add.n a1,a1,at ; ret.n //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="64" postbits="24">+ <prepatterns>+ <data>10000000 00000000 00000000 00000000 00000000</data> <!-- ret //2 filler -->+ <data>00001101 11110000 00000000 00000000 00000000</data> <!-- ret.n //3 filler -->+ <data>..000110 ........ 1....... 00000000 00000000</data> <!-- j -off //2 filler -->+ <data>....1010 00010001 00001101 11110000 00000000</data> <!-- add.n a1,a1,at ; ret.n //1 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="64" postbits="24">+ <prepatterns>+ <data>00010010 11000001 0...0000 00001101 11110000</data> <!-- addi a1,a1,off ; ret.n //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="72" postbits="24">+ <prepatterns>+ <data>10000000 00000000 00000000 00000000 00000000 00000000</data> <!-- ret //3 filler -->+ <data>00010010 11000001 0...0000 00001101 11110000 00000000</data> <!-- addi a1,a1,off ; ret.n //1 filler -->+ <data>..000110 ........ 1....... 00000000 00000000 00000000</data> <!-- j -off //3 filler -->+ <data>....1010 00010001 00001101 11110000 00000000 00000000</data> <!-- add.n a1,a1,at ; ret.n //2 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="80" postbits="24">+ <prepatterns>+ <data>00010010 11000001 0...0000 00001101 11110000 00000000 00000000</data> <!-- addi a1,a1,off ; ret.n //2 filler -->+ <data>....1010 00010001 00001101 11110000 00000000 00000000 00000000</data> <!-- add.n a1,a1,at ; ret.n //3 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="88" postbits="24">+ <prepatterns>+ <data>00010010 11000001 0...0000 00001101 11110000 00000000 00000000 00000000</data> <!-- addi a1,a1,off ; ret.n //3 filler -->+ </prepatterns>+ <postpatterns>+ <data>00010010 11000001 1...0000</data> <!-- addi a1,a1,-off -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="64" postbits="48">+ <prepatterns>+ <data>00001101 11110000</data> <!-- ret.n //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="72" postbits="48">+ <prepatterns>+ <data>00001101 11110000 00000000</data> <!-- ret.n //1 filler -->+ <data>..000110 ........ 1.......</data> <!-- j -off //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="72" postbits="48">+ <prepatterns>+ <data>10000000 00000000 00000000</data> <!-- ret //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="80" postbits="48"> <!-- Main patterns -->+ <prepatterns>+ <data>00001101 11110000 00000000 00000000</data> <!-- ret.n //2 filler -->+ <data>..000110 ........ 1....... 00000000</data> <!-- j -off //1 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="80" postbits="48">+ <prepatterns>+ <data>....1010 00010001 00001101 11110000</data> <!-- add.n a1,a1,at ; ret.n //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="88" postbits="48">+ <prepatterns>+ <data>00001101 11110000 00000000 00000000 00000000</data> <!-- ret.n //3 filler -->+ <data>..000110 ........ 1....... 00000000 00000000</data> <!-- j -off //2 filler -->+ <data>....1010 00010001 00001101 11110000 00000000</data> <!-- add.n a1,a1,at ; ret.n //1 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="88" postbits="48">+ <prepatterns>+ <data>00010010 11000001 0...0000 00001101 11110000</data> <!-- addi a1,a1,off ; ret.n //0 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart after="func"/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="96" postbits="48">+ <prepatterns>+ <data>00010010 11000001 0...0000 00001101 11110000 00000000</data> <!-- addi a1,a1,off ; ret.n //1 filler -->+ <data>..000110 ........ 1....... 00000000 00000000 00000000</data> <!-- j -off //3 filler -->+ <data>....1010 00010001 00001101 11110000 00000000 00000000</data> <!-- add.n a1,a1,at ; ret.n //2 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="104" postbits="48">+ <prepatterns>+ <data>00010010 11000001 0...0000 00001101 11110000 00000000 00000000</data> <!-- addi a1,a1,off ; ret.n //2 filler -->+ <data>....1010 00010001 00001101 11110000 00000000 00000000 00000000</data> <!-- add.n a1,a1,at ; ret.n //3 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <patternpairs totalbits="112" postbits="48">+ <prepatterns>+ <data>00010010 11000001 0...0000 00001101 11110000 00000000 00000000 00000000</data> <!-- addi a1,a1,off ; ret.n //3 filler -->+ </prepatterns>+ <postpatterns>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <align mark="0" bits="3"/>+ <funcstart/>+ </postpatterns>+ </patternpairs>+ <pattern>+ <data>....0010 10100... ........ ....0000 00010001 11000000</data> <!-- movi at,off ; subi a1,a1,at -->+ <funcstart after="data" />+ </pattern>+ <pattern>+ <data>00010010 11000001 1...0000</data> <!-- addi a1, a1, -offset -->+ <funcstart after="data" />+ </pattern>+ <pattern>+ <data>0x12 0xc1 0xf0 0x09 0x01 ..000101 ........ ........ 0x08 0x01 0x12 0xc1 0x10 0x0d 0xf0</data>+ <!--+ addi a1,a1,-0x10+ s32i.n a0,a1,0x0+ call0 FUN+ l32i.n a0,a1,0x0+ addi a1,a1,0x10+ ret.n+ -->+ <align mark="0" bits="3" />+ <funcstart validcode="function" thunk="true" />+ </pattern>+</patternlist>+diff --git a/Ghidra/Processors/Xtensa/src/main/help/help/TOC_Source.xml b/Ghidra/Processors/Xtensa/src/main/help/help/TOC_Source.xmlnew file mode 100644index 0000000000..a34f62e8f1--- /dev/null+++ b/Ghidra/Processors/Xtensa/src/main/help/help/TOC_Source.xml@@ -0,0 +1,57 @@+<?xml version='1.0' encoding='ISO-8859-1' ?>+<!--++ This is an XML file intended to be parsed by the Ghidra help system. It is loosely based+ upon the JavaHelp table of contents document format. The Ghidra help system uses a+ TOC_Source.xml file to allow a module with help to define how its contents appear in the+ Ghidra help viewer's table of contents. The main document (in the Base module)+ defines a basic structure for the+ Ghidra table of contents system. Other TOC_Source.xml files may use this structure to insert+ their files directly into this structure (and optionally define a substructure).+++ In this document, a tag can be either a <tocdef> or a <tocref>. The former is a definition+ of an XML item that may have a link and may contain other <tocdef> and <tocref> children.+ <tocdef> items may be referred to in other documents by using a <tocref> tag with the+ appropriate id attribute value. Using these two tags allows any module to define a place+ in the table of contents system (<tocdef>), which also provides a place for+ other TOC_Source.xml files to insert content (<tocref>).++ During the help build time, all TOC_Source.xml files will be parsed and validated to ensure+ that all <tocref> tags point to valid <tocdef> tags. From these files will be generated+ <module name>_TOC.xml files, which are table of contents files written in the format+ desired by the JavaHelp system. Additionally, the genated files will be merged together+ as they are loaded by the JavaHelp system. In the end, when displaying help in the Ghidra+ help GUI, there will be on table of contents that has been created from the definitions in+ all of the modules' TOC_Source.xml files.+++ Tags and Attributes++ <tocdef>+ -id - the name of the definition (this must be unique across all TOC_Source.xml files)+ -text - the display text of the node, as seen in the help GUI+ -target** - the file to display when the node is clicked in the GUI+ -sortgroup - this is a string that defines where a given node should appear under a given+ parent. The string values will be sorted by the JavaHelp system using+ a javax.text.RulesBasedCollator. If this attribute is not specified, then+ the text of attribute will be used.++ <tocref>+ -id - The id of the <tocdef> that this reference points to++ **The URL for the target is relative and should start with 'help/topics'. This text is+ used by the Ghidra help system to provide a universal starting point for all links so that+ they can be resolved at runtime, across modules.+++-->+++<tocroot>+ <!-- Uncomment and adjust fields to add help topic to help system's Table of Contents+ <tocref id="Ghidra Functionality">+ <tocdef id="HelpAnchor" text="My Feature" target="help/topics/my_topic/help.html" />+ </tocref>+ -->+</tocroot>diff --git a/Ghidra/Processors/Xtensa/src/main/help/help/topics/xtensa/help.html b/Ghidra/Processors/Xtensa/src/main/help/help/topics/xtensa/help.htmlnew file mode 100644index 0000000000..1f9d6a1fc7--- /dev/null+++ b/Ghidra/Processors/Xtensa/src/main/help/help/topics/xtensa/help.html@@ -0,0 +1,23 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">++<HTML>+ <HEAD>+ <META name="generator" content=+ "HTML Tidy for Java (vers. 2009-12-01), see jtidy.sourceforge.net">+ <META http-equiv="Content-Language" content="en-us">+ <META http-equiv="Content-Type" content="text/html; charset=windows-1252">+ <META name="GENERATOR" content="Microsoft FrontPage 4.0">+ <META name="ProgId" content="FrontPage.Editor.Document">++ <TITLE>Skeleton Help File for a Module</TITLE>+ <LINK rel="stylesheet" type="text/css" href="help/shared/DefaultStyle.css">+ </HEAD>++ <BODY>+ <H1><a name="HelpAnchor"></a>Skeleton Help File for a Module</H1>++ <P>This is a simple skeleton help topic. For a better description of what should and should not+ go in here, see the "sample" Ghidra extension in the Extensions/Ghidra directory, or see your+ favorite help topic. In general, language modules do not have their own help topics.</P>+ </BODY>+</HTML>diff --git a/Ghidra/Processors/Xtensa/src/main/java/ghidra/app/util/bin/format/elf/relocation/Xtensa_ElfRelocationHandler.java b/Ghidra/Processors/Xtensa/src/main/java/ghidra/app/util/bin/format/elf/relocation/Xtensa_ElfRelocationHandler.javaindex 5882690335..f0033e4bed 100644--- a/Ghidra/Processors/Xtensa/src/main/java/ghidra/app/util/bin/format/elf/relocation/Xtensa_ElfRelocationHandler.java+++ b/Ghidra/Processors/Xtensa/src/main/java/ghidra/app/util/bin/format/elf/relocation/Xtensa_ElfRelocationHandler.java@@ -6,8 +6,8 @@ import ghidra.app.util.bin.format.elf.ElfRelocation;import ghidra.app.util.bin.format.elf.ElfSymbol;import ghidra.program.model.address.Address;import ghidra.program.model.listing.Program;-import ghidra.program.model.mem.Memory;import ghidra.program.model.mem.MemoryAccessException;+import ghidra.program.model.reloc.RelocationResult;import ghidra.util.exception.NotFoundException;public class Xtensa_ElfRelocationHandler extends ElfRelocationHandler {@@ -19,26 +19,21 @@ public class Xtensa_ElfRelocationHandler extends ElfRelocationHandler {}@Override- public void relocate(ElfRelocationContext elfRelocationContext, ElfRelocation relocation, Address relocationAddress)+ public RelocationResult relocate(ElfRelocationContext elfRelocationContext, ElfRelocation relocation, Address relocationAddress)throws MemoryAccessException, NotFoundException {ElfHeader elf = elfRelocationContext.getElfHeader();if (!canRelocate(elf)) {- return;+ return RelocationResult.FAILURE;}int type=relocation.getType();if (Xtensa_ElfRelocationConstants.R_XTENSA_NONE == type) {- return;+ return RelocationResult.FAILURE;}Program program = elfRelocationContext.getProgram();- Memory memory = program.getMemory();-- long addend = relocation.hasAddend() ? relocation.getAddend() : memory.getInt(relocationAddress);- long offset = relocationAddress.getOffset();- long base = elfRelocationContext.getImageBaseWordAdjustmentOffset();+ElfSymbol sym = null;- long symbolValue = 0;String symbolName = null;int symbolIndex = relocation.getSymbolIndex();@@ -47,246 +42,248 @@ public class Xtensa_ElfRelocationHandler extends ElfRelocationHandler {}if (null != sym) {- symbolValue = elfRelocationContext.getSymbolValue(sym);symbolName = sym.getNameAsString();}+ //int byteLength = 4; // most relocations affect 4-bytes (change if different)+switch(type) {case Xtensa_ElfRelocationConstants.R_XTENSA_32:markAsWarning(program, relocationAddress, "R_XTENSA_32",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_RTLD:markAsWarning(program, relocationAddress, "R_XTENSA_RTLD",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_GLOB_DAT:markAsWarning(program, relocationAddress, "R_XTENSA_GLOB_DAT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_JMP_SLOT:markAsWarning(program, relocationAddress, "R_XTENSA_JMP_SLOT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_RELATIVE:markAsWarning(program, relocationAddress, "R_XTENSA_RELATIVE",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_PLT:markAsWarning(program, relocationAddress, "R_XTENSA_PLT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_OP0:markAsWarning(program, relocationAddress, "R_XTENSA_OP0",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_OP1:markAsWarning(program, relocationAddress, "R_XTENSA_OP1",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_OP2:markAsWarning(program, relocationAddress, "R_XTENSA_OP2",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_ASM_EXPAND:markAsWarning(program, relocationAddress, "R_XTENSA_ASM_EXPAND",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_ASM_SIMPLIFY:markAsWarning(program, relocationAddress, "R_XTENSA_ASM_SIMPLIFY",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_GNU_VTINHERIT:markAsWarning(program, relocationAddress, "R_XTENSA_GNU_VTINHERIT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_GNU_VTENTRY:markAsWarning(program, relocationAddress, "R_XTENSA_GNU_VTENTRY",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_DIFF8:markAsWarning(program, relocationAddress, "R_XTENSA_DIFF8",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_DIFF16:markAsWarning(program, relocationAddress, "R_XTENSA_DIFF16",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_DIFF32:markAsWarning(program, relocationAddress, "R_XTENSA_DIFF32",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT0_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT0_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT1_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT1_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT2_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT2_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT3_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT3_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT4_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT4_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT5_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT5_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT6_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT6_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT7_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT7_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT8_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT8_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT9_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT9_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT10_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT10_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT11_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT11_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT12_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT12_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT13_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT13_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT14_OP:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT14_OP",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT0_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT0_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT1_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT1_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT2_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT2_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT3_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT3_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT4_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT4_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT5_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT5_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT6_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT6_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT7_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT7_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT8_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT8_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT9_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT9_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT10_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT10_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT11_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT11_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT12_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT12_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT13_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT13_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;case Xtensa_ElfRelocationConstants.R_XTENSA_SLOT14_ALT:markAsWarning(program, relocationAddress, "R_XTENSA_SLOT14_ALT",symbolName, symbolIndex, "TODO, needs support ",elfRelocationContext.getLog());- break;+ return RelocationResult.UNSUPPORTED;default:markAsUnhandled(program, relocationAddress, type, symbolIndex,symbolName, elfRelocationContext.getLog());- break;+ return RelocationResult.SKIPPED;}+}}