Osegi
Software·2 min read

Borland C++ 2.0 source code rebuilt from BCC.EXE, byte for byte

Borland never released the source of Borland C++ 2.0. A project called borland-reborn rebuilt it from the 1991 binary, and it compiles back to an identical BCC.EXE.

A vintage DOS screen showing a Borland C++ 2.0 command-line compiler prompt next to lines of recovered C source code.
Image: Хабр

Borland C++ 2.0 shipped in 1991, and its source code was never made public. Now a version exists anyway, reconstructed from the compiler's own executable. Build it with Borland's original toolchain and you get a BCC.EXE with the same SHA-256 hash as the real one.

The project is called borland-reborn. It holds 298 source files in 15 directories: 265 in C (from Borland C++ 2.0 and Turbo C 2.01) and 33 hand-written TASM assembly modules. The original split between compiled C and assembly was kept. Nothing was forced into C, and nothing compiled was left as assembly. The standalone preprocessor, CPP.EXE, also rebuilds byte for byte.

How was Borland C++ 2.0 source recovered from a binary?

The first job was guessing the right compiler version and its switches, because a function only matches when every one of them is correct. Along the way the author found that 29 library modules were built with Turbo C 2.01, not Borland C++. Then functions were tuned one at a time until each byte matched.

Only after that was the code made readable: about 3,100 names restored or invented, 300 record fields, 40 record layouts and roughly 10,000 lines of comments. Every later edit, renames included, has to pass the same byte-for-byte test.

What did it find inside the compiler?

The parser is hand-written recursive descent, with an operator-precedence expression parser and no yacc. The notes also list probable bugs in the original. strrchr reads one byte before an empty string, and space freed in the precompiled-header file is never reused.

The repository does not include Borland's programs, so you have to get the original distributions yourself to rebuild. The scripts and documentation are MIT-licensed. The recovered source comes from copyrighted Borland software and is published for study and preservation, with no rights claimed.

The work was done with Exhume, a toolkit for Claude Code that grew out of decompiling Ultima Underworld II. A third part of the project, using BCC.EXE as a tool for decompiling other Borland-built games, has only just started.

Apps worth a look

SUMO: the number puzzle

Tap the right tiles, add them up, hit the target. Easy to learn, hard to master. Free, for all ages.

Tags:borland c++borland-rebornreverse engineeringdecompilationretrocomputingexhume

More from this day

See all →

More in: Software

See all →