Skip to content
Tech News
← Back to articles

The smallest ELF executable (2021)

read original get Tiny ELF Executable Kit → more articles
Why This Matters

This article highlights the ongoing efforts to minimize ELF executable sizes, showcasing how tiny, efficient Linux binaries can be crafted. Such advancements are significant for embedded systems, security, and performance-critical applications, emphasizing the importance of understanding low-level system components. It also demonstrates the evolving capabilities of developers to push the boundaries of minimalism in software design.

Key Takeaways

Tiny ELF Files: Revisited in 2021

October 11, 2021

Quick edit: While I work on a proper update, I'll note here that several posters on reddit and hackernews have pointed out ways to bring the total size of the program down to 105 bytes while still printing the full "Hello, world!" Much credit goes to Josh Triplett, who produced the 105-byte version which you can find here. I fully plan to include this in an updated version of the page!

Here are the tricks I wasn't aware of when writing the article:

The Inspiration

Many years ago, I came across this famous article, which I largely credit changing the trajectory of my career. At the time, I was an intern working on a the build system for a fairly large Java code base, so I was particularly susceptible to an article attempting to do the polar opposite of "enterprise Java:" strip away all but the most essential components required to define a valid Linux program. (Before removing even more!)

In short, the article walks through the creation of a 45 byte (!) Linux binary. While the resulting binary is arguably not an entirely "valid" ELF file, it was at least one that Linux could run. Or at least at the time. Perhaps unfortunately, Linux has gotten more strict about ELF loading since the article's original publication (I haven't been able to track down the original date, but it was already around in the early 2000's), and the migration of many systems to 64-bit CPUs has rendered the older 32-bit ELF binary less relevant.

My Goals

Like the article I take for inspriation, I set out to create the smallest ELF file that runs on modern Linux (kernel 5.14 at the time of writing). Like the original article, I will still use the nasm assembler, since it is easy to install, I love its syntax, and it remains one of the best x86 assemblers available.

However, I have a few goals that aren't quite like the original article:

... continue reading