Cramming a tiny program into a tiny ELF file
tmpout.sh
tmpout.sh
Also, if you're interested in more ELF shenanegans, check out the rest of tmp.0ut #3 [0]; the other authors have been working on some really neat stuff!
jmp 0x14
0x14:I wonder if that's enough bytes that implementing a tiny interpreter would work; certainly it would win for slightly larger sizes (say, 4KiB).
Meanwhile, you're right that an ad-hoc interpreter will always be the answer for larger sizes. (It's very common in regular sizecoding to use a compressed executable with some code to unpack itself.) But since there simply isn't enough space here for complex logic, our only remaining avenue is to make the bytes work double and triple duty, whether through "Ouroboros Programming" or through regular subroutines. And of course, these kinds of techniques remain important when golfing the interpreter/decompressor itself, which has to be rooted in bare machine code.
To plug my own entry in the genre, back in 2006 a few members of the Nintendo DS emulation scene tried to put together the smallest DS ROM that would still do something visible on the system: https://imrannazar.com/hacks/the-smallest-nds-rom
We ended up with a 352-byte file with two minimal executables, for the ARM7 and ARM9 cores. I've yet to see a .nds file smaller than that.
https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-...
The annotated ELF file contains two types of comment annotations corresponding to the different software that parses it.
https://github.com/oriansj/bootstrap-seeds/blob/master/POSIX...
Or the eternal busy beaver question: how big an output can be expressed with a program of a given number of bits?
We know the answer up to 36 bits (578960446186580977117854925043439539266349923328202820197287920039565648199686) [1] and that within at most 13 more bits, Graham's Number will be surpassed [2].
[2] https://codegolf.stackexchange.com/questions/6430/shortest-t...
(hmm... I haven't done this since widespread W^X; it might be a little more difficult these days but if so anyone who's had to write ROMable code will know the usual workarounds)
(for the historians, we're basically discussing the difference between OMAGIC [0407] and NMAGIC [0410] a.out formats, both of which are much simpler than ELF)
PS. salut, balou !
Fuzzing might be more useful for something like the dynamic loader, which has far more features than the kernel loader, and is far more eager to read user-supplied data.