summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qelfparser_p.h
Commit message (Collapse)AuthorAgeFilesLines
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | 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>
* QNX: check and use elf.h from alternative locationJanne Juntunen2021-11-301-2/+2
| | | | | | | | | | | 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>
* QElfParser: rewrite using elf.hThiago Macieira2021-10-061-25/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | 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-3/+2
| | | | | | | | | | | | | | | | | 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>
* QElfParser: remove one more unnecesary variable from the ELF parserThiago Macieira2021-09-141-1/+0
| | | | | | | | There's no need to keep this variable in the class. Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a35775d56d3e45 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QElfParser: don't attempt to parse ELF files of the wrong endiannessThiago Macieira2021-09-141-10/+0
| | | | | | | | | | | | | | There's no sense in continuing to parse. We'll never be able to load such a plugin anyway. This simplifies the code generation a lot because now all the read<T> calls become unconditional qFromUnaligned<T>, which is just a memcpy(), which for primitive types the compiler will simply emit a memory load into a register. Task-number: QTBUG-96327 Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a3574daf010635 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QElfParser: don't use int for the enumThiago Macieira2021-09-131-2/+2
| | | | | | | | An enum shows the proper values in the debugger... Pick-to: 6.2 Change-Id: I2de1b4dfacd443148279fffd16a3a5848196983c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Whitespace cleanup in corelib/ mimetypes, plugin and threadAllan Sandfeld Jensen2020-10-211-2/+2
| | | | | | | Done with selective application of clang-format Change-Id: Iee6bf2426de81356b6d480629ba972f980b6d93d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix integer overflow in very long sections in ELF objectsThiago Macieira2018-09-151-1/+1
| | | | | | | | | | | | The source is an ElfXX_Off, which is an unsigned 32- or 64-bit. That means any section bigger than 2 GB would cause an overflow when we assigned in m_stringTableFileOffset = strtab.offset; Change-Id: Ib47c56818178458a88b4fffd15546bd47a89894e Fixes: QTBUG-70560 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QPluginLoader: limit the amount of memory used when scanning pluginsThiago Macieira2018-07-141-1/+1
| | | | | | | | | | | | | | | | | | | 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>
* Use QT_CONFIG(library) instead of QT_NO_LIBRARYUlf Hermann2017-03-061-2/+2
| | | | | | | | | | | | | For the windows file system engine, we add an extra macro to use library loading if configured to do so, but avoid it on WinRT, as none of the symbols would be found. We also QT_REQUIRE_CONFIG(library) in the library headers and exclude the sources from the build if library loading is disabled. This, in turn, makes it necessary to clean up some header inclusions. Change-Id: I2b152cb5b47a2658996b6f4702b038536a5704ec Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* Make sure all private headers in Qt Core include qglobal_p.hThiago Macieira2016-06-251-1/+1
| | | | | | | | | | | | The rule was: - if the header included qglobal.h, turn that into qglobal_p.h - otherwise, insert the #include after the "We mean it" warning qglobal_p.h currently only includes qglobal.h. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use void instead of uchar in the endian-swapping function parametersv5.7.0-rc1Thiago Macieira2016-05-261-2/+2
| | | | | | | | | This allows us to pass pointers to storage that is not an array of uchar, which it hardly ever is. Change-Id: Ifea6e497f11a461db432ffff14490d2c2df21906 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.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>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb 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>
* Remove support for Qt 4 style pluginsLars Knoll2012-06-061-1/+1
| | | | | | | | | | The new plugin format allows us to avoid loading the plugins in all cases. Remove the old format, as we could get bad behavior with the old format if Qt would try to dlopen a Qt 4.x plugin. Change-Id: I2193e6874d6cca3c0b12298c2b9beb4105a42fd5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QElfParser: fix type of sh_sizePino Toscano2012-05-151-1/+1
| | | | | | | | | The type of the sh_size field of a section header is either Elf32_Word or Elf64_Xword, so the type used cannot be qelfword_t (always 32 bits) but qelfoff_t. Change-Id: Ia380b6823913fee7a96b39f742630ae3a9ca0cb8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Arvid Picciani <arvid.picciani@nokia.com>
* Implement new plugin mechanismLars Knoll2012-02-151-1/+1
| | | | | | | | | | | | | | moc can now embed meta information about the plugin inside the plugin itself. This information can be queried by Qt without having to load the plugin. Source compatibility with the old plugin loading mechanism is still there, but will be removed before Qt 5.0. Change-Id: I03e4196ddfed07d0fe94acca40d5de8a6ce7f920 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+108
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12