asmsh/child.s
2023-03-07 12:17:42 +01:00

71 行
1.4 KiB
ArmAsm
Raw Blame 履歴

このファイルには不可視のUnicode文字が含まれています

このファイルには人間が識別できない不可視のUnicode文字が含まれており、コンピューターによって特殊な処理が行われる可能性があります。 それが意図的なものと考えられる場合は、この警告を無視して構いません。 不可視文字を表示するにはエスケープボタンを使用します。

# 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