summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin/qelfparser_p.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/plugin/qelfparser_p.cpp')
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index 54e5a19e2e..78c9be0e56 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -20,11 +20,6 @@
# error "Need ELF header to parse plugins."
#endif
-// Support older ELFOSABI define for GNU/Linux
-#if !defined(ELFOSABI_GNU) && defined(ELFOSABI_LINUX)
-# define ELFOSABI_GNU ELFOSABI_LINUX
-#endif
-
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
@@ -40,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()
@@ -59,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")
@@ -340,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;
@@ -402,7 +401,9 @@ Q_DECL_UNUSED Q_DECL_COLD_FUNCTION static QDebug &operator<<(QDebug &d, ElfHeade
#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;
@@ -542,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;
@@ -696,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"));