#include <proxmark3.h>\r
#include "apps.h"\r
\r
-void Vector(void)\r
+extern char __data_start__, __data_src_start__, __data_end__, __bss_start__, __bss_end__;\r
+void __attribute__((section(".startos"))) Vector(void)\r
{\r
+ /* Stack should have been set up by the bootloader */\r
+ char *src, *dst, *end;\r
+ \r
+ /* Set up (that is: clear) BSS. */\r
+ dst = &__bss_start__;\r
+ end = &__bss_end__;\r
+ while(dst < end) *dst++ = 0;\r
+ \r
+ /* Set up data segment: Copy from flash to ram */\r
+ src = &__data_src_start__;\r
+ dst = &__data_start__;\r
+ end = &__data_end__;\r
+ while(dst < end) *dst++ = *src++;\r
+ \r
AppMain();\r
}\r