diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-27 18:58:35 +0200 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-04-27 18:58:35 +0200 |
commit | 8ba4199077a3f47e892b9d35a2265632f42b624d (patch) | |
tree | 79f6f27d40f0650c0a2738538562bd7606a33753 | |
parent | f_status rewrite (diff) | |
download | lowbat-bsd-8ba4199077a3f47e892b9d35a2265632f42b624d.tar.gz lowbat-bsd-8ba4199077a3f47e892b9d35a2265632f42b624d.tar.bz2 lowbat-bsd-8ba4199077a3f47e892b9d35a2265632f42b624d.tar.xz lowbat-bsd-8ba4199077a3f47e892b9d35a2265632f42b624d.tar.zst lowbat-bsd-8ba4199077a3f47e892b9d35a2265632f42b624d.zip |
segv on sprintf/puts in cpyhead
-rw-r--r-- | asm/r_cpyhead.asm | 79 |
1 files changed, 55 insertions, 24 deletions
diff --git a/asm/r_cpyhead.asm b/asm/r_cpyhead.asm index fbbed6a..397faa4 100644 --- a/asm/r_cpyhead.asm +++ b/asm/r_cpyhead.asm @@ -10,31 +10,62 @@ /* */ /****************************************************************************************/ -section .text - extern memset - extern sprintf - global jo_r_cpyhead +.text +.extern sprintf +.globl r_cpyhead + .extern puts + .globl main -jo_r_cpyhead: ; jo_r_cpyhead(percent: rdi) - push rdi - mov rdi, buff - mov rsi, 0x0 - mov rdx, 0x11 - call memset ; memset 0 notification head - lea rsi, [rel n_head] - pop rdi - mov rdx, rdi - mov rdi, rax - xor rax, rax - mov al, 0x1 - push rdi - call sprintf - pop rdi - mov rax, rdi +r_cpyhead: + movq $buff, %rdi + movq $n_head, %rsi + xorq %rax, %rax + callq sprintf + movq %rdi, %rax retq -section .data - n_head: db "Low battery: %d%%", 0x0 +main: + movq $25, %rdx + callq r_cpyhead + movq %rax, %rdi + callq puts -section .bss - buff: resb 0x11 + xorq %rdi, %rdi + movq $0x1, %rax + syscall + retq + +.data + n_head: .asciz "Low battery: %d%%" + +.bss + buff: .zero 0x11 + +/* ;; section .text */ +/* ;; extern memset */ +/* ;; extern sprintf */ +/* ;; global jo_r_cpyhead */ +/* */ +/* ;; jo_r_cpyhead: ; jo_r_cpyhead(percent: rdi) */ +/* ;; push rdi */ +/* ;; mov rdi, buff */ +/* ;; mov rsi, 0x0 */ +/* ;; mov rdx, 0x11 */ +/* ;; call memset ; memset 0 notification head */ + /* ;; lea rsi, [rel n_head] */ + /* ;; pop rdi */ + /* ;; mov rdx, rdi */ + /* ;; mov rdi, rax */ + /* ;; xor rax, rax */ +/* ;; mov al, 0x1 */ +/* ;; push rdi */ +/* ;; call sprintf */ +/* ;; pop rdi */ +/* ;; mov rax, rdi */ +/* ;; retq */ +/* */ +/* ;; section .data */ +/* ;; n_head: db "Low battery: %d%%", 0x0 */ +/* */ +/* ;; section .bss */ +/* ;; buff: resb 0x11 */ |