diff options
author | Arvid Ephraim Picciani <arvid.picciani@nokia.com> | 2010-08-30 08:45:44 (GMT) |
---|---|---|
committer | Arvid Ephraim Picciani <arvid.picciani@nokia.com> | 2010-08-30 13:00:37 (GMT) |
commit | e4f12672ab7a70dbaac2feb81499a9ee816f677f (patch) | |
tree | 27c08bbbfcb35bc4b9cd42fcf45d715bed639994 /src/corelib/plugin/qlibrary.cpp | |
parent | 9678de93f4b3d0f59436d086de80d821b4694e98 (diff) | |
download | Qt-e4f12672ab7a70dbaac2feb81499a9ee816f677f.zip Qt-e4f12672ab7a70dbaac2feb81499a9ee816f677f.tar.gz Qt-e4f12672ab7a70dbaac2feb81499a9ee816f677f.tar.bz2 |
find .rodata in qt plugins to optimize loading of plugins with no qt section
Reviewed-by: janarve
Diffstat (limited to 'src/corelib/plugin/qlibrary.cpp')
-rw-r--r-- | src/corelib/plugin/qlibrary.cpp | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp index 451c244..eb464c7 100644 --- a/src/corelib/plugin/qlibrary.cpp +++ b/src/corelib/plugin/qlibrary.cpp @@ -295,7 +295,6 @@ static bool qt_parse_pattern(const char *s, uint *version, bool *debug, QByteArr #if defined(Q_OS_UNIX) && !defined(Q_OS_MAC) && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_PLUGIN_CHECK) -#if !defined (Q_OF_ELF) || !defined(Q_CC_GNU) static long qt_find_pattern(const char *s, ulong s_len, const char *pattern, ulong p_len) { @@ -331,7 +330,6 @@ static long qt_find_pattern(const char *s, ulong s_len, return -1; } -#endif // !defined (Q_OF_ELF) || !defined(Q_CC_GNU) /* This opens the specified library, mmaps it into memory, and searches @@ -371,15 +369,27 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB ELF binaries on GNU, have .qplugin sections. */ long pos = 0; -#if defined (Q_OF_ELF) && defined(Q_CC_GNU) - int r = QElfParser().parse(filedata, &fdlen, library, version, debug, key, lib, &pos); - return (r == QElfParser::Ok); -#else const char pattern[] = "pattern=QT_PLUGIN_VERIFICATION_DATA"; const ulong plen = qstrlen(pattern); - if (pos == 0) - pos = qt_find_pattern(filedata, fdlen, pattern, plen); - +#if defined (Q_OF_ELF) && defined(Q_CC_GNU) + int r = QElfParser().parse(filedata, fdlen, library, lib, &pos, &fdlen); + if (r == QElfParser::NoQtSection) { + if (pos > 0) { + // find inside .rodata + long rel = qt_find_pattern(filedata + pos, fdlen, pattern, plen); + if (rel < 0) { + pos = -1; + } else { + pos += rel; + } + } else { + pos = qt_find_pattern(filedata, fdlen, pattern, plen); + } + } else if (r != QElfParser::Ok) + return false; +#else + pos = qt_find_pattern(filedata, fdlen, pattern, plen); +#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) bool ret = false; if (pos >= 0) ret = qt_parse_pattern(filedata + pos, version, debug, key); @@ -388,7 +398,6 @@ static bool qt_unix_query(const QString &library, uint *version, bool *debug, QB lib->errorString = QLibrary::tr("Plugin verification data mismatch in '%1'").arg(library); file.close(); return ret; -#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU) } #endif // Q_OS_UNIX && !Q_OS_MAC && !defined(Q_OS_SYMBIAN) && !defined(QT_NO_PLUGIN_CHECK) |