Hello,
On Wed, 24 May 2017 00:35:53 -0700 (PDT)
Vlad Ivanov <
vlad.x.do....@gmail.com> wrote:
> Hi Paul,
>
> I've been looking into ESP8266 RE for quite a while too and I decided
> to try a different approach.
Sure, if you read my mails, you know I'm not surprised at all that
everyone tries different approaches ;-).
> Since there are no xtensa decompilers
> but there are plenty for other architectures,
Well, "plenty" doesn't mean "good". Guys writing those decompilers also
each tried one's own approach, with the expected results (usually lack
of anything useful for anybody else).
> I'm trying to implement
> a binary translator from xtensa to arm which would produce assembly
> files which, in turn, can be compiled into elf and passed to one of
> the existing decompilers. I think it would be best to produce ARM
> binaries with a small number of functions and not translate the whole
> thing.
For some analyses, a non-sparse call graph is required. For example, if
a function is never called, it's fair to assume that it's type is void.
If it's called 10 times, but no results from it are used, it's fair to
make the same assumption. But you never know if 11th call will change
that assumption.
> xtensa and ARM are quite similar (as both are RISC) and many
> operations can be translated practically 1:1.
Well, there's RISC and RISC. Xtensa and ARM are on the opposite sides
of RISC, with Xtensa being pure MIPS-style RISC (thus, MIPS being the
closest arch to Xtensa), while ARM is full of ugly CISCy features like
flag register. Surely, you (almost) can translate pure, high-level RISC
like Xtensa/MIPS into ARM. Almost, because various issues will pop up,
like Xtensa having true 16 general-purpose regs, while ARM has 15, one
taken by PC.
Actually, you can translate Xtensa into a nicely readable C code,
that's what I have been doing for couple of years now,
https://github.com/pfalcon/xtensa-subjects/blob/master/2.0.0-p20160809/out.lst
is the whole ESP8266 codebase translated into such format.
You can postprocess it a bit further into fully valid C, build for
any arch, pass into any decompiler...
Good luck, and keep us posted!
>
> Regards,
>
> Vlad
[]