diff options
Diffstat (limited to 'src/corelib/plugin/qelfparser_p.cpp')
-rw-r--r-- | src/corelib/plugin/qelfparser_p.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp index b0c23d58b6..78c9be0e56 100644 --- a/src/corelib/plugin/qelfparser_p.cpp +++ b/src/corelib/plugin/qelfparser_p.cpp @@ -35,7 +35,7 @@ static constexpr bool IncludeValidityChecks = true; # define QELFPARSER_DEBUG #endif #if defined(QELFPARSER_DEBUG) -static Q_LOGGING_CATEGORY(lcElfParser, "qt.core.plugin.elfparser") +Q_STATIC_LOGGING_CATEGORY(lcElfParser, "qt.core.plugin.elfparser") # define qEDebug qCDebug(lcElfParser) << reinterpret_cast<const char16_t *>(error.errMsg->constData()) << ':' #else # define qEDebug if (false) {} else QNoDebug() @@ -54,6 +54,10 @@ static Q_LOGGING_CATEGORY(lcElfParser, "qt.core.plugin.elfparser") # define PT_GNU_PROPERTY 0x6474e553 #endif +#ifndef PN_XNUM +# define PN_XNUM 0xffff +#endif + QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wunused-const-variable") @@ -107,14 +111,22 @@ struct ElfMachineCheck static const Elf32_Half ExpectedMachine = #if 0 // nothing +#elif defined(Q_PROCESSOR_ALPHA) + EM_ALPHA #elif defined(Q_PROCESSOR_ARM_32) EM_ARM #elif defined(Q_PROCESSOR_ARM_64) EM_AARCH64 #elif defined(Q_PROCESSOR_BLACKFIN) EM_BLACKFIN +#elif defined(Q_PROCESSOR_HPPA) + EM_PARISC #elif defined(Q_PROCESSOR_IA64) EM_IA_64 +#elif defined(Q_PROCESSOR_LOONGARCH) + EM_LOONGARCH +#elif defined(Q_PROCESSOR_M68K) + EM_68K #elif defined(Q_PROCESSOR_MIPS) EM_MIPS #elif defined(Q_PROCESSOR_POWER_32) @@ -128,10 +140,8 @@ struct ElfMachineCheck #elif defined(Q_PROCESSOR_SH) EM_SH #elif defined(Q_PROCESSOR_SPARC_V9) -# warning "Please confirm that this is correct for Linux and Solaris" EM_SPARCV9 #elif defined(Q_PROCESSOR_SPARC_64) -# warning "Please confirm that this is correct for Linux and Solaris" EM_SPARCV9 #elif defined(Q_PROCESSOR_SPARC) EM_SPARC @@ -329,7 +339,7 @@ Q_DECL_UNUSED Q_DECL_COLD_FUNCTION static QDebug &operator<<(QDebug &d, ElfHeade case ELFOSABI_SYSV: d << " (SYSV"; break; case ELFOSABI_HPUX: d << " (HP-UX"; break; case ELFOSABI_NETBSD: d << " (NetBSD"; break; - case ELFOSABI_GNU: d << " (GNU/Linux"; break; + case ELFOSABI_LINUX: d << " (GNU/Linux"; break; case ELFOSABI_SOLARIS: d << " (Solaris"; break; case ELFOSABI_AIX: d << " (AIX"; break; case ELFOSABI_IRIX: d << " (IRIX"; break; @@ -373,19 +383,27 @@ Q_DECL_UNUSED Q_DECL_COLD_FUNCTION static QDebug &operator<<(QDebug &d, ElfHeade switch (r.machine) { // list definitely not exhaustive! case EM_NONE: d << ", no machine"; break; + case EM_ALPHA: d << ", Alpha"; break; + case EM_68K: d << ", MC68000"; break; case EM_ARM: d << ", ARM"; break; case EM_AARCH64: d << ", AArch64"; break; #ifdef EM_BLACKFIN case EM_BLACKFIN: d << ", Blackfin"; break; #endif case EM_IA_64: d << ", IA-64"; break; +#ifdef EM_LOONGARCH + case EM_LOONGARCH: d << ", LoongArch"; break; +#endif case EM_MIPS: d << ", MIPS"; break; + case EM_PARISC: d << ", HPPA"; break; case EM_PPC: d << ", PowerPC"; break; case EM_PPC64: d << ", PowerPC 64-bit"; break; #ifdef EM_RISCV case EM_RISCV: d << ", RISC-V"; break; #endif +#ifdef EM_S390 case EM_S390: d << ", S/390"; break; +#endif case EM_SH: d << ", SuperH"; break; case EM_SPARC: d << ", SPARC"; break; case EM_SPARCV9: d << ", SPARCv9"; break; @@ -525,6 +543,8 @@ static bool preScanProgramHeaders(QByteArrayView data, const ErrorMaker &error) // first, validate the extent of the full program header table T::Word e_phnum = header->e_phnum; + if (e_phnum == PN_XNUM) + return error(QLibrary::tr("unimplemented: PN_XNUM program headers")), false; T::Off offset = e_phnum * sizeof(T::Phdr); // can't overflow due to size of T::Half if (qAddOverflow(offset, header->e_phoff, &offset) || offset > size_t(data.size())) return error(QLibrary::tr("program header table extends past the end of the file")), false; @@ -679,7 +699,7 @@ static QLibraryScanResult scanSections(QByteArrayView data, const ErrorMaker &er // sections aren't allowed to extend past the end of the file, unless // they are NOBITS sections if (shdr->sh_type == SHT_NOBITS) - continue;; + continue; if (T::Off end; qAddOverflow(shdr->sh_offset, shdr->sh_size, &end) || end > size_t(data.size())) { return error(QLibrary::tr("section contents extend past the end of the file")); |