Borland C++ 2.0 Compiler Source Reconstructed

As the successor to Turbo C++, Borland C++ was a staple of professional IDEs for C and C++ development, starting with the initial 2.0 release in 1991. Being a commercial project the original source code for the toolchains were naturally not made available by Borland, but thanks to the efforts of [Abedegno] we have now got what is claimed to be a byte-perfect recreation, in the sense that the binaries compiled using the toolchain are identical to the original toolchain.

The process of creating the source from the original toolchain binaries is detailed in a separate document, including the use of [Abedgno]’s Claude Code-based Exhume tool to assist in the effort.

Having the source code for BC++ 2.0 available is probably most useful for projects that deal with DOS-based software from the same era, as well as for purely historic interest reason. When BC++ 2.0 was released, the C programming language had only just seen itself standardized in the form of C89, and C++’s initial standard in 1998 was still years away.

Thanks to [Stephen Walters] for the tip.

14 thoughts on “Borland C++ 2.0 Compiler Source Reconstructed”

  1. This is a great reverse-engineering writeup. Reconstructing a byte-perfect BC++ 2.0 from release binaries is exactly the kind of grinding work that rarely gets documented. The Exhume approach of decompiling and correlating against known compiler output is smart. For anyone who wants to go deeper into decompilation, binary diffing and source reconstruction, there’s an active reverse-engineering community over at https://cayenne.to with tutorials and writeups that pair well with this kind of project. Nice tip, Stephen.

  2. I learned C with BC++. Thankfully I saw the light and switched to gcc soon (with Lubuntu 12 iirc)

    Although I will say, the discipline to define variables at the beginning of functions is a good thing BC instilled in me. When starting to work professionally I was taken aback whenever someone dropped a uint32_t or whatever in the middle of a loop or wherever they decided was a good place. Nothing wrong with it, it just looks nice to have all the variables in your head when you start following the code

    I guess its just a matter of style, I like mine better.

    1. If variable is used only within the loop then it makes perfect sense to put it there. Otherwise you’re polluting the namespace of your function, confuse code completion and others who may have to maintain your code.

    2. The risk with defined at the top is that usage maybe quite far away.

      For a loop I might care if it’s a int8_t or uint8_t, yet in unlikely to remember which was used once I’m looking at the loop.

      For me stylistically what I want is code that reduces the cognitive burden as much as possible.

    3. I use a hybrid method that works well for me but might possibly drive other people insane.

      All important variables that get reused throughout a function are declared at the beginning of the function and have appropriately explanatory names.

      Variables such as loop counters (and anything used for an obvious immediate but temporary purpose) are given a single character name (uint_8t i;), with a comment to explain if needed.

    4. I like the mixed mode. What is uses throughout the entire function is declared at the top. Local stuff is declared at that point where I need it.

      And I thougt that variable memorys declared inside curly braces is reused. Like { int a=3; } {int b=4;} only allocated space for one int.

      https://godbolt.org/z/EaY9j3v6o shows a mixed picture.

    5. It’s actually much better to have the variables in the minimum scope possible. So yes, ones that are used in the whole function should be declared at the top, but if you have a for loop that has variables that are only used inside it – then that is where they should be declared..

  3. So Turbo C and Borland C were of the same era as Thompson’s famous speech that (summarized) said “To what extent should one trust a statement that a program is free of Trojan horses? Perhaps it is more important to trust the people who wrote the software.“

    ( https://dl.acm.org/doi/epdf/10.1145/358198.358210 )

    Meaning: A compiler can be invisibly compromised to produce code with security holes and, further, any subsequent compiler created with that software can also be invisibly infected.

    Maybe the process of reverse-engineering a compiler as described here can reveal such deception? (depending on whether the reverse-engineered version is a work-alike, or actually, truly byte-similar to the original)

  4. Noice. I’ve noticed, with great satisfaction, that despite the corporate push to hurd people into closely controlled, heavily monetized, and bloated, pipelines there is an increasingly hard pushback from the YOUNGER generations.

  5. Byte-identical binaries are a great acceptance test for AI-assisted reverse engineering, because there’s no arguing with a diff. I’d love to read more about how the Exhume tool kept enough of the toolchain in view at once to make that comparison work.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.