aboutsummaryrefslogtreecommitdiff
path: root/sts/ia32/elf
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2020-10-18 18:22:31 +0300
committerAleksey Veresov <aleksey@veresov.pro>2020-10-18 18:22:31 +0300
commitdf0d6a4503a26508553510b4050eaa79f52e4e4e (patch)
tree2517b6070319270a4cb0df9dcf3814b16ecaece9 /sts/ia32/elf
parent9eadc7bac8863b7fd3a39edc9ba31cf4d3b5ab95 (diff)
downloadcryptrobber-df0d6a4503a26508553510b4050eaa79f52e4e4e.tar
cryptrobber-df0d6a4503a26508553510b4050eaa79f52e4e4e.tar.xz
cryptrobber-df0d6a4503a26508553510b4050eaa79f52e4e4e.zip
Another step to release.
Diffstat (limited to 'sts/ia32/elf')
-rw-r--r--sts/ia32/elf/begin.sts129
-rw-r--r--sts/ia32/elf/end.sts21
-rw-r--r--sts/ia32/elf/syscall.sts41
3 files changed, 191 insertions, 0 deletions
diff --git a/sts/ia32/elf/begin.sts b/sts/ia32/elf/begin.sts
new file mode 100644
index 0000000..16d3355
--- /dev/null
+++ b/sts/ia32/elf/begin.sts
@@ -0,0 +1,129 @@
+?create ?? _code_segment
+_code_segment ?choose
+
+# 08048000 ?org
+# 4 ?size
+# 0 ?endianness
+
+?create ?? _data_segment
+_data_segment ?choose
+
+# 09048000 ?org
+# 4 ?size
+# 0 ?endianness
+
+_code_segment ?choose
+
+; ELF header
+; EI_MAG - ELF magic number
+# 7f ?' # 45 ?' # 4c ?' # 46 ?'
+; EI_CLASS - 32-bit format
+# 1 ?'
+; EI_DATA - little-endiann
+# 1 ?'
+; EI_VERSION - current ELF header version
+# 1 ?'
+; EI_OSABI - Linux ABI
+# 3 ?'
+; EI_ABIVERSION - none
+# 0 ?'
+; EI_PAD - padding
+# 7 ?res
+; Executable file type
+# 2 ?2.
+; IA-32 architecture
+# 3 ?2.
+; ELF version
+# 1 ?4.
+; Entry point
+?$ ?? _elf_entry
+# 0 ?4.
+; Program headers offset
+# 34 ?4.
+; Section headers offset
+# 0 ?4.
+; Extra flags
+# 0 ?4.
+; ELF header size
+# 34 ?2.
+; Program header size
+# 20 ?2.
+; Number of program headers
+# 2 ?2.
+; Section header size
+# 28 ?2.
+; Number of section headers
+# 0 ?2.
+; Section name section index
+# 0 ?2.
+
+; ELF CODE PROGRAM HEADER
+; Segment type
+# 1 ?4.
+; Segment offset
+# 0 ?4.
+; Segment virtual address
+?$$ ?4.
+; Segment physical address
+?$$ ?4.
+; Segment file size
+?$ ?? _code_segment_file_size
+# 0 ?4.
+; Segment memory size
+?$ ?? _code_segment_memory_size
+# 0 ?4.
+; Segment flags
+# 5 ?4.
+; Segment alignment
+# 1000 ?4.
+
+; ELF DATA PROGRAM HEADER
+; Segment type
+# 1 ?4.
+; Segment offset
+?$ ?? _data_segment_offset
+# 0 ?4.
+; Segment virtual address
+_data_segment ?choose
+?$$
+_code_segment ?choose
+?4.
+; Segment physical address
+_data_segment ?choose
+?$$
+_code_segment ?choose
+?4.
+; Segment file size
+?$ ?? _data_segment_file_size
+# 0 ?4.
+; Segment memory size
+?$ ?? _data_segment_memory_size
+# 0 ?4.
+; Segment flags
+# 6 ?4.
+; Segment alignment
+# 1000 ?4.
+
+; Return stack
+_data_segment ?choose
+1000 ?res
+?$ ?dup ?? _return_stack
+_code_segment ?choose
+
+; PROGRAM ENTRY CODE
+?$ _elf_entry ?!
+; mov ebp, _return_stack
+# bd ?'
+_return_stack ?.
+; mov esi, _threaded_code_entry
+# be ?'
+?$ ?? _threaded_code_entry
+# 0 ?.
+; lodsd
+# ad ?'
+; jmp dword [eax]
+# ff ?' # 20 ?'
+
+module sts/ia32/ia32.sts
+module sts/ia32/elf/syscall.sts
+module sts/common/common.sts
diff --git a/sts/ia32/elf/end.sts b/sts/ia32/elf/end.sts
new file mode 100644
index 0000000..7c80eec
--- /dev/null
+++ b/sts/ia32/elf/end.sts
@@ -0,0 +1,21 @@
+; Code segment alignment
+# 1000 ?$ # 1000 ?mod ?- ?dup ?res
+
+; Code segment ELF sizes
+?$ ?$$ ?- _code_segment_file_size ?!
+?$ ?$$ ?- _code_segment_memory_size ?!
+
+; Data segment ELF offset
+?$ ?$$ ?-
+_code_segment ?choose
+_data_segment_offset ?!
+
+; Data segment ELF sizes
+_data_segment ?choose
+?$ ?$$ ?-
+_code_segment ?choose
+_data_segment_file_size ?!
+_data_segment ?choose
+?$ ?$$ ?-
+_code_segment ?choose
+_data_segment_memory_size ?!
diff --git a/sts/ia32/elf/syscall.sts b/sts/ia32/elf/syscall.sts
new file mode 100644
index 0000000..3acfef2
--- /dev/null
+++ b/sts/ia32/elf/syscall.sts
@@ -0,0 +1,41 @@
+defasm sys_exit
+ # b8 ?' # 1 ?. ; mov eax, 1
+ # 31 ?' # db ?' ; xor ebx, ebx
+ # cd ?' # 80 ?' ; int 0x80
+; no need in next since this is the last instruction
+
+_data_segment ?choose
+ ?$ ?? _iobuf # 0 ?.
+_code_segment ?choose
+
+defasm sys_read
+ # b8 ?' # 3 ?. ; mov eax, 3
+ # 31 ?' # db ?' ; xor ebx, ebx
+ # b9 ?' _iobuf ?. ; mov ecx, _iobuf
+ # ba ?' # 1 ?. ; mov edx, 1
+ # cd ?' # 80 ?' ; int 0x80
+ # 31 ?' # db ?' ; xor ebx, ebx
+ # 8a ?' # 1d ?' _iobuf ?. ; mov bl, [_iobuf]
+ # 53 ?' ; push ebx
+ # 50 ?' ; push eax
+next
+
+defasm sys_write
+ # 58 ?' ; pop eax
+ # a2 ?' _iobuf ?. ; mov [_iobuf], al
+ # b8 ?' # 4 ?. ; mov eax, 4
+ # bb ?' # 1 ?. ; mov ebx, 1
+ # b9 ?' _iobuf ?. ; mov ecx, _iobuf
+ # ba ?' # 1 ?. ; mov edx, 1
+ # cd ?' # 80 ?' ; int 0x80
+next
+
+defasm sys_write_err
+ # 58 ?' ; pop eax
+ # a2 ?' _iobuf ?. ; mov [_iobuf], al
+ # b8 ?' # 4 ?. ; mov eax, 4
+ # bb ?' # 2 ?. ; mov ebx, 2
+ # b9 ?' _iobuf ?. ; mov ecx, _iobuf
+ # ba ?' # 1 ?. ; mov edx, 1
+ # cd ?' # 80 ?' ; int 0x80
+next