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 <thiago.macieira@intel.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Lars Knoll 2012-04-30 13:22:51 +02:00 committed by Qt by Nokia
parent a7d1b6419d
commit ec360d7ad9

View File

@ -69,11 +69,25 @@ struct QStaticPlugin
void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); 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 \ # define QT_PLUGIN_VERIFICATION_SECTION \
__attribute__ ((section (".qtplugin"))) __attribute__((used)) __attribute__ ((section (".qtplugin"))) __attribute__((used))
# define QT_PLUGIN_METADATA_SECTION \ # define QT_PLUGIN_METADATA_SECTION \
__attribute__ ((section (".qtmetadata"))) __attribute__((used)) __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 #else
# define QT_PLUGIN_VERIFICATION_SECTION # define QT_PLUGIN_VERIFICATION_SECTION
# define QT_PLUGIN_METADATA_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 // NOTE: if you change pattern, you MUST change the pattern in
// qlibrary.cpp as well. changing the pattern will break all // qlibrary.cpp as well. changing the pattern will break all
// backwards compatibility as well (no old plugins will be loaded). // 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 # ifdef QPLUGIN_DEBUG_STR
# undef QPLUGIN_DEBUG_STR # undef QPLUGIN_DEBUG_STR
# endif # endif