Skip to content

Commit 3975d09

Browse files
committed
Add elf_x64_template.s template source
1 parent 681c991 commit 3975d09

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; build with:
2+
; nasm elf_x64_template.s -f bin -o template_x64_linux.bin
3+
4+
BITS 64
5+
6+
org 0x0000000000400000
7+
8+
ehdr: ; Elf64_Ehdr
9+
db 0x7F, "ELF", 2, 1, 1, 0 ; e_ident
10+
db 0, 0, 0, 0, 0, 0, 0, 0 ;
11+
dw 2 ; e_type = ET_EXEC for an executable
12+
dw 0x3e ; e_machine
13+
dd 1 ; e_version
14+
dq _start ; e_entry
15+
dq phdr - $$ ; e_phoff
16+
dq 0 ; e_shoff
17+
dd 0 ; e_flags
18+
dw ehdrsize ; e_ehsize
19+
dw phdrsize ; e_phentsize
20+
dw 1 ; e_phnum
21+
dw 0 ; e_shentsize
22+
dw 0 ; e_shnum
23+
dw 0 ; e_shstrndx
24+
25+
ehdrsize equ $ - ehdr
26+
27+
phdr: ; Elf64_Phdr
28+
dd 1 ; p_type = PT_LOAD
29+
dd 7 ; p_flags = rwx
30+
dq 0 ; p_offset
31+
dq $$ ; p_vaddr
32+
dq $$ ; p_paddr
33+
dq 0x4141414141414141 ; p_filesz
34+
dq 0x4242424242424242 ; p_memsz
35+
dq 0x1000 ; p_align
36+
37+
phdrsize equ $ - phdr
38+
39+
global _start
40+
41+
_start:
42+

0 commit comments

Comments
 (0)