summaryrefslogtreecommitdiffstats
path: root/tests/auto/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 /tests/auto/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 'tests/auto/corelib/plugin')
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/fakeplugin.cpp4
1 files changed, 3 insertions, 1 deletions
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);