summaryrefslogtreecommitdiff
path: root/bridges
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-27 19:51:59 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-01-28 15:49:45 +0100
commitf921a66d31ec25afe618900f41001472a1a9dc46 (patch)
tree39122ac6989488d0b461b052040400e8101e8c8f /bridges
parentdee3cff90d5d5948e1f8dcba084f192af2e5eb07 (diff)
ofz: MemorySanitizer: extend use-of-uninitialized-value bridge workaround
Change-Id: I84f458b540e2e43cb3b4a06f4353e37ee2b7da2f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162646 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'bridges')
-rw-r--r--bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx25
1 files changed, 16 insertions, 9 deletions
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx
index bf3e7f388108..e0bb1d54a56f 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/callvirtualmethod.cxx
@@ -27,11 +27,16 @@
#include "abi.hxx"
#include "callvirtualmethod.hxx"
-#if defined(__has_feature)
-# if __has_feature(memory_sanitizer)
-# include <sanitizer/msan_interface.h>
-# define MEMORY_SANITIZER
-# endif
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
+#if __has_feature(memory_sanitizer)
+# include <sanitizer/msan_interface.h>
+ // In the absence of a better idea just unpoison this
+# define MSAN_UNPOISON_RETURN_REGISTER() __msan_unpoison(pRegisterReturn, pReturnTypeRef->pType->nSize)
+#else
+# define MSAN_UNPOISON_RETURN_REGISTER()
#endif
// The call instruction within the asm block of callVirtualMethod may throw
@@ -142,30 +147,32 @@ void CPPU_CURRENT_NAMESPACE::callVirtualMethod(
case typelib_TypeClass_HYPER:
case typelib_TypeClass_UNSIGNED_HYPER:
*static_cast<sal_uInt64 *>( pRegisterReturn ) = data.rax;
+ MSAN_UNPOISON_RETURN_REGISTER();
break;
case typelib_TypeClass_LONG:
case typelib_TypeClass_UNSIGNED_LONG:
case typelib_TypeClass_ENUM:
*static_cast<sal_uInt32 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt32*>( &data.rax );
+ MSAN_UNPOISON_RETURN_REGISTER();
break;
case typelib_TypeClass_CHAR:
case typelib_TypeClass_SHORT:
case typelib_TypeClass_UNSIGNED_SHORT:
*static_cast<sal_uInt16 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt16*>( &data.rax );
+ MSAN_UNPOISON_RETURN_REGISTER();
break;
case typelib_TypeClass_BOOLEAN:
case typelib_TypeClass_BYTE:
*static_cast<sal_uInt8 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt8*>( &data.rax );
+ MSAN_UNPOISON_RETURN_REGISTER();
break;
case typelib_TypeClass_FLOAT:
*static_cast<float *>(pRegisterReturn) = *reinterpret_cast<float *>(&data.xmm0);
+ MSAN_UNPOISON_RETURN_REGISTER();
break;
case typelib_TypeClass_DOUBLE:
-#if defined(MEMORY_SANITIZER)
- // In the absence of a better idea just unpoison this
- __msan_unpoison(&data.xmm0, sizeof(data.xmm0));
-#endif
*static_cast<double *>( pRegisterReturn ) = data.xmm0;
+ MSAN_UNPOISON_RETURN_REGISTER();
break;
default:
{