I'm having trouble tracking down a segmentation fault. After compiling my c program to assembly, I'm editing it and adding a few things.
I added some code, including this section:
.SB1:
call fib
jmp .LBL2
That part works fine. But now I want to call test and maybe jump to another label. Right now, I'm just playing with it to see if I can learn how things work (taking baby steps). So I changed the code to this:
.SB1:
call fib
test %esp, 0xfffffff
jz .SB2
jmp .LBL2
.SB2:
jmp .LBL2
But now I get a segmentation fault. Anyone know why? If you need more information or want the code to reproduce it let me know.
In AT&T syntax, a literal needs to be prefixed with $
. Then, also the operands need to be switched:
test $0xfffffff, %esp
Without the $
prefix, the assembler assumes a memory address, and accessing address 0xfffffff
is most likely out of your mapped memory, which causes the segmentation fault.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.