我有一些由我自己的編譯器創建的asm程序,當我想運行它們時,它們最終會出現分段錯誤。所有指令都按照我想要的方式執行,但執行完成時會出現段錯誤。分段錯誤x86 <_dl_debug_state>
當我嘗試以看段錯誤使用gdb的,看來,它總是發生在該行:0x11ee90 < _dl_debug_state>推%EBP>
我甚至不知道這是什麼線,並首先如何防止它引起段錯誤。
這裏是那種PROGRAMM的一個爲例:%ebp
被壓入堆棧:
file "test_appel.c"
.text
.globl f
.type f, @function
f:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
movl 8(%ebp), %eax
pushl %eax
movl 12(%ebp), %eax
popl %ecx
imull %ecx, %eax
movl %eax, 16(%ebp)
movl 16(%ebp), %eax
leave
ret
.section .rodata
.LC0:
.string "appel à fonction pour la multiplication\n"
.LC1:
.string "resultat 2 * 3 = %d\n"
.text
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $32, %esp
movl $2, %eax
movl %eax, 8(%ebp)
movl $3, %eax
movl %eax, 12(%ebp)
movl 12(%ebp), %eax
movl %eax ,4(%esp)
movl 8(%ebp), %eax
movl %eax ,0(%esp)
call f
movl %eax, 4(%ebp)
movl 4(%esp), %eax
movl (%esp), %ecx
pushl %eax
pushl %ecx
movl $.LC0, %eax
movl %eax, (%esp)
call printf
popl %ecx
popl %eax
movl %eax, 4(%esp)
movl %ecx, (%esp)
movl 4(%esp),%eax
movl (%esp), %ecx
pushl %eax
pushl %ecx
movl 4(%ebp), %eax
movl %eax, %edx
movl %edx, 4(%esp)
movl $.LC1, (%esp)
call printf
popl %ecx
popl %eax
movl %eax, 4(%esp)
movl %ecx, (%esp)
leave
ret