summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qplugin.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/plugin/qplugin.h')
-rw-r--r--src/corelib/plugin/qplugin.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h
index 9b3725a718..9af1629a13 100644
--- a/src/corelib/plugin/qplugin.h
+++ b/src/corelib/plugin/qplugin.h
@@ -40,7 +40,6 @@
QT_BEGIN_NAMESPACE
-
#ifndef Q_EXTERN_C
# ifdef __cplusplus
# define Q_EXTERN_C extern "C"
@@ -71,7 +70,20 @@ Q_DECLARE_TYPEINFO(QStaticPlugin, Q_PRIMITIVE_TYPE);
void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin);
-#ifdef Q_OS_PNACL
+#if defined(Q_OS_NACL_EMSCRIPTEN)
+// It is important that the metadata is aligned in Emscripten because we are
+// not allowed to read unaligned data in JS/Emscripten.
+// Without this, importing static plugins will randomly fail because reading
+// the offset 'size' value in QLibraryPrivate::fromRawMetaData is undefined behavior.
+// For this purpose, aligning to 32 bits would suffice.
+// Using 64 bits is probably overkill, but should ensure that this problem doesn't
+// surface in other parts of the code.
+
+// TODO Do we need "section" and "used" attributes on Emscripten?
+// TODO Should we reduce alignment to 32 bits?
+# define QT_PLUGIN_METADATA_SECTION \
+ __attribute__ ((section (".qtmetadata"))) __attribute__((used)) __attribute__((aligned(64)))
+#elif defined(Q_OS_PNACL)
// PNaCl does not support "section":
// "Variable _ZL17qt_pluginMetaData has disallowed "section" attribute"
// PNaCl is Q_CC_CLANG. TODO: should it not set Q_OF_ELF?