4 ms·
A whirlwind tutorial on creating teensy ELF executables for Linux (1999)
- dang 2y agoRelated. Others? A Whirlwind Tutorial on Creating Teensy ELF Executables for Linux - https://news.ycombinator.com/item?id=32524007 https://news.ycombinator.com/item?id=32524007 - Aug 2022 (10 comments) A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux (1999) - https://news.ycombinator.com/item?id=21846785 https://news.ycombinator.com/item?id=21846785 - Dec 2019 (22 comments) A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux (2005) - https://news.ycombinator.com/item?id=11709247 https://news.ycombinator.com/item?id=11709247 - May 2016 (5 comments) Creating Really Teensy ELF Executables for Linux - https://news.ycombinator.com/item?id=8745024 https://news.ycombinator.com/item?id=8745024 - Dec 2014 (13 comments) The Teensy Files: Creating teensy ELF executables for Linux - https://news.ycombinator.com/item?id=8642734 https://news.ycombinator.com/item?id=8642734 - Nov 2014 (7 comments) A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux - https://news.ycombinator.com/item?id=5016434 https://news.ycombinator.com/item?id=5016434 - Jan 2013 (14 comments) Tutorial on Creating Really Teensy ELF Executables for Linux - https://news.ycombinator.com/item?id=875077 https://news.ycombinator.com/item?id=875077 - Oct 2009 (16 comments) 3998-byte executable reduced to 45 bytes - https://news.ycombinator.com/item?id=68056 https://news.ycombinator.com/item?id=68056 - Oct 2007 (10 comments)
- jart 2y agoPlus if you want them to run on four OSes: https://justine.lol/sizetricks/#elf https://justine.lol/sizetricks/#elf
- ptspts 2y agoShameless plug: write your program in C, get almost as little size overhead as in the Whirlwind turorial: https://github.com/pts/minilibc686 https://github.com/pts/minilibc686 (libc, compiler, linker, settings)
- le-mark 2y agoDoes anyone recall an “intro to computing” style book that was available free online and starts with using the gas assembler and talked a lot about elf format executables? I lost the link a while ago and don’t recall the name.
- tiu 2y agoYou are probably thinking about Programming from the Ground Up by Jonathan Bartlett. There are many others in the same style though. He also has a newer book if I recall right. https://www.amazon.com/Programming-Ground-Up-Jonathan-Bartlett/dp/1616100648 https://www.amazon.com/Programming-Ground-Up-Jonathan-Bartle... https://download-mirror.savannah.gnu.org/releases/pgubook/ https://download-mirror.savannah.gnu.org/releases/pgubook/
- deater 2y agofor those excited about tiny ELF executables, or tiny programs in general, check out the Lovebyte size-coding demoparty happening next weekend. It's likely there will be a few tiny ELF entries there.
- LegionMammal978 2y agoThat's neat, I didn't know that there was much sizecoding activity with ELFs, except for the BGGP competitions [0]. (Mainly because it's not nearly as easy to output graphics than on all the old-school platforms, I'd imagine.) Does Lovebyte publish previous years' demos anywhere? [0] https://binary.golf/ https://binary.golf/
- deater 2y agoI don't know if there's a good way to search for them. Most of the Lovebyte entries can be found on pouet or demozoo.org but I don't know if there's an easy way to filter out only Linux entries. I've written a few sizecoded raspberry pi entries, there's even a writeup of one of them in tmp.out where I loaded some code into the ELF headers https://tmpout.sh/3/08.html https://tmpout.sh/3/08.html
- LegionMammal978 2y agoAh, then I suppose you'd be aware of my own forays into 64-bit ELFs (https://tmpout.sh/3/22.html https://tmpout.sh/3/22.html)! I really should get around to publishing my writeup of the 73-byte minimum on Linux. (At least, it's 73 bytes for x86-64, since '\177E' at the start of the file jumps to byte 71, but it may be different under AArch64.) I have a nearly-complete draft, but I got caught on some oddities around the vDSO mapping which may or may not have changed across kernel versions, especially since the time I wrote it. Perhaps I should just jettison that section entirely and get the article out, since it's not like any of the x86 vDSOs have useful gadgets anyway.
- duskwuff 2y agoPouet certainly has platform filtering; try: https://www.pouet.net/prodlist.php?type[]=32b&type[]=64b&type[]=128b&type[]=256b&platform[]=Linux&order=release&reverse=1 https://www.pouet.net/prodlist.php?type[]=32b&type[]=64b&typ...
- cryne 2y agoI tried to replicate this on my 64 bit machine, so nasm -f elf64 tiny.s && ld -s tiny.o ; tiny.asm BITS 64 GLOBAL _start SECTION .text _start: mov eax, 1 mov ebx, 42 int 0x80 and this lands me at 4320 bytes! Why is there such a stark difference?
- oguz-ismail 2y ago> Why is there such a stark difference? Your linker must align the .text section to the page size (often 4096 bytes). If you open the binary with a hex editor you'll see lots of null padding.
- yjftsjthsd-h 2y agoIf that's a hard lower limit, then it really invites a different sort of code golf / demo to see how much functionality you can stuff into a 4K(ish) binary
- oguz-ismail 2y ago> If that's a hard lower limit I think it's some sort of optimization (retrieving one page of memory should be easier than two, right?). With GNU ld I can do ld -s -Ttext=0x4000b0 tiny.o and shave off 3920 bytes on my system.
- LegionMammal978 2y agoThe real hard limit is 73 bytes [0], to actually run any code in the executable without segfaulting right away. You can cram about 3 simple syscalls into that limit (e.g., my BGGP4 submission [1], which copies the executable to another file), including the final exit() or exit_group() if you want your program to terminate cleanly. Strings are very costly: I couldn't get a Hello World below 77 bytes. [0] https://tmpout.sh/3/22.html https://tmpout.sh/3/22.html [1] https://github.com/binarygolf/BGGP/pull/3/files https://github.com/binarygolf/BGGP/pull/3/files, assembly at https://gist.github.com/LegionMammal978/347c939def56dcba449cb54dd9ee22f4 https://gist.github.com/LegionMammal978/347c939def56dcba449c...