aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozanLeClerc <JozanLeClerc@noemail.net>2020-11-20 18:31:08 +0000
committerJozanLeClerc <JozanLeClerc@noemail.net>2020-11-20 18:31:08 +0000
commitc16e1a7f76d46c169f4063cfb056e6a7bb295437 (patch)
treeffbaae69f0e064760f94f5dcf0d7da5c0d7c1d75
parentIn progress (diff)
downloadbsdsetsid-c16e1a7f76d46c169f4063cfb056e6a7bb295437.tar.gz
bsdsetsid-c16e1a7f76d46c169f4063cfb056e6a7bb295437.tar.bz2
bsdsetsid-c16e1a7f76d46c169f4063cfb056e6a7bb295437.tar.xz
bsdsetsid-c16e1a7f76d46c169f4063cfb056e6a7bb295437.tar.zst
bsdsetsid-c16e1a7f76d46c169f4063cfb056e6a7bb295437.zip
For some reason it's bad
FossilOrigin-Name: 36252a8a5d81a5daaa6491ddd28f195d4558c3c7
-rw-r--r--src/c_bsdsetsid.S46
-rw-r--r--src/e_err.S6
-rw-r--r--src/u_strlen.S12
3 files changed, 43 insertions, 21 deletions
diff --git a/src/c_bsdsetsid.S b/src/c_bsdsetsid.S
index 7e1c6ae..70556a5 100644
--- a/src/c_bsdsetsid.S
+++ b/src/c_bsdsetsid.S
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* bsdsetsid: src/c_bsdsetsid.S
- * 2020-11-20 18:18
+ * 2020-11-20 19:30
* Joe
*
* This is the entrypoint of the program.
@@ -51,6 +51,29 @@ status: .space 4, 0x0
.text
.globl main
+c_hex_dec:
+ xor %r10, %r10
+ xor %r9, %r9
+ xor %r8, %r8
+ mov $0xa, %rbx
+ clc
+.repeat:
+ xor %rdx, %rdx
+ idiv %rbx
+ or $0x0, %dl
+ mov $0x8, %rcx
+.shift:
+ rcrb $0x1, %dl
+ rcr $0x1, %r10
+ rcr $0x1, %r9
+ rcr $0x1, %r8
+ dec %rcx
+ and %rcx, %rcx
+ jnz .shift
+ and %rax, %rax
+ jnz .repeat
+ jmp c_parent_next
+
main:
cmpb $0x1, %dil
jle e_noarg
@@ -67,23 +90,25 @@ main:
c_parent:
mov %rax, %rdi
lea status, %rsi
- mov $0x0, %rdx
- mov $0x0, %rcx
+ xor %rdx, %rdx
+ xor %rcx, %rcx
xor %rax, %rax
movb $0x7, %al /* SYS_wait4 */
syscall
- xor %rdi, %rdi
- lea (%rsi), %rdi
+ mov %rsi, %rax
+ jmp c_hex_dec
+c_parent_next:
+ mov %r10, %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
+# movb $0x93, %al /* SYS_setsid */
+# syscall
+# jc e_setsid
xor %rax, %rax
pop %rdx
pop %rsi
@@ -94,7 +119,8 @@ c_child:
movb $0x3b, %al /* SYS_execve */
syscall
jc e_execve
- jmp c_exit
+ test %rax, %rax
+ js e_execve
c_exit:
xor %rdi, %rdi
diff --git a/src/e_err.S b/src/e_err.S
index bf5fa1d..e29e105 100644
--- a/src/e_err.S
+++ b/src/e_err.S
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* bsdsetsid: src/e_err.S
- * 2020-11-20 16:43
+ * 2020-11-20 19:10
* Joe
*
* General error handling happen here.
@@ -96,9 +96,7 @@ e_execve:
lea nl, %rdi
call u_perr
mov $0x4, %rdi
- xor %rax, %rax
- movb $0x1, %al /* SYS_exit */
- syscall
+ jmp e_exit
e_exit:
xor %rax, %rax
diff --git a/src/u_strlen.S b/src/u_strlen.S
index fb783ab..aaa6c02 100644
--- a/src/u_strlen.S
+++ b/src/u_strlen.S
@@ -39,7 +39,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* bsdsetsid: src/u_strlen.S
- * 2020-11-19 14:10
+ * 2020-11-20 19:25
* Joe
*
* Simple implementation of strlen.
@@ -50,14 +50,12 @@
u_strlen:
mov %rdi, %rcx
-
-u_loop:
+.u.loop:
cmpb $0x0, (%rcx)
- je u_ret
+ je .u.ret
inc %rcx
- jmp u_loop
-
-u_ret:
+ jmp .u.loop
+.u.ret:
sub %rdi, %rcx
mov %rcx, %rax
ret