Skip to content

Instantly share code, notes, and snippets.

@orivej
Last active July 13, 2017 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orivej/29b9834e4621f2c69bfddf0bfc1baa1f to your computer and use it in GitHub Desktop.
Save orivej/29b9834e4621f2c69bfddf0bfc1baa1f to your computer and use it in GitHub Desktop.
.intel_syntax
.globl _start
_start:
lea r12, __init_array_start
lea r13, __init_array_end
loop:
cmp r12, r13
je end
call [r12]
add r12, 8
jmp loop
end:
mov rdi, 0
mov rax, 60
syscall
ctor:
int3
ret
.section .ctors
.quad ctor
.section .init_array, "aw", @init_array
default: main.ld main.lld
clean:
rm -f lib.o main.o main.ld main.lld
main.ld: main.o
ld -o $@ $^
main.lld: main.o
ld.lld -o $@ $^
.s.o:
llvm-mc -filetype=obj -o $@ $<
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment