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>