Borland 的 DOS 编译器,从其自身二进制文件重建。
Borland's DOS compilers, rebuilt from their own binaries

原始链接: https://github.com/abedegno/borland-reborn

Borland-reborn 从已发布的可执行文件中恢复经典 Borland DOS 编译器的源代码,使用 Borland 原始工具链逐字节重建每个程序,并通过真实名称、字段、注释和注解使其可读。 bc20 目录包含 Borland C++ 2.0 组件——BCC.EXE、CPP、TLINK、TASM、TLIB、MAKE、保护模式工具、实用程序、运行时模块和原生编译器端口——每个程序都可逐字节重建。 更多版本将跟进。 用户必须提供原始 Borland 程序。 设置包括下载工具链、安装 Python、DOSBox-X 和 Node,然后生成链接输入、编译、验证和链接。 模组构建允许修改,并通过 1,836 次编译验证。 文档涵盖设置、方法、模组、覆盖范围、贡献和许可:脚本和文档采用 MIT 许可证,而恢复的源代码仅供研究和保存。

一个 Hacker News 帖子介绍了一个 GitHub 项目,该项目从原始二进制文件逆向工程并重建了 Borland 的 DOS 编译器,可能使用了 AI。评论者争论由此生成的 C 代码的价值与可读性,指出它类似低层汇编,并且生成可编译的输出比创建可维护的源码更容易。有些人认为它可用于反编译、移植和编译器研究;另一些人则批评它是 AI slop。该帖还包含对 Borland IDE 的怀旧、指向其他反编译编译器的链接,以及关于遗留 COBOL 系统为何因风险、正确性和生态系统复杂性而继续运行在大型机上的切线讨论。还提出了许可担忧和工具限制。
相关文章

原文

Borland's DOS compilers, rebuilt from their own binaries.

This repository recovers the source code of classic Borland compilers from the published executables, so that the recovered C and assembly rebuild each executable byte for byte with the original Borland toolchain. Then it makes that source readable: real names, named record fields, comments on every file, and notes on what the compiler does and where it goes wrong.

Directory Product Status
bc20/ Borland C++ 2.0 (1991): the compiler BCC.EXE, CPP, TLINK, TASM, TLIB, MAKE, the protected-mode tools (TKERNEL, BCCX, TLINKX, TASMX) and the utilities, 22 executables in all; plus its run-time library modules and a native port of the compiler Every program rebuilds byte-identical; bc20/README.md lists each one

More Borland and Turbo versions will join as further top-level directories (tc201/, ...), sharing the scripts/ and the Exhume build tools.

You need the original Borland programs (not included: see NOTICE.md). The full guide is docs/SETUP.md; in short:

git clone --recurse-submodules https://github.com/abedegno/borland-reborn
cd borland-reborn
# 1. download Borland C++ 2.0 and Turbo C 2.01 from WinWorld (links in docs/SETUP.md)
python3 scripts/setup-toolchains.py --bc20 "Borland CPP 2.0 (1991) (3.5-720k).7z" --tc201 "<Turbo C 2.01>.7z"
# 2. Python packages and the DOS emulator (dosbox-x), node
python3 -m venv .venv && .venv/bin/pip install -r exhume/tools/requirements.txt
# 3. generate the link inputs from your own BCC.EXE (Borland C++ 2.0's compiler), then compile, verify and link everything
cd bc20/bcc
../../.venv/bin/python scripts/prepare.py
../../.venv/bin/python ../../exhume/tools/gate.py check --all

The last command compiles all 298 sources in DOS, checks every function against the original byte for byte, verifies every relocation and name, and links a new BCC.EXE that is identical to Borland's.

To change the compiler, use the modding build. It links the same sources with a layout TLINK chooses, so any function may grow or shrink, new data may go between any two data items, and new source files may be added. It is checked by running 1836 compiles with both compilers (Borland's own example programs and old GCC and cfront tests among them) and comparing every output, with the code and the data moved in several ways and with new and edited files. A tracing emulator shows which words of the data the compiler uses as addresses, and which of its code the tests run: 83% (bc20/bcc/docs/COVERAGE.md). See bc20/bcc/docs/MODDING.md.

docs/HOW-IT-WORKS.md explains the method: identifying the exact compiler and switches, matching each function, verifying what matching cannot see, linking the whole program with TLINK, and the readability pass that followed, all checked by the same byte-for-byte gate.

Contributing, licence and notice

Corrections to names, comments and findings are welcome: see CONTRIBUTING.md. The project's own scripts and documentation are MIT-licensed (LICENSE). The recovered sources are derived from Borland's copyrighted programs and are provided for study and preservation, with no rights claimed: read NOTICE.md.

联系我们 contact @ memedata.com