aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile54
-rw-r--r--src/c_bsdsetsid.S16
-rw-r--r--src/u_write.S14
3 files changed, 84 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..2d5df69
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,54 @@
+# ========================
+# ===== ===============
+# ====== ================
+# ====== ================
+# ====== ==== ==== ==
+# ====== === == = =
+# ====== === = == =
+# = === === = == ====
+# = === === = == = =
+# == ===== ==== ==
+# ========================
+#
+# bsdsetsid: Makefile
+# 2020-11-13 13:22
+# Joe
+#
+# BSD Makefile
+
+default: all
+
+SRCS_DIR := src/
+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
+
+LD := ld.lld
+LDFLAGS :=
+
+NAME := bsdsetsid
+
+RM := rm -f
+
+.SUFFIXES: .S .o
+
+.S.o:
+ ${ASM} ${ASMFLAGS} -o ${.TARGET} ${.IMPSRC}
+
+${NAME}: ${OBJS}
+ ${LD} -o ${.TARGET} ${.ALLSRC}
+
+all: ${NAME}
+
+clean:
+ ${RM} ${OBJS} ${NAME}
+
+.PHONY: all clean
diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S
new file mode 100644
index 0000000..abf5afb
--- /dev/null
+++ b/src/c_bsdsetsid.S
@@ -0,0 +1,16 @@
+.data
+str:
+ .asciz "a string\n"
+
+.text
+.extern u_write
+.globl _start
+
+_start:
+ movq $0x1, %rdi
+ leaq str, %rsi
+ movq $0x9, %rdx
+ callq u_write
+ movq $0x1, %rax
+ xorq %rdi, %rdi
+ syscall
diff --git a/src/u_write.S b/src/u_write.S
new file mode 100644
index 0000000..efd7b9c
--- /dev/null
+++ b/src/u_write.S
@@ -0,0 +1,14 @@
+.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