diff options
author | JozanLeClerc <JozanLeClerc@noemail.net> | 2020-11-20 14:39:51 +0000 |
---|---|---|
committer | JozanLeClerc <JozanLeClerc@noemail.net> | 2020-11-20 14:39:51 +0000 |
commit | f914b2f38c0e4ae3de473e83e2e02229997b7de7 (patch) | |
tree | f8ba7b1d5e907455e0a76ebda8b43f6b63eb4a9e | |
parent | In good progress (diff) | |
download | bsdsetsid-f914b2f38c0e4ae3de473e83e2e02229997b7de7.tar.gz bsdsetsid-f914b2f38c0e4ae3de473e83e2e02229997b7de7.tar.bz2 bsdsetsid-f914b2f38c0e4ae3de473e83e2e02229997b7de7.tar.xz bsdsetsid-f914b2f38c0e4ae3de473e83e2e02229997b7de7.tar.zst bsdsetsid-f914b2f38c0e4ae3de473e83e2e02229997b7de7.zip |
Noq
FossilOrigin-Name: 87bc744080eac5e50fa79550e5b833bc82cc5f1a
-rw-r--r-- | Makefile | 26 | ||||
-rw-r--r-- | src/c_bsdsetsid.S | 50 | ||||
-rw-r--r-- | src/u_print.S | 22 | ||||
-rw-r--r-- | src/u_strlen.S | 6 |
4 files changed, 40 insertions, 64 deletions
@@ -34,29 +34,6 @@ ASFLAGS += -pgas CC = cc -LD := ld -LDFLAGS := -melf_x86_64 -LDFLAGS += --eh-frame-hdr -LDFLAGS += -dynamic-linker -LDFLAGS += /libexec/ld-elf.so.1 -LDFLAGS += --hash-style=both -LDFLAGS += --enable-new-dtags -LDPOST := /usr/lib/crt1.o -LDPOST += /usr/lib/crti.o -LDPOST += /usr/lib/crtbegin.o -LDPOST += -L/usr/lib -LDPOST += -lgcc -LDPOST += --as-needed -LDPOST += -lgcc_s -LDPOST += --no-as-needed -LDPOST += -lc -LDPOST += -lgcc -LDPOST += --as-needed -LDPOST += -lgcc_s -LDPOST += --no-as-needed -LDPOST += /usr/lib/crtend.o -LDPOST += /usr/lib/crtn.o - NAME := bsdsetsid RM := rm -f @@ -67,8 +44,7 @@ RM := rm -f ${AS} ${ASFLAGS} -o ${.TARGET} ${.IMPSRC} ${NAME}: ${OBJS} - ${LD} ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} ${LDPOST} - # ${CC} -v -o ${.TARGET} ${.ALLSRC} + ${CC} -o ${.TARGET} ${.ALLSRC} all: ${NAME} diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S index 17cf57b..de55b7f 100644 --- a/src/c_bsdsetsid.S +++ b/src/c_bsdsetsid.S @@ -7,39 +7,39 @@ main: cmpb $0x1, %dil jle c_noarg - pushq %rdi - pushq %rsi - pushq %rdx - xorq %rcx, %rcx - movq (%rsi, %rcx, 8), %rdi - movq %rcx, %r8 - callq u_pout - movq %r8, %rcx - popq %rdx - popq %rsi - popq %rdi - pushq %rdi - pushq %rsi - pushq %rdx + push %rdi + push %rsi + push %rdx + xor %rcx, %rcx + mov (%rsi, %rcx, 8), %rdi + mov %rcx, %r8 + call u_pout + mov %r8, %rcx + pop %rdx + pop %rsi + pop %rdi + push %rdi + push %rsi + push %rdx inc %rcx - movq (%rsi, %rcx, 8), %rdi - callq u_pout - popq %rdx - popq %rsi - popq %rdi + mov (%rsi, %rcx, 8), %rdi + call u_pout + pop %rdx + pop %rsi + pop %rdi jmp c_exit c_noarg: - leaq noarg_str, %rdi - callq u_perr - movq $0x1, %rdi - xorq %rax, %rax + lea noarg_str, %rdi + call u_perr + mov $0x1, %rdi + xor %rax, %rax movb $0x1, %al # SYS_exit syscall c_exit: - xorq %rdi, %rdi - xorq %rax, %rax + xor %rdi, %rdi + xor %rax, %rax movb $0x1, %al # SYS_exit syscall diff --git a/src/u_print.S b/src/u_print.S index 3866868..47a9483 100644 --- a/src/u_print.S +++ b/src/u_print.S @@ -4,25 +4,25 @@ .globl u_perr u_pout: - movq $0x1, %r11 # stdout + mov $0x1, %r11 # stdout jmp u_print u_perr: - movq $0x2, %r11 # stderr + mov $0x2, %r11 # stderr jmp u_print u_print: - callq u_strlen - movq %rax, %rdx - movq %rdi, %rsi - movq %r11, %rdi - movq $0x4, %rax # SYS_write + call u_strlen + mov %rax, %rdx + mov %rdi, %rsi + mov %r11, %rdi + mov $0x4, %rax # SYS_write syscall - leaq nl, %rsi - movq $0x1, %rdx - movq $0x4, %rax # SYS_write + lea nl, %rsi + mov $0x1, %rdx + mov $0x4, %rax # SYS_write syscall - retq + ret .data nl: .asciz "\n" diff --git a/src/u_strlen.S b/src/u_strlen.S index 27d9663..b1e2447 100644 --- a/src/u_strlen.S +++ b/src/u_strlen.S @@ -2,7 +2,7 @@ .globl u_strlen u_strlen: - movq %rdi, %rcx + mov %rdi, %rcx u_loop: cmpb $0x0, (%rcx) @@ -12,5 +12,5 @@ u_loop: u_ret: sub %rdi, %rcx - movq %rcx, %rax - retq + mov %rcx, %rax + ret |