Skip to content

Commit 1c5cfee

Browse files
committed
adding template and src for elf 64 shared object payload target
1 parent 2683ec5 commit 1c5cfee

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
; build with:
2+
; nasm elf_dll_x64_template.s -f bin -o template_x64_linux_dll.bin
3+
4+
BITS 64
5+
org 0
6+
ehdr:
7+
db 0x7f, "ELF", 2, 1, 1, 0 ; e_ident
8+
db 0, 0, 0, 0, 0, 0, 0, 0
9+
dw 3 ; e_type = ET_DYN
10+
dw 62 ; e_machine = EM_X86_64
11+
dd 1 ; e_version = EV_CURRENT
12+
dq _start ; e_entry = _start
13+
dq phdr - $$ ; e_phoff
14+
dd shdr - $$ ; e_shoff
15+
dq 0 ; e_flags
16+
dw ehdrsize ; e_ehsize
17+
dw phdrsize ; e_phentsize
18+
dw 2 ; e_phnum
19+
dw shentsize ; e_shentsize
20+
dw 2 ; e_shnum
21+
dw 1 ; e_shstrndx
22+
ehdrsize equ $ - ehdr
23+
24+
phdr:
25+
dd 1 ; p_type = PT_LOAD
26+
dd 7 ; p_flags = rwx
27+
dq 0 ; p_offset
28+
dq $$ ; p_vaddr
29+
dq $$ ; p_paddr
30+
dq 0xDEADBEEF ; p_filesz
31+
dq 0xDEADBEEF ; p_memsz
32+
dq 0x1000 ; p_align
33+
phdrsize equ $ - phdr
34+
dd 2 ; p_type = PT_DYNAMIC
35+
dd 7 ; p_flags = rwx
36+
dq dynsection ; p_offset
37+
dq dynsection ; p_vaddr
38+
dq dynsection ; p_vaddr
39+
dq dynsz ; p_filesz
40+
dq dynsz ; p_memsz
41+
dq 0x1000 ; p_align
42+
43+
shdr:
44+
dd 1 ; sh_name
45+
dd 6 ; sh_type = SHT_DYNAMIC
46+
dq 0 ; sh_flags
47+
dq dynsection ; sh_addr
48+
dq dynsection ; sh_offset
49+
dq dynsz ; sh_size
50+
dd 0 ; sh_link
51+
dd 0 ; sh_info
52+
dq 8 ; sh_addralign
53+
dq dynsz ; sh_entsize
54+
shentsize equ $ - shdr
55+
dd 0 ; sh_name
56+
dd 3 ; sh_type = SHT_STRTAB
57+
dq 0 ; sh_flags
58+
dq strtab ; sh_addr
59+
dq strtab ; sh_offset
60+
dq strtabsz ; sh_size
61+
dd 0 ; sh_link
62+
dd 0 ; sh_info
63+
dq 0 ; sh_addralign
64+
dq 0 ; sh_entsize
65+
dynsection:
66+
; DT_INIT
67+
dq 0x0c
68+
dq _start
69+
; DT_HASH
70+
dq 0x04
71+
dq 0
72+
; DT_STRTAB
73+
dq 0x05
74+
dq strtab
75+
; DT_SYMTAB
76+
dq 0x06
77+
dq strtab
78+
; DT_STRSZ
79+
dq 0x0a
80+
dq strtabsz
81+
; DT_SYMENT
82+
dq 0x0b
83+
dq 0
84+
; DT_NULL
85+
dq 0x00
86+
dq 0
87+
dynsz equ $ - dynsection
88+
89+
strtab:
90+
db 0
91+
db 0
92+
strtabsz equ $ - strtab
93+
global _start
94+
_start:
95+
418 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)