diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index 5f4ef81bb6..35af6205cc 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -199,7 +199,15 @@ template class QPluginMetaDataV2 # define QT_PLUGIN_METADATAV2_SECTION using Payload = StaticPayload; #elif defined(Q_OF_ELF) -# define QT_PLUGIN_METADATAV2_SECTION __attribute__((section(".note.qt.metadata"), used, aligned(alignof(void*)))) +# ifdef Q_CC_CLANG +// the metadata section doesn't work well with clang's sanitizer - QTBUG-97941 +# define QT_PLUGIN_METADATAV2_SECTION \ + __attribute__((section(".note.qt.metadata"), used, aligned(alignof(void *)), \ + no_sanitize("address"))) +# else +# define QT_PLUGIN_METADATAV2_SECTION \ + __attribute__((section(".note.qt.metadata"), used, aligned(alignof(void *)))) +# endif using Payload = ElfNotePayload; #else # define QT_PLUGIN_METADATAV2_SECTION QT_PLUGIN_METADATA_SECTION diff --git a/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp b/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp index 6d758f23c9..c1b939bf3e 100644 --- a/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp @@ -50,7 +50,9 @@ static constexpr bool IsDebug = false; #endif #if defined(__ELF__) && PLUGIN_VERSION >= 1 -__attribute__((section(".note.qt.metadata"), used, aligned(4))) +// GCC will produce: +// fakeplugin.cpp:64:3: warning: ‘no_sanitize_address’ attribute ignored [-Wattributes] +__attribute__((section(".note.qt.metadata"), used, no_sanitize("address"), aligned(sizeof(void*)))) static const struct { unsigned n_namesz = sizeof(name); unsigned n_descsz = sizeof(payload);