Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3211: Code review fix-up

ghidorahrex81fb89e2591c
diff --git a/Ghidra/Processors/Loongarch/data/languages/Loongarch32_Instructions.sinc b/Ghidra/Processors/Loongarch/data/languages/Loongarch32_Instructions.sinc
index be0d205bc2..2966aff9c4 100644
--- a/Ghidra/Processors/Loongarch/data/languages/Loongarch32_Instructions.sinc
+++ b/Ghidra/Processors/Loongarch/data/languages/Loongarch32_Instructions.sinc
@@ -579,6 +579,10 @@
call Rel26;
}
+:bl Rel26 is op26_31=0x15 & Rel26 & imm10_16=1 & simm0_10=0 {
+ ra = inst_next;
+ goto Rel26;
+}
#la-base-32.txt beq mask=0x58000000 [@orig_fmt=JDSk16ps2, @la32, @primary, @qemu]
#0x58000000 0xfc000000 r5:5,r0:5,sb10:16<<2 ['reg5_5_s0', 'reg0_5_s0', 'sbranch10_16_s0']
@@ -660,10 +664,10 @@
return [retAddr];
}
-# alias of jirl zer, rj, 0
+# alias of jirl zero, rj, 0
:jr RJsrc is op26_31=0x13 & rD=0x0 & RJsrc & simm10_16=0 {
local retAddr = RJsrc;
- return [retAddr];
+ goto [retAddr];
}
diff --git a/Ghidra/Processors/Loongarch/data/languages/privileged-32.sinc b/Ghidra/Processors/Loongarch/data/languages/privileged-32.sinc
index 582bd27843..2158a64094 100644
--- a/Ghidra/Processors/Loongarch/data/languages/privileged-32.sinc
+++ b/Ghidra/Processors/Loongarch/data/languages/privileged-32.sinc
@@ -1,8 +1,7 @@
#la-privileged-32.txt csrxchg mask=0x04000000 [@primary]
#0x04000000 0xff000000 r0:5,r5:5,u10:14 ['reg0_5_s0', 'reg5_5_s0', 'imm10_14_s0']
csr: csr is imm10_14 [csr = $(CSR_OFFSET) + imm10_14 * $(REGSIZE);] {
- local tmp:$(REGSIZE) = csr;
- export *[register]:$(REGSIZE) tmp;
+ export *[register]:$(REGSIZE) csr;
}
:csrxchg RD, RJsrc, csr is op24_31=0x4 & RD & RJsrc & csr {
@@ -153,7 +152,8 @@ define pcodeop ertn;
#la-privileged-32.txt eret mask=0x06483800 [@orig_name=ertn, @primary]
#0x06483800 0xffffffff
:ertn is instword=0x06483800 {
- ertn();
+ local ret = ertn();
+ return [ret];
}