]> git.ipfire.org Git - people/ms/gcc.git/commit
libffi: Fix up x86_64 classify_argument
authorJakub Jelinek <jakub@redhat.com>
Wed, 16 Jun 2021 08:45:27 +0000 (10:45 +0200)
committerJakub Jelinek <jakub@redhat.com>
Thu, 17 Jun 2021 05:58:26 +0000 (07:58 +0200)
commit346a0920bdcf47595fa1b7f0bbdf5992ba24f299
treec65c36f399bc2f572d3fda91d8e60f2e88eae2c3
parent5ece5ac99e804cccc3d8534d8871eb72e08edb06
libffi: Fix up x86_64 classify_argument

As the following testcase shows, libffi didn't handle properly
classify_arguments of structures at byte offsets not divisible by
UNITS_PER_WORD.  The following patch adjusts it to match what
config/i386/ classify_argument does for that and also ports the
PR38781 fix there (the second chunk).

This has been committed to upstream libffi already:
https://github.com/libffi/libffi/commit/5651bea284ad0822eafe768e3443c2f4d7da2c8f

2021-06-16  Jakub Jelinek  <jakub@redhat.com>

* src/x86/ffi64.c (classify_argument): For FFI_TYPE_STRUCT set words
to number of words needed for type->size + byte_offset bytes rather
than just type->size bytes.  Compute pos before the loop and check
total size of the structure.
* testsuite/libffi.call/nested_struct12.c: New test.

(cherry picked from commit 041f74177072df1d66502319205990a4d970c92a)
libffi/src/x86/ffi64.c
libffi/testsuite/libffi.call/nested_struct12.c [new file with mode: 0644]