Unofficial Hacker News companion — get notified on comment replies, and more.

Borland's DOS compilers, rebuilt from their own binaries (opens external site)

262 points by frostbyte7 3 days ago | github.com | 100 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (8)

  1. Nice!

    I'm quite far with Microsoft C 5.1, I wonder how much similarity there is, if any.

    Replies (2)
    1. Not a lawyer, but I guess since the binaries for that version (plus MASM and more) are available with a MIT license, it would be OK to decompile and distribute the source code too?

      https://github.com/microsoft/MS-DOS/tree/main/v4.0/src/TOOLS

      Not that I have found anything that I felt like I wanted to change. Maybe bring it up to full ANSI C89? It is already quite close though. Think there was some minor thing I ran into that was missing, but usually it just works to treat it as C89, and LLMs seem to have no problem with it either.

    2. what was Microsoft-C 5.1 build with out of curiosity? was it build with version 4?
      Replies (1)
      1. It seems like it was built with some intermediate version between 5.0 and 5.1.

        The copyright strings have the year 1988, while 5.0 has 1987.

        The runtime library mostly fits the library shipped with 5.1, but a couple of functions fit 5.0 instead, and a couple others don't fit either versions.

        Replies (1)
        1. that must make it much harder to retrieve the sources, how do you know if you found a binary match if neither version fits? or will you leave these at behaviour match only? i have been binary matching with an agent a game built with 6.00 and i did think about starting binary match for the compiler itself, just to get more leverage at the task, because the game pipeline keeps getting stuck.
          Replies (1)
          1. I got distracted by other projects recently, but the idea is that we have two stages to the problem.

            Our main goal from reverse engineering the compiler is to understand how it works and to allow us to decompile other stuff better. That means that for the most part, binary identity of the compiler's decompilation isn't required - we can always use the original to verify the output is identical.

            So at the moment, behavioral identity is good enough.

            Once we have the entire compiler understood, we can try to tweak the reconstructed code to get a binary match, or alternatively, prove it couldn't have been compiled with itself.

            Replies (1)
            1. i would be quite interested to peek into 5.1 source code or maybe start working on 6.00 on top of it. do you plan any releases?

              Continue this thread (1 replies) →