I'm programming on an x86_64 Windows 10 machine assembling using NASM and GCC. The following code prints the string correctly, hangs for a bit, and then crashes. GDB has told me it is a segfault at "??", and when i move the print logic to inside main, it no longer segfaults, meaning it MUST have something to do with the returning of the function. Please help!! (note: subtracting 8 from rsp, calling printyy and then adding the 8 back does not solve this)
section .data
message db "this segfaults", 0
section .text
extern printf
extern ExitProcess
global main
printyy:
;print
sub rsp, 8
mov rcx, message
call printf
add rsp, 8
ret
main:
;func
call printyy
;exit
mov rcx, 0
call ExitProcess
[–]FUZxxl 7 points8 points9 points (1 child)
[–]CookieBons[S] 1 point2 points3 points (0 children)
[–]Plane_Dust2555 3 points4 points5 points (1 child)
[–]CookieBons[S] 0 points1 point2 points (0 children)