Change in libffi behaviour -- large struct args

Anthony Green green@moxielogic.com
Sun May 29 14:09:36 GMT 2022


Interestingly, the powerpc-unknown-eabisim port mostly got this right,
except that it never passed small structs in registers as it should.
Does anybody care about the 32-bit embedded Power port anymore?

AG

On Sat, May 28, 2022 at 9:40 AM Anthony Green <green@moxielogic.com> wrote:
>
> As has been discussed in various github PRs recently, I'd like to
> change libffi's behaviour regarding large struct arguments.
>
> When passing a struct by value, most (all?) ABI definitions ask that
> you try to fit structs up to a certain size into registers, and if
> they are too large, make a copy and pass them on the stack.
> Libffi's current behaviour is to fit small structs in registers, but
> then if something is too large, pass it by reference, leaving it as an
> exercise for the user to make their own copies.   Many libffi users,
> like cpython, do this special work themselves.   I don't like this
> because it exposes this ABI detail, the threshold for struct sizes, to
> the libffi caller.   Libffi should be making this copy itself.
>
> The struct_by_value_big.c test checks for this, and most ports fail
> today   Changing this behaviour won't introduce regressions for libffi
> users, and eventually they will be able to remove their special
> handling of large struct args.
>
> AG


More information about the Libffi-discuss mailing list