runnable Linux ELF executables in under 200 bytes

Alex Suykov c230449920 license 9 年之前
.gitignore 24c63ea643 initial commit 9 年之前
LICENSE c230449920 license 9 年之前
Makefile 24c63ea643 initial commit 9 年之前
README 24c63ea643 initial commit 9 年之前
elf32.s 24c63ea643 initial commit 9 年之前
elf64.s 24c63ea643 initial commit 9 年之前
elf_arm.s 24c63ea643 initial commit 9 年之前
elf_arm64.s 24c63ea643 initial commit 9 年之前
elf_mips.s 24c63ea643 initial commit 9 年之前
elf_mipsel.s 24c63ea643 initial commit 9 年之前
elf_x86.s 24c63ea643 initial commit 9 年之前
elf_x86_32.s 24c63ea643 initial commit 9 年之前
elf_x86_64.s 24c63ea643 initial commit 9 年之前
hello_arm.s 24c63ea643 initial commit 9 年之前
hello_arm64.s 24c63ea643 initial commit 9 年之前
hello_mips.s 24c63ea643 initial commit 9 年之前
hello_x86.s 24c63ea643 initial commit 9 年之前
hello_x86_32.s 24c63ea643 initial commit 9 年之前
hello_x86_64.s 24c63ea643 initial commit 9 年之前
tiny.ld 24c63ea643 initial commit 9 年之前

README

This is a set of tiny Hello world executables for Linux.
All they do is

write(1, "Hello!\n", 7)
_exit(0)

but it's done in as little bytes as possible. This particular
implementation stores the string in ELF header padding and
squashes Ehdr against Phdr on little-endian targets.

For context and the origins of the size-reducing tricks, see

http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html
http://mainisusuallyafunction.blogspot.com/2015/01/151-byte-static-linux-binary-in-rust.html
http://hookrace.net/blog/nim-binary-size/

Unlike the x86-focused projects above, this one attempts
to be relatively portable. GNU binutils are used instead of nasm,
and it is expected to work well with cross-compiling toolchains.

For most configurations, run something like

make ARCH=arm CROSS=arm-linux-gnueabi-

or set both variables in Makefile.
To build x86_32 with a native x86_64 toolchain, set

AS = as --x32
LD = ld -melf32_x86_64

Run resulting executables with appropriate qemu:

qemu-arm ./hello_arm

Use -strace option to verify it's working properly.