I have an executable that crashes after main
has finished all its instructions, and the last assembler instruction is executed. Just before the program crashes, I do disas
on GDB:
0x2001c054 <+84>: movt r3, #16384 ; 0x4000
0x2001c058 <+88>: ldrh r3, [r3, #16]
0x2001c05a <+90>: uxth r3, r3
0x2001c05c <+92>: str r3, [sp, #0]
0x2001c05e <+94>: bl 0x2001c0f8 <scream>
0x2001c062 <+98>: mov.w r3, #0
0x2001c066 <+102>: mov r0, r3
0x2001c068 <+104>: add sp, #28
=> 0x2001c06a <+106>: pop {pc}
End of assembler dump.
Now if I go to the next instruction (ni
in GDB) I get the following in GDB:
0xfffffffe in ?? ()
Also, OpenOCD (which I use to communicate with my STM32F2 board) gives the following error:
Error: address + size wrapped(0xfffffffe, 0x00000004)
How can I tell my executable to exit gracefully?
main
? A program on a microcontroller (unless running under an existing OS) is more like an OS kernel. Never exit. \$\endgroup\$