From b5266802fb585596234faff4ee92bc4d04294ea2 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Thu, 19 Nov 2020 20:57:22 +0000 Subject: In good progress FossilOrigin-Name: 40f3efb8963f27cbb111250ced45c7623211eec7 --- .fossil-settings/ignore-glob | 1 + Makefile | 2 +- src/c_bsdsetsid.S | 46 +++++++++++++++++++++++++++----------------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob index b37143a..bcae5eb 100644 --- a/.fossil-settings/ignore-glob +++ b/.fossil-settings/ignore-glob @@ -5,3 +5,4 @@ bsdsetsid git *.gz *.o +vgcore* diff --git a/Makefile b/Makefile index 67a99cc..88f7aa4 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ ${NAME}: ${OBJS} all: ${NAME} clean: - ${RM} ${OBJS} ${NAME} + ${RM} ${OBJS} ${NAME} vgcore* .PHONY: all clean diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S index 810fe8c..17cf57b 100644 --- a/src/c_bsdsetsid.S +++ b/src/c_bsdsetsid.S @@ -5,33 +5,43 @@ .globl main main: + cmpb $0x1, %dil + jle c_noarg + pushq %rdi + pushq %rsi + pushq %rdx xorq %rcx, %rcx - callq c_push movq (%rsi, %rcx, 8), %rdi + movq %rcx, %r8 callq u_pout - callq c_pop + movq %r8, %rcx + popq %rdx + popq %rsi + popq %rdi + pushq %rdi + pushq %rsi + pushq %rdx inc %rcx - callq c_push movq (%rsi, %rcx, 8), %rdi callq u_pout - callq c_pop - xorq %rdi, %rdi + popq %rdx + popq %rsi + popq %rdi + jmp c_exit + +c_noarg: + leaq noarg_str, %rdi + callq u_perr + movq $0x1, %rdi xorq %rax, %rax movb $0x1, %al # SYS_exit syscall -c_push: - movq %rdx, %r8 - movq %rsi, %r9 - movq %rdi, %r10 - retq - -c_pop: - movq %r8, %rdi - movq %r9, %rsi - movq %r10, %rdx - retq +c_exit: + xorq %rdi, %rdi + xorq %rax, %rax + movb $0x1, %al # SYS_exit + syscall .data -nl: .asciz "\n" -asd: .asciz "hey\n" +noarg_str: .asciz "bsdsetsid: no command specified" -- cgit v1.2.3