1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- # Copyright Yann Weber <asmsh@yannweb.net>
- # This file is part of asmsh.
- #
- # asmsh is free software: you can redistribute it and/or modify it under the
- # terms of the GNU General Public License as published by the Free Software
- # Foundation, either version 3 of the License, or any later version.
- #
- # asmsh is distributed in the hope that it will be useful, but WITHOUT ANY
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- # details.
- #
- # You should have received a copy of the GNU General Public License along
- # with asmsh. If not, see <https://www.gnu.org/licenses/>.
-
- .ifndef MAP_SIZE
- .set MAP_LEN, 0x1000
- .endif
-
- .file "child64.s"
-
- .comm map_len 8
-
- .section .text
- .global _start
-
- map_exec:
-
- _start:
- mov %rsp, %r15
- mov $MAP_LEN, %r14
- movq %r14, (map_len)
- lea redo(%rip), %rax
- push %rax # redo addr
- pushq $MAP_LEN # map size
-
- mov $0x9, %rax # MMAP
- xor %rdi, %rdi
- mov (%rsp), %rsi # 1 page map
- #mov $(0x1|0x2), %rdx # PROT_READ | PROT_WRITE
- mov $(0x1|0x4|0x2), %rdx # PROT_READ | PROT_EXEC | PROT_WRITE
- mov $(0x20 | 0x1), %r10 # MAP_ANONYMOUS | MAP_SHARED
- mov $-1, %r8 # fd
- xor %r9, %r9
- syscall
-
- push %rax
- cmp $0, %rax
- jle .errmap
-
- redo:
- jmp *(%rsp)
-
-
- .err:
- mov $60, %rax # sys_exit
- mov $3, %rdi
- syscall
-
-
- .errmap:
- mov $60, %rax # sys_exit
- mov $1, %rdi
- syscall
-
-
- ## PAUSE SYSCALL example
- #mov $60, %rax
- #xor %rdi, %rdi
- #syscall
|