From ec360d7ad90945273c7d96c9a159131dcbcd67c3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 30 Apr 2012 13:22:51 +0200 Subject: Place the plugin metadata into special sections for Mac and Win The plugin metadata is placed into a special section in the object file on ELF systems to allow finding it fast. Place the data into a special section on Mac and Windows as well, even though we don't have Mach-O or COFF parsers available yet. This will allow us to add the Mach-O and COFF parsers as a pure optimization later on. Task-number: QTBUG-25054 Change-Id: I376d5443ede715aee2c68fb62d24afdbf66e5685 Reviewed-by: Thiago Macieira Reviewed-by: Friedemann Kleint Reviewed-by: Bradley T. Hughes Reviewed-by: Lars Knoll --- src/corelib/plugin/qplugin.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 93be7248c3..e31ab5f565 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -69,11 +69,25 @@ struct QStaticPlugin void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); -#if defined (Q_OF_ELF) && defined (Q_CC_GNU) +#if defined (Q_OF_ELF) && (defined (Q_CC_GNU) || defined(Q_CC_CLANG)) # define QT_PLUGIN_VERIFICATION_SECTION \ __attribute__ ((section (".qtplugin"))) __attribute__((used)) # define QT_PLUGIN_METADATA_SECTION \ __attribute__ ((section (".qtmetadata"))) __attribute__((used)) +#elif defined(Q_OS_MAC) +// TODO: Implement section parsing on Mac +# define QT_PLUGIN_VERIFICATION_SECTION \ + __attribute__((section("__TEXT,qtplugin"))) __attribute__((used)) +# define QT_PLUGIN_METADATA_SECTION \ + __attribute__ ((section ("__TEXT,qtmetadata"))) __attribute__((used)) +#elif defined(Q_CC_MSVC) +// TODO: Implement section parsing for MSVC +#pragma section(".qtplugin",read,shared) +#pragma section(".qtmetadata",read,shared) +# define QT_PLUGIN_VERIFICATION_SECTION \ + __declspec(allocate(".qtplugin")) +# define QT_PLUGIN_METADATA_SECTION \ + __declspec(allocate(".qtmetadata")) #else # define QT_PLUGIN_VERIFICATION_SECTION # define QT_PLUGIN_METADATA_SECTION @@ -140,8 +154,6 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); // NOTE: if you change pattern, you MUST change the pattern in // qlibrary.cpp as well. changing the pattern will break all // backwards compatibility as well (no old plugins will be loaded). -// QT5: should probably remove the entire pattern thing and do the section -// trick for all platforms. for now, keep it and fallback to scan for it. # ifdef QPLUGIN_DEBUG_STR # undef QPLUGIN_DEBUG_STR # endif -- cgit v1.2.3