-5

I have application .BIN that is used in Arm processor, I want to get the source file back to C source code, because i lost the source files but I still have .bin . The .bin file created using arm -elf -GCC or arm-elf-g++ to create, I want it to get .c file or CPP file so i can rebuild the app.

I tried .bin to CPP converter

genpfault
  • 51,148
  • 11
  • 85
  • 139
  • 7
    You can't get it "back" as it lost most of the information during compilation. You can use some kind of decompiler software though to get something remotely resembling the original sources. – Eugene Sh. Aug 19 '19 at 21:27
  • 2
    @EugeneSh. You mean "barely resembling the original sources". – S.S. Anne Aug 19 '19 at 21:30
  • 1
    @JL2210 Apparently modern tools are not that bad at all. I was really surprised how well some customer have managed to decompile our product from bare "ARM bin" – Eugene Sh. Aug 19 '19 at 21:32
  • @EugeneSh. Really? Even on a large tested open-source decompiler (retdec), it barely gives correct results, even with debug information. – S.S. Anne Aug 19 '19 at 21:33
  • @JL2210 What do you mean by "correct"? It is correct for sure. the main concern is how readable it is, right? – Eugene Sh. Aug 19 '19 at 21:34
  • @EugeneSh. It doesn't give the right code (doesn't even compile). – S.S. Anne Aug 19 '19 at 21:36
  • 1
    @JL2210 I guess it's a matter of settings. Well, these guys used it to analyze security stuff, not to compile it back. – Eugene Sh. Aug 19 '19 at 21:37
  • Difficulty is increased if the optimization settings were set to high. The compiler can remove code that wasn't executed or simplify functions and loops. – Thomas Matthews Aug 19 '19 at 23:34

1 Answers1

2
static unsigned int more_fun ( unsigned int x)
{
    return(x+1);
}
unsigned int fun ( void )
{
    unsigned int ra;
    unsigned int rb;

    rb=0;
    for(ra=0;ra<20;ra++)
    {
        rb+=more_fun(ra);
    }
    return(rb);
}

produces

00000000 <fun>:
   0:   e3a000d2    mov r0, #210    ; 0xd2
   4:   e12fff1e    bx  lr

explain how you think you are going to get all that code back from these 2 instructions?

Extreme example but very much demonstrates the impossibility of replacing information that has been completely removed.

old_timer
  • 69,149
  • 8
  • 89
  • 168