diff --git a/glib/gmacros.h b/glib/gmacros.h
index 430a3fbb7..c5c2b369b 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -364,6 +364,14 @@
 #endif
 #endif
 
+
+#if G_GNUC_CHECK_VERSION(4, 4)
+# define G_GNUC_NO_STACK_PROTECTOR __attribute__((__optimize__("no-stack-protector")))
+#else
+# define G_GNUC_NO_STACK_PROTECTOR
+#endif
+
+
 /*
  * The G_LIKELY and G_UNLIKELY macros let the programmer give hints to 
  * the compiler about the expected result of an expression. Some compilers
diff --git a/gobject/gtype.h b/gobject/gtype.h
index 375dfa210..7ceab9f10 100644
--- a/gobject/gtype.h
+++ b/gobject/gtype.h
@@ -1393,7 +1393,7 @@ guint     g_type_get_type_registration_serial (void);
  * Since: 2.44
  **/
 #define G_DECLARE_FINAL_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \
-  GType module_obj_name##_get_type (void);                                                               \
+  GType module_obj_name##_get_type (void) G_GNUC_NO_STACK_PROTECTOR;                                     \
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS                                                                       \
   typedef struct _##ModuleObjName ModuleObjName;                                                         \
   typedef struct { ParentName##Class parent_class; } ModuleObjName##Class;                               \
@@ -1483,7 +1483,7 @@ guint     g_type_get_type_registration_serial (void);
  * Since: 2.44
  **/
 #define G_DECLARE_DERIVABLE_TYPE(ModuleObjName, module_obj_name, MODULE, OBJ_NAME, ParentName) \
-  GType module_obj_name##_get_type (void);                                                               \
+  GType module_obj_name##_get_type (void) G_GNUC_NO_STACK_PROTECTOR;                                     \
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS                                                                       \
   typedef struct _##ModuleObjName ModuleObjName;                                                         \
   typedef struct _##ModuleObjName##Class ModuleObjName##Class;                                           \
