bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx | 30 +++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
New commits: commit 239cc612b478d82d3dd73e3a8d5be310b781a5f0 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Wed Oct 13 11:28:34 2021 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Wed Oct 13 13:43:09 2021 +0200 Extend return values < 32-bit on macOS ARM64 <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Pass-Arguments-to-Functions-Correctly> only mentions function arguments, not return values in "The caller of a function is responsible for signing or zero-extending any argument with fewer than 32 bits. The standard ABI expects the callee to sign or zero-extend those arguments." But this appears to also be relevant for return values, where the callee apparently has to provide properly extended values: Without this change, in an --enable-optimized build, e.g. selecting "Tools - Macros - Organize Macros - BeanShell... - LibreOffice Macros - Capitalize - capitalize.bsh" would not enable the "Run" button, as in SvxScriptOrgDialog::CheckButtons (cui/source/dialogs/scriptdlg.cxx) node->getType() (which returns a sal_Int16 value, and which calls DefaultBrowseNode::getType, scripting/source/provider/BrowseNodeFactoryImpl.cxx, which in turn calls m_xWrappedBrowseNode->getType() on a proxied Java object via the UNO bridge) would return a value in r0 with bits > 16 left with random values, while the calling code assumes them to be zero (and exploits that violated assumption with --enable-optimized). Change-Id: Ic99dd9e62b49b44e13cdde6158bef7e2296547f2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123550 Reviewed-by: Tor Lillqvist <t...@collabora.com> Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> Tested-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx index b31d87655d0c..775a4aff6962 100644 --- a/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx @@ -291,15 +291,43 @@ void call( switch (rtd == nullptr ? typelib_TypeClass_VOID : rtd->eTypeClass) { case typelib_TypeClass_VOID: break; +#if defined MACOSX case typelib_TypeClass_BOOLEAN: + assert(rtd->nSize == sizeof (bool)); + *gpr = static_cast<unsigned long>(*static_cast<bool *>(retin)); + assert(!retConv); + break; case typelib_TypeClass_BYTE: + assert(rtd->nSize == sizeof (sal_Int8)); + *gpr = *static_cast<sal_Int8 *>(retin); + assert(!retConv); + break; case typelib_TypeClass_SHORT: + assert(rtd->nSize == sizeof (sal_Int16)); + *gpr = *static_cast<sal_Int16 *>(retin); + assert(!retConv); + break; case typelib_TypeClass_UNSIGNED_SHORT: + assert(rtd->nSize == sizeof (sal_uInt16)); + *gpr = *static_cast<sal_uInt16 *>(retin); + assert(!retConv); + break; + case typelib_TypeClass_CHAR: + assert(rtd->nSize == sizeof (sal_Unicode)); + *gpr = *static_cast<sal_Unicode *>(retin); + assert(!retConv); + break; +#else + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_CHAR: +#endif case typelib_TypeClass_LONG: case typelib_TypeClass_UNSIGNED_LONG: case typelib_TypeClass_HYPER: case typelib_TypeClass_UNSIGNED_HYPER: - case typelib_TypeClass_CHAR: case typelib_TypeClass_ENUM: std::memcpy(gpr, retin, rtd->nSize); assert(!retConv);