Use __attribute__((constructor)) to initialize the functable

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
GitOrigin-RevId: 80eac58d477f66132c0966938ef69520c0e7b547
Change-Id: I03fb31130824f498fdf76aa4d50736582282b670
diff --git a/functable.c b/functable.c
index b3c3936..fad863e 100644
--- a/functable.c
+++ b/functable.c
@@ -472,6 +472,12 @@
     return Z_OK;
 }
 
+#if !defined(_WIN32) && (defined(__GNUC__) || defined(__clang__))
+static void __attribute__((constructor)) functable_constructor(void) {
+    FUNCTABLE_INIT_ABORT;
+}
+#endif
+
 /* stub functions */
 static int force_init_stub(void) {
     return init_functable();