You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/05/11 15:09:05 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6235: RISC-V: add C++ support to crt0

xiaoxiang781216 commented on code in PR #6235:
URL: https://github.com/apache/incubator-nuttx/pull/6235#discussion_r870438164


##########
arch/risc-v/src/common/crt0.c:
##########
@@ -88,6 +88,71 @@ static void sig_trampoline(void)
   );
 }
 
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+/* Linker defined symbols to .ctors and .dtors */
+
+  extern void (*_sctors)(void);
+  extern void (*_ectors)(void);
+  extern void (*_sdtors)(void);
+  extern void (*_edtors)(void);
+
+#if defined(__cplusplus)
+}
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+
+/****************************************************************************
+ * Name: exec_ctors
+ *
+ * Description:
+ *   Call static constructors
+ *
+ ****************************************************************************/
+
+  static void exec_ctors(void)
+  {
+    for (void (**ctor)(void) = &_sctors; ctor != &_ectors; ctor++)
+      {
+        (*ctor)();
+      }
+  }
+
+/****************************************************************************
+ * Name: exec_dtors
+ *
+ * Description:
+ *   Call static destructors
+ *
+ ****************************************************************************/
+
+  static void exec_dtors(void)

Review Comment:
   it is already done by binfmt, please search CONFIG_BINFMT_CONSTRUCTORS.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org