Closed brainstorm closed 5 years ago
Updated, but I haven't tested this arch because I don't know anything about it.
Also for now you have to set r2ghidra.lang
to the id you want manually, so please send a pr with the respective entries here: https://github.com/radareorg/r2ghidra-dec/blob/master/src/R2Architecture.cpp#L16
Did that change, shows up on the pdgs
listing, but:
Ghidra Decompiler Error: Could not match asm.arch sh32 to sleigh arch.
Since AFAIK all SuperH's are 32 bits, r2 maps it as sh so it kinda breaks your scheme... I'm debating myself on whether to add this weird case on r2ghidra-dec, i.e sth like (pseudocode):
(...)
std::string SleighIdFromCore(RCore *core)
{
const char *arch = r_config_get(core->config, "asm.arch");
bool be = r_config_get_i(core->config, "cfg.bigendian") != 0;
ut64 bits = r_config_get_i(core->config, "asm.bits");
string flavor = string("default");
auto arch_it = arch_map.find(arch + to_string(bits));
if(arch_it == arch_map.end())
throw LowlevelError("Could not match asm.arch " + std::string(arch) + to_string(bits) + " to sleigh arch.");
if (!arch_it->second.compare("ARM")) {
flavor = string("v7");
bits = 32;
}
if (!arch_it->second.compare("superh")) {
arch_it = arch_map.find(arch);
bits = 32;
}
if (!arch_it->second.compare("superh4")) {
arch_it = arch_map.find(arch);
bits = 32;
}
Or "uniformize" it on @radare so that asm.arch
becomes sh32
(unsure about how many third party r2pipes, anal & co would that break though).
Better hack into ghidra. The arch is sh. Not sh32
On 21 Sep 2019, at 02:12, Roman Valls Guimera notifications@github.com wrote:
Did that change, shows up on the pdgs listing, but:
Ghidra Decompiler Error: Could not match asm.arch sh32 to sleigh arch.
Since AFAIK all SuperH's are 32 bits, r2 maps it as sh so it kinda breaks your scheme... I'm debating myself on whether to add this weird case on r2ghidra-dec, i.e sth like (pseudocode):
(...) std::string SleighIdFromCore(RCore core) { const char arch = r_config_get(core->config, "asm.arch"); bool be = r_config_get_i(core->config, "cfg.bigendian") != 0; ut64 bits = r_config_get_i(core->config, "asm.bits"); string flavor = string("default");
auto arch_it = arch_map.find(arch + to_string(bits)); if(arch_it == arch_map.end()) throw LowlevelError("Could not match asm.arch " + std::string(arch) + to_string(bits) + " to sleigh arch."); if (!arch_it->second.compare("ARM")) { flavor = string("v7"); bits = 32; } if (!arch_it->second.compare("superh")) { arch_it = arch_map.find(arch); bits = 32; } if (!arch_it->second.compare("superh4")) { arch_it = arch_map.find(arch); bits = 32; }
Or "uniformize" it on @radare so that asm.arch becomes sh32 (unsure about how many third party r2pipes, anal & co would that break though).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Yes what is currently done is simply concatenating the arch from r2 with the bits and mapping that, which is hacky and planned to be changed, that's how sh32
is generated from sh
. So for now, just adding an entry using sh32
as the key to arch_map
should work.
I see, but not exactly as it turns out:
$ git diff
diff --git a/src/R2Architecture.cpp b/src/R2Architecture.cpp
index fc88e79..acc5af2 100644
--- a/src/R2Architecture.cpp
+++ b/src/R2Architecture.cpp
@@ -31,6 +31,8 @@ static const std::map<std::string, std::string> arch_map = {
{ "ppc64", "PowerPC" } ,
{ "sparc32", "sparc" } ,
{ "sparc64", "sparc" } ,
+ { "superh4", "sh32" } ,
+ { "superh", "sh32" } ,
{ "msp43016", "TI_MSP430" } ,
{ "m68k32", "68000" } ,
};
Leads to:
[0x08000040]> pdg
Ghidra Decompiler Error: Could not match asm.arch sh32 to sleigh arch.
[0x08000040]>
It's the other way around. It should be something like { "sh32", "SuperH4" }
Handling on PR #41, closing.
Thanks for the good work here!
SuperH4 It was introduced recently (11th Sept)... is it too tricky to refresh the build to include it?
/cc @radare