C++ init
authorkristina <kb@kbs-iMac.local>
Sat, 21 May 2016 02:42:50 +0000 (03:42 +0100)
committerkristina <kb@kbs-iMac.local>
Sat, 21 May 2016 02:42:50 +0000 (03:42 +0100)
arm_chainloader/main.c

index c6903e1..06466aa 100755 (executable)
@@ -2,6 +2,27 @@
 #include <chainloader.h>\r
 #include <hardware.h>\r
 \r
+extern uintptr_t* __init_array_start;\r
+extern uintptr_t* __init_array_end;\r
+\r
+#define logf(fmt, ...) printf("[startup::%s]: " fmt, __FUNCTION__, ##__VA_ARGS__);\r
+\r
+void cxx_init() {\r
+       unsigned ctor_count = (unsigned)(&__init_array_end - &__init_array_start);\r
+       void (*static_ctor)();\r
+\r
+       logf("calling %d static constructors (0x%X - 0x%X) ...\n", ctor_count, &__init_array_start, &__init_array_end);\r
+\r
+       for (unsigned i = 0; i < ctor_count; i++) {\r
+               uintptr_t* ptr = (((uintptr_t*)&__init_array_start) + i);\r
+               static_ctor = (void*)*ptr;\r
+               static_ctor();\r
+       }\r
+}\r
+\r
 void main() {\r
-       printf("%s: arm_chainloader started on ARM, continuing boot from here ...\n", __FUNCTION__);\r
+       logf("started on ARM, continuing boot from here ...\n", __FUNCTION__);\r
+\r
+       /* c++ runtime */\r
+       cxx_init();\r
 }
\ No newline at end of file
This page took 0.023362 seconds and 4 git commands to generate.