Extend return values < 32-bit on macOS ARM64
commit239cc612b478d82d3dd73e3a8d5be310b781a5f0
authorStephan Bergmann <sbergman@redhat.com>
Wed, 13 Oct 2021 09:28:34 +0000 (13 11:28 +0200)
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Wed, 13 Oct 2021 11:43:09 +0000 (13 13:43 +0200)
tree152a87922f963880c661c6a935f42980a09594ed
parent4e1f5b5eaddac6ff4b3028074edc8f6886d64c3f
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 <tml@collabora.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Tested-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx