From 7b9f2118969a0d929a33826755955e113bc789ae Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 8 May 2024 19:01:45 +0200 Subject: [PATCH] WIP branch supporting latest ghidra-native-0.5.0 * Currently segfaulting --- Makefile.acr | 2 +- ghidra/deps.mk | 7 +++++++ preconfigure.bat | 2 +- src/R2PrintC.cpp | 13 +++++++++++-- src/R2PrintC.h | 2 +- src/R2TypeFactory.cpp | 5 ++++- 6 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Makefile.acr b/Makefile.acr index 0812e193..f29a1815 100644 --- a/Makefile.acr +++ b/Makefile.acr @@ -1,7 +1,7 @@ include config.mk DESTDIR?= -GHIDRA_NATIVE_COMMIT=0.4.5 +GHIDRA_NATIVE_COMMIT=0.5.0 PUGIXML=third-party/pugixml/Makefile diff --git a/ghidra/deps.mk b/ghidra/deps.mk index 6edd5a85..e221b736 100644 --- a/ghidra/deps.mk +++ b/ghidra/deps.mk @@ -1,6 +1,9 @@ # hardcoded for now USE_BISON=0 + +LDFLAGS+=-lz + # GHIDRA_HOME=../ghidra/ghidra/ # GHIDRA_DECOMPILER=$(GHIDRA_HOME)/Ghidra/Features/Decompiler/src/decompile/cpp GHIDRA_HOME=../ghidra-native @@ -20,6 +23,10 @@ G_DECOMPILER+=merge.cc double.cc coreaction.cc condexe.cc override.cc G_DECOMPILER+=dynamic.cc crc32.cc prettyprint.cc printlanguage.cc G_DECOMPILER+=printc.cc printjava.cc memstate.cc opbehavior.cc G_DECOMPILER+=paramid.cc transform.cc string_ghidra.cc stringmanage.cc +G_DECOMPILER+=slaformat.cc +G_DECOMPILER+=compression.cc +G_DECOMPILER+=multiprecision.cc +G_DECOMPILER+=modelrules.cc G_DECOMPILER+=ghidra_arch.cc G_DECOMPILER+=loadimage_ghidra.cc diff --git a/preconfigure.bat b/preconfigure.bat index 95c501b1..320a3607 100644 --- a/preconfigure.bat +++ b/preconfigure.bat @@ -3,7 +3,7 @@ set PATH=%CD%\radare2\bin;%PATH% set VSARCH=x64 git submodule update --init -set GNV=0.4.5 +set GNV=0.5.0 python -m wget https://github.com/radareorg/ghidra-native/releases/download/%GNV%/ghidra-native-%GNV%.zip diff --git a/src/R2PrintC.cpp b/src/R2PrintC.cpp index d00f26d6..f4a2d84e 100644 --- a/src/R2PrintC.cpp +++ b/src/R2PrintC.cpp @@ -1,4 +1,4 @@ -/* r2ghidra - LGPL - Copyright 2019-2023 - thestr4ng3r, pancake */ +/* r2ghidra - LGPL - Copyright 2019-2024 - thestr4ng3r, pancake */ #include "R2PrintC.h" #include "RCoreMutex.h" @@ -55,8 +55,17 @@ void R2PrintC::pushUnnamedLocation(const Address &addr, const Varnode *vn, const if (space->getType() == IPTR_PROCESSOR) { pushOp (&dereference, op); auto type = glb->types->getTypePointer (space->getAddrSize (), vn->getType (), space->getWordSize ()); - pushConstant (addr.getOffset (), type, vn, op); + // pushConstant (addr.getOffset (), type, vn, op); + pushConstant(addr.getOffset(),type,casetoken,vn, op); } else { PrintC::pushUnnamedLocation (addr,vn, op); } } + +/* +void R2PrintC::push_integer(uintb val,int4 sz,bool sign,tagtype tag, const Varnode *vn,const PcodeOp *op) { +} + +void R2PrintC::pushConstant(uintb val,const Datatype *ct,tagtype tag, const Varnode *vn, const PcodeOp *op) { +} +*/ diff --git a/src/R2PrintC.h b/src/R2PrintC.h index f71a2e99..b081c056 100644 --- a/src/R2PrintC.h +++ b/src/R2PrintC.h @@ -1,4 +1,4 @@ -/* r2ghidra - LGPL - Copyright 2019-2023 - thestr4ng3r, pancake */ +/* r2ghidra - LGPL - Copyright 2019-2024 - pancake */ #ifndef R2GHIDRA_R2PRINTC_H #define R2GHIDRA_R2PRINTC_H diff --git a/src/R2TypeFactory.cpp b/src/R2TypeFactory.cpp index 8a196705..68494996 100644 --- a/src/R2TypeFactory.cpp +++ b/src/R2TypeFactory.cpp @@ -114,7 +114,7 @@ Datatype *R2TypeFactory::queryR2Struct(const string &n, std::set &s arch->addWarning ("Struct " + n + " has no fields."); return nullptr; } - setFields (fields, r, 0, 0); + // setFields (fields, r, 0, 0); return r; } catch (std::invalid_argument &e) { arch->addWarning ("Failed to load struct " + n + " from sdb."); @@ -168,10 +168,13 @@ Datatype *R2TypeFactory::queryR2Typedef(const string &n, std::set & if (!resolved) { return nullptr; } +#if 0 Datatype *typedefd = resolved->clone (); setName (typedefd, n); // this removes the old name from the nametree setName (resolved, resolved->getName()); // add the old name back return typedefd; +#endif + return nullptr; } Datatype *R2TypeFactory::queryR2(const string &n, std::set &stackTypes) {