Skip to content

Commit

Permalink
Merge pull request #16362 from knn-k/aarch64macos_ffiFix
Browse files Browse the repository at this point in the history
AArch64 macOS: Fix alignment of structs passed in the stack
  • Loading branch information
gacholio authored Nov 28, 2022
2 parents 92e9a2c + f23edd1 commit d012930
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions runtime/libffi/aarch64/ffi.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

/*
* ===========================================================================
* Copyright (c) 2022, 2022 IBM Corp. and others
* ===========================================================================
*/

#if defined(__aarch64__) || defined(__arm64__)|| defined (_M_ARM64)
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -792,7 +798,14 @@ ffi_call_int (ffi_cif *cif, void (*fn)(void), void *orig_rvalue,
adjusted and the argument is copied to memory at the
adjusted NSAA. */
state.ngrn = N_X_ARG_REG;
#if defined (__APPLE__)
dest = allocate_to_stack (&state, stack,
(ty->alignment < 8) ? 8 : ty->alignment,
s);
state.nsaa = FFI_ALIGN (state.nsaa, 8);
#else
dest = allocate_to_stack (&state, stack, ty->alignment, s);
#endif
}
}
memcpy (dest, a, s);
Expand Down

0 comments on commit d012930

Please sign in to comment.