From 3b0cb4b73766f0ff72f9757e716b0d77b8850d60 Mon Sep 17 00:00:00 2001 From: Guillaume Geoffroy Date: Mon, 18 Dec 2023 15:42:35 +0100 Subject: [PATCH] TP debug x86-64 --- tp/tp-debug-x86-64/minimum-wrong.s | 60 ++++++++++++++++++++++++++++++ tp/tp-debug-x86-64/segfault.s | 37 ++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 tp/tp-debug-x86-64/minimum-wrong.s create mode 100644 tp/tp-debug-x86-64/segfault.s diff --git a/tp/tp-debug-x86-64/minimum-wrong.s b/tp/tp-debug-x86-64/minimum-wrong.s new file mode 100644 index 0000000..317d60a --- /dev/null +++ b/tp/tp-debug-x86-64/minimum-wrong.s @@ -0,0 +1,60 @@ + .file "min.c" + .text + .globl min + .type min, @function +min: +.LFB22: + .cfi_startproc + movl (%rdi), %eax + cmpl $1, %esi + jbe .L1 + leaq 4(%rdi), %rdx + leal -2(%rsi), %ecx + leaq 8(%rdi,%rcx,4), %rsi +.L3: + movl (%rdx), %ecx + cmpl %ecx, %eax + cmovl %ecx, %eax + addq $4, %rdx + cmpq %rsi, %rdx + jne .L3 +.L1: + ret + .cfi_endproc +.LFE22: + .size min, .-min + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "%d\n" + .text + .globl main + .type main, @function +main: +.LFB23: + .cfi_startproc + subq $56, %rsp + .cfi_def_cfa_offset 64 + movl $1, (%rsp) + movl $5, 4(%rsp) + movl $5, 8(%rsp) + movl $6, 12(%rsp) + movl $3, 16(%rsp) + movl $-1, 20(%rsp) + movl $4, 24(%rsp) + movl $37, 28(%rsp) + movl $-73, 32(%rsp) + movl $0, 36(%rsp) + movq %rsp, %rdi + movl $10, %esi + call min + movl %eax, %esi + leaq .LC0(%rip), %rdi + movl $0, %eax + call printf@PLT + movl $0, %edi + call exit@PLT + .cfi_endproc +.LFE23: + .size main, .-main + .ident "GCC: (Debian 8.2.0-13) 8.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/tp/tp-debug-x86-64/segfault.s b/tp/tp-debug-x86-64/segfault.s new file mode 100644 index 0000000..22c1a4d --- /dev/null +++ b/tp/tp-debug-x86-64/segfault.s @@ -0,0 +1,37 @@ + .file "segfault.c" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "rtbbdrr" + .text + .globl main + .type main, @function +main: +.LFB22: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + movl $9, %edi + call malloc@PLT + movl $0, %esi + movl $114, %edx + movl $0, %ecx + leaq .LC0(%rip), %rdi +.L2: + addl $1, %edx + movb %dl, (%rax,%rcx) + addl $1, %esi + movl %esi, %ecx + movzbl (%rdi,%rcx), %edx + testb %dl, %dl + jne .L2 + movb $0, (%rax,%rcx) + movl $0, %edi + call puts@PLT + movl $0, %edi + call exit@PLT + .cfi_endproc +.LFE22: + .size main, .-main + .ident "GCC: (Debian 8.2.0-13) 8.2.0" + .section .note.GNU-stack,"",@progbits