From 2bfa4b9960f283396427828deac6f194893cc811 Mon Sep 17 00:00:00 2001 From: Janne Juntunen Date: Wed, 3 Nov 2021 13:04:07 +0200 Subject: [PATCH] QNX: check and use elf.h from alternative location In QNX, instead of #include , we have to use #include since that file is placed in a subdirectory. Also removed the previous workaround. Fixes: QTBUG-97833 Change-Id: Id932a5eeb618a42c8778459cdfd8bb5bf903523c Reviewed-by: Thiago Macieira --- src/corelib/plugin/qelfparser_p.cpp | 14 +++++++++++--- src/corelib/plugin/qelfparser_p.h | 4 ++-- src/corelib/plugin/qlibrary.cpp | 2 +- src/corelib/plugin/qmachparser_p.h | 2 +- .../plugin/qpluginloader/tst_qpluginloader.cpp | 17 ++++++++--------- 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() +#ifdef Q_OF_ELF #include "qlibrary_p.h" @@ -48,7 +48,13 @@ #include #include -#include +#if __has_include() +# include +#elif __has_include() +# include +#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() +#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() +#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() -#undef Q_OF_ELF +#if defined(Q_OF_ELF) +#if __has_include() +# include +#else +# include #endif - -#if defined (Q_OF_ELF) -# include # include # include @@ -183,7 +181,7 @@ static std::unique_ptr 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)