├── README.md └── tiny.asm /README.md: -------------------------------------------------------------------------------- 1 | tiny-elf 2 | ======== 3 | A very tiny ELF (Executable and Linkable Format) executable, that does exactly the same as 4 | ``` 5 | int main(void) { 6 | return 42; 7 | } 8 | ``` 9 | but a 100 times thinner. 10 | 11 | #### Source #### 12 | 13 | http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html 14 | 15 | ([cached version](http://webcache.googleusercontent.com/search?q=cache%3Ahttp%3A%2F%2Fwww.muppetlabs.com%2F~breadbox%2Fsoftware%2Ftiny%2Fteensy.html)) 16 | 17 | #### Run it #### 18 | 19 | ``` 20 | $ nasm -f bin -o a.out tiny.asm 21 | $ chmod +x a.out 22 | $ ./a.out ; echo $? 23 | 42 24 | $ wc -c a.out 25 | 45 a.out 26 | ``` 27 | 28 | #### Credits #### 29 | 30 | All credits to muppetlabs.com 31 | -------------------------------------------------------------------------------- /tiny.asm: -------------------------------------------------------------------------------- 1 | ; tiny.asm 2 | ; All credits to muppetlabs.com 3 | ; code from [muppetlabs.com/~breadbox/software/tiny/teensy.html] 4 | 5 | BITS 32 6 | 7 | org 0x00010000 8 | 9 | db 0x7F, "ELF" ; e_ident 10 | dd 1 ; p_type 11 | dd 0 ; p_offset 12 | dd $$ ; p_vaddr 13 | dw 2 ; e_type ; p_paddr 14 | dw 3 ; e_machine 15 | dd _start ; e_version ; p_filesz 16 | dd _start ; e_entry ; p_memsz 17 | dd 4 ; e_phoff ; p_flags 18 | _start: 19 | mov bl, 42 ; e_shoff ; p_align 20 | xor eax, eax 21 | inc eax ; e_flags 22 | int 0x80 23 | db 0 24 | dw 0x34 ; e_ehsize 25 | dw 0x20 ; e_phentsize 26 | db 1 ; e_phnum 27 | ; e_shentsize 28 | ; e_shnum 29 | ; e_shstrndx 30 | 31 | filesize equ $ - $$ --------------------------------------------------------------------------------