Initial support for wasm via ghidra-native 0.2.4

This commit is contained in:
pancake authored and GitHub committed 2022-07-31 11:50:13 +02:00
1 parent d4deb74c8b
commit 6ef4055c91
8 files changed
+14 -15

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
-include config.mk
DESTDIR?=
GHIDRA_NATIVE_COMMIT=0.2.2
GHIDRA_NATIVE_COMMIT=0.2.4
ifeq ($(shell test -f config.mk && echo $$?),0)
all: ghidra-native ghidra-processors.txt
+2 -1
View File
@@ -66,6 +66,7 @@ Usage: pdg # Native Ghidra decompiler plugin
The following config vars (for the `e` command) can be used to adjust r2ghidra's behavior:
```
[0x000275a7]> e?r2ghidra.
r2ghidra.casts: Show type casts where needed
r2ghidra.cmt.cpp: C++ comment style
r2ghidra.cmt.indent: Comment indent
@@ -74,7 +75,7 @@ The following config vars (for the `e` command) can be used to adjust r2ghidra's
r2ghidra.linelen: Max line length
r2ghidra.maximplref: Maximum number of references to an expression before showing an explicit variable.
r2ghidra.rawptr: Show unknown globals as raw addresses instead of variables
r2ghidra.roprop: Propagate read-only constants
r2ghidra.roprop: Propagate read-only constants (0,1,2,3,4)
r2ghidra.sleighhome: SLEIGHHOME
r2ghidra.timeout: Run decompilation in a separate process and kill it after a specific time
r2ghidra.verbose: Show verbose warning messages while decompiling
+1
View File
@@ -16,3 +16,4 @@ Sparc
V850
Z80
x86
wasm
+5 -4
View File
@@ -3,14 +3,15 @@ set PATH=%CD%\radare2\bin;%PATH%
set VSARCH=x64
git submodule update --init
set GNV=0.2.4
python -m wget https://github.com/radareorg/ghidra-native/releases/download/0.2.2/ghidra-native-0.2.2.zip
python -m wget https://github.com/radareorg/ghidra-native/releases/download/%GNV%/ghidra-native-%GNV%.zip
unzip -q ghidra-native-0.2.2.zip
unzip -q ghidra-native-%GNV%.zip
if %ERRORLEVEL% NEQ 0 (
powershell "Expand-Archive -LiteralPath ghidra-native-0.2.2.zip -DestinationPath ."
powershell "Expand-Archive -LiteralPath ghidra-native-%GNV%.zip -DestinationPath ."
)
ren ghidra-native-0.2.2 ghidra-native
ren ghidra-native-%GNV% ghidra-native
REM call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
echo === Finding Visual Studio...
+1
View File
@@ -91,6 +91,7 @@ static const std::map<std::string, ArchMapper> arch_map = {
{ "dalvik", { "Dalvik", "default", 32, false, 2, 10 }},
{ "tricore", { "tricore", "default", 32, true } },
{ "hexagon", { "hexagon", "default", 32, false } },
{ "wasm", { "wasm", "default", 32 } },
{ "6502", { "6502", "default", 16 } },
{ "65c02", { "65c02", "default", 16 } },
{ "java", { "JVM", "default", bits_mapper_default, true } },
+1
View File
@@ -1747,6 +1747,7 @@ static void append_hardcoded_regs(std::stringstream &buf, const std::string &arc
case ('D' | 'A' << 8 | 'T' << 16): // DATA
case ('z' | '8' << 8 | '4' << 16): // z8401x
case ('8' | '0' << 8 | '4' << 16): // 8048
case ('w' | 'a' << 8 | 's' << 16): // wasm
case ('M' | 'C' << 8 | 'S' << 16): // MCS96
case ('M' | 'a' << 8 | 'n' << 16): // Management
break;
+1 -1
View File
@@ -22,7 +22,7 @@ RAnalPlugin r_anal_plugin_ghidra = {
#if R2_VERSION_NUMBER >= 50609
.endian = R_SYS_ENDIAN_LITTLE | R_SYS_ENDIAN_BIG,
#endif
.cpus = "6502,6805,8051,arm,avr,cr16,dalvik,hppa,java,m68k,m8c,mips,mcs96,msp430,pic24,ppc,sh,sparc,stm8,tricore,toy,v850,x86,z80",
.cpus = "6502,6805,8051,arm,avr,cr16,dalvik,hppa,java,m68k,m8c,mips,mcs96,msp430,pic24,ppc,sh,sparc,stm8,tricore,toy,v850,wasm,x86,z80",
.bits = 0,
.esil = true,
.fileformat_type = 0,
+2 -8
View File
@@ -98,7 +98,7 @@ static void PrintUsage(const RCore *const core) {
"pdgj", "", "# Dump the current decompiled function as JSON",
"pdgo", "", "# Decompile current function side by side with offsets",
"pdgp", "", "# Switch to RAsm and RAnal plugins driven by SLEIGH from Ghidra",
"pdgs", "", "# Display loaded Sleigh Languages",
"pdgs", "", "# Display loaded Sleigh Languages (alias for pdgL)",
"pdgsd", " N", "# Disassemble N instructions with Sleigh and print pcode",
"pdgss", "", "# Display automatically matched Sleigh Language ID",
"pdgx", "", "# Dump the XML of the current decompiled function",
@@ -180,13 +180,6 @@ static void Decompile(RCore *core, ut64 addr, DecompileMode mode, std::stringstr
if (res < 0) {
R_LOG_WARN ("break");
}
#if 0
else {
eprintf("Decompilation complete\n");
if (res == 0)
eprintf("(no change)\n");
}
#endif
if (cfg_var_verbose.GetBool (core->config)) {
for (const auto &warning : arch.getWarnings()) {
func->warningHeader("[r2ghidra] " + warning);
@@ -500,6 +493,7 @@ static void runcmd(RCore *core, const char *input) {
case '*': // "pdg*"
DecompileCmd (core, DecompileMode::STATEMENTS);
break;
case 'L': // "pdgL"
case 's': // "pdgs"
switch (input[1]) {
case 's': // "pdgss"