summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp14
-rw-r--r--src/corelib/plugin/qelfparser_p.h4
-rw-r--r--src/corelib/plugin/qlibrary.cpp2
-rw-r--r--src/corelib/plugin/qmachparser_p.h2
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp17
5 files changed, 23 insertions, 16 deletions
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index 6a83c94e20..ed973e4323 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -40,7 +40,7 @@
#include "qelfparser_p.h"
-#if defined (Q_OF_ELF) && __has_include(<elf.h>)
+#ifdef Q_OF_ELF
#include "qlibrary_p.h"
@@ -48,7 +48,13 @@
#include <qnumeric.h>
#include <qsysinfo.h>
-#include <elf.h>
+#if __has_include(<elf.h>)
+# include <elf.h>
+#elif __has_include(<sys/elf.h>)
+# include <sys/elf.h>
+#else
+# error "Need ELF header to parse plugins."
+#endif
QT_BEGIN_NAMESPACE
@@ -408,7 +414,9 @@ Q_DECL_UNUSED Q_DECL_COLD_FUNCTION static QDebug &operator<<(QDebug &d, ElfHeade
case EM_MIPS: d << ", MIPS"; 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
case EM_S390: d << ", S/390"; break;
case EM_SH: d << ", SuperH"; break;
case EM_SPARC: d << ", SPARC"; break;
@@ -790,4 +798,4 @@ QLibraryScanResult QElfParser::parse(QByteArrayView data, QString *errMsg)
QT_END_NAMESPACE
-#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
+#endif // Q_OF_ELF
diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h
index 42eb212ee1..5c8a0b700f 100644
--- a/src/corelib/plugin/qelfparser_p.h
+++ b/src/corelib/plugin/qelfparser_p.h
@@ -56,7 +56,7 @@
QT_REQUIRE_CONFIG(library);
-#if defined(Q_OF_ELF) && __has_include(<elf.h>)
+#ifdef Q_OF_ELF
QT_BEGIN_NAMESPACE
@@ -67,6 +67,6 @@ struct QElfParser
QT_END_NAMESPACE
-#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
+#endif // Q_OF_ELF
#endif // QELFPARSER_P_H
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index d4ee833554..9f89abdf01 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -203,7 +203,7 @@ static QLibraryScanResult qt_find_pattern(const char *s, qsizetype s_len, QStrin
More importantly, the pattern string may exist in the debug information due
to it being used in the plugin in the first place.
*/
-#if defined (Q_OF_ELF) && __has_include(<elf.h>)
+#if defined(Q_OF_ELF)
return QElfParser::parse({s, s_len}, errMsg);
#elif defined(Q_OF_MACH_O)
return QMachOParser::parse(s, s_len, errMsg);
diff --git a/src/corelib/plugin/qmachparser_p.h b/src/corelib/plugin/qmachparser_p.h
index 9e0375c6cb..216f4c3bb9 100644
--- a/src/corelib/plugin/qmachparser_p.h
+++ b/src/corelib/plugin/qmachparser_p.h
@@ -70,6 +70,6 @@ public:
QT_END_NAMESPACE
-#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
+#endif // defined(Q_OF_MACH_O)
#endif // QMACHPARSER_P_H
diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
index 8994835471..8c68cfde0d 100644
--- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp
@@ -94,14 +94,12 @@
# define PREFIX "lib"
#endif
-// Workaround for missing elf.h in QNX test environment
-// TODO: this can be removed after QTBUG-97833 has been solved
-#if defined(Q_OF_ELF) && defined(Q_OS_QNX) && !__has_include(<elf.h>)
-#undef Q_OF_ELF
+#if defined(Q_OF_ELF)
+#if __has_include(<elf.h>)
+# include <elf.h>
+#else
+# include <sys/elf.h>
#endif
-
-#if defined (Q_OF_ELF)
-# include <elf.h>
# include <memory>
# include <functional>
@@ -183,7 +181,7 @@ static std::unique_ptr<QTemporaryFile> patchElf(const QString &source, ElfPatche
if (QTest::currentTestFailed()) return; \
std::move(r); \
})
-#endif
+#endif // Q_OF_ELF
static QString sys_qualifiedLibraryName(const QString &fileName)
{
@@ -395,7 +393,8 @@ void tst_QPluginLoader::deleteinstanceOnUnload()
}
}
-#if defined (Q_OF_ELF)
+#if defined(Q_OF_ELF)
+
void tst_QPluginLoader::loadDebugObj()
{
#if !defined(QT_SHARED)