]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Fix data segement. You may now use stuff like int foo = 1; in global context (as...
authorhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 8 Sep 2009 15:40:22 +0000 (15:40 +0000)
committerhenryk@ploetzli.ch <henryk@ploetzli.ch@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 8 Sep 2009 15:40:22 +0000 (15:40 +0000)
crashing down

armsrc/appmain.c
armsrc/apps.h
armsrc/ldscript
armsrc/start.c

index 9a692128c328f978d290910785926b3eff9abc4e..23046b4d03b644e618976adfecef0e06fa4c6cea 100644 (file)
@@ -692,9 +692,8 @@ void UsbPacketReceived(BYTE *packet, int len)
        }
 }
 
-void AppMain(void)
+void  __attribute__((noreturn)) AppMain(void)
 {
-       memset(BigBuf,0,sizeof(BigBuf));
        SpinDelay(100);
        
        if(common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
index f07504d25ccc7fbfef9a514d95f2a609ec89d841..1cb971bde3e4f68f6635c7a7f129fbe386c01199 100644 (file)
@@ -13,7 +13,7 @@ DWORD BigBuf[12000];
 \r
 /// appmain.h\r
 void ReadMem(int addr);\r
-void AppMain(void);\r
+void __attribute__((noreturn)) AppMain(void);\r
 void SamyRun(void);\r
 void DbpIntegers(int a, int b, int c);\r
 void DbpString(char *str);\r
index 8e3231c083715e92ab71d3aa9275dc1b56158d66..cc5ce4e02e4b1ea0d9dece8561fa4200de60b706 100644 (file)
@@ -13,15 +13,26 @@ SECTIONS
                *(.eh_frame)\r
                *(.glue_7)\r
                *(.glue_7t)\r
-               *(.version_information)\r
-       } >osimage\r
-       .rodata : { \r
                *(.rodata) \r
                *(.rodata*) \r
+               *(.version_information)\r
        } >osimage\r
-       .data : { *(.data) } >ram\r
-       __bss_start__ = .;\r
-       .bss : { *(.bss) } >ram\r
+       __end_of_text__ = .;\r
+       \r
+       .data : {\r
+               __data_start__ = .;\r
+               __data_src_start__ = __end_of_text__; \r
+               *(.data)\r
+               *(.data.*)\r
+               __data_end__ = .;\r
+       } >ram AT>osimage\r
+       \r
+       .bss : {\r
+               __bss_start__ = .; \r
+               *(.bss)\r
+               *(.bss.*) \r
+       } >ram\r
+       . = ALIGN(32 / 8);\r
        __bss_end__ = .;\r
 \r
        .commonarea (NOLOAD) : {\r
index de2dd2f639c3e0d8c8cf86c963f6a9583c3729d8..0466a92fdb28eef430e0d26805f2471a4afb2eee 100644 (file)
@@ -6,7 +6,22 @@
 #include <proxmark3.h>\r
 #include "apps.h"\r
 \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
Impressum, Datenschutz