Skip to content

Instantly share code, notes, and snippets.

@Fuzion24
Last active December 28, 2015 11:39
Show Gist options
  • Save Fuzion24/7495408 to your computer and use it in GitHub Desktop.
Save Fuzion24/7495408 to your computer and use it in GitHub Desktop.
Tiny 128 byte ARM ELF Hello World
$ xxd hello_world_128
0000000: 7f45 4c46 0101 0100 0000 0000 0000 0000 .ELF............
0000010: 0200 2800 0100 0000 5480 0000 3400 0000 ..(.....T...4...
0000020: b800 0000 0202 0005 3400 2000 0100 2800 ........4. ...(.
0000030: 0400 0300 0100 0000 0000 0000 0080 0000 ................
0000040: 0080 0000 8000 0000 8000 0000 0500 0000 ................
0000050: 0080 0000 0100 8fe2 10ff 2fe1 0120 0349 ........../.. .I
0000060: 0e22 0427 00df 0127 00df 0000 7080 0000 .".'...'....p...
0000070: 4865 6c6c 6f2c 2077 6f72 6c64 0a00 c046 Hello, world...F
#! /bin/sh
as -mthumb -R -o shell.o -k shell.s && ld -o shell shell.o && objdump -d shell && strip shell
.data
hello_world:
.asciz "Hello, world\n"
len_hi = . - hello_world
.section .text
.global _start
_start:
//Switch to thumb for smaller code
.code 32
add r0, pc, #1
bx r0
.code 16
//write(1,&hello_world,strlen(hello_world));
mov r0, #1
ldr r1, =hello_world
ldr r2, =len_hi
mov r7, #4
svc #0
//exit(0)
mov r7, #1
svc #0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment