Hacker News

Favorites Setup
Creating Teensy ELF Executables for Linux (Or, "Size Is Everything") (1999) (muppetlabs.com)
2026-08-25 Tue | 72 points by Bluestein | original
[−]BruceEel · 2026-08-30 Sun 05:34 UTC · link
This is actually a lot of fun. Never did it on Linux, but Windows PE EXE files make similar tricks possible. Windows 95 in particular was very permissive. Using a (very primitive, by today's standards) hex editor I tried making the ".text" section begin halfway through the header and bang! ..it worked, a revelation of sorts. I imagine today's loaders may be a bit more strict because of security but I guess you can always make your own loader :)
[−]Panzerschrek · 2026-08-30 Sun 05:39 UTC · link
The program described in this article is as simple as possible. What about something more complex, like basic "hello world"? It requires at least one more syscall and several bytes more data.
[−]stevekemp · 2026-08-30 Sun 07:32 UTC · link
Take a look at the collections by the same author:

https://www.muppetlabs.com/~breadbox/software/tiny/home.html

There are some more complete programs there.

[−]Retr0id · 2026-08-30 Sun 12:46 UTC · link
My approach to crafting "small" ELFs (in the hundreds-of-bytes range, written in relatively normal C) is like so: https://github.com/DavidBuchanan314/kurl/blob/main/golfed/el...
[−]davidwritesbugs · 2026-08-30 Sun 05:47 UTC · link
I wonder how much of this could be done by a clever linker? There’s a lot of skill in there but how would an llm do, for the rest of us?
[−]dwattttt · 2026-08-30 Sun 09:42 UTC · link
A linker could do this, but "clever" isn't the adjective I'd use when something randomly breaks due to it not working to standard.
[−]mrlonglong · 2026-08-30 Sun 06:42 UTC · link
i386 are perhaps starting to die out. Has anything like this been done for amd64? Can we play such tricks with arm and aarch64?
[−]enoent · 2026-08-30 Sun 07:31 UTC · link
84 byte aarch64 ELF: https://tmpout.sh/2/14.html
[−]Retr0id · 2026-08-30 Sun 12:45 UTC · link
57 byte x86-64 ELF https://tmpout.sh/5/3.html
[−]1001111 · 2026-08-30 Sun 14:17 UTC · link
4 byte x86 .mut ELF https://tmpout.sh/4/13.html
[−]WalterGR · 2026-08-30 Sun 06:47 UTC · link
[−]qsera · 2026-08-30 Sun 06:50 UTC · link
Lot of useful info here! Good work!
[−]radicaldreamer · 2026-08-30 Sun 07:48 UTC · link
First experience with proper ELFs was using PS2 Linux ELFs to run homebrew and games and get past Sony’s restrictions
[−]guenthert · 2026-08-30 Sun 08:14 UTC · link
Oh, ELF file manipulation. I thought this would be about getting Linux to run on a Teensy.

https://forum.pjrc.com/index.php?threads/linux-on-teensy-4-x...

[−]sylware · 2026-08-30 Sun 11:45 UTC · link
This is the wrong end of the issue. ELF for executables and dynamic libs is obsolete on modern hardware (same for microsoft PE+).

I am now using for most of my projects a exe/dynamic lib format of my own. This file format is so miminal a simple RFC will suffice. BUT, I will need to build dynamic libs which are system interfaces (for instance userland drivers like mesa) with this file format: problem, c++ and its runtime (and probably other similar languages with their runtimes)... as usual...

Well, I am still removing stuff from my file format, because I think this is not yet "minimal and enough" on modern hardware architecture (I think I have still too much complexity in the tracker of loaded dynamic libs).

[−]Retr0id · 2026-08-30 Sun 12:48 UTC · link
> ELF for executables and dynamic libs is obsolete on modern hardware (same for microsoft PE+)

This is... extremely not true?

[−]BruceEel · 2026-08-30 Sun 14:33 UTC · link
> I am now using for most of my projects a exe/dynamic lib format of my own. This file format is so miminal a simple RFC will suffice.

That's great! Have you published it? If not, please consider doing so.