Thread: Decompiling an old GCC for backend extraction

  1. #1
    Registered User
    Join Date
    Sep 2006
    Location
    Beaverton, Oregon, United States
    Posts
    176

    Decompiling an old GCC for backend extraction

    There is an old gcc(2.6.3) that has a unique backend for a custom set of risc's. The people who worked on it for contract was a company called BrainStorm who never complied with the GPL and never released the sources despite numerous requests by the company who contracted them and the community back when they were releasing incremental versions of this.

    We now would like to have the sources, or backend so that it can be recompiled on a new gcc. And some of us are wondering about decompiling it. I heard that decompiling is messy and extremely confusing.

    I was wondering if anyone here has any experience with this and can give us some pointers or let us know if this would even be worth it or not?

    Thank you all for your time.

  2. #2
    Lurker
    Join Date
    Dec 2004
    Posts
    296
    Quote Originally Posted by A34Chris View Post
    There is an old gcc(2.6.3) that has a unique backend for a custom set of risc's. The people who worked on it for contract was a company called BrainStorm who never complied with the GPL and never released the sources despite numerous requests by the company who contracted them and the community back when they were releasing incremental versions of this.

    We now would like to have the sources, or backend so that it can be recompiled on a new gcc. And some of us are wondering about decompiling it. I heard that decompiling is messy and extremely confusing.

    I was wondering if anyone here has any experience with this and can give us some pointers or let us know if this would even be worth it or not?

    Thank you all for your time.
    I can almost guarantee that it is not worth the work to do so.

    It will not be useful as a backend for a new GCC even if you do decompile it. And decompiled code is not really in a state to be modified. So you will probably have to reverse engineer the backend from the decompiled code and then reimplement it and after that modify it so that it works with a newer GCC.

    All in all, it is probably less work to just reimplement it from scratch. Unless the problem is lack of documentation?
    "A Professor of Computer Science gave a paper on how he uses Linux to teach his undergraduates about operating systems. Someone in the audience asked why use Linux rather than Plan 9?' and the professor answered:Plan 9 looks like it was written by experts; Linux looks like something my students could aspire to write'."

  3. #3
    Registered User
    Join Date
    Sep 2006
    Location
    Beaverton, Oregon, United States
    Posts
    176
    Thank you for the input!

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by A34Chris View Post
    There is an old gcc(2.6.3) that has a unique backend for a custom set of risc's. The people who worked on it for contract was a company called BrainStorm who never complied with the GPL and never released the sources despite numerous requests by the company who contracted them and the community back when they were releasing incremental versions of this.

    We now would like to have the sources, or backend so that it can be recompiled on a new gcc. And some of us are wondering about decompiling it. I heard that decompiling is messy and extremely confusing.

    I was wondering if anyone here has any experience with this and can give us some pointers or let us know if this would even be worth it or not?

    Thank you all for your time.
    How custom is custom? If was publicly released you should check LLVM. If it isn't there, you could implement this architecture in LLVM yourself (this would be much easier than implementing it in GCC).

    Otherwise, if you don't have any specs, and reverse engineering is your only option, I would not decompile the compiler, rather I would compile (with all optimizations turned off) various versions of programs making use of these features you need, and decompile those programs.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Location
    Beaverton, Oregon, United States
    Posts
    176
    Quote Originally Posted by Yarin View Post
    How custom is custom? If was publicly released you should check LLVM. If it isn't there, you could implement this architecture in LLVM yourself (this would be much easier than implementing it in GCC).

    Otherwise, if you don't have any specs, and reverse engineering is your only option, I would not decompile the compiler, rather I would compile (with all optimizations turned off) various versions of programs making use of these features you need, and decompile those programs.
    The chips are custom, they are not off the shelf in any way. Absolutely unique.

    Actually the people/company that made them then went to work for Nvidia and I think the new gfx chips in the PS4 bear a somewhat vague similarity to what was learned through that if my understanding is correct.

    The gcc was actually not publicly released until several years later sans sources. These contractors were in no way cooperative. And are still not.

    All we have is the old 2.6.3 binary.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Location
    Beaverton, Oregon, United States
    Posts
    176
    Quote Originally Posted by Yarin View Post
    Otherwise, if you don't have any specs, and reverse engineering is your only option, I would not decompile the compiler, rather I would compile (with all optimizations turned off) various versions of programs making use of these features you need, and decompile those programs.
    This is interesting. And it would be easier to reverse engineer a backend from this information rather than the actual decompiled backend? Am I misunderstanding?

  7. #7
    Registered User
    Join Date
    Sep 2006
    Location
    Beaverton, Oregon, United States
    Posts
    176
    We have the specs of the chips. We have the assemblers. We have the development documentation. We have programmers with 20 year experience working on them.

    We have no one skilled at retargetting compilers.

  8. #8
    Lurker
    Join Date
    Dec 2004
    Posts
    296
    Quote Originally Posted by A34Chris View Post
    We have the specs of the chips. We have the assemblers. We have the development documentation. We have programmers with 20 year experience working on them.

    We have no one skilled at retargetting compilers.
    Creating an usable backend that generate passable code should be doable for an experienced developer if he is familiar with the instruction set of the target chip and if he is experienced in C/C++. It all depends on the quality you are aiming for in the end though.

    Personally I would do what Yarin suggested and go for Clang/LLVM instead of GCC for at least two reasons. From my experience it is probably easier to implement it for LLVM and it is probably easier to have the code accepted upstream. Having code accepted for GCC requires you being friendly with a GCC developer more or less.

    Seeing as it is for a custom chip, you might have a hard time getting upstream to accept your code anyway, but maybe you where about to maintain it yourselves anyway?
    "A Professor of Computer Science gave a paper on how he uses Linux to teach his undergraduates about operating systems. Someone in the audience asked why use Linux rather than Plan 9?' and the professor answered:Plan 9 looks like it was written by experts; Linux looks like something my students could aspire to write'."

  9. #9
    Registered User
    Join Date
    Sep 2006
    Location
    Beaverton, Oregon, United States
    Posts
    176
    ok thanks guys.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Atlanta - C++/Unix/Linux Backend Development
    By jojoblue in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 08-07-2010, 02:54 AM
  2. Java bytecode backend for gcc?
    By cyberfish in forum C++ Programming
    Replies: 8
    Last Post: 05-08-2008, 08:41 AM
  3. Decompiling an exe
    By BJWom23 in forum C++ Programming
    Replies: 3
    Last Post: 12-16-2003, 12:51 AM
  4. Backend Compiler Error
    By ginoitalo in forum C Programming
    Replies: 4
    Last Post: 02-10-2002, 01:49 AM
  5. visual basic decompiling
    By esilja in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-18-2001, 06:21 PM