summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove extra semi-colonsTasuku Suzuki2024-02-061-1/+1
| | | | | Change-Id: I92fddb36cd136fd1bd627955f15d0559b9942d7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Change license for tests filesLucie Gérard2024-02-041-1/+1
| | | | | | | | | | | | According to QUIP-18 [1], all tests file should be LicenseRef-Qt-Commercial OR GPL-3.0-only [1]: https://contribute.qt-project.org/quips/18 Pick-to: 6.7 Task-number: QTBUG-121787 Change-Id: I9657df5d660820e56c96d511ea49d321c54682e8 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Resurrect tests/auto/corelib/plugin/qpluginloader/machtestJoerg Bornemann2024-01-101-14/+6
| | | | | | | | | | | | | | | | | | | | | | | | Update the CMake project file to generate the binaries that are to be tested by tst_qpluginloader. Update the tested architectures to arm64 and x86_64 like it was done in 2739aa98b1da164b398a37e6018c205d59debf7e for Qt 5.15. Remove the ppcconverter script that was used to create PowerPC binaries. This architecture is unsupported since ages. Remove the comparison with the pointer size and the alignment check. This isn't valid since commit 2549a88ba2a48fa2bedce97dd71a2974c6f8840a. Remove the magic header check. This is done by the parser itself since commit 3b49aa72fe6ec0dd0aa0c1c41fb81e874dc789fa. Remove the blacklisting of the test. Fixes: QTBUG-86792 Change-Id: Ib7c8e648bdacca6d6290c0f40a3bb02987365fc9 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QTemporaryFile(Name): don't make the path absolute on generationThiago Macieira2023-10-261-1/+3
| | | | | | | | | | | | | | | | | | I need to use QTemporaryFileName in a context where absolute paths are not allowed because they change the behavior of the system call (the -at() POSIX system calls); see next commit. This required a fix to a seemingly unrelated test, which depended on the absolute path, because QPluginLoader and QLibrary assume a file name with no path components imply "search the standard places". [ChangeLog][Important Behavior Changes][QTemporaryFile] This class will now return relative file paths in fileName() if the file template was also a relative path (it used to always return an absolute path). The temporary files are still created in the same directory; this change only affects the length of the path the function returns. Change-Id: I79e700614d034281bf55fffd178f65f2b3d602d8 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tests: port assorted trivial uses of Q_FOREACH to ranged for loopsMarc Mutz2023-08-141-2/+2
| | | | | | | | | | | | | | | | | | | | All of these fall into the trivial category: loops over (readily made) const local containers. As such, they cannot possibly depend on the safety copy that Q_FOREACH performs, so are safe to port as-is to ranged for loops. There may be more where these came from, but these were the ones that stood out as immediately obvious when scanning the 100s of uses in qtbase, so I preferred to directly fix them over white-listing their files with QT_NO_FOREACH (which still may be necessary for some files, as this patch may not port all uses in that file). Pick-to: 6.6 6.5 Task-nubmber: QTBUG-115839 Change-Id: I7b7893bec8254f902660dac24167113aca855029 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* QLibraryPrivate: Actually merge load hintsIevgenii Meshcheriakov2023-06-201-3/+23
| | | | | | | | | | | | | | | | | | | Or old and new load hints in mergeLoadHints() instead of just storing new ones. Andjust QLibraryPrivate::setLoadHints() to handle objects with no file name differently and just set load hints directly. Mention that load hints are merged once the file name is set in the documentation for QLibrary::setLoadHints(). Add a regression test into tst_qfactoryloader. Update and extend tst_QPluginLoader::loadHints() to take into account load hints merging. Fixes: QTBUG-114480 Change-Id: I3b9afaec7acde1f5ff992d913f8d7217392c7e00 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QPluginLoader: don't instantiante multiple, identical instancesThiago Macieira2023-04-051-7/+19
| | | | | | | | | | | | | | | | | This can happen if the same project has two or more Q_IMPORT_PLUGIN macros in their source. And that can happen when converting from qmake- based builds to CMake, as qmake didn't generate a source file with the macro but CMake does. [ChangeLog][QtCore][QPluginLoader] staticInstances() will not call duplicated registrations of the same instantiation function, which can only happen as a result of duplicated Q_IMPORT_PLUGIN for the same plugin name. Fixes: QTBUG-102745 Pick-to: 6.2 6.5 Change-Id: Idd5e1bb52be047d7b4fffffd174fb9dd62d8583d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Corelib: s/Q_OS_MAC/Q_OS_DARWIN/wg except for doc and definitionEdward Welbourne2023-03-201-1/+1
| | | | | | | | | | I got tired of being told off by the inanity 'bot for faithfully reflecting existing #if-ery in new #if-ery. Retain only the documentation and definition of the deprecated define. Change-Id: I47f47b76bd239a360f27ae5afe593dfad8746538 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Port from container::count() and length() to size() - V5Marc Mutz2022-11-031-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to handle typedefs and accesses through pointers, too: const std::string o = "object"; auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); }; auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) { auto exprOfDeclaredType = [&](auto decl) { return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o); }; return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes)))); }; auto renameMethod = [&] (ArrayRef<StringRef> classes, StringRef from, StringRef to) { return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)), callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))), changeTo(cat(access(o, cat(to)), "()")), cat("use '", to, "' instead of '", from, "'")); }; renameMethod(<classes>, "count", "size"); renameMethod(<classes>, "length", "size"); except that the on() matcher has been replaced by one that doesn't ignoreParens(). a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'. Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache, to avoid porting calls that explicitly test count(). Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Android: skip tst_QPluginLoader::loadSectionTableStrippedElf()Assam Boudjelthia2022-08-181-0/+4
| | | | | | | | | | | | | | ... on Android 7+ because Android linker doens't accept missing or bad section headers. * https://android.googlesource.com/platform/bionic/+/refs/heads/oreo-r2- release/android-changes-for-ndk-developers.md#missing-section-headers- enforced-for-api-level-24 Pick-to: 6.4 6.3 6.2 Task-number: QTQAINFRA-4748 Change-Id: I37fcf7995bbfe7d258b92f7425baf4722b0ad4ab Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-28/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Android: activate tst_QPluginLoaderIvan Solovev2022-03-301-2/+34
| | | | | | | | | | | | | | - Use QT_ANDROID_EXTRA_LIBS to correctly deploy libraries on Android. - Update the test code to use application libraries directory on Android. This allows to enable the test for Android in CMakeLists.txt Task-number: QTBUG-87438 Pick-to: 6.3 6.2 Change-Id: Ib74da036472320736888052b63a45ca50431de48 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* QPluginLoader: report the right load hintsGiuseppe D'Angelo2022-02-031-1/+10
| | | | | | | | | | | | | | | A default-constructed QPluginLoader erroneously reports that the load hints are empty. However, setting a filename would then automatically set the PreventUnload hint, surprising the user. Return the correct flags instead. Amends 494376f980e96339b6f1eff7c41336ca4d853065 Change-Id: I7a95964cb680afd3adf2f71ed73d2f93023238f2 Fixes: QTBUG-100416 Pick-to: 5.15 6.2 6.3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q*Parser: Replace "data" with "contents" in stringsRobert Löhning2022-01-121-3/+3
| | | | | | | | | ...to be clearer and avoid confusion with "data section". Change-Id: I13319be0e3e12aecf1e0e86c256007dfe6cb98c6 Pick-to: 6.3 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: check and use elf.h from alternative locationJanne Juntunen2021-11-301-9/+8
| | | | | | | | | | | In QNX, instead of #include <elf.h>, we have to use #include <sys/elf.h> since that file is placed in a subdirectory. Also removed the previous workaround. Fixes: QTBUG-97833 Change-Id: Id932a5eeb618a42c8778459cdfd8bb5bf903523c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix test when accessing patched plugin too fastPasi Petäjäjärvi2021-11-191-3/+18
| | | | | | | | | At least one OS (QNX) can't dlopen() a library that is still open for writing elsewhere Pick-to: 6.2 Change-Id: I2d4425d8c69162cdfa43c2523c7459def7839eb9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNX: Handle missing elf.h gracefullyJanne Juntunen2021-10-281-5/+11
| | | | | | | | | | | | It seems that after commit id 46fc01d7ca10ab95e53206077c7c710d2032b4f0 the qpluginloder test case cannot find elf.h in QNX test environment. This is just a workaround, fix for missing elf.h (QTBUG-97833) needs to be done later on. Change-Id: I3f6ec36c8ceaed82552fd0e156a56637c056780d Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QPlugin: Move the plugin metadata to a note in ELF platformsThiago Macieira2021-10-181-44/+282
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A few systems, like OpenWRT, may strip the section table off the resulting binaries (see [1]), making it impossible for us to pinpoint the exact location of the Qt plugin metadata. This commit moves the meta data to a location that is identifiable even in fully stripped binaries: an ELF note. By naming our section ".note.qt.metadata", we instruct the linker to place it along the other notes and to mark it in the program header section. Another advantage is that the notes are usually in the very beginning of the file, as they are used by the dynamic linker itself, so we'll need to read much less of the full contents. The unit test is modified not to attempt to strip the plugin of debugging data. In fact, we add something to the end that would, otherwise, be matched as (invalid) metadata. The following was produced with GCC 11 and GNU binutils ld 2.36.1. Section Headers: [Nr] Name Type Addr Off Size ES Flags Lk Inf Al [ 0] NULL 0000000000000000 00000000 00000000 0 0 0 0 [ 1] .note.gnu.property NOTE 00000000000002a8 000002a8 00000030 0 A 0 0 8 [ 2] .note.gnu.build-id NOTE 00000000000002d8 000002d8 00000024 0 A 0 0 4 [ 3] .note.qt.metadata NOTE 00000000000002fc 000002fc 000001ac 0 A 0 0 4 Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align ... NOTE 0x0002a8 0x00000000000002a8 0x00000000000002a8 0x000030 0x000030 R 0x8 NOTE 0x0002d8 0x00000000000002d8 0x00000000000002d8 0x0001d0 0x0001d0 R 0x4 The Qt metadata note is 4-byte aligned and can thus be found in the second note section, which spans from 0x02d8 to 0x02d8+0xac=0x0384. GNU readelf -n can even show it: Displaying notes found in: .note.qt.metadata Owner Data size Description qt-project! 0x0000018f Unknown note type: (0x74510001) description data: 01 06 03 81 bf ...... ff I chose 0x7451 as the prefix for our notes, even though they're already namespaced by the owner in the first place, because eu-readelf mistakenly tries to interpret note 1 as a GNU ABI tag regardless of owner. The owner name was chosen to be 12 bytes long, so the ELF note header is 24 bytes in total. There's no space wasted because the payload needs to be aligned to 32-bit anyway and I didn't want to use only 4 characters (header total size 16 bytes) so we'd skip the "GNU" note on size, without string comparison. And I couldn't think of a 4-character representative string ("QtP" ?). [1] https://github.com/openwrt/video/issues/1 Fixes: QTBUG-96327 Change-Id: I2de1b4dfacd443148279fffd16a3987729346567 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QElfParser: rewrite using elf.hThiago Macieira2021-10-061-46/+317
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This rewrite uses the actual structures supplied by the system's C library, so it should be easier to read. It removes hardcoded constants with little evident meaning in favor of sizeof() and the macros from that header. It also removes advancing the data pointer in favor of having absolute offsets. The resulting implementation is stricter than the original, checking more fields in the header. Because the QPluginLoader and QFactoryLoader users may make decisions based on availability of plugins before attempting to load them, it's better to be stricter here than to fail later when trying to dlopen() them. Debugging and testing are much improved. Instead of stored artifacts, I added a routine to modify a valid plugin to make it invalid, given the conditions we've found so far. If you turn debugging on for this category, you'll see things like: not-elf.fcqdMq.so : Not an ELF file (invalid signature) wrong-word-size.QrnSAx.so : ELF 32-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 invalid-word-size.bOkXvp.so : Invalid ELF file (class 0), LSB (GNU/Linux) unknown-word-size.ogYKeF.so : Invalid ELF file (class 66), LSB (GNU/Linux) wrong-endian.owiElX.so : ELF 64-bit MSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 invalid-endian.FRxClR.so : ELF 64-bit invalid endianness (0) (GNU/Linux) unknown-endian.FfvRrP.so : ELF 64-bit invalid endianness (65) (GNU/Linux) elf-version-0.gPTdpQ.so : ELF 64-bit LSB (GNU/Linux), file version 0 elf-version-2.jlIUUg.so : ELF 64-bit LSB (GNU/Linux), file version 2 executable.LlXiFp.so : ELF 64-bit LSB (GNU/Linux), version 1, executable, x86-64 relocatable.UsOYuy.so : ELF 64-bit LSB (GNU/Linux), version 1, relocatable, x86-64 core-file.hqvNRz.so : ELF 64-bit LSB (GNU/Linux), version 1, core dump, x86-64 invalid-type.CIJgfS.so : ELF 64-bit LSB (GNU/Linux), version 1, unknown type 259, x86-64 wrong-arch.UcNmgz.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, AArch64 file-version-0.lZYuda.so : ELF 64-bit LSB (GNU/Linux), version 0, shared library or PIC executable, x86-64 file-version-2.ucfdwL.so : ELF 64-bit LSB (GNU/Linux), version 2, shared library or PIC executable, x86-64 no-sections.rSjsHh.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 no-sections.rSjsHh.so : contains 0 sections of 64 bytes at offset 0 ; section header string table (shstrtab) is entry 0 no-sections.rSjsHh.so : no section table present, not able to find Qt metadata qtmetadata-executable.vrxcIf.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 qtmetadata-executable.vrxcIf.so : contains 42 sections of 64 bytes at offset 997256 ; section header string table (shstrtab) is entry 41 qtmetadata-executable.vrxcIf.so : shstrtab section is located at offset 996831 size 423 qtmetadata-executable.vrxcIf.so : section 0 name "" type NULL flags X offset 0x0 size 0x0 qtmetadata-executable.vrxcIf.so : section 1 name ".note.gnu.property" type NOTE flags AX offset 0x2a8 size 0x30 qtmetadata-executable.vrxcIf.so : section 2 name ".note.gnu.build-id" type NOTE flags AX offset 0x2d8 size 0x24 qtmetadata-executable.vrxcIf.so : section 3 name ".hash" type HASH flags AX offset 0x300 size 0x44c qtmetadata-executable.vrxcIf.so : section 4 name ".gnu.hash" type 0x6ffffff6 flags AX offset 0x750 size 0x3b8 qtmetadata-executable.vrxcIf.so : section 5 name ".dynsym" type DYNSYM flags AX offset 0xb08 size 0xd50 qtmetadata-executable.vrxcIf.so : section 6 name ".dynstr" type STRTAB flags AX offset 0x1858 size 0x15d8 qtmetadata-executable.vrxcIf.so : section 7 name ".gnu.version" type 0x6fffffff flags AX offset 0x2e30 size 0x11c qtmetadata-executable.vrxcIf.so : section 8 name ".gnu.version_r" type 0x6ffffffe flags AX offset 0x2f50 size 0xb0 qtmetadata-executable.vrxcIf.so : section 9 name ".rela.dyn" type RELA flags AX offset 0x3000 size 0x480 qtmetadata-executable.vrxcIf.so : section 10 name ".rela.plt" type RELA flags AX offset 0x3480 size 0x7e0 qtmetadata-executable.vrxcIf.so : section 11 name ".init" type PROGBITS flags AX offset 0x4000 size 0x1b qtmetadata-executable.vrxcIf.so : section 12 name ".plt" type PROGBITS flags AX offset 0x4020 size 0x550 qtmetadata-executable.vrxcIf.so : section 13 name ".plt.got" type PROGBITS flags AX offset 0x4570 size 0x8 qtmetadata-executable.vrxcIf.so : section 14 name ".text" type PROGBITS flags AX offset 0x4580 size 0x110e qtmetadata-executable.vrxcIf.so : section 15 name ".fini" type PROGBITS flags AX offset 0x5690 size 0xd qtmetadata-executable.vrxcIf.so : section 16 name ".rodata" type PROGBITS flags AX offset 0x6000 size 0x473 qtmetadata-executable.vrxcIf.so : section 17 name ".qtversion" type PROGBITS flags AX offset 0x6478 size 0x10 qtmetadata-executable.vrxcIf.so : section 18 name ".qtmetadata" type PROGBITS flags AX offset 0x64a0 size 0x19b qtmetadata-executable.vrxcIf.so : found .qtmetadata section qtmetadata-writable.stzwrk.so : ELF 64-bit LSB (GNU/Linux), version 1, shared library or PIC executable, x86-64 Change-Id: I42eb903a916645db9900fffd16a4437af9728eea Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Q{Elf,Mach}Parser: harmonize the arguments passedThiago Macieira2021-10-041-3/+4
| | | | | | | | | | | | | | Both functions took a QString for the input file name, but while the ELF parser had an optional QLibrary pointer (which was never null) where to store the error string, the Mach-O parser received a pointer to a QString. So make both of them take a single in/out QString pointer, which has the file name on input and is cheap for us because of COW. Drive-by fix the name of the static function in qmachparser.cpp from "ns" (which stood for "not suitable") to "notfound". Change-Id: I3eb1bd30e0124f89a052fffd16a8182f4f8541c3 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Q{Elf,Mach}Parser: simplify the return codesThiago Macieira2021-09-241-33/+33
| | | | | | | | | | | | | | | | | The multi-state return code was a legacy of how Arvid wrote the ELF parser code back in the day, the fact that it scanned for two different types of plugins in Qt 4 and that the metadata could exist in different places. None of that matters nowadays: who cares if the file is a corrupt binary, not a valid binary, does not have the right architecture, or has no suitable section? It's not a plugin, period. The Qt 4 plugin mechanism was removed for Qt 5.0 in commit 7443895857fdaee132c8efc643e471f02b3d0fa4 ("Remove support for Qt 4 style plugins"). Change-Id: I42eb903a916645db9900fffd16a442d800399b98 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* tst_qplugin{,loader}: make it pass on MacsThiago Macieira2021-09-241-6/+6
| | | | | | | | | | | | | | | Debug builds were broken. WARNING: tst_QPluginLoader::errorString() testdata bin/libtst_qpluginloaderlib.dylib could not be located! $ ls -l bin total 112 -rwxr-xr-x 1 tjmaciei staff 77296 Sep 14 08:46 libtheplugin_debug.dylib -rwxr-xr-x 1 tjmaciei staff 33408 Sep 14 08:46 libtst_qpluginloaderlib_debug.dylib Pick-to: 6.2 Change-Id: I42eb903a916645db9900fffd16a4bb0a51ef967c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace QtTest headers with QTestDavid Skoland2020-12-221-1/+3
| | | | | | | | | | | Complete search and replace of QtTest and QtTest/QtTest with QTest, as QtTest includes the whole module. Replace all such instances with correct header includes. See Jira task for more discussion. Fixes: QTBUG-88831 Change-Id: I981cfae18a1cabcabcabee376016b086d9d01f44 Pick-to: 6.0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix warning when comparing qsizetype to result of sizeofTor Arne Vestbø2020-07-261-1/+1
| | | | | | | warning: comparison of integers of different signs: 'qsizetype' (aka 'long long') and 'unsigned long' Change-Id: I03acb1f7aed782169a0a42cd8afc84b85991cd1e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Avoid initializing QFlags with 0 or nullptr in testsFriedemann Kleint2019-11-261-1/+1
| | | | | | | Amends qtbase/af2daafde72db02454d24b7d691aa6861525ab99. Change-Id: Ib5d17611e43e7ab2c63c7f0587f549377f262e32 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-07-051-1/+2
|\ | | | | | | | | | | | | | | Conflicts: .qmake.conf qmake/generators/makefile.cpp Change-Id: Ifb2633a69d0bf8cdf12d799c6259beefc279c49e
| * QPluginLoader: fix failing test comparing the Qt versionThiago Macieira2019-07-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | We stopped storing the patch release number of Qt in the plugin metadata in commit 7bd79b3cffbbbece23867c5e111a3dd2ebcad016 (5.13), to make it simpler to parse the validity of plugins before decoding the CBOR payload. Fixes: QTBUG-76855 Change-Id: I6aed4df6a12e43c3ac8efffd15adbbf83e928866 Reviewed-by: Liang Qi <liang.qi@qt.io>
* | moc: Add a standard way of specifying a URI as part of Q_PLUGIN_METADATAUlf Hermann2019-04-111-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | Usually, when you load a plugin, you don't want to load just any plugin that fulfills a given interface, but rather a specific one. When loading dynamic plugins you can differentiate the plugins by file name. This doesn't work in the static case, and file names are also separate from the plugin metadata shipped inside the plugin files. To solve this problem, different hacks have been developed in various places. QML extension plugins add a special property "uri" via the -M option of moc, QML debug plugins expect you to add a json file with an array of "Keys", Qt Creator plugins have a "Name" in their json files, etc. By allowing the identifier for the plugin to be specified inline with the metadata declaration we can make many of the above workarounds obsolete and provide a clean way for users to find their plugins. Task-number: QTBUG-74775 Change-Id: Ie2af16c49d4c5aa5a77fab0fae1e0a4449bd7a39 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-09-111-0/+8
|\ | | | | | | Change-Id: I1df9adea124326ef7c7802839eb93efc4302b287
| * moc: Fix compilation of text strings containing non-ASCIIThiago Macieira2018-09-101-0/+8
| | | | | | | | | | | | | | | | | | | | | | On platforms where char is signed, like x86, the following is an error (narrowing conversion): unsigned char x[] = { '\xc3' }; Change-Id: I495bc19409f348069f5bfffd15518f9ef4e43faf Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QPluginLoader: pave the way for Qt 6 plugin meta dataThiago Macieira2018-08-211-1/+36
|/ | | | | | | We want to store the metadata size and get it from the plugin in Qt 6. Change-Id: Ieb48f7c0dd0e4e0fb35efffd153bebc2914d9a3c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Enable QPluginLoader test for static buildsSimon Hausmann2018-08-031-0/+31
| | | | | | | | | | | The majority of tests use QPluginLoader::setFileName implicitly, which refuses to do any work in static builds. Therefore the majority of tests are skipped. But in the future we'll get tests here that for example use QPluginLoader::staticPlugins() and for that we want to include the sub-directory in the build and test run. Change-Id: Ib8ec274e22ac8050feaca8967eb8626b53876b92 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* tst_qpluginloader: Fix preprocessor conditionOliver Wolff2018-07-271-1/+1
| | | | | Change-Id: Icb7767cb6b0e091a21196518d3908a810970592a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QPluginLoader: limit the amount of memory used when scanning pluginsThiago Macieira2018-07-141-2/+2
| | | | | | | | | | | | | | | | | | | When using actual memory allocation, limit to 64 MB, not the full file size. On most systems, the memory map technique will work, so this won't even be tried. In any case, we don't need the fix for the OOM situation that was applied in commit e211ab76d766878b4dbe88901b9a7a4a70ce7332. As for the memory mapping technique, this commit limits the allocation to reasonable values given the virtual memory addressing space. Half a gigabyte is probably acceptable on 32-bit systems, where there should be a contiguous space for the OS to allocate the file in. This commit also fixes an overflow when converting from qint64 of the file size to ulong (32-bit on 32-bit platforms and on Windows). For 64-bit systems, we currently limit to 1 TB. Change-Id: I117816bf0f5e469b8d34fffd153dc1705a8eedc4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* QtCore: Remove Windows CE.Friedemann Kleint2016-03-301-5/+0
| | | | | | | | | Remove QSysInfo::WV_CE_5/6 enumeration values, #ifdef sections for Q_OS_WINCE and wince .pro file clauses in library, examples and tests. Task-number: QTBUG-51673 Change-Id: Ib63463445f3a26e04d018b193e4655030002f5f9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add Intel copyright to files that Intel has had non-trivial contributionThiago Macieira2016-01-211-0/+1
| | | | | | | | | I wrote a script to help find the files, but I reviewed the contributions manually to be sure I wasn't claiming copyright for search & replace, adding Q_DECL_NOTHROW or adding "We mean it" headers. Change-Id: I7a9e11d7b64a4cc78e24ffff142b506368fc8842 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-211-17/+12
| | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* tests/auto/corelib: Remove some placeholder formatting.Friedemann Kleint2015-10-221-2/+4
| | | | | | | | Use QByteArray/QString addition instead in loops and for test row names. Change-Id: Ieffb429efdc14aa5932b3fcdef5a18e13a62d35f Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@theqtcompany.com>
* Fix building tst_QPluginLoader on OS X, non-devel buildsFrederik Gladhorn2015-05-131-2/+2
| | | | | | | | | QMachOParser is defined in the private header that only gets included in developer-builds. Thus ifdef its usage out, not just the header inclusion. Change-Id: I1e0059787be6eb70bd1661c7814e69eee7c5b2ee Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Allow passing absolute paths without file extension to QPluginLoaderAlex Richardson2015-02-261-0/+15
| | | | | | | | | Previously QPluginLoader("/foo/bar/plugin").fileName() would return an empty string even if /foo/bar/plugin.so existed, now we correctly find that file. Change-Id: Ibf6ba329e92956de45f695be65773caacf14050a Reviewed-by: David Faure <david.faure@kdab.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Updated corelib's unit tests to use QSignalSpy's functor constructorKeith Gardner2014-05-081-3/+3
| | | | | | | | | The intent is to provide compile time validation of signals and to help detect signal overloading in the future. Change-Id: I9d5d46ed4b70c5d0cd407deb5928b1e76d37e007 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
* Make the Mach-O size checking a little more robustThiago Macieira2013-07-201-0/+5
| | | | | | | | | | | | | | | | | It's not necessary to check at every point if we know the minimum file size: it must contain at least the header, one segment (__TEXT) and one section (qtmetadata). Most files have more than one segment and more than one loader command, so this check does not mean we can eliminate the checks further down. Also be more resilient against corruptions in the header data: check not only the additions, but the values themselves. For example, an offset + size addition could be smaller than the file size when the addition overflows in 32-bit. Another thing is that the cmdsize fields could be corrupt too. Change-Id: I7968a769c1cbe9150270c91823cafc4f8f833876 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add a Mach-O decoder to the QPluginLoaderThiago Macieira2013-07-201-0/+73
| | | | | | | | | | | | | | | | | | | | | | | We already had an ELF decoder, which helped us greatly to find the metadata and that catches most Unix systems (Solaris, QNX, HP-UXi, and all of the free Unixes). On other Unix systems, aside from Mac OS X, we simply scanned the entire file for the signature. On Windows, even without a COFF-PE decoder, we use a LoadLibrary trick to load the plugin without loading the dependent libraries. In most cases, that works. Unfortunately, on Mac OS X we didn't have a decoder and nor could we do the file scan: because Mac OS X binaries could be fat binaries, we wouldn't know which architecture's signature we had found. No more. This adds a full Mach-O decoder to QtCore. It is also capable of finding the boundaries of the architecture's binary, but that functionality is disabled since all Qt 5 plugins have plugin metadata sections. Change-Id: I2d5c04c5ecf024864b8a43f31ab6b7e6c5eae9ce Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Make sure that the reference count for plugins is kept correctlyThiago Macieira2013-02-271-1/+48
| | | | | | | | | | | | | | | | | | | | For systems where the Unix signature checker isn't enabled (read: Mac and Windows), QPluginLoader must actually load the plugin to query for the metadata. On Mac it even tried to keep the library loaded to avoid unloading and reloading again when the user calls load(). However, that plus the fact that it was calling load_sys() (on Mac) meant that it would bypass the reference count checking. And on all Unix, if a library-that-wasnt-a-plugin was already loaded by way of a QLibrary, it would have an effect of unloading said library. So remove the "caching" of the library. We should instead invest time to write a proper Mach-O binary decoder. Task-number: QTBUG-29776 Change-Id: Iebbddabe60047aafedeced21f26a170f59656757 Reviewed-by: Liang Qi <liang.qi@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Autotest: check that the plugin was actually unloaded in QPluginLoaderThiago Macieira2013-02-271-0/+20
| | | | | Change-Id: I66d26da4e86add244d37ff670ad79ff2aff17ca1 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QPluginLoader: fix loading of plugins with a relative file nameDavid Faure2012-12-041-5/+24
| | | | | | | | | | | This makes QT_PLUGIN_PATH / QCoreApplication::libraryPaths() actually work, as a search path for plugins, when apps look for a specific plugin by name. To make it possible to write portable code (unlike the current QPluginLoader unittest), let QPluginLoader figure out the extension, too. Change-Id: I895d597d7cb05ded268734bc5f313f32d8d12cb9 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>