summaryrefslogtreecommitdiffstats
path: root/src/corelib/plugin
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2021-11-03 13:23:59 -0700
committerAndrei Golubev <andrei.golubev@qt.io>2021-11-04 18:20:09 +0100
commit0ab3c5c2505dcfa684fd4a3961f24345de7e1d6f (patch)
tree090d1032249e57bee5c8c1f04abd58d139a12d20 /src/corelib/plugin
parent9f559699cc5dbba9ef8e6da06d2ed48a8b6729a6 (diff)
QPluginLoader/ELF: fix Clang ASan builds
Clang aligns the object at 32-byte boundaries even though we specifically asked for alignof(void*), so tell it not to sanitize the address of the plugin object. Tested with Clang 12 and 13. GCC seems not to be affected, even when ASan is enabled. If this doesn't work, we may need to accept reading a note that is improperly aligned. I don't think the output will be actually a correct note because the intra-note alignment will be wrong (I carefully chose the ELF note name so it would not require alignment, but that's only valid up to 8-byte alignments). Fixes: QTBUG-97941 Change-Id: Ice04365c72984d07a64dfffd16b422fe074d8a70 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/plugin')
-rw-r--r--src/corelib/plugin/qplugin.h10
1 files changed, 9 insertions, 1 deletions
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 <auto (&PluginMetaData)> 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