lld file format as native OS executable format

Hello,

Would it be feasible to use the internal lld file format as the native executable format for an OS? Are there performance or space considerations that would make this a poor choice?

Cheers,
Shea Levy

P.S. please CC me on replies, I'm not subscribed.

Hello,

Would it be feasible to use the internal lld file format as the native
executable format for an OS? Are there performance or space
considerations that would make this a poor choice?

By lld, do you mean the LLVM IR bitcode format, or are you referring to something else?

As far as using LLVM IR as a format for executables, there was a research paper on that topic with an older version of LLVM (http://llvm.org/pubs/2003-10-01-LLVA.html). You'd probably want to redo the experiments on file size and such since LLVM's on-disk format has changed considerably over the years, but it might give you an idea of what issues to consider and what trouble spots there might be.

Also note that there's follow-on work to support an entire OS on the LLVM IR without the inline assembly language feature. Just look for the publications written by me if you need that.
:slight_smile:

The more significant challenge, I think, would be translating LLVM IR to native code on-the-fly. That'll add overhead; you will probably want a way to cache native code for executables, and that adds some new issues into OS design (such as how you securely fetch and update the native code translations).

To summarize, is it feasible? Yes. Is it a good idea? I'm not certain; it definitely depends on what environment your OS is going to run in and what your goals are.

Cheers,
Shea Levy

P.S. please CC me on replies, I'm not subscribed.

Please note that I had to approve your message to the mailing list. It is better if you subscribe and then disable delivery of messages. I usually only approve messages from non-subscribers once in the morning when I receive an email about the pending requests from yesterday.

-- John T.

Shea,

Feasible? Sure, anything is feasible. A good idea? Not really. The internal lld file format is an _intermediate_ data structure designed to make creating the final executable straightforward and fast. It isn't designed to be an executable format itself. In fact, the reason why linkers can often be slow is because the intermediate and final object file formats are conflated.

davez

Hello,

Would it be feasible to use the internal lld file format as the native
executable format for an OS? Are there performance or space
considerations that would make this a poor choice?

By lld, do you mean the LLVM IR bitcode format, or are you referring to something else?

I meant the format used by the nascent lld project (lld.llvm.org). The scenario I had in mind would involve native code inside the relevant atoms.

Shea,

Feasible? Sure, anything is feasible. A good idea? Not really. The internal lld file format is an _intermediate_ data structure designed to make creating the final executable straightforward and fast. It isn't designed to be an executable format itself. In fact, the reason why linkers can often be slow is because the intermediate and final object file formats are conflated.

Hm, OK. Does the target executable format play a role in the intermediate steps the linker takes? That is, are there certain features or optimizations that only work for specific target formats?

Shea,

Feasible? Sure, anything is feasible. A good idea? Not really. The internal lld file format is an _intermediate_ data structure designed to make creating the final executable straightforward and fast. It isn't designed to be an executable format itself. In fact, the reason why linkers can often be slow is because the intermediate and final object file formats are conflated.

Hm, OK. Does the target executable format play a role in the
intermediate steps the linker takes? That is, are there certain features
or optimizations that only work for specific target formats?

Yes, the target format determines the features available and passes run. For instance, each format handles shared object linkage differently. The atom format is able to represent different formats, but any actual file is specific to an output format.

- Michael Spencer