From 9bc8ca088ab64fea2f815e1aa1971bdde23ef0d1 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Wed, 18 Nov 2020 15:13:02 +0000 Subject: In progress FossilOrigin-Name: ff7fff8d77d6179426bd8ca6c7585423605896e3 --- Makefile | 15 +++++++-------- src/c_bsdsetsid.S | 9 ++++++--- src/u_write.S | 14 -------------- 3 files changed, 13 insertions(+), 25 deletions(-) delete mode 100644 src/u_write.S diff --git a/Makefile b/Makefile index 2d5df69..7c56037 100644 --- a/Makefile +++ b/Makefile @@ -23,16 +23,15 @@ PREFIX := /usr/local/ DESTDIR := SRCS := ${SRCS_DIR}c_bsdsetsid.S -SRCS += ${SRCS_DIR}u_write.S OBJS = ${SRCS:.S=.o} -ASM ?= yasm -ASMFLAGS := -felf64 -ASMFLAGS += -pgas +AS := yasm +ASFLAGS := -felf64 +ASFLAGS += -pgas -LD := ld.lld -LDFLAGS := +LD := ld +LDFLAGS := -melf_x86_64 NAME := bsdsetsid @@ -41,10 +40,10 @@ RM := rm -f .SUFFIXES: .S .o .S.o: - ${ASM} ${ASMFLAGS} -o ${.TARGET} ${.IMPSRC} + ${AS} ${ASFLAGS} -o ${.TARGET} ${.IMPSRC} ${NAME}: ${OBJS} - ${LD} -o ${.TARGET} ${.ALLSRC} + ${LD} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} all: ${NAME} diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S index abf5afb..d9b1067 100644 --- a/src/c_bsdsetsid.S +++ b/src/c_bsdsetsid.S @@ -3,14 +3,17 @@ str: .asciz "a string\n" .text -.extern u_write .globl _start _start: + jmp c_main + +c_main: movq $0x1, %rdi leaq str, %rsi movq $0x9, %rdx - callq u_write - movq $0x1, %rax + movq $0x4, %rax + syscall xorq %rdi, %rdi + movq $0x1, %rax syscall diff --git a/src/u_write.S b/src/u_write.S deleted file mode 100644 index efd7b9c..0000000 --- a/src/u_write.S +++ /dev/null @@ -1,14 +0,0 @@ -.text -.globl u_write - -u_write: - movq $0x4, %rax - syscall - movq %rax, %rcx - jc u_err - movq %rcx, %rax - retq - -u_err: - movq $0xffffffffffffffff, %rax - retq -- cgit v1.2.3