diff options
author | JozanLeClerc <JozanLeClerc@noemail.net> | 2020-11-20 17:49:30 +0000 |
---|---|---|
committer | JozanLeClerc <JozanLeClerc@noemail.net> | 2020-11-20 17:49:30 +0000 |
commit | 040a73a8e3763954320f36e1ac98e73ea0bb76f1 (patch) | |
tree | 64e0f463cd0e6ae3207a4406dc2ec9498965a0d6 | |
parent | Errors I do not understand (diff) | |
download | bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.gz bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.bz2 bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.xz bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.tar.zst bsdsetsid-040a73a8e3763954320f36e1ac98e73ea0bb76f1.zip |
In progress
FossilOrigin-Name: 541eb5074479979fbad29b2df18964971000b067
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | src/c_bsdsetsid.S | 31 |
2 files changed, 19 insertions, 20 deletions
@@ -29,12 +29,6 @@ SRCS += ${SRCS_DIR}u_strlen.S OBJS = ${SRCS:.S=.o} -# AS = yasm -# ASFLAGS = -felf64 -# ASFLAGS += -pgas - -CC = cc - NAME := bsdsetsid RM := rm -f @@ -42,7 +36,7 @@ RM := rm -f .SUFFIXES: .S .o .S.o: - ${AS} ${ASFLAGS} -o ${.TARGET} ${.IMPSRC} + ${AS} -o ${.TARGET} ${.IMPSRC} ${NAME}: ${OBJS} ${CC} -o ${.TARGET} ${.ALLSRC} diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S index b0027f9..7e1c6ae 100644 --- a/src/c_bsdsetsid.S +++ b/src/c_bsdsetsid.S @@ -45,6 +45,9 @@ * This is the entrypoint of the program. */ +.data +status: .space 4, 0x0 + .text .globl main @@ -53,42 +56,44 @@ main: jle e_noarg xor %rax, %rax movb $0x2, %al + push %rdi + push %rsi + push %rdx syscall - jc e_fork - cmp $0x0, %rax - je c_child + test %rax, %rax + js e_fork + jz c_child c_parent: mov %rax, %rdi -# xor %r8, %r8 -# lea (%r8), %rsi + lea status, %rsi mov $0x0, %rdx mov $0x0, %rcx xor %rax, %rax movb $0x7, %al /* SYS_wait4 */ syscall - xor %rdi, %rdi - movb %al, %dil + lea (%rsi), %rdi movb $0x7, %al xor %rax, %rax movb $0x1, %al /* SYS_exit */ syscall c_child: -# xor %rax, %rax -# movb $0x93, %al /* SYS_setsid */ -# syscall -# jc e_setsid xor %rax, %rax - push %rsi + movb $0x93, %al /* SYS_setsid */ + syscall + jc e_setsid + xor %rax, %rax + pop %rdx + pop %rsi + pop %rdi mov $0x1, %rcx mov (%rsi, %rcx, 8), %rdi lea 0(%rsi, %rcx, 8), %rsi movb $0x3b, %al /* SYS_execve */ syscall jc e_execve - pop %rsi jmp c_exit c_exit: |