Skip to content

Instantly share code, notes, and snippets.

@michidk
Last active October 10, 2026 12:14
Show Gist options
  • Select an option

  • Save michidk/b998e4150bb72930a0f43e2793a1e074 to your computer and use it in GitHub Desktop.

Select an option

Save michidk/b998e4150bb72930a0f43e2793a1e074 to your computer and use it in GitHub Desktop.
114-byte Linux ELF32 Hello World; complete separate headers; GNU binutils build commands included; exits 0 after returned write errors; requires i386 compatibility
/* Build with GNU binutils:
* as --32 hello114.S -o hello114.o
* objcopy -O binary -j .text hello114.o hello114
* chmod +x hello114
* A 114-byte Linux ELF32 executable; requires i386 compatibility support.
*/
.intel_syntax noprefix
.section .text
.set base, 0x08048000
image:
.byte 0x7f
.ascii "ELF"
.byte 1, 1, 1, 0
.zero 8
.short 2, 3
.long 1
.long base + (start - image)
.long phdr - image
.long 0, 0
.short 52, 32, 1, 0, 0, 0
phdr:
.long 1, 0
.long base, base
.long image_end - image, image_end - image
.long 5, 0x1000
msg:
.ascii "Hello, World!\n"
msg_end:
start:
/* Linux static ELF entry: EAX=EBX=EDX=ESI=0. */
mov al, 4
inc ebx
mov ecx, OFFSET FLAT:base + (msg - image)
mov dl, msg_end - msg
int 0x80
/* One-byte exchanges: EAX=0, then EAX=1 and EBX=0.
* Exit succeeds even if write returned a negative errno.
*/
xchg eax, esi
xchg eax, ebx
int 0x80
image_end:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment