11 ms·
It's interesting to compare with DOS, where a do-nothing program is a single byte: C3 A Hello World is roughly 20 bytes, the bulk of it being the string i
by userbinator 10y ago
It's interesting to compare with DOS, where a do-nothing program is a single byte:
C3
A Hello World is roughly 20 bytes, the bulk of it being the string itself:
95 BA 07 01 CD 21 C3 48 65 6C 6C 6F 20 77 6F 72 6C 64 21 24
The ELF in the article, which is 130 by my count, could be reduced to 45 with some tricks:
http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm...
Also worth looking at is what the demoscene has done with binaries of 128 bytes or less:
http://www.pouet.net/prodlist.php?type%5B%5D=32b&type%5B%5D=64b&type%5B%5D=128b&page=1 http://www.pouet.net/prodlist.php?type%5B%5D=32b&type%5B%5D=...
- SonOfLilit 10y agoWhen working on this[1], I spent three sleepless days shaving bytes from the included Brainf*ck interpreter. The last byte probably took about 5 hours. Then I showed it to a security researcher I knew and he immediately replied "oh, this is so cool! also, you can replace the last four bytes with C3". Oh man, that hurt :-) [1] https://news.ycombinator.com/item?id=7943514 https://news.ycombinator.com/item?id=7943514
- joeyh 10y agojoey@darkstar:~>touch true joey@darkstar:~>chmod +x true joey@darkstar:~>ls -l true -rwxr-xr-x 1 joey joey 0 Nov 18 10:53 true* joey@darkstar:~>if ./true; then echo yay; fi yay Just saying.
- deleted 10y ago[deleted]
- aexaey 10y agoAlso, you don't actually need a "true" binary for a shell of any reasonable vintage: # which true /usr/bin/which: no true in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin) # true; echo $? 0
- jkn 10y agoOn Unix, an empty file is a working implementation of the "true" command (provided that is in the PATH and set as executable). This is because it is interpreted as a shell script, and an empty script of course exits successfully. I'm pretty sure this was actually used in some Unix/Linux version, and they got bug reports due to the poor performance (executing a shell to do nothing), which makes for a lot of bugs per line of code. Unfortunately I can't find a reference. Instead I found that AT&T Unix implemented "true" as an empty file... with a copyright notice! See http://trillian.mit.edu/~jc/humor/ATT_Copyright_true.html http://trillian.mit.edu/~jc/humor/ATT_Copyright_true.html
- posterboy 10y ago>demoscene the smallest prod on pouet is a zero byte com file. of course it errors. With C3 you have skewed the definition of a program, already, anyhow. Edit: Queue the story of the empty dos program that was nevertheless useful to prompt the OS's program loader to do some memory management with useful side effects
- deleted 10y ago[deleted]
- tomcam 10y agoThat's a little misleading because what you described is a .COM file. They're limited to 64K, non-relocatable, and a holdover from the CP/M days. An .EXE is closer to an ELF in format. It's relocatable and necessarily larger in size.