Open tyfkda opened 1 year ago
Unlike x64, aarch64 uses %x8 to pass the function result struct address:
%x8
typedef struct { long long x, y, z; } FooStruct; FooStruct return_struct(long long x, long long y, long long z) { FooStruct s = {.x = x, .y = y, .z = z}; return s; }
$ gcc -S -O2 -fno-asynchronous-unwind-tables ,foo/foo.c
.section __TEXT,__text,regular,pure_instructions .build_version macos, 13, 0 sdk_version 13, 3 .globl _return_struct ; -- Begin function return_struct .p2align 2 _return_struct: ; @return_struct .cfi_startproc ; %bb.0: stp x0, x1, [x8] str x2, [x8, #16] ret .cfi_endproc ; -- End function .subsections_via_symbols
Unlike x64, aarch64 uses
%x8
to pass the function result struct address: